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,
89 // enums for wxHtmlWindow::OnOpeningURL
90 enum wxHtmlOpeningStatus
106 //---------------------------------------------------------------------------
108 class wxHtmlLinkInfo : public wxObject {
110 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
112 wxString GetTarget();
113 wxMouseEvent* GetEvent();
114 wxHtmlCell* GetHtmlCell();
116 void SetEvent(const wxMouseEvent *e);
117 void SetHtmlCell(const wxHtmlCell * e);
120 //---------------------------------------------------------------------------
122 class wxHtmlTag : public wxObject {
124 // Never need to create a new tag from Python...
125 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
128 bool HasParam(const wxString& par);
129 wxString GetParam(const wxString& par, int with_commas = False);
131 // Can't do this one as-is, but GetParam should be enough...
132 //int ScanParam(const wxString& par, const char *format, void* param);
134 wxString GetAllParams();
141 //---------------------------------------------------------------------------
143 class wxHtmlParser : public wxObject {
145 // wxHtmlParser(); This is an abstract base class...
147 void SetFS(wxFileSystem *fs);
148 wxFileSystem* GetFS();
149 wxObject* Parse(const wxString& source);
150 void InitParser(const wxString& source);
152 void DoParsing(int begin_pos, int end_pos);
154 // wxObject* GetProduct();
156 void AddTagHandler(wxHtmlTagHandler *handler);
157 wxString* GetSource();
158 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
159 void PopTagHandler();
161 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
163 // void AddText(const char* txt) = 0;
164 // void AddTag(const wxHtmlTag& tag);
168 //---------------------------------------------------------------------------
170 class wxHtmlWinParser : public wxHtmlParser {
172 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
174 void SetDC(wxDC *dc);
178 wxPyHtmlWindow* GetWindow();
180 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
182 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
184 if (sizes) temp = int_LIST_helper(sizes);
185 self->SetFonts(normal_face, fixed_face, temp);
191 wxHtmlContainerCell* GetContainer();
192 wxHtmlContainerCell* OpenContainer();
193 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
194 wxHtmlContainerCell* CloseContainer();
197 void SetFontSize(int s);
199 void SetFontBold(int x);
201 void SetFontItalic(int x);
202 int GetFontUnderlined();
203 void SetFontUnderlined(int x);
205 void SetFontFixed(int x);
207 void SetAlign(int a);
208 wxColour GetLinkColor();
209 void SetLinkColor(const wxColour& clr);
210 wxColour GetActualColor();
211 void SetActualColor(const wxColour& clr);
212 void SetLink(const wxString& link);
213 wxFont* CreateCurrentFont();
214 wxHtmlLinkInfo GetLink();
219 //---------------------------------------------------------------------------
222 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
223 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
225 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
227 wxHtmlParser* GetParser() { return m_Parser; }
228 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
230 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
231 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
236 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
238 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
239 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
243 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
245 %addtofunc wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
246 wxPyHtmlTagHandler();
248 void _setCallbackInfo(PyObject* self, PyObject* _class);
250 void SetParser(wxHtmlParser *parser);
251 wxHtmlParser* GetParser();
252 void ParseInner(const wxHtmlTag& tag);
256 //---------------------------------------------------------------------------
259 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
260 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
262 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
264 wxHtmlWinParser* GetParser() { return m_WParser; }
265 void ParseInner(const wxHtmlTag& tag)
266 { wxHtmlWinTagHandler::ParseInner(tag); }
268 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
269 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
274 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
276 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
277 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
281 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
283 %addtofunc wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
284 wxPyHtmlWinTagHandler();
286 void _setCallbackInfo(PyObject* self, PyObject* _class);
288 void SetParser(wxHtmlParser *parser);
289 wxHtmlWinParser* GetParser();
290 void ParseInner(const wxHtmlTag& tag);
294 //---------------------------------------------------------------------------
298 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
300 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
301 m_tagHandlerClass = thc;
302 Py_INCREF(m_tagHandlerClass);
303 RegisterModule(this);
304 wxHtmlWinParser::AddModule(this);
308 wxPyBeginBlockThreads();
309 Py_DECREF(m_tagHandlerClass);
310 m_tagHandlerClass = NULL;
311 for (size_t x=0; x < m_objArray.GetCount(); x++) {
312 PyObject* obj = (PyObject*)m_objArray.Item(x);
315 wxPyEndBlockThreads();
318 void FillHandlersTable(wxHtmlWinParser *parser) {
319 // Wave our magic wand... (if it works it's a miracle! ;-)
321 // First, make a new instance of the tag handler
322 wxPyBeginBlockThreads();
323 PyObject* arg = Py_BuildValue("()");
324 PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL);
326 wxPyEndBlockThreads();
328 // now figure out where it's C++ object is...
329 wxPyHtmlWinTagHandler* thPtr;
330 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler")))
334 parser->AddTagHandler(thPtr);
341 PyObject* m_tagHandlerClass;
342 wxArrayPtrVoid m_objArray;
350 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
351 // Dynamically create a new wxModule. Refcounts tagHandlerClass
352 // and adds itself to the wxModules list and to the wxHtmlWinParser.
353 new wxPyHtmlTagsModule(tagHandlerClass);
358 //---------------------------------------------------------------------------
359 //---------------------------------------------------------------------------
363 // wxHtmlSelection is data holder with information about text selection.
364 // Selection is defined by two positions (beginning and end of the selection)
365 // and two leaf(!) cells at these positions.
366 class wxHtmlSelection
372 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
373 const wxPoint& toPos, const wxHtmlCell *toCell);
374 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
376 const wxHtmlCell *GetFromCell() const;
377 const wxHtmlCell *GetToCell() const;
379 // these values are in absolute coordinates:
380 const wxPoint& GetFromPos() const;
381 const wxPoint& GetToPos() const;
383 // these are From/ToCell's private data
384 const wxPoint& GetFromPrivPos() const;
385 const wxPoint& GetToPrivPos() const;
386 void SetFromPrivPos(const wxPoint& pos);
387 void SetToPrivPos(const wxPoint& pos);
390 const bool IsEmpty() const;
395 enum wxHtmlSelectionState
397 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
398 wxHTML_SEL_IN, // ... is inside selection
399 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
404 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
405 // differently e.g. when inside text selection or outside it.
406 class wxHtmlRenderingState
409 wxHtmlRenderingState();
410 ~wxHtmlRenderingState();
412 void SetSelectionState(wxHtmlSelectionState s);
413 wxHtmlSelectionState GetSelectionState() const;
415 void SetFgColour(const wxColour& c);
416 const wxColour& GetFgColour() const;
417 void SetBgColour(const wxColour& c);
418 const wxColour& GetBgColour() const;
423 // HTML rendering customization. This class is used when rendering wxHtmlCells
425 class wxHtmlRenderingStyle
428 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
429 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
433 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
436 virtual wxColour GetSelectedTextColour(const wxColour& clr);
437 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
442 // Information given to cells when drawing them. Contains rendering state,
443 // selection information and rendering style object that can be used to
444 // customize the output.
445 class wxHtmlRenderingInfo
448 wxHtmlRenderingInfo();
449 ~wxHtmlRenderingInfo();
451 void SetSelection(wxHtmlSelection *s);
452 wxHtmlSelection *GetSelection() const;
454 void SetStyle(wxHtmlRenderingStyle *style);
455 wxHtmlRenderingStyle& GetStyle();
457 wxHtmlRenderingState& GetState();
460 //---------------------------------------------------------------------------
466 wxHTML_FIND_EXACT = 1,
467 wxHTML_FIND_NEAREST_BEFORE = 2,
468 wxHTML_FIND_NEAREST_AFTER = 4
472 class wxHtmlCell : public wxObject {
481 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
482 wxHtmlCell* GetNext();
483 wxHtmlContainerCell* GetParent();
484 wxHtmlCell* GetFirstChild() const;
486 // Returns cursor to be used when mouse is over the cell:
487 wxCursor GetCursor() const;
489 // Formatting cells are not visible on the screen, they only alter
491 bool IsFormattingCell() const;
494 void SetLink(const wxHtmlLinkInfo& link);
495 void SetNext(wxHtmlCell *cell);
496 void SetParent(wxHtmlContainerCell *p);
497 void SetPos(int x, int y);
499 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
500 wxHtmlRenderingInfo& info);
501 void DrawInvisible(wxDC& dc, int x, int y,
502 wxHtmlRenderingInfo& info);
503 const wxHtmlCell* Find(int condition, const void* param);
505 bool AdjustPagebreak(int* INOUT);
506 void SetCanLiveOnPagebreak(bool can);
508 // Can the line be broken before this cell?
509 bool IsLinebreakAllowed() const;
511 // Returns True for simple == terminal cells, i.e. not composite ones.
512 // This if for internal usage only and may disappear in future versions!
513 bool IsTerminalCell() const;
515 // Find a cell inside this cell positioned at the given coordinates
516 // (relative to this's positions). Returns NULL if no such cell exists.
517 // The flag can be used to specify whether to look for terminal or
518 // nonterminal cells or both. In either case, returned cell is deepest
519 // cell in cells tree that contains [x,y].
520 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
521 unsigned flags = wxHTML_FIND_EXACT) const;
523 // Returns absolute position of the cell on HTML canvas
524 wxPoint GetAbsPos() const;
526 // Returns first (last) terminal cell inside this cell. It may return NULL,
527 // but it is rare -- only if there are no terminals in the tree.
528 wxHtmlCell *GetFirstTerminal() const ;
529 wxHtmlCell *GetLastTerminal() const ;
531 // Returns cell's depth, i.e. how far under the root cell it is
532 // (if it is the root, depth is 0)
533 unsigned GetDepth() const;
535 // Returns True if the cell appears before 'cell' in natural order of
536 // cells (= as they are read). If cell A is (grand)parent of cell B,
537 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
538 bool IsBefore(wxHtmlCell *cell) const;
540 // Converts the cell into text representation. If sel != NULL then
541 // only part of the cell inside the selection is converted.
542 wxString ConvertToText(wxHtmlSelection *sel) const;
546 class wxHtmlWordCell : public wxHtmlCell
549 wxHtmlWordCell(const wxString& word, wxDC& dc);
553 class wxHtmlContainerCell : public wxHtmlCell {
555 wxHtmlContainerCell(wxHtmlContainerCell *parent);
557 void InsertCell(wxHtmlCell *cell);
558 void SetAlignHor(int al);
560 void SetAlignVer(int al);
562 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
563 int GetIndent(int ind);
564 int GetIndentUnits(int ind);
565 void SetAlign(const wxHtmlTag& tag);
566 void SetWidthFloat(int w, int units);
567 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
568 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
569 void SetBackgroundColour(const wxColour& clr);
570 wxColour GetBackgroundColour();
571 void SetBorder(const wxColour& clr1, const wxColour& clr2);
572 wxHtmlCell* GetFirstChild();
573 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
578 class wxHtmlColourCell : public wxHtmlCell {
580 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
585 class wxHtmlFontCell : public wxHtmlCell
588 wxHtmlFontCell(wxFont *font);
592 class wxHtmlWidgetCell : public wxHtmlCell {
594 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
601 //---------------------------------------------------------------------------
603 //---------------------------------------------------------------------------
607 %{ // here's the C++ version
608 class wxPyHtmlFilter : public wxHtmlFilter {
609 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
611 wxPyHtmlFilter() : wxHtmlFilter() {}
613 // returns True if this filter is able to open&read given file
614 virtual bool CanRead(const wxFSFile& file) const {
617 wxPyBeginBlockThreads();
618 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
619 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
620 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
623 wxPyEndBlockThreads();
628 // Reads given file and returns HTML document.
629 // Returns empty string if opening failed
630 virtual wxString ReadFile(const wxFSFile& file) const {
633 wxPyBeginBlockThreads();
634 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
635 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
637 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
640 rval = Py2wxString(ro);
644 wxPyEndBlockThreads();
651 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
655 // And now the version seen by SWIG
657 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
659 %addtofunc wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
662 void _setCallbackInfo(PyObject* self, PyObject* _class);
666 // TODO: wxHtmlFilterHTML
669 //---------------------------------------------------------------------------
671 //---------------------------------------------------------------------------
675 class wxPyHtmlWindow : public wxHtmlWindow {
676 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
678 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
679 const wxPoint& pos = wxDefaultPosition,
680 const wxSize& size = wxDefaultSize,
681 long style = wxHW_DEFAULT_STYLE,
682 const wxString& name = wxPyHtmlWindowNameStr)
683 : wxHtmlWindow(parent, id, pos, size, style, name) {};
684 wxPyHtmlWindow() : wxHtmlWindow() {};
686 bool ScrollToAnchor(const wxString& anchor) {
687 return wxHtmlWindow::ScrollToAnchor(anchor);
690 bool HasAnchor(const wxString& anchor) {
691 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
695 void OnLinkClicked(const wxHtmlLinkInfo& link);
696 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
698 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
700 wxString *redirect) const;
702 DEC_PYCALLBACK__STRING(OnSetTitle);
703 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
704 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
708 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
709 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
710 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
711 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
714 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
716 wxPyBeginBlockThreads();
717 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
718 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
719 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
722 wxPyEndBlockThreads();
724 wxHtmlWindow::OnLinkClicked(link);
726 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
727 wxHtmlWindow::OnLinkClicked(link);
731 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
733 wxString *redirect) const {
735 wxHtmlOpeningStatus rval;
736 wxPyBeginBlockThreads();
737 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
739 PyObject* s = wx2PyString(url);
740 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
742 if (PyString_Check(ro)
743 #if PYTHON_API_VERSION >= 1009
744 || PyUnicode_Check(ro)
747 *redirect = Py2wxString(ro);
748 rval = wxHTML_REDIRECT;
751 PyObject* num = PyNumber_Int(ro);
752 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
757 wxPyEndBlockThreads();
759 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
768 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
770 %addtofunc wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
771 %addtofunc wxPyHtmlWindow() ""
773 wxPyHtmlWindow(wxWindow *parent, int id = -1,
774 const wxPoint& pos = wxDefaultPosition,
775 const wxSize& size = wxDefaultSize,
776 int style=wxHW_DEFAULT_STYLE,
777 const wxString& name = wxPyHtmlWindowNameStr);
778 %name(PreHtmlWindow)wxPyHtmlWindow();
780 bool Create(wxWindow *parent, int id = -1,
781 const wxPoint& pos = wxDefaultPosition,
782 const wxSize& size = wxDefaultSize,
783 int style=wxHW_SCROLLBAR_AUTO,
784 const wxString& name = wxPyHtmlWindowNameStr);
787 void _setCallbackInfo(PyObject* self, PyObject* _class);
790 // Set HTML page and display it. !! source is HTML document itself,
791 // it is NOT address/filename of HTML document. If you want to
792 // specify document location, use LoadPage() istead
793 // Return value : False if an error occured, True otherwise
794 bool SetPage(const wxString& source);
796 // Load HTML page from given location. Location can be either
797 // a) /usr/wxGTK2/docs/html/wx.htm
798 // b) http://www.somewhere.uk/document.htm
799 // c) ftp://ftp.somesite.cz/pub/something.htm
800 // In case there is no prefix (http:,ftp:), the method
801 // will try to find it itself (1. local file, then http or ftp)
802 // After the page is loaded, the method calls SetPage() to display it.
803 // Note : you can also use path relative to previously loaded page
804 // Return value : same as SetPage
805 bool LoadPage(const wxString& location);
807 // Loads HTML page from file
808 bool LoadFile(const wxString& filename);
810 // Append to current page
811 bool AppendToPage(const wxString& source);
813 // Returns full location of opened page
814 wxString GetOpenedPage();
816 // Returns anchor within opened page
817 wxString GetOpenedAnchor();
819 // Returns <TITLE> of opened page or empty string otherwise
820 wxString GetOpenedPageTitle();
822 // Sets frame in which page title will be displayed. Format is format of
823 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
824 void SetRelatedFrame(wxFrame* frame, const wxString& format);
825 wxFrame* GetRelatedFrame();
827 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
828 // will be displayed. Default is -1 = no messages.
829 void SetRelatedStatusBar(int bar);
831 // Sets fonts to be used when displaying HTML page.
833 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
835 if (sizes) temp = int_LIST_helper(sizes);
836 self->SetFonts(normal_face, fixed_face, temp);
842 void SetTitle(const wxString& title);
844 // Sets space between text and window borders.
845 void SetBorders(int b);
847 // Saves custom settings into cfg config. it will use the path 'path'
848 // if given, otherwise it will save info into currently selected path.
849 // saved values : things set by SetFonts, SetBorders.
850 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
851 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
853 // Goes to previous/next page (in browsing history)
854 // Returns True if successful, False otherwise
856 bool HistoryForward();
857 bool HistoryCanBack();
858 bool HistoryCanForward();
863 // Returns pointer to conteiners/cells structure.
864 wxHtmlContainerCell* GetInternalRepresentation();
866 // Returns a pointer to the parser.
867 wxHtmlWinParser* GetParser();
869 bool ScrollToAnchor(const wxString& anchor);
870 bool HasAnchor(const wxString& anchor);
873 static void AddFilter(wxPyHtmlFilter *filter);
876 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
877 void base_OnSetTitle(const wxString& title);
878 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
879 void base_OnCellClicked(wxHtmlCell *cell,
880 wxCoord x, wxCoord y,
881 const wxMouseEvent& event);
887 //---------------------------------------------------------------------------
888 //---------------------------------------------------------------------------
892 class wxHtmlDCRenderer : public wxObject {
897 void SetDC(wxDC *dc, int maxwidth);
898 void SetSize(int width, int height);
899 void SetHtmlText(const wxString& html,
900 const wxString& basepath = wxPyEmptyString,
902 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
904 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
906 if (sizes) temp = int_LIST_helper(sizes);
907 self->SetFonts(normal_face, fixed_face, temp);
912 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
913 //int *known_pagebreaks = NULL, int number_of_pages = 0
914 int* choices=NULL, int LCOUNT = 0
916 int GetTotalHeight();
917 // returns total height of the html document
918 // (compare Render's return value with this)
929 class wxHtmlPrintout : public wxPyPrintout {
931 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
932 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
934 void SetHtmlText(const wxString& html,
935 const wxString &basepath = wxPyEmptyString,
937 void SetHtmlFile(const wxString &htmlfile);
938 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
939 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
941 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
943 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
945 if (sizes) temp = int_LIST_helper(sizes);
946 self->SetFonts(normal_face, fixed_face, temp);
951 void SetMargins(float top = 25.2, float bottom = 25.2,
952 float left = 25.2, float right = 25.2,
956 static void AddFilter(wxHtmlFilter *filter);
959 static void CleanUpStatics();
964 class wxHtmlEasyPrinting : public wxObject {
966 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
967 wxWindow *parentWindow = NULL);
968 ~wxHtmlEasyPrinting();
970 void PreviewFile(const wxString &htmlfile);
971 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
972 void PrintFile(const wxString &htmlfile);
973 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
976 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
977 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
980 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
982 if (sizes) temp = int_LIST_helper(sizes);
983 self->SetFonts(normal_face, fixed_face, temp);
989 wxPrintData *GetPrintData() {return m_PrintData;}
990 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
995 //---------------------------------------------------------------------------
996 //---------------------------------------------------------------------------
1000 class wxHtmlBookRecord {
1002 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1003 const wxString& title, const wxString& start);
1005 wxString GetBookFile();
1006 wxString GetTitle();
1007 wxString GetStart();
1008 wxString GetBasePath();
1010 void SetContentsRange(int start, int end);
1011 int GetContentsStart();
1012 int GetContentsEnd();
1014 void SetTitle(const wxString& title);
1015 void SetBasePath(const wxString& path);
1016 void SetStart(const wxString& start);
1018 wxString GetFullPath(const wxString &page) const;
1021 //---------------------------------------------------------------------------
1023 struct wxHtmlContentsItem
1026 int GetLevel() { return self->m_Level; }
1027 int GetID() { return self->m_ID; }
1028 wxString GetName() { return self->m_Name; }
1029 wxString GetPage() { return self->m_Page; }
1030 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1034 //---------------------------------------------------------------------------
1036 class wxHtmlSearchStatus
1039 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1040 // const wxString& book = wxPyEmptyString);
1045 const wxString& GetName();
1046 wxHtmlContentsItem* GetContentsItem();
1049 //---------------------------------------------------------------------------
1051 class wxHtmlHelpData {
1056 void SetTempDir(const wxString& path);
1057 bool AddBook(const wxString& book);
1058 // bool AddBookParam(const wxString& title, const wxString& contfile,
1059 // const wxString& indexfile=wxPyEmptyString,
1060 // const wxString& deftopic=wxPyEmptyString,
1061 // const wxString& path=wxPyEmptyString);
1063 wxString FindPageByName(const wxString& page);
1064 wxString FindPageById(int id);
1066 // TODO: this one needs fixed...
1067 const wxHtmlBookRecArray& GetBookRecArray();
1069 wxHtmlContentsItem* GetContents();
1070 int GetContentsCnt();
1071 wxHtmlContentsItem* GetIndex();
1075 //---------------------------------------------------------------------------
1077 class wxHtmlHelpFrame : public wxFrame {
1079 %addtofunc wxHtmlHelpFrame "self._setOORInfo(self)"
1081 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1082 const wxString& title = wxPyEmptyString,
1083 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1085 wxHtmlHelpData* GetData();
1086 void SetTitleFormat(const wxString& format);
1087 void Display(const wxString& x);
1088 %name(DisplayID) void Display(int id);
1089 void DisplayContents();
1090 void DisplayIndex();
1091 bool KeywordSearch(const wxString& keyword);
1092 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1093 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1094 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1098 //---------------------------------------------------------------------------
1114 class wxHtmlHelpController : public wxEvtHandler {
1116 %addtofunc wxHtmlHelpController "self._setOORInfo(self)"
1118 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1119 ~wxHtmlHelpController();
1121 void SetTitleFormat(const wxString& format);
1122 void SetTempDir(const wxString& path);
1123 bool AddBook(const wxString& book, int show_wait_msg = False);
1124 void Display(const wxString& x);
1125 %name(DisplayID) void Display(int id);
1126 void DisplayContents();
1127 void DisplayIndex();
1128 bool KeywordSearch(const wxString& keyword);
1129 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1130 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1131 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1132 wxHtmlHelpFrame* GetFrame();
1138 //---------------------------------------------------------------------------
1140 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1141 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1142 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1143 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1145 //---------------------------------------------------------------------------
1146 //---------------------------------------------------------------------------