]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/html.i
SWIGged updates for wxMac
[wxWidgets.git] / wxPython / src / html.i
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 #include <wx/filesys.h>
25
26 #include "printfw.h"
27 %}
28
29 //---------------------------------------------------------------------------
30
31 %include typemaps.i
32 %include my_typemaps.i
33
34 %extern wx.i
35 %extern windows.i
36 %extern _defs.i
37 %extern events.i
38 %extern controls.i
39 %extern controls2.i
40 %extern printfw.i
41 %extern utils.i
42 %extern filesys.i
43 %extern streams.i
44
45
46 %pragma(python) code = "import wx"
47
48
49 //----------------------------------------------------------------------
50
51 %{
52 // Put some wx default wxChar* values into wxStrings.
53 static const wxChar* wxHtmlWindowNameStr = wxT("htmlWindow");
54 DECLARE_DEF_STRING(HtmlWindowNameStr);
55
56 static const wxChar* wxHtmlPrintoutTitleStr = wxT("Printout");
57 DECLARE_DEF_STRING(HtmlPrintoutTitleStr);
58
59 static const wxChar* wxHtmlPrintingTitleStr = wxT("Printing");
60 DECLARE_DEF_STRING(HtmlPrintingTitleStr);
61
62 static const wxString wxPyEmptyString(wxT(""));
63 %}
64
65 //---------------------------------------------------------------------------
66
67 enum {
68 wxHTML_ALIGN_LEFT,
69 wxHTML_ALIGN_CENTER,
70 wxHTML_ALIGN_RIGHT,
71 wxHTML_ALIGN_BOTTOM,
72 wxHTML_ALIGN_TOP,
73
74 wxHTML_CLR_FOREGROUND,
75 wxHTML_CLR_BACKGROUND,
76
77 wxHTML_UNITS_PIXELS,
78 wxHTML_UNITS_PERCENT,
79
80 wxHTML_INDENT_LEFT,
81 wxHTML_INDENT_RIGHT,
82 wxHTML_INDENT_TOP,
83 wxHTML_INDENT_BOTTOM,
84
85 wxHTML_INDENT_HORIZONTAL,
86 wxHTML_INDENT_VERTICAL,
87 wxHTML_INDENT_ALL,
88
89 wxHTML_COND_ISANCHOR,
90 wxHTML_COND_ISIMAGEMAP,
91 wxHTML_COND_USER,
92 };
93
94
95 enum {
96 wxHW_SCROLLBAR_NEVER,
97 wxHW_SCROLLBAR_AUTO,
98 };
99
100
101 // enums for wxHtmlWindow::OnOpeningURL
102 enum wxHtmlOpeningStatus
103 {
104 wxHTML_OPEN,
105 wxHTML_BLOCK,
106 wxHTML_REDIRECT
107 };
108
109 enum wxHtmlURLType
110 {
111 wxHTML_URL_PAGE,
112 wxHTML_URL_IMAGE,
113 wxHTML_URL_OTHER
114 };
115
116 //---------------------------------------------------------------------------
117
118 class wxHtmlLinkInfo : public wxObject {
119 public:
120 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
121 wxString GetHref();
122 wxString GetTarget();
123 wxMouseEvent* GetEvent();
124 wxHtmlCell* GetHtmlCell();
125
126 void SetEvent(const wxMouseEvent *e);
127 void SetHtmlCell(const wxHtmlCell * e);
128 };
129
130 //---------------------------------------------------------------------------
131
132 class wxHtmlTag : public wxObject {
133 public:
134 // Never need to create a new tag from Python...
135 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
136
137 wxString GetName();
138 bool HasParam(const wxString& par);
139 wxString GetParam(const wxString& par, int with_commas = FALSE);
140
141 // Can't do this one as-is, but GetParam should be enough...
142 //int ScanParam(const wxString& par, const char *format, void* param);
143
144 wxString GetAllParams();
145 bool HasEnding();
146 int GetBeginPos();
147 int GetEndPos1();
148 int GetEndPos2();
149 };
150
151
152 //---------------------------------------------------------------------------
153
154 class wxHtmlParser : public wxObject {
155 public:
156 // wxHtmlParser(); This is an abstract base class...
157
158 void SetFS(wxFileSystem *fs);
159 wxFileSystem* GetFS();
160 wxObject* Parse(const wxString& source);
161 void InitParser(const wxString& source);
162 void DoneParser();
163 void DoParsing(int begin_pos, int end_pos);
164 void StopParsing();
165 // wxObject* GetProduct();
166
167 void AddTagHandler(wxHtmlTagHandler *handler);
168 wxString* GetSource();
169 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
170 void PopTagHandler();
171
172 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
173
174 // void AddText(const char* txt) = 0;
175 // void AddTag(const wxHtmlTag& tag);
176 };
177
178
179 //---------------------------------------------------------------------------
180
181 class wxHtmlWinParser : public wxHtmlParser {
182 public:
183 wxHtmlWinParser(wxHtmlWindow *wnd = NULL);
184
185 void SetDC(wxDC *dc);
186 wxDC* GetDC();
187 int GetCharHeight();
188 int GetCharWidth();
189 wxHtmlWindow* GetWindow();
190 %addmethods {
191 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
192 int* temp = NULL;
193 if (sizes) temp = int_LIST_helper(sizes);
194 self->SetFonts(normal_face, fixed_face, temp);
195 if (temp)
196 delete [] temp;
197 }
198 }
199
200 wxHtmlContainerCell* GetContainer();
201 wxHtmlContainerCell* OpenContainer();
202 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
203 wxHtmlContainerCell* CloseContainer();
204
205 int GetFontSize();
206 void SetFontSize(int s);
207 int GetFontBold();
208 void SetFontBold(int x);
209 int GetFontItalic();
210 void SetFontItalic(int x);
211 int GetFontUnderlined();
212 void SetFontUnderlined(int x);
213 int GetFontFixed();
214 void SetFontFixed(int x);
215 int GetAlign();
216 void SetAlign(int a);
217 wxColour GetLinkColor();
218 void SetLinkColor(const wxColour& clr);
219 wxColour GetActualColor();
220 void SetActualColor(const wxColour& clr);
221 void SetLink(const wxString& link);
222 wxFont* CreateCurrentFont();
223 wxHtmlLinkInfo GetLink();
224
225 };
226
227
228
229 //---------------------------------------------------------------------------
230
231 %{
232 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
233 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
234 public:
235 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
236
237 wxHtmlParser* GetParser() { return m_Parser; }
238 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
239
240 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
241 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
242
243 PYPRIVATE;
244 };
245
246 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
247
248 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
249 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
250 %}
251
252
253 %name(wxHtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
254 public:
255 wxPyHtmlTagHandler();
256
257 void _setCallbackInfo(PyObject* self, PyObject* _class);
258 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlTagHandler)"
259
260 void SetParser(wxHtmlParser *parser);
261 wxHtmlParser* GetParser();
262 void ParseInner(const wxHtmlTag& tag);
263 };
264
265
266 //---------------------------------------------------------------------------
267
268 %{
269 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
270 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
271 public:
272 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
273
274 wxHtmlWinParser* GetParser() { return m_WParser; }
275 void ParseInner(const wxHtmlTag& tag)
276 { wxHtmlWinTagHandler::ParseInner(tag); }
277
278 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
279 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
280
281 PYPRIVATE;
282 };
283
284 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
285
286 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
287 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
288 %}
289
290
291 %name(wxHtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
292 public:
293 wxPyHtmlWinTagHandler();
294
295 void _setCallbackInfo(PyObject* self, PyObject* _class);
296 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWinTagHandler)"
297
298 void SetParser(wxHtmlParser *parser);
299 wxHtmlWinParser* GetParser();
300 void ParseInner(const wxHtmlTag& tag);
301 };
302
303
304 //---------------------------------------------------------------------------
305
306 %{
307
308 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
309 public:
310 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
311 m_tagHandlerClass = thc;
312 Py_INCREF(m_tagHandlerClass);
313 RegisterModule(this);
314 wxHtmlWinParser::AddModule(this);
315 }
316
317 void OnExit() {
318 wxPyBeginBlockThreads();
319 Py_DECREF(m_tagHandlerClass);
320 m_tagHandlerClass = NULL;
321 for (size_t x=0; x < m_objArray.GetCount(); x++) {
322 PyObject* obj = (PyObject*)m_objArray.Item(x);
323 Py_DECREF(obj);
324 }
325 wxPyEndBlockThreads();
326 };
327
328 void FillHandlersTable(wxHtmlWinParser *parser) {
329 // Wave our magic wand... (if it works it's a miracle! ;-)
330
331 // First, make a new instance of the tag handler
332 wxPyBeginBlockThreads();
333 PyObject* arg = Py_BuildValue("()");
334 PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL);
335 Py_DECREF(arg);
336 wxPyEndBlockThreads();
337
338 // now figure out where it's C++ object is...
339 wxPyHtmlWinTagHandler* thPtr;
340 if (SWIG_GetPtrObj(obj, (void **)&thPtr, "_wxPyHtmlWinTagHandler_p"))
341 return;
342
343 // add it,
344 parser->AddTagHandler(thPtr);
345
346 // and track it.
347 m_objArray.Add(obj);
348 }
349
350 private:
351 PyObject* m_tagHandlerClass;
352 wxArrayPtrVoid m_objArray;
353
354 };
355 %}
356
357
358
359 %inline %{
360 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
361 // Dynamically create a new wxModule. Refcounts tagHandlerClass
362 // and adds itself to the wxModules list and to the wxHtmlWinParser.
363 new wxPyHtmlTagsModule(tagHandlerClass);
364 }
365 %}
366
367
368 //---------------------------------------------------------------------------
369 //---------------------------------------------------------------------------
370
371 class wxHtmlCell : public wxObject {
372 public:
373 wxHtmlCell();
374
375 int GetPosX();
376 int GetPosY();
377 int GetWidth();
378 int GetHeight();
379 int GetDescent();
380 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
381 wxHtmlCell* GetNext();
382 wxHtmlContainerCell* GetParent();
383 void SetLink(const wxHtmlLinkInfo& link);
384 void SetNext(wxHtmlCell *cell);
385 void SetParent(wxHtmlContainerCell *p);
386 void SetPos(int x, int y);
387 void Layout(int w);
388 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
389 void DrawInvisible(wxDC& dc, int x, int y);
390 const wxHtmlCell* Find(int condition, const void* param);
391
392 bool AdjustPagebreak(int * pagebreak);
393 void SetCanLiveOnPagebreak(bool can);
394
395 };
396
397
398 class wxHtmlWordCell : public wxHtmlCell
399 {
400 public:
401 wxHtmlWordCell(const wxString& word, wxDC& dc);
402 };
403
404
405 class wxHtmlContainerCell : public wxHtmlCell {
406 public:
407 wxHtmlContainerCell(wxHtmlContainerCell *parent);
408
409 void InsertCell(wxHtmlCell *cell);
410 void SetAlignHor(int al);
411 int GetAlignHor();
412 void SetAlignVer(int al);
413 int GetAlignVer();
414 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
415 int GetIndent(int ind);
416 int GetIndentUnits(int ind);
417 void SetAlign(const wxHtmlTag& tag);
418 void SetWidthFloat(int w, int units);
419 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
420 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
421 void SetBackgroundColour(const wxColour& clr);
422 wxColour GetBackgroundColour();
423 void SetBorder(const wxColour& clr1, const wxColour& clr2);
424 wxHtmlCell* GetFirstCell();
425 };
426
427
428
429 class wxHtmlColourCell : public wxHtmlCell {
430 public:
431 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
432
433 };
434
435
436 class wxHtmlFontCell : public wxHtmlCell
437 {
438 public:
439 wxHtmlFontCell(wxFont *font);
440 };
441
442
443 class wxHtmlWidgetCell : public wxHtmlCell {
444 public:
445 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
446
447 };
448
449
450 //---------------------------------------------------------------------------
451 // wxHtmlFilter
452 //---------------------------------------------------------------------------
453
454
455 %{ // here's the C++ version
456 class wxPyHtmlFilter : public wxHtmlFilter {
457 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
458 public:
459 wxPyHtmlFilter() : wxHtmlFilter() {}
460
461 // returns TRUE if this filter is able to open&read given file
462 virtual bool CanRead(const wxFSFile& file) const {
463 bool rval = FALSE;
464 bool found;
465 wxPyBeginBlockThreads();
466 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
467 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
468 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
469 Py_DECREF(obj);
470 }
471 wxPyEndBlockThreads();
472 return rval;
473 }
474
475
476 // Reads given file and returns HTML document.
477 // Returns empty string if opening failed
478 virtual wxString ReadFile(const wxFSFile& file) const {
479 wxString rval;
480 bool found;
481 wxPyBeginBlockThreads();
482 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
483 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
484 PyObject* ro;
485 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
486 Py_DECREF(obj);
487 if (ro) {
488 rval = Py2wxString(ro);
489 Py_DECREF(ro);
490 }
491 }
492 wxPyEndBlockThreads();
493 return rval;
494 }
495
496 PYPRIVATE;
497 };
498
499 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
500 %}
501
502
503 // And now the version seen by SWIG
504
505 %name(wxHtmlFilter) class wxPyHtmlFilter : public wxObject {
506 public:
507 wxPyHtmlFilter();
508
509 void _setCallbackInfo(PyObject* self, PyObject* _class);
510 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlFilter)"
511 };
512
513
514 // TODO: wxHtmlFilterHTML
515
516
517 //---------------------------------------------------------------------------
518 // wxHtmlWindow
519 //---------------------------------------------------------------------------
520
521 %{
522 class wxPyHtmlWindow : public wxHtmlWindow {
523 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
524 public:
525 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
526 const wxPoint& pos = wxDefaultPosition,
527 const wxSize& size = wxDefaultSize,
528 long style = wxHW_SCROLLBAR_AUTO,
529 const wxString& name = wxPyHtmlWindowNameStr)
530 : wxHtmlWindow(parent, id, pos, size, style, name) {};
531 wxPyHtmlWindow() : wxHtmlWindow() {};
532
533 bool ScrollToAnchor(const wxString& anchor) {
534 return wxHtmlWindow::ScrollToAnchor(anchor);
535 }
536
537 bool HasAnchor(const wxString& anchor) {
538 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
539 return c!=NULL;
540 }
541
542 void OnLinkClicked(const wxHtmlLinkInfo& link);
543 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
544
545 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
546 const wxString& url,
547 wxString *redirect) const;
548
549 DEC_PYCALLBACK__STRING(OnSetTitle);
550 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
551 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
552 PYPRIVATE;
553 };
554
555 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
556 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
557 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
558 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
559
560
561 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
562 bool found;
563 wxPyBeginBlockThreads();
564 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
565 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
566 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
567 Py_DECREF(obj);
568 }
569 wxPyEndBlockThreads();
570 if (! found)
571 wxHtmlWindow::OnLinkClicked(link);
572 }
573 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
574 wxHtmlWindow::OnLinkClicked(link);
575 }
576
577
578 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
579 const wxString& url,
580 wxString *redirect) const {
581 bool found;
582 wxHtmlOpeningStatus rval;
583 wxPyBeginBlockThreads();
584 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
585 PyObject* ro;
586 PyObject* s = wx2PyString(url);
587 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
588 Py_DECREF(s);
589 if (PyString_Check(ro)
590 #if PYTHON_API_VERSION >= 1009
591 || PyUnicode_Check(ro)
592 #endif
593 ) {
594 *redirect = Py2wxString(ro);
595 rval = wxHTML_REDIRECT;
596 }
597 else {
598 PyObject* num = PyNumber_Int(ro);
599 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
600 Py_DECREF(num);
601 }
602 Py_DECREF(ro);
603 }
604 wxPyEndBlockThreads();
605 if (! found)
606 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
607 return rval;
608 }
609
610
611 %}
612
613
614
615 %name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
616 public:
617 wxPyHtmlWindow(wxWindow *parent, int id = -1,
618 wxPoint& pos = wxDefaultPosition,
619 wxSize& size = wxDefaultSize,
620 int style=wxHW_SCROLLBAR_AUTO,
621 const wxString& name = wxPyHtmlWindowNameStr);
622 %name(wxPreHtmlWindow)wxPyHtmlWindow();
623
624 bool Create(wxWindow *parent, int id = -1,
625 wxPoint& pos = wxDefaultPosition,
626 wxSize& size = wxDefaultSize,
627 int style=wxHW_SCROLLBAR_AUTO,
628 const wxString& name = wxPyHtmlWindowNameStr);
629
630
631 void _setCallbackInfo(PyObject* self, PyObject* _class);
632 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWindow)"
633 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
634 %pragma(python) addtomethod = "wxPreHtmlWindow:val._setOORInfo(val)"
635
636 // Set HTML page and display it. !! source is HTML document itself,
637 // it is NOT address/filename of HTML document. If you want to
638 // specify document location, use LoadPage() istead
639 // Return value : FALSE if an error occured, TRUE otherwise
640 bool SetPage(const wxString& source);
641
642 // Load HTML page from given location. Location can be either
643 // a) /usr/wxGTK2/docs/html/wx.htm
644 // b) http://www.somewhere.uk/document.htm
645 // c) ftp://ftp.somesite.cz/pub/something.htm
646 // In case there is no prefix (http:,ftp:), the method
647 // will try to find it itself (1. local file, then http or ftp)
648 // After the page is loaded, the method calls SetPage() to display it.
649 // Note : you can also use path relative to previously loaded page
650 // Return value : same as SetPage
651 bool LoadPage(const wxString& location);
652
653 // TODO: (accept a string, convert to filename)
654 // Loads HTML page from file
655 // bool LoadFile(const wxFileName& filename);
656
657 // Append to current page
658 bool AppendToPage(const wxString& source);
659
660 // Returns full location of opened page
661 wxString GetOpenedPage();
662
663 // Returns anchor within opened page
664 wxString GetOpenedAnchor();
665
666 // Returns <TITLE> of opened page or empty string otherwise
667 wxString GetOpenedPageTitle();
668
669 // Sets frame in which page title will be displayed. Format is format of
670 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
671 void SetRelatedFrame(wxFrame* frame, const wxString& format);
672 wxFrame* GetRelatedFrame();
673
674 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
675 // will be displayed. Default is -1 = no messages.
676 void SetRelatedStatusBar(int bar);
677
678 // Sets fonts to be used when displaying HTML page.
679 %addmethods {
680 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
681 int* temp = NULL;
682 if (sizes) temp = int_LIST_helper(sizes);
683 self->SetFonts(normal_face, fixed_face, temp);
684 if (temp)
685 delete [] temp;
686 }
687 }
688
689 void SetTitle(const wxString& title);
690
691 // Sets space between text and window borders.
692 void SetBorders(int b);
693
694 // Saves custom settings into cfg config. it will use the path 'path'
695 // if given, otherwise it will save info into currently selected path.
696 // saved values : things set by SetFonts, SetBorders.
697 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
698 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
699
700 // Goes to previous/next page (in browsing history)
701 // Returns TRUE if successful, FALSE otherwise
702 bool HistoryBack();
703 bool HistoryForward();
704 bool HistoryCanBack();
705 bool HistoryCanForward();
706
707 // Resets History
708 void HistoryClear();
709
710 // Returns pointer to conteiners/cells structure.
711 wxHtmlContainerCell* GetInternalRepresentation();
712
713 // Returns a pointer to the parser.
714 wxHtmlWinParser* GetParser();
715
716 bool ScrollToAnchor(const wxString& anchor);
717 bool HasAnchor(const wxString& anchor);
718
719 //Adds input filter
720 static void AddFilter(wxPyHtmlFilter *filter);
721
722
723 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
724 void base_OnSetTitle(const wxString& title);
725 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
726 void base_OnCellClicked(wxHtmlCell *cell,
727 wxCoord x, wxCoord y,
728 const wxMouseEvent& event);
729 };
730
731
732
733 //---------------------------------------------------------------------------
734 //---------------------------------------------------------------------------
735
736
737 class wxHtmlDCRenderer : public wxObject {
738 public:
739 wxHtmlDCRenderer();
740 ~wxHtmlDCRenderer();
741
742 void SetDC(wxDC *dc, int maxwidth);
743 void SetSize(int width, int height);
744 void SetHtmlText(const wxString& html,
745 const wxString& basepath = wxPyEmptyString,
746 bool isdir = TRUE);
747 %addmethods {
748 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
749 int* temp = NULL;
750 if (sizes) temp = int_LIST_helper(sizes);
751 self->SetFonts(normal_face, fixed_face, temp);
752 if (temp)
753 delete [] temp;
754 }
755 }
756 int Render(int x, int y, int from = 0, int dont_render = FALSE);
757 int GetTotalHeight();
758 // returns total height of the html document
759 // (compare Render's return value with this)
760 };
761
762 enum {
763 wxPAGE_ODD,
764 wxPAGE_EVEN,
765 wxPAGE_ALL
766 };
767
768
769 class wxHtmlPrintout : public wxPyPrintout {
770 public:
771 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
772 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
773
774 void SetHtmlText(const wxString& html,
775 const wxString &basepath = wxPyEmptyString,
776 bool isdir = TRUE);
777 void SetHtmlFile(const wxString &htmlfile);
778 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
779 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
780 %addmethods {
781 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
782 int* temp = NULL;
783 if (sizes) temp = int_LIST_helper(sizes);
784 self->SetFonts(normal_face, fixed_face, temp);
785 if (temp)
786 delete [] temp;
787 }
788 }
789 void SetMargins(float top = 25.2, float bottom = 25.2,
790 float left = 25.2, float right = 25.2,
791 float spaces = 5);
792 };
793
794
795
796 class wxHtmlEasyPrinting : public wxObject {
797 public:
798 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
799 wxFrame *parent_frame = NULL);
800 ~wxHtmlEasyPrinting();
801
802 void PreviewFile(const wxString &htmlfile);
803 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
804 void PrintFile(const wxString &htmlfile);
805 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
806 void PrinterSetup();
807 void PageSetup();
808 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
809 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
810
811 %addmethods {
812 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
813 int* temp = NULL;
814 if (sizes) temp = int_LIST_helper(sizes);
815 self->SetFonts(normal_face, fixed_face, temp);
816 if (temp)
817 delete [] temp;
818 }
819 }
820
821 wxPrintData *GetPrintData() {return m_PrintData;}
822 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
823
824 };
825
826
827
828 //---------------------------------------------------------------------------
829 //---------------------------------------------------------------------------
830
831 %{
832 extern "C" SWIGEXPORT(void) inithtmlhelpc();
833 %}
834
835
836 %init %{
837
838 inithtmlhelpc();
839
840 wxClassInfo::CleanUpClasses();
841 wxClassInfo::InitializeClasses();
842
843 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
844 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
845 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
846 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
847 %}
848
849 //----------------------------------------------------------------------
850 // And this gets appended to the shadow class file.
851 //----------------------------------------------------------------------
852
853 %pragma(python) include="_htmlextras.py";
854
855 //---------------------------------------------------------------------------