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>
27 DECLARE_DEF_STRING(EmptyString);
28 static const wxChar* wxHtmlWindowNameStr = wxT("htmlWindow");
29 DECLARE_DEF_STRING(HtmlWindowNameStr);
30 static const wxChar* wxHtmlPrintoutTitleStr = wxT("Printout");
31 DECLARE_DEF_STRING(HtmlPrintoutTitleStr);
32 static const wxChar* wxHtmlPrintingTitleStr = wxT("Printing");
33 DECLARE_DEF_STRING(HtmlPrintingTitleStr);
37 //---------------------------------------------------------------------------
40 %pythoncode { wx = core }
42 %include _html_rename.i
45 // TODO: Split this file into multiple %included files that coresponds to the
46 // wx/html include files (more or less.)
48 //---------------------------------------------------------------------------
49 //---------------------------------------------------------------------------
60 wxHTML_CLR_FOREGROUND,
61 wxHTML_CLR_BACKGROUND,
71 wxHTML_INDENT_HORIZONTAL,
72 wxHTML_INDENT_VERTICAL,
76 wxHTML_COND_ISIMAGEMAP,
98 // enums for wxHtmlWindow::OnOpeningURL
99 enum wxHtmlOpeningStatus
115 //---------------------------------------------------------------------------
117 class wxHtmlLinkInfo : public wxObject {
119 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
121 wxString GetTarget();
122 wxMouseEvent* GetEvent();
123 wxHtmlCell* GetHtmlCell();
125 void SetEvent(const wxMouseEvent *e);
126 void SetHtmlCell(const wxHtmlCell * e);
129 //---------------------------------------------------------------------------
131 class wxHtmlTag : public wxObject {
133 // Never need to create a new tag from Python...
134 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
137 bool HasParam(const wxString& par);
138 wxString GetParam(const wxString& par, int with_commas = False);
140 // Can't do this one as-is, but GetParam should be enough...
141 //int ScanParam(const wxString& par, const char *format, void* param);
143 wxString GetAllParams();
150 //---------------------------------------------------------------------------
152 class wxHtmlParser : public wxObject {
154 // wxHtmlParser(); This is an abstract base class...
156 void SetFS(wxFileSystem *fs);
157 wxFileSystem* GetFS();
158 wxObject* Parse(const wxString& source);
159 void InitParser(const wxString& source);
161 void DoParsing(int begin_pos, int end_pos);
163 // wxObject* GetProduct();
165 void AddTagHandler(wxHtmlTagHandler *handler);
166 wxString* GetSource();
167 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
168 void PopTagHandler();
170 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
172 // void AddText(const char* txt) = 0;
173 // void AddTag(const wxHtmlTag& tag);
177 //---------------------------------------------------------------------------
179 class wxHtmlWinParser : public wxHtmlParser {
181 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
183 void SetDC(wxDC *dc);
187 wxPyHtmlWindow* GetWindow();
189 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
191 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
193 if (sizes) temp = int_LIST_helper(sizes);
194 self->SetFonts(normal_face, fixed_face, temp);
200 wxHtmlContainerCell* GetContainer();
201 wxHtmlContainerCell* OpenContainer();
202 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
203 wxHtmlContainerCell* CloseContainer();
206 void SetFontSize(int s);
208 void SetFontBold(int x);
210 void SetFontItalic(int x);
211 int GetFontUnderlined();
212 void SetFontUnderlined(int x);
214 void SetFontFixed(int x);
216 void SetAlign(int a);
217 wxColour GetLinkColor();
218 void SetLinkColor(const wxColour& clr);
219 wxColour GetActualColor();
220 void SetActualColor(const wxColour& clr);
221 void SetLink(const wxString& link);
222 wxFont* CreateCurrentFont();
223 wxHtmlLinkInfo GetLink();
228 //---------------------------------------------------------------------------
231 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
232 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
234 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
236 wxHtmlParser* GetParser() { return m_Parser; }
237 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
239 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
240 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
245 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
247 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
248 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
252 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
254 %addtofunc wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
255 wxPyHtmlTagHandler();
257 void _setCallbackInfo(PyObject* self, PyObject* _class);
259 void SetParser(wxHtmlParser *parser);
260 wxHtmlParser* GetParser();
261 void ParseInner(const wxHtmlTag& tag);
265 //---------------------------------------------------------------------------
268 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
269 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
271 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
273 wxHtmlWinParser* GetParser() { return m_WParser; }
274 void ParseInner(const wxHtmlTag& tag)
275 { wxHtmlWinTagHandler::ParseInner(tag); }
277 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
278 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
283 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
285 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
286 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
290 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
292 %addtofunc wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
293 wxPyHtmlWinTagHandler();
295 void _setCallbackInfo(PyObject* self, PyObject* _class);
297 void SetParser(wxHtmlParser *parser);
298 wxHtmlWinParser* GetParser();
299 void ParseInner(const wxHtmlTag& tag);
303 //---------------------------------------------------------------------------
307 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
309 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
310 m_tagHandlerClass = thc;
311 Py_INCREF(m_tagHandlerClass);
312 RegisterModule(this);
313 wxHtmlWinParser::AddModule(this);
317 wxPyBeginBlockThreads();
318 Py_DECREF(m_tagHandlerClass);
319 m_tagHandlerClass = NULL;
320 for (size_t x=0; x < m_objArray.GetCount(); x++) {
321 PyObject* obj = (PyObject*)m_objArray.Item(x);
324 wxPyEndBlockThreads();
327 void FillHandlersTable(wxHtmlWinParser *parser) {
328 // Wave our magic wand... (if it works it's a miracle! ;-)
330 // First, make a new instance of the tag handler
331 wxPyBeginBlockThreads();
332 PyObject* arg = PyTuple_New(0);
333 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
336 // now figure out where it's C++ object is...
337 wxPyHtmlWinTagHandler* thPtr;
338 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
339 wxPyEndBlockThreads();
342 wxPyEndBlockThreads();
345 parser->AddTagHandler(thPtr);
352 PyObject* m_tagHandlerClass;
353 wxArrayPtrVoid m_objArray;
361 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
362 // Dynamically create a new wxModule. Refcounts tagHandlerClass
363 // and adds itself to the wxModules list and to the wxHtmlWinParser.
364 new wxPyHtmlTagsModule(tagHandlerClass);
369 //---------------------------------------------------------------------------
370 //---------------------------------------------------------------------------
374 // wxHtmlSelection is data holder with information about text selection.
375 // Selection is defined by two positions (beginning and end of the selection)
376 // and two leaf(!) cells at these positions.
377 class wxHtmlSelection
383 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
384 const wxPoint& toPos, const wxHtmlCell *toCell);
385 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
387 const wxHtmlCell *GetFromCell() const;
388 const wxHtmlCell *GetToCell() const;
390 // these values are in absolute coordinates:
391 const wxPoint& GetFromPos() const;
392 const wxPoint& GetToPos() const;
394 // these are From/ToCell's private data
395 const wxPoint& GetFromPrivPos() const;
396 const wxPoint& GetToPrivPos() const;
397 void SetFromPrivPos(const wxPoint& pos);
398 void SetToPrivPos(const wxPoint& pos);
401 const bool IsEmpty() const;
406 enum wxHtmlSelectionState
408 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
409 wxHTML_SEL_IN, // ... is inside selection
410 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
415 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
416 // differently e.g. when inside text selection or outside it.
417 class wxHtmlRenderingState
420 wxHtmlRenderingState();
421 ~wxHtmlRenderingState();
423 void SetSelectionState(wxHtmlSelectionState s);
424 wxHtmlSelectionState GetSelectionState() const;
426 void SetFgColour(const wxColour& c);
427 const wxColour& GetFgColour() const;
428 void SetBgColour(const wxColour& c);
429 const wxColour& GetBgColour() const;
434 // HTML rendering customization. This class is used when rendering wxHtmlCells
436 class wxHtmlRenderingStyle
439 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
440 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
444 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
447 virtual wxColour GetSelectedTextColour(const wxColour& clr);
448 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
453 // Information given to cells when drawing them. Contains rendering state,
454 // selection information and rendering style object that can be used to
455 // customize the output.
456 class wxHtmlRenderingInfo
459 wxHtmlRenderingInfo();
460 ~wxHtmlRenderingInfo();
462 void SetSelection(wxHtmlSelection *s);
463 wxHtmlSelection *GetSelection() const;
465 void SetStyle(wxHtmlRenderingStyle *style);
466 wxHtmlRenderingStyle& GetStyle();
468 wxHtmlRenderingState& GetState();
471 //---------------------------------------------------------------------------
477 wxHTML_FIND_EXACT = 1,
478 wxHTML_FIND_NEAREST_BEFORE = 2,
479 wxHTML_FIND_NEAREST_AFTER = 4
483 class wxHtmlCell : public wxObject {
492 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
493 wxHtmlCell* GetNext();
494 wxHtmlContainerCell* GetParent();
495 wxHtmlCell* GetFirstChild() const;
497 // Returns cursor to be used when mouse is over the cell:
498 wxCursor GetCursor() const;
500 // Formatting cells are not visible on the screen, they only alter
502 bool IsFormattingCell() const;
505 void SetLink(const wxHtmlLinkInfo& link);
506 void SetNext(wxHtmlCell *cell);
507 void SetParent(wxHtmlContainerCell *p);
508 void SetPos(int x, int y);
510 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
511 wxHtmlRenderingInfo& info);
512 void DrawInvisible(wxDC& dc, int x, int y,
513 wxHtmlRenderingInfo& info);
514 const wxHtmlCell* Find(int condition, const void* param);
516 bool AdjustPagebreak(int* INOUT);
517 void SetCanLiveOnPagebreak(bool can);
519 // Can the line be broken before this cell?
520 bool IsLinebreakAllowed() const;
522 // Returns True for simple == terminal cells, i.e. not composite ones.
523 // This if for internal usage only and may disappear in future versions!
524 bool IsTerminalCell() const;
526 // Find a cell inside this cell positioned at the given coordinates
527 // (relative to this's positions). Returns NULL if no such cell exists.
528 // The flag can be used to specify whether to look for terminal or
529 // nonterminal cells or both. In either case, returned cell is deepest
530 // cell in cells tree that contains [x,y].
531 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
532 unsigned flags = wxHTML_FIND_EXACT) const;
534 // Returns absolute position of the cell on HTML canvas
535 wxPoint GetAbsPos() const;
537 // Returns first (last) terminal cell inside this cell. It may return NULL,
538 // but it is rare -- only if there are no terminals in the tree.
539 wxHtmlCell *GetFirstTerminal() const ;
540 wxHtmlCell *GetLastTerminal() const ;
542 // Returns cell's depth, i.e. how far under the root cell it is
543 // (if it is the root, depth is 0)
544 unsigned GetDepth() const;
546 // Returns True if the cell appears before 'cell' in natural order of
547 // cells (= as they are read). If cell A is (grand)parent of cell B,
548 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
549 bool IsBefore(wxHtmlCell *cell) const;
551 // Converts the cell into text representation. If sel != NULL then
552 // only part of the cell inside the selection is converted.
553 wxString ConvertToText(wxHtmlSelection *sel) const;
557 class wxHtmlWordCell : public wxHtmlCell
560 wxHtmlWordCell(const wxString& word, wxDC& dc);
564 class wxHtmlContainerCell : public wxHtmlCell {
566 wxHtmlContainerCell(wxHtmlContainerCell *parent);
568 void InsertCell(wxHtmlCell *cell);
569 void SetAlignHor(int al);
571 void SetAlignVer(int al);
573 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
574 int GetIndent(int ind);
575 int GetIndentUnits(int ind);
576 void SetAlign(const wxHtmlTag& tag);
577 void SetWidthFloat(int w, int units);
578 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
579 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
580 void SetBackgroundColour(const wxColour& clr);
581 wxColour GetBackgroundColour();
582 void SetBorder(const wxColour& clr1, const wxColour& clr2);
583 wxHtmlCell* GetFirstChild();
584 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
589 class wxHtmlColourCell : public wxHtmlCell {
591 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
596 class wxHtmlFontCell : public wxHtmlCell
599 wxHtmlFontCell(wxFont *font);
603 class wxHtmlWidgetCell : public wxHtmlCell {
605 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
612 //---------------------------------------------------------------------------
614 //---------------------------------------------------------------------------
618 %{ // here's the C++ version
619 class wxPyHtmlFilter : public wxHtmlFilter {
620 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
622 wxPyHtmlFilter() : wxHtmlFilter() {}
624 // returns True if this filter is able to open&read given file
625 virtual bool CanRead(const wxFSFile& file) const {
628 wxPyBeginBlockThreads();
629 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
630 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
631 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
634 wxPyEndBlockThreads();
639 // Reads given file and returns HTML document.
640 // Returns empty string if opening failed
641 virtual wxString ReadFile(const wxFSFile& file) const {
644 wxPyBeginBlockThreads();
645 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
646 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
648 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
651 rval = Py2wxString(ro);
655 wxPyEndBlockThreads();
662 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
666 // And now the version seen by SWIG
668 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
670 %addtofunc wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
673 void _setCallbackInfo(PyObject* self, PyObject* _class);
677 // TODO: wxHtmlFilterHTML
680 //---------------------------------------------------------------------------
682 //---------------------------------------------------------------------------
686 class wxPyHtmlWindow : public wxHtmlWindow {
687 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
689 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
690 const wxPoint& pos = wxDefaultPosition,
691 const wxSize& size = wxDefaultSize,
692 long style = wxHW_DEFAULT_STYLE,
693 const wxString& name = wxPyHtmlWindowNameStr)
694 : wxHtmlWindow(parent, id, pos, size, style, name) {};
695 wxPyHtmlWindow() : wxHtmlWindow() {};
697 bool ScrollToAnchor(const wxString& anchor) {
698 return wxHtmlWindow::ScrollToAnchor(anchor);
701 bool HasAnchor(const wxString& anchor) {
702 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
706 void OnLinkClicked(const wxHtmlLinkInfo& link);
707 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
709 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
711 wxString *redirect) const;
713 DEC_PYCALLBACK__STRING(OnSetTitle);
714 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
715 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
719 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
720 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
721 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
722 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
725 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
727 wxPyBeginBlockThreads();
728 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
729 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
730 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
733 wxPyEndBlockThreads();
735 wxHtmlWindow::OnLinkClicked(link);
737 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
738 wxHtmlWindow::OnLinkClicked(link);
742 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
744 wxString *redirect) const {
746 wxHtmlOpeningStatus rval;
747 wxPyBeginBlockThreads();
748 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
750 PyObject* s = wx2PyString(url);
751 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
753 if (PyString_Check(ro)
754 #if PYTHON_API_VERSION >= 1009
755 || PyUnicode_Check(ro)
758 *redirect = Py2wxString(ro);
759 rval = wxHTML_REDIRECT;
762 PyObject* num = PyNumber_Int(ro);
763 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
768 wxPyEndBlockThreads();
770 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
779 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
781 %addtofunc wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
782 %addtofunc wxPyHtmlWindow() ""
784 wxPyHtmlWindow(wxWindow *parent, int id = -1,
785 const wxPoint& pos = wxDefaultPosition,
786 const wxSize& size = wxDefaultSize,
787 int style=wxHW_DEFAULT_STYLE,
788 const wxString& name = wxPyHtmlWindowNameStr);
789 %name(PreHtmlWindow)wxPyHtmlWindow();
791 bool Create(wxWindow *parent, int id = -1,
792 const wxPoint& pos = wxDefaultPosition,
793 const wxSize& size = wxDefaultSize,
794 int style=wxHW_SCROLLBAR_AUTO,
795 const wxString& name = wxPyHtmlWindowNameStr);
798 void _setCallbackInfo(PyObject* self, PyObject* _class);
801 // Set HTML page and display it. !! source is HTML document itself,
802 // it is NOT address/filename of HTML document. If you want to
803 // specify document location, use LoadPage() istead
804 // Return value : False if an error occured, True otherwise
805 bool SetPage(const wxString& source);
807 // Load HTML page from given location. Location can be either
808 // a) /usr/wxGTK2/docs/html/wx.htm
809 // b) http://www.somewhere.uk/document.htm
810 // c) ftp://ftp.somesite.cz/pub/something.htm
811 // In case there is no prefix (http:,ftp:), the method
812 // will try to find it itself (1. local file, then http or ftp)
813 // After the page is loaded, the method calls SetPage() to display it.
814 // Note : you can also use path relative to previously loaded page
815 // Return value : same as SetPage
816 bool LoadPage(const wxString& location);
818 // Loads HTML page from file
819 bool LoadFile(const wxString& filename);
821 // Append to current page
822 bool AppendToPage(const wxString& source);
824 // Returns full location of opened page
825 wxString GetOpenedPage();
827 // Returns anchor within opened page
828 wxString GetOpenedAnchor();
830 // Returns <TITLE> of opened page or empty string otherwise
831 wxString GetOpenedPageTitle();
833 // Sets frame in which page title will be displayed. Format is format of
834 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
835 void SetRelatedFrame(wxFrame* frame, const wxString& format);
836 wxFrame* GetRelatedFrame();
838 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
839 // will be displayed. Default is -1 = no messages.
840 void SetRelatedStatusBar(int bar);
842 // Sets fonts to be used when displaying HTML page.
844 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
846 if (sizes) temp = int_LIST_helper(sizes);
847 self->SetFonts(normal_face, fixed_face, temp);
853 void SetTitle(const wxString& title);
855 // Sets space between text and window borders.
856 void SetBorders(int b);
858 // Saves custom settings into cfg config. it will use the path 'path'
859 // if given, otherwise it will save info into currently selected path.
860 // saved values : things set by SetFonts, SetBorders.
861 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
862 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
864 // Goes to previous/next page (in browsing history)
865 // Returns True if successful, False otherwise
867 bool HistoryForward();
868 bool HistoryCanBack();
869 bool HistoryCanForward();
874 // Returns pointer to conteiners/cells structure.
875 wxHtmlContainerCell* GetInternalRepresentation();
877 // Returns a pointer to the parser.
878 wxHtmlWinParser* GetParser();
880 bool ScrollToAnchor(const wxString& anchor);
881 bool HasAnchor(const wxString& anchor);
884 static void AddFilter(wxPyHtmlFilter *filter);
887 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
888 void base_OnSetTitle(const wxString& title);
889 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
890 void base_OnCellClicked(wxHtmlCell *cell,
891 wxCoord x, wxCoord y,
892 const wxMouseEvent& event);
898 //---------------------------------------------------------------------------
899 //---------------------------------------------------------------------------
903 class wxHtmlDCRenderer : public wxObject {
908 void SetDC(wxDC *dc, int maxwidth);
909 void SetSize(int width, int height);
910 void SetHtmlText(const wxString& html,
911 const wxString& basepath = wxPyEmptyString,
913 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
915 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
917 if (sizes) temp = int_LIST_helper(sizes);
918 self->SetFonts(normal_face, fixed_face, temp);
923 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
924 //int *known_pagebreaks = NULL, int number_of_pages = 0
925 int* choices=NULL, int LCOUNT = 0
927 int GetTotalHeight();
928 // returns total height of the html document
929 // (compare Render's return value with this)
940 class wxHtmlPrintout : public wxPyPrintout {
942 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
943 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
945 void SetHtmlText(const wxString& html,
946 const wxString &basepath = wxPyEmptyString,
948 void SetHtmlFile(const wxString &htmlfile);
949 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
950 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
952 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
954 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
956 if (sizes) temp = int_LIST_helper(sizes);
957 self->SetFonts(normal_face, fixed_face, temp);
962 void SetMargins(float top = 25.2, float bottom = 25.2,
963 float left = 25.2, float right = 25.2,
967 static void AddFilter(wxHtmlFilter *filter);
970 static void CleanUpStatics();
975 class wxHtmlEasyPrinting : public wxObject {
977 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
978 wxWindow *parentWindow = NULL);
979 ~wxHtmlEasyPrinting();
981 void PreviewFile(const wxString &htmlfile);
982 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
983 void PrintFile(const wxString &htmlfile);
984 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
987 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
988 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
991 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
993 if (sizes) temp = int_LIST_helper(sizes);
994 self->SetFonts(normal_face, fixed_face, temp);
1000 wxPrintData *GetPrintData() {return m_PrintData;}
1001 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1006 //---------------------------------------------------------------------------
1007 //---------------------------------------------------------------------------
1011 class wxHtmlBookRecord {
1013 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1014 const wxString& title, const wxString& start);
1016 wxString GetBookFile();
1017 wxString GetTitle();
1018 wxString GetStart();
1019 wxString GetBasePath();
1021 void SetContentsRange(int start, int end);
1022 int GetContentsStart();
1023 int GetContentsEnd();
1025 void SetTitle(const wxString& title);
1026 void SetBasePath(const wxString& path);
1027 void SetStart(const wxString& start);
1029 wxString GetFullPath(const wxString &page) const;
1032 //---------------------------------------------------------------------------
1034 struct wxHtmlContentsItem
1037 int GetLevel() { return self->m_Level; }
1038 int GetID() { return self->m_ID; }
1039 wxString GetName() { return self->m_Name; }
1040 wxString GetPage() { return self->m_Page; }
1041 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1045 //---------------------------------------------------------------------------
1047 class wxHtmlSearchStatus
1050 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1051 // const wxString& book = wxPyEmptyString);
1056 const wxString& GetName();
1057 wxHtmlContentsItem* GetContentsItem();
1060 //---------------------------------------------------------------------------
1062 class wxHtmlHelpData {
1067 void SetTempDir(const wxString& path);
1068 bool AddBook(const wxString& book);
1069 // bool AddBookParam(const wxString& title, const wxString& contfile,
1070 // const wxString& indexfile=wxPyEmptyString,
1071 // const wxString& deftopic=wxPyEmptyString,
1072 // const wxString& path=wxPyEmptyString);
1074 wxString FindPageByName(const wxString& page);
1075 wxString FindPageById(int id);
1077 // TODO: this one needs fixed...
1078 const wxHtmlBookRecArray& GetBookRecArray();
1080 wxHtmlContentsItem* GetContents();
1081 int GetContentsCnt();
1082 wxHtmlContentsItem* GetIndex();
1086 //---------------------------------------------------------------------------
1088 class wxHtmlHelpFrame : public wxFrame {
1090 %addtofunc wxHtmlHelpFrame "self._setOORInfo(self)"
1092 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1093 const wxString& title = wxPyEmptyString,
1094 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1096 wxHtmlHelpData* GetData();
1097 void SetTitleFormat(const wxString& format);
1098 void Display(const wxString& x);
1099 %name(DisplayID) void Display(int id);
1100 void DisplayContents();
1101 void DisplayIndex();
1102 bool KeywordSearch(const wxString& keyword);
1103 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1104 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1105 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1109 //---------------------------------------------------------------------------
1125 class wxHtmlHelpController : public wxEvtHandler {
1127 %addtofunc wxHtmlHelpController "self._setOORInfo(self)"
1129 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1130 ~wxHtmlHelpController();
1132 void SetTitleFormat(const wxString& format);
1133 void SetTempDir(const wxString& path);
1134 bool AddBook(const wxString& book, int show_wait_msg = False);
1135 void Display(const wxString& x);
1136 %name(DisplayID) void Display(int id);
1137 void DisplayContents();
1138 void DisplayIndex();
1139 bool KeywordSearch(const wxString& keyword);
1140 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1141 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1142 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1143 wxHtmlHelpFrame* GetFrame();
1149 //---------------------------------------------------------------------------
1151 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1152 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1153 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1154 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1156 //---------------------------------------------------------------------------
1157 //---------------------------------------------------------------------------