]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/html.i
wxPython Merge #2 of 2.4 branch --> HEAD (branch tag: wxPy_2_4_merge_2)
[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(wxPyHtmlWindow *wnd = NULL);
184
185 void SetDC(wxDC *dc);
186 wxDC* GetDC();
187 int GetCharHeight();
188 int GetCharWidth();
189 wxPyHtmlWindow* GetWindow();
190 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
191 %addmethods {
192 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
193 int* temp = NULL;
194 if (sizes) temp = int_LIST_helper(sizes);
195 self->SetFonts(normal_face, fixed_face, temp);
196 if (temp)
197 delete [] temp;
198 }
199 }
200
201 wxHtmlContainerCell* GetContainer();
202 wxHtmlContainerCell* OpenContainer();
203 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
204 wxHtmlContainerCell* CloseContainer();
205
206 int GetFontSize();
207 void SetFontSize(int s);
208 int GetFontBold();
209 void SetFontBold(int x);
210 int GetFontItalic();
211 void SetFontItalic(int x);
212 int GetFontUnderlined();
213 void SetFontUnderlined(int x);
214 int GetFontFixed();
215 void SetFontFixed(int x);
216 int GetAlign();
217 void SetAlign(int a);
218 wxColour GetLinkColor();
219 void SetLinkColor(const wxColour& clr);
220 wxColour GetActualColor();
221 void SetActualColor(const wxColour& clr);
222 void SetLink(const wxString& link);
223 wxFont* CreateCurrentFont();
224 wxHtmlLinkInfo GetLink();
225
226 };
227
228
229
230 //---------------------------------------------------------------------------
231
232 %{
233 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
234 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
235 public:
236 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
237
238 wxHtmlParser* GetParser() { return m_Parser; }
239 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
240
241 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
242 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
243
244 PYPRIVATE;
245 };
246
247 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
248
249 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
250 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
251 %}
252
253
254 %name(wxHtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
255 public:
256 wxPyHtmlTagHandler();
257
258 void _setCallbackInfo(PyObject* self, PyObject* _class);
259 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlTagHandler)"
260
261 void SetParser(wxHtmlParser *parser);
262 wxHtmlParser* GetParser();
263 void ParseInner(const wxHtmlTag& tag);
264 };
265
266
267 //---------------------------------------------------------------------------
268
269 %{
270 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
271 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
272 public:
273 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
274
275 wxHtmlWinParser* GetParser() { return m_WParser; }
276 void ParseInner(const wxHtmlTag& tag)
277 { wxHtmlWinTagHandler::ParseInner(tag); }
278
279 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
280 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
281
282 PYPRIVATE;
283 };
284
285 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
286
287 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
288 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
289 %}
290
291
292 %name(wxHtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
293 public:
294 wxPyHtmlWinTagHandler();
295
296 void _setCallbackInfo(PyObject* self, PyObject* _class);
297 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWinTagHandler)"
298
299 void SetParser(wxHtmlParser *parser);
300 wxHtmlWinParser* GetParser();
301 void ParseInner(const wxHtmlTag& tag);
302 };
303
304
305 //---------------------------------------------------------------------------
306
307 %{
308
309 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
310 public:
311 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
312 m_tagHandlerClass = thc;
313 Py_INCREF(m_tagHandlerClass);
314 RegisterModule(this);
315 wxHtmlWinParser::AddModule(this);
316 }
317
318 void OnExit() {
319 wxPyBeginBlockThreads();
320 Py_DECREF(m_tagHandlerClass);
321 m_tagHandlerClass = NULL;
322 for (size_t x=0; x < m_objArray.GetCount(); x++) {
323 PyObject* obj = (PyObject*)m_objArray.Item(x);
324 Py_DECREF(obj);
325 }
326 wxPyEndBlockThreads();
327 };
328
329 void FillHandlersTable(wxHtmlWinParser *parser) {
330 // Wave our magic wand... (if it works it's a miracle! ;-)
331
332 // First, make a new instance of the tag handler
333 wxPyBeginBlockThreads();
334 PyObject* arg = Py_BuildValue("()");
335 PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL);
336 Py_DECREF(arg);
337 wxPyEndBlockThreads();
338
339 // now figure out where it's C++ object is...
340 wxPyHtmlWinTagHandler* thPtr;
341 if (SWIG_GetPtrObj(obj, (void **)&thPtr, "_wxPyHtmlWinTagHandler_p"))
342 return;
343
344 // add it,
345 parser->AddTagHandler(thPtr);
346
347 // and track it.
348 m_objArray.Add(obj);
349 }
350
351 private:
352 PyObject* m_tagHandlerClass;
353 wxArrayPtrVoid m_objArray;
354
355 };
356 %}
357
358
359
360 %inline %{
361 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
362 // Dynamically create a new wxModule. Refcounts tagHandlerClass
363 // and adds itself to the wxModules list and to the wxHtmlWinParser.
364 new wxPyHtmlTagsModule(tagHandlerClass);
365 }
366 %}
367
368
369 //---------------------------------------------------------------------------
370 //---------------------------------------------------------------------------
371
372 class wxHtmlCell : public wxObject {
373 public:
374 wxHtmlCell();
375
376 int GetPosX();
377 int GetPosY();
378 int GetWidth();
379 int GetHeight();
380 int GetDescent();
381 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
382 wxHtmlCell* GetNext();
383 wxHtmlContainerCell* GetParent();
384 void SetLink(const wxHtmlLinkInfo& link);
385 void SetNext(wxHtmlCell *cell);
386 void SetParent(wxHtmlContainerCell *p);
387 void SetPos(int x, int y);
388 void Layout(int w);
389 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
390 void DrawInvisible(wxDC& dc, int x, int y);
391 const wxHtmlCell* Find(int condition, const void* param);
392
393 bool AdjustPagebreak(int* INOUT);
394 void SetCanLiveOnPagebreak(bool can);
395
396 };
397
398
399 class wxHtmlWordCell : public wxHtmlCell
400 {
401 public:
402 wxHtmlWordCell(const wxString& word, wxDC& dc);
403 };
404
405
406 class wxHtmlContainerCell : public wxHtmlCell {
407 public:
408 wxHtmlContainerCell(wxHtmlContainerCell *parent);
409
410 void InsertCell(wxHtmlCell *cell);
411 void SetAlignHor(int al);
412 int GetAlignHor();
413 void SetAlignVer(int al);
414 int GetAlignVer();
415 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
416 int GetIndent(int ind);
417 int GetIndentUnits(int ind);
418 void SetAlign(const wxHtmlTag& tag);
419 void SetWidthFloat(int w, int units);
420 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
421 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
422 void SetBackgroundColour(const wxColour& clr);
423 wxColour GetBackgroundColour();
424 void SetBorder(const wxColour& clr1, const wxColour& clr2);
425 wxHtmlCell* GetFirstCell();
426 };
427
428
429
430 class wxHtmlColourCell : public wxHtmlCell {
431 public:
432 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
433
434 };
435
436
437 class wxHtmlFontCell : public wxHtmlCell
438 {
439 public:
440 wxHtmlFontCell(wxFont *font);
441 };
442
443
444 class wxHtmlWidgetCell : public wxHtmlCell {
445 public:
446 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
447
448 };
449
450
451 //---------------------------------------------------------------------------
452 // wxHtmlFilter
453 //---------------------------------------------------------------------------
454
455
456 %{ // here's the C++ version
457 class wxPyHtmlFilter : public wxHtmlFilter {
458 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
459 public:
460 wxPyHtmlFilter() : wxHtmlFilter() {}
461
462 // returns TRUE if this filter is able to open&read given file
463 virtual bool CanRead(const wxFSFile& file) const {
464 bool rval = FALSE;
465 bool found;
466 wxPyBeginBlockThreads();
467 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
468 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
469 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
470 Py_DECREF(obj);
471 }
472 wxPyEndBlockThreads();
473 return rval;
474 }
475
476
477 // Reads given file and returns HTML document.
478 // Returns empty string if opening failed
479 virtual wxString ReadFile(const wxFSFile& file) const {
480 wxString rval;
481 bool found;
482 wxPyBeginBlockThreads();
483 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
484 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
485 PyObject* ro;
486 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
487 Py_DECREF(obj);
488 if (ro) {
489 rval = Py2wxString(ro);
490 Py_DECREF(ro);
491 }
492 }
493 wxPyEndBlockThreads();
494 return rval;
495 }
496
497 PYPRIVATE;
498 };
499
500 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
501 %}
502
503
504 // And now the version seen by SWIG
505
506 %name(wxHtmlFilter) class wxPyHtmlFilter : public wxObject {
507 public:
508 wxPyHtmlFilter();
509
510 void _setCallbackInfo(PyObject* self, PyObject* _class);
511 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlFilter)"
512 };
513
514
515 // TODO: wxHtmlFilterHTML
516
517
518 //---------------------------------------------------------------------------
519 // wxHtmlWindow
520 //---------------------------------------------------------------------------
521
522 %{
523 class wxPyHtmlWindow : public wxHtmlWindow {
524 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
525 public:
526 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
527 const wxPoint& pos = wxDefaultPosition,
528 const wxSize& size = wxDefaultSize,
529 long style = wxHW_SCROLLBAR_AUTO,
530 const wxString& name = wxPyHtmlWindowNameStr)
531 : wxHtmlWindow(parent, id, pos, size, style, name) {};
532 wxPyHtmlWindow() : wxHtmlWindow() {};
533
534 bool ScrollToAnchor(const wxString& anchor) {
535 return wxHtmlWindow::ScrollToAnchor(anchor);
536 }
537
538 bool HasAnchor(const wxString& anchor) {
539 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
540 return c!=NULL;
541 }
542
543 void OnLinkClicked(const wxHtmlLinkInfo& link);
544 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
545
546 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
547 const wxString& url,
548 wxString *redirect) const;
549
550 DEC_PYCALLBACK__STRING(OnSetTitle);
551 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
552 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
553 PYPRIVATE;
554 };
555
556 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
557 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
558 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
559 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
560
561
562 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
563 bool found;
564 wxPyBeginBlockThreads();
565 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
566 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
567 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
568 Py_DECREF(obj);
569 }
570 wxPyEndBlockThreads();
571 if (! found)
572 wxHtmlWindow::OnLinkClicked(link);
573 }
574 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
575 wxHtmlWindow::OnLinkClicked(link);
576 }
577
578
579 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
580 const wxString& url,
581 wxString *redirect) const {
582 bool found;
583 wxHtmlOpeningStatus rval;
584 wxPyBeginBlockThreads();
585 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
586 PyObject* ro;
587 PyObject* s = wx2PyString(url);
588 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
589 Py_DECREF(s);
590 if (PyString_Check(ro)
591 #if PYTHON_API_VERSION >= 1009
592 || PyUnicode_Check(ro)
593 #endif
594 ) {
595 *redirect = Py2wxString(ro);
596 rval = wxHTML_REDIRECT;
597 }
598 else {
599 PyObject* num = PyNumber_Int(ro);
600 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
601 Py_DECREF(num);
602 }
603 Py_DECREF(ro);
604 }
605 wxPyEndBlockThreads();
606 if (! found)
607 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
608 return rval;
609 }
610
611
612 %}
613
614
615
616 %name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
617 public:
618 wxPyHtmlWindow(wxWindow *parent, int id = -1,
619 wxPoint& pos = wxDefaultPosition,
620 wxSize& size = wxDefaultSize,
621 int style=wxHW_SCROLLBAR_AUTO,
622 const wxString& name = wxPyHtmlWindowNameStr);
623 %name(wxPreHtmlWindow)wxPyHtmlWindow();
624
625 bool Create(wxWindow *parent, int id = -1,
626 wxPoint& pos = wxDefaultPosition,
627 wxSize& size = wxDefaultSize,
628 int style=wxHW_SCROLLBAR_AUTO,
629 const wxString& name = wxPyHtmlWindowNameStr);
630
631
632 void _setCallbackInfo(PyObject* self, PyObject* _class);
633 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWindow)"
634 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
635 %pragma(python) addtomethod = "wxPreHtmlWindow:val._setOORInfo(val)"
636
637 // Set HTML page and display it. !! source is HTML document itself,
638 // it is NOT address/filename of HTML document. If you want to
639 // specify document location, use LoadPage() istead
640 // Return value : FALSE if an error occured, TRUE otherwise
641 bool SetPage(const wxString& source);
642
643 // Load HTML page from given location. Location can be either
644 // a) /usr/wxGTK2/docs/html/wx.htm
645 // b) http://www.somewhere.uk/document.htm
646 // c) ftp://ftp.somesite.cz/pub/something.htm
647 // In case there is no prefix (http:,ftp:), the method
648 // will try to find it itself (1. local file, then http or ftp)
649 // After the page is loaded, the method calls SetPage() to display it.
650 // Note : you can also use path relative to previously loaded page
651 // Return value : same as SetPage
652 bool LoadPage(const wxString& location);
653
654 // Loads HTML page from file
655 bool LoadFile(const wxString& 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 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
748 %addmethods {
749 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
750 int* temp = NULL;
751 if (sizes) temp = int_LIST_helper(sizes);
752 self->SetFonts(normal_face, fixed_face, temp);
753 if (temp)
754 delete [] temp;
755 }
756 }
757 int Render(int x, int y, int from = 0, int dont_render = FALSE);
758 int GetTotalHeight();
759 // returns total height of the html document
760 // (compare Render's return value with this)
761 };
762
763 enum {
764 wxPAGE_ODD,
765 wxPAGE_EVEN,
766 wxPAGE_ALL
767 };
768
769
770 class wxHtmlPrintout : public wxPyPrintout {
771 public:
772 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
773 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
774
775 void SetHtmlText(const wxString& html,
776 const wxString &basepath = wxPyEmptyString,
777 bool isdir = TRUE);
778 void SetHtmlFile(const wxString &htmlfile);
779 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
780 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
781 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
782 %addmethods {
783 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
784 int* temp = NULL;
785 if (sizes) temp = int_LIST_helper(sizes);
786 self->SetFonts(normal_face, fixed_face, temp);
787 if (temp)
788 delete [] temp;
789 }
790 }
791 void SetMargins(float top = 25.2, float bottom = 25.2,
792 float left = 25.2, float right = 25.2,
793 float spaces = 5);
794 };
795
796
797
798 class wxHtmlEasyPrinting : public wxObject {
799 public:
800 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
801 wxFrame *parent_frame = NULL);
802 ~wxHtmlEasyPrinting();
803
804 void PreviewFile(const wxString &htmlfile);
805 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
806 void PrintFile(const wxString &htmlfile);
807 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
808 void PrinterSetup();
809 void PageSetup();
810 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
811 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
812
813 %addmethods {
814 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
815 int* temp = NULL;
816 if (sizes) temp = int_LIST_helper(sizes);
817 self->SetFonts(normal_face, fixed_face, temp);
818 if (temp)
819 delete [] temp;
820 }
821 }
822
823 wxPrintData *GetPrintData() {return m_PrintData;}
824 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
825
826 };
827
828
829
830 //---------------------------------------------------------------------------
831 //---------------------------------------------------------------------------
832
833 %{
834 extern "C" SWIGEXPORT(void) inithtmlhelpc();
835 %}
836
837
838 %init %{
839
840 inithtmlhelpc();
841
842 wxClassInfo::CleanUpClasses();
843 wxClassInfo::InitializeClasses();
844
845 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
846 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
847 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
848 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
849 %}
850
851 //----------------------------------------------------------------------
852 // And this gets appended to the shadow class file.
853 //----------------------------------------------------------------------
854
855 %pragma(python) include="_htmlextras.py";
856
857 //---------------------------------------------------------------------------