1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of html classes
7 // Created: 25-nov-1998
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/html/htmlwin.h>
19 #include <wx/html/htmprint.h>
21 #include <wx/fs_zip.h>
22 #include <wx/fs_inet.h>
23 #include <wx/wfstream.h>
24 #include <wx/filesys.h>
29 //---------------------------------------------------------------------------
32 %include my_typemaps.i
46 %pragma(python) code = "import wx"
49 //----------------------------------------------------------------------
52 // Put some wx default wxChar* values into wxStrings.
53 static const wxChar* wxHtmlWindowNameStr = wxT("htmlWindow");
54 DECLARE_DEF_STRING(HtmlWindowNameStr);
56 static const wxChar* wxHtmlPrintoutTitleStr = wxT("Printout");
57 DECLARE_DEF_STRING(HtmlPrintoutTitleStr);
59 static const wxChar* wxHtmlPrintingTitleStr = wxT("Printing");
60 DECLARE_DEF_STRING(HtmlPrintingTitleStr);
62 static const wxString wxPyEmptyString(wxT(""));
65 //---------------------------------------------------------------------------
74 wxHTML_CLR_FOREGROUND,
75 wxHTML_CLR_BACKGROUND,
85 wxHTML_INDENT_HORIZONTAL,
86 wxHTML_INDENT_VERTICAL,
90 wxHTML_COND_ISIMAGEMAP,
103 // enums for wxHtmlWindow::OnOpeningURL
104 enum wxHtmlOpeningStatus
118 //---------------------------------------------------------------------------
120 class wxHtmlLinkInfo : public wxObject {
122 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
124 wxString GetTarget();
125 wxMouseEvent* GetEvent();
126 wxHtmlCell* GetHtmlCell();
128 void SetEvent(const wxMouseEvent *e);
129 void SetHtmlCell(const wxHtmlCell * e);
132 //---------------------------------------------------------------------------
134 class wxHtmlTag : public wxObject {
136 // Never need to create a new tag from Python...
137 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
140 bool HasParam(const wxString& par);
141 wxString GetParam(const wxString& par, int with_commas = FALSE);
143 // Can't do this one as-is, but GetParam should be enough...
144 //int ScanParam(const wxString& par, const char *format, void* param);
146 wxString GetAllParams();
154 //---------------------------------------------------------------------------
156 class wxHtmlParser : public wxObject {
158 // wxHtmlParser(); This is an abstract base class...
160 void SetFS(wxFileSystem *fs);
161 wxFileSystem* GetFS();
162 wxObject* Parse(const wxString& source);
163 void InitParser(const wxString& source);
165 void DoParsing(int begin_pos, int end_pos);
167 // wxObject* GetProduct();
169 void AddTagHandler(wxHtmlTagHandler *handler);
170 wxString* GetSource();
171 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
172 void PopTagHandler();
174 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
176 // void AddText(const char* txt) = 0;
177 // void AddTag(const wxHtmlTag& tag);
181 //---------------------------------------------------------------------------
183 class wxHtmlWinParser : public wxHtmlParser {
185 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
187 void SetDC(wxDC *dc);
191 wxPyHtmlWindow* GetWindow();
192 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
194 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
196 if (sizes) temp = int_LIST_helper(sizes);
197 self->SetFonts(normal_face, fixed_face, temp);
203 wxHtmlContainerCell* GetContainer();
204 wxHtmlContainerCell* OpenContainer();
205 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
206 wxHtmlContainerCell* CloseContainer();
209 void SetFontSize(int s);
211 void SetFontBold(int x);
213 void SetFontItalic(int x);
214 int GetFontUnderlined();
215 void SetFontUnderlined(int x);
217 void SetFontFixed(int x);
219 void SetAlign(int a);
220 wxColour GetLinkColor();
221 void SetLinkColor(const wxColour& clr);
222 wxColour GetActualColor();
223 void SetActualColor(const wxColour& clr);
224 void SetLink(const wxString& link);
225 wxFont* CreateCurrentFont();
226 wxHtmlLinkInfo GetLink();
232 //---------------------------------------------------------------------------
235 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
236 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
238 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
240 wxHtmlParser* GetParser() { return m_Parser; }
241 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
243 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
244 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
249 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
251 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
252 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
256 %name(wxHtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
258 wxPyHtmlTagHandler();
260 void _setCallbackInfo(PyObject* self, PyObject* _class);
261 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlTagHandler)"
263 void SetParser(wxHtmlParser *parser);
264 wxHtmlParser* GetParser();
265 void ParseInner(const wxHtmlTag& tag);
269 //---------------------------------------------------------------------------
272 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
273 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
275 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
277 wxHtmlWinParser* GetParser() { return m_WParser; }
278 void ParseInner(const wxHtmlTag& tag)
279 { wxHtmlWinTagHandler::ParseInner(tag); }
281 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
282 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
287 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
289 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
290 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
294 %name(wxHtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
296 wxPyHtmlWinTagHandler();
298 void _setCallbackInfo(PyObject* self, PyObject* _class);
299 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWinTagHandler)"
301 void SetParser(wxHtmlParser *parser);
302 wxHtmlWinParser* GetParser();
303 void ParseInner(const wxHtmlTag& tag);
307 //---------------------------------------------------------------------------
311 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
313 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
314 m_tagHandlerClass = thc;
315 Py_INCREF(m_tagHandlerClass);
316 RegisterModule(this);
317 wxHtmlWinParser::AddModule(this);
321 wxPyBeginBlockThreads();
322 Py_DECREF(m_tagHandlerClass);
323 m_tagHandlerClass = NULL;
324 for (size_t x=0; x < m_objArray.GetCount(); x++) {
325 PyObject* obj = (PyObject*)m_objArray.Item(x);
328 wxPyEndBlockThreads();
331 void FillHandlersTable(wxHtmlWinParser *parser) {
332 // Wave our magic wand... (if it works it's a miracle! ;-)
334 // First, make a new instance of the tag handler
335 wxPyBeginBlockThreads();
336 PyObject* arg = Py_BuildValue("()");
337 PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL);
339 wxPyEndBlockThreads();
341 // now figure out where it's C++ object is...
342 wxPyHtmlWinTagHandler* thPtr;
343 if (SWIG_GetPtrObj(obj, (void **)&thPtr, "_wxPyHtmlWinTagHandler_p"))
347 parser->AddTagHandler(thPtr);
354 PyObject* m_tagHandlerClass;
355 wxArrayPtrVoid m_objArray;
363 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
364 // Dynamically create a new wxModule. Refcounts tagHandlerClass
365 // and adds itself to the wxModules list and to the wxHtmlWinParser.
366 new wxPyHtmlTagsModule(tagHandlerClass);
371 //---------------------------------------------------------------------------
372 //---------------------------------------------------------------------------
375 // wxHtmlSelection is data holder with information about text selection.
376 // Selection is defined by two positions (beginning and end of the selection)
377 // and two leaf(!) cells at these positions.
378 class wxHtmlSelection
384 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
385 const wxPoint& toPos, const wxHtmlCell *toCell);
386 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
388 const wxHtmlCell *GetFromCell() const;
389 const wxHtmlCell *GetToCell() const;
391 // these values are in absolute coordinates:
392 const wxPoint& GetFromPos() const;
393 const wxPoint& GetToPos() const;
395 // these are From/ToCell's private data
396 const wxPoint& GetFromPrivPos() const;
397 const wxPoint& GetToPrivPos() const;
398 void SetFromPrivPos(const wxPoint& pos);
399 void SetToPrivPos(const wxPoint& pos);
402 const bool IsEmpty() const;
407 enum wxHtmlSelectionState
409 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
410 wxHTML_SEL_IN, // ... is inside selection
411 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
414 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
415 // differently e.g. when inside text selection or outside it.
416 class wxHtmlRenderingState
419 wxHtmlRenderingState();
420 ~wxHtmlRenderingState();
422 void SetSelectionState(wxHtmlSelectionState s);
423 wxHtmlSelectionState GetSelectionState() const;
425 void SetFgColour(const wxColour& c);
426 const wxColour& GetFgColour() const;
427 void SetBgColour(const wxColour& c);
428 const wxColour& GetBgColour() const;
432 // HTML rendering customization. This class is used when rendering wxHtmlCells
434 class wxHtmlRenderingStyle
437 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
438 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
442 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
445 virtual wxColour GetSelectedTextColour(const wxColour& clr);
446 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
451 // Information given to cells when drawing them. Contains rendering state,
452 // selection information and rendering style object that can be used to
453 // customize the output.
454 class wxHtmlRenderingInfo
457 wxHtmlRenderingInfo();
458 ~wxHtmlRenderingInfo();
460 void SetSelection(wxHtmlSelection *s);
461 wxHtmlSelection *GetSelection() const;
463 void SetStyle(wxHtmlRenderingStyle *style);
464 wxHtmlRenderingStyle& GetStyle();
466 wxHtmlRenderingState& GetState();
469 //---------------------------------------------------------------------------
474 wxHTML_FIND_EXACT = 1,
475 wxHTML_FIND_NEAREST_BEFORE = 2,
476 wxHTML_FIND_NEAREST_AFTER = 4
480 class wxHtmlCell : public wxObject {
489 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
490 wxHtmlCell* GetNext();
491 wxHtmlContainerCell* GetParent();
492 wxHtmlCell* GetFirstChild() const;
494 // Returns cursor to be used when mouse is over the cell:
495 wxCursor GetCursor() const;
497 // Formatting cells are not visible on the screen, they only alter
499 bool IsFormattingCell() const;
502 void SetLink(const wxHtmlLinkInfo& link);
503 void SetNext(wxHtmlCell *cell);
504 void SetParent(wxHtmlContainerCell *p);
505 void SetPos(int x, int y);
507 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
508 wxHtmlRenderingInfo& info);
509 void DrawInvisible(wxDC& dc, int x, int y,
510 wxHtmlRenderingInfo& info);
511 const wxHtmlCell* Find(int condition, const void* param);
513 bool AdjustPagebreak(int* INOUT);
514 void SetCanLiveOnPagebreak(bool can);
516 // Can the line be broken before this cell?
517 bool IsLinebreakAllowed() const;
519 // Returns true for simple == terminal cells, i.e. not composite ones.
520 // This if for internal usage only and may disappear in future versions!
521 bool IsTerminalCell() const;
523 // Find a cell inside this cell positioned at the given coordinates
524 // (relative to this's positions). Returns NULL if no such cell exists.
525 // The flag can be used to specify whether to look for terminal or
526 // nonterminal cells or both. In either case, returned cell is deepest
527 // cell in cells tree that contains [x,y].
528 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
529 unsigned flags = wxHTML_FIND_EXACT) const;
531 // Returns absolute position of the cell on HTML canvas
532 wxPoint GetAbsPos() const;
534 // Returns first (last) terminal cell inside this cell. It may return NULL,
535 // but it is rare -- only if there are no terminals in the tree.
536 wxHtmlCell *GetFirstTerminal() const ;
537 wxHtmlCell *GetLastTerminal() const ;
539 // Returns cell's depth, i.e. how far under the root cell it is
540 // (if it is the root, depth is 0)
541 unsigned GetDepth() const;
543 // Returns true if the cell appears before 'cell' in natural order of
544 // cells (= as they are read). If cell A is (grand)parent of cell B,
545 // then both A.IsBefore(B) and B.IsBefore(A) always return true.
546 bool IsBefore(wxHtmlCell *cell) const;
548 // Converts the cell into text representation. If sel != NULL then
549 // only part of the cell inside the selection is converted.
550 wxString ConvertToText(wxHtmlSelection *sel) const;
554 class wxHtmlWordCell : public wxHtmlCell
557 wxHtmlWordCell(const wxString& word, wxDC& dc);
561 class wxHtmlContainerCell : public wxHtmlCell {
563 wxHtmlContainerCell(wxHtmlContainerCell *parent);
565 void InsertCell(wxHtmlCell *cell);
566 void SetAlignHor(int al);
568 void SetAlignVer(int al);
570 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
571 int GetIndent(int ind);
572 int GetIndentUnits(int ind);
573 void SetAlign(const wxHtmlTag& tag);
574 void SetWidthFloat(int w, int units);
575 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
576 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
577 void SetBackgroundColour(const wxColour& clr);
578 wxColour GetBackgroundColour();
579 void SetBorder(const wxColour& clr1, const wxColour& clr2);
580 wxHtmlCell* GetFirstChild();
581 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
586 class wxHtmlColourCell : public wxHtmlCell {
588 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
593 class wxHtmlFontCell : public wxHtmlCell
596 wxHtmlFontCell(wxFont *font);
600 class wxHtmlWidgetCell : public wxHtmlCell {
602 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
607 //---------------------------------------------------------------------------
609 //---------------------------------------------------------------------------
612 %{ // here's the C++ version
613 class wxPyHtmlFilter : public wxHtmlFilter {
614 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
616 wxPyHtmlFilter() : wxHtmlFilter() {}
618 // returns TRUE if this filter is able to open&read given file
619 virtual bool CanRead(const wxFSFile& file) const {
622 wxPyBeginBlockThreads();
623 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
624 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
625 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
628 wxPyEndBlockThreads();
633 // Reads given file and returns HTML document.
634 // Returns empty string if opening failed
635 virtual wxString ReadFile(const wxFSFile& file) const {
638 wxPyBeginBlockThreads();
639 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
640 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
642 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
645 rval = Py2wxString(ro);
649 wxPyEndBlockThreads();
656 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
660 // And now the version seen by SWIG
662 %name(wxHtmlFilter) class wxPyHtmlFilter : public wxObject {
666 void _setCallbackInfo(PyObject* self, PyObject* _class);
667 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlFilter)"
671 // TODO: wxHtmlFilterHTML
674 //---------------------------------------------------------------------------
676 //---------------------------------------------------------------------------
679 class wxPyHtmlWindow : public wxHtmlWindow {
680 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
682 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
683 const wxPoint& pos = wxDefaultPosition,
684 const wxSize& size = wxDefaultSize,
685 long style = wxHW_DEFAULT_STYLE,
686 const wxString& name = wxPyHtmlWindowNameStr)
687 : wxHtmlWindow(parent, id, pos, size, style, name) {};
688 wxPyHtmlWindow() : wxHtmlWindow() {};
690 bool ScrollToAnchor(const wxString& anchor) {
691 return wxHtmlWindow::ScrollToAnchor(anchor);
694 bool HasAnchor(const wxString& anchor) {
695 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
699 void OnLinkClicked(const wxHtmlLinkInfo& link);
700 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
702 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
704 wxString *redirect) const;
706 DEC_PYCALLBACK__STRING(OnSetTitle);
707 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
708 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
712 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
713 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
714 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
715 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
718 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
720 wxPyBeginBlockThreads();
721 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
722 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
723 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
726 wxPyEndBlockThreads();
728 wxHtmlWindow::OnLinkClicked(link);
730 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
731 wxHtmlWindow::OnLinkClicked(link);
735 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
737 wxString *redirect) const {
739 wxHtmlOpeningStatus rval;
740 wxPyBeginBlockThreads();
741 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
743 PyObject* s = wx2PyString(url);
744 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
746 if (PyString_Check(ro)
747 #if PYTHON_API_VERSION >= 1009
748 || PyUnicode_Check(ro)
751 *redirect = Py2wxString(ro);
752 rval = wxHTML_REDIRECT;
755 PyObject* num = PyNumber_Int(ro);
756 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
761 wxPyEndBlockThreads();
763 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
772 %name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
774 wxPyHtmlWindow(wxWindow *parent, int id = -1,
775 wxPoint& pos = wxDefaultPosition,
776 wxSize& size = wxDefaultSize,
777 int style=wxHW_DEFAULT_STYLE,
778 const wxString& name = wxPyHtmlWindowNameStr);
779 %name(wxPreHtmlWindow)wxPyHtmlWindow();
781 bool Create(wxWindow *parent, int id = -1,
782 wxPoint& pos = wxDefaultPosition,
783 wxSize& size = wxDefaultSize,
784 int style=wxHW_SCROLLBAR_AUTO,
785 const wxString& name = wxPyHtmlWindowNameStr);
788 void _setCallbackInfo(PyObject* self, PyObject* _class);
789 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlWindow)"
790 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
791 %pragma(python) addtomethod = "wxPreHtmlWindow:val._setOORInfo(val)"
793 // Set HTML page and display it. !! source is HTML document itself,
794 // it is NOT address/filename of HTML document. If you want to
795 // specify document location, use LoadPage() istead
796 // Return value : FALSE if an error occured, TRUE otherwise
797 bool SetPage(const wxString& source);
799 // Load HTML page from given location. Location can be either
800 // a) /usr/wxGTK2/docs/html/wx.htm
801 // b) http://www.somewhere.uk/document.htm
802 // c) ftp://ftp.somesite.cz/pub/something.htm
803 // In case there is no prefix (http:,ftp:), the method
804 // will try to find it itself (1. local file, then http or ftp)
805 // After the page is loaded, the method calls SetPage() to display it.
806 // Note : you can also use path relative to previously loaded page
807 // Return value : same as SetPage
808 bool LoadPage(const wxString& location);
810 // Loads HTML page from file
811 bool LoadFile(const wxString& filename);
813 // Append to current page
814 bool AppendToPage(const wxString& source);
816 // Returns full location of opened page
817 wxString GetOpenedPage();
819 // Returns anchor within opened page
820 wxString GetOpenedAnchor();
822 // Returns <TITLE> of opened page or empty string otherwise
823 wxString GetOpenedPageTitle();
825 // Sets frame in which page title will be displayed. Format is format of
826 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
827 void SetRelatedFrame(wxFrame* frame, const wxString& format);
828 wxFrame* GetRelatedFrame();
830 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
831 // will be displayed. Default is -1 = no messages.
832 void SetRelatedStatusBar(int bar);
834 // Sets fonts to be used when displaying HTML page.
836 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
838 if (sizes) temp = int_LIST_helper(sizes);
839 self->SetFonts(normal_face, fixed_face, temp);
845 void SetTitle(const wxString& title);
847 // Sets space between text and window borders.
848 void SetBorders(int b);
850 // Saves custom settings into cfg config. it will use the path 'path'
851 // if given, otherwise it will save info into currently selected path.
852 // saved values : things set by SetFonts, SetBorders.
853 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
854 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
856 // Goes to previous/next page (in browsing history)
857 // Returns TRUE if successful, FALSE otherwise
859 bool HistoryForward();
860 bool HistoryCanBack();
861 bool HistoryCanForward();
866 // Returns pointer to conteiners/cells structure.
867 wxHtmlContainerCell* GetInternalRepresentation();
869 // Returns a pointer to the parser.
870 wxHtmlWinParser* GetParser();
872 bool ScrollToAnchor(const wxString& anchor);
873 bool HasAnchor(const wxString& anchor);
876 static void AddFilter(wxPyHtmlFilter *filter);
879 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
880 void base_OnSetTitle(const wxString& title);
881 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
882 void base_OnCellClicked(wxHtmlCell *cell,
883 wxCoord x, wxCoord y,
884 const wxMouseEvent& event);
889 //---------------------------------------------------------------------------
890 //---------------------------------------------------------------------------
893 class wxHtmlDCRenderer : public wxObject {
898 void SetDC(wxDC *dc, int maxwidth);
899 void SetSize(int width, int height);
900 void SetHtmlText(const wxString& html,
901 const wxString& basepath = wxPyEmptyString,
903 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
905 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
907 if (sizes) temp = int_LIST_helper(sizes);
908 self->SetFonts(normal_face, fixed_face, temp);
913 int Render(int x, int y, int from = 0, int dont_render = FALSE, int to = INT_MAX,
914 //int *known_pagebreaks = NULL, int number_of_pages = 0
915 int* choices=NULL, int LCOUNT = 0
917 int GetTotalHeight();
918 // returns total height of the html document
919 // (compare Render's return value with this)
929 class wxHtmlPrintout : public wxPyPrintout {
931 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
932 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
934 void SetHtmlText(const wxString& html,
935 const wxString &basepath = wxPyEmptyString,
937 void SetHtmlFile(const wxString &htmlfile);
938 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
939 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
940 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
942 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
944 if (sizes) temp = int_LIST_helper(sizes);
945 self->SetFonts(normal_face, fixed_face, temp);
950 void SetMargins(float top = 25.2, float bottom = 25.2,
951 float left = 25.2, float right = 25.2,
955 static void AddFilter(wxHtmlFilter *filter);
958 static void CleanUpStatics();
963 class wxHtmlEasyPrinting : public wxObject {
965 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
966 wxWindow *parentWindow = NULL);
967 ~wxHtmlEasyPrinting();
969 void PreviewFile(const wxString &htmlfile);
970 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
971 void PrintFile(const wxString &htmlfile);
972 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
975 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
976 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
979 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
981 if (sizes) temp = int_LIST_helper(sizes);
982 self->SetFonts(normal_face, fixed_face, temp);
988 wxPrintData *GetPrintData() {return m_PrintData;}
989 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
995 //---------------------------------------------------------------------------
996 //---------------------------------------------------------------------------
999 extern "C" SWIGEXPORT(void) inithtmlhelpc();
1007 wxClassInfo::CleanUpClasses();
1008 wxClassInfo::InitializeClasses();
1010 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1011 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1012 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1013 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1016 //----------------------------------------------------------------------
1017 // And this gets appended to the shadow class file.
1018 //----------------------------------------------------------------------
1020 %pragma(python) include="_htmlextras.py";
1022 //---------------------------------------------------------------------------