]>
Commit | Line | Data |
---|---|---|
4b123bb9 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: html.i | |
3 | // Purpose: SWIG definitions of html classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 25-nov-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module html | |
15 | ||
16 | %{ | |
1e7ecb7b | 17 | #include "export.h" |
4b123bb9 | 18 | #include <wx/html/htmlwin.h> |
dc2f8a65 | 19 | #include <wx/html/htmprint.h> |
4b123bb9 HH |
20 | #include <wx/image.h> |
21 | #include <wx/fs_zip.h> | |
22 | #include <wx/fs_inet.h> | |
5ca24bf4 | 23 | #include <wx/wfstream.h> |
dc2f8a65 RD |
24 | |
25 | #include "printfw.h" | |
4b123bb9 HH |
26 | %} |
27 | ||
28 | //--------------------------------------------------------------------------- | |
29 | ||
30 | %include typemaps.i | |
31 | %include my_typemaps.i | |
32 | ||
33 | %extern wx.i | |
34 | %extern windows.i | |
35 | %extern _defs.i | |
36 | %extern events.i | |
5ca24bf4 HH |
37 | %extern controls.i |
38 | %extern controls2.i | |
dc2f8a65 | 39 | %extern printfw.i |
4b123bb9 | 40 | |
0f66a9f3 RD |
41 | %extern utils.i |
42 | ||
2f90df85 | 43 | %pragma(python) code = "import wx" |
4b123bb9 | 44 | |
4b123bb9 | 45 | |
0f66a9f3 | 46 | //--------------------------------------------------------------------------- |
e166644c RD |
47 | |
48 | enum { | |
9d8bd15f RD |
49 | wxHTML_ALIGN_LEFT, |
50 | wxHTML_ALIGN_CENTER, | |
51 | wxHTML_ALIGN_RIGHT, | |
52 | wxHTML_ALIGN_BOTTOM, | |
53 | wxHTML_ALIGN_TOP, | |
54 | ||
55 | wxHTML_CLR_FOREGROUND, | |
56 | wxHTML_CLR_BACKGROUND, | |
57 | ||
58 | wxHTML_UNITS_PIXELS, | |
59 | wxHTML_UNITS_PERCENT, | |
60 | ||
61 | wxHTML_INDENT_LEFT, | |
62 | wxHTML_INDENT_RIGHT, | |
63 | wxHTML_INDENT_TOP, | |
64 | wxHTML_INDENT_BOTTOM, | |
65 | ||
66 | wxHTML_INDENT_HORIZONTAL, | |
67 | wxHTML_INDENT_VERTICAL, | |
68 | wxHTML_INDENT_ALL, | |
69 | ||
70 | wxHTML_COND_ISANCHOR, | |
71 | wxHTML_COND_ISIMAGEMAP, | |
72 | wxHTML_COND_USER, | |
e166644c RD |
73 | }; |
74 | ||
75 | ||
c6c593e8 RD |
76 | enum { |
77 | wxHW_SCROLLBAR_NEVER, | |
78 | wxHW_SCROLLBAR_AUTO, | |
79 | }; | |
80 | ||
81 | ||
82 | // enums for wxHtmlWindow::OnOpeningURL | |
83 | enum wxHtmlOpeningStatus | |
84 | { | |
85 | wxHTML_OPEN, | |
86 | wxHTML_BLOCK, | |
87 | wxHTML_REDIRECT | |
88 | }; | |
89 | ||
90 | enum wxHtmlURLType | |
91 | { | |
92 | wxHTML_URL_PAGE, | |
93 | wxHTML_URL_IMAGE, | |
94 | wxHTML_URL_OTHER | |
95 | }; | |
96 | ||
9c00cfa3 RD |
97 | //--------------------------------------------------------------------------- |
98 | ||
9416aa89 | 99 | class wxHtmlLinkInfo : public wxObject { |
9c00cfa3 RD |
100 | public: |
101 | wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString); | |
102 | wxString GetHref(); | |
103 | wxString GetTarget(); | |
c8bc03c3 RD |
104 | wxMouseEvent* GetEvent(); |
105 | wxHtmlCell* GetHtmlCell(); | |
7a446686 RD |
106 | |
107 | void SetEvent(const wxMouseEvent *e); | |
108 | void SetHtmlCell(const wxHtmlCell * e); | |
9c00cfa3 RD |
109 | }; |
110 | ||
0f66a9f3 RD |
111 | //--------------------------------------------------------------------------- |
112 | ||
9416aa89 | 113 | class wxHtmlTag : public wxObject { |
0f66a9f3 | 114 | public: |
e166644c | 115 | // Never need to create a new tag from Python... |
0f66a9f3 RD |
116 | //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); |
117 | ||
118 | wxString GetName(); | |
119 | bool HasParam(const wxString& par); | |
120 | wxString GetParam(const wxString& par, int with_commas = FALSE); | |
121 | ||
122 | // Can't do this one as-is, but GetParam should be enough... | |
123 | //int ScanParam(const wxString& par, const char *format, void* param); | |
124 | ||
125 | wxString GetAllParams(); | |
0f66a9f3 RD |
126 | bool HasEnding(); |
127 | int GetBeginPos(); | |
128 | int GetEndPos1(); | |
129 | int GetEndPos2(); | |
130 | }; | |
131 | ||
132 | ||
133 | //--------------------------------------------------------------------------- | |
134 | ||
9416aa89 | 135 | class wxHtmlParser : public wxObject { |
0f66a9f3 RD |
136 | public: |
137 | // wxHtmlParser(); This is an abstract base class... | |
138 | ||
139 | void SetFS(wxFileSystem *fs); | |
140 | wxFileSystem* GetFS(); | |
141 | wxObject* Parse(const wxString& source); | |
142 | void InitParser(const wxString& source); | |
143 | void DoneParser(); | |
144 | void DoParsing(int begin_pos, int end_pos); | |
145 | // wxObject* GetProduct(); | |
146 | void AddTagHandler(wxHtmlTagHandler *handler); | |
147 | wxString* GetSource(); | |
dc2f8a65 RD |
148 | void PushTagHandler(wxHtmlTagHandler* handler, wxString tags); |
149 | void PopTagHandler(); | |
0f66a9f3 | 150 | |
c6c593e8 | 151 | // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const; |
0f66a9f3 RD |
152 | |
153 | // void AddText(const char* txt) = 0; | |
154 | // void AddTag(const wxHtmlTag& tag); | |
155 | }; | |
156 | ||
157 | ||
158 | //--------------------------------------------------------------------------- | |
159 | ||
160 | class wxHtmlWinParser : public wxHtmlParser { | |
161 | public: | |
ce914f73 | 162 | wxHtmlWinParser(wxHtmlWindow *wnd = NULL); |
0f66a9f3 RD |
163 | |
164 | void SetDC(wxDC *dc); | |
165 | wxDC* GetDC(); | |
166 | int GetCharHeight(); | |
167 | int GetCharWidth(); | |
6c5ae2d2 | 168 | wxHtmlWindow* GetWindow(); |
f6bcfd97 BP |
169 | //void SetFonts(wxString normal_face, wxString fixed_face, int *LIST); |
170 | %addmethods { | |
171 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes) { | |
172 | int* temp = int_LIST_helper(sizes); | |
173 | if (temp) { | |
174 | self->SetFonts(normal_face, fixed_face, temp); | |
175 | delete [] temp; | |
176 | } | |
177 | } | |
178 | } | |
0f66a9f3 RD |
179 | |
180 | wxHtmlContainerCell* GetContainer(); | |
181 | wxHtmlContainerCell* OpenContainer(); | |
dc2f8a65 | 182 | wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); |
0f66a9f3 | 183 | wxHtmlContainerCell* CloseContainer(); |
dc2f8a65 | 184 | |
0f66a9f3 RD |
185 | int GetFontSize(); |
186 | void SetFontSize(int s); | |
187 | int GetFontBold(); | |
188 | void SetFontBold(int x); | |
189 | int GetFontItalic(); | |
190 | void SetFontItalic(int x); | |
191 | int GetFontUnderlined(); | |
192 | void SetFontUnderlined(int x); | |
193 | int GetFontFixed(); | |
194 | void SetFontFixed(int x); | |
195 | int GetAlign(); | |
196 | void SetAlign(int a); | |
c5943253 | 197 | wxColour GetLinkColor(); |
0f66a9f3 | 198 | void SetLinkColor(const wxColour& clr); |
c5943253 | 199 | wxColour GetActualColor(); |
0f66a9f3 | 200 | void SetActualColor(const wxColour& clr); |
0f66a9f3 RD |
201 | void SetLink(const wxString& link); |
202 | wxFont* CreateCurrentFont(); | |
9c00cfa3 RD |
203 | wxHtmlLinkInfo GetLink(); |
204 | ||
0f66a9f3 RD |
205 | }; |
206 | ||
207 | ||
208 | ||
209 | //--------------------------------------------------------------------------- | |
210 | ||
211 | %{ | |
212 | class wxPyHtmlTagHandler : public wxHtmlTagHandler { | |
9416aa89 | 213 | DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler); |
0f66a9f3 RD |
214 | public: |
215 | wxPyHtmlTagHandler() : wxHtmlTagHandler() {}; | |
216 | ||
217 | wxHtmlParser* GetParser() { return m_Parser; } | |
218 | void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); } | |
219 | ||
220 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
221 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
222 | ||
223 | PYPRIVATE; | |
224 | }; | |
225 | ||
9416aa89 RD |
226 | IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler); |
227 | ||
0f66a9f3 RD |
228 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags); |
229 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag); | |
0f66a9f3 RD |
230 | %} |
231 | ||
232 | ||
9416aa89 | 233 | %name(wxHtmlTagHandler) class wxPyHtmlTagHandler : public wxObject { |
0f66a9f3 RD |
234 | public: |
235 | wxPyHtmlTagHandler(); | |
236 | ||
0122b7e3 RD |
237 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
238 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlTagHandler)" | |
0f66a9f3 RD |
239 | |
240 | void SetParser(wxHtmlParser *parser); | |
241 | wxHtmlParser* GetParser(); | |
242 | void ParseInner(const wxHtmlTag& tag); | |
243 | }; | |
244 | ||
245 | ||
246 | //--------------------------------------------------------------------------- | |
247 | ||
248 | %{ | |
249 | class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler { | |
9416aa89 | 250 | DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler); |
0f66a9f3 RD |
251 | public: |
252 | wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {}; | |
253 | ||
254 | wxHtmlWinParser* GetParser() { return m_WParser; } | |
255 | void ParseInner(const wxHtmlTag& tag) | |
256 | { wxHtmlWinTagHandler::ParseInner(tag); } | |
257 | ||
258 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
259 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
260 | ||
261 | PYPRIVATE; | |
262 | }; | |
263 | ||
9416aa89 RD |
264 | IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler); |
265 | ||
0f66a9f3 RD |
266 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags); |
267 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag); | |
0f66a9f3 RD |
268 | %} |
269 | ||
270 | ||
271 | %name(wxHtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler { | |
272 | public: | |
273 | wxPyHtmlWinTagHandler(); | |
274 | ||
0122b7e3 RD |
275 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
276 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWinTagHandler)" | |
0f66a9f3 RD |
277 | |
278 | void SetParser(wxHtmlParser *parser); | |
279 | wxHtmlWinParser* GetParser(); | |
280 | void ParseInner(const wxHtmlTag& tag); | |
281 | }; | |
282 | ||
283 | ||
284 | //--------------------------------------------------------------------------- | |
285 | ||
286 | %{ | |
287 | ||
288 | class wxPyHtmlTagsModule : public wxHtmlTagsModule { | |
289 | public: | |
290 | wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() { | |
291 | m_tagHandlerClass = thc; | |
292 | Py_INCREF(m_tagHandlerClass); | |
293 | RegisterModule(this); | |
294 | wxHtmlWinParser::AddModule(this); | |
295 | } | |
296 | ||
297 | void OnExit() { | |
4268f798 | 298 | wxPyBeginBlockThreads(); |
0f66a9f3 RD |
299 | Py_DECREF(m_tagHandlerClass); |
300 | m_tagHandlerClass = NULL; | |
dc2f8a65 | 301 | for (size_t x=0; x < m_objArray.GetCount(); x++) { |
0f66a9f3 RD |
302 | PyObject* obj = (PyObject*)m_objArray.Item(x); |
303 | Py_DECREF(obj); | |
304 | } | |
4268f798 | 305 | wxPyEndBlockThreads(); |
0f66a9f3 RD |
306 | }; |
307 | ||
308 | void FillHandlersTable(wxHtmlWinParser *parser) { | |
309 | // Wave our magic wand... (if it works it's a miracle! ;-) | |
310 | ||
311 | // First, make a new instance of the tag handler | |
4268f798 | 312 | wxPyBeginBlockThreads(); |
0f66a9f3 RD |
313 | PyObject* arg = Py_BuildValue("()"); |
314 | PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL); | |
315 | Py_DECREF(arg); | |
4268f798 | 316 | wxPyEndBlockThreads(); |
0f66a9f3 RD |
317 | |
318 | // now figure out where it's C++ object is... | |
319 | wxPyHtmlWinTagHandler* thPtr; | |
320 | if (SWIG_GetPtrObj(obj, (void **)&thPtr, "_wxPyHtmlWinTagHandler_p")) | |
321 | return; | |
322 | ||
323 | // add it, | |
324 | parser->AddTagHandler(thPtr); | |
325 | ||
326 | // and track it. | |
327 | m_objArray.Add(obj); | |
328 | } | |
329 | ||
330 | private: | |
331 | PyObject* m_tagHandlerClass; | |
332 | wxArrayPtrVoid m_objArray; | |
333 | ||
334 | }; | |
335 | %} | |
336 | ||
337 | ||
338 | ||
339 | %inline %{ | |
340 | void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) { | |
341 | // Dynamically create a new wxModule. Refcounts tagHandlerClass | |
342 | // and adds itself to the wxModules list and to the wxHtmlWinParser. | |
343 | new wxPyHtmlTagsModule(tagHandlerClass); | |
344 | } | |
345 | %} | |
346 | ||
dc2f8a65 | 347 | |
e166644c RD |
348 | //--------------------------------------------------------------------------- |
349 | //--------------------------------------------------------------------------- | |
350 | ||
9416aa89 | 351 | class wxHtmlCell : public wxObject { |
e166644c RD |
352 | public: |
353 | wxHtmlCell(); | |
354 | ||
e166644c RD |
355 | int GetPosX(); |
356 | int GetPosY(); | |
357 | int GetWidth(); | |
358 | int GetHeight(); | |
359 | int GetDescent(); | |
9c00cfa3 | 360 | wxHtmlLinkInfo* GetLink(int x = 0, int y = 0); |
e166644c | 361 | wxHtmlCell* GetNext(); |
9c00cfa3 RD |
362 | wxHtmlContainerCell* GetParent(); |
363 | void SetLink(const wxHtmlLinkInfo& link); | |
e166644c | 364 | void SetNext(wxHtmlCell *cell); |
9c00cfa3 RD |
365 | void SetParent(wxHtmlContainerCell *p); |
366 | void SetPos(int x, int y); | |
e166644c RD |
367 | void Layout(int w); |
368 | void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); | |
369 | void DrawInvisible(wxDC& dc, int x, int y); | |
370 | const wxHtmlCell* Find(int condition, const void* param); | |
dc2f8a65 RD |
371 | |
372 | bool AdjustPagebreak(int * pagebreak); | |
373 | void SetCanLiveOnPagebreak(bool can); | |
9c00cfa3 | 374 | |
e166644c RD |
375 | }; |
376 | ||
377 | ||
9416aa89 RD |
378 | class wxHtmlWordCell : public wxHtmlCell |
379 | { | |
380 | public: | |
381 | wxHtmlWordCell(const wxString& word, wxDC& dc); | |
382 | }; | |
383 | ||
384 | ||
e166644c RD |
385 | class wxHtmlContainerCell : public wxHtmlCell { |
386 | public: | |
387 | wxHtmlContainerCell(wxHtmlContainerCell *parent); | |
388 | ||
389 | void InsertCell(wxHtmlCell *cell); | |
390 | void SetAlignHor(int al); | |
391 | int GetAlignHor(); | |
392 | void SetAlignVer(int al); | |
393 | int GetAlignVer(); | |
9d8bd15f | 394 | void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); |
e166644c RD |
395 | int GetIndent(int ind); |
396 | int GetIndentUnits(int ind); | |
397 | void SetAlign(const wxHtmlTag& tag); | |
398 | void SetWidthFloat(int w, int units); | |
399 | %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag); | |
9d8bd15f | 400 | void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP); |
e166644c RD |
401 | void SetBackgroundColour(const wxColour& clr); |
402 | void SetBorder(const wxColour& clr1, const wxColour& clr2); | |
403 | wxHtmlCell* GetFirstCell(); | |
404 | }; | |
405 | ||
406 | ||
407 | ||
9c00cfa3 RD |
408 | class wxHtmlColourCell : public wxHtmlCell { |
409 | public: | |
410 | wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND); | |
411 | ||
412 | }; | |
413 | ||
414 | ||
9416aa89 RD |
415 | class wxHtmlFontCell : public wxHtmlCell |
416 | { | |
417 | public: | |
418 | wxHtmlFontCell(wxFont *font); | |
419 | }; | |
420 | ||
e166644c RD |
421 | |
422 | class wxHtmlWidgetCell : public wxHtmlCell { | |
423 | public: | |
424 | wxHtmlWidgetCell(wxWindow* wnd, int w = 0); | |
425 | ||
426 | }; | |
427 | ||
0f66a9f3 RD |
428 | |
429 | ||
430 | //--------------------------------------------------------------------------- | |
431 | //--------------------------------------------------------------------------- | |
4b123bb9 HH |
432 | //--------------------------------------------------------------------------- |
433 | ||
0f66a9f3 RD |
434 | %{ |
435 | class wxPyHtmlWindow : public wxHtmlWindow { | |
cdf14688 | 436 | DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow); |
0f66a9f3 RD |
437 | public: |
438 | wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1, | |
439 | const wxPoint& pos = wxDefaultPosition, | |
440 | const wxSize& size = wxDefaultSize, | |
441 | long style = wxHW_SCROLLBAR_AUTO, | |
442 | const wxString& name = "htmlWindow") | |
443 | : wxHtmlWindow(parent, id, pos, size, style, name) {}; | |
7b7ac0ab | 444 | wxPyHtmlWindow() : wxHtmlWindow() {}; |
0f66a9f3 | 445 | |
e5d41db0 RD |
446 | bool ScrollToAnchor(const wxString& anchor) { |
447 | return wxHtmlWindow::ScrollToAnchor(anchor); | |
448 | } | |
449 | ||
450 | bool HasAnchor(const wxString& anchor) { | |
451 | const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor); | |
452 | return c!=NULL; | |
453 | } | |
454 | ||
c8bc03c3 RD |
455 | void OnLinkClicked(const wxHtmlLinkInfo& link); |
456 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); | |
9c00cfa3 | 457 | |
e5d41db0 | 458 | wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, |
c6c593e8 RD |
459 | const wxString& url, |
460 | wxString *redirect) const; | |
461 | ||
9c00cfa3 | 462 | DEC_PYCALLBACK__STRING(OnSetTitle); |
0122b7e3 RD |
463 | DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover); |
464 | DEC_PYCALLBACK__CELLINTINTME(OnCellClicked); | |
c6c593e8 | 465 | // DEC_PYCALLBACK_BOOL_STRING(OnOpeningURL); |
0f66a9f3 RD |
466 | PYPRIVATE; |
467 | }; | |
468 | ||
cdf14688 | 469 | IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); |
9c00cfa3 | 470 | IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); |
0122b7e3 RD |
471 | IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover); |
472 | IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked); | |
c6c593e8 | 473 | // IMP_PYCALLBACK_BOOL_STRING(wxPyHtmlWindow, wxHtmlWindow, OnOpeningURL); |
0122b7e3 | 474 | |
0f66a9f3 | 475 | |
9416aa89 | 476 | void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { |
19a97bd6 | 477 | bool found; |
4268f798 | 478 | wxPyBeginBlockThreads(); |
0122b7e3 | 479 | if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { |
1e7ecb7b RD |
480 | PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo", 0); |
481 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); | |
de20db99 | 482 | Py_DECREF(obj); |
9c00cfa3 | 483 | } |
4268f798 | 484 | wxPyEndBlockThreads(); |
19a97bd6 | 485 | if (! found) |
9c00cfa3 | 486 | wxHtmlWindow::OnLinkClicked(link); |
9c00cfa3 | 487 | } |
c8bc03c3 | 488 | void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { |
9c00cfa3 RD |
489 | wxHtmlWindow::OnLinkClicked(link); |
490 | } | |
0122b7e3 | 491 | |
c6c593e8 RD |
492 | |
493 | wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type, | |
494 | const wxString& url, | |
495 | wxString *redirect) const { | |
496 | bool found; | |
497 | wxHtmlOpeningStatus rval; | |
498 | wxPyBeginBlockThreads(); | |
499 | if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) { | |
500 | PyObject* ro; | |
a541c325 | 501 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, wx2PyString(url))); |
c6c593e8 RD |
502 | if (PyString_Check(ro) |
503 | #if PYTHON_API_VERSION >= 1009 | |
504 | || PyUnicode_Check(ro) | |
505 | #endif | |
506 | ) { | |
a541c325 | 507 | *redirect = Py2wxString(ro); |
c6c593e8 RD |
508 | rval = wxHTML_REDIRECT; |
509 | } | |
510 | else { | |
511 | PyObject* num = PyNumber_Int(ro); | |
512 | rval = (wxHtmlOpeningStatus)PyInt_AsLong(num); | |
513 | Py_DECREF(num); | |
514 | } | |
515 | Py_DECREF(ro); | |
516 | } | |
517 | wxPyEndBlockThreads(); | |
518 | if (! found) | |
519 | rval = wxHtmlWindow::OnOpeningURL(type, url, redirect); | |
520 | return rval; | |
521 | } | |
522 | ||
523 | ||
0f66a9f3 RD |
524 | %} |
525 | ||
526 | ||
95837b4d | 527 | |
0f66a9f3 RD |
528 | %name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow { |
529 | public: | |
530 | wxPyHtmlWindow(wxWindow *parent, int id = -1, | |
1e7ecb7b RD |
531 | wxPoint& pos = wxDefaultPosition, |
532 | wxSize& size = wxDefaultSize, | |
0f66a9f3 RD |
533 | int flags=wxHW_SCROLLBAR_AUTO, |
534 | char* name = "htmlWindow"); | |
7b7ac0ab RD |
535 | %name(wxPreHtmlWindow)wxPyHtmlWindow(); |
536 | ||
537 | bool Create(wxWindow *parent, int id = -1, | |
538 | wxPoint& pos = wxDefaultPosition, | |
539 | wxSize& size = wxDefaultSize, | |
540 | int flags=wxHW_SCROLLBAR_AUTO, | |
541 | char* name = "htmlWindow"); | |
542 | ||
0f66a9f3 | 543 | |
0122b7e3 RD |
544 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
545 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWindow)" | |
0122b7e3 | 546 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
7b7ac0ab | 547 | %pragma(python) addtomethod = "wxPreHtmlWindow:val._setOORInfo(val)" |
0f66a9f3 | 548 | |
7a446686 RD |
549 | bool SetPage(const wxString& source); |
550 | bool LoadPage(const wxString& location); | |
de112a55 | 551 | bool AppendToPage(const wxString& source); |
0f66a9f3 | 552 | wxString GetOpenedPage(); |
7a446686 RD |
553 | wxString GetOpenedAnchor(); |
554 | wxString GetOpenedPageTitle(); | |
555 | ||
0f66a9f3 | 556 | void SetRelatedFrame(wxFrame* frame, const char* format); |
0f66a9f3 | 557 | wxFrame* GetRelatedFrame(); |
0f66a9f3 | 558 | void SetRelatedStatusBar(int bar); |
f6bcfd97 BP |
559 | |
560 | //void SetFonts(wxString normal_face, wxString fixed_face, int *LIST); | |
561 | %addmethods { | |
562 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes) { | |
563 | int* temp = int_LIST_helper(sizes); | |
564 | if (temp) { | |
565 | self->SetFonts(normal_face, fixed_face, temp); | |
566 | delete [] temp; | |
567 | } | |
568 | } | |
569 | } | |
570 | ||
7a446686 | 571 | void SetTitle(const wxString& title); |
0f66a9f3 | 572 | void SetBorders(int b); |
7a446686 RD |
573 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); |
574 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); | |
0f66a9f3 RD |
575 | bool HistoryBack(); |
576 | bool HistoryForward(); | |
7a446686 RD |
577 | bool HistoryCanBack(); |
578 | bool HistoryCanForward(); | |
0f66a9f3 | 579 | void HistoryClear(); |
a65c6e14 | 580 | wxHtmlContainerCell* GetInternalRepresentation(); |
e166644c RD |
581 | wxHtmlWinParser* GetParser(); |
582 | ||
e5d41db0 RD |
583 | bool ScrollToAnchor(const wxString& anchor); |
584 | bool HasAnchor(const wxString& anchor); | |
585 | ||
c8bc03c3 | 586 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); |
9c00cfa3 | 587 | void base_OnSetTitle(const char* title); |
0122b7e3 RD |
588 | void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y); |
589 | void base_OnCellClicked(wxHtmlCell *cell, | |
590 | wxCoord x, wxCoord y, | |
591 | const wxMouseEvent& event); | |
4b123bb9 HH |
592 | }; |
593 | ||
0f66a9f3 RD |
594 | // Static methods are mapped to stand-alone functions |
595 | %inline %{ | |
596 | void wxHtmlWindow_AddFilter(wxHtmlFilter *filter) { | |
597 | wxHtmlWindow::AddFilter(filter); | |
598 | } | |
599 | %} | |
5ca24bf4 | 600 | |
5ca24bf4 | 601 | |
dc2f8a65 RD |
602 | //--------------------------------------------------------------------------- |
603 | //--------------------------------------------------------------------------- | |
604 | ||
605 | ||
9416aa89 | 606 | class wxHtmlDCRenderer : public wxObject { |
dc2f8a65 RD |
607 | public: |
608 | wxHtmlDCRenderer(); | |
609 | ~wxHtmlDCRenderer(); | |
610 | ||
611 | void SetDC(wxDC *dc, int maxwidth); | |
612 | void SetSize(int width, int height); | |
613 | void SetHtmlText(const wxString& html, | |
614 | const wxString& basepath = wxEmptyString, | |
615 | bool isdir = TRUE); | |
616 | int Render(int x, int y, int from = 0, int dont_render = FALSE); | |
617 | int GetTotalHeight(); | |
618 | // returns total height of the html document | |
619 | // (compare Render's return value with this) | |
620 | }; | |
621 | ||
622 | enum { | |
623 | wxPAGE_ODD, | |
624 | wxPAGE_EVEN, | |
625 | wxPAGE_ALL | |
626 | }; | |
627 | ||
628 | ||
629 | class wxHtmlPrintout : public wxPyPrintout { | |
630 | public: | |
65dd82cb | 631 | wxHtmlPrintout(const char* title = "Printout"); |
f3d9dc1d | 632 | //~wxHtmlPrintout(); wxPrintPreview object takes ownership... |
dc2f8a65 RD |
633 | |
634 | void SetHtmlText(const wxString& html, | |
635 | const wxString &basepath = wxEmptyString, | |
636 | bool isdir = TRUE); | |
637 | void SetHtmlFile(const wxString &htmlfile); | |
638 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
639 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
640 | void SetMargins(float top = 25.2, float bottom = 25.2, | |
641 | float left = 25.2, float right = 25.2, | |
642 | float spaces = 5); | |
643 | }; | |
644 | ||
645 | ||
646 | ||
9416aa89 | 647 | class wxHtmlEasyPrinting : public wxObject { |
dc2f8a65 | 648 | public: |
65dd82cb | 649 | wxHtmlEasyPrinting(const char* name = "Printing", |
dc2f8a65 RD |
650 | wxFrame *parent_frame = NULL); |
651 | ~wxHtmlEasyPrinting(); | |
652 | ||
653 | void PreviewFile(const wxString &htmlfile); | |
654 | void PreviewText(const wxString &htmltext, const wxString& basepath = wxEmptyString); | |
655 | void PrintFile(const wxString &htmlfile); | |
656 | void PrintText(const wxString &htmltext, const wxString& basepath = wxEmptyString); | |
657 | void PrinterSetup(); | |
658 | void PageSetup(); | |
659 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
660 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
661 | ||
662 | wxPrintData *GetPrintData() {return m_PrintData;} | |
663 | wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} | |
664 | ||
665 | }; | |
666 | ||
667 | ||
668 | ||
0f66a9f3 RD |
669 | //--------------------------------------------------------------------------- |
670 | //--------------------------------------------------------------------------- | |
5ca24bf4 | 671 | |
0f66a9f3 RD |
672 | %{ |
673 | extern "C" SWIGEXPORT(void) inithtmlhelpc(); | |
674 | %} | |
4b123bb9 | 675 | |
4b123bb9 HH |
676 | |
677 | %init %{ | |
678 | ||
2f90df85 | 679 | inithtmlhelpc(); |
0f66a9f3 | 680 | |
e508a2b6 RD |
681 | wxClassInfo::CleanUpClasses(); |
682 | wxClassInfo::InitializeClasses(); | |
9416aa89 RD |
683 | |
684 | wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler"); | |
685 | wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler"); | |
686 | wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow"); | |
4b123bb9 HH |
687 | %} |
688 | ||
e166644c RD |
689 | //---------------------------------------------------------------------- |
690 | // And this gets appended to the shadow class file. | |
691 | //---------------------------------------------------------------------- | |
692 | ||
f6bcfd97 | 693 | %pragma(python) include="_htmlextras.py"; |
e166644c | 694 | |
4b123bb9 | 695 | //--------------------------------------------------------------------------- |