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 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/wxPython/wxPython.h"
18 #include "wx/wxPython/pyclasses.h"
19 #include "wx/wxPython/pyistream.h"
20 #include "wx/wxPython/printfw.h"
22 #include <wx/html/htmlwin.h>
23 #include <wx/html/htmprint.h>
24 #include <wx/html/helpctrl.h>
29 //---------------------------------------------------------------------------
32 %pythoncode { wx = core }
34 %include _html_rename.i
37 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
38 MAKE_CONST_WXSTRING2(HtmlWindowNameStr, "htmlWindow")
39 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, "Printout")
40 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, "Printing")
43 // TODO: Split this file into multiple %included files that coresponds to the
44 // wx/html include files (more or less.)
46 //---------------------------------------------------------------------------
47 //---------------------------------------------------------------------------
58 wxHTML_CLR_FOREGROUND,
59 wxHTML_CLR_BACKGROUND,
69 wxHTML_INDENT_HORIZONTAL,
70 wxHTML_INDENT_VERTICAL,
74 wxHTML_COND_ISIMAGEMAP,
96 // enums for wxHtmlWindow::OnOpeningURL
97 enum wxHtmlOpeningStatus
113 //---------------------------------------------------------------------------
115 class wxHtmlLinkInfo : public wxObject {
117 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
119 wxString GetTarget();
120 wxMouseEvent* GetEvent();
121 wxHtmlCell* GetHtmlCell();
123 void SetEvent(const wxMouseEvent *e);
124 void SetHtmlCell(const wxHtmlCell * e);
127 //---------------------------------------------------------------------------
129 class wxHtmlTag : public wxObject {
131 // Never need to create a new tag from Python...
132 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
135 bool HasParam(const wxString& par);
136 wxString GetParam(const wxString& par, int with_commas = False);
138 // Can't do this one as-is, but GetParam should be enough...
139 //int ScanParam(const wxString& par, const char *format, void* param);
141 wxString GetAllParams();
148 //---------------------------------------------------------------------------
150 class wxHtmlParser : public wxObject {
152 // wxHtmlParser(); This is an abstract base class...
154 void SetFS(wxFileSystem *fs);
155 wxFileSystem* GetFS();
156 wxObject* Parse(const wxString& source);
157 void InitParser(const wxString& source);
159 void DoParsing(int begin_pos, int end_pos);
161 // wxObject* GetProduct();
163 void AddTagHandler(wxHtmlTagHandler *handler);
164 wxString* GetSource();
165 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
166 void PopTagHandler();
168 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
170 // void AddText(const char* txt) = 0;
171 // void AddTag(const wxHtmlTag& tag);
175 //---------------------------------------------------------------------------
177 class wxHtmlWinParser : public wxHtmlParser {
179 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
181 void SetDC(wxDC *dc);
185 wxPyHtmlWindow* GetWindow();
187 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
189 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
191 if (sizes) temp = int_LIST_helper(sizes);
192 self->SetFonts(normal_face, fixed_face, temp);
198 wxHtmlContainerCell* GetContainer();
199 wxHtmlContainerCell* OpenContainer();
200 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
201 wxHtmlContainerCell* CloseContainer();
204 void SetFontSize(int s);
206 void SetFontBold(int x);
208 void SetFontItalic(int x);
209 int GetFontUnderlined();
210 void SetFontUnderlined(int x);
212 void SetFontFixed(int x);
214 void SetAlign(int a);
215 wxColour GetLinkColor();
216 void SetLinkColor(const wxColour& clr);
217 wxColour GetActualColor();
218 void SetActualColor(const wxColour& clr);
219 void SetLink(const wxString& link);
220 wxFont* CreateCurrentFont();
221 wxHtmlLinkInfo GetLink();
226 //---------------------------------------------------------------------------
229 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
230 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
232 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
234 wxHtmlParser* GetParser() { return m_Parser; }
235 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
237 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
238 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
243 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
245 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
246 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
250 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
252 %addtofunc wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
253 wxPyHtmlTagHandler();
255 void _setCallbackInfo(PyObject* self, PyObject* _class);
257 void SetParser(wxHtmlParser *parser);
258 wxHtmlParser* GetParser();
259 void ParseInner(const wxHtmlTag& tag);
263 //---------------------------------------------------------------------------
266 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
267 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
269 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
271 wxHtmlWinParser* GetParser() { return m_WParser; }
272 void ParseInner(const wxHtmlTag& tag)
273 { wxHtmlWinTagHandler::ParseInner(tag); }
275 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
276 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
281 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
283 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
284 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
288 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
290 %addtofunc wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
291 wxPyHtmlWinTagHandler();
293 void _setCallbackInfo(PyObject* self, PyObject* _class);
295 void SetParser(wxHtmlParser *parser);
296 wxHtmlWinParser* GetParser();
297 void ParseInner(const wxHtmlTag& tag);
301 //---------------------------------------------------------------------------
305 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
307 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
308 m_tagHandlerClass = thc;
309 Py_INCREF(m_tagHandlerClass);
310 RegisterModule(this);
311 wxHtmlWinParser::AddModule(this);
315 wxPyBeginBlockThreads();
316 Py_DECREF(m_tagHandlerClass);
317 m_tagHandlerClass = NULL;
318 for (size_t x=0; x < m_objArray.GetCount(); x++) {
319 PyObject* obj = (PyObject*)m_objArray.Item(x);
322 wxPyEndBlockThreads();
325 void FillHandlersTable(wxHtmlWinParser *parser) {
326 // Wave our magic wand... (if it works it's a miracle! ;-)
328 // First, make a new instance of the tag handler
329 wxPyBeginBlockThreads();
330 PyObject* arg = PyTuple_New(0);
331 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
334 // now figure out where it's C++ object is...
335 wxPyHtmlWinTagHandler* thPtr;
336 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
337 wxPyEndBlockThreads();
340 wxPyEndBlockThreads();
343 parser->AddTagHandler(thPtr);
350 PyObject* m_tagHandlerClass;
351 wxArrayPtrVoid m_objArray;
359 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
360 // Dynamically create a new wxModule. Refcounts tagHandlerClass
361 // and adds itself to the wxModules list and to the wxHtmlWinParser.
362 new wxPyHtmlTagsModule(tagHandlerClass);
367 //---------------------------------------------------------------------------
368 //---------------------------------------------------------------------------
372 // wxHtmlSelection is data holder with information about text selection.
373 // Selection is defined by two positions (beginning and end of the selection)
374 // and two leaf(!) cells at these positions.
375 class wxHtmlSelection
381 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
382 const wxPoint& toPos, const wxHtmlCell *toCell);
383 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
385 const wxHtmlCell *GetFromCell() const;
386 const wxHtmlCell *GetToCell() const;
388 // these values are in absolute coordinates:
389 const wxPoint& GetFromPos() const;
390 const wxPoint& GetToPos() const;
392 // these are From/ToCell's private data
393 const wxPoint& GetFromPrivPos() const;
394 const wxPoint& GetToPrivPos() const;
395 void SetFromPrivPos(const wxPoint& pos);
396 void SetToPrivPos(const wxPoint& pos);
399 const bool IsEmpty() const;
404 enum wxHtmlSelectionState
406 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
407 wxHTML_SEL_IN, // ... is inside selection
408 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
413 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
414 // differently e.g. when inside text selection or outside it.
415 class wxHtmlRenderingState
418 wxHtmlRenderingState();
419 ~wxHtmlRenderingState();
421 void SetSelectionState(wxHtmlSelectionState s);
422 wxHtmlSelectionState GetSelectionState() const;
424 void SetFgColour(const wxColour& c);
425 const wxColour& GetFgColour() const;
426 void SetBgColour(const wxColour& c);
427 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 //---------------------------------------------------------------------------
475 wxHTML_FIND_EXACT = 1,
476 wxHTML_FIND_NEAREST_BEFORE = 2,
477 wxHTML_FIND_NEAREST_AFTER = 4
481 class wxHtmlCell : public wxObject {
490 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
491 wxHtmlCell* GetNext();
492 wxHtmlContainerCell* GetParent();
493 wxHtmlCell* GetFirstChild() const;
495 // Returns cursor to be used when mouse is over the cell:
496 wxCursor GetCursor() const;
498 // Formatting cells are not visible on the screen, they only alter
500 bool IsFormattingCell() const;
503 void SetLink(const wxHtmlLinkInfo& link);
504 void SetNext(wxHtmlCell *cell);
505 void SetParent(wxHtmlContainerCell *p);
506 void SetPos(int x, int y);
508 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
509 wxHtmlRenderingInfo& info);
510 void DrawInvisible(wxDC& dc, int x, int y,
511 wxHtmlRenderingInfo& info);
512 const wxHtmlCell* Find(int condition, const void* param);
514 bool AdjustPagebreak(int* INOUT);
515 void SetCanLiveOnPagebreak(bool can);
517 // Can the line be broken before this cell?
518 bool IsLinebreakAllowed() const;
520 // Returns True for simple == terminal cells, i.e. not composite ones.
521 // This if for internal usage only and may disappear in future versions!
522 bool IsTerminalCell() const;
524 // Find a cell inside this cell positioned at the given coordinates
525 // (relative to this's positions). Returns NULL if no such cell exists.
526 // The flag can be used to specify whether to look for terminal or
527 // nonterminal cells or both. In either case, returned cell is deepest
528 // cell in cells tree that contains [x,y].
529 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
530 unsigned flags = wxHTML_FIND_EXACT) const;
532 // Returns absolute position of the cell on HTML canvas
533 wxPoint GetAbsPos() const;
535 // Returns first (last) terminal cell inside this cell. It may return NULL,
536 // but it is rare -- only if there are no terminals in the tree.
537 wxHtmlCell *GetFirstTerminal() const ;
538 wxHtmlCell *GetLastTerminal() const ;
540 // Returns cell's depth, i.e. how far under the root cell it is
541 // (if it is the root, depth is 0)
542 unsigned GetDepth() const;
544 // Returns True if the cell appears before 'cell' in natural order of
545 // cells (= as they are read). If cell A is (grand)parent of cell B,
546 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
547 bool IsBefore(wxHtmlCell *cell) const;
549 // Converts the cell into text representation. If sel != NULL then
550 // only part of the cell inside the selection is converted.
551 wxString ConvertToText(wxHtmlSelection *sel) const;
555 class wxHtmlWordCell : public wxHtmlCell
558 wxHtmlWordCell(const wxString& word, wxDC& dc);
562 class wxHtmlContainerCell : public wxHtmlCell {
564 wxHtmlContainerCell(wxHtmlContainerCell *parent);
566 void InsertCell(wxHtmlCell *cell);
567 void SetAlignHor(int al);
569 void SetAlignVer(int al);
571 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
572 int GetIndent(int ind);
573 int GetIndentUnits(int ind);
574 void SetAlign(const wxHtmlTag& tag);
575 void SetWidthFloat(int w, int units);
576 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
577 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
578 void SetBackgroundColour(const wxColour& clr);
579 wxColour GetBackgroundColour();
580 void SetBorder(const wxColour& clr1, const wxColour& clr2);
581 wxHtmlCell* GetFirstChild();
582 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
587 class wxHtmlColourCell : public wxHtmlCell {
589 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
594 class wxHtmlFontCell : public wxHtmlCell
597 wxHtmlFontCell(wxFont *font);
601 class wxHtmlWidgetCell : public wxHtmlCell {
603 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
610 //---------------------------------------------------------------------------
612 //---------------------------------------------------------------------------
616 %{ // here's the C++ version
617 class wxPyHtmlFilter : public wxHtmlFilter {
618 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
620 wxPyHtmlFilter() : wxHtmlFilter() {}
622 // returns True if this filter is able to open&read given file
623 virtual bool CanRead(const wxFSFile& file) const {
626 wxPyBeginBlockThreads();
627 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
628 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
629 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
632 wxPyEndBlockThreads();
637 // Reads given file and returns HTML document.
638 // Returns empty string if opening failed
639 virtual wxString ReadFile(const wxFSFile& file) const {
642 wxPyBeginBlockThreads();
643 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
644 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
646 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
649 rval = Py2wxString(ro);
653 wxPyEndBlockThreads();
660 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
664 // And now the version seen by SWIG
666 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
668 %addtofunc wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
671 void _setCallbackInfo(PyObject* self, PyObject* _class);
675 // TODO: wxHtmlFilterHTML
678 //---------------------------------------------------------------------------
680 //---------------------------------------------------------------------------
684 class wxPyHtmlWindow : public wxHtmlWindow {
685 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
687 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
688 const wxPoint& pos = wxDefaultPosition,
689 const wxSize& size = wxDefaultSize,
690 long style = wxHW_DEFAULT_STYLE,
691 const wxString& name = wxPyHtmlWindowNameStr)
692 : wxHtmlWindow(parent, id, pos, size, style, name) {};
693 wxPyHtmlWindow() : wxHtmlWindow() {};
695 bool ScrollToAnchor(const wxString& anchor) {
696 return wxHtmlWindow::ScrollToAnchor(anchor);
699 bool HasAnchor(const wxString& anchor) {
700 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
704 void OnLinkClicked(const wxHtmlLinkInfo& link);
705 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
707 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
709 wxString *redirect) const;
711 DEC_PYCALLBACK__STRING(OnSetTitle);
712 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
713 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
717 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
718 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
719 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
720 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
723 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
725 wxPyBeginBlockThreads();
726 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
727 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
728 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
731 wxPyEndBlockThreads();
733 wxHtmlWindow::OnLinkClicked(link);
735 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
736 wxHtmlWindow::OnLinkClicked(link);
740 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
742 wxString *redirect) const {
744 wxHtmlOpeningStatus rval;
745 wxPyBeginBlockThreads();
746 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
748 PyObject* s = wx2PyString(url);
749 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
751 if (PyString_Check(ro)
752 #if PYTHON_API_VERSION >= 1009
753 || PyUnicode_Check(ro)
756 *redirect = Py2wxString(ro);
757 rval = wxHTML_REDIRECT;
760 PyObject* num = PyNumber_Int(ro);
761 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
766 wxPyEndBlockThreads();
768 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
777 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
779 %addtofunc wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
780 %addtofunc wxPyHtmlWindow() ""
782 wxPyHtmlWindow(wxWindow *parent, int id = -1,
783 const wxPoint& pos = wxDefaultPosition,
784 const wxSize& size = wxDefaultSize,
785 int style=wxHW_DEFAULT_STYLE,
786 const wxString& name = wxPyHtmlWindowNameStr);
787 %name(PreHtmlWindow)wxPyHtmlWindow();
789 bool Create(wxWindow *parent, int id = -1,
790 const wxPoint& pos = wxDefaultPosition,
791 const wxSize& size = wxDefaultSize,
792 int style=wxHW_SCROLLBAR_AUTO,
793 const wxString& name = wxPyHtmlWindowNameStr);
796 void _setCallbackInfo(PyObject* self, PyObject* _class);
799 // Set HTML page and display it. !! source is HTML document itself,
800 // it is NOT address/filename of HTML document. If you want to
801 // specify document location, use LoadPage() istead
802 // Return value : False if an error occured, True otherwise
803 bool SetPage(const wxString& source);
805 // Load HTML page from given location. Location can be either
806 // a) /usr/wxGTK2/docs/html/wx.htm
807 // b) http://www.somewhere.uk/document.htm
808 // c) ftp://ftp.somesite.cz/pub/something.htm
809 // In case there is no prefix (http:,ftp:), the method
810 // will try to find it itself (1. local file, then http or ftp)
811 // After the page is loaded, the method calls SetPage() to display it.
812 // Note : you can also use path relative to previously loaded page
813 // Return value : same as SetPage
814 bool LoadPage(const wxString& location);
816 // Loads HTML page from file
817 bool LoadFile(const wxString& filename);
819 // Append to current page
820 bool AppendToPage(const wxString& source);
822 // Returns full location of opened page
823 wxString GetOpenedPage();
825 // Returns anchor within opened page
826 wxString GetOpenedAnchor();
828 // Returns <TITLE> of opened page or empty string otherwise
829 wxString GetOpenedPageTitle();
831 // Sets frame in which page title will be displayed. Format is format of
832 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
833 void SetRelatedFrame(wxFrame* frame, const wxString& format);
834 wxFrame* GetRelatedFrame();
836 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
837 // will be displayed. Default is -1 = no messages.
838 void SetRelatedStatusBar(int bar);
840 // Sets fonts to be used when displaying HTML page.
842 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
844 if (sizes) temp = int_LIST_helper(sizes);
845 self->SetFonts(normal_face, fixed_face, temp);
851 void SetTitle(const wxString& title);
853 // Sets space between text and window borders.
854 void SetBorders(int b);
856 // Saves custom settings into cfg config. it will use the path 'path'
857 // if given, otherwise it will save info into currently selected path.
858 // saved values : things set by SetFonts, SetBorders.
859 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
860 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
862 // Goes to previous/next page (in browsing history)
863 // Returns True if successful, False otherwise
865 bool HistoryForward();
866 bool HistoryCanBack();
867 bool HistoryCanForward();
872 // Returns pointer to conteiners/cells structure.
873 wxHtmlContainerCell* GetInternalRepresentation();
875 // Returns a pointer to the parser.
876 wxHtmlWinParser* GetParser();
878 bool ScrollToAnchor(const wxString& anchor);
879 bool HasAnchor(const wxString& anchor);
882 static void AddFilter(wxPyHtmlFilter *filter);
885 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
886 void base_OnSetTitle(const wxString& title);
887 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
888 void base_OnCellClicked(wxHtmlCell *cell,
889 wxCoord x, wxCoord y,
890 const wxMouseEvent& event);
896 //---------------------------------------------------------------------------
897 //---------------------------------------------------------------------------
901 class wxHtmlDCRenderer : public wxObject {
906 void SetDC(wxDC *dc, int maxwidth);
907 void SetSize(int width, int height);
908 void SetHtmlText(const wxString& html,
909 const wxString& basepath = wxPyEmptyString,
911 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
913 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
915 if (sizes) temp = int_LIST_helper(sizes);
916 self->SetFonts(normal_face, fixed_face, temp);
921 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
922 //int *known_pagebreaks = NULL, int number_of_pages = 0
923 int* choices=NULL, int LCOUNT = 0
925 int GetTotalHeight();
926 // returns total height of the html document
927 // (compare Render's return value with this)
938 class wxHtmlPrintout : public wxPyPrintout {
940 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
941 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
943 void SetHtmlText(const wxString& html,
944 const wxString &basepath = wxPyEmptyString,
946 void SetHtmlFile(const wxString &htmlfile);
947 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
948 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
950 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
952 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
954 if (sizes) temp = int_LIST_helper(sizes);
955 self->SetFonts(normal_face, fixed_face, temp);
960 void SetMargins(float top = 25.2, float bottom = 25.2,
961 float left = 25.2, float right = 25.2,
965 static void AddFilter(wxHtmlFilter *filter);
968 static void CleanUpStatics();
973 class wxHtmlEasyPrinting : public wxObject {
975 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
976 wxWindow *parentWindow = NULL);
977 ~wxHtmlEasyPrinting();
979 void PreviewFile(const wxString &htmlfile);
980 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
981 void PrintFile(const wxString &htmlfile);
982 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
985 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
986 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
989 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
991 if (sizes) temp = int_LIST_helper(sizes);
992 self->SetFonts(normal_face, fixed_face, temp);
998 wxPrintData *GetPrintData() {return m_PrintData;}
999 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1004 //---------------------------------------------------------------------------
1005 //---------------------------------------------------------------------------
1009 class wxHtmlBookRecord {
1011 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1012 const wxString& title, const wxString& start);
1014 wxString GetBookFile();
1015 wxString GetTitle();
1016 wxString GetStart();
1017 wxString GetBasePath();
1019 void SetContentsRange(int start, int end);
1020 int GetContentsStart();
1021 int GetContentsEnd();
1023 void SetTitle(const wxString& title);
1024 void SetBasePath(const wxString& path);
1025 void SetStart(const wxString& start);
1027 wxString GetFullPath(const wxString &page) const;
1030 //---------------------------------------------------------------------------
1032 struct wxHtmlContentsItem
1035 int GetLevel() { return self->m_Level; }
1036 int GetID() { return self->m_ID; }
1037 wxString GetName() { return self->m_Name; }
1038 wxString GetPage() { return self->m_Page; }
1039 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1043 //---------------------------------------------------------------------------
1045 class wxHtmlSearchStatus
1048 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1049 // const wxString& book = wxPyEmptyString);
1054 const wxString& GetName();
1055 wxHtmlContentsItem* GetContentsItem();
1058 //---------------------------------------------------------------------------
1060 class wxHtmlHelpData {
1065 void SetTempDir(const wxString& path);
1066 bool AddBook(const wxString& book);
1067 // bool AddBookParam(const wxString& title, const wxString& contfile,
1068 // const wxString& indexfile=wxPyEmptyString,
1069 // const wxString& deftopic=wxPyEmptyString,
1070 // const wxString& path=wxPyEmptyString);
1072 wxString FindPageByName(const wxString& page);
1073 wxString FindPageById(int id);
1075 // TODO: this one needs fixed...
1076 const wxHtmlBookRecArray& GetBookRecArray();
1078 wxHtmlContentsItem* GetContents();
1079 int GetContentsCnt();
1080 wxHtmlContentsItem* GetIndex();
1084 //---------------------------------------------------------------------------
1086 class wxHtmlHelpFrame : public wxFrame {
1088 %addtofunc wxHtmlHelpFrame "self._setOORInfo(self)"
1090 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1091 const wxString& title = wxPyEmptyString,
1092 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1094 wxHtmlHelpData* GetData();
1095 void SetTitleFormat(const wxString& format);
1096 void Display(const wxString& x);
1097 %name(DisplayID) void Display(int id);
1098 void DisplayContents();
1099 void DisplayIndex();
1100 bool KeywordSearch(const wxString& keyword);
1101 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1102 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1103 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1107 //---------------------------------------------------------------------------
1123 class wxHtmlHelpController : public wxEvtHandler {
1125 %addtofunc wxHtmlHelpController "self._setOORInfo(self)"
1127 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1128 ~wxHtmlHelpController();
1130 void SetTitleFormat(const wxString& format);
1131 void SetTempDir(const wxString& path);
1132 bool AddBook(const wxString& book, int show_wait_msg = False);
1133 void Display(const wxString& x);
1134 %name(DisplayID) void Display(int id);
1135 void DisplayContents();
1136 void DisplayIndex();
1137 bool KeywordSearch(const wxString& keyword);
1138 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1139 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1140 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1141 wxHtmlHelpFrame* GetFrame();
1147 //---------------------------------------------------------------------------
1149 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1150 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1151 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1152 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1154 //---------------------------------------------------------------------------
1155 //---------------------------------------------------------------------------