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);
231 GetActualColour = GetActualColor
232 SetActualColour = SetActualColor
234 void SetLink(const wxString& link);
235 wxFont* CreateCurrentFont();
236 wxHtmlLinkInfo GetLink();
241 //---------------------------------------------------------------------------
244 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
245 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler);
247 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
249 wxHtmlParser* GetParser() { return m_Parser; }
250 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
252 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
253 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
258 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
260 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
261 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
265 %rename(HtmlTagHandler) wxPyHtmlTagHandler;
266 class wxPyHtmlTagHandler : public wxObject {
268 %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
269 wxPyHtmlTagHandler();
271 void _setCallbackInfo(PyObject* self, PyObject* _class);
273 void SetParser(wxHtmlParser *parser);
274 wxHtmlParser* GetParser();
275 void ParseInner(const wxHtmlTag& tag);
279 //---------------------------------------------------------------------------
282 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
283 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler);
285 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
287 wxHtmlWinParser* GetParser() { return m_WParser; }
288 void ParseInner(const wxHtmlTag& tag)
289 { wxHtmlWinTagHandler::ParseInner(tag); }
291 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
292 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
297 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
299 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
300 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
304 %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler;
305 class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
307 %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
308 wxPyHtmlWinTagHandler();
310 void _setCallbackInfo(PyObject* self, PyObject* _class);
312 void SetParser(wxHtmlParser *parser);
313 wxHtmlWinParser* GetParser();
314 void ParseInner(const wxHtmlTag& tag);
318 //---------------------------------------------------------------------------
322 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
324 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
325 m_tagHandlerClass = thc;
326 Py_INCREF(m_tagHandlerClass);
327 RegisterModule(this);
328 wxHtmlWinParser::AddModule(this);
332 bool blocked = wxPyBeginBlockThreads();
333 Py_DECREF(m_tagHandlerClass);
334 m_tagHandlerClass = NULL;
335 for (size_t x=0; x < m_objArray.GetCount(); x++) {
336 PyObject* obj = (PyObject*)m_objArray.Item(x);
339 wxPyEndBlockThreads(blocked);
342 void FillHandlersTable(wxHtmlWinParser *parser) {
343 // Wave our magic wand... (if it works it's a miracle! ;-)
345 // First, make a new instance of the tag handler
346 bool blocked = wxPyBeginBlockThreads();
347 PyObject* arg = PyTuple_New(0);
348 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
351 // now figure out where it's C++ object is...
352 wxPyHtmlWinTagHandler* thPtr;
353 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
354 wxPyEndBlockThreads(blocked);
357 wxPyEndBlockThreads(blocked);
360 parser->AddTagHandler(thPtr);
367 PyObject* m_tagHandlerClass;
368 wxArrayPtrVoid m_objArray;
376 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
377 // Dynamically create a new wxModule. Refcounts tagHandlerClass
378 // and adds itself to the wxModules list and to the wxHtmlWinParser.
379 new wxPyHtmlTagsModule(tagHandlerClass);
384 //---------------------------------------------------------------------------
385 //---------------------------------------------------------------------------
389 // wxHtmlSelection is data holder with information about text selection.
390 // Selection is defined by two positions (beginning and end of the selection)
391 // and two leaf(!) cells at these positions.
392 class wxHtmlSelection
398 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
399 const wxPoint& toPos, const wxHtmlCell *toCell);
400 %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell));
402 const wxHtmlCell *GetFromCell() const;
403 const wxHtmlCell *GetToCell() const;
405 // these values are in absolute coordinates:
406 const wxPoint& GetFromPos() const;
407 const wxPoint& GetToPos() const;
409 // these are From/ToCell's private data
410 const wxPoint& GetFromPrivPos() const;
411 const wxPoint& GetToPrivPos() const;
412 void SetFromPrivPos(const wxPoint& pos);
413 void SetToPrivPos(const wxPoint& pos);
416 const bool IsEmpty() const;
421 enum wxHtmlSelectionState
423 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
424 wxHTML_SEL_IN, // ... is inside selection
425 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
430 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
431 // differently e.g. when inside text selection or outside it.
432 class wxHtmlRenderingState
435 wxHtmlRenderingState();
436 ~wxHtmlRenderingState();
438 void SetSelectionState(wxHtmlSelectionState s);
439 wxHtmlSelectionState GetSelectionState() const;
441 void SetFgColour(const wxColour& c);
442 const wxColour& GetFgColour() const;
443 void SetBgColour(const wxColour& c);
444 const wxColour& GetBgColour() const;
449 // HTML rendering customization. This class is used when rendering wxHtmlCells
451 class wxHtmlRenderingStyle
454 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
455 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
459 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
462 virtual wxColour GetSelectedTextColour(const wxColour& clr);
463 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
468 // Information given to cells when drawing them. Contains rendering state,
469 // selection information and rendering style object that can be used to
470 // customize the output.
471 class wxHtmlRenderingInfo
474 wxHtmlRenderingInfo();
475 ~wxHtmlRenderingInfo();
477 void SetSelection(wxHtmlSelection *s);
478 wxHtmlSelection *GetSelection() const;
480 void SetStyle(wxHtmlRenderingStyle *style);
481 wxHtmlRenderingStyle& GetStyle();
483 wxHtmlRenderingState& GetState();
486 //---------------------------------------------------------------------------
492 wxHTML_FIND_EXACT = 1,
493 wxHTML_FIND_NEAREST_BEFORE = 2,
494 wxHTML_FIND_NEAREST_AFTER = 4
498 class wxHtmlCell : public wxObject {
508 // Returns the maximum possible length of the cell.
509 // Call Layout at least once before using GetMaxTotalWidth()
510 int GetMaxTotalWidth() const;
512 const wxString& GetId() const;
513 void SetId(const wxString& id);
514 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
515 wxHtmlCell* GetNext();
516 wxHtmlContainerCell* GetParent();
517 wxHtmlCell* GetFirstChild() const;
519 // Returns cursor to be used when mouse is over the cell:
520 wxCursor GetCursor() const;
522 // Formatting cells are not visible on the screen, they only alter
524 bool IsFormattingCell() const;
527 void SetLink(const wxHtmlLinkInfo& link);
528 void SetNext(wxHtmlCell *cell);
529 void SetParent(wxHtmlContainerCell *p);
530 void SetPos(int x, int y);
532 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
533 wxHtmlRenderingInfo& info);
534 void DrawInvisible(wxDC& dc, int x, int y,
535 wxHtmlRenderingInfo& info);
536 const wxHtmlCell* Find(int condition, const void* param);
538 bool AdjustPagebreak(int* INOUT);
539 void SetCanLiveOnPagebreak(bool can);
541 // Can the line be broken before this cell?
542 bool IsLinebreakAllowed() const;
544 // Returns True for simple == terminal cells, i.e. not composite ones.
545 // This if for internal usage only and may disappear in future versions!
546 bool IsTerminalCell() const;
548 // Find a cell inside this cell positioned at the given coordinates
549 // (relative to this's positions). Returns NULL if no such cell exists.
550 // The flag can be used to specify whether to look for terminal or
551 // nonterminal cells or both. In either case, returned cell is deepest
552 // cell in cells tree that contains [x,y].
553 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
554 unsigned flags = wxHTML_FIND_EXACT) const;
556 // Returns absolute position of the cell on HTML canvas
557 wxPoint GetAbsPos() const;
559 // Returns first (last) terminal cell inside this cell. It may return NULL,
560 // but it is rare -- only if there are no terminals in the tree.
561 wxHtmlCell *GetFirstTerminal() const ;
562 wxHtmlCell *GetLastTerminal() const ;
564 // Returns cell's depth, i.e. how far under the root cell it is
565 // (if it is the root, depth is 0)
566 unsigned GetDepth() const;
568 // Returns True if the cell appears before 'cell' in natural order of
569 // cells (= as they are read). If cell A is (grand)parent of cell B,
570 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
571 bool IsBefore(wxHtmlCell *cell) const;
573 // Converts the cell into text representation. If sel != NULL then
574 // only part of the cell inside the selection is converted.
575 wxString ConvertToText(wxHtmlSelection *sel) const;
579 class wxHtmlWordCell : public wxHtmlCell
582 wxHtmlWordCell(const wxString& word, wxDC& dc);
586 class wxHtmlContainerCell : public wxHtmlCell {
588 wxHtmlContainerCell(wxHtmlContainerCell *parent);
590 void InsertCell(wxHtmlCell *cell);
591 void SetAlignHor(int al);
593 void SetAlignVer(int al);
595 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
596 int GetIndent(int ind);
597 int GetIndentUnits(int ind);
598 void SetAlign(const wxHtmlTag& tag);
599 void SetWidthFloat(int w, int units);
600 %Rename(SetWidthFloatFromTag, void, SetWidthFloat(const wxHtmlTag& tag));
601 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
602 void SetBackgroundColour(const wxColour& clr);
603 wxColour GetBackgroundColour();
604 void SetBorder(const wxColour& clr1, const wxColour& clr2);
605 wxHtmlCell* GetFirstChild();
606 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
611 class wxHtmlColourCell : public wxHtmlCell {
613 wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
618 class wxHtmlFontCell : public wxHtmlCell
621 wxHtmlFontCell(wxFont *font);
625 class wxHtmlWidgetCell : public wxHtmlCell {
627 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
634 //---------------------------------------------------------------------------
636 //---------------------------------------------------------------------------
640 %{ // here's the C++ version
641 class wxPyHtmlFilter : public wxHtmlFilter {
642 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter);
644 wxPyHtmlFilter() : wxHtmlFilter() {}
646 // returns True if this filter is able to open&read given file
647 virtual bool CanRead(const wxFSFile& file) const {
650 bool blocked = wxPyBeginBlockThreads();
651 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
652 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
653 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
656 wxPyEndBlockThreads(blocked);
661 // Reads given file and returns HTML document.
662 // Returns empty string if opening failed
663 virtual wxString ReadFile(const wxFSFile& file) const {
666 bool blocked = wxPyBeginBlockThreads();
667 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
668 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
670 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
673 rval = Py2wxString(ro);
677 wxPyEndBlockThreads(blocked);
684 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
688 // And now the version seen by SWIG
690 %rename(HtmlFilter) wxPyHtmlFilter;
691 class wxPyHtmlFilter : public wxObject {
693 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
696 void _setCallbackInfo(PyObject* self, PyObject* _class);
700 // TODO: wxHtmlFilterHTML
703 //---------------------------------------------------------------------------
705 //---------------------------------------------------------------------------
709 class wxPyHtmlWindow : public wxHtmlWindow {
710 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow);
712 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
713 const wxPoint& pos = wxDefaultPosition,
714 const wxSize& size = wxDefaultSize,
715 long style = wxHW_DEFAULT_STYLE,
716 const wxString& name = wxPyHtmlWindowNameStr)
717 : wxHtmlWindow(parent, id, pos, size, style, name) {};
718 wxPyHtmlWindow() : wxHtmlWindow() {};
720 bool ScrollToAnchor(const wxString& anchor) {
721 return wxHtmlWindow::ScrollToAnchor(anchor);
724 bool HasAnchor(const wxString& anchor) {
725 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
729 void OnLinkClicked(const wxHtmlLinkInfo& link);
730 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
732 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
734 wxString *redirect) const;
736 DEC_PYCALLBACK__STRING(OnSetTitle);
737 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
738 DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
742 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
743 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
744 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
745 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
748 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
750 bool blocked = wxPyBeginBlockThreads();
751 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
752 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
753 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
756 wxPyEndBlockThreads(blocked);
758 wxHtmlWindow::OnLinkClicked(link);
760 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
761 wxHtmlWindow::OnLinkClicked(link);
765 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
767 wxString *redirect) const {
769 wxHtmlOpeningStatus rval;
770 bool blocked = wxPyBeginBlockThreads();
771 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
773 PyObject* s = wx2PyString(url);
774 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
776 if (PyString_Check(ro)
777 #if PYTHON_API_VERSION >= 1009
778 || PyUnicode_Check(ro)
781 *redirect = Py2wxString(ro);
782 rval = wxHTML_REDIRECT;
785 PyObject* num = PyNumber_Int(ro);
786 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
791 wxPyEndBlockThreads(blocked);
793 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
802 MustHaveApp(wxPyHtmlWindow);
804 %rename(HtmlWindow) wxPyHtmlWindow;
805 class wxPyHtmlWindow : public wxScrolledWindow {
807 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
808 %pythonAppend wxPyHtmlWindow() ""
809 %typemap(out) wxPyHtmlWindow*; // turn off this typemap
811 wxPyHtmlWindow(wxWindow *parent, int id = -1,
812 const wxPoint& pos = wxDefaultPosition,
813 const wxSize& size = wxDefaultSize,
814 int style=wxHW_DEFAULT_STYLE,
815 const wxString& name = wxPyHtmlWindowNameStr);
816 %RenameCtor(PreHtmlWindow, wxPyHtmlWindow());
818 // Turn it back on again
819 %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
821 bool Create(wxWindow *parent, int id = -1,
822 const wxPoint& pos = wxDefaultPosition,
823 const wxSize& size = wxDefaultSize,
824 int style=wxHW_SCROLLBAR_AUTO,
825 const wxString& name = wxPyHtmlWindowNameStr);
828 void _setCallbackInfo(PyObject* self, PyObject* _class);
831 // Set HTML page and display it. !! source is HTML document itself,
832 // it is NOT address/filename of HTML document. If you want to
833 // specify document location, use LoadPage() istead
834 // Return value : False if an error occured, True otherwise
835 bool SetPage(const wxString& source);
837 // Load HTML page from given location. Location can be either
838 // a) /usr/wxGTK2/docs/html/wx.htm
839 // b) http://www.somewhere.uk/document.htm
840 // c) ftp://ftp.somesite.cz/pub/something.htm
841 // In case there is no prefix (http:,ftp:), the method
842 // will try to find it itself (1. local file, then http or ftp)
843 // After the page is loaded, the method calls SetPage() to display it.
844 // Note : you can also use path relative to previously loaded page
845 // Return value : same as SetPage
846 bool LoadPage(const wxString& location);
848 // Loads HTML page from file
849 bool LoadFile(const wxString& filename);
851 // Append to current page
852 bool AppendToPage(const wxString& source);
854 // Returns full location of opened page
855 wxString GetOpenedPage();
857 // Returns anchor within opened page
858 wxString GetOpenedAnchor();
860 // Returns <TITLE> of opened page or empty string otherwise
861 wxString GetOpenedPageTitle();
863 // Sets frame in which page title will be displayed. Format is format of
864 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
865 void SetRelatedFrame(wxFrame* frame, const wxString& format);
866 wxFrame* GetRelatedFrame();
868 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
869 // will be displayed. Default is -1 = no messages.
870 void SetRelatedStatusBar(int bar);
872 // Sets fonts to be used when displaying HTML page.
874 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
876 if (sizes) temp = int_LIST_helper(sizes);
877 self->SetFonts(normal_face, fixed_face, temp);
883 // Sets font sizes to be relative to the given size or the system
884 // default size; use either specified or default font
885 void SetStandardFonts(int size = -1,
886 const wxString& normal_face = wxPyEmptyString,
887 const wxString& fixed_face = wxPyEmptyString);
890 void, SetTitle(const wxString& title),
893 // Sets space between text and window borders.
894 void SetBorders(int b);
896 // Saves custom settings into cfg config. it will use the path 'path'
897 // if given, otherwise it will save info into currently selected path.
898 // saved values : things set by SetFonts, SetBorders.
899 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
900 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
902 // Goes to previous/next page (in browsing history)
903 // Returns True if successful, False otherwise
905 bool HistoryForward();
906 bool HistoryCanBack();
907 bool HistoryCanForward();
912 // Returns pointer to conteiners/cells structure.
913 wxHtmlContainerCell* GetInternalRepresentation();
915 // Returns a pointer to the parser.
916 wxHtmlWinParser* GetParser();
918 bool ScrollToAnchor(const wxString& anchor);
919 bool HasAnchor(const wxString& anchor);
922 static void AddFilter(wxPyHtmlFilter *filter);
924 // Helper functions to select parts of page:
925 void SelectWord(const wxPoint& pos);
926 void SelectLine(const wxPoint& pos);
929 // Convert selection to text:
930 wxString SelectionToText();
932 // Converts current page to text:
935 void base_OnLinkClicked(const wxHtmlLinkInfo& link);
936 void base_OnSetTitle(const wxString& title);
937 void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
938 void base_OnCellClicked(wxHtmlCell *cell,
939 wxCoord x, wxCoord y,
940 const wxMouseEvent& event);
942 static wxVisualAttributes
943 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
949 //---------------------------------------------------------------------------
950 //---------------------------------------------------------------------------
954 MustHaveApp(wxHtmlDCRenderer);
956 class wxHtmlDCRenderer : public wxObject {
961 void SetDC(wxDC *dc, int maxwidth);
962 void SetSize(int width, int height);
963 void SetHtmlText(const wxString& html,
964 const wxString& basepath = wxPyEmptyString,
966 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
968 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
970 if (sizes) temp = int_LIST_helper(sizes);
971 self->SetFonts(normal_face, fixed_face, temp);
977 // Sets font sizes to be relative to the given size or the system
978 // default size; use either specified or default font
979 void SetStandardFonts(int size = -1,
980 const wxString& normal_face = wxPyEmptyString,
981 const wxString& fixed_face = wxPyEmptyString);
983 int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX,
984 //int *known_pagebreaks = NULL, int number_of_pages = 0
985 int* choices=NULL, int LCOUNT = 0
987 int GetTotalHeight();
988 // returns total height of the html document
989 // (compare Render's return value with this)
1000 MustHaveApp(wxHtmlPrintout);
1002 class wxHtmlPrintout : public wxPyPrintout {
1004 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
1005 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
1007 void SetHtmlText(const wxString& html,
1008 const wxString &basepath = wxPyEmptyString,
1010 void SetHtmlFile(const wxString &htmlfile);
1011 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1012 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1014 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
1016 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1018 if (sizes) temp = int_LIST_helper(sizes);
1019 self->SetFonts(normal_face, fixed_face, temp);
1025 // Sets font sizes to be relative to the given size or the system
1026 // default size; use either specified or default font
1027 void SetStandardFonts(int size = -1,
1028 const wxString& normal_face = wxPyEmptyString,
1029 const wxString& fixed_face = wxPyEmptyString);
1031 void SetMargins(float top = 25.2, float bottom = 25.2,
1032 float left = 25.2, float right = 25.2,
1035 // Adds input filter
1036 static void AddFilter(wxHtmlFilter *filter);
1039 static void CleanUpStatics();
1044 MustHaveApp(wxHtmlEasyPrinting);
1046 class wxHtmlEasyPrinting : public wxObject {
1048 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
1049 wxWindow *parentWindow = NULL);
1050 ~wxHtmlEasyPrinting();
1052 void PreviewFile(const wxString &htmlfile);
1053 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1054 void PrintFile(const wxString &htmlfile);
1055 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1056 // void PrinterSetup();
1058 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1059 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1062 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1064 if (sizes) temp = int_LIST_helper(sizes);
1065 self->SetFonts(normal_face, fixed_face, temp);
1071 // Sets font sizes to be relative to the given size or the system
1072 // default size; use either specified or default font
1073 void SetStandardFonts(int size = -1,
1074 const wxString& normal_face = wxPyEmptyString,
1075 const wxString& fixed_face = wxPyEmptyString);
1077 wxPrintData *GetPrintData() {return m_PrintData;}
1078 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1083 //---------------------------------------------------------------------------
1084 //---------------------------------------------------------------------------
1088 class wxHtmlBookRecord {
1090 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1091 const wxString& title, const wxString& start);
1093 wxString GetBookFile();
1094 wxString GetTitle();
1095 wxString GetStart();
1096 wxString GetBasePath();
1098 void SetContentsRange(int start, int end);
1099 int GetContentsStart();
1100 int GetContentsEnd();
1102 void SetTitle(const wxString& title);
1103 void SetBasePath(const wxString& path);
1104 void SetStart(const wxString& start);
1106 wxString GetFullPath(const wxString &page) const;
1109 //---------------------------------------------------------------------------
1111 struct wxHtmlContentsItem
1114 int GetLevel() { return self->m_Level; }
1115 int GetID() { return self->m_ID; }
1116 wxString GetName() { return self->m_Name; }
1117 wxString GetPage() { return self->m_Page; }
1118 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1122 //---------------------------------------------------------------------------
1124 class wxHtmlSearchStatus
1127 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1128 // const wxString& book = wxPyEmptyString);
1133 const wxString& GetName();
1134 wxHtmlContentsItem* GetContentsItem();
1137 //---------------------------------------------------------------------------
1139 class wxHtmlHelpData {
1144 void SetTempDir(const wxString& path);
1145 bool AddBook(const wxString& book);
1146 // bool AddBookParam(const wxString& title, const wxString& contfile,
1147 // const wxString& indexfile=wxPyEmptyString,
1148 // const wxString& deftopic=wxPyEmptyString,
1149 // const wxString& path=wxPyEmptyString);
1151 wxString FindPageByName(const wxString& page);
1152 wxString FindPageById(int id);
1154 // TODO: this one needs fixed...
1155 const wxHtmlBookRecArray& GetBookRecArray();
1157 wxHtmlContentsItem* GetContents();
1158 int GetContentsCnt();
1159 wxHtmlContentsItem* GetIndex();
1163 //---------------------------------------------------------------------------
1165 MustHaveApp(wxHtmlHelpFrame);
1167 class wxHtmlHelpFrame : public wxFrame {
1169 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1171 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1172 const wxString& title = wxPyEmptyString,
1173 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1175 wxHtmlHelpData* GetData();
1176 void SetTitleFormat(const wxString& format);
1177 void Display(const wxString& x);
1178 %Rename(DisplayID, void, Display(int id));
1179 void DisplayContents();
1180 void DisplayIndex();
1181 bool KeywordSearch(const wxString& keyword);
1182 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1183 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1184 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1188 //---------------------------------------------------------------------------
1204 MustHaveApp(wxHtmlHelpController);
1206 class wxHtmlHelpController : public wxObject // wxHelpControllerBase
1209 // %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1211 wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
1212 ~wxHtmlHelpController();
1214 void SetTitleFormat(const wxString& format);
1215 void SetTempDir(const wxString& path);
1216 bool AddBook(const wxString& book, int show_wait_msg = false);
1217 void Display(const wxString& x);
1218 %Rename(DisplayID, void, Display(int id));
1219 void DisplayContents();
1220 void DisplayIndex();
1221 bool KeywordSearch(const wxString& keyword);
1222 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1223 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1224 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1225 wxHtmlHelpFrame* GetFrame();
1231 //---------------------------------------------------------------------------
1233 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1234 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1235 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1236 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1238 //---------------------------------------------------------------------------
1239 //---------------------------------------------------------------------------