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, wxT("htmlWindow"))
39 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout"))
40 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("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 %pythonAppend 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 %pythonAppend 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 bool blocked = 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(blocked);
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 bool blocked = 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(blocked);
340 wxPyEndBlockThreads(blocked);
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 {
491 // Returns the maximum possible length of the cell.
492 // Call Layout at least once before using GetMaxTotalWidth()
493 int GetMaxTotalWidth() const;
495 const wxString& GetId() const;
496 void SetId(const wxString& id);
497 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
498 wxHtmlCell* GetNext();
499 wxHtmlContainerCell* GetParent();
500 wxHtmlCell* GetFirstChild() const;
502 // Returns cursor to be used when mouse is over the cell:
503 wxCursor GetCursor() const;
505 // Formatting cells are not visible on the screen, they only alter
507 bool IsFormattingCell() const;
510 void SetLink(const wxHtmlLinkInfo& link);
511 void SetNext(wxHtmlCell *cell);
512 void SetParent(wxHtmlContainerCell *p);
513 void SetPos(int x, int y);
515 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
516 wxHtmlRenderingInfo& info);
517 void DrawInvisible(wxDC& dc, int x, int y,
518 wxHtmlRenderingInfo& info);
519 const wxHtmlCell* Find(int condition, const void* param);
521 bool AdjustPagebreak(int* INOUT);
522 void SetCanLiveOnPagebreak(bool can);
524 // Can the line be broken before this cell?
525 bool IsLinebreakAllowed() const;
527 // Returns True for simple == terminal cells, i.e. not composite ones.
528 // This if for internal usage only and may disappear in future versions!
529 bool IsTerminalCell() const;
531 // Find a cell inside this cell positioned at the given coordinates
532 // (relative to this's positions). Returns NULL if no such cell exists.
533 // The flag can be used to specify whether to look for terminal or
534 // nonterminal cells or both. In either case, returned cell is deepest
535 // cell in cells tree that contains [x,y].
536 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
537 unsigned flags = wxHTML_FIND_EXACT) const;
539 // Returns absolute position of the cell on HTML canvas
540 wxPoint GetAbsPos() const;
542 // Returns first (last) terminal cell inside this cell. It may return NULL,
543 // but it is rare -- only if there are no terminals in the tree.
544 wxHtmlCell *GetFirstTerminal() const ;
545 wxHtmlCell *GetLastTerminal() const ;
547 // Returns cell's depth, i.e. how far under the root cell it is
548 // (if it is the root, depth is 0)
549 unsigned GetDepth() const;
551 // Returns True if the cell appears before 'cell' in natural order of
552 // cells (= as they are read). If cell A is (grand)parent of cell B,
553 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
554 bool IsBefore(wxHtmlCell *cell) const;
556 // Converts the cell into text representation. If sel != NULL then
557 // only part of the cell inside the selection is converted.
558 wxString ConvertToText(wxHtmlSelection *sel) const;
562 class wxHtmlWordCell : public wxHtmlCell
565 wxHtmlWordCell(const wxString& word, wxDC& dc);
569 class wxHtmlContainerCell : public wxHtmlCell {
571 wxHtmlContainerCell(wxHtmlContainerCell *parent);
573 void InsertCell(wxHtmlCell *cell);
574 void SetAlignHor(int al);
576 void SetAlignVer(int al);
578 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
579 int GetIndent(int ind);
580 int GetIndentUnits(int ind);
581 void SetAlign(const wxHtmlTag& tag);
582 void SetWidthFloat(int w, int units);
583 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
584 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
585 void SetBackgroundColour(const wxColour& clr);
586 wxColour GetBackgroundColour();
587 void SetBorder(const wxColour& clr1, const wxColour& clr2);
588 wxHtmlCell* GetFirstChild();
589 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
594 class wxHtmlColourCell : public wxHtmlCell {
596 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
601 class wxHtmlFontCell : public wxHtmlCell
604 wxHtmlFontCell(wxFont *font);
608 class wxHtmlWidgetCell : public wxHtmlCell {
610 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
617 //---------------------------------------------------------------------------
619 //---------------------------------------------------------------------------
623 %{ // here's the C++ version
624 class wxPyHtmlFilter : public wxHtmlFilter {
625 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
627 wxPyHtmlFilter() : wxHtmlFilter() {}
629 // returns True if this filter is able to open&read given file
630 virtual bool CanRead(const wxFSFile& file) const {
633 bool blocked = wxPyBeginBlockThreads();
634 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
635 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
636 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
639 wxPyEndBlockThreads(blocked);
644 // Reads given file and returns HTML document.
645 // Returns empty string if opening failed
646 virtual wxString ReadFile(const wxFSFile& file) const {
649 bool blocked = wxPyBeginBlockThreads();
650 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
651 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
653 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
656 rval = Py2wxString(ro);
660 wxPyEndBlockThreads(blocked);
667 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
671 // And now the version seen by SWIG
673 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
675 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
678 void _setCallbackInfo(PyObject* self, PyObject* _class);
682 // TODO: wxHtmlFilterHTML
685 //---------------------------------------------------------------------------
687 //---------------------------------------------------------------------------
691 class wxPyHtmlWindow : public wxHtmlWindow {
692 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
694 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
695 const wxPoint& pos = wxDefaultPosition,
696 const wxSize& size = wxDefaultSize,
697 long style = wxHW_DEFAULT_STYLE,
698 const wxString& name = wxPyHtmlWindowNameStr)
699 : wxHtmlWindow(parent, id, pos, size, style, name) {};
700 wxPyHtmlWindow() : wxHtmlWindow() {};
702 bool ScrollToAnchor(const wxString& anchor) {
703 return wxHtmlWindow::ScrollToAnchor(anchor);
706 bool HasAnchor(const wxString& anchor) {
707 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
711 void OnLinkClicked(const wxHtmlLinkInfo& link);
712 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
714 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
716 wxString *redirect) const;
718 DEC_PYCALLBACK__STRING(OnSetTitle);
719 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
720 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
724 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
725 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
726 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
727 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
730 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
732 bool blocked = wxPyBeginBlockThreads();
733 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
734 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
738 wxPyEndBlockThreads(blocked);
740 wxHtmlWindow::OnLinkClicked(link);
742 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
743 wxHtmlWindow::OnLinkClicked(link);
747 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
749 wxString *redirect) const {
751 wxHtmlOpeningStatus rval;
752 bool blocked = wxPyBeginBlockThreads();
753 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
755 PyObject* s = wx2PyString(url);
756 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
758 if (PyString_Check(ro)
759 #if PYTHON_API_VERSION >= 1009
760 || PyUnicode_Check(ro)
763 *redirect = Py2wxString(ro);
764 rval = wxHTML_REDIRECT;
767 PyObject* num = PyNumber_Int(ro);
768 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
773 wxPyEndBlockThreads(blocked);
775 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
784 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
786 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
787 %pythonAppend wxPyHtmlWindow() ""
789 wxPyHtmlWindow(wxWindow *parent, int id = -1,
790 const wxPoint& pos = wxDefaultPosition,
791 const wxSize& size = wxDefaultSize,
792 int style=wxHW_DEFAULT_STYLE,
793 const wxString& name = wxPyHtmlWindowNameStr);
794 %name(PreHtmlWindow)wxPyHtmlWindow();
796 bool Create(wxWindow *parent, int id = -1,
797 const wxPoint& pos = wxDefaultPosition,
798 const wxSize& size = wxDefaultSize,
799 int style=wxHW_SCROLLBAR_AUTO,
800 const wxString& name = wxPyHtmlWindowNameStr);
803 void _setCallbackInfo(PyObject* self, PyObject* _class);
806 // Set HTML page and display it. !! source is HTML document itself,
807 // it is NOT address/filename of HTML document. If you want to
808 // specify document location, use LoadPage() istead
809 // Return value : False if an error occured, True otherwise
810 bool SetPage(const wxString& source);
812 // Load HTML page from given location. Location can be either
813 // a) /usr/wxGTK2/docs/html/wx.htm
814 // b) http://www.somewhere.uk/document.htm
815 // c) ftp://ftp.somesite.cz/pub/something.htm
816 // In case there is no prefix (http:,ftp:), the method
817 // will try to find it itself (1. local file, then http or ftp)
818 // After the page is loaded, the method calls SetPage() to display it.
819 // Note : you can also use path relative to previously loaded page
820 // Return value : same as SetPage
821 bool LoadPage(const wxString& location);
823 // Loads HTML page from file
824 bool LoadFile(const wxString& filename);
826 // Append to current page
827 bool AppendToPage(const wxString& source);
829 // Returns full location of opened page
830 wxString GetOpenedPage();
832 // Returns anchor within opened page
833 wxString GetOpenedAnchor();
835 // Returns <TITLE> of opened page or empty string otherwise
836 wxString GetOpenedPageTitle();
838 // Sets frame in which page title will be displayed. Format is format of
839 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
840 void SetRelatedFrame(wxFrame* frame, const wxString& format);
841 wxFrame* GetRelatedFrame();
843 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
844 // will be displayed. Default is -1 = no messages.
845 void SetRelatedStatusBar(int bar);
847 // Sets fonts to be used when displaying HTML page.
849 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
851 if (sizes) temp = int_LIST_helper(sizes);
852 self->SetFonts(normal_face, fixed_face, temp);
859 void, SetTitle(const wxString& title),
862 // Sets space between text and window borders.
863 void SetBorders(int b);
865 // Saves custom settings into cfg config. it will use the path 'path'
866 // if given, otherwise it will save info into currently selected path.
867 // saved values : things set by SetFonts, SetBorders.
868 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
869 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
871 // Goes to previous/next page (in browsing history)
872 // Returns True if successful, False otherwise
874 bool HistoryForward();
875 bool HistoryCanBack();
876 bool HistoryCanForward();
881 // Returns pointer to conteiners/cells structure.
882 wxHtmlContainerCell* GetInternalRepresentation();
884 // Returns a pointer to the parser.
885 wxHtmlWinParser* GetParser();
887 bool ScrollToAnchor(const wxString& anchor);
888 bool HasAnchor(const wxString& anchor);
891 static void AddFilter(wxPyHtmlFilter *filter);
893 // Helper functions to select parts of page:
894 void SelectWord(const wxPoint& pos);
895 void SelectLine(const wxPoint& pos);
899 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
900 void base_OnSetTitle(const wxString& title);
901 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
902 void base_OnCellClicked(wxHtmlCell *cell,
903 wxCoord x, wxCoord y,
904 const wxMouseEvent& event);
910 //---------------------------------------------------------------------------
911 //---------------------------------------------------------------------------
915 class wxHtmlDCRenderer : public wxObject {
920 void SetDC(wxDC *dc, int maxwidth);
921 void SetSize(int width, int height);
922 void SetHtmlText(const wxString& html,
923 const wxString& basepath = wxPyEmptyString,
925 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
927 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
929 if (sizes) temp = int_LIST_helper(sizes);
930 self->SetFonts(normal_face, fixed_face, temp);
935 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
936 //int *known_pagebreaks = NULL, int number_of_pages = 0
937 int* choices=NULL, int LCOUNT = 0
939 int GetTotalHeight();
940 // returns total height of the html document
941 // (compare Render's return value with this)
952 class wxHtmlPrintout : public wxPyPrintout {
954 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
955 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
957 void SetHtmlText(const wxString& html,
958 const wxString &basepath = wxPyEmptyString,
960 void SetHtmlFile(const wxString &htmlfile);
961 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
962 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
964 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
966 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
968 if (sizes) temp = int_LIST_helper(sizes);
969 self->SetFonts(normal_face, fixed_face, temp);
974 void SetMargins(float top = 25.2, float bottom = 25.2,
975 float left = 25.2, float right = 25.2,
979 static void AddFilter(wxHtmlFilter *filter);
982 static void CleanUpStatics();
987 class wxHtmlEasyPrinting : public wxObject {
989 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
990 wxWindow *parentWindow = NULL);
991 ~wxHtmlEasyPrinting();
993 void PreviewFile(const wxString &htmlfile);
994 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
995 void PrintFile(const wxString &htmlfile);
996 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
999 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1000 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1003 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1005 if (sizes) temp = int_LIST_helper(sizes);
1006 self->SetFonts(normal_face, fixed_face, temp);
1012 wxPrintData *GetPrintData() {return m_PrintData;}
1013 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1018 //---------------------------------------------------------------------------
1019 //---------------------------------------------------------------------------
1023 class wxHtmlBookRecord {
1025 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1026 const wxString& title, const wxString& start);
1028 wxString GetBookFile();
1029 wxString GetTitle();
1030 wxString GetStart();
1031 wxString GetBasePath();
1033 void SetContentsRange(int start, int end);
1034 int GetContentsStart();
1035 int GetContentsEnd();
1037 void SetTitle(const wxString& title);
1038 void SetBasePath(const wxString& path);
1039 void SetStart(const wxString& start);
1041 wxString GetFullPath(const wxString &page) const;
1044 //---------------------------------------------------------------------------
1046 struct wxHtmlContentsItem
1049 int GetLevel() { return self->m_Level; }
1050 int GetID() { return self->m_ID; }
1051 wxString GetName() { return self->m_Name; }
1052 wxString GetPage() { return self->m_Page; }
1053 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1057 //---------------------------------------------------------------------------
1059 class wxHtmlSearchStatus
1062 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1063 // const wxString& book = wxPyEmptyString);
1068 const wxString& GetName();
1069 wxHtmlContentsItem* GetContentsItem();
1072 //---------------------------------------------------------------------------
1074 class wxHtmlHelpData {
1079 void SetTempDir(const wxString& path);
1080 bool AddBook(const wxString& book);
1081 // bool AddBookParam(const wxString& title, const wxString& contfile,
1082 // const wxString& indexfile=wxPyEmptyString,
1083 // const wxString& deftopic=wxPyEmptyString,
1084 // const wxString& path=wxPyEmptyString);
1086 wxString FindPageByName(const wxString& page);
1087 wxString FindPageById(int id);
1089 // TODO: this one needs fixed...
1090 const wxHtmlBookRecArray& GetBookRecArray();
1092 wxHtmlContentsItem* GetContents();
1093 int GetContentsCnt();
1094 wxHtmlContentsItem* GetIndex();
1098 //---------------------------------------------------------------------------
1100 class wxHtmlHelpFrame : public wxFrame {
1102 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1104 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1105 const wxString& title = wxPyEmptyString,
1106 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1108 wxHtmlHelpData* GetData();
1109 void SetTitleFormat(const wxString& format);
1110 void Display(const wxString& x);
1111 %name(DisplayID) void Display(int id);
1112 void DisplayContents();
1113 void DisplayIndex();
1114 bool KeywordSearch(const wxString& keyword);
1115 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1116 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1117 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1121 //---------------------------------------------------------------------------
1137 class wxHtmlHelpController : public wxEvtHandler {
1139 %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1141 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1142 ~wxHtmlHelpController();
1144 void SetTitleFormat(const wxString& format);
1145 void SetTempDir(const wxString& path);
1146 bool AddBook(const wxString& book, int show_wait_msg = False);
1147 void Display(const wxString& x);
1148 %name(DisplayID) void Display(int id);
1149 void DisplayContents();
1150 void DisplayIndex();
1151 bool KeywordSearch(const wxString& keyword);
1152 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1153 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1154 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1155 wxHtmlHelpFrame* GetFrame();
1161 //---------------------------------------------------------------------------
1163 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1164 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1165 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1166 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1168 //---------------------------------------------------------------------------
1169 //---------------------------------------------------------------------------