]>
Commit | Line | Data |
---|---|---|
4b123bb9 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: html.i | |
3 | // Purpose: SWIG definitions of html classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
d14a1e28 | 7 | // Created: 25-Nov-1998 |
4b123bb9 | 8 | // RCS-ID: $Id$ |
d14a1e28 | 9 | // Copyright: (c) 2003 by Total Control Software |
4b123bb9 HH |
10 | // Licence: wxWindows license |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module html | |
15 | ||
16 | %{ | |
d14a1e28 RD |
17 | #include "wx/wxPython/wxPython.h" |
18 | #include "wx/wxPython/pyclasses.h" | |
19 | #include "wx/wxPython/pyistream.h" | |
20 | #include "wx/wxPython/printfw.h" | |
21 | ||
4b123bb9 | 22 | #include <wx/html/htmlwin.h> |
dc2f8a65 | 23 | #include <wx/html/htmprint.h> |
d14a1e28 | 24 | #include <wx/html/helpctrl.h> |
4b123bb9 | 25 | |
1e4a197e | 26 | |
d14a1e28 | 27 | DECLARE_DEF_STRING(EmptyString); |
137b5242 RD |
28 | static const wxChar* wxHtmlWindowNameStr = wxT("htmlWindow"); |
29 | DECLARE_DEF_STRING(HtmlWindowNameStr); | |
137b5242 RD |
30 | static const wxChar* wxHtmlPrintoutTitleStr = wxT("Printout"); |
31 | DECLARE_DEF_STRING(HtmlPrintoutTitleStr); | |
137b5242 RD |
32 | static const wxChar* wxHtmlPrintingTitleStr = wxT("Printing"); |
33 | DECLARE_DEF_STRING(HtmlPrintingTitleStr); | |
d14a1e28 | 34 | |
137b5242 RD |
35 | %} |
36 | ||
0f66a9f3 | 37 | //--------------------------------------------------------------------------- |
e166644c | 38 | |
d14a1e28 RD |
39 | %import windows.i |
40 | %pythoncode { wx = core } | |
41 | ||
42 | %include _html_rename.i | |
43 | ||
44 | ||
45 | // TODO: Split this file into multiple %included files that coresponds to the | |
46 | // wx/html include files (more or less.) | |
47 | ||
48 | //--------------------------------------------------------------------------- | |
49 | //--------------------------------------------------------------------------- | |
50 | %newgroup | |
51 | ||
52 | ||
e166644c | 53 | enum { |
9d8bd15f RD |
54 | wxHTML_ALIGN_LEFT, |
55 | wxHTML_ALIGN_CENTER, | |
56 | wxHTML_ALIGN_RIGHT, | |
57 | wxHTML_ALIGN_BOTTOM, | |
58 | wxHTML_ALIGN_TOP, | |
59 | ||
60 | wxHTML_CLR_FOREGROUND, | |
61 | wxHTML_CLR_BACKGROUND, | |
62 | ||
63 | wxHTML_UNITS_PIXELS, | |
64 | wxHTML_UNITS_PERCENT, | |
65 | ||
66 | wxHTML_INDENT_LEFT, | |
67 | wxHTML_INDENT_RIGHT, | |
68 | wxHTML_INDENT_TOP, | |
69 | wxHTML_INDENT_BOTTOM, | |
70 | ||
71 | wxHTML_INDENT_HORIZONTAL, | |
72 | wxHTML_INDENT_VERTICAL, | |
73 | wxHTML_INDENT_ALL, | |
74 | ||
75 | wxHTML_COND_ISANCHOR, | |
76 | wxHTML_COND_ISIMAGEMAP, | |
77 | wxHTML_COND_USER, | |
4eeb5705 RD |
78 | |
79 | ||
80 | wxHTML_FONT_SIZE_1, | |
81 | wxHTML_FONT_SIZE_2, | |
82 | wxHTML_FONT_SIZE_3, | |
83 | wxHTML_FONT_SIZE_4, | |
84 | wxHTML_FONT_SIZE_5, | |
85 | wxHTML_FONT_SIZE_6, | |
86 | wxHTML_FONT_SIZE_7, | |
e166644c RD |
87 | }; |
88 | ||
89 | ||
c6c593e8 RD |
90 | enum { |
91 | wxHW_SCROLLBAR_NEVER, | |
92 | wxHW_SCROLLBAR_AUTO, | |
3ef86e32 RD |
93 | wxHW_NO_SELECTION, |
94 | wxHW_DEFAULT_STYLE, | |
c6c593e8 RD |
95 | }; |
96 | ||
97 | ||
98 | // enums for wxHtmlWindow::OnOpeningURL | |
99 | enum wxHtmlOpeningStatus | |
100 | { | |
101 | wxHTML_OPEN, | |
102 | wxHTML_BLOCK, | |
103 | wxHTML_REDIRECT | |
104 | }; | |
105 | ||
106 | enum wxHtmlURLType | |
107 | { | |
108 | wxHTML_URL_PAGE, | |
109 | wxHTML_URL_IMAGE, | |
110 | wxHTML_URL_OTHER | |
111 | }; | |
112 | ||
d14a1e28 RD |
113 | |
114 | ||
9c00cfa3 RD |
115 | //--------------------------------------------------------------------------- |
116 | ||
9416aa89 | 117 | class wxHtmlLinkInfo : public wxObject { |
9c00cfa3 | 118 | public: |
137b5242 | 119 | wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString); |
9c00cfa3 RD |
120 | wxString GetHref(); |
121 | wxString GetTarget(); | |
c8bc03c3 RD |
122 | wxMouseEvent* GetEvent(); |
123 | wxHtmlCell* GetHtmlCell(); | |
7a446686 RD |
124 | |
125 | void SetEvent(const wxMouseEvent *e); | |
126 | void SetHtmlCell(const wxHtmlCell * e); | |
9c00cfa3 RD |
127 | }; |
128 | ||
0f66a9f3 RD |
129 | //--------------------------------------------------------------------------- |
130 | ||
9416aa89 | 131 | class wxHtmlTag : public wxObject { |
0f66a9f3 | 132 | public: |
e166644c | 133 | // Never need to create a new tag from Python... |
0f66a9f3 RD |
134 | //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); |
135 | ||
136 | wxString GetName(); | |
137 | bool HasParam(const wxString& par); | |
dd9f7fea | 138 | wxString GetParam(const wxString& par, int with_commas = False); |
0f66a9f3 RD |
139 | |
140 | // Can't do this one as-is, but GetParam should be enough... | |
141 | //int ScanParam(const wxString& par, const char *format, void* param); | |
142 | ||
143 | wxString GetAllParams(); | |
0f66a9f3 RD |
144 | bool HasEnding(); |
145 | int GetBeginPos(); | |
146 | int GetEndPos1(); | |
147 | int GetEndPos2(); | |
148 | }; | |
149 | ||
0f66a9f3 RD |
150 | //--------------------------------------------------------------------------- |
151 | ||
9416aa89 | 152 | class wxHtmlParser : public wxObject { |
0f66a9f3 RD |
153 | public: |
154 | // wxHtmlParser(); This is an abstract base class... | |
155 | ||
156 | void SetFS(wxFileSystem *fs); | |
157 | wxFileSystem* GetFS(); | |
158 | wxObject* Parse(const wxString& source); | |
159 | void InitParser(const wxString& source); | |
160 | void DoneParser(); | |
161 | void DoParsing(int begin_pos, int end_pos); | |
1e4a197e | 162 | void StopParsing(); |
0f66a9f3 | 163 | // wxObject* GetProduct(); |
1e4a197e | 164 | |
0f66a9f3 RD |
165 | void AddTagHandler(wxHtmlTagHandler *handler); |
166 | wxString* GetSource(); | |
dc2f8a65 RD |
167 | void PushTagHandler(wxHtmlTagHandler* handler, wxString tags); |
168 | void PopTagHandler(); | |
0f66a9f3 | 169 | |
c6c593e8 | 170 | // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const; |
0f66a9f3 RD |
171 | |
172 | // void AddText(const char* txt) = 0; | |
173 | // void AddTag(const wxHtmlTag& tag); | |
174 | }; | |
175 | ||
176 | ||
177 | //--------------------------------------------------------------------------- | |
178 | ||
179 | class wxHtmlWinParser : public wxHtmlParser { | |
180 | public: | |
1fded56b | 181 | wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL); |
0f66a9f3 RD |
182 | |
183 | void SetDC(wxDC *dc); | |
184 | wxDC* GetDC(); | |
185 | int GetCharHeight(); | |
186 | int GetCharWidth(); | |
1fded56b | 187 | wxPyHtmlWindow* GetWindow(); |
d14a1e28 | 188 | |
1fded56b | 189 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 190 | %extend { |
9cbf6f6e RD |
191 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
192 | int* temp = NULL; | |
193 | if (sizes) temp = int_LIST_helper(sizes); | |
194 | self->SetFonts(normal_face, fixed_face, temp); | |
195 | if (temp) | |
f6bcfd97 | 196 | delete [] temp; |
f6bcfd97 BP |
197 | } |
198 | } | |
0f66a9f3 RD |
199 | |
200 | wxHtmlContainerCell* GetContainer(); | |
201 | wxHtmlContainerCell* OpenContainer(); | |
dc2f8a65 | 202 | wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); |
0f66a9f3 | 203 | wxHtmlContainerCell* CloseContainer(); |
dc2f8a65 | 204 | |
0f66a9f3 RD |
205 | int GetFontSize(); |
206 | void SetFontSize(int s); | |
207 | int GetFontBold(); | |
208 | void SetFontBold(int x); | |
209 | int GetFontItalic(); | |
210 | void SetFontItalic(int x); | |
211 | int GetFontUnderlined(); | |
212 | void SetFontUnderlined(int x); | |
213 | int GetFontFixed(); | |
214 | void SetFontFixed(int x); | |
215 | int GetAlign(); | |
216 | void SetAlign(int a); | |
c5943253 | 217 | wxColour GetLinkColor(); |
0f66a9f3 | 218 | void SetLinkColor(const wxColour& clr); |
c5943253 | 219 | wxColour GetActualColor(); |
0f66a9f3 | 220 | void SetActualColor(const wxColour& clr); |
0f66a9f3 RD |
221 | void SetLink(const wxString& link); |
222 | wxFont* CreateCurrentFont(); | |
9c00cfa3 RD |
223 | wxHtmlLinkInfo GetLink(); |
224 | ||
0f66a9f3 RD |
225 | }; |
226 | ||
227 | ||
0f66a9f3 RD |
228 | //--------------------------------------------------------------------------- |
229 | ||
230 | %{ | |
231 | class wxPyHtmlTagHandler : public wxHtmlTagHandler { | |
9416aa89 | 232 | DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler); |
0f66a9f3 RD |
233 | public: |
234 | wxPyHtmlTagHandler() : wxHtmlTagHandler() {}; | |
235 | ||
236 | wxHtmlParser* GetParser() { return m_Parser; } | |
237 | void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); } | |
238 | ||
239 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
240 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
241 | ||
242 | PYPRIVATE; | |
243 | }; | |
244 | ||
9416aa89 RD |
245 | IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler); |
246 | ||
0f66a9f3 RD |
247 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags); |
248 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag); | |
0f66a9f3 RD |
249 | %} |
250 | ||
251 | ||
d14a1e28 | 252 | %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject { |
0f66a9f3 | 253 | public: |
d14a1e28 | 254 | %addtofunc wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)" |
0f66a9f3 RD |
255 | wxPyHtmlTagHandler(); |
256 | ||
0122b7e3 | 257 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
258 | |
259 | void SetParser(wxHtmlParser *parser); | |
260 | wxHtmlParser* GetParser(); | |
261 | void ParseInner(const wxHtmlTag& tag); | |
262 | }; | |
263 | ||
264 | ||
265 | //--------------------------------------------------------------------------- | |
266 | ||
267 | %{ | |
268 | class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler { | |
9416aa89 | 269 | DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler); |
0f66a9f3 RD |
270 | public: |
271 | wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {}; | |
272 | ||
273 | wxHtmlWinParser* GetParser() { return m_WParser; } | |
274 | void ParseInner(const wxHtmlTag& tag) | |
275 | { wxHtmlWinTagHandler::ParseInner(tag); } | |
276 | ||
277 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
278 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
279 | ||
280 | PYPRIVATE; | |
281 | }; | |
282 | ||
9416aa89 RD |
283 | IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler); |
284 | ||
0f66a9f3 RD |
285 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags); |
286 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag); | |
0f66a9f3 RD |
287 | %} |
288 | ||
289 | ||
d14a1e28 | 290 | %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler { |
0f66a9f3 | 291 | public: |
d14a1e28 | 292 | %addtofunc wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)" |
0f66a9f3 RD |
293 | wxPyHtmlWinTagHandler(); |
294 | ||
0122b7e3 | 295 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
296 | |
297 | void SetParser(wxHtmlParser *parser); | |
298 | wxHtmlWinParser* GetParser(); | |
299 | void ParseInner(const wxHtmlTag& tag); | |
300 | }; | |
301 | ||
302 | ||
303 | //--------------------------------------------------------------------------- | |
304 | ||
305 | %{ | |
306 | ||
307 | class wxPyHtmlTagsModule : public wxHtmlTagsModule { | |
308 | public: | |
309 | wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() { | |
310 | m_tagHandlerClass = thc; | |
311 | Py_INCREF(m_tagHandlerClass); | |
312 | RegisterModule(this); | |
313 | wxHtmlWinParser::AddModule(this); | |
314 | } | |
315 | ||
316 | void OnExit() { | |
4268f798 | 317 | wxPyBeginBlockThreads(); |
0f66a9f3 RD |
318 | Py_DECREF(m_tagHandlerClass); |
319 | m_tagHandlerClass = NULL; | |
dc2f8a65 | 320 | for (size_t x=0; x < m_objArray.GetCount(); x++) { |
0f66a9f3 RD |
321 | PyObject* obj = (PyObject*)m_objArray.Item(x); |
322 | Py_DECREF(obj); | |
323 | } | |
4268f798 | 324 | wxPyEndBlockThreads(); |
0f66a9f3 RD |
325 | }; |
326 | ||
327 | void FillHandlersTable(wxHtmlWinParser *parser) { | |
328 | // Wave our magic wand... (if it works it's a miracle! ;-) | |
329 | ||
330 | // First, make a new instance of the tag handler | |
4268f798 | 331 | wxPyBeginBlockThreads(); |
0f66a9f3 RD |
332 | PyObject* arg = Py_BuildValue("()"); |
333 | PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL); | |
334 | Py_DECREF(arg); | |
4268f798 | 335 | wxPyEndBlockThreads(); |
0f66a9f3 RD |
336 | |
337 | // now figure out where it's C++ object is... | |
338 | wxPyHtmlWinTagHandler* thPtr; | |
d14a1e28 | 339 | if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) |
0f66a9f3 RD |
340 | return; |
341 | ||
342 | // add it, | |
343 | parser->AddTagHandler(thPtr); | |
344 | ||
345 | // and track it. | |
346 | m_objArray.Add(obj); | |
347 | } | |
348 | ||
349 | private: | |
350 | PyObject* m_tagHandlerClass; | |
351 | wxArrayPtrVoid m_objArray; | |
352 | ||
353 | }; | |
354 | %} | |
355 | ||
356 | ||
357 | ||
358 | %inline %{ | |
359 | void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) { | |
360 | // Dynamically create a new wxModule. Refcounts tagHandlerClass | |
361 | // and adds itself to the wxModules list and to the wxHtmlWinParser. | |
362 | new wxPyHtmlTagsModule(tagHandlerClass); | |
363 | } | |
364 | %} | |
365 | ||
dc2f8a65 | 366 | |
e166644c RD |
367 | //--------------------------------------------------------------------------- |
368 | //--------------------------------------------------------------------------- | |
d14a1e28 | 369 | %newgroup |
e166644c | 370 | |
dd116e73 RD |
371 | |
372 | // wxHtmlSelection is data holder with information about text selection. | |
373 | // Selection is defined by two positions (beginning and end of the selection) | |
374 | // and two leaf(!) cells at these positions. | |
375 | class wxHtmlSelection | |
376 | { | |
377 | public: | |
378 | wxHtmlSelection(); | |
379 | ~wxHtmlSelection(); | |
380 | ||
381 | void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell, | |
382 | const wxPoint& toPos, const wxHtmlCell *toCell); | |
383 | %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell); | |
384 | ||
385 | const wxHtmlCell *GetFromCell() const; | |
386 | const wxHtmlCell *GetToCell() const; | |
387 | ||
388 | // these values are in absolute coordinates: | |
389 | const wxPoint& GetFromPos() const; | |
390 | const wxPoint& GetToPos() const; | |
391 | ||
392 | // these are From/ToCell's private data | |
393 | const wxPoint& GetFromPrivPos() const; | |
394 | const wxPoint& GetToPrivPos() const; | |
395 | void SetFromPrivPos(const wxPoint& pos); | |
396 | void SetToPrivPos(const wxPoint& pos); | |
397 | void ClearPrivPos(); | |
398 | ||
399 | const bool IsEmpty() const; | |
400 | ||
401 | }; | |
402 | ||
403 | ||
404 | enum wxHtmlSelectionState | |
405 | { | |
406 | wxHTML_SEL_OUT, // currently rendered cell is outside the selection | |
407 | wxHTML_SEL_IN, // ... is inside selection | |
408 | wxHTML_SEL_CHANGING // ... is the cell on which selection state changes | |
409 | }; | |
410 | ||
d14a1e28 RD |
411 | |
412 | ||
dd116e73 RD |
413 | // Selection state is passed to wxHtmlCell::Draw so that it can render itself |
414 | // differently e.g. when inside text selection or outside it. | |
415 | class wxHtmlRenderingState | |
416 | { | |
417 | public: | |
418 | wxHtmlRenderingState(); | |
419 | ~wxHtmlRenderingState(); | |
420 | ||
421 | void SetSelectionState(wxHtmlSelectionState s); | |
422 | wxHtmlSelectionState GetSelectionState() const; | |
423 | ||
424 | void SetFgColour(const wxColour& c); | |
425 | const wxColour& GetFgColour() const; | |
426 | void SetBgColour(const wxColour& c); | |
427 | const wxColour& GetBgColour() const; | |
428 | }; | |
429 | ||
430 | ||
d14a1e28 | 431 | |
dd116e73 RD |
432 | // HTML rendering customization. This class is used when rendering wxHtmlCells |
433 | // as a callback: | |
434 | class wxHtmlRenderingStyle | |
435 | { | |
436 | public: | |
437 | virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0; | |
438 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0; | |
439 | }; | |
440 | ||
441 | // Standard style: | |
442 | class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle | |
443 | { | |
444 | public: | |
445 | virtual wxColour GetSelectedTextColour(const wxColour& clr); | |
446 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr); | |
447 | }; | |
448 | ||
449 | ||
450 | ||
451 | // Information given to cells when drawing them. Contains rendering state, | |
452 | // selection information and rendering style object that can be used to | |
453 | // customize the output. | |
454 | class wxHtmlRenderingInfo | |
455 | { | |
456 | public: | |
457 | wxHtmlRenderingInfo(); | |
458 | ~wxHtmlRenderingInfo(); | |
459 | ||
460 | void SetSelection(wxHtmlSelection *s); | |
461 | wxHtmlSelection *GetSelection() const; | |
462 | ||
463 | void SetStyle(wxHtmlRenderingStyle *style); | |
464 | wxHtmlRenderingStyle& GetStyle(); | |
465 | ||
466 | wxHtmlRenderingState& GetState(); | |
467 | }; | |
468 | ||
469 | //--------------------------------------------------------------------------- | |
d14a1e28 | 470 | %newgroup |
dd116e73 | 471 | |
3ef86e32 RD |
472 | |
473 | enum | |
474 | { | |
475 | wxHTML_FIND_EXACT = 1, | |
476 | wxHTML_FIND_NEAREST_BEFORE = 2, | |
477 | wxHTML_FIND_NEAREST_AFTER = 4 | |
478 | }; | |
479 | ||
480 | ||
9416aa89 | 481 | class wxHtmlCell : public wxObject { |
e166644c RD |
482 | public: |
483 | wxHtmlCell(); | |
484 | ||
e166644c RD |
485 | int GetPosX(); |
486 | int GetPosY(); | |
487 | int GetWidth(); | |
488 | int GetHeight(); | |
489 | int GetDescent(); | |
9c00cfa3 | 490 | wxHtmlLinkInfo* GetLink(int x = 0, int y = 0); |
e166644c | 491 | wxHtmlCell* GetNext(); |
9c00cfa3 | 492 | wxHtmlContainerCell* GetParent(); |
3ef86e32 RD |
493 | wxHtmlCell* GetFirstChild() const; |
494 | ||
495 | // Returns cursor to be used when mouse is over the cell: | |
496 | wxCursor GetCursor() const; | |
497 | ||
498 | // Formatting cells are not visible on the screen, they only alter | |
499 | // renderer's state. | |
500 | bool IsFormattingCell() const; | |
501 | ||
502 | ||
9c00cfa3 | 503 | void SetLink(const wxHtmlLinkInfo& link); |
e166644c | 504 | void SetNext(wxHtmlCell *cell); |
9c00cfa3 RD |
505 | void SetParent(wxHtmlContainerCell *p); |
506 | void SetPos(int x, int y); | |
e166644c | 507 | void Layout(int w); |
dd116e73 RD |
508 | void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
509 | wxHtmlRenderingInfo& info); | |
510 | void DrawInvisible(wxDC& dc, int x, int y, | |
511 | wxHtmlRenderingInfo& info); | |
e166644c | 512 | const wxHtmlCell* Find(int condition, const void* param); |
dc2f8a65 | 513 | |
1fded56b | 514 | bool AdjustPagebreak(int* INOUT); |
dc2f8a65 | 515 | void SetCanLiveOnPagebreak(bool can); |
9c00cfa3 | 516 | |
3ef86e32 RD |
517 | // Can the line be broken before this cell? |
518 | bool IsLinebreakAllowed() const; | |
519 | ||
dd9f7fea | 520 | // Returns True for simple == terminal cells, i.e. not composite ones. |
3ef86e32 RD |
521 | // This if for internal usage only and may disappear in future versions! |
522 | bool IsTerminalCell() const; | |
523 | ||
524 | // Find a cell inside this cell positioned at the given coordinates | |
525 | // (relative to this's positions). Returns NULL if no such cell exists. | |
526 | // The flag can be used to specify whether to look for terminal or | |
527 | // nonterminal cells or both. In either case, returned cell is deepest | |
528 | // cell in cells tree that contains [x,y]. | |
529 | wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y, | |
530 | unsigned flags = wxHTML_FIND_EXACT) const; | |
531 | ||
532 | // Returns absolute position of the cell on HTML canvas | |
533 | wxPoint GetAbsPos() const; | |
534 | ||
535 | // Returns first (last) terminal cell inside this cell. It may return NULL, | |
536 | // but it is rare -- only if there are no terminals in the tree. | |
537 | wxHtmlCell *GetFirstTerminal() const ; | |
538 | wxHtmlCell *GetLastTerminal() const ; | |
539 | ||
540 | // Returns cell's depth, i.e. how far under the root cell it is | |
541 | // (if it is the root, depth is 0) | |
542 | unsigned GetDepth() const; | |
543 | ||
dd9f7fea | 544 | // Returns True if the cell appears before 'cell' in natural order of |
3ef86e32 | 545 | // cells (= as they are read). If cell A is (grand)parent of cell B, |
dd9f7fea | 546 | // then both A.IsBefore(B) and B.IsBefore(A) always return True. |
3ef86e32 RD |
547 | bool IsBefore(wxHtmlCell *cell) const; |
548 | ||
549 | // Converts the cell into text representation. If sel != NULL then | |
550 | // only part of the cell inside the selection is converted. | |
551 | wxString ConvertToText(wxHtmlSelection *sel) const; | |
e166644c RD |
552 | }; |
553 | ||
554 | ||
9416aa89 RD |
555 | class wxHtmlWordCell : public wxHtmlCell |
556 | { | |
557 | public: | |
558 | wxHtmlWordCell(const wxString& word, wxDC& dc); | |
559 | }; | |
560 | ||
561 | ||
e166644c RD |
562 | class wxHtmlContainerCell : public wxHtmlCell { |
563 | public: | |
564 | wxHtmlContainerCell(wxHtmlContainerCell *parent); | |
565 | ||
566 | void InsertCell(wxHtmlCell *cell); | |
567 | void SetAlignHor(int al); | |
568 | int GetAlignHor(); | |
569 | void SetAlignVer(int al); | |
570 | int GetAlignVer(); | |
9d8bd15f | 571 | void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); |
e166644c RD |
572 | int GetIndent(int ind); |
573 | int GetIndentUnits(int ind); | |
574 | void SetAlign(const wxHtmlTag& tag); | |
575 | void SetWidthFloat(int w, int units); | |
576 | %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag); | |
9d8bd15f | 577 | void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP); |
e166644c | 578 | void SetBackgroundColour(const wxColour& clr); |
1e4a197e | 579 | wxColour GetBackgroundColour(); |
e166644c | 580 | void SetBorder(const wxColour& clr1, const wxColour& clr2); |
dd116e73 RD |
581 | wxHtmlCell* GetFirstChild(); |
582 | %pragma(python) addtoclass = "GetFirstCell = GetFirstChild" | |
e166644c RD |
583 | }; |
584 | ||
585 | ||
586 | ||
9c00cfa3 RD |
587 | class wxHtmlColourCell : public wxHtmlCell { |
588 | public: | |
589 | wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND); | |
590 | ||
591 | }; | |
592 | ||
593 | ||
9416aa89 RD |
594 | class wxHtmlFontCell : public wxHtmlCell |
595 | { | |
596 | public: | |
597 | wxHtmlFontCell(wxFont *font); | |
598 | }; | |
599 | ||
e166644c RD |
600 | |
601 | class wxHtmlWidgetCell : public wxHtmlCell { | |
602 | public: | |
603 | wxHtmlWidgetCell(wxWindow* wnd, int w = 0); | |
604 | ||
605 | }; | |
606 | ||
0f66a9f3 | 607 | |
d14a1e28 RD |
608 | |
609 | ||
0f66a9f3 | 610 | //--------------------------------------------------------------------------- |
1e4a197e RD |
611 | // wxHtmlFilter |
612 | //--------------------------------------------------------------------------- | |
d14a1e28 | 613 | %newgroup |
1e4a197e RD |
614 | |
615 | ||
616 | %{ // here's the C++ version | |
617 | class wxPyHtmlFilter : public wxHtmlFilter { | |
618 | DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter); | |
619 | public: | |
620 | wxPyHtmlFilter() : wxHtmlFilter() {} | |
621 | ||
dd9f7fea | 622 | // returns True if this filter is able to open&read given file |
1e4a197e | 623 | virtual bool CanRead(const wxFSFile& file) const { |
dd9f7fea | 624 | bool rval = False; |
1e4a197e RD |
625 | bool found; |
626 | wxPyBeginBlockThreads(); | |
627 | if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) { | |
628 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const | |
629 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); | |
630 | Py_DECREF(obj); | |
631 | } | |
632 | wxPyEndBlockThreads(); | |
633 | return rval; | |
634 | } | |
635 | ||
636 | ||
637 | // Reads given file and returns HTML document. | |
638 | // Returns empty string if opening failed | |
639 | virtual wxString ReadFile(const wxFSFile& file) const { | |
640 | wxString rval; | |
641 | bool found; | |
642 | wxPyBeginBlockThreads(); | |
643 | if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) { | |
644 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const | |
645 | PyObject* ro; | |
646 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj)); | |
647 | Py_DECREF(obj); | |
648 | if (ro) { | |
649 | rval = Py2wxString(ro); | |
650 | Py_DECREF(ro); | |
651 | } | |
652 | } | |
653 | wxPyEndBlockThreads(); | |
654 | return rval; | |
655 | } | |
656 | ||
657 | PYPRIVATE; | |
658 | }; | |
659 | ||
660 | IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter); | |
661 | %} | |
662 | ||
663 | ||
664 | // And now the version seen by SWIG | |
665 | ||
d14a1e28 | 666 | %name(HtmlFilter) class wxPyHtmlFilter : public wxObject { |
1e4a197e | 667 | public: |
d14a1e28 | 668 | %addtofunc wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)" |
1e4a197e RD |
669 | wxPyHtmlFilter(); |
670 | ||
671 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1e4a197e RD |
672 | }; |
673 | ||
674 | ||
675 | // TODO: wxHtmlFilterHTML | |
676 | ||
677 | ||
0f66a9f3 | 678 | //--------------------------------------------------------------------------- |
1e4a197e | 679 | // wxHtmlWindow |
4b123bb9 | 680 | //--------------------------------------------------------------------------- |
d14a1e28 | 681 | %newgroup |
4b123bb9 | 682 | |
0f66a9f3 RD |
683 | %{ |
684 | class wxPyHtmlWindow : public wxHtmlWindow { | |
cdf14688 | 685 | DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow); |
0f66a9f3 RD |
686 | public: |
687 | wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1, | |
688 | const wxPoint& pos = wxDefaultPosition, | |
689 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 690 | long style = wxHW_DEFAULT_STYLE, |
1e4a197e | 691 | const wxString& name = wxPyHtmlWindowNameStr) |
0f66a9f3 | 692 | : wxHtmlWindow(parent, id, pos, size, style, name) {}; |
7b7ac0ab | 693 | wxPyHtmlWindow() : wxHtmlWindow() {}; |
0f66a9f3 | 694 | |
e5d41db0 RD |
695 | bool ScrollToAnchor(const wxString& anchor) { |
696 | return wxHtmlWindow::ScrollToAnchor(anchor); | |
697 | } | |
698 | ||
699 | bool HasAnchor(const wxString& anchor) { | |
700 | const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor); | |
701 | return c!=NULL; | |
702 | } | |
703 | ||
c8bc03c3 RD |
704 | void OnLinkClicked(const wxHtmlLinkInfo& link); |
705 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); | |
9c00cfa3 | 706 | |
e5d41db0 | 707 | wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, |
c6c593e8 RD |
708 | const wxString& url, |
709 | wxString *redirect) const; | |
710 | ||
9c00cfa3 | 711 | DEC_PYCALLBACK__STRING(OnSetTitle); |
0122b7e3 RD |
712 | DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover); |
713 | DEC_PYCALLBACK__CELLINTINTME(OnCellClicked); | |
0f66a9f3 RD |
714 | PYPRIVATE; |
715 | }; | |
716 | ||
cdf14688 | 717 | IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); |
9c00cfa3 | 718 | IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); |
0122b7e3 RD |
719 | IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover); |
720 | IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked); | |
721 | ||
0f66a9f3 | 722 | |
9416aa89 | 723 | void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { |
19a97bd6 | 724 | bool found; |
4268f798 | 725 | wxPyBeginBlockThreads(); |
0122b7e3 | 726 | if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { |
1e4a197e | 727 | PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0); |
1e7ecb7b | 728 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); |
de20db99 | 729 | Py_DECREF(obj); |
9c00cfa3 | 730 | } |
4268f798 | 731 | wxPyEndBlockThreads(); |
19a97bd6 | 732 | if (! found) |
9c00cfa3 | 733 | wxHtmlWindow::OnLinkClicked(link); |
9c00cfa3 | 734 | } |
c8bc03c3 | 735 | void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { |
9c00cfa3 RD |
736 | wxHtmlWindow::OnLinkClicked(link); |
737 | } | |
0122b7e3 | 738 | |
c6c593e8 RD |
739 | |
740 | wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type, | |
741 | const wxString& url, | |
742 | wxString *redirect) const { | |
743 | bool found; | |
744 | wxHtmlOpeningStatus rval; | |
745 | wxPyBeginBlockThreads(); | |
746 | if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) { | |
747 | PyObject* ro; | |
a66212dc RD |
748 | PyObject* s = wx2PyString(url); |
749 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s)); | |
750 | Py_DECREF(s); | |
c6c593e8 RD |
751 | if (PyString_Check(ro) |
752 | #if PYTHON_API_VERSION >= 1009 | |
753 | || PyUnicode_Check(ro) | |
754 | #endif | |
755 | ) { | |
a541c325 | 756 | *redirect = Py2wxString(ro); |
c6c593e8 RD |
757 | rval = wxHTML_REDIRECT; |
758 | } | |
759 | else { | |
760 | PyObject* num = PyNumber_Int(ro); | |
761 | rval = (wxHtmlOpeningStatus)PyInt_AsLong(num); | |
762 | Py_DECREF(num); | |
763 | } | |
764 | Py_DECREF(ro); | |
765 | } | |
766 | wxPyEndBlockThreads(); | |
767 | if (! found) | |
768 | rval = wxHtmlWindow::OnOpeningURL(type, url, redirect); | |
769 | return rval; | |
770 | } | |
771 | ||
772 | ||
0f66a9f3 RD |
773 | %} |
774 | ||
775 | ||
95837b4d | 776 | |
d14a1e28 | 777 | %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow { |
0f66a9f3 | 778 | public: |
d14a1e28 RD |
779 | %addtofunc wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)" |
780 | %addtofunc wxPyHtmlWindow() "" | |
781 | ||
0f66a9f3 | 782 | wxPyHtmlWindow(wxWindow *parent, int id = -1, |
d14a1e28 RD |
783 | const wxPoint& pos = wxDefaultPosition, |
784 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 785 | int style=wxHW_DEFAULT_STYLE, |
137b5242 | 786 | const wxString& name = wxPyHtmlWindowNameStr); |
d14a1e28 | 787 | %name(PreHtmlWindow)wxPyHtmlWindow(); |
7b7ac0ab RD |
788 | |
789 | bool Create(wxWindow *parent, int id = -1, | |
d14a1e28 RD |
790 | const wxPoint& pos = wxDefaultPosition, |
791 | const wxSize& size = wxDefaultSize, | |
fc51b8c3 | 792 | int style=wxHW_SCROLLBAR_AUTO, |
137b5242 | 793 | const wxString& name = wxPyHtmlWindowNameStr); |
7b7ac0ab | 794 | |
0f66a9f3 | 795 | |
0122b7e3 | 796 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 | 797 | |
d14a1e28 | 798 | |
1e4a197e RD |
799 | // Set HTML page and display it. !! source is HTML document itself, |
800 | // it is NOT address/filename of HTML document. If you want to | |
801 | // specify document location, use LoadPage() istead | |
dd9f7fea | 802 | // Return value : False if an error occured, True otherwise |
7a446686 | 803 | bool SetPage(const wxString& source); |
1e4a197e RD |
804 | |
805 | // Load HTML page from given location. Location can be either | |
806 | // a) /usr/wxGTK2/docs/html/wx.htm | |
807 | // b) http://www.somewhere.uk/document.htm | |
808 | // c) ftp://ftp.somesite.cz/pub/something.htm | |
809 | // In case there is no prefix (http:,ftp:), the method | |
810 | // will try to find it itself (1. local file, then http or ftp) | |
811 | // After the page is loaded, the method calls SetPage() to display it. | |
812 | // Note : you can also use path relative to previously loaded page | |
813 | // Return value : same as SetPage | |
7a446686 | 814 | bool LoadPage(const wxString& location); |
1e4a197e | 815 | |
9cbf6f6e | 816 | // Loads HTML page from file |
1fded56b | 817 | bool LoadFile(const wxString& filename); |
9cbf6f6e | 818 | |
1e4a197e | 819 | // Append to current page |
de112a55 | 820 | bool AppendToPage(const wxString& source); |
1e4a197e RD |
821 | |
822 | // Returns full location of opened page | |
0f66a9f3 | 823 | wxString GetOpenedPage(); |
1e4a197e RD |
824 | |
825 | // Returns anchor within opened page | |
7a446686 | 826 | wxString GetOpenedAnchor(); |
1e4a197e RD |
827 | |
828 | // Returns <TITLE> of opened page or empty string otherwise | |
7a446686 RD |
829 | wxString GetOpenedPageTitle(); |
830 | ||
1e4a197e RD |
831 | // Sets frame in which page title will be displayed. Format is format of |
832 | // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s | |
137b5242 | 833 | void SetRelatedFrame(wxFrame* frame, const wxString& format); |
0f66a9f3 | 834 | wxFrame* GetRelatedFrame(); |
1e4a197e RD |
835 | |
836 | // After(!) calling SetRelatedFrame, this sets statusbar slot where messages | |
837 | // will be displayed. Default is -1 = no messages. | |
0f66a9f3 | 838 | void SetRelatedStatusBar(int bar); |
f6bcfd97 | 839 | |
1e4a197e | 840 | // Sets fonts to be used when displaying HTML page. |
d14a1e28 | 841 | %extend { |
9cbf6f6e RD |
842 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
843 | int* temp = NULL; | |
844 | if (sizes) temp = int_LIST_helper(sizes); | |
845 | self->SetFonts(normal_face, fixed_face, temp); | |
846 | if (temp) | |
f6bcfd97 | 847 | delete [] temp; |
f6bcfd97 BP |
848 | } |
849 | } | |
850 | ||
7a446686 | 851 | void SetTitle(const wxString& title); |
1e4a197e RD |
852 | |
853 | // Sets space between text and window borders. | |
0f66a9f3 | 854 | void SetBorders(int b); |
1e4a197e RD |
855 | |
856 | // Saves custom settings into cfg config. it will use the path 'path' | |
857 | // if given, otherwise it will save info into currently selected path. | |
858 | // saved values : things set by SetFonts, SetBorders. | |
137b5242 RD |
859 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); |
860 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1e4a197e RD |
861 | |
862 | // Goes to previous/next page (in browsing history) | |
dd9f7fea | 863 | // Returns True if successful, False otherwise |
0f66a9f3 RD |
864 | bool HistoryBack(); |
865 | bool HistoryForward(); | |
7a446686 RD |
866 | bool HistoryCanBack(); |
867 | bool HistoryCanForward(); | |
1e4a197e RD |
868 | |
869 | // Resets History | |
0f66a9f3 | 870 | void HistoryClear(); |
1e4a197e RD |
871 | |
872 | // Returns pointer to conteiners/cells structure. | |
a65c6e14 | 873 | wxHtmlContainerCell* GetInternalRepresentation(); |
1e4a197e RD |
874 | |
875 | // Returns a pointer to the parser. | |
e166644c RD |
876 | wxHtmlWinParser* GetParser(); |
877 | ||
e5d41db0 RD |
878 | bool ScrollToAnchor(const wxString& anchor); |
879 | bool HasAnchor(const wxString& anchor); | |
880 | ||
1e4a197e RD |
881 | //Adds input filter |
882 | static void AddFilter(wxPyHtmlFilter *filter); | |
883 | ||
884 | ||
c8bc03c3 | 885 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); |
137b5242 | 886 | void base_OnSetTitle(const wxString& title); |
0122b7e3 RD |
887 | void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y); |
888 | void base_OnCellClicked(wxHtmlCell *cell, | |
889 | wxCoord x, wxCoord y, | |
890 | const wxMouseEvent& event); | |
4b123bb9 HH |
891 | }; |
892 | ||
5ca24bf4 | 893 | |
5ca24bf4 | 894 | |
d14a1e28 | 895 | |
dc2f8a65 RD |
896 | //--------------------------------------------------------------------------- |
897 | //--------------------------------------------------------------------------- | |
d14a1e28 | 898 | %newgroup |
dc2f8a65 RD |
899 | |
900 | ||
9416aa89 | 901 | class wxHtmlDCRenderer : public wxObject { |
dc2f8a65 RD |
902 | public: |
903 | wxHtmlDCRenderer(); | |
904 | ~wxHtmlDCRenderer(); | |
905 | ||
906 | void SetDC(wxDC *dc, int maxwidth); | |
907 | void SetSize(int width, int height); | |
908 | void SetHtmlText(const wxString& html, | |
137b5242 | 909 | const wxString& basepath = wxPyEmptyString, |
dd9f7fea | 910 | bool isdir = True); |
1fded56b | 911 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 912 | %extend { |
9cbf6f6e RD |
913 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
914 | int* temp = NULL; | |
915 | if (sizes) temp = int_LIST_helper(sizes); | |
916 | self->SetFonts(normal_face, fixed_face, temp); | |
917 | if (temp) | |
918 | delete [] temp; | |
919 | } | |
920 | } | |
dd9f7fea | 921 | int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX, |
3ef86e32 RD |
922 | //int *known_pagebreaks = NULL, int number_of_pages = 0 |
923 | int* choices=NULL, int LCOUNT = 0 | |
924 | ); | |
dc2f8a65 RD |
925 | int GetTotalHeight(); |
926 | // returns total height of the html document | |
927 | // (compare Render's return value with this) | |
928 | }; | |
929 | ||
d14a1e28 | 930 | |
dc2f8a65 RD |
931 | enum { |
932 | wxPAGE_ODD, | |
933 | wxPAGE_EVEN, | |
934 | wxPAGE_ALL | |
935 | }; | |
936 | ||
937 | ||
938 | class wxHtmlPrintout : public wxPyPrintout { | |
939 | public: | |
137b5242 | 940 | wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr); |
f3d9dc1d | 941 | //~wxHtmlPrintout(); wxPrintPreview object takes ownership... |
dc2f8a65 RD |
942 | |
943 | void SetHtmlText(const wxString& html, | |
137b5242 | 944 | const wxString &basepath = wxPyEmptyString, |
dd9f7fea | 945 | bool isdir = True); |
dc2f8a65 RD |
946 | void SetHtmlFile(const wxString &htmlfile); |
947 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
948 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
d14a1e28 | 949 | |
1fded56b | 950 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 951 | %extend { |
9cbf6f6e RD |
952 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
953 | int* temp = NULL; | |
954 | if (sizes) temp = int_LIST_helper(sizes); | |
955 | self->SetFonts(normal_face, fixed_face, temp); | |
956 | if (temp) | |
957 | delete [] temp; | |
958 | } | |
959 | } | |
dc2f8a65 RD |
960 | void SetMargins(float top = 25.2, float bottom = 25.2, |
961 | float left = 25.2, float right = 25.2, | |
962 | float spaces = 5); | |
3ef86e32 RD |
963 | |
964 | // Adds input filter | |
965 | static void AddFilter(wxHtmlFilter *filter); | |
966 | ||
967 | // Cleanup | |
968 | static void CleanUpStatics(); | |
dc2f8a65 RD |
969 | }; |
970 | ||
971 | ||
972 | ||
9416aa89 | 973 | class wxHtmlEasyPrinting : public wxObject { |
dc2f8a65 | 974 | public: |
137b5242 | 975 | wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr, |
3ef86e32 | 976 | wxWindow *parentWindow = NULL); |
dc2f8a65 RD |
977 | ~wxHtmlEasyPrinting(); |
978 | ||
979 | void PreviewFile(const wxString &htmlfile); | |
137b5242 | 980 | void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
dc2f8a65 | 981 | void PrintFile(const wxString &htmlfile); |
137b5242 | 982 | void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
dc2f8a65 RD |
983 | void PrinterSetup(); |
984 | void PageSetup(); | |
985 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
986 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
987 | ||
d14a1e28 | 988 | %extend { |
9cbf6f6e RD |
989 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
990 | int* temp = NULL; | |
991 | if (sizes) temp = int_LIST_helper(sizes); | |
992 | self->SetFonts(normal_face, fixed_face, temp); | |
993 | if (temp) | |
994 | delete [] temp; | |
995 | } | |
996 | } | |
997 | ||
dc2f8a65 RD |
998 | wxPrintData *GetPrintData() {return m_PrintData;} |
999 | wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} | |
1000 | ||
1001 | }; | |
1002 | ||
1003 | ||
0f66a9f3 RD |
1004 | //--------------------------------------------------------------------------- |
1005 | //--------------------------------------------------------------------------- | |
d14a1e28 | 1006 | %newgroup |
5ca24bf4 | 1007 | |
4b123bb9 | 1008 | |
d14a1e28 RD |
1009 | class wxHtmlBookRecord { |
1010 | public: | |
1011 | wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath, | |
1012 | const wxString& title, const wxString& start); | |
4b123bb9 | 1013 | |
d14a1e28 RD |
1014 | wxString GetBookFile(); |
1015 | wxString GetTitle(); | |
1016 | wxString GetStart(); | |
1017 | wxString GetBasePath(); | |
1018 | ||
1019 | void SetContentsRange(int start, int end); | |
1020 | int GetContentsStart(); | |
1021 | int GetContentsEnd(); | |
4b123bb9 | 1022 | |
d14a1e28 RD |
1023 | void SetTitle(const wxString& title); |
1024 | void SetBasePath(const wxString& path); | |
1025 | void SetStart(const wxString& start); | |
1026 | ||
1027 | wxString GetFullPath(const wxString &page) const; | |
1028 | }; | |
1029 | ||
1030 | //--------------------------------------------------------------------------- | |
0f66a9f3 | 1031 | |
d14a1e28 RD |
1032 | struct wxHtmlContentsItem |
1033 | { | |
1034 | %extend { | |
1035 | int GetLevel() { return self->m_Level; } | |
1036 | int GetID() { return self->m_ID; } | |
1037 | wxString GetName() { return self->m_Name; } | |
1038 | wxString GetPage() { return self->m_Page; } | |
1039 | wxHtmlBookRecord* GetBook() { return self->m_Book; } | |
1040 | } | |
1041 | }; | |
1042 | ||
1043 | //--------------------------------------------------------------------------- | |
1044 | ||
1045 | class wxHtmlSearchStatus | |
1046 | { | |
1047 | public: | |
1048 | //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword, | |
1049 | // const wxString& book = wxPyEmptyString); | |
1050 | bool Search(); | |
1051 | bool IsActive(); | |
1052 | int GetCurIndex(); | |
1053 | int GetMaxIndex(); | |
1054 | const wxString& GetName(); | |
1055 | wxHtmlContentsItem* GetContentsItem(); | |
1056 | }; | |
1057 | ||
1058 | //--------------------------------------------------------------------------- | |
1059 | ||
1060 | class wxHtmlHelpData { | |
1061 | public: | |
1062 | wxHtmlHelpData(); | |
1063 | ~wxHtmlHelpData(); | |
1064 | ||
1065 | void SetTempDir(const wxString& path); | |
1066 | bool AddBook(const wxString& book); | |
1067 | // bool AddBookParam(const wxString& title, const wxString& contfile, | |
1068 | // const wxString& indexfile=wxPyEmptyString, | |
1069 | // const wxString& deftopic=wxPyEmptyString, | |
1070 | // const wxString& path=wxPyEmptyString); | |
1071 | ||
1072 | wxString FindPageByName(const wxString& page); | |
1073 | wxString FindPageById(int id); | |
1074 | ||
1075 | // TODO: this one needs fixed... | |
1076 | const wxHtmlBookRecArray& GetBookRecArray(); | |
1077 | ||
1078 | wxHtmlContentsItem* GetContents(); | |
1079 | int GetContentsCnt(); | |
1080 | wxHtmlContentsItem* GetIndex(); | |
1081 | int GetIndexCnt(); | |
1082 | }; | |
1083 | ||
1084 | //--------------------------------------------------------------------------- | |
1085 | ||
1086 | class wxHtmlHelpFrame : public wxFrame { | |
1087 | public: | |
1088 | %addtofunc wxHtmlHelpFrame "self._setOORInfo(self)" | |
1089 | ||
1090 | wxHtmlHelpFrame(wxWindow* parent, int wxWindowID, | |
1091 | const wxString& title = wxPyEmptyString, | |
1092 | int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); | |
1093 | ||
1094 | wxHtmlHelpData* GetData(); | |
1095 | void SetTitleFormat(const wxString& format); | |
1096 | void Display(const wxString& x); | |
1097 | %name(DisplayID) void Display(int id); | |
1098 | void DisplayContents(); | |
1099 | void DisplayIndex(); | |
1100 | bool KeywordSearch(const wxString& keyword); | |
1101 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString); | |
1102 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1103 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1104 | }; | |
1105 | ||
1106 | ||
1107 | //--------------------------------------------------------------------------- | |
1108 | ||
1109 | ||
1110 | enum { | |
1111 | wxHF_TOOLBAR, | |
1112 | wxHF_FLATTOOLBAR, | |
1113 | wxHF_CONTENTS, | |
1114 | wxHF_INDEX, | |
1115 | wxHF_SEARCH, | |
1116 | wxHF_BOOKMARKS, | |
1117 | wxHF_OPENFILES, | |
1118 | wxHF_PRINT, | |
1119 | wxHF_DEFAULTSTYLE, | |
1120 | }; | |
1121 | ||
1122 | ||
1123 | class wxHtmlHelpController : public wxEvtHandler { | |
1124 | public: | |
1125 | %addtofunc wxHtmlHelpController "self._setOORInfo(self)" | |
1126 | ||
1127 | wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE); | |
1128 | ~wxHtmlHelpController(); | |
1129 | ||
1130 | void SetTitleFormat(const wxString& format); | |
1131 | void SetTempDir(const wxString& path); | |
dd9f7fea | 1132 | bool AddBook(const wxString& book, int show_wait_msg = False); |
d14a1e28 RD |
1133 | void Display(const wxString& x); |
1134 | %name(DisplayID) void Display(int id); | |
1135 | void DisplayContents(); | |
1136 | void DisplayIndex(); | |
1137 | bool KeywordSearch(const wxString& keyword); | |
1138 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString); | |
1139 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1140 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1141 | wxHtmlHelpFrame* GetFrame(); | |
1142 | }; | |
1143 | ||
1144 | ||
1145 | ||
1146 | ||
1147 | //--------------------------------------------------------------------------- | |
1148 | %init %{ | |
1149 | wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler"); | |
9416aa89 | 1150 | wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler"); |
d14a1e28 RD |
1151 | wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow"); |
1152 | wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter"); | |
4b123bb9 | 1153 | %} |
d14a1e28 RD |
1154 | //--------------------------------------------------------------------------- |
1155 | //--------------------------------------------------------------------------- | |
4b123bb9 | 1156 | |
e166644c | 1157 | |
e166644c | 1158 |