1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of html classes
7 // Created: 25-Nov-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
14 "Classes for a simple HTML rendering window, HTML Help Window, etc."
17 %module(package="wx", docstring=DOCSTRING) html
20 #include "wx/wxPython/wxPython.h"
21 #include "wx/wxPython/pyclasses.h"
22 #include "wx/wxPython/pyistream.h"
23 #include "wx/wxPython/printfw.h"
25 #include <wx/html/htmlwin.h>
26 #include <wx/html/htmprint.h>
27 #include <wx/html/helpctrl.h>
32 //---------------------------------------------------------------------------
35 %pythoncode { wx = _core }
36 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
38 %include _html_rename.i
41 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
42 MAKE_CONST_WXSTRING2(HtmlWindowNameStr, wxT("htmlWindow"))
43 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout"))
44 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("Printing"))
47 // TODO: Split this file into multiple %included files that coresponds to the
48 // wx/html include files (more or less.)
50 //---------------------------------------------------------------------------
51 //---------------------------------------------------------------------------
62 wxHTML_CLR_FOREGROUND,
63 wxHTML_CLR_BACKGROUND,
73 wxHTML_INDENT_HORIZONTAL,
74 wxHTML_INDENT_VERTICAL,
78 wxHTML_COND_ISIMAGEMAP,
100 // enums for wxHtmlWindow::OnOpeningURL
101 enum wxHtmlOpeningStatus
117 //---------------------------------------------------------------------------
119 class wxHtmlLinkInfo : public wxObject {
121 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
123 wxString GetTarget();
124 wxMouseEvent* GetEvent();
125 wxHtmlCell* GetHtmlCell();
127 void SetEvent(const wxMouseEvent *e);
128 void SetHtmlCell(const wxHtmlCell * e);
131 //---------------------------------------------------------------------------
133 class wxHtmlTag : public wxObject {
135 // Never need to create a new tag from Python...
136 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
139 bool HasParam(const wxString& par);
140 wxString GetParam(const wxString& par, int with_commas = False);
142 // Can't do this one as-is, but GetParam should be enough...
143 //int ScanParam(const wxString& par, const char *format, void* param);
145 wxString GetAllParams();
152 //---------------------------------------------------------------------------
154 class wxHtmlParser : public wxObject {
156 // wxHtmlParser(); This is an abstract base class...
158 void SetFS(wxFileSystem *fs);
159 wxFileSystem* GetFS();
160 wxObject* Parse(const wxString& source);
161 void InitParser(const wxString& source);
163 void DoParsing(int begin_pos, int end_pos);
165 // wxObject* GetProduct();
167 void AddTagHandler(wxHtmlTagHandler *handler);
168 wxString* GetSource();
169 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
170 void PopTagHandler();
172 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
174 // void AddText(const char* txt) = 0;
175 // void AddTag(const wxHtmlTag& tag);
179 //---------------------------------------------------------------------------
181 class wxHtmlWinParser : public wxHtmlParser {
183 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
185 void SetDC(wxDC *dc);
189 wxPyHtmlWindow* GetWindow();
191 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
193 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
195 if (sizes) temp = int_LIST_helper(sizes);
196 self->SetFonts(normal_face, fixed_face, temp);
202 wxHtmlContainerCell* GetContainer();
203 wxHtmlContainerCell* OpenContainer();
204 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
205 wxHtmlContainerCell* CloseContainer();
208 void SetFontSize(int s);
210 void SetFontBold(int x);
212 void SetFontItalic(int x);
213 int GetFontUnderlined();
214 void SetFontUnderlined(int x);
216 void SetFontFixed(int x);
218 void SetAlign(int a);
219 wxColour GetLinkColor();
220 void SetLinkColor(const wxColour& clr);
221 wxColour GetActualColor();
222 void SetActualColor(const wxColour& clr);
223 void SetLink(const wxString& link);
224 wxFont* CreateCurrentFont();
225 wxHtmlLinkInfo GetLink();
230 //---------------------------------------------------------------------------
233 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
234 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
236 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
238 wxHtmlParser* GetParser() { return m_Parser; }
239 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
241 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
242 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
247 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
249 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
250 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
254 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
256 %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
257 wxPyHtmlTagHandler();
259 void _setCallbackInfo(PyObject* self, PyObject* _class);
261 void SetParser(wxHtmlParser *parser);
262 wxHtmlParser* GetParser();
263 void ParseInner(const wxHtmlTag& tag);
267 //---------------------------------------------------------------------------
270 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
271 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
273 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
275 wxHtmlWinParser* GetParser() { return m_WParser; }
276 void ParseInner(const wxHtmlTag& tag)
277 { wxHtmlWinTagHandler::ParseInner(tag); }
279 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
280 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
285 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
287 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
288 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
292 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
294 %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
295 wxPyHtmlWinTagHandler();
297 void _setCallbackInfo(PyObject* self, PyObject* _class);
299 void SetParser(wxHtmlParser *parser);
300 wxHtmlWinParser* GetParser();
301 void ParseInner(const wxHtmlTag& tag);
305 //---------------------------------------------------------------------------
309 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
311 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
312 m_tagHandlerClass = thc;
313 Py_INCREF(m_tagHandlerClass);
314 RegisterModule(this);
315 wxHtmlWinParser::AddModule(this);
319 bool blocked = 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);
326 wxPyEndBlockThreads(blocked);
329 void FillHandlersTable(wxHtmlWinParser *parser) {
330 // Wave our magic wand... (if it works it's a miracle! ;-)
332 // First, make a new instance of the tag handler
333 bool blocked = wxPyBeginBlockThreads();
334 PyObject* arg = PyTuple_New(0);
335 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
338 // now figure out where it's C++ object is...
339 wxPyHtmlWinTagHandler* thPtr;
340 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
341 wxPyEndBlockThreads(blocked);
344 wxPyEndBlockThreads(blocked);
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 //---------------------------------------------------------------------------
376 // wxHtmlSelection is data holder with information about text selection.
377 // Selection is defined by two positions (beginning and end of the selection)
378 // and two leaf(!) cells at these positions.
379 class wxHtmlSelection
385 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
386 const wxPoint& toPos, const wxHtmlCell *toCell);
387 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
389 const wxHtmlCell *GetFromCell() const;
390 const wxHtmlCell *GetToCell() const;
392 // these values are in absolute coordinates:
393 const wxPoint& GetFromPos() const;
394 const wxPoint& GetToPos() const;
396 // these are From/ToCell's private data
397 const wxPoint& GetFromPrivPos() const;
398 const wxPoint& GetToPrivPos() const;
399 void SetFromPrivPos(const wxPoint& pos);
400 void SetToPrivPos(const wxPoint& pos);
403 const bool IsEmpty() const;
408 enum wxHtmlSelectionState
410 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
411 wxHTML_SEL_IN, // ... is inside selection
412 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
417 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
418 // differently e.g. when inside text selection or outside it.
419 class wxHtmlRenderingState
422 wxHtmlRenderingState();
423 ~wxHtmlRenderingState();
425 void SetSelectionState(wxHtmlSelectionState s);
426 wxHtmlSelectionState GetSelectionState() const;
428 void SetFgColour(const wxColour& c);
429 const wxColour& GetFgColour() const;
430 void SetBgColour(const wxColour& c);
431 const wxColour& GetBgColour() const;
436 // HTML rendering customization. This class is used when rendering wxHtmlCells
438 class wxHtmlRenderingStyle
441 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
442 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
446 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
449 virtual wxColour GetSelectedTextColour(const wxColour& clr);
450 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
455 // Information given to cells when drawing them. Contains rendering state,
456 // selection information and rendering style object that can be used to
457 // customize the output.
458 class wxHtmlRenderingInfo
461 wxHtmlRenderingInfo();
462 ~wxHtmlRenderingInfo();
464 void SetSelection(wxHtmlSelection *s);
465 wxHtmlSelection *GetSelection() const;
467 void SetStyle(wxHtmlRenderingStyle *style);
468 wxHtmlRenderingStyle& GetStyle();
470 wxHtmlRenderingState& GetState();
473 //---------------------------------------------------------------------------
479 wxHTML_FIND_EXACT = 1,
480 wxHTML_FIND_NEAREST_BEFORE = 2,
481 wxHTML_FIND_NEAREST_AFTER = 4
485 class wxHtmlCell : public wxObject {
495 // Returns the maximum possible length of the cell.
496 // Call Layout at least once before using GetMaxTotalWidth()
497 int GetMaxTotalWidth() const;
499 const wxString& GetId() const;
500 void SetId(const wxString& id);
501 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
502 wxHtmlCell* GetNext();
503 wxHtmlContainerCell* GetParent();
504 wxHtmlCell* GetFirstChild() const;
506 // Returns cursor to be used when mouse is over the cell:
507 wxCursor GetCursor() const;
509 // Formatting cells are not visible on the screen, they only alter
511 bool IsFormattingCell() const;
514 void SetLink(const wxHtmlLinkInfo& link);
515 void SetNext(wxHtmlCell *cell);
516 void SetParent(wxHtmlContainerCell *p);
517 void SetPos(int x, int y);
519 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
520 wxHtmlRenderingInfo& info);
521 void DrawInvisible(wxDC& dc, int x, int y,
522 wxHtmlRenderingInfo& info);
523 const wxHtmlCell* Find(int condition, const void* param);
525 bool AdjustPagebreak(int* INOUT);
526 void SetCanLiveOnPagebreak(bool can);
528 // Can the line be broken before this cell?
529 bool IsLinebreakAllowed() const;
531 // Returns True for simple == terminal cells, i.e. not composite ones.
532 // This if for internal usage only and may disappear in future versions!
533 bool IsTerminalCell() const;
535 // Find a cell inside this cell positioned at the given coordinates
536 // (relative to this's positions). Returns NULL if no such cell exists.
537 // The flag can be used to specify whether to look for terminal or
538 // nonterminal cells or both. In either case, returned cell is deepest
539 // cell in cells tree that contains [x,y].
540 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
541 unsigned flags = wxHTML_FIND_EXACT) const;
543 // Returns absolute position of the cell on HTML canvas
544 wxPoint GetAbsPos() const;
546 // Returns first (last) terminal cell inside this cell. It may return NULL,
547 // but it is rare -- only if there are no terminals in the tree.
548 wxHtmlCell *GetFirstTerminal() const ;
549 wxHtmlCell *GetLastTerminal() const ;
551 // Returns cell's depth, i.e. how far under the root cell it is
552 // (if it is the root, depth is 0)
553 unsigned GetDepth() const;
555 // Returns True if the cell appears before 'cell' in natural order of
556 // cells (= as they are read). If cell A is (grand)parent of cell B,
557 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
558 bool IsBefore(wxHtmlCell *cell) const;
560 // Converts the cell into text representation. If sel != NULL then
561 // only part of the cell inside the selection is converted.
562 wxString ConvertToText(wxHtmlSelection *sel) const;
566 class wxHtmlWordCell : public wxHtmlCell
569 wxHtmlWordCell(const wxString& word, wxDC& dc);
573 class wxHtmlContainerCell : public wxHtmlCell {
575 wxHtmlContainerCell(wxHtmlContainerCell *parent);
577 void InsertCell(wxHtmlCell *cell);
578 void SetAlignHor(int al);
580 void SetAlignVer(int al);
582 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
583 int GetIndent(int ind);
584 int GetIndentUnits(int ind);
585 void SetAlign(const wxHtmlTag& tag);
586 void SetWidthFloat(int w, int units);
587 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
588 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
589 void SetBackgroundColour(const wxColour& clr);
590 wxColour GetBackgroundColour();
591 void SetBorder(const wxColour& clr1, const wxColour& clr2);
592 wxHtmlCell* GetFirstChild();
593 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
598 class wxHtmlColourCell : public wxHtmlCell {
600 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
605 class wxHtmlFontCell : public wxHtmlCell
608 wxHtmlFontCell(wxFont *font);
612 class wxHtmlWidgetCell : public wxHtmlCell {
614 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
621 //---------------------------------------------------------------------------
623 //---------------------------------------------------------------------------
627 %{ // here's the C++ version
628 class wxPyHtmlFilter : public wxHtmlFilter {
629 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
631 wxPyHtmlFilter() : wxHtmlFilter() {}
633 // returns True if this filter is able to open&read given file
634 virtual bool CanRead(const wxFSFile& file) const {
637 bool blocked = wxPyBeginBlockThreads();
638 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
639 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
640 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
643 wxPyEndBlockThreads(blocked);
648 // Reads given file and returns HTML document.
649 // Returns empty string if opening failed
650 virtual wxString ReadFile(const wxFSFile& file) const {
653 bool blocked = wxPyBeginBlockThreads();
654 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
655 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
657 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
660 rval = Py2wxString(ro);
664 wxPyEndBlockThreads(blocked);
671 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
675 // And now the version seen by SWIG
677 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
679 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
682 void _setCallbackInfo(PyObject* self, PyObject* _class);
686 // TODO: wxHtmlFilterHTML
689 //---------------------------------------------------------------------------
691 //---------------------------------------------------------------------------
695 class wxPyHtmlWindow : public wxHtmlWindow {
696 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
698 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
699 const wxPoint& pos = wxDefaultPosition,
700 const wxSize& size = wxDefaultSize,
701 long style = wxHW_DEFAULT_STYLE,
702 const wxString& name = wxPyHtmlWindowNameStr)
703 : wxHtmlWindow(parent, id, pos, size, style, name) {};
704 wxPyHtmlWindow() : wxHtmlWindow() {};
706 bool ScrollToAnchor(const wxString& anchor) {
707 return wxHtmlWindow::ScrollToAnchor(anchor);
710 bool HasAnchor(const wxString& anchor) {
711 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
715 void OnLinkClicked(const wxHtmlLinkInfo& link);
716 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
718 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
720 wxString *redirect) const;
722 DEC_PYCALLBACK__STRING(OnSetTitle);
723 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
724 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
728 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
729 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
730 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
731 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
734 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
736 bool blocked = wxPyBeginBlockThreads();
737 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
738 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
739 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
742 wxPyEndBlockThreads(blocked);
744 wxHtmlWindow::OnLinkClicked(link);
746 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
747 wxHtmlWindow::OnLinkClicked(link);
751 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
753 wxString *redirect) const {
755 wxHtmlOpeningStatus rval;
756 bool blocked = wxPyBeginBlockThreads();
757 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
759 PyObject* s = wx2PyString(url);
760 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
762 if (PyString_Check(ro)
763 #if PYTHON_API_VERSION >= 1009
764 || PyUnicode_Check(ro)
767 *redirect = Py2wxString(ro);
768 rval = wxHTML_REDIRECT;
771 PyObject* num = PyNumber_Int(ro);
772 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
777 wxPyEndBlockThreads(blocked);
779 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
788 MustHaveApp(wxPyHtmlWindow);
790 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
792 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
793 %pythonAppend wxPyHtmlWindow() ""
795 wxPyHtmlWindow(wxWindow *parent, int id = -1,
796 const wxPoint& pos = wxDefaultPosition,
797 const wxSize& size = wxDefaultSize,
798 int style=wxHW_DEFAULT_STYLE,
799 const wxString& name = wxPyHtmlWindowNameStr);
800 %name(PreHtmlWindow)wxPyHtmlWindow();
802 bool Create(wxWindow *parent, int id = -1,
803 const wxPoint& pos = wxDefaultPosition,
804 const wxSize& size = wxDefaultSize,
805 int style=wxHW_SCROLLBAR_AUTO,
806 const wxString& name = wxPyHtmlWindowNameStr);
809 void _setCallbackInfo(PyObject* self, PyObject* _class);
812 // Set HTML page and display it. !! source is HTML document itself,
813 // it is NOT address/filename of HTML document. If you want to
814 // specify document location, use LoadPage() istead
815 // Return value : False if an error occured, True otherwise
816 bool SetPage(const wxString& source);
818 // Load HTML page from given location. Location can be either
819 // a) /usr/wxGTK2/docs/html/wx.htm
820 // b) http://www.somewhere.uk/document.htm
821 // c) ftp://ftp.somesite.cz/pub/something.htm
822 // In case there is no prefix (http:,ftp:), the method
823 // will try to find it itself (1. local file, then http or ftp)
824 // After the page is loaded, the method calls SetPage() to display it.
825 // Note : you can also use path relative to previously loaded page
826 // Return value : same as SetPage
827 bool LoadPage(const wxString& location);
829 // Loads HTML page from file
830 bool LoadFile(const wxString& filename);
832 // Append to current page
833 bool AppendToPage(const wxString& source);
835 // Returns full location of opened page
836 wxString GetOpenedPage();
838 // Returns anchor within opened page
839 wxString GetOpenedAnchor();
841 // Returns <TITLE> of opened page or empty string otherwise
842 wxString GetOpenedPageTitle();
844 // Sets frame in which page title will be displayed. Format is format of
845 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
846 void SetRelatedFrame(wxFrame* frame, const wxString& format);
847 wxFrame* GetRelatedFrame();
849 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
850 // will be displayed. Default is -1 = no messages.
851 void SetRelatedStatusBar(int bar);
853 // Sets fonts to be used when displaying HTML page.
855 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
857 if (sizes) temp = int_LIST_helper(sizes);
858 self->SetFonts(normal_face, fixed_face, temp);
865 void, SetTitle(const wxString& title),
868 // Sets space between text and window borders.
869 void SetBorders(int b);
871 // Saves custom settings into cfg config. it will use the path 'path'
872 // if given, otherwise it will save info into currently selected path.
873 // saved values : things set by SetFonts, SetBorders.
874 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
875 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
877 // Goes to previous/next page (in browsing history)
878 // Returns True if successful, False otherwise
880 bool HistoryForward();
881 bool HistoryCanBack();
882 bool HistoryCanForward();
887 // Returns pointer to conteiners/cells structure.
888 wxHtmlContainerCell* GetInternalRepresentation();
890 // Returns a pointer to the parser.
891 wxHtmlWinParser* GetParser();
893 bool ScrollToAnchor(const wxString& anchor);
894 bool HasAnchor(const wxString& anchor);
897 static void AddFilter(wxPyHtmlFilter *filter);
899 // Helper functions to select parts of page:
900 void SelectWord(const wxPoint& pos);
901 void SelectLine(const wxPoint& pos);
905 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
906 void base_OnSetTitle(const wxString& title);
907 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
908 void base_OnCellClicked(wxHtmlCell *cell,
909 wxCoord x, wxCoord y,
910 const wxMouseEvent& event);
912 static wxVisualAttributes
913 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
919 //---------------------------------------------------------------------------
920 //---------------------------------------------------------------------------
924 MustHaveApp(wxHtmlDCRenderer);
926 class wxHtmlDCRenderer : public wxObject {
931 void SetDC(wxDC *dc, int maxwidth);
932 void SetSize(int width, int height);
933 void SetHtmlText(const wxString& html,
934 const wxString& basepath = wxPyEmptyString,
936 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
938 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
940 if (sizes) temp = int_LIST_helper(sizes);
941 self->SetFonts(normal_face, fixed_face, temp);
946 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
947 //int *known_pagebreaks = NULL, int number_of_pages = 0
948 int* choices=NULL, int LCOUNT = 0
950 int GetTotalHeight();
951 // returns total height of the html document
952 // (compare Render's return value with this)
963 MustHaveApp(wxHtmlPrintout);
965 class wxHtmlPrintout : public wxPyPrintout {
967 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
968 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
970 void SetHtmlText(const wxString& html,
971 const wxString &basepath = wxPyEmptyString,
973 void SetHtmlFile(const wxString &htmlfile);
974 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
975 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
977 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
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);
987 void SetMargins(float top = 25.2, float bottom = 25.2,
988 float left = 25.2, float right = 25.2,
992 static void AddFilter(wxHtmlFilter *filter);
995 static void CleanUpStatics();
1000 MustHaveApp(wxHtmlEasyPrinting);
1002 class wxHtmlEasyPrinting : public wxObject {
1004 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
1005 wxWindow *parentWindow = NULL);
1006 ~wxHtmlEasyPrinting();
1008 void PreviewFile(const wxString &htmlfile);
1009 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1010 void PrintFile(const wxString &htmlfile);
1011 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1012 void PrinterSetup();
1014 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1015 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1018 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1020 if (sizes) temp = int_LIST_helper(sizes);
1021 self->SetFonts(normal_face, fixed_face, temp);
1027 wxPrintData *GetPrintData() {return m_PrintData;}
1028 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1033 //---------------------------------------------------------------------------
1034 //---------------------------------------------------------------------------
1038 class wxHtmlBookRecord {
1040 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1041 const wxString& title, const wxString& start);
1043 wxString GetBookFile();
1044 wxString GetTitle();
1045 wxString GetStart();
1046 wxString GetBasePath();
1048 void SetContentsRange(int start, int end);
1049 int GetContentsStart();
1050 int GetContentsEnd();
1052 void SetTitle(const wxString& title);
1053 void SetBasePath(const wxString& path);
1054 void SetStart(const wxString& start);
1056 wxString GetFullPath(const wxString &page) const;
1059 //---------------------------------------------------------------------------
1061 struct wxHtmlContentsItem
1064 int GetLevel() { return self->m_Level; }
1065 int GetID() { return self->m_ID; }
1066 wxString GetName() { return self->m_Name; }
1067 wxString GetPage() { return self->m_Page; }
1068 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1072 //---------------------------------------------------------------------------
1074 class wxHtmlSearchStatus
1077 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1078 // const wxString& book = wxPyEmptyString);
1083 const wxString& GetName();
1084 wxHtmlContentsItem* GetContentsItem();
1087 //---------------------------------------------------------------------------
1089 class wxHtmlHelpData {
1094 void SetTempDir(const wxString& path);
1095 bool AddBook(const wxString& book);
1096 // bool AddBookParam(const wxString& title, const wxString& contfile,
1097 // const wxString& indexfile=wxPyEmptyString,
1098 // const wxString& deftopic=wxPyEmptyString,
1099 // const wxString& path=wxPyEmptyString);
1101 wxString FindPageByName(const wxString& page);
1102 wxString FindPageById(int id);
1104 // TODO: this one needs fixed...
1105 const wxHtmlBookRecArray& GetBookRecArray();
1107 wxHtmlContentsItem* GetContents();
1108 int GetContentsCnt();
1109 wxHtmlContentsItem* GetIndex();
1113 //---------------------------------------------------------------------------
1115 MustHaveApp(wxHtmlHelpFrame);
1117 class wxHtmlHelpFrame : public wxFrame {
1119 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1121 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1122 const wxString& title = wxPyEmptyString,
1123 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1125 wxHtmlHelpData* GetData();
1126 void SetTitleFormat(const wxString& format);
1127 void Display(const wxString& x);
1128 %name(DisplayID) void Display(int id);
1129 void DisplayContents();
1130 void DisplayIndex();
1131 bool KeywordSearch(const wxString& keyword);
1132 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1133 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1134 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1138 //---------------------------------------------------------------------------
1154 MustHaveApp(wxHtmlHelpController);
1156 class wxHtmlHelpController : public wxEvtHandler {
1158 %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1160 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1161 ~wxHtmlHelpController();
1163 void SetTitleFormat(const wxString& format);
1164 void SetTempDir(const wxString& path);
1165 bool AddBook(const wxString& book, int show_wait_msg = False);
1166 void Display(const wxString& x);
1167 %name(DisplayID) void Display(int id);
1168 void DisplayContents();
1169 void DisplayIndex();
1170 bool KeywordSearch(const wxString& keyword);
1171 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1172 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1173 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1174 wxHtmlHelpFrame* GetFrame();
1180 //---------------------------------------------------------------------------
1182 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1183 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1184 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1185 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1187 //---------------------------------------------------------------------------
1188 //---------------------------------------------------------------------------