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>
28 #include <wx/html/helpwnd.h>
29 #include <wx/html/helpfrm.h>
30 #include <wx/html/helpdlg.h>
35 //---------------------------------------------------------------------------
38 %pythoncode { wx = _core }
39 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
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 //---------------------------------------------------------------------------
61 wxHTML_CLR_FOREGROUND,
62 wxHTML_CLR_BACKGROUND,
72 wxHTML_INDENT_HORIZONTAL,
73 wxHTML_INDENT_VERTICAL,
77 wxHTML_COND_ISIMAGEMAP,
99 // enums for wxHtmlWindow::OnOpeningURL
100 enum wxHtmlOpeningStatus
116 //---------------------------------------------------------------------------
118 class wxHtmlLinkInfo : public wxObject {
120 wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
122 wxString GetTarget();
123 wxMouseEvent* GetEvent();
124 wxHtmlCell* GetHtmlCell();
126 void SetEvent(const wxMouseEvent *e);
127 void SetHtmlCell(const wxHtmlCell * e);
130 //---------------------------------------------------------------------------
132 class wxHtmlTag : public wxObject {
134 // Never need to create a new tag from Python...
135 //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
138 bool HasParam(const wxString& par);
139 wxString GetParam(const wxString& par, int with_commas = false);
141 // Can't do this one as-is, but GetParam should be enough...
142 //int ScanParam(const wxString& par, const char *format, void* param);
144 wxString GetAllParams();
151 //---------------------------------------------------------------------------
153 class wxHtmlParser : public wxObject {
155 // wxHtmlParser(); This is an abstract base class...
157 void SetFS(wxFileSystem *fs);
158 wxFileSystem* GetFS();
159 wxObject* Parse(const wxString& source);
160 void InitParser(const wxString& source);
162 void DoParsing(int begin_pos, int end_pos);
164 // wxObject* GetProduct();
166 void AddTagHandler(wxHtmlTagHandler *handler);
167 wxString* GetSource();
168 void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
169 void PopTagHandler();
171 // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
173 // void AddText(const char* txt) = 0;
174 // void AddTag(const wxHtmlTag& tag);
177 // Returns HTML source inside the element (i.e. between the starting
179 wxString GetInnerSource(const wxHtmlTag& tag);
183 //---------------------------------------------------------------------------
185 class wxHtmlWinParser : public wxHtmlParser {
187 wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
189 void SetDC(wxDC *dc);
193 wxPyHtmlWindow* GetWindow();
194 %pythoncode { GetWindow = wx._deprecated(GetWindow) }
196 wxHtmlWindowInterface *GetWindowInterface();
198 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
200 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
202 if (sizes) temp = int_LIST_helper(sizes);
203 self->SetFonts(normal_face, fixed_face, temp);
209 // Sets font sizes to be relative to the given size or the system
210 // default size; use either specified or default font
211 void SetStandardFonts(int size = -1,
212 const wxString& normal_face = wxPyEmptyString,
213 const wxString& fixed_face = wxPyEmptyString);
216 wxHtmlContainerCell* GetContainer();
217 wxHtmlContainerCell* OpenContainer();
218 wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
219 wxHtmlContainerCell* CloseContainer();
222 void SetFontSize(int s);
224 void SetFontBold(int x);
226 void SetFontItalic(int x);
227 int GetFontUnderlined();
228 void SetFontUnderlined(int x);
230 void SetFontFixed(int x);
232 void SetAlign(int a);
233 wxColour GetLinkColor();
234 void SetLinkColor(const wxColour& clr);
235 wxColour GetActualColor();
236 void SetActualColor(const wxColour& clr);
238 GetActualColour = GetActualColor
239 SetActualColour = SetActualColor
241 void SetLink(const wxString& link);
242 wxFont* CreateCurrentFont();
243 wxHtmlLinkInfo GetLink();
248 //---------------------------------------------------------------------------
251 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
252 DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler)
254 wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
256 wxHtmlParser* GetParser() { return m_Parser; }
257 void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
259 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
260 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
265 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
267 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
268 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
272 %rename(HtmlTagHandler) wxPyHtmlTagHandler;
273 class wxPyHtmlTagHandler : public wxObject {
275 %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)"
276 wxPyHtmlTagHandler();
278 void _setCallbackInfo(PyObject* self, PyObject* _class);
280 void SetParser(wxHtmlParser *parser);
281 wxHtmlParser* GetParser();
282 void ParseInner(const wxHtmlTag& tag);
286 //---------------------------------------------------------------------------
289 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
290 DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler)
292 wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
294 wxHtmlWinParser* GetParser() { return m_WParser; }
295 void ParseInner(const wxHtmlTag& tag)
296 { wxHtmlWinTagHandler::ParseInner(tag); }
298 DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
299 DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
304 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
306 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
307 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
311 %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler;
312 class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
314 %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)"
315 wxPyHtmlWinTagHandler();
317 void _setCallbackInfo(PyObject* self, PyObject* _class);
319 void SetParser(wxHtmlParser *parser);
320 wxHtmlWinParser* GetParser();
321 void ParseInner(const wxHtmlTag& tag);
325 //---------------------------------------------------------------------------
329 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
331 wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
332 m_tagHandlerClass = thc;
333 Py_INCREF(m_tagHandlerClass);
334 RegisterModule(this);
335 wxHtmlWinParser::AddModule(this);
339 wxPyBlock_t blocked = wxPyBeginBlockThreads();
340 Py_DECREF(m_tagHandlerClass);
341 m_tagHandlerClass = NULL;
342 for (size_t x=0; x < m_objArray.GetCount(); x++) {
343 PyObject* obj = (PyObject*)m_objArray.Item(x);
346 wxPyEndBlockThreads(blocked);
349 void FillHandlersTable(wxHtmlWinParser *parser) {
350 // Wave our magic wand... (if it works it's a miracle! ;-)
352 // First, make a new instance of the tag handler
353 wxPyBlock_t blocked = wxPyBeginBlockThreads();
354 PyObject* arg = PyTuple_New(0);
355 PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
358 // now figure out where it's C++ object is...
359 wxPyHtmlWinTagHandler* thPtr;
360 if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
361 wxPyEndBlockThreads(blocked);
364 wxPyEndBlockThreads(blocked);
367 parser->AddTagHandler(thPtr);
374 PyObject* m_tagHandlerClass;
375 wxArrayPtrVoid m_objArray;
383 void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
384 // Dynamically create a new wxModule. Refcounts tagHandlerClass
385 // and adds itself to the wxModules list and to the wxHtmlWinParser.
386 new wxPyHtmlTagsModule(tagHandlerClass);
391 //---------------------------------------------------------------------------
393 %typemap(out) wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); }
394 %typemap(out) const wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); }
396 //---------------------------------------------------------------------------
400 // wxHtmlSelection is data holder with information about text selection.
401 // Selection is defined by two positions (beginning and end of the selection)
402 // and two leaf(!) cells at these positions.
403 class wxHtmlSelection
409 void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
410 const wxPoint& toPos, const wxHtmlCell *toCell);
411 %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell));
413 const wxHtmlCell *GetFromCell() const;
414 const wxHtmlCell *GetToCell() const;
416 // these values are in absolute coordinates:
417 const wxPoint& GetFromPos() const;
418 const wxPoint& GetToPos() const;
420 // these are From/ToCell's private data
421 const wxPoint& GetFromPrivPos() const;
422 const wxPoint& GetToPrivPos() const;
423 void SetFromPrivPos(const wxPoint& pos);
424 void SetToPrivPos(const wxPoint& pos);
427 const bool IsEmpty() const;
432 enum wxHtmlSelectionState
434 wxHTML_SEL_OUT, // currently rendered cell is outside the selection
435 wxHTML_SEL_IN, // ... is inside selection
436 wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
441 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
442 // differently e.g. when inside text selection or outside it.
443 class wxHtmlRenderingState
446 wxHtmlRenderingState();
447 ~wxHtmlRenderingState();
449 void SetSelectionState(wxHtmlSelectionState s);
450 wxHtmlSelectionState GetSelectionState() const;
452 void SetFgColour(const wxColour& c);
453 const wxColour& GetFgColour() const;
454 void SetBgColour(const wxColour& c);
455 const wxColour& GetBgColour() const;
460 // HTML rendering customization. This class is used when rendering wxHtmlCells
462 class wxHtmlRenderingStyle
465 virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
466 virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
470 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
473 virtual wxColour GetSelectedTextColour(const wxColour& clr);
474 virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
479 // Information given to cells when drawing them. Contains rendering state,
480 // selection information and rendering style object that can be used to
481 // customize the output.
482 class wxHtmlRenderingInfo
485 wxHtmlRenderingInfo();
486 ~wxHtmlRenderingInfo();
488 void SetSelection(wxHtmlSelection *s);
489 wxHtmlSelection *GetSelection() const;
491 void SetStyle(wxHtmlRenderingStyle *style);
492 wxHtmlRenderingStyle& GetStyle();
494 wxHtmlRenderingState& GetState();
497 //---------------------------------------------------------------------------
503 wxHTML_FIND_EXACT = 1,
504 wxHTML_FIND_NEAREST_BEFORE = 2,
505 wxHTML_FIND_NEAREST_AFTER = 4
509 class wxHtmlCell : public wxObject {
511 %typemap(out) wxHtmlCell*; // turn off this typemap
516 // Turn it back on again
517 %typemap(out) wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); }
525 // Returns the maximum possible length of the cell.
526 // Call Layout at least once before using GetMaxTotalWidth()
527 int GetMaxTotalWidth() const;
529 const wxString& GetId() const;
530 void SetId(const wxString& id);
531 wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
532 wxHtmlCell* GetNext();
533 wxHtmlContainerCell* GetParent();
534 wxHtmlCell* GetFirstChild() const;
536 // Returns cursor to be used when mouse is over the cell:
537 virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const;
539 // Returns cursor to be used when mouse is over the cell:
540 wxCursor GetCursor() const;
541 %pythoncode { GetCursor = wx._deprecated(GetCursor) }
543 // Formatting cells are not visible on the screen, they only alter
545 bool IsFormattingCell() const;
548 void SetLink(const wxHtmlLinkInfo& link);
550 %disownarg(wxHtmlCell*);
551 void SetNext(wxHtmlCell *cell);
552 %cleardisown(wxHtmlCell*);
554 void SetParent(wxHtmlContainerCell *p);
555 void SetPos(int x, int y);
557 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
558 wxHtmlRenderingInfo& info);
559 void DrawInvisible(wxDC& dc, int x, int y,
560 wxHtmlRenderingInfo& info);
561 const wxHtmlCell* Find(int condition, const void* param);
564 virtual bool ProcessMouseClick(wxHtmlWindowInterface *window,
566 const wxMouseEvent& event);
568 bool AdjustPagebreak(int* INOUT);
569 void SetCanLiveOnPagebreak(bool can);
571 // Can the line be broken before this cell?
572 bool IsLinebreakAllowed() const;
574 // Returns True for simple == terminal cells, i.e. not composite ones.
575 // This if for internal usage only and may disappear in future versions!
576 bool IsTerminalCell() const;
578 // Find a cell inside this cell positioned at the given coordinates
579 // (relative to this's positions). Returns NULL if no such cell exists.
580 // The flag can be used to specify whether to look for terminal or
581 // nonterminal cells or both. In either case, returned cell is deepest
582 // cell in cells tree that contains [x,y].
583 wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
584 unsigned flags = wxHTML_FIND_EXACT) const;
586 // Returns absolute position of the cell on HTML canvas
587 // If rootCell is provided, then it's considered to be the root of the
588 // hierarchy and the returned value is relative to it.
589 wxPoint GetAbsPos(wxHtmlCell *rootCell = NULL) const;
591 // Returns root cell of the hierarchy (i.e. grand-grand-...-parent that
592 // doesn't have a parent itself)
593 wxHtmlCell *GetRootCell() const;
595 // Returns first (last) terminal cell inside this cell. It may return NULL,
596 // but it is rare -- only if there are no terminals in the tree.
597 wxHtmlCell *GetFirstTerminal() const ;
598 wxHtmlCell *GetLastTerminal() const ;
600 // Returns cell's depth, i.e. how far under the root cell it is
601 // (if it is the root, depth is 0)
602 unsigned GetDepth() const;
604 // Returns True if the cell appears before 'cell' in natural order of
605 // cells (= as they are read). If cell A is (grand)parent of cell B,
606 // then both A.IsBefore(B) and B.IsBefore(A) always return True.
607 bool IsBefore(wxHtmlCell *cell) const;
609 // Converts the cell into text representation. If sel != NULL then
610 // only part of the cell inside the selection is converted.
611 wxString ConvertToText(wxHtmlSelection *sel) const;
615 class wxHtmlWordCell : public wxHtmlCell
618 wxHtmlWordCell(const wxString& word, wxDC& dc);
619 wxString ConvertToText(wxHtmlSelection *sel) const;
620 bool IsLinebreakAllowed() const;
621 void SetPreviousWord(wxHtmlWordCell *cell);
625 class wxHtmlContainerCell : public wxHtmlCell {
627 wxHtmlContainerCell(wxHtmlContainerCell *parent);
629 %disownarg(wxHtmlCell*);
630 void InsertCell(wxHtmlCell *cell);
631 %cleardisown(wxHtmlCell*);
633 void SetAlignHor(int al);
635 void SetAlignVer(int al);
637 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
638 int GetIndent(int ind);
639 int GetIndentUnits(int ind);
640 void SetAlign(const wxHtmlTag& tag);
641 void SetWidthFloat(int w, int units);
642 %Rename(SetWidthFloatFromTag, void, SetWidthFloat(const wxHtmlTag& tag));
643 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
644 void SetBackgroundColour(const wxColour& clr);
645 wxColour GetBackgroundColour();
646 void SetBorder(const wxColour& clr1, const wxColour& clr2);
647 wxHtmlCell* GetFirstChild();
648 %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
653 class wxHtmlColourCell : public wxHtmlCell {
655 wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
660 class wxHtmlFontCell : public wxHtmlCell
663 wxHtmlFontCell(wxFont *font);
667 class wxHtmlWidgetCell : public wxHtmlCell {
669 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
676 //---------------------------------------------------------------------------
678 //---------------------------------------------------------------------------
682 %{ // here's the C++ version
683 class wxPyHtmlFilter : public wxHtmlFilter {
684 DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter)
686 wxPyHtmlFilter() : wxHtmlFilter() {}
688 // returns True if this filter is able to open&read given file
689 virtual bool CanRead(const wxFSFile& file) const {
692 wxPyBlock_t blocked = wxPyBeginBlockThreads();
693 if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
694 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
695 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
698 wxPyEndBlockThreads(blocked);
703 // Reads given file and returns HTML document.
704 // Returns empty string if opening failed
705 virtual wxString ReadFile(const wxFSFile& file) const {
708 wxPyBlock_t blocked = wxPyBeginBlockThreads();
709 if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
710 PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
712 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
715 rval = Py2wxString(ro);
719 wxPyEndBlockThreads(blocked);
726 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
730 // And now the version seen by SWIG
732 %rename(HtmlFilter) wxPyHtmlFilter;
733 class wxPyHtmlFilter : public wxObject {
735 %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)"
738 void _setCallbackInfo(PyObject* self, PyObject* _class);
742 // TODO: wxHtmlFilterHTML
745 //---------------------------------------------------------------------------
748 class wxHtmlWindowInterface
752 wxHtmlWindowInterface();
753 virtual ~wxHtmlWindowInterface();
756 Called by the parser to set window's title to given text.
758 virtual void SetHTMLWindowTitle(const wxString& title) = 0;
761 // Called when a link is clicked.
763 // @param link information about the clicked link
765 // virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link) = 0;
768 // Called when the parser needs to open another URL (e.g. an image).
770 // @param type Type of the URL request (e.g. image)
771 // @param url URL the parser wants to open
772 // @param redirect If the return value is wxHTML_REDIRECT, then the
773 // URL to redirect to will be stored in this variable
774 // (the pointer must never be NULL)
776 // @return indicator of how to treat the request
778 // virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
779 // const wxString& url,
780 // wxString *redirect) const = 0;
783 Converts coordinates @a pos relative to given @a cell to
784 physical coordinates in the window.
786 virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
787 const wxPoint& pos) const = 0;
789 /// Returns the window used for rendering (may be NULL).
790 virtual wxWindow* GetHTMLWindow() = 0;
792 /// Returns background colour to use by default.
793 virtual wxColour GetHTMLBackgroundColour() const = 0;
795 /// Sets window's background to colour @a clr.
796 virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
798 /// Sets window's background to given bitmap.
799 virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0;
801 /// Sets status bar text.
802 virtual void SetHTMLStatusText(const wxString& text) = 0;
804 /// Type of mouse cursor
807 /// Standard mouse cursor (typically an arrow)
809 /// Cursor shown over links
811 /// Cursor shown over selectable text
816 Returns mouse cursor of given @a type.
818 // virtual wxCursor GetHTMLCursor(HTMLCursor type) const = 0;
822 //---------------------------------------------------------------------------
824 //---------------------------------------------------------------------------
828 // wxHtmlWindowInterface and wxHtmlWindowMouseHelper
832 class wxPyHtmlWindow : public wxHtmlWindow {
833 DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow)
835 wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
836 const wxPoint& pos = wxDefaultPosition,
837 const wxSize& size = wxDefaultSize,
838 long style = wxHW_DEFAULT_STYLE,
839 const wxString& name = wxPyHtmlWindowNameStr)
840 : wxHtmlWindow(parent, id, pos, size, style, name) {};
841 wxPyHtmlWindow() : wxHtmlWindow() {};
843 bool ScrollToAnchor(const wxString& anchor) {
844 return wxHtmlWindow::ScrollToAnchor(anchor);
847 bool HasAnchor(const wxString& anchor) {
848 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
852 void OnLinkClicked(const wxHtmlLinkInfo& link);
854 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
856 wxString *redirect) const;
858 DEC_PYCALLBACK__STRING(OnSetTitle);
859 DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
860 DEC_PYCALLBACK_BOOL_CELLINTINTME(OnCellClicked);
865 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
866 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
867 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
868 IMP_PYCALLBACK_BOOL_CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
871 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
873 wxPyBlock_t blocked = wxPyBeginBlockThreads();
874 if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
875 PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
876 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
879 wxPyEndBlockThreads(blocked);
881 wxHtmlWindow::OnLinkClicked(link);
885 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
887 wxString *redirect) const {
889 wxHtmlOpeningStatus rval;
890 wxPyBlock_t blocked = wxPyBeginBlockThreads();
891 if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
893 PyObject* s = wx2PyString(url);
894 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
896 if (PyString_Check(ro)
897 #if PYTHON_API_VERSION >= 1009
898 || PyUnicode_Check(ro)
901 *redirect = Py2wxString(ro);
902 rval = wxHTML_REDIRECT;
905 PyObject* num = PyNumber_Int(ro);
906 rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
911 wxPyEndBlockThreads(blocked);
913 rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
922 MustHaveApp(wxPyHtmlWindow);
924 %rename(HtmlWindow) wxPyHtmlWindow;
925 class wxPyHtmlWindow : public wxScrolledWindow //,
926 // public wxHtmlWindowInterface //,
927 // public wxHtmlWindowMouseHelper
930 %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
931 %pythonAppend wxPyHtmlWindow() ""
932 %typemap(out) wxPyHtmlWindow*; // turn off this typemap
934 wxPyHtmlWindow(wxWindow *parent, int id = -1,
935 const wxPoint& pos = wxDefaultPosition,
936 const wxSize& size = wxDefaultSize,
937 int style=wxHW_DEFAULT_STYLE,
938 const wxString& name = wxPyHtmlWindowNameStr);
939 %RenameCtor(PreHtmlWindow, wxPyHtmlWindow());
941 // Turn it back on again
942 %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
944 bool Create(wxWindow *parent, int id = -1,
945 const wxPoint& pos = wxDefaultPosition,
946 const wxSize& size = wxDefaultSize,
947 int style=wxHW_SCROLLBAR_AUTO,
948 const wxString& name = wxPyHtmlWindowNameStr);
951 void _setCallbackInfo(PyObject* self, PyObject* _class);
954 // Set HTML page and display it. !! source is HTML document itself,
955 // it is NOT address/filename of HTML document. If you want to
956 // specify document location, use LoadPage() istead
957 // Return value : False if an error occurred, True otherwise
958 bool SetPage(const wxString& source);
960 // Load HTML page from given location. Location can be either
961 // a) /usr/wxGTK2/docs/html/wx.htm
962 // b) http://www.somewhere.uk/document.htm
963 // c) ftp://ftp.somesite.cz/pub/something.htm
964 // In case there is no prefix (http:,ftp:), the method
965 // will try to find it itself (1. local file, then http or ftp)
966 // After the page is loaded, the method calls SetPage() to display it.
967 // Note : you can also use path relative to previously loaded page
968 // Return value : same as SetPage
969 bool LoadPage(const wxString& location);
971 // Loads HTML page from file
972 bool LoadFile(const wxString& filename);
974 // Append to current page
975 bool AppendToPage(const wxString& source);
977 // Returns full location of opened page
978 wxString GetOpenedPage();
980 // Returns anchor within opened page
981 wxString GetOpenedAnchor();
983 // Returns <TITLE> of opened page or empty string otherwise
984 wxString GetOpenedPageTitle();
986 // Sets frame in which page title will be displayed. Format is format of
987 // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
988 void SetRelatedFrame(wxFrame* frame, const wxString& format);
989 wxFrame* GetRelatedFrame();
991 // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
992 // will be displayed. Default is -1 = no messages.
993 void SetRelatedStatusBar(int bar);
995 // Sets fonts to be used when displaying HTML page.
997 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
999 if (sizes) temp = int_LIST_helper(sizes);
1000 self->SetFonts(normal_face, fixed_face, temp);
1006 // Sets font sizes to be relative to the given size or the system
1007 // default size; use either specified or default font
1008 void SetStandardFonts(int size = -1,
1009 const wxString& normal_face = wxPyEmptyString,
1010 const wxString& fixed_face = wxPyEmptyString);
1013 void, SetLabel(const wxString& title),
1016 // Sets space between text and window borders.
1017 void SetBorders(int b);
1019 // Sets the bitmap to use for background (currnetly it will be tiled,
1020 // when/if we have CSS support we could add other possibilities...)
1021 void SetBackgroundImage(const wxBitmap& bmpBg);
1023 // Saves custom settings into cfg config. it will use the path 'path'
1024 // if given, otherwise it will save info into currently selected path.
1025 // saved values : things set by SetFonts, SetBorders.
1026 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1027 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1029 // Goes to previous/next page (in browsing history)
1030 // Returns True if successful, False otherwise
1032 bool HistoryForward();
1033 bool HistoryCanBack();
1034 bool HistoryCanForward();
1037 void HistoryClear();
1039 // Returns pointer to conteiners/cells structure.
1040 wxHtmlContainerCell* GetInternalRepresentation();
1042 // Returns a pointer to the parser.
1043 wxHtmlWinParser* GetParser();
1045 bool ScrollToAnchor(const wxString& anchor);
1046 bool HasAnchor(const wxString& anchor);
1049 static void AddFilter(wxPyHtmlFilter *filter);
1051 // Helper functions to select parts of page:
1052 void SelectWord(const wxPoint& pos);
1053 void SelectLine(const wxPoint& pos);
1056 // Convert selection to text:
1057 wxString SelectionToText();
1059 // Converts current page to text:
1062 void OnLinkClicked(const wxHtmlLinkInfo& link);
1063 void OnSetTitle(const wxString& title);
1064 void OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
1065 bool OnCellClicked(wxHtmlCell *cell,
1066 wxCoord x, wxCoord y,
1067 const wxMouseEvent& event);
1068 wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
1069 const wxString& url,
1070 wxString *redirect) const;
1071 %MAKE_BASE_FUNC(HtmlWindow, OnLinkClicked);
1072 %MAKE_BASE_FUNC(HtmlWindow, OnSetTitle);
1073 %MAKE_BASE_FUNC(HtmlWindow, OnCellMouseHover);
1074 %MAKE_BASE_FUNC(HtmlWindow, OnCellClicked);
1076 static wxVisualAttributes
1077 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
1079 /// Type of mouse cursor
1082 /// Standard mouse cursor (typically an arrow)
1084 /// Cursor shown over links
1086 /// Cursor shown over selectable text
1090 // Returns standard HTML cursor as used by wxHtmlWindow
1091 static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
1095 // // wxHtmlWindowInterface methods:
1096 // virtual void SetHTMLWindowTitle(const wxString& title);
1097 // virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link);
1098 // virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
1099 // const wxString& url,
1100 // wxString *redirect) const;
1101 // virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
1102 // const wxPoint& pos) const;
1103 // virtual wxWindow* GetHTMLWindow();
1104 // virtual wxColour GetHTMLBackgroundColour() const;
1105 // virtual void SetHTMLBackgroundColour(const wxColour& clr);
1106 // virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
1107 // virtual void SetHTMLStatusText(const wxString& text);
1108 // virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
1115 //---------------------------------------------------------------------------
1116 //---------------------------------------------------------------------------
1120 MustHaveApp(wxHtmlDCRenderer);
1122 class wxHtmlDCRenderer : public wxObject {
1125 ~wxHtmlDCRenderer();
1127 void SetDC(wxDC *dc, int maxwidth);
1128 void SetSize(int width, int height);
1129 void SetHtmlText(const wxString& html,
1130 const wxString& basepath = wxPyEmptyString,
1132 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
1134 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1136 if (sizes) temp = int_LIST_helper(sizes);
1137 self->SetFonts(normal_face, fixed_face, temp);
1143 // Sets font sizes to be relative to the given size or the system
1144 // default size; use either specified or default font
1145 void SetStandardFonts(int size = -1,
1146 const wxString& normal_face = wxPyEmptyString,
1147 const wxString& fixed_face = wxPyEmptyString);
1149 int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
1150 int dont_render = FALSE, int to = INT_MAX);
1151 int GetTotalHeight();
1152 // returns total height of the html document
1153 // (compare Render's return value with this)
1164 MustHaveApp(wxHtmlPrintout);
1166 class wxHtmlPrintout : public wxPyPrintout {
1168 wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
1169 //~wxHtmlPrintout(); wxPrintPreview object takes ownership...
1171 void SetHtmlText(const wxString& html,
1172 const wxString &basepath = wxPyEmptyString,
1174 void SetHtmlFile(const wxString &htmlfile);
1175 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1176 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1178 // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
1180 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1182 if (sizes) temp = int_LIST_helper(sizes);
1183 self->SetFonts(normal_face, fixed_face, temp);
1189 // Sets font sizes to be relative to the given size or the system
1190 // default size; use either specified or default font
1191 void SetStandardFonts(int size = -1,
1192 const wxString& normal_face = wxPyEmptyString,
1193 const wxString& fixed_face = wxPyEmptyString);
1195 void SetMargins(float top = 25.2, float bottom = 25.2,
1196 float left = 25.2, float right = 25.2,
1199 // Adds input filter
1200 static void AddFilter(wxHtmlFilter *filter);
1203 static void CleanUpStatics();
1208 MustHaveApp(wxHtmlEasyPrinting);
1210 class wxHtmlEasyPrinting : public wxObject {
1212 wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
1213 wxWindow *parentWindow = NULL);
1214 ~wxHtmlEasyPrinting();
1216 void PreviewFile(const wxString &htmlfile);
1217 void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1218 void PrintFile(const wxString &htmlfile);
1219 void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
1220 // void PrinterSetup();
1222 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
1223 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
1226 void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
1228 if (sizes) temp = int_LIST_helper(sizes);
1229 self->SetFonts(normal_face, fixed_face, temp);
1235 // Sets font sizes to be relative to the given size or the system
1236 // default size; use either specified or default font
1237 void SetStandardFonts(int size = -1,
1238 const wxString& normal_face = wxPyEmptyString,
1239 const wxString& fixed_face = wxPyEmptyString);
1241 wxPrintData *GetPrintData() {return m_PrintData;}
1242 wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
1247 //---------------------------------------------------------------------------
1248 //---------------------------------------------------------------------------
1252 class wxHtmlBookRecord {
1254 wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
1255 const wxString& title, const wxString& start);
1257 wxString GetBookFile();
1258 wxString GetTitle();
1259 wxString GetStart();
1260 wxString GetBasePath();
1262 void SetContentsRange(int start, int end);
1263 int GetContentsStart();
1264 int GetContentsEnd();
1266 void SetTitle(const wxString& title);
1267 void SetBasePath(const wxString& path);
1268 void SetStart(const wxString& start);
1270 wxString GetFullPath(const wxString &page) const;
1273 //---------------------------------------------------------------------------
1274 // WXWIN_COMPATIBILITY_2_4
1276 struct wxHtmlContentsItem
1279 int GetLevel() { return self->m_Level; }
1280 int GetID() { return self->m_ID; }
1281 wxString GetName() { return self->m_Name; }
1282 wxString GetPage() { return self->m_Page; }
1283 wxHtmlBookRecord* GetBook() { return self->m_Book; }
1287 //---------------------------------------------------------------------------
1289 class wxHtmlSearchStatus
1292 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
1293 // const wxString& book = wxPyEmptyString);
1298 const wxString& GetName();
1301 //---------------------------------------------------------------------------
1303 class wxHtmlHelpData {
1308 void SetTempDir(const wxString& path);
1309 bool AddBook(const wxString& book);
1310 // bool AddBookParam(const wxString& title, const wxString& contfile,
1311 // const wxString& indexfile=wxPyEmptyString,
1312 // const wxString& deftopic=wxPyEmptyString,
1313 // const wxString& path=wxPyEmptyString);
1315 wxString FindPageByName(const wxString& page);
1316 wxString FindPageById(int id);
1318 // TODO: this one needs fixed...
1319 const wxHtmlBookRecArray& GetBookRecArray();
1323 //---------------------------------------------------------------------------
1336 wxHF_ICONS_BOOK_CHAPTER,
1356 wxID_HTML_BOOKMARKSLIST,
1357 wxID_HTML_BOOKMARKSADD,
1358 wxID_HTML_BOOKMARKSREMOVE,
1360 wxID_HTML_INDEXPAGE,
1361 wxID_HTML_INDEXLIST,
1362 wxID_HTML_INDEXTEXT,
1363 wxID_HTML_INDEXBUTTON,
1364 wxID_HTML_INDEXBUTTONALL,
1366 wxID_HTML_SEARCHPAGE,
1367 wxID_HTML_SEARCHTEXT,
1368 wxID_HTML_SEARCHLIST,
1369 wxID_HTML_SEARCHBUTTON,
1370 wxID_HTML_SEARCHCHOICE,
1376 MustHaveApp(wxHtmlHelpWindow);
1378 class wxHtmlHelpWindow : public wxWindow
1381 %pythonAppend wxHtmlHelpWindow "self._setOORInfo(self)"
1382 %pythonAppend wxHtmlHelpWindow() ""
1383 %typemap(out) wxHtmlHelpWindow*; // turn off this typemap
1385 wxHtmlHelpWindow(wxWindow* parent, wxWindowID wxWindowID,
1386 const wxPoint& pos = wxDefaultPosition,
1387 const wxSize& size = wxDefaultSize,
1388 int style = wxTAB_TRAVERSAL|wxNO_BORDER,
1389 int helpStyle = wxHF_DEFAULT_STYLE,
1390 wxHtmlHelpData* data = NULL);
1391 %RenameCtor(PreHtmlHelpWindow, wxHtmlHelpWindow(wxHtmlHelpData* data = NULL));
1393 // Turn it back on again
1394 %typemap(out) wxHtmlHelpWindow* { $result = wxPyMake_wxObject($1, $owner); }
1396 bool Create(wxWindow* parent, wxWindowID id,
1397 const wxPoint& pos = wxDefaultPosition,
1398 const wxSize& size = wxDefaultSize,
1399 int style = wxTAB_TRAVERSAL|wxNO_BORDER,
1400 int helpStyle = wxHF_DEFAULT_STYLE);
1402 wxHtmlHelpData* GetData();
1403 wxHtmlHelpController* GetController() const;
1405 %disownarg( wxHtmlHelpController* controller );
1406 void SetController(wxHtmlHelpController* controller);
1407 %cleardisown( wxHtmlHelpController* controller );
1409 // Displays page x. If not found it will offect the user a choice of
1411 // Looking for the page runs in these steps:
1412 // 1. try to locate file named x (if x is for example "doc/howto.htm")
1413 // 2. try to open starting page of book x
1414 // 3. try to find x in contents (if x is for example "How To ...")
1415 // 4. try to find x in index (if x is for example "How To ...")
1416 bool Display(const wxString& x);
1418 // Alternative version that works with numeric ID.
1419 // (uses extension to MS format, <param name="ID" value=id>, see docs)
1420 %Rename(DisplayID, bool, Display(int id));
1422 // Displays help window and focuses contents.
1423 bool DisplayContents();
1425 // Displays help window and focuses index.
1426 bool DisplayIndex();
1428 // Searches for keyword. Returns true and display page if found, return
1430 // Syntax of keyword is Altavista-like:
1431 // * words are separated by spaces
1432 // (but "\"hello world\"" is only one world "hello world")
1433 // * word may be pretended by + or -
1434 // (+ : page must contain the word ; - : page can't contain the word)
1435 // * if there is no + or - before the word, + is default
1436 bool KeywordSearch(const wxString& keyword,
1437 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
1439 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
1441 // Saves custom settings into cfg config. it will use the path 'path'
1442 // if given, otherwise it will save info into currently selected path.
1443 // saved values : things set by SetFonts, SetBorders.
1444 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
1445 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
1447 // call this to let wxHtmlHelpWindow know page changed
1448 void NotifyPageChanged();
1450 // Refreshes Contents and Index tabs
1451 void RefreshLists();
1453 // Gets the HTML window
1454 wxHtmlWindow* GetHtmlWindow() const;
1456 // Gets the splitter window
1457 wxSplitterWindow* GetSplitterWindow();
1460 wxToolBar* GetToolBar() const;
1462 // Gets the configuration data
1463 wxHtmlHelpFrameCfg& GetCfgData();
1465 // Gets the tree control
1466 wxTreeCtrl *GetTreeCtrl() const;
1471 class wxHtmlWindowEvent: public wxNotifyEvent
1474 wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
1475 wxNotifyEvent(commandType, id);
1477 void SetURL(const wxString& url);
1478 const wxString& GetURL() const;
1483 MustHaveApp(wxHtmlHelpFrame);
1485 class wxHtmlHelpFrame : public wxFrame {
1487 %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)"
1488 %pythonAppend wxHtmlHelpFrame() ""
1489 %typemap(out) wxHtmlHelpFrame*; // turn off this typemap
1491 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
1492 const wxString& title = wxPyEmptyString,
1493 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
1494 %RenameCtor(PreHtmlHelpFrame, wxHtmlHelpFrame(wxHtmlHelpData* data = NULL));
1496 // Turn it back on again
1497 %typemap(out) wxHtmlHelpFrame* { $result = wxPyMake_wxObject($1, $owner); }
1499 bool Create(wxWindow* parent, wxWindowID id,
1500 const wxString& title = wxPyEmptyString,
1501 int style = wxHF_DEFAULT_STYLE);
1503 wxHtmlHelpData* GetData();
1504 void SetTitleFormat(const wxString& format);
1506 void AddGrabIfNeeded();
1508 /// Returns the help controller associated with the window.
1509 wxHtmlHelpController* GetController() const;
1511 /// Sets the help controller associated with the window.
1512 %disownarg( wxHtmlHelpController* controller );
1513 void SetController(wxHtmlHelpController* controller);
1514 %cleardisown( wxHtmlHelpController* controller );
1516 /// Returns the help window.
1517 wxHtmlHelpWindow* GetHelpWindow() const;
1520 %# For compatibility from before the refactor
1521 def Display(self, x):
1522 return self.GetHelpWindow().Display(x)
1523 def DisplayID(self, x):
1524 return self.GetHelpWindow().DisplayID(id)
1525 def DisplayContents(self):
1526 return self.GetHelpWindow().DisplayContents()
1527 def DisplayIndex(self):
1528 return self.GetHelpWindow().DisplayIndex()
1530 def KeywordSearch(self, keyword):
1531 return self.GetHelpWindow().KeywordSearch(keyword)
1533 def UseConfig(self, config, rootpath=""):
1534 return self.GetHelpWindow().UseConfig(config, rootpath)
1535 def ReadCustomization(self, config, rootpath=""):
1536 return self.GetHelpWindow().ReadCustomization(config, rootpath)
1537 def WriteCustomization(self, config, rootpath=""):
1538 return self.GetHelpWindow().WriteCustomization(config, rootpath)
1544 MustHaveApp(wxHtmlHelpDialog);
1546 class wxHtmlHelpDialog : public wxDialog
1549 %pythonAppend wxHtmlHelpDialog "self._setOORInfo(self)"
1550 %pythonAppend wxHtmlHelpDialog() ""
1551 %typemap(out) wxHtmlHelpDialog*; // turn off this typemap
1553 wxHtmlHelpDialog(wxWindow* parent, wxWindowID wxWindowID,
1554 const wxString& title = wxPyEmptyString,
1555 int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
1556 %RenameCtor(PreHtmlHelpDialog, wxHtmlHelpDialog(wxHtmlHelpData* data = NULL));
1558 // Turn it back on again
1559 %typemap(out) wxHtmlHelpDialog* { $result = wxPyMake_wxObject($1, $owner); }
1561 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxPyEmptyString,
1562 int style = wxHF_DEFAULT_STYLE);
1564 /// Returns the data associated with this dialog.
1565 wxHtmlHelpData* GetData();
1567 /// Returns the controller that created this dialog.
1568 wxHtmlHelpController* GetController() const;
1570 /// Sets the controller associated with this dialog.
1571 %disownarg( wxHtmlHelpController* controller );
1572 void SetController(wxHtmlHelpController* controller);
1573 %cleardisown( wxHtmlHelpController* controller );
1575 /// Returns the help window.
1576 wxHtmlHelpWindow* GetHelpWindow() const;
1578 // Sets format of title of the frame. Must contain exactly one "%s"
1579 // (for title of displayed HTML page)
1580 void SetTitleFormat(const wxString& format);
1582 // Override to add custom buttons to the toolbar
1583 // virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {};
1588 //---------------------------------------------------------------------------
1591 // TODO: Make virtual methods of this class overridable in Python.
1593 MustHaveApp(wxHelpControllerBase);
1595 class wxHelpControllerBase: public wxObject
1598 // wxHelpControllerBase(wxWindow* parentWindow = NULL);
1599 // ~wxHelpControllerBase();
1601 %nokwargs Initialize;
1602 virtual bool Initialize(const wxString& file, int server );
1603 virtual bool Initialize(const wxString& file);
1605 virtual void SetViewer(const wxString& viewer, long flags = 0);
1607 // If file is "", reloads file given in Initialize
1608 virtual bool LoadFile(const wxString& file = wxEmptyString) /* = 0 */;
1610 // Displays the contents
1611 virtual bool DisplayContents(void) /* = 0 */;
1613 %nokwargs DisplaySection;
1615 // Display the given section
1616 virtual bool DisplaySection(int sectionNo) /* = 0 */;
1618 // Display the section using a context id
1619 virtual bool DisplayContextPopup(int contextId);
1621 // Display the text in a popup, if possible
1622 virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
1624 // By default, uses KeywordSection to display a topic. Implementations
1625 // may override this for more specific behaviour.
1626 virtual bool DisplaySection(const wxString& section);
1628 virtual bool DisplayBlock(long blockNo) /* = 0 */;
1629 virtual bool KeywordSearch(const wxString& k,
1630 wxHelpSearchMode mode = wxHELP_SEARCH_ALL) /* = 0 */;
1632 /// Allows one to override the default settings for the help frame.
1633 virtual void SetFrameParameters(const wxString& title,
1635 const wxPoint& pos = wxDefaultPosition,
1636 bool newFrameEachTime = false);
1638 /// Obtains the latest settings used by the help frame and the help
1640 virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
1641 wxPoint *pos = NULL,
1642 bool *newFrameEachTime = NULL);
1644 virtual bool Quit() /* = 0 */;
1646 virtual void OnQuit();
1648 /// Set the window that can optionally be used for the help window's parent.
1649 virtual void SetParentWindow(wxWindow* win);
1651 /// Get the window that can optionally be used for the help window's parent.
1652 virtual wxWindow* GetParentWindow() const;
1659 MustHaveApp(wxHtmlHelpController);
1661 class wxHtmlHelpController : public wxHelpControllerBase
1664 // %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
1666 wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
1667 ~wxHtmlHelpController();
1669 wxHtmlHelpWindow* GetHelpWindow();
1670 void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
1672 wxHtmlHelpFrame* GetFrame();
1673 wxHtmlHelpDialog* GetDialog();
1675 void SetTitleFormat(const wxString& format);
1676 void SetTempDir(const wxString& path);
1677 bool AddBook(const wxString& book, int show_wait_msg = false);
1678 void Display(const wxString& x);
1679 %Rename(DisplayID, void, Display(int id));
1680 void DisplayContents();
1681 void DisplayIndex();
1682 bool KeywordSearch(const wxString& keyword);
1683 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
1684 void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1685 void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
1687 void MakeModalIfNeeded();
1688 wxWindow* FindTopLevelWindow();
1694 * A convenience class particularly for use on wxMac,
1695 * where you can only show modal dialogs from a modal
1700 * wxHtmlModalHelp help(parent, filename, topic);
1702 * If topic is empty, the help contents is displayed.
1705 class wxHtmlModalHelp
1708 wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
1709 const wxString& topic = wxEmptyString,
1710 int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
1714 //---------------------------------------------------------------------------
1716 wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler");
1717 wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
1718 wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow");
1719 wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter");
1721 //---------------------------------------------------------------------------
1722 //---------------------------------------------------------------------------