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