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 %include _html_rename.i
 
  44 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
  45 MAKE_CONST_WXSTRING2(HtmlWindowNameStr,    wxT("htmlWindow"))
 
  46 MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout"))
 
  47 MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("Printing"))
 
  50 // TODO: Split this file into multiple %included files that coresponds to the
 
  51 // wx/html include files (more or less.)
 
  53 //---------------------------------------------------------------------------
 
  54 //---------------------------------------------------------------------------
 
  65     wxHTML_CLR_FOREGROUND,
 
  66     wxHTML_CLR_BACKGROUND,
 
  76     wxHTML_INDENT_HORIZONTAL,
 
  77     wxHTML_INDENT_VERTICAL,
 
  81     wxHTML_COND_ISIMAGEMAP,
 
 103 // enums for wxHtmlWindow::OnOpeningURL
 
 104 enum wxHtmlOpeningStatus
 
 120 //---------------------------------------------------------------------------
 
 122 class wxHtmlLinkInfo : public wxObject {
 
 124     wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
 
 126     wxString GetTarget();
 
 127     wxMouseEvent* GetEvent();
 
 128     wxHtmlCell* GetHtmlCell();
 
 130     void SetEvent(const wxMouseEvent *e);
 
 131     void SetHtmlCell(const wxHtmlCell * e);
 
 134 //---------------------------------------------------------------------------
 
 136 class wxHtmlTag : public wxObject {
 
 138     // Never need to create a new tag from Python...
 
 139     //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
 
 142     bool HasParam(const wxString& par);
 
 143     wxString GetParam(const wxString& par, int with_commas = false);
 
 145     // Can't do this one as-is, but GetParam should be enough...
 
 146     //int ScanParam(const wxString& par, const char *format, void* param);
 
 148     wxString GetAllParams();
 
 155 //---------------------------------------------------------------------------
 
 157 class wxHtmlParser : public wxObject {
 
 159     // wxHtmlParser();  This is an abstract base class...
 
 161     void SetFS(wxFileSystem *fs);
 
 162     wxFileSystem* GetFS();
 
 163     wxObject* Parse(const wxString& source);
 
 164     void InitParser(const wxString& source);
 
 166     void DoParsing(int begin_pos, int end_pos);
 
 168     // wxObject* GetProduct();
 
 170     void AddTagHandler(wxHtmlTagHandler *handler);
 
 171     wxString* GetSource();
 
 172     void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
 
 173     void PopTagHandler();
 
 175     // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
 
 177     // void AddText(const char* txt) = 0;
 
 178     // void AddTag(const wxHtmlTag& tag);
 
 182 //---------------------------------------------------------------------------
 
 184 class wxHtmlWinParser : public wxHtmlParser {
 
 186     wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
 
 188     void SetDC(wxDC *dc);
 
 192     wxPyHtmlWindow* GetWindow();
 
 194     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
 196         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
 198             if (sizes) temp = int_LIST_helper(sizes);
 
 199             self->SetFonts(normal_face, fixed_face, temp);
 
 205     // Sets font sizes to be relative to the given size or the system
 
 206     // default size; use either specified or default font
 
 207     void SetStandardFonts(int size = -1,
 
 208                           const wxString& normal_face = wxPyEmptyString,
 
 209                           const wxString& fixed_face = wxPyEmptyString);
 
 212     wxHtmlContainerCell* GetContainer();
 
 213     wxHtmlContainerCell* OpenContainer();
 
 214     wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
 
 215     wxHtmlContainerCell* CloseContainer();
 
 218     void SetFontSize(int s);
 
 220     void SetFontBold(int x);
 
 222     void SetFontItalic(int x);
 
 223     int GetFontUnderlined();
 
 224     void SetFontUnderlined(int x);
 
 226     void SetFontFixed(int x);
 
 228     void SetAlign(int a);
 
 229     wxColour GetLinkColor();
 
 230     void SetLinkColor(const wxColour& clr);
 
 231     wxColour GetActualColor();
 
 232     void SetActualColor(const wxColour& clr);
 
 234         GetActualColour = GetActualColor
 
 235         SetActualColour = SetActualColor
 
 237     void SetLink(const wxString& link);
 
 238     wxFont* CreateCurrentFont();
 
 239     wxHtmlLinkInfo GetLink();
 
 244 //---------------------------------------------------------------------------
 
 247 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
 
 248     DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler)
 
 250     wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
 
 252     wxHtmlParser* GetParser() { return m_Parser; }
 
 253     void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
 
 255     DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
 
 256     DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
 
 261 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
 
 263 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
 
 264 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
 
 268 %rename(HtmlTagHandler) wxPyHtmlTagHandler;
 
 269 class wxPyHtmlTagHandler : public wxObject {
 
 271     %pythonAppend wxPyHtmlTagHandler   "self._setCallbackInfo(self, HtmlTagHandler)"
 
 272     wxPyHtmlTagHandler();
 
 274     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 276     void SetParser(wxHtmlParser *parser);
 
 277     wxHtmlParser* GetParser();
 
 278     void ParseInner(const wxHtmlTag& tag);
 
 282 //---------------------------------------------------------------------------
 
 285 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
 
 286     DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler)
 
 288     wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
 
 290     wxHtmlWinParser* GetParser() { return m_WParser; }
 
 291     void ParseInner(const wxHtmlTag& tag)
 
 292         { wxHtmlWinTagHandler::ParseInner(tag); }
 
 294     DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
 
 295     DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
 
 300 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
 
 302 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
 
 303 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
 
 307 %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler;
 
 308 class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
 
 310     %pythonAppend wxPyHtmlWinTagHandler    "self._setCallbackInfo(self, HtmlWinTagHandler)"
 
 311     wxPyHtmlWinTagHandler();
 
 313     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 315     void SetParser(wxHtmlParser *parser);
 
 316     wxHtmlWinParser* GetParser();
 
 317     void ParseInner(const wxHtmlTag& tag);
 
 321 //---------------------------------------------------------------------------
 
 325 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
 
 327     wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
 
 328         m_tagHandlerClass = thc;
 
 329         Py_INCREF(m_tagHandlerClass);
 
 330         RegisterModule(this);
 
 331         wxHtmlWinParser::AddModule(this);
 
 335         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 336         Py_DECREF(m_tagHandlerClass);
 
 337         m_tagHandlerClass = NULL;
 
 338         for (size_t x=0; x < m_objArray.GetCount(); x++) {
 
 339             PyObject* obj = (PyObject*)m_objArray.Item(x);
 
 342         wxPyEndBlockThreads(blocked);
 
 345     void FillHandlersTable(wxHtmlWinParser *parser) {
 
 346         // Wave our magic wand...  (if it works it's a miracle!  ;-)
 
 348         // First, make a new instance of the tag handler
 
 349         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 350         PyObject* arg = PyTuple_New(0);
 
 351         PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
 
 354         // now figure out where it's C++ object is...
 
 355         wxPyHtmlWinTagHandler* thPtr;
 
 356         if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
 
 357             wxPyEndBlockThreads(blocked);
 
 360         wxPyEndBlockThreads(blocked);
 
 363         parser->AddTagHandler(thPtr);
 
 370     PyObject*           m_tagHandlerClass;
 
 371     wxArrayPtrVoid      m_objArray;
 
 379     void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
 
 380         // Dynamically create a new wxModule.  Refcounts tagHandlerClass
 
 381         // and adds itself to the wxModules list and to the wxHtmlWinParser.
 
 382         new wxPyHtmlTagsModule(tagHandlerClass);
 
 387 //---------------------------------------------------------------------------
 
 388 //---------------------------------------------------------------------------
 
 392 // wxHtmlSelection is data holder with information about text selection.
 
 393 // Selection is defined by two positions (beginning and end of the selection)
 
 394 // and two leaf(!) cells at these positions.
 
 395 class wxHtmlSelection
 
 401     void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
 
 402              const wxPoint& toPos, const wxHtmlCell *toCell);
 
 403     %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell));
 
 405     const wxHtmlCell *GetFromCell() const;
 
 406     const wxHtmlCell *GetToCell() const;
 
 408     // these values are in absolute coordinates:
 
 409     const wxPoint& GetFromPos() const;
 
 410     const wxPoint& GetToPos() const;
 
 412     // these are From/ToCell's private data
 
 413     const wxPoint& GetFromPrivPos() const;
 
 414     const wxPoint& GetToPrivPos() const;
 
 415     void SetFromPrivPos(const wxPoint& pos);
 
 416     void SetToPrivPos(const wxPoint& pos);
 
 419     const bool IsEmpty() const;
 
 424 enum wxHtmlSelectionState
 
 426     wxHTML_SEL_OUT,     // currently rendered cell is outside the selection
 
 427     wxHTML_SEL_IN,      // ... is inside selection
 
 428     wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
 
 433 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
 
 434 // differently e.g. when inside text selection or outside it.
 
 435 class wxHtmlRenderingState
 
 438     wxHtmlRenderingState();
 
 439     ~wxHtmlRenderingState();
 
 441     void SetSelectionState(wxHtmlSelectionState s);
 
 442     wxHtmlSelectionState GetSelectionState() const;
 
 444     void SetFgColour(const wxColour& c);
 
 445     const wxColour& GetFgColour() const;
 
 446     void SetBgColour(const wxColour& c);
 
 447     const wxColour& GetBgColour() const;
 
 452 // HTML rendering customization. This class is used when rendering wxHtmlCells
 
 454 class wxHtmlRenderingStyle
 
 457     virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
 
 458     virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
 
 462 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
 
 465     virtual wxColour GetSelectedTextColour(const wxColour& clr);
 
 466     virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
 
 471 // Information given to cells when drawing them. Contains rendering state,
 
 472 // selection information and rendering style object that can be used to
 
 473 // customize the output.
 
 474 class wxHtmlRenderingInfo
 
 477     wxHtmlRenderingInfo();
 
 478     ~wxHtmlRenderingInfo();
 
 480     void SetSelection(wxHtmlSelection *s);
 
 481     wxHtmlSelection *GetSelection() const;
 
 483     void SetStyle(wxHtmlRenderingStyle *style);
 
 484     wxHtmlRenderingStyle& GetStyle();
 
 486     wxHtmlRenderingState& GetState();
 
 489 //---------------------------------------------------------------------------
 
 495     wxHTML_FIND_EXACT             = 1,
 
 496     wxHTML_FIND_NEAREST_BEFORE    = 2,
 
 497     wxHTML_FIND_NEAREST_AFTER     = 4
 
 501 class wxHtmlCell : public wxObject {
 
 511     // Returns the maximum possible length of the cell.
 
 512     // Call Layout at least once before using GetMaxTotalWidth()
 
 513     int GetMaxTotalWidth() const;
 
 515     const wxString& GetId() const;
 
 516     void SetId(const wxString& id);
 
 517     wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
 
 518     wxHtmlCell* GetNext();
 
 519     wxHtmlContainerCell* GetParent();
 
 520     wxHtmlCell* GetFirstChild() const;
 
 522     // Returns cursor to be used when mouse is over the cell:
 
 523     wxCursor GetCursor() const;
 
 525     // Formatting cells are not visible on the screen, they only alter
 
 527     bool IsFormattingCell() const;
 
 530     void SetLink(const wxHtmlLinkInfo& link);
 
 531     void SetNext(wxHtmlCell *cell);
 
 532     void SetParent(wxHtmlContainerCell *p);
 
 533     void SetPos(int x, int y);
 
 535     void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
 
 536               wxHtmlRenderingInfo& info);
 
 537     void DrawInvisible(wxDC& dc, int x, int y,
 
 538               wxHtmlRenderingInfo& info);
 
 539     const wxHtmlCell* Find(int condition, const void* param);
 
 541     bool AdjustPagebreak(int* INOUT);
 
 542     void SetCanLiveOnPagebreak(bool can);
 
 544     // Can the line be broken before this cell?
 
 545     bool IsLinebreakAllowed() const;
 
 547     // Returns True for simple == terminal cells, i.e. not composite ones.
 
 548     // This if for internal usage only and may disappear in future versions!
 
 549     bool IsTerminalCell() const;
 
 551     // Find a cell inside this cell positioned at the given coordinates
 
 552     // (relative to this's positions). Returns NULL if no such cell exists.
 
 553     // The flag can be used to specify whether to look for terminal or
 
 554     // nonterminal cells or both. In either case, returned cell is deepest
 
 555     // cell in cells tree that contains [x,y].
 
 556     wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
 
 557                                   unsigned flags = wxHTML_FIND_EXACT) const;
 
 559     // Returns absolute position of the cell on HTML canvas
 
 560     wxPoint GetAbsPos() const;
 
 562     // Returns first (last) terminal cell inside this cell. It may return NULL,
 
 563     // but it is rare -- only if there are no terminals in the tree.
 
 564     wxHtmlCell *GetFirstTerminal() const ;
 
 565     wxHtmlCell *GetLastTerminal() const ;
 
 567     // Returns cell's depth, i.e. how far under the root cell it is
 
 568     // (if it is the root, depth is 0)
 
 569     unsigned GetDepth() const;
 
 571     // Returns True if the cell appears before 'cell' in natural order of
 
 572     // cells (= as they are read). If cell A is (grand)parent of cell B,
 
 573     // then both A.IsBefore(B) and B.IsBefore(A) always return True.
 
 574     bool IsBefore(wxHtmlCell *cell) const;
 
 576     // Converts the cell into text representation. If sel != NULL then
 
 577     // only part of the cell inside the selection is converted.
 
 578     wxString ConvertToText(wxHtmlSelection *sel) const;
 
 582 class  wxHtmlWordCell : public wxHtmlCell
 
 585     wxHtmlWordCell(const wxString& word, wxDC& dc);
 
 589 class wxHtmlContainerCell : public wxHtmlCell {
 
 591     wxHtmlContainerCell(wxHtmlContainerCell *parent);
 
 593     void InsertCell(wxHtmlCell *cell);
 
 594     void SetAlignHor(int al);
 
 596     void SetAlignVer(int al);
 
 598     void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
 
 599     int GetIndent(int ind);
 
 600     int GetIndentUnits(int ind);
 
 601     void SetAlign(const wxHtmlTag& tag);
 
 602     void SetWidthFloat(int w, int units);
 
 603     %Rename(SetWidthFloatFromTag, void,  SetWidthFloat(const wxHtmlTag& tag));
 
 604     void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
 
 605     void SetBackgroundColour(const wxColour& clr);
 
 606     wxColour GetBackgroundColour();
 
 607     void SetBorder(const wxColour& clr1, const wxColour& clr2);
 
 608     wxHtmlCell* GetFirstChild();
 
 609     %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
 
 614 class wxHtmlColourCell : public wxHtmlCell {
 
 616     wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
 
 621 class  wxHtmlFontCell : public wxHtmlCell
 
 624     wxHtmlFontCell(wxFont *font);
 
 628 class wxHtmlWidgetCell : public wxHtmlCell {
 
 630     wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
 
 637 //---------------------------------------------------------------------------
 
 639 //---------------------------------------------------------------------------
 
 643 %{ // here's the C++ version
 
 644 class wxPyHtmlFilter : public wxHtmlFilter {
 
 645     DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter)
 
 647     wxPyHtmlFilter() : wxHtmlFilter() {}
 
 649     // returns True if this filter is able to open&read given file
 
 650     virtual bool CanRead(const wxFSFile& file) const {
 
 653         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 654         if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
 
 655             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 656             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 659         wxPyEndBlockThreads(blocked);
 
 664     // Reads given file and returns HTML document.
 
 665     // Returns empty string if opening failed
 
 666     virtual wxString ReadFile(const wxFSFile& file) const {
 
 669         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 670         if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
 
 671             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 673             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
 
 676                 rval = Py2wxString(ro);
 
 680         wxPyEndBlockThreads(blocked);
 
 687 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
 
 691 // And now the version seen by SWIG
 
 693 %rename(HtmlFilter) wxPyHtmlFilter;
 
 694 class wxPyHtmlFilter : public wxObject {
 
 696     %pythonAppend wxPyHtmlFilter   "self._setCallbackInfo(self, HtmlFilter)"
 
 699     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 703 // TODO: wxHtmlFilterHTML
 
 706 //---------------------------------------------------------------------------
 
 708 //---------------------------------------------------------------------------
 
 712 class wxPyHtmlWindow : public wxHtmlWindow {
 
 713     DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow)
 
 715     wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
 
 716                    const wxPoint& pos = wxDefaultPosition,
 
 717                    const wxSize& size = wxDefaultSize,
 
 718                    long style = wxHW_DEFAULT_STYLE,
 
 719                    const wxString& name = wxPyHtmlWindowNameStr)
 
 720         : wxHtmlWindow(parent, id, pos, size, style, name)  {};
 
 721     wxPyHtmlWindow() : wxHtmlWindow() {};
 
 723     bool ScrollToAnchor(const wxString& anchor) {
 
 724         return wxHtmlWindow::ScrollToAnchor(anchor);
 
 727     bool HasAnchor(const wxString& anchor) {
 
 728         const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
 
 732     void OnLinkClicked(const wxHtmlLinkInfo& link);
 
 733     void base_OnLinkClicked(const wxHtmlLinkInfo& link);
 
 735     wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
 
 737                                       wxString *redirect) const;
 
 739     DEC_PYCALLBACK__STRING(OnSetTitle);
 
 740     DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
 
 741     DEC_PYCALLBACK__CELLINTINTME(OnCellClicked);
 
 745 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
 
 746 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
 
 747 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
 
 748 IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
 
 751 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
 
 753     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 754     if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
 
 755         PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
 
 756         wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 759     wxPyEndBlockThreads(blocked);
 
 761         wxHtmlWindow::OnLinkClicked(link);
 
 763 void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
 
 764     wxHtmlWindow::OnLinkClicked(link);
 
 768 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
 
 770                                                  wxString *redirect) const {
 
 772     wxHtmlOpeningStatus rval;
 
 773     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 774     if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
 
 776         PyObject* s = wx2PyString(url);
 
 777         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
 
 779         if (PyString_Check(ro)
 
 780 #if PYTHON_API_VERSION >= 1009
 
 781             || PyUnicode_Check(ro)
 
 784             *redirect = Py2wxString(ro);
 
 785             rval = wxHTML_REDIRECT;
 
 788             PyObject* num = PyNumber_Int(ro);
 
 789             rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
 
 794     wxPyEndBlockThreads(blocked);
 
 796         rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
 
 805 MustHaveApp(wxPyHtmlWindow);
 
 807 %rename(HtmlWindow) wxPyHtmlWindow;
 
 808 class wxPyHtmlWindow : public wxScrolledWindow {
 
 810     %pythonAppend wxPyHtmlWindow      "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
 
 811     %pythonAppend wxPyHtmlWindow()    ""
 
 812     %typemap(out) wxPyHtmlWindow*;    // turn off this typemap
 
 814     wxPyHtmlWindow(wxWindow *parent, int id = -1,
 
 815                  const wxPoint& pos = wxDefaultPosition,
 
 816                  const wxSize& size = wxDefaultSize,
 
 817                  int style=wxHW_DEFAULT_STYLE,
 
 818                  const wxString& name = wxPyHtmlWindowNameStr);
 
 819     %RenameCtor(PreHtmlWindow, wxPyHtmlWindow());
 
 821     // Turn it back on again
 
 822     %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
 824     bool Create(wxWindow *parent, int id = -1,
 
 825                 const wxPoint& pos = wxDefaultPosition,
 
 826                 const wxSize& size = wxDefaultSize,
 
 827                 int style=wxHW_SCROLLBAR_AUTO,
 
 828                 const wxString& name = wxPyHtmlWindowNameStr);
 
 831     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 834     // Set HTML page and display it. !! source is HTML document itself,
 
 835     // it is NOT address/filename of HTML document. If you want to
 
 836     // specify document location, use LoadPage() istead
 
 837     // Return value : False if an error occurred, True otherwise
 
 838     bool SetPage(const wxString& source);
 
 840     // Load HTML page from given location. Location can be either
 
 841     // a) /usr/wxGTK2/docs/html/wx.htm
 
 842     // b) http://www.somewhere.uk/document.htm
 
 843     // c) ftp://ftp.somesite.cz/pub/something.htm
 
 844     // In case there is no prefix (http:,ftp:), the method
 
 845     // will try to find it itself (1. local file, then http or ftp)
 
 846     // After the page is loaded, the method calls SetPage() to display it.
 
 847     // Note : you can also use path relative to previously loaded page
 
 848     // Return value : same as SetPage
 
 849     bool LoadPage(const wxString& location);
 
 851     // Loads HTML page from file
 
 852     bool LoadFile(const wxString& filename);
 
 854     // Append to current page
 
 855     bool AppendToPage(const wxString& source);
 
 857      // Returns full location of opened page
 
 858     wxString GetOpenedPage();
 
 860     // Returns anchor within opened page
 
 861     wxString GetOpenedAnchor();
 
 863     // Returns <TITLE> of opened page or empty string otherwise
 
 864     wxString GetOpenedPageTitle();
 
 866     // Sets frame in which page title will  be displayed. Format is format of
 
 867     // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
 
 868     void SetRelatedFrame(wxFrame* frame, const wxString& format);
 
 869     wxFrame* GetRelatedFrame();
 
 871     // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
 
 872     // will be displayed. Default is -1 = no messages.
 
 873     void SetRelatedStatusBar(int bar);
 
 875     // Sets fonts to be used when displaying HTML page.
 
 877         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
 879             if (sizes) temp = int_LIST_helper(sizes);
 
 880             self->SetFonts(normal_face, fixed_face, temp);
 
 886     // Sets font sizes to be relative to the given size or the system
 
 887     // default size; use either specified or default font
 
 888     void SetStandardFonts(int size = -1,
 
 889                           const wxString& normal_face = wxPyEmptyString,
 
 890                           const wxString& fixed_face = wxPyEmptyString);
 
 893         void, SetLabel(const wxString& title),
 
 896     // Sets space between text and window borders.
 
 897     void SetBorders(int b);
 
 899     // Sets the bitmap to use for background (currnetly it will be tiled,
 
 900     // when/if we have CSS support we could add other possibilities...)
 
 901     void SetBackgroundImage(const wxBitmap& bmpBg);
 
 903     // Saves custom settings into cfg config. it will use the path 'path'
 
 904     // if given, otherwise it will save info into currently selected path.
 
 905     // saved values : things set by SetFonts, SetBorders.
 
 906     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
 907     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
 909     // Goes to previous/next page (in browsing history)
 
 910     // Returns True if successful, False otherwise
 
 912     bool HistoryForward();
 
 913     bool HistoryCanBack();
 
 914     bool HistoryCanForward();
 
 919     // Returns pointer to conteiners/cells structure.
 
 920     wxHtmlContainerCell* GetInternalRepresentation();
 
 922     // Returns a pointer to the parser.
 
 923     wxHtmlWinParser* GetParser();
 
 925     bool ScrollToAnchor(const wxString& anchor);
 
 926     bool HasAnchor(const wxString& anchor);
 
 929     static void AddFilter(wxPyHtmlFilter *filter);
 
 931     // Helper functions to select parts of page:
 
 932     void SelectWord(const wxPoint& pos);
 
 933     void SelectLine(const wxPoint& pos);
 
 936     // Convert selection to text:
 
 937     wxString SelectionToText();
 
 939     // Converts current page to text:
 
 942     void base_OnLinkClicked(const wxHtmlLinkInfo& link);
 
 943     void base_OnSetTitle(const wxString& title);
 
 944     void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
 
 945     void base_OnCellClicked(wxHtmlCell *cell,
 
 946                             wxCoord x, wxCoord y,
 
 947                             const wxMouseEvent& event);
 
 949     static wxVisualAttributes
 
 950     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 956 //---------------------------------------------------------------------------
 
 957 //---------------------------------------------------------------------------
 
 961 MustHaveApp(wxHtmlDCRenderer);
 
 963 class wxHtmlDCRenderer : public wxObject {
 
 968     void SetDC(wxDC *dc, int maxwidth);
 
 969     void SetSize(int width, int height);
 
 970     void SetHtmlText(const wxString& html,
 
 971                      const wxString& basepath = wxPyEmptyString,
 
 973     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
 975         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
 977             if (sizes) temp = int_LIST_helper(sizes);
 
 978             self->SetFonts(normal_face, fixed_face, temp);
 
 984     // Sets font sizes to be relative to the given size or the system
 
 985     // default size; use either specified or default font
 
 986     void SetStandardFonts(int size = -1,
 
 987                           const wxString& normal_face = wxPyEmptyString,
 
 988                           const wxString& fixed_face = wxPyEmptyString);
 
 990     int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX,
 
 991                //int *known_pagebreaks = NULL, int number_of_pages = 0
 
 992                int* choices=NULL, int LCOUNT = 0
 
 994     int GetTotalHeight();
 
 995                 // returns total height of the html document
 
 996                 // (compare Render's return value with this)
 
1007 MustHaveApp(wxHtmlPrintout);
 
1009 class wxHtmlPrintout : public wxPyPrintout {
 
1011     wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
 
1012     //~wxHtmlPrintout();   wxPrintPreview object takes ownership...
 
1014     void SetHtmlText(const wxString& html,
 
1015                      const wxString &basepath = wxPyEmptyString,
 
1017     void SetHtmlFile(const wxString &htmlfile);
 
1018     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1019     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1021     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
1023         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1025             if (sizes) temp = int_LIST_helper(sizes);
 
1026             self->SetFonts(normal_face, fixed_face, temp);
 
1032     // Sets font sizes to be relative to the given size or the system
 
1033     // default size; use either specified or default font
 
1034     void SetStandardFonts(int size = -1,
 
1035                           const wxString& normal_face = wxPyEmptyString,
 
1036                           const wxString& fixed_face = wxPyEmptyString);
 
1038     void SetMargins(float top = 25.2, float bottom = 25.2,
 
1039                     float left = 25.2, float right = 25.2,
 
1042     // Adds input filter
 
1043     static void AddFilter(wxHtmlFilter *filter);
 
1046     static void CleanUpStatics();
 
1051 MustHaveApp(wxHtmlEasyPrinting);
 
1053 class wxHtmlEasyPrinting : public wxObject {
 
1055     wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
 
1056                        wxWindow *parentWindow = NULL);
 
1057     ~wxHtmlEasyPrinting();
 
1059     void PreviewFile(const wxString &htmlfile);
 
1060     void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1061     void PrintFile(const wxString &htmlfile);
 
1062     void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1063 //    void PrinterSetup();
 
1065     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1066     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1069         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1071             if (sizes) temp = int_LIST_helper(sizes);
 
1072             self->SetFonts(normal_face, fixed_face, temp);
 
1078     // Sets font sizes to be relative to the given size or the system
 
1079     // default size; use either specified or default font
 
1080     void SetStandardFonts(int size = -1,
 
1081                           const wxString& normal_face = wxPyEmptyString,
 
1082                           const wxString& fixed_face = wxPyEmptyString);
 
1084     wxPrintData *GetPrintData() {return m_PrintData;}
 
1085     wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
 
1090 //---------------------------------------------------------------------------
 
1091 //---------------------------------------------------------------------------
 
1095 class wxHtmlBookRecord {
 
1097     wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
 
1098                      const wxString& title, const wxString& start);
 
1100     wxString GetBookFile();
 
1101     wxString GetTitle();
 
1102     wxString GetStart();
 
1103     wxString GetBasePath();
 
1105     void SetContentsRange(int start, int end);
 
1106     int GetContentsStart();
 
1107     int GetContentsEnd();
 
1109     void SetTitle(const wxString& title);
 
1110     void SetBasePath(const wxString& path);
 
1111     void SetStart(const wxString& start);
 
1113     wxString GetFullPath(const wxString &page) const;
 
1116 //---------------------------------------------------------------------------
 
1117 // WXWIN_COMPATIBILITY_2_4
 
1119 struct wxHtmlContentsItem
 
1122         int GetLevel() { return self->m_Level; }
 
1123         int GetID() { return self->m_ID; }
 
1124         wxString GetName() { return self->m_Name; }
 
1125         wxString GetPage() { return self->m_Page; }
 
1126         wxHtmlBookRecord* GetBook() { return self->m_Book; }
 
1130 //---------------------------------------------------------------------------
 
1132 class wxHtmlSearchStatus
 
1135     //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
 
1136     //                   const wxString& book = wxPyEmptyString);
 
1141     const wxString& GetName();
 
1142     // WXWIN_COMPATIBILITY_2_4
 
1144     wxHtmlContentsItem* GetContentsItem();
 
1148 //---------------------------------------------------------------------------
 
1150 class wxHtmlHelpData {
 
1155     void SetTempDir(const wxString& path);
 
1156     bool AddBook(const wxString& book);
 
1157 //      bool AddBookParam(const wxString& title, const wxString& contfile,
 
1158 //                    const wxString& indexfile=wxPyEmptyString,
 
1159 //                    const wxString& deftopic=wxPyEmptyString,
 
1160 //                    const wxString& path=wxPyEmptyString);
 
1162     wxString FindPageByName(const wxString& page);
 
1163     wxString FindPageById(int id);
 
1165     // TODO: this one needs fixed...
 
1166     const wxHtmlBookRecArray& GetBookRecArray();
 
1168     // WXWIN_COMPATIBILITY_2_4
 
1170     wxHtmlContentsItem* GetContents();
 
1171     int GetContentsCnt();
 
1172     wxHtmlContentsItem* GetIndex();
 
1177 //---------------------------------------------------------------------------
 
1190     wxHF_ICONS_BOOK_CHAPTER,
 
1210     wxID_HTML_BOOKMARKSLIST,
 
1211     wxID_HTML_BOOKMARKSADD,
 
1212     wxID_HTML_BOOKMARKSREMOVE,
 
1214     wxID_HTML_INDEXPAGE,
 
1215     wxID_HTML_INDEXLIST,
 
1216     wxID_HTML_INDEXTEXT,
 
1217     wxID_HTML_INDEXBUTTON,
 
1218     wxID_HTML_INDEXBUTTONALL,
 
1220     wxID_HTML_SEARCHPAGE,
 
1221     wxID_HTML_SEARCHTEXT,
 
1222     wxID_HTML_SEARCHLIST,
 
1223     wxID_HTML_SEARCHBUTTON,
 
1224     wxID_HTML_SEARCHCHOICE,
 
1230 MustHaveApp(wxHtmlHelpWindow);
 
1232 class wxHtmlHelpWindow : public wxWindow
 
1235     %pythonAppend wxHtmlHelpWindow    "self._setOORInfo(self)"
 
1236     %pythonAppend wxHtmlHelpWindow()       ""
 
1237     %typemap(out) wxHtmlHelpWindow*;    // turn off this typemap
 
1239     wxHtmlHelpWindow(wxWindow* parent, wxWindowID wxWindowID,
 
1240                      const wxPoint& pos = wxDefaultPosition,
 
1241                      const wxSize& size = wxDefaultSize,
 
1242                      int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1243                      int helpStyle = wxHF_DEFAULT_STYLE,
 
1244                      wxHtmlHelpData* data = NULL);
 
1245     %RenameCtor(PreHtmlHelpWindow, wxHtmlHelpWindow(wxHtmlHelpData* data = NULL));
 
1247     // Turn it back on again
 
1248     %typemap(out) wxHtmlHelpWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
1250     bool Create(wxWindow* parent, wxWindowID id,
 
1251                 const wxPoint& pos = wxDefaultPosition,
 
1252                 const wxSize& size = wxDefaultSize,
 
1253                 int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1254                 int helpStyle = wxHF_DEFAULT_STYLE);
 
1256     wxHtmlHelpData* GetData();
 
1257     wxHtmlHelpController* GetController() const;
 
1259     %disownarg( wxHtmlHelpController* controller );
 
1260     void SetController(wxHtmlHelpController* controller);
 
1261     %cleardisown( wxHtmlHelpController* controller );
 
1263     // Displays page x. If not found it will offect the user a choice of
 
1265     // Looking for the page runs in these steps:
 
1266     // 1. try to locate file named x (if x is for example "doc/howto.htm")
 
1267     // 2. try to open starting page of book x
 
1268     // 3. try to find x in contents (if x is for example "How To ...")
 
1269     // 4. try to find x in index (if x is for example "How To ...")
 
1270     bool Display(const wxString& x);
 
1272     // Alternative version that works with numeric ID.
 
1273     // (uses extension to MS format, <param name="ID" value=id>, see docs)
 
1274     %Rename(DisplayID,  bool,  Display(int id));
 
1276     // Displays help window and focuses contents.
 
1277     bool DisplayContents();
 
1279     // Displays help window and focuses index.
 
1280     bool DisplayIndex();
 
1282     // Searches for keyword. Returns true and display page if found, return
 
1284     // Syntax of keyword is Altavista-like:
 
1285     // * words are separated by spaces
 
1286     //   (but "\"hello world\"" is only one world "hello world")
 
1287     // * word may be pretended by + or -
 
1288     //   (+ : page must contain the word ; - : page can't contain the word)
 
1289     // * if there is no + or - before the word, + is default
 
1290     bool KeywordSearch(const wxString& keyword,
 
1291                        wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
 
1293     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
 
1295     // Saves custom settings into cfg config. it will use the path 'path'
 
1296     // if given, otherwise it will save info into currently selected path.
 
1297     // saved values : things set by SetFonts, SetBorders.
 
1298     void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1299     void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1301     // call this to let wxHtmlHelpWindow know page changed
 
1302     void NotifyPageChanged();
 
1304     // Refreshes Contents and Index tabs
 
1305     void RefreshLists();
 
1307     // Gets the HTML window
 
1308     wxHtmlWindow* GetHtmlWindow() const;
 
1310     // Gets the splitter window
 
1311     wxSplitterWindow* GetSplitterWindow();
 
1314     wxToolBar* GetToolBar() const;
 
1316     // Gets the configuration data
 
1317     wxHtmlHelpFrameCfg& GetCfgData();
 
1319     // Gets the tree control
 
1320     wxTreeCtrl *GetTreeCtrl() const;
 
1325 class wxHtmlWindowEvent: public wxNotifyEvent
 
1328     wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
 
1329         wxNotifyEvent(commandType, id);
 
1331     void SetURL(const wxString& url);
 
1332     const wxString& GetURL() const;
 
1337 MustHaveApp(wxHtmlHelpFrame);
 
1339 class wxHtmlHelpFrame : public wxFrame {
 
1341     %pythonAppend wxHtmlHelpFrame    "self._setOORInfo(self)"
 
1342     %pythonAppend wxHtmlHelpFrame()       ""
 
1343     %typemap(out) wxHtmlHelpFrame*;    // turn off this typemap
 
1345     wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
 
1346                     const wxString& title = wxPyEmptyString,
 
1347                     int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
 
1348     %RenameCtor(PreHtmlHelpFrame, wxHtmlHelpFrame(wxHtmlHelpData* data = NULL));
 
1350     // Turn it back on again
 
1351     %typemap(out) wxHtmlHelpFrame* { $result = wxPyMake_wxObject($1, $owner); }
 
1353     bool Create(wxWindow* parent, wxWindowID id,
 
1354                 const wxString& title = wxPyEmptyString,
 
1355                 int style = wxHF_DEFAULT_STYLE);
 
1357     wxHtmlHelpData* GetData();
 
1358     void SetTitleFormat(const wxString& format);
 
1360     void AddGrabIfNeeded();
 
1362     /// Returns the help controller associated with the window.
 
1363     wxHtmlHelpController* GetController() const;
 
1365     /// Sets the help controller associated with the window.
 
1366     %disownarg( wxHtmlHelpController* controller );
 
1367     void SetController(wxHtmlHelpController* controller);
 
1368     %cleardisown( wxHtmlHelpController* controller );
 
1370     /// Returns the help window.
 
1371     wxHtmlHelpWindow* GetHelpWindow() const;
 
1374         %# For compatibility from before the refactor
 
1375         def Display(self, x):
 
1376             return self.GetHelpWindow().Display(x)
 
1377         def DisplayID(self, x):
 
1378             return self.GetHelpWindow().DisplayID(id)
 
1379         def DisplayContents(self):
 
1380             return self.GetHelpWindow().DisplayContents()
 
1381         def DisplayIndex(self):
 
1382             return self.GetHelpWindow().DisplayIndex()
 
1384         def KeywordSearch(self, keyword):
 
1385             return self.GetHelpWindow().KeywordSearch(keyword)
 
1387         def UseConfig(self, config, rootpath=""):
 
1388             return self.GetHelpWindow().UseConfig(config, rootpath)
 
1389         def ReadCustomization(self, config, rootpath=""):
 
1390             return self.GetHelpWindow().ReadCustomization(config, rootpath)
 
1391         def WriteCustomization(self, config, rootpath=""):
 
1392             return self.GetHelpWindow().WriteCustomization(config, rootpath)
 
1398 MustHaveApp(wxHtmlHelpDialog);
 
1400 class wxHtmlHelpDialog : public wxDialog
 
1403     %pythonAppend wxHtmlHelpDialog    "self._setOORInfo(self)"
 
1404     %pythonAppend wxHtmlHelpDialog()       ""
 
1405     %typemap(out) wxHtmlHelpDialog*;    // turn off this typemap
 
1407     wxHtmlHelpDialog(wxWindow* parent, wxWindowID wxWindowID,
 
1408                     const wxString& title = wxPyEmptyString,
 
1409                     int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
 
1410     %RenameCtor(PreHtmlHelpDialog, wxHtmlHelpDialog(wxHtmlHelpData* data = NULL));
 
1412     // Turn it back on again
 
1413     %typemap(out) wxHtmlHelpDialog* { $result = wxPyMake_wxObject($1, $owner); }
 
1415     bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxPyEmptyString,
 
1416                 int style = wxHF_DEFAULT_STYLE);
 
1418     /// Returns the data associated with this dialog.
 
1419     wxHtmlHelpData* GetData();
 
1421     /// Returns the controller that created this dialog.
 
1422     wxHtmlHelpController* GetController() const;
 
1424     /// Sets the controller associated with this dialog.
 
1425     %disownarg( wxHtmlHelpController* controller );
 
1426     void SetController(wxHtmlHelpController* controller);
 
1427     %cleardisown( wxHtmlHelpController* controller );
 
1429     /// Returns the help window.
 
1430     wxHtmlHelpWindow* GetHelpWindow() const;
 
1432     // Sets format of title of the frame. Must contain exactly one "%s"
 
1433     // (for title of displayed HTML page)
 
1434     void SetTitleFormat(const wxString& format);
 
1436     // Override to add custom buttons to the toolbar
 
1437 //    virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {};
 
1442 //---------------------------------------------------------------------------
 
1445 // TODO: Make virtual methods of this class overridable in Python.
 
1447 MustHaveApp(wxHelpControllerBase);
 
1449 class wxHelpControllerBase: public wxObject
 
1452 //    wxHelpControllerBase(wxWindow* parentWindow = NULL);
 
1453 //    ~wxHelpControllerBase();
 
1455     %nokwargs Initialize;
 
1456     virtual bool Initialize(const wxString& file, int server );
 
1457     virtual bool Initialize(const wxString& file);
 
1459     virtual void SetViewer(const wxString& viewer, long flags = 0);
 
1461     // If file is "", reloads file given  in Initialize
 
1462     virtual bool LoadFile(const wxString& file = wxEmptyString) /* = 0 */;
 
1464     // Displays the contents
 
1465     virtual bool DisplayContents(void) /* = 0 */;
 
1467     %nokwargs DisplaySection;
 
1469     // Display the given section
 
1470     virtual bool DisplaySection(int sectionNo) /* = 0 */;
 
1472     // Display the section using a context id
 
1473     virtual bool DisplayContextPopup(int contextId);
 
1475     // Display the text in a popup, if possible
 
1476     virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
 
1478     // By default, uses KeywordSection to display a topic. Implementations
 
1479     // may override this for more specific behaviour.
 
1480     virtual bool DisplaySection(const wxString& section);
 
1482     virtual bool DisplayBlock(long blockNo) /* = 0 */;
 
1483     virtual bool KeywordSearch(const wxString& k,
 
1484                                wxHelpSearchMode mode = wxHELP_SEARCH_ALL) /* = 0 */;
 
1486     /// Allows one to override the default settings for the help frame.
 
1487     virtual void SetFrameParameters(const wxString& title,
 
1489                                     const wxPoint& pos = wxDefaultPosition,
 
1490                                     bool newFrameEachTime = false);
 
1492     /// Obtains the latest settings used by the help frame and the help
 
1494     virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
 
1495                                         wxPoint *pos = NULL,
 
1496                                         bool *newFrameEachTime = NULL);
 
1498     virtual bool Quit() /* = 0 */;
 
1500     virtual void OnQuit();
 
1502     /// Set the window that can optionally be used for the help window's parent.
 
1503     virtual void SetParentWindow(wxWindow* win);
 
1505     /// Get the window that can optionally be used for the help window's parent.
 
1506     virtual wxWindow* GetParentWindow() const;
 
1513 MustHaveApp(wxHtmlHelpController);
 
1515 class wxHtmlHelpController : public wxHelpControllerBase
 
1518 //    %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
 
1520     wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
 
1521     ~wxHtmlHelpController();
 
1523     wxHtmlHelpWindow* GetHelpWindow();
 
1524     void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
 
1526     wxHtmlHelpFrame* GetFrame();
 
1527     wxHtmlHelpDialog* GetDialog();
 
1529     void SetTitleFormat(const wxString& format);
 
1530     void SetTempDir(const wxString& path);
 
1531     bool AddBook(const wxString& book, int show_wait_msg = false);
 
1532     void Display(const wxString& x);
 
1533     %Rename(DisplayID,  void,  Display(int id));
 
1534     void DisplayContents();
 
1535     void DisplayIndex();
 
1536     bool KeywordSearch(const wxString& keyword);
 
1537     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
 
1538     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1539     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1541     void MakeModalIfNeeded();
 
1542     wxWindow* FindTopLevelWindow();
 
1548  * A convenience class particularly for use on wxMac,
 
1549  * where you can only show modal dialogs from a modal
 
1554  * wxHtmlModalHelp help(parent, filename, topic);
 
1556  * If topic is empty, the help contents is displayed.
 
1559 class wxHtmlModalHelp
 
1562     wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
 
1563                     const wxString& topic = wxEmptyString,
 
1564                     int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
 
1568 //---------------------------------------------------------------------------
 
1570     wxPyPtrTypeMap_Add("wxHtmlTagHandler",    "wxPyHtmlTagHandler");
 
1571     wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
 
1572     wxPyPtrTypeMap_Add("wxHtmlWindow",        "wxPyHtmlWindow");
 
1573     wxPyPtrTypeMap_Add("wxHtmlFilter",        "wxPyHtmlFilter");
 
1575 //---------------------------------------------------------------------------
 
1576 //---------------------------------------------------------------------------