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