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 }
33 %pythoncode { __docfilter__ = wx.__docfilter__ }
35 %include _html_rename.i
38 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
39 MAKE_CONST_WXSTRING2(HtmlWindowNameStr, wxT("htmlWindow"))
40 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout"))
41 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("Printing"))
44 // TODO: Split this file into multiple %included files that coresponds to the
45 // wx/html include files (more or less.)
47 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
59 wxHTML_CLR_FOREGROUND,
60 wxHTML_CLR_BACKGROUND,
70 wxHTML_INDENT_HORIZONTAL,
71 wxHTML_INDENT_VERTICAL,
75 wxHTML_COND_ISIMAGEMAP,
97 // enums for wxHtmlWindow::OnOpeningURL
98 enum wxHtmlOpeningStatus
114 //---------------------------------------------------------------------------
116 class wxHtmlLinkInfo : public wxObject {
118 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
120 wxString GetTarget();
121 wxMouseEvent* GetEvent();
122 wxHtmlCell* GetHtmlCell();
124 void SetEvent(const wxMouseEvent *e);
125 void SetHtmlCell(const wxHtmlCell * e);
128 //---------------------------------------------------------------------------
130 class wxHtmlTag : public wxObject {
132 // Never need to create a new tag from Python...
133 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
136 bool HasParam(const wxString& par);
137 wxString GetParam(const wxString& par, int with_commas = False);
139 // Can't do this one as-is, but GetParam should be enough...
140 //int ScanParam(const wxString& par, const char *format, void* param);
142 wxString GetAllParams();
149 //---------------------------------------------------------------------------
151 class wxHtmlParser : public wxObject {
153 // wxHtmlParser(); This is an abstract base class...
155 void SetFS(wxFileSystem *fs);
156 wxFileSystem* GetFS();
157 wxObject* Parse(const wxString& source);
158 void InitParser(const wxString& source);
160 void DoParsing(int begin_pos, int end_pos);
162 // wxObject* GetProduct();
164 void AddTagHandler(wxHtmlTagHandler *handler);
165 wxString* GetSource();
166 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
167 void PopTagHandler();
169 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
171 // void AddText(const char* txt) = 0;
172 // void AddTag(const wxHtmlTag& tag);
176 //---------------------------------------------------------------------------
178 class wxHtmlWinParser : public wxHtmlParser {
180 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
182 void SetDC(wxDC *dc);
186 wxPyHtmlWindow* GetWindow();
188 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
190 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
192 if (sizes) temp = int_LIST_helper(sizes);
193 self->SetFonts(normal_face, fixed_face, temp);
199 wxHtmlContainerCell* GetContainer();
200 wxHtmlContainerCell* OpenContainer();
201 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
202 wxHtmlContainerCell* CloseContainer();
205 void SetFontSize(int s);
207 void SetFontBold(int x);
209 void SetFontItalic(int x);
210 int GetFontUnderlined();
211 void SetFontUnderlined(int x);
213 void SetFontFixed(int x);
215 void SetAlign(int a);
216 wxColour GetLinkColor();
217 void SetLinkColor(const wxColour& clr);
218 wxColour GetActualColor();
219 void SetActualColor(const wxColour& clr);
220 void SetLink(const wxString& link);
221 wxFont* CreateCurrentFont();
222 wxHtmlLinkInfo GetLink();
227 //---------------------------------------------------------------------------
230 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
231 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
233 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
235 wxHtmlParser* GetParser() { return m_Parser; }
236 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
238 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
239 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
244 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
246 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
247 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
251 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
253 %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
254 wxPyHtmlTagHandler();
256 void _setCallbackInfo(PyObject* self, PyObject* _class);
258 void SetParser(wxHtmlParser *parser);
259 wxHtmlParser* GetParser();
260 void ParseInner(const wxHtmlTag& tag);
264 //---------------------------------------------------------------------------
267 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
268 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
270 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
272 wxHtmlWinParser* GetParser() { return m_WParser; }
273 void ParseInner(const wxHtmlTag& tag)
274 { wxHtmlWinTagHandler::ParseInner(tag); }
276 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
277 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
282 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
284 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
285 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
289 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
291 %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
292 wxPyHtmlWinTagHandler();
294 void _setCallbackInfo(PyObject* self, PyObject* _class);
296 void SetParser(wxHtmlParser *parser);
297 wxHtmlWinParser* GetParser();
298 void ParseInner(const wxHtmlTag& tag);
302 //---------------------------------------------------------------------------
306 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
308 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
309 m_tagHandlerClass = thc;
310 Py_INCREF(m_tagHandlerClass);
311 RegisterModule(this);
312 wxHtmlWinParser::AddModule(this);
316 bool blocked = wxPyBeginBlockThreads();
317 Py_DECREF(m_tagHandlerClass);
318 m_tagHandlerClass = NULL;
319 for (size_t x=0; x < m_objArray.GetCount(); x++) {
320 PyObject* obj = (PyObject*)m_objArray.Item(x);
323 wxPyEndBlockThreads(blocked);
326 void FillHandlersTable(wxHtmlWinParser *parser) {
327 // Wave our magic wand... (if it works it's a miracle! ;-)
329 // First, make a new instance of the tag handler
330 bool blocked = wxPyBeginBlockThreads();
331 PyObject* arg = PyTuple_New(0);
332 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
335 // now figure out where it's C++ object is...
336 wxPyHtmlWinTagHandler* thPtr;
337 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
338 wxPyEndBlockThreads(blocked);
341 wxPyEndBlockThreads(blocked);
344 parser->AddTagHandler(thPtr);
351 PyObject* m_tagHandlerClass;
352 wxArrayPtrVoid m_objArray;
360 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
361 // Dynamically create a new wxModule. Refcounts tagHandlerClass
362 // and adds itself to the wxModules list and to the wxHtmlWinParser.
363 new wxPyHtmlTagsModule(tagHandlerClass);
368 //---------------------------------------------------------------------------
369 //---------------------------------------------------------------------------
373 // wxHtmlSelection is data holder with information about text selection.
374 // Selection is defined by two positions (beginning and end of the selection)
375 // and two leaf(!) cells at these positions.
376 class wxHtmlSelection
382 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
383 const wxPoint& toPos, const wxHtmlCell *toCell);
384 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
386 const wxHtmlCell *GetFromCell() const;
387 const wxHtmlCell *GetToCell() const;
389 // these values are in absolute coordinates:
390 const wxPoint& GetFromPos() const;
391 const wxPoint& GetToPos() const;
393 // these are From/ToCell's private data
394 const wxPoint& GetFromPrivPos() const;
395 const wxPoint& GetToPrivPos() const;
396 void SetFromPrivPos(const wxPoint& pos);
397 void SetToPrivPos(const wxPoint& pos);
400 const bool IsEmpty() const;
405 enum wxHtmlSelectionState
407 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
408 wxHTML_SEL_IN, // ... is inside selection
409 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
414 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
415 // differently e.g. when inside text selection or outside it.
416 class wxHtmlRenderingState
419 wxHtmlRenderingState();
420 ~wxHtmlRenderingState();
422 void SetSelectionState(wxHtmlSelectionState s);
423 wxHtmlSelectionState GetSelectionState() const;
425 void SetFgColour(const wxColour& c);
426 const wxColour& GetFgColour() const;
427 void SetBgColour(const wxColour& c);
428 const wxColour& GetBgColour() const;
433 // HTML rendering customization. This class is used when rendering wxHtmlCells
435 class wxHtmlRenderingStyle
438 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
439 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
443 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
446 virtual wxColour GetSelectedTextColour(const wxColour& clr);
447 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
452 // Information given to cells when drawing them. Contains rendering state,
453 // selection information and rendering style object that can be used to
454 // customize the output.
455 class wxHtmlRenderingInfo
458 wxHtmlRenderingInfo();
459 ~wxHtmlRenderingInfo();
461 void SetSelection(wxHtmlSelection *s);
462 wxHtmlSelection *GetSelection() const;
464 void SetStyle(wxHtmlRenderingStyle *style);
465 wxHtmlRenderingStyle& GetStyle();
467 wxHtmlRenderingState& GetState();
470 //---------------------------------------------------------------------------
476 wxHTML_FIND_EXACT = 1,
477 wxHTML_FIND_NEAREST_BEFORE = 2,
478 wxHTML_FIND_NEAREST_AFTER = 4
482 class wxHtmlCell : public wxObject {
492 // Returns the maximum possible length of the cell.
493 // Call Layout at least once before using GetMaxTotalWidth()
494 int GetMaxTotalWidth() const;
496 const wxString& GetId() const;
497 void SetId(const wxString& id);
498 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
499 wxHtmlCell* GetNext();
500 wxHtmlContainerCell* GetParent();
501 wxHtmlCell* GetFirstChild() const;
503 // Returns cursor to be used when mouse is over the cell:
504 wxCursor GetCursor() const;
506 // Formatting cells are not visible on the screen, they only alter
508 bool IsFormattingCell() const;
511 void SetLink(const wxHtmlLinkInfo& link);
512 void SetNext(wxHtmlCell *cell);
513 void SetParent(wxHtmlContainerCell *p);
514 void SetPos(int x, int y);
516 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
517 wxHtmlRenderingInfo& info);
518 void DrawInvisible(wxDC& dc, int x, int y,
519 wxHtmlRenderingInfo& info);
520 const wxHtmlCell* Find(int condition, const void* param);
522 bool AdjustPagebreak(int* INOUT);
523 void SetCanLiveOnPagebreak(bool can);
525 // Can the line be broken before this cell?
526 bool IsLinebreakAllowed() const;
528 // Returns True for simple == terminal cells, i.e. not composite ones.
529 // This if for internal usage only and may disappear in future versions!
530 bool IsTerminalCell() const;
532 // Find a cell inside this cell positioned at the given coordinates
533 // (relative to this's positions). Returns NULL if no such cell exists.
534 // The flag can be used to specify whether to look for terminal or
535 // nonterminal cells or both. In either case, returned cell is deepest
536 // cell in cells tree that contains [x,y].
537 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
538 unsigned flags = wxHTML_FIND_EXACT) const;
540 // Returns absolute position of the cell on HTML canvas
541 wxPoint GetAbsPos() const;
543 // Returns first (last) terminal cell inside this cell. It may return NULL,
544 // but it is rare -- only if there are no terminals in the tree.
545 wxHtmlCell *GetFirstTerminal() const ;
546 wxHtmlCell *GetLastTerminal() const ;
548 // Returns cell's depth, i.e. how far under the root cell it is
549 // (if it is the root, depth is 0)
550 unsigned GetDepth() const;
552 // Returns True if the cell appears before 'cell' in natural order of
553 // cells (= as they are read). If cell A is (grand)parent of cell B,
554 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
555 bool IsBefore(wxHtmlCell *cell) const;
557 // Converts the cell into text representation. If sel != NULL then
558 // only part of the cell inside the selection is converted.
559 wxString ConvertToText(wxHtmlSelection *sel) const;
563 class wxHtmlWordCell : public wxHtmlCell
566 wxHtmlWordCell(const wxString& word, wxDC& dc);
570 class wxHtmlContainerCell : public wxHtmlCell {
572 wxHtmlContainerCell(wxHtmlContainerCell *parent);
574 void InsertCell(wxHtmlCell *cell);
575 void SetAlignHor(int al);
577 void SetAlignVer(int al);
579 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
580 int GetIndent(int ind);
581 int GetIndentUnits(int ind);
582 void SetAlign(const wxHtmlTag& tag);
583 void SetWidthFloat(int w, int units);
584 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
585 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
586 void SetBackgroundColour(const wxColour& clr);
587 wxColour GetBackgroundColour();
588 void SetBorder(const wxColour& clr1, const wxColour& clr2);
589 wxHtmlCell* GetFirstChild();
590 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
595 class wxHtmlColourCell : public wxHtmlCell {
597 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
602 class wxHtmlFontCell : public wxHtmlCell
605 wxHtmlFontCell(wxFont *font);
609 class wxHtmlWidgetCell : public wxHtmlCell {
611 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
618 //---------------------------------------------------------------------------
620 //---------------------------------------------------------------------------
624 %{ // here's the C++ version
625 class wxPyHtmlFilter : public wxHtmlFilter {
626 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
628 wxPyHtmlFilter() : wxHtmlFilter() {}
630 // returns True if this filter is able to open&read given file
631 virtual bool CanRead(const wxFSFile& file) const {
634 bool blocked = wxPyBeginBlockThreads();
635 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
636 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
637 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
640 wxPyEndBlockThreads(blocked);
645 // Reads given file and returns HTML document.
646 // Returns empty string if opening failed
647 virtual wxString ReadFile(const wxFSFile& file) const {
650 bool blocked = wxPyBeginBlockThreads();
651 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
652 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
654 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
657 rval = Py2wxString(ro);
661 wxPyEndBlockThreads(blocked);
668 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
672 // And now the version seen by SWIG
674 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
676 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
679 void _setCallbackInfo(PyObject* self, PyObject* _class);
683 // TODO: wxHtmlFilterHTML
686 //---------------------------------------------------------------------------
688 //---------------------------------------------------------------------------
692 class wxPyHtmlWindow : public wxHtmlWindow {
693 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
695 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
696 const wxPoint& pos = wxDefaultPosition,
697 const wxSize& size = wxDefaultSize,
698 long style = wxHW_DEFAULT_STYLE,
699 const wxString& name = wxPyHtmlWindowNameStr)
700 : wxHtmlWindow(parent, id, pos, size, style, name) {};
701 wxPyHtmlWindow() : wxHtmlWindow() {};
703 bool ScrollToAnchor(const wxString& anchor) {
704 return wxHtmlWindow::ScrollToAnchor(anchor);
707 bool HasAnchor(const wxString& anchor) {
708 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
712 void OnLinkClicked(const wxHtmlLinkInfo& link);
713 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
715 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
717 wxString *redirect) const;
719 DEC_PYCALLBACK__STRING(OnSetTitle);
720 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
721 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
725 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
726 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
727 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
728 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
731 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
733 bool blocked = wxPyBeginBlockThreads();
734 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
735 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
736 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
739 wxPyEndBlockThreads(blocked);
741 wxHtmlWindow::OnLinkClicked(link);
743 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
744 wxHtmlWindow::OnLinkClicked(link);
748 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
750 wxString *redirect) const {
752 wxHtmlOpeningStatus rval;
753 bool blocked = wxPyBeginBlockThreads();
754 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
756 PyObject* s = wx2PyString(url);
757 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
759 if (PyString_Check(ro)
760 #if PYTHON_API_VERSION >= 1009
761 || PyUnicode_Check(ro)
764 *redirect = Py2wxString(ro);
765 rval = wxHTML_REDIRECT;
768 PyObject* num = PyNumber_Int(ro);
769 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
774 wxPyEndBlockThreads(blocked);
776 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
785 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
787 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
788 %pythonAppend wxPyHtmlWindow() ""
790 wxPyHtmlWindow(wxWindow *parent, int id = -1,
791 const wxPoint& pos = wxDefaultPosition,
792 const wxSize& size = wxDefaultSize,
793 int style=wxHW_DEFAULT_STYLE,
794 const wxString& name = wxPyHtmlWindowNameStr);
795 %name(PreHtmlWindow)wxPyHtmlWindow();
797 bool Create(wxWindow *parent, int id = -1,
798 const wxPoint& pos = wxDefaultPosition,
799 const wxSize& size = wxDefaultSize,
800 int style=wxHW_SCROLLBAR_AUTO,
801 const wxString& name = wxPyHtmlWindowNameStr);
804 void _setCallbackInfo(PyObject* self, PyObject* _class);
807 // Set HTML page and display it. !! source is HTML document itself,
808 // it is NOT address/filename of HTML document. If you want to
809 // specify document location, use LoadPage() istead
810 // Return value : False if an error occured, True otherwise
811 bool SetPage(const wxString& source);
813 // Load HTML page from given location. Location can be either
814 // a) /usr/wxGTK2/docs/html/wx.htm
815 // b) http://www.somewhere.uk/document.htm
816 // c) ftp://ftp.somesite.cz/pub/something.htm
817 // In case there is no prefix (http:,ftp:), the method
818 // will try to find it itself (1. local file, then http or ftp)
819 // After the page is loaded, the method calls SetPage() to display it.
820 // Note : you can also use path relative to previously loaded page
821 // Return value : same as SetPage
822 bool LoadPage(const wxString& location);
824 // Loads HTML page from file
825 bool LoadFile(const wxString& filename);
827 // Append to current page
828 bool AppendToPage(const wxString& source);
830 // Returns full location of opened page
831 wxString GetOpenedPage();
833 // Returns anchor within opened page
834 wxString GetOpenedAnchor();
836 // Returns <TITLE> of opened page or empty string otherwise
837 wxString GetOpenedPageTitle();
839 // Sets frame in which page title will be displayed. Format is format of
840 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
841 void SetRelatedFrame(wxFrame* frame, const wxString& format);
842 wxFrame* GetRelatedFrame();
844 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
845 // will be displayed. Default is -1 = no messages.
846 void SetRelatedStatusBar(int bar);
848 // Sets fonts to be used when displaying HTML page.
850 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
852 if (sizes) temp = int_LIST_helper(sizes);
853 self->SetFonts(normal_face, fixed_face, temp);
860 void, SetTitle(const wxString& title),
863 // Sets space between text and window borders.
864 void SetBorders(int b);
866 // Saves custom settings into cfg config. it will use the path 'path'
867 // if given, otherwise it will save info into currently selected path.
868 // saved values : things set by SetFonts, SetBorders.
869 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
870 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
872 // Goes to previous/next page (in browsing history)
873 // Returns True if successful, False otherwise
875 bool HistoryForward();
876 bool HistoryCanBack();
877 bool HistoryCanForward();
882 // Returns pointer to conteiners/cells structure.
883 wxHtmlContainerCell* GetInternalRepresentation();
885 // Returns a pointer to the parser.
886 wxHtmlWinParser* GetParser();
888 bool ScrollToAnchor(const wxString& anchor);
889 bool HasAnchor(const wxString& anchor);
892 static void AddFilter(wxPyHtmlFilter *filter);
894 // Helper functions to select parts of page:
895 void SelectWord(const wxPoint& pos);
896 void SelectLine(const wxPoint& pos);
900 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
901 void base_OnSetTitle(const wxString& title);
902 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
903 void base_OnCellClicked(wxHtmlCell *cell,
904 wxCoord x, wxCoord y,
905 const wxMouseEvent& event);
911 //---------------------------------------------------------------------------
912 //---------------------------------------------------------------------------
916 class wxHtmlDCRenderer : public wxObject {
921 void SetDC(wxDC *dc, int maxwidth);
922 void SetSize(int width, int height);
923 void SetHtmlText(const wxString& html,
924 const wxString& basepath = wxPyEmptyString,
926 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
928 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
930 if (sizes) temp = int_LIST_helper(sizes);
931 self->SetFonts(normal_face, fixed_face, temp);
936 int Render(int x, int y, int from = 0, int dont_render = False, int to = INT_MAX,
937 //int *known_pagebreaks = NULL, int number_of_pages = 0
938 int* choices=NULL, int LCOUNT = 0
940 int GetTotalHeight();
941 // returns total height of the html document
942 // (compare Render's return value with this)
953 class wxHtmlPrintout : public wxPyPrintout {
955 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
956 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
958 void SetHtmlText(const wxString& html,
959 const wxString &basepath = wxPyEmptyString,
961 void SetHtmlFile(const wxString &htmlfile);
962 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
963 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
965 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
967 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
969 if (sizes) temp = int_LIST_helper(sizes);
970 self->SetFonts(normal_face, fixed_face, temp);
975 void SetMargins(float top = 25.2, float bottom = 25.2,
976 float left = 25.2, float right = 25.2,
980 static void AddFilter(wxHtmlFilter *filter);
983 static void CleanUpStatics();
988 class wxHtmlEasyPrinting : public wxObject {
990 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
991 wxWindow *parentWindow = NULL);
992 ~wxHtmlEasyPrinting();
994 void PreviewFile(const wxString &htmlfile);
995 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
996 void PrintFile(const wxString &htmlfile);
997 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1000 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1001 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1004 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1006 if (sizes) temp = int_LIST_helper(sizes);
1007 self->SetFonts(normal_face, fixed_face, temp);
1013 wxPrintData *GetPrintData() {return m_PrintData;}
1014 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1019 //---------------------------------------------------------------------------
1020 //---------------------------------------------------------------------------
1024 class wxHtmlBookRecord {
1026 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1027 const wxString& title, const wxString& start);
1029 wxString GetBookFile();
1030 wxString GetTitle();
1031 wxString GetStart();
1032 wxString GetBasePath();
1034 void SetContentsRange(int start, int end);
1035 int GetContentsStart();
1036 int GetContentsEnd();
1038 void SetTitle(const wxString& title);
1039 void SetBasePath(const wxString& path);
1040 void SetStart(const wxString& start);
1042 wxString GetFullPath(const wxString &page) const;
1045 //---------------------------------------------------------------------------
1047 struct wxHtmlContentsItem
1050 int GetLevel() { return self->m_Level; }
1051 int GetID() { return self->m_ID; }
1052 wxString GetName() { return self->m_Name; }
1053 wxString GetPage() { return self->m_Page; }
1054 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1058 //---------------------------------------------------------------------------
1060 class wxHtmlSearchStatus
1063 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1064 // const wxString& book = wxPyEmptyString);
1069 const wxString& GetName();
1070 wxHtmlContentsItem* GetContentsItem();
1073 //---------------------------------------------------------------------------
1075 class wxHtmlHelpData {
1080 void SetTempDir(const wxString& path);
1081 bool AddBook(const wxString& book);
1082 // bool AddBookParam(const wxString& title, const wxString& contfile,
1083 // const wxString& indexfile=wxPyEmptyString,
1084 // const wxString& deftopic=wxPyEmptyString,
1085 // const wxString& path=wxPyEmptyString);
1087 wxString FindPageByName(const wxString& page);
1088 wxString FindPageById(int id);
1090 // TODO: this one needs fixed...
1091 const wxHtmlBookRecArray& GetBookRecArray();
1093 wxHtmlContentsItem* GetContents();
1094 int GetContentsCnt();
1095 wxHtmlContentsItem* GetIndex();
1099 //---------------------------------------------------------------------------
1101 class wxHtmlHelpFrame : public wxFrame {
1103 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1105 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1106 const wxString& title = wxPyEmptyString,
1107 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1109 wxHtmlHelpData* GetData();
1110 void SetTitleFormat(const wxString& format);
1111 void Display(const wxString& x);
1112 %name(DisplayID) void Display(int id);
1113 void DisplayContents();
1114 void DisplayIndex();
1115 bool KeywordSearch(const wxString& keyword);
1116 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1117 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1118 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1122 //---------------------------------------------------------------------------
1138 class wxHtmlHelpController : public wxEvtHandler {
1140 %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1142 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1143 ~wxHtmlHelpController();
1145 void SetTitleFormat(const wxString& format);
1146 void SetTempDir(const wxString& path);
1147 bool AddBook(const wxString& book, int show_wait_msg = False);
1148 void Display(const wxString& x);
1149 %name(DisplayID) void Display(int id);
1150 void DisplayContents();
1151 void DisplayIndex();
1152 bool KeywordSearch(const wxString& keyword);
1153 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1154 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1155 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1156 wxHtmlHelpFrame* GetFrame();
1162 //---------------------------------------------------------------------------
1164 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1165 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1166 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1167 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1169 //---------------------------------------------------------------------------
1170 //---------------------------------------------------------------------------