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 /////////////////////////////////////////////////////////////////////////////
14 "Classes for a simple HTML rendering window, HTML Help Window, etc."
17 %module(package="wx", docstring=DOCSTRING) html
20 #include "wx/wxPython/wxPython.h"
21 #include "wx/wxPython/pyclasses.h"
22 #include "wx/wxPython/pyistream.h"
23 #include "wx/wxPython/printfw.h"
25 #include <wx/html/htmlwin.h>
26 #include <wx/html/htmprint.h>
27 #include <wx/html/helpctrl.h>
32 //---------------------------------------------------------------------------
35 %pythoncode { wx = _core }
36 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
38 %include _html_rename.i
41 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
42 MAKE_CONST_WXSTRING2(HtmlWindowNameStr, wxT("htmlWindow"))
43 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout"))
44 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("Printing"))
47 // TODO: Split this file into multiple %included files that coresponds to the
48 // wx/html include files (more or less.)
50 //---------------------------------------------------------------------------
51 //---------------------------------------------------------------------------
62 wxHTML_CLR_FOREGROUND,
63 wxHTML_CLR_BACKGROUND,
73 wxHTML_INDENT_HORIZONTAL,
74 wxHTML_INDENT_VERTICAL,
78 wxHTML_COND_ISIMAGEMAP,
100 // enums for wxHtmlWindow::OnOpeningURL
101 enum wxHtmlOpeningStatus
117 //---------------------------------------------------------------------------
119 class wxHtmlLinkInfo : public wxObject {
121 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
123 wxString GetTarget();
124 wxMouseEvent* GetEvent();
125 wxHtmlCell* GetHtmlCell();
127 void SetEvent(const wxMouseEvent *e);
128 void SetHtmlCell(const wxHtmlCell * e);
131 //---------------------------------------------------------------------------
133 class wxHtmlTag : public wxObject {
135 // Never need to create a new tag from Python...
136 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
139 bool HasParam(const wxString& par);
140 wxString GetParam(const wxString& par, int with_commas = false);
142 // Can't do this one as-is, but GetParam should be enough...
143 //int ScanParam(const wxString& par, const char *format, void* param);
145 wxString GetAllParams();
152 //---------------------------------------------------------------------------
154 class wxHtmlParser : public wxObject {
156 // wxHtmlParser(); This is an abstract base class...
158 void SetFS(wxFileSystem *fs);
159 wxFileSystem* GetFS();
160 wxObject* Parse(const wxString& source);
161 void InitParser(const wxString& source);
163 void DoParsing(int begin_pos, int end_pos);
165 // wxObject* GetProduct();
167 void AddTagHandler(wxHtmlTagHandler *handler);
168 wxString* GetSource();
169 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
170 void PopTagHandler();
172 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
174 // void AddText(const char* txt) = 0;
175 // void AddTag(const wxHtmlTag& tag);
179 //---------------------------------------------------------------------------
181 class wxHtmlWinParser : public wxHtmlParser {
183 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
185 void SetDC(wxDC *dc);
189 wxPyHtmlWindow* GetWindow();
191 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
193 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
195 if (sizes) temp = int_LIST_helper(sizes);
196 self->SetFonts(normal_face, fixed_face, temp);
202 // Sets font sizes to be relative to the given size or the system
203 // default size; use either specified or default font
204 void SetStandardFonts(int size = -1,
205 const wxString& normal_face = wxPyEmptyString,
206 const wxString& fixed_face = wxPyEmptyString);
209 wxHtmlContainerCell* GetContainer();
210 wxHtmlContainerCell* OpenContainer();
211 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
212 wxHtmlContainerCell* CloseContainer();
215 void SetFontSize(int s);
217 void SetFontBold(int x);
219 void SetFontItalic(int x);
220 int GetFontUnderlined();
221 void SetFontUnderlined(int x);
223 void SetFontFixed(int x);
225 void SetAlign(int a);
226 wxColour GetLinkColor();
227 void SetLinkColor(const wxColour& clr);
228 wxColour GetActualColor();
229 void SetActualColor(const wxColour& clr);
230 void SetLink(const wxString& link);
231 wxFont* CreateCurrentFont();
232 wxHtmlLinkInfo GetLink();
237 //---------------------------------------------------------------------------
240 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
241 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
243 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
245 wxHtmlParser* GetParser() { return m_Parser; }
246 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
248 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
249 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
254 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
256 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
257 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
261 %name(HtmlTagHandler) class wxPyHtmlTagHandler : public wxObject {
263 %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
264 wxPyHtmlTagHandler();
266 void _setCallbackInfo(PyObject* self, PyObject* _class);
268 void SetParser(wxHtmlParser *parser);
269 wxHtmlParser* GetParser();
270 void ParseInner(const wxHtmlTag& tag);
274 //---------------------------------------------------------------------------
277 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
278 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
280 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
282 wxHtmlWinParser* GetParser() { return m_WParser; }
283 void ParseInner(const wxHtmlTag& tag)
284 { wxHtmlWinTagHandler::ParseInner(tag); }
286 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
287 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
292 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
294 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
295 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
299 %name(HtmlWinTagHandler) class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
301 %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
302 wxPyHtmlWinTagHandler();
304 void _setCallbackInfo(PyObject* self, PyObject* _class);
306 void SetParser(wxHtmlParser *parser);
307 wxHtmlWinParser* GetParser();
308 void ParseInner(const wxHtmlTag& tag);
312 //---------------------------------------------------------------------------
316 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
318 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
319 m_tagHandlerClass = thc;
320 Py_INCREF(m_tagHandlerClass);
321 RegisterModule(this);
322 wxHtmlWinParser::AddModule(this);
326 bool blocked = wxPyBeginBlockThreads();
327 Py_DECREF(m_tagHandlerClass);
328 m_tagHandlerClass = NULL;
329 for (size_t x=0; x < m_objArray.GetCount(); x++) {
330 PyObject* obj = (PyObject*)m_objArray.Item(x);
333 wxPyEndBlockThreads(blocked);
336 void FillHandlersTable(wxHtmlWinParser *parser) {
337 // Wave our magic wand... (if it works it's a miracle! ;-)
339 // First, make a new instance of the tag handler
340 bool blocked = wxPyBeginBlockThreads();
341 PyObject* arg = PyTuple_New(0);
342 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
345 // now figure out where it's C++ object is...
346 wxPyHtmlWinTagHandler* thPtr;
347 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
348 wxPyEndBlockThreads(blocked);
351 wxPyEndBlockThreads(blocked);
354 parser->AddTagHandler(thPtr);
361 PyObject* m_tagHandlerClass;
362 wxArrayPtrVoid m_objArray;
370 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
371 // Dynamically create a new wxModule. Refcounts tagHandlerClass
372 // and adds itself to the wxModules list and to the wxHtmlWinParser.
373 new wxPyHtmlTagsModule(tagHandlerClass);
378 //---------------------------------------------------------------------------
379 //---------------------------------------------------------------------------
383 // wxHtmlSelection is data holder with information about text selection.
384 // Selection is defined by two positions (beginning and end of the selection)
385 // and two leaf(!) cells at these positions.
386 class wxHtmlSelection
392 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
393 const wxPoint& toPos, const wxHtmlCell *toCell);
394 %name(SetCells)void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
396 const wxHtmlCell *GetFromCell() const;
397 const wxHtmlCell *GetToCell() const;
399 // these values are in absolute coordinates:
400 const wxPoint& GetFromPos() const;
401 const wxPoint& GetToPos() const;
403 // these are From/ToCell's private data
404 const wxPoint& GetFromPrivPos() const;
405 const wxPoint& GetToPrivPos() const;
406 void SetFromPrivPos(const wxPoint& pos);
407 void SetToPrivPos(const wxPoint& pos);
410 const bool IsEmpty() const;
415 enum wxHtmlSelectionState
417 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
418 wxHTML_SEL_IN, // ... is inside selection
419 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
424 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
425 // differently e.g. when inside text selection or outside it.
426 class wxHtmlRenderingState
429 wxHtmlRenderingState();
430 ~wxHtmlRenderingState();
432 void SetSelectionState(wxHtmlSelectionState s);
433 wxHtmlSelectionState GetSelectionState() const;
435 void SetFgColour(const wxColour& c);
436 const wxColour& GetFgColour() const;
437 void SetBgColour(const wxColour& c);
438 const wxColour& GetBgColour() const;
443 // HTML rendering customization. This class is used when rendering wxHtmlCells
445 class wxHtmlRenderingStyle
448 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
449 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
453 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
456 virtual wxColour GetSelectedTextColour(const wxColour& clr);
457 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
462 // Information given to cells when drawing them. Contains rendering state,
463 // selection information and rendering style object that can be used to
464 // customize the output.
465 class wxHtmlRenderingInfo
468 wxHtmlRenderingInfo();
469 ~wxHtmlRenderingInfo();
471 void SetSelection(wxHtmlSelection *s);
472 wxHtmlSelection *GetSelection() const;
474 void SetStyle(wxHtmlRenderingStyle *style);
475 wxHtmlRenderingStyle& GetStyle();
477 wxHtmlRenderingState& GetState();
480 //---------------------------------------------------------------------------
486 wxHTML_FIND_EXACT = 1,
487 wxHTML_FIND_NEAREST_BEFORE = 2,
488 wxHTML_FIND_NEAREST_AFTER = 4
492 class wxHtmlCell : public wxObject {
502 // Returns the maximum possible length of the cell.
503 // Call Layout at least once before using GetMaxTotalWidth()
504 int GetMaxTotalWidth() const;
506 const wxString& GetId() const;
507 void SetId(const wxString& id);
508 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
509 wxHtmlCell* GetNext();
510 wxHtmlContainerCell* GetParent();
511 wxHtmlCell* GetFirstChild() const;
513 // Returns cursor to be used when mouse is over the cell:
514 wxCursor GetCursor() const;
516 // Formatting cells are not visible on the screen, they only alter
518 bool IsFormattingCell() const;
521 void SetLink(const wxHtmlLinkInfo& link);
522 void SetNext(wxHtmlCell *cell);
523 void SetParent(wxHtmlContainerCell *p);
524 void SetPos(int x, int y);
526 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
527 wxHtmlRenderingInfo& info);
528 void DrawInvisible(wxDC& dc, int x, int y,
529 wxHtmlRenderingInfo& info);
530 const wxHtmlCell* Find(int condition, const void* param);
532 bool AdjustPagebreak(int* INOUT);
533 void SetCanLiveOnPagebreak(bool can);
535 // Can the line be broken before this cell?
536 bool IsLinebreakAllowed() const;
538 // Returns True for simple == terminal cells, i.e. not composite ones.
539 // This if for internal usage only and may disappear in future versions!
540 bool IsTerminalCell() const;
542 // Find a cell inside this cell positioned at the given coordinates
543 // (relative to this's positions). Returns NULL if no such cell exists.
544 // The flag can be used to specify whether to look for terminal or
545 // nonterminal cells or both. In either case, returned cell is deepest
546 // cell in cells tree that contains [x,y].
547 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
548 unsigned flags = wxHTML_FIND_EXACT) const;
550 // Returns absolute position of the cell on HTML canvas
551 wxPoint GetAbsPos() const;
553 // Returns first (last) terminal cell inside this cell. It may return NULL,
554 // but it is rare -- only if there are no terminals in the tree.
555 wxHtmlCell *GetFirstTerminal() const ;
556 wxHtmlCell *GetLastTerminal() const ;
558 // Returns cell's depth, i.e. how far under the root cell it is
559 // (if it is the root, depth is 0)
560 unsigned GetDepth() const;
562 // Returns True if the cell appears before 'cell' in natural order of
563 // cells (= as they are read). If cell A is (grand)parent of cell B,
564 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
565 bool IsBefore(wxHtmlCell *cell) const;
567 // Converts the cell into text representation. If sel != NULL then
568 // only part of the cell inside the selection is converted.
569 wxString ConvertToText(wxHtmlSelection *sel) const;
573 class wxHtmlWordCell : public wxHtmlCell
576 wxHtmlWordCell(const wxString& word, wxDC& dc);
580 class wxHtmlContainerCell : public wxHtmlCell {
582 wxHtmlContainerCell(wxHtmlContainerCell *parent);
584 void InsertCell(wxHtmlCell *cell);
585 void SetAlignHor(int al);
587 void SetAlignVer(int al);
589 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
590 int GetIndent(int ind);
591 int GetIndentUnits(int ind);
592 void SetAlign(const wxHtmlTag& tag);
593 void SetWidthFloat(int w, int units);
594 %name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
595 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
596 void SetBackgroundColour(const wxColour& clr);
597 wxColour GetBackgroundColour();
598 void SetBorder(const wxColour& clr1, const wxColour& clr2);
599 wxHtmlCell* GetFirstChild();
600 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
605 class wxHtmlColourCell : public wxHtmlCell {
607 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
612 class wxHtmlFontCell : public wxHtmlCell
615 wxHtmlFontCell(wxFont *font);
619 class wxHtmlWidgetCell : public wxHtmlCell {
621 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
628 //---------------------------------------------------------------------------
630 //---------------------------------------------------------------------------
634 %{ // here's the C++ version
635 class wxPyHtmlFilter : public wxHtmlFilter {
636 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
638 wxPyHtmlFilter() : wxHtmlFilter() {}
640 // returns True if this filter is able to open&read given file
641 virtual bool CanRead(const wxFSFile& file) const {
644 bool blocked = wxPyBeginBlockThreads();
645 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
646 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
647 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
650 wxPyEndBlockThreads(blocked);
655 // Reads given file and returns HTML document.
656 // Returns empty string if opening failed
657 virtual wxString ReadFile(const wxFSFile& file) const {
660 bool blocked = wxPyBeginBlockThreads();
661 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
662 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
664 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
667 rval = Py2wxString(ro);
671 wxPyEndBlockThreads(blocked);
678 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
682 // And now the version seen by SWIG
684 %name(HtmlFilter) class wxPyHtmlFilter : public wxObject {
686 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
689 void _setCallbackInfo(PyObject* self, PyObject* _class);
693 // TODO: wxHtmlFilterHTML
696 //---------------------------------------------------------------------------
698 //---------------------------------------------------------------------------
702 class wxPyHtmlWindow : public wxHtmlWindow {
703 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
705 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
706 const wxPoint& pos = wxDefaultPosition,
707 const wxSize& size = wxDefaultSize,
708 long style = wxHW_DEFAULT_STYLE,
709 const wxString& name = wxPyHtmlWindowNameStr)
710 : wxHtmlWindow(parent, id, pos, size, style, name) {};
711 wxPyHtmlWindow() : wxHtmlWindow() {};
713 bool ScrollToAnchor(const wxString& anchor) {
714 return wxHtmlWindow::ScrollToAnchor(anchor);
717 bool HasAnchor(const wxString& anchor) {
718 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
722 void OnLinkClicked(const wxHtmlLinkInfo& link);
723 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
725 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
727 wxString *redirect) const;
729 DEC_PYCALLBACK__STRING(OnSetTitle);
730 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
731 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
735 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
736 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
737 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
738 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
741 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
743 bool blocked = wxPyBeginBlockThreads();
744 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
745 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
746 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
749 wxPyEndBlockThreads(blocked);
751 wxHtmlWindow::OnLinkClicked(link);
753 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
754 wxHtmlWindow::OnLinkClicked(link);
758 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
760 wxString *redirect) const {
762 wxHtmlOpeningStatus rval;
763 bool blocked = wxPyBeginBlockThreads();
764 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
766 PyObject* s = wx2PyString(url);
767 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
769 if (PyString_Check(ro)
770 #if PYTHON_API_VERSION >= 1009
771 || PyUnicode_Check(ro)
774 *redirect = Py2wxString(ro);
775 rval = wxHTML_REDIRECT;
778 PyObject* num = PyNumber_Int(ro);
779 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
784 wxPyEndBlockThreads(blocked);
786 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
795 MustHaveApp(wxPyHtmlWindow);
797 %name(HtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
799 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
800 %pythonAppend wxPyHtmlWindow() ""
801 %typemap(out) wxPyHtmlWindow*; // turn off this typemap
803 wxPyHtmlWindow(wxWindow *parent, int id = -1,
804 const wxPoint& pos = wxDefaultPosition,
805 const wxSize& size = wxDefaultSize,
806 int style=wxHW_DEFAULT_STYLE,
807 const wxString& name = wxPyHtmlWindowNameStr);
808 %name(PreHtmlWindow)wxPyHtmlWindow();
810 // Turn it back on again
811 %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
813 bool Create(wxWindow *parent, int id = -1,
814 const wxPoint& pos = wxDefaultPosition,
815 const wxSize& size = wxDefaultSize,
816 int style=wxHW_SCROLLBAR_AUTO,
817 const wxString& name = wxPyHtmlWindowNameStr);
820 void _setCallbackInfo(PyObject* self, PyObject* _class);
823 // Set HTML page and display it. !! source is HTML document itself,
824 // it is NOT address/filename of HTML document. If you want to
825 // specify document location, use LoadPage() istead
826 // Return value : False if an error occured, True otherwise
827 bool SetPage(const wxString& source);
829 // Load HTML page from given location. Location can be either
830 // a) /usr/wxGTK2/docs/html/wx.htm
831 // b) http://www.somewhere.uk/document.htm
832 // c) ftp://ftp.somesite.cz/pub/something.htm
833 // In case there is no prefix (http:,ftp:), the method
834 // will try to find it itself (1. local file, then http or ftp)
835 // After the page is loaded, the method calls SetPage() to display it.
836 // Note : you can also use path relative to previously loaded page
837 // Return value : same as SetPage
838 bool LoadPage(const wxString& location);
840 // Loads HTML page from file
841 bool LoadFile(const wxString& filename);
843 // Append to current page
844 bool AppendToPage(const wxString& source);
846 // Returns full location of opened page
847 wxString GetOpenedPage();
849 // Returns anchor within opened page
850 wxString GetOpenedAnchor();
852 // Returns <TITLE> of opened page or empty string otherwise
853 wxString GetOpenedPageTitle();
855 // Sets frame in which page title will be displayed. Format is format of
856 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
857 void SetRelatedFrame(wxFrame* frame, const wxString& format);
858 wxFrame* GetRelatedFrame();
860 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
861 // will be displayed. Default is -1 = no messages.
862 void SetRelatedStatusBar(int bar);
864 // Sets fonts to be used when displaying HTML page.
866 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
868 if (sizes) temp = int_LIST_helper(sizes);
869 self->SetFonts(normal_face, fixed_face, temp);
875 // Sets font sizes to be relative to the given size or the system
876 // default size; use either specified or default font
877 void SetStandardFonts(int size = -1,
878 const wxString& normal_face = wxPyEmptyString,
879 const wxString& fixed_face = wxPyEmptyString);
882 void, SetTitle(const wxString& title),
885 // Sets space between text and window borders.
886 void SetBorders(int b);
888 // Saves custom settings into cfg config. it will use the path 'path'
889 // if given, otherwise it will save info into currently selected path.
890 // saved values : things set by SetFonts, SetBorders.
891 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
892 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
894 // Goes to previous/next page (in browsing history)
895 // Returns True if successful, False otherwise
897 bool HistoryForward();
898 bool HistoryCanBack();
899 bool HistoryCanForward();
904 // Returns pointer to conteiners/cells structure.
905 wxHtmlContainerCell* GetInternalRepresentation();
907 // Returns a pointer to the parser.
908 wxHtmlWinParser* GetParser();
910 bool ScrollToAnchor(const wxString& anchor);
911 bool HasAnchor(const wxString& anchor);
914 static void AddFilter(wxPyHtmlFilter *filter);
916 // Helper functions to select parts of page:
917 void SelectWord(const wxPoint& pos);
918 void SelectLine(const wxPoint& pos);
921 // Convert selection to text:
922 wxString SelectionToText();
924 // Converts current page to text:
927 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
928 void base_OnSetTitle(const wxString& title);
929 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
930 void base_OnCellClicked(wxHtmlCell *cell,
931 wxCoord x, wxCoord y,
932 const wxMouseEvent& event);
934 static wxVisualAttributes
935 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
941 //---------------------------------------------------------------------------
942 //---------------------------------------------------------------------------
946 MustHaveApp(wxHtmlDCRenderer);
948 class wxHtmlDCRenderer : public wxObject {
953 void SetDC(wxDC *dc, int maxwidth);
954 void SetSize(int width, int height);
955 void SetHtmlText(const wxString& html,
956 const wxString& basepath = wxPyEmptyString,
958 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
960 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
962 if (sizes) temp = int_LIST_helper(sizes);
963 self->SetFonts(normal_face, fixed_face, temp);
969 // Sets font sizes to be relative to the given size or the system
970 // default size; use either specified or default font
971 void SetStandardFonts(int size = -1,
972 const wxString& normal_face = wxPyEmptyString,
973 const wxString& fixed_face = wxPyEmptyString);
975 int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX,
976 //int *known_pagebreaks = NULL, int number_of_pages = 0
977 int* choices=NULL, int LCOUNT = 0
979 int GetTotalHeight();
980 // returns total height of the html document
981 // (compare Render's return value with this)
992 MustHaveApp(wxHtmlPrintout);
994 class wxHtmlPrintout : public wxPyPrintout {
996 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
997 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
999 void SetHtmlText(const wxString& html,
1000 const wxString &basepath = wxPyEmptyString,
1002 void SetHtmlFile(const wxString &htmlfile);
1003 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1004 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1006 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
1008 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1010 if (sizes) temp = int_LIST_helper(sizes);
1011 self->SetFonts(normal_face, fixed_face, temp);
1017 // Sets font sizes to be relative to the given size or the system
1018 // default size; use either specified or default font
1019 void SetStandardFonts(int size = -1,
1020 const wxString& normal_face = wxPyEmptyString,
1021 const wxString& fixed_face = wxPyEmptyString);
1023 void SetMargins(float top = 25.2, float bottom = 25.2,
1024 float left = 25.2, float right = 25.2,
1027 // Adds input filter
1028 static void AddFilter(wxHtmlFilter *filter);
1031 static void CleanUpStatics();
1036 MustHaveApp(wxHtmlEasyPrinting);
1038 class wxHtmlEasyPrinting : public wxObject {
1040 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
1041 wxWindow *parentWindow = NULL);
1042 ~wxHtmlEasyPrinting();
1044 void PreviewFile(const wxString &htmlfile);
1045 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1046 void PrintFile(const wxString &htmlfile);
1047 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1048 // void PrinterSetup();
1050 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1051 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1054 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1056 if (sizes) temp = int_LIST_helper(sizes);
1057 self->SetFonts(normal_face, fixed_face, temp);
1063 // Sets font sizes to be relative to the given size or the system
1064 // default size; use either specified or default font
1065 void SetStandardFonts(int size = -1,
1066 const wxString& normal_face = wxPyEmptyString,
1067 const wxString& fixed_face = wxPyEmptyString);
1069 wxPrintData *GetPrintData() {return m_PrintData;}
1070 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1075 //---------------------------------------------------------------------------
1076 //---------------------------------------------------------------------------
1080 class wxHtmlBookRecord {
1082 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1083 const wxString& title, const wxString& start);
1085 wxString GetBookFile();
1086 wxString GetTitle();
1087 wxString GetStart();
1088 wxString GetBasePath();
1090 void SetContentsRange(int start, int end);
1091 int GetContentsStart();
1092 int GetContentsEnd();
1094 void SetTitle(const wxString& title);
1095 void SetBasePath(const wxString& path);
1096 void SetStart(const wxString& start);
1098 wxString GetFullPath(const wxString &page) const;
1101 //---------------------------------------------------------------------------
1103 struct wxHtmlContentsItem
1106 int GetLevel() { return self->m_Level; }
1107 int GetID() { return self->m_ID; }
1108 wxString GetName() { return self->m_Name; }
1109 wxString GetPage() { return self->m_Page; }
1110 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1114 //---------------------------------------------------------------------------
1116 class wxHtmlSearchStatus
1119 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1120 // const wxString& book = wxPyEmptyString);
1125 const wxString& GetName();
1126 wxHtmlContentsItem* GetContentsItem();
1129 //---------------------------------------------------------------------------
1131 class wxHtmlHelpData {
1136 void SetTempDir(const wxString& path);
1137 bool AddBook(const wxString& book);
1138 // bool AddBookParam(const wxString& title, const wxString& contfile,
1139 // const wxString& indexfile=wxPyEmptyString,
1140 // const wxString& deftopic=wxPyEmptyString,
1141 // const wxString& path=wxPyEmptyString);
1143 wxString FindPageByName(const wxString& page);
1144 wxString FindPageById(int id);
1146 // TODO: this one needs fixed...
1147 const wxHtmlBookRecArray& GetBookRecArray();
1149 wxHtmlContentsItem* GetContents();
1150 int GetContentsCnt();
1151 wxHtmlContentsItem* GetIndex();
1155 //---------------------------------------------------------------------------
1157 MustHaveApp(wxHtmlHelpFrame);
1159 class wxHtmlHelpFrame : public wxFrame {
1161 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1163 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1164 const wxString& title = wxPyEmptyString,
1165 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1167 wxHtmlHelpData* GetData();
1168 void SetTitleFormat(const wxString& format);
1169 void Display(const wxString& x);
1170 %name(DisplayID) void Display(int id);
1171 void DisplayContents();
1172 void DisplayIndex();
1173 bool KeywordSearch(const wxString& keyword);
1174 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1175 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1176 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1180 //---------------------------------------------------------------------------
1196 MustHaveApp(wxHtmlHelpController);
1198 class wxHtmlHelpController : public wxObject // wxHelpControllerBase
1201 // %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1203 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1204 ~wxHtmlHelpController();
1206 void SetTitleFormat(const wxString& format);
1207 void SetTempDir(const wxString& path);
1208 bool AddBook(const wxString& book, int show_wait_msg = false);
1209 void Display(const wxString& x);
1210 %name(DisplayID) void Display(int id);
1211 void DisplayContents();
1212 void DisplayIndex();
1213 bool KeywordSearch(const wxString& keyword);
1214 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1215 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1216 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1217 wxHtmlHelpFrame* GetFrame();
1223 //---------------------------------------------------------------------------
1225 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1226 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1227 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1228 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1230 //---------------------------------------------------------------------------
1231 //---------------------------------------------------------------------------