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 // TODO:     bool AdjustPagebreak(int* INOUT,
 
 569 //                                 wxArrayInt& known_pagebreaks);
 
 570     void SetCanLiveOnPagebreak(bool can);
 
 572     // Can the line be broken before this cell?
 
 573     bool IsLinebreakAllowed() const;
 
 575     // Returns True for simple == terminal cells, i.e. not composite ones.
 
 576     // This if for internal usage only and may disappear in future versions!
 
 577     bool IsTerminalCell() const;
 
 579     // Find a cell inside this cell positioned at the given coordinates
 
 580     // (relative to this's positions). Returns NULL if no such cell exists.
 
 581     // The flag can be used to specify whether to look for terminal or
 
 582     // nonterminal cells or both. In either case, returned cell is deepest
 
 583     // cell in cells tree that contains [x,y].
 
 584     wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
 
 585                                   unsigned flags = wxHTML_FIND_EXACT) const;
 
 587     // Returns absolute position of the cell on HTML canvas
 
 588     // If rootCell is provided, then it's considered to be the root of the
 
 589     // hierarchy and the returned value is relative to it.
 
 590     wxPoint GetAbsPos(wxHtmlCell *rootCell = NULL) const;
 
 592     // Returns root cell of the hierarchy (i.e. grand-grand-...-parent that
 
 593     // doesn't have a parent itself)
 
 594     wxHtmlCell *GetRootCell() const;
 
 596     // Returns first (last) terminal cell inside this cell. It may return NULL,
 
 597     // but it is rare -- only if there are no terminals in the tree.
 
 598     wxHtmlCell *GetFirstTerminal() const ;
 
 599     wxHtmlCell *GetLastTerminal() const ;
 
 601     // Returns cell's depth, i.e. how far under the root cell it is
 
 602     // (if it is the root, depth is 0)
 
 603     unsigned GetDepth() const;
 
 605     // Returns True if the cell appears before 'cell' in natural order of
 
 606     // cells (= as they are read). If cell A is (grand)parent of cell B,
 
 607     // then both A.IsBefore(B) and B.IsBefore(A) always return True.
 
 608     bool IsBefore(wxHtmlCell *cell) const;
 
 610     // Converts the cell into text representation. If sel != NULL then
 
 611     // only part of the cell inside the selection is converted.
 
 612     wxString ConvertToText(wxHtmlSelection *sel) const;
 
 616 class  wxHtmlWordCell : public wxHtmlCell
 
 619     wxHtmlWordCell(const wxString& word, wxDC& dc);
 
 620     wxString ConvertToText(wxHtmlSelection *sel) const;
 
 621     bool IsLinebreakAllowed() const;
 
 622     void SetPreviousWord(wxHtmlWordCell *cell);
 
 626 class wxHtmlContainerCell : public wxHtmlCell {
 
 628     wxHtmlContainerCell(wxHtmlContainerCell *parent);
 
 630     %disownarg(wxHtmlCell*);
 
 631     void InsertCell(wxHtmlCell *cell);
 
 632     %cleardisown(wxHtmlCell*);
 
 634     void SetAlignHor(int al);
 
 636     void SetAlignVer(int al);
 
 638     void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
 
 639     int GetIndent(int ind);
 
 640     int GetIndentUnits(int ind);
 
 641     void SetAlign(const wxHtmlTag& tag);
 
 642     void SetWidthFloat(int w, int units);
 
 643     %Rename(SetWidthFloatFromTag, void,  SetWidthFloat(const wxHtmlTag& tag));
 
 644     void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
 
 645     void SetBackgroundColour(const wxColour& clr);
 
 646     wxColour GetBackgroundColour();
 
 647     void SetBorder(const wxColour& clr1, const wxColour& clr2);
 
 648     wxHtmlCell* GetFirstChild();
 
 649     %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
 
 654 class wxHtmlColourCell : public wxHtmlCell {
 
 656     wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
 
 661 class  wxHtmlFontCell : public wxHtmlCell
 
 664     wxHtmlFontCell(wxFont *font);
 
 668 class wxHtmlWidgetCell : public wxHtmlCell {
 
 670     wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
 
 677 //---------------------------------------------------------------------------
 
 679 //---------------------------------------------------------------------------
 
 683 %{ // here's the C++ version
 
 684 class wxPyHtmlFilter : public wxHtmlFilter {
 
 685     DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter)
 
 687     wxPyHtmlFilter() : wxHtmlFilter() {}
 
 689     // returns True if this filter is able to open&read given file
 
 690     virtual bool CanRead(const wxFSFile& file) const {
 
 693         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 694         if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
 
 695             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 696             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 699         wxPyEndBlockThreads(blocked);
 
 704     // Reads given file and returns HTML document.
 
 705     // Returns empty string if opening failed
 
 706     virtual wxString ReadFile(const wxFSFile& file) const {
 
 709         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 710         if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
 
 711             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 713             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
 
 716                 rval = Py2wxString(ro);
 
 720         wxPyEndBlockThreads(blocked);
 
 727 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
 
 731 // And now the version seen by SWIG
 
 733 %rename(HtmlFilter) wxPyHtmlFilter;
 
 734 class wxPyHtmlFilter : public wxObject {
 
 736     %pythonAppend wxPyHtmlFilter   "self._setCallbackInfo(self, HtmlFilter)"
 
 739     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 743 // TODO: wxHtmlFilterHTML
 
 746 //---------------------------------------------------------------------------
 
 749 class wxHtmlWindowInterface
 
 753     wxHtmlWindowInterface();
 
 754     virtual ~wxHtmlWindowInterface();
 
 757         Called by the parser to set window's title to given text.
 
 759     virtual void SetHTMLWindowTitle(const wxString& title) = 0;
 
 762 //         Called when a link is clicked.
 
 764 //         @param link information about the clicked link
 
 766 //     virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link) = 0;
 
 769 //         Called when the parser needs to open another URL (e.g. an image).
 
 771 //         @param type     Type of the URL request (e.g. image)
 
 772 //         @param url      URL the parser wants to open
 
 773 //         @param redirect If the return value is wxHTML_REDIRECT, then the
 
 774 //                         URL to redirect to will be stored in this variable
 
 775 //                         (the pointer must never be NULL)
 
 777 //         @return indicator of how to treat the request
 
 779 //     virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
 
 780 //                                                  const wxString& url,
 
 781 //                                                  wxString *redirect) const = 0;
 
 784         Converts coordinates @a pos relative to given @a cell to
 
 785         physical coordinates in the window.
 
 787     virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
 
 788                                        const wxPoint& pos) const = 0;
 
 790     /// Returns the window used for rendering (may be NULL).
 
 791     virtual wxWindow* GetHTMLWindow() = 0;
 
 793     /// Returns background colour to use by default.
 
 794     virtual wxColour GetHTMLBackgroundColour() const = 0;
 
 796     /// Sets window's background to colour @a clr.
 
 797     virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
 
 799     /// Sets window's background to given bitmap.
 
 800     virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0;
 
 802     /// Sets status bar text.
 
 803     virtual void SetHTMLStatusText(const wxString& text) = 0;
 
 805     /// Type of mouse cursor
 
 808         /// Standard mouse cursor (typically an arrow)
 
 810         /// Cursor shown over links
 
 812         /// Cursor shown over selectable text
 
 817         Returns mouse cursor of given @a type.
 
 819 //    virtual wxCursor GetHTMLCursor(HTMLCursor type) const = 0;
 
 823 //---------------------------------------------------------------------------
 
 825 //---------------------------------------------------------------------------
 
 829 //      wxHtmlWindowInterface and wxHtmlWindowMouseHelper
 
 833 class wxPyHtmlWindow : public wxHtmlWindow {
 
 834     DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow)
 
 836     wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
 
 837                    const wxPoint& pos = wxDefaultPosition,
 
 838                    const wxSize& size = wxDefaultSize,
 
 839                    long style = wxHW_DEFAULT_STYLE,
 
 840                    const wxString& name = wxPyHtmlWindowNameStr)
 
 841         : wxHtmlWindow(parent, id, pos, size, style, name)  {};
 
 842     wxPyHtmlWindow() : wxHtmlWindow() {};
 
 844     bool ScrollToAnchor(const wxString& anchor) {
 
 845         return wxHtmlWindow::ScrollToAnchor(anchor);
 
 848     bool HasAnchor(const wxString& anchor) {
 
 849         const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
 
 853     void OnLinkClicked(const wxHtmlLinkInfo& link);
 
 855     wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
 
 857                                       wxString *redirect) const;
 
 859     DEC_PYCALLBACK__STRING(OnSetTitle);
 
 860     DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
 
 861     DEC_PYCALLBACK_BOOL_CELLINTINTME(OnCellClicked);
 
 866 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
 
 867 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
 
 868 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
 
 869 IMP_PYCALLBACK_BOOL_CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
 
 872 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
 
 874     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 875     if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
 
 876         PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
 
 877         wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 880     wxPyEndBlockThreads(blocked);
 
 882         wxHtmlWindow::OnLinkClicked(link);
 
 886 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
 
 888                                                  wxString *redirect) const {
 
 890     wxHtmlOpeningStatus rval;
 
 891     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 892     if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
 
 894         PyObject* s = wx2PyString(url);
 
 895         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
 
 897         if (PyString_Check(ro)
 
 898 #if PYTHON_API_VERSION >= 1009
 
 899             || PyUnicode_Check(ro)
 
 902             *redirect = Py2wxString(ro);
 
 903             rval = wxHTML_REDIRECT;
 
 906             PyObject* num = PyNumber_Int(ro);
 
 907             rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
 
 912     wxPyEndBlockThreads(blocked);
 
 914         rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
 
 923 MustHaveApp(wxPyHtmlWindow);
 
 925 %rename(HtmlWindow) wxPyHtmlWindow;
 
 926 class wxPyHtmlWindow : public wxScrolledWindow //,
 
 927                        // public wxHtmlWindowInterface //,
 
 928                        // public wxHtmlWindowMouseHelper
 
 931     %pythonAppend wxPyHtmlWindow      "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
 
 932     %pythonAppend wxPyHtmlWindow()    ""
 
 933     %typemap(out) wxPyHtmlWindow*;    // turn off this typemap
 
 935     wxPyHtmlWindow(wxWindow *parent, int id = -1,
 
 936                  const wxPoint& pos = wxDefaultPosition,
 
 937                  const wxSize& size = wxDefaultSize,
 
 938                  int style=wxHW_DEFAULT_STYLE,
 
 939                  const wxString& name = wxPyHtmlWindowNameStr);
 
 940     %RenameCtor(PreHtmlWindow, wxPyHtmlWindow());
 
 942     // Turn it back on again
 
 943     %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
 945     bool Create(wxWindow *parent, int id = -1,
 
 946                 const wxPoint& pos = wxDefaultPosition,
 
 947                 const wxSize& size = wxDefaultSize,
 
 948                 int style=wxHW_SCROLLBAR_AUTO,
 
 949                 const wxString& name = wxPyHtmlWindowNameStr);
 
 952     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 955     // Set HTML page and display it. !! source is HTML document itself,
 
 956     // it is NOT address/filename of HTML document. If you want to
 
 957     // specify document location, use LoadPage() instead
 
 958     // Return value : False if an error occurred, True otherwise
 
 959     bool SetPage(const wxString& source);
 
 961     // Load HTML page from given location. Location can be either
 
 962     // a) /usr/wxGTK2/docs/html/wx.htm
 
 963     // b) http://www.somewhere.uk/document.htm
 
 964     // c) ftp://ftp.somesite.cz/pub/something.htm
 
 965     // In case there is no prefix (http:,ftp:), the method
 
 966     // will try to find it itself (1. local file, then http or ftp)
 
 967     // After the page is loaded, the method calls SetPage() to display it.
 
 968     // Note : you can also use path relative to previously loaded page
 
 969     // Return value : same as SetPage
 
 970     bool LoadPage(const wxString& location);
 
 972     // Loads HTML page from file
 
 973     bool LoadFile(const wxString& filename);
 
 975     // Append to current page
 
 976     bool AppendToPage(const wxString& source);
 
 978      // Returns full location of opened page
 
 979     wxString GetOpenedPage();
 
 981     // Returns anchor within opened page
 
 982     wxString GetOpenedAnchor();
 
 984     // Returns <TITLE> of opened page or empty string otherwise
 
 985     wxString GetOpenedPageTitle();
 
 987     // Sets frame in which page title will  be displayed. Format is format of
 
 988     // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
 
 989     void SetRelatedFrame(wxFrame* frame, const wxString& format);
 
 990     wxFrame* GetRelatedFrame();
 
 992     // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
 
 993     // will be displayed. Default is -1 = no messages.
 
 994     void SetRelatedStatusBar(int bar);
 
 996     // Sets fonts to be used when displaying HTML page.
 
 998         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1000             if (sizes) temp = int_LIST_helper(sizes);
 
1001             self->SetFonts(normal_face, fixed_face, temp);
 
1007     // Sets font sizes to be relative to the given size or the system
 
1008     // default size; use either specified or default font
 
1009     void SetStandardFonts(int size = -1,
 
1010                           const wxString& normal_face = wxPyEmptyString,
 
1011                           const wxString& fixed_face = wxPyEmptyString);
 
1014         void, SetLabel(const wxString& title),
 
1017     // Sets space between text and window borders.
 
1018     void SetBorders(int b);
 
1020     // Sets the bitmap to use for background (currnetly it will be tiled,
 
1021     // when/if we have CSS support we could add other possibilities...)
 
1022     void SetBackgroundImage(const wxBitmap& bmpBg);
 
1024     // Saves custom settings into cfg config. it will use the path 'path'
 
1025     // if given, otherwise it will save info into currently selected path.
 
1026     // saved values : things set by SetFonts, SetBorders.
 
1027     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1028     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1030     // Goes to previous/next page (in browsing history)
 
1031     // Returns True if successful, False otherwise
 
1033     bool HistoryForward();
 
1034     bool HistoryCanBack();
 
1035     bool HistoryCanForward();
 
1038     void HistoryClear();
 
1040     // Returns pointer to conteiners/cells structure.
 
1041     wxHtmlContainerCell* GetInternalRepresentation();
 
1043     // Returns a pointer to the parser.
 
1044     wxHtmlWinParser* GetParser();
 
1046     bool ScrollToAnchor(const wxString& anchor);
 
1047     bool HasAnchor(const wxString& anchor);
 
1050     static void AddFilter(wxPyHtmlFilter *filter);
 
1052     // Helper functions to select parts of page:
 
1053     void SelectWord(const wxPoint& pos);
 
1054     void SelectLine(const wxPoint& pos);
 
1057     // Convert selection to text:
 
1058     wxString SelectionToText();
 
1060     // Converts current page to text:
 
1063     void OnLinkClicked(const wxHtmlLinkInfo& link);
 
1064     void OnSetTitle(const wxString& title);
 
1065     void OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
 
1066     bool OnCellClicked(wxHtmlCell *cell,
 
1067                        wxCoord x, wxCoord y,
 
1068                        const wxMouseEvent& event);
 
1069     wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
 
1070                                       const wxString& url,
 
1071                                       wxString *redirect) const;
 
1072     %MAKE_BASE_FUNC(HtmlWindow, OnLinkClicked);
 
1073     %MAKE_BASE_FUNC(HtmlWindow, OnSetTitle);
 
1074     %MAKE_BASE_FUNC(HtmlWindow, OnCellMouseHover);
 
1075     %MAKE_BASE_FUNC(HtmlWindow, OnCellClicked);
 
1077     static wxVisualAttributes
 
1078     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
1080     /// Type of mouse cursor
 
1083         /// Standard mouse cursor (typically an arrow)
 
1085         /// Cursor shown over links
 
1087         /// Cursor shown over selectable text
 
1091     // Returns standard HTML cursor as used by wxHtmlWindow
 
1092     static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
 
1096 //     // wxHtmlWindowInterface methods:
 
1097 //     virtual void SetHTMLWindowTitle(const wxString& title);
 
1098 //     virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link);
 
1099 //     virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
 
1100 //                                                  const wxString& url,
 
1101 //                                                  wxString *redirect) const;
 
1102 //     virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
 
1103 //                                        const wxPoint& pos) const;
 
1104 //     virtual wxWindow* GetHTMLWindow();
 
1105 //     virtual wxColour GetHTMLBackgroundColour() const;
 
1106 //     virtual void SetHTMLBackgroundColour(const wxColour& clr);
 
1107 //     virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
 
1108 //     virtual void SetHTMLStatusText(const wxString& text);
 
1109 //     virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
 
1116 //---------------------------------------------------------------------------
 
1117 //---------------------------------------------------------------------------
 
1121 MustHaveApp(wxHtmlDCRenderer);
 
1123 class wxHtmlDCRenderer : public wxObject {
 
1126     ~wxHtmlDCRenderer();
 
1128     void SetDC(wxDC *dc, int maxwidth);
 
1129     void SetSize(int width, int height);
 
1130     void SetHtmlText(const wxString& html,
 
1131                      const wxString& basepath = wxPyEmptyString,
 
1133     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
1135         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1137             if (sizes) temp = int_LIST_helper(sizes);
 
1138             self->SetFonts(normal_face, fixed_face, temp);
 
1144     // Sets font sizes to be relative to the given size or the system
 
1145     // default size; use either specified or default font
 
1146     void SetStandardFonts(int size = -1,
 
1147                           const wxString& normal_face = wxPyEmptyString,
 
1148                           const wxString& fixed_face = wxPyEmptyString);
 
1150     int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
 
1151                int dont_render = FALSE, int to = INT_MAX);
 
1152     int GetTotalHeight();
 
1153                 // returns total height of the html document
 
1154                 // (compare Render's return value with this)
 
1165 MustHaveApp(wxHtmlPrintout);
 
1167 class wxHtmlPrintout : public wxPyPrintout {
 
1169     wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
 
1170     //~wxHtmlPrintout();   wxPrintPreview object takes ownership...
 
1172     void SetHtmlText(const wxString& html,
 
1173                      const wxString &basepath = wxPyEmptyString,
 
1175     void SetHtmlFile(const wxString &htmlfile);
 
1176     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1177     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1179     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
1181         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1183             if (sizes) temp = int_LIST_helper(sizes);
 
1184             self->SetFonts(normal_face, fixed_face, temp);
 
1190     // Sets font sizes to be relative to the given size or the system
 
1191     // default size; use either specified or default font
 
1192     void SetStandardFonts(int size = -1,
 
1193                           const wxString& normal_face = wxPyEmptyString,
 
1194                           const wxString& fixed_face = wxPyEmptyString);
 
1196     void SetMargins(float top = 25.2, float bottom = 25.2,
 
1197                     float left = 25.2, float right = 25.2,
 
1200     // Adds input filter
 
1201     static void AddFilter(wxHtmlFilter *filter);
 
1204     static void CleanUpStatics();
 
1209 MustHaveApp(wxHtmlEasyPrinting);
 
1211 class wxHtmlEasyPrinting : public wxObject {
 
1213     wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
 
1214                        wxWindow *parentWindow = NULL);
 
1215     ~wxHtmlEasyPrinting();
 
1217     void PreviewFile(const wxString &htmlfile);
 
1218     void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1219     void PrintFile(const wxString &htmlfile);
 
1220     void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1221 //    void PrinterSetup();
 
1223     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1224     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1227         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1229             if (sizes) temp = int_LIST_helper(sizes);
 
1230             self->SetFonts(normal_face, fixed_face, temp);
 
1236     // Sets font sizes to be relative to the given size or the system
 
1237     // default size; use either specified or default font
 
1238     void SetStandardFonts(int size = -1,
 
1239                           const wxString& normal_face = wxPyEmptyString,
 
1240                           const wxString& fixed_face = wxPyEmptyString);
 
1242     wxPrintData *GetPrintData() {return m_PrintData;}
 
1243     wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
 
1248 //---------------------------------------------------------------------------
 
1249 //---------------------------------------------------------------------------
 
1253 class wxHtmlBookRecord {
 
1255     wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
 
1256                      const wxString& title, const wxString& start);
 
1258     wxString GetBookFile();
 
1259     wxString GetTitle();
 
1260     wxString GetStart();
 
1261     wxString GetBasePath();
 
1263     void SetContentsRange(int start, int end);
 
1264     int GetContentsStart();
 
1265     int GetContentsEnd();
 
1267     void SetTitle(const wxString& title);
 
1268     void SetBasePath(const wxString& path);
 
1269     void SetStart(const wxString& start);
 
1271     wxString GetFullPath(const wxString &page) const;
 
1274 //---------------------------------------------------------------------------
 
1275 // WXWIN_COMPATIBILITY_2_4
 
1277 struct wxHtmlContentsItem
 
1280         int GetLevel() { return self->m_Level; }
 
1281         int GetID() { return self->m_ID; }
 
1282         wxString GetName() { return self->m_Name; }
 
1283         wxString GetPage() { return self->m_Page; }
 
1284         wxHtmlBookRecord* GetBook() { return self->m_Book; }
 
1288 //---------------------------------------------------------------------------
 
1290 class wxHtmlSearchStatus
 
1293     //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
 
1294     //                   const wxString& book = wxPyEmptyString);
 
1299     const wxString& GetName();
 
1302 //---------------------------------------------------------------------------
 
1304 class wxHtmlHelpData {
 
1309     void SetTempDir(const wxString& path);
 
1310     bool AddBook(const wxString& book);
 
1311 //      bool AddBookParam(const wxString& title, const wxString& contfile,
 
1312 //                    const wxString& indexfile=wxPyEmptyString,
 
1313 //                    const wxString& deftopic=wxPyEmptyString,
 
1314 //                    const wxString& path=wxPyEmptyString);
 
1316     wxString FindPageByName(const wxString& page);
 
1317     wxString FindPageById(int id);
 
1319     // TODO: this one needs fixed...
 
1320     const wxHtmlBookRecArray& GetBookRecArray();
 
1324 //---------------------------------------------------------------------------
 
1337     wxHF_ICONS_BOOK_CHAPTER,
 
1357     wxID_HTML_BOOKMARKSLIST,
 
1358     wxID_HTML_BOOKMARKSADD,
 
1359     wxID_HTML_BOOKMARKSREMOVE,
 
1361     wxID_HTML_INDEXPAGE,
 
1362     wxID_HTML_INDEXLIST,
 
1363     wxID_HTML_INDEXTEXT,
 
1364     wxID_HTML_INDEXBUTTON,
 
1365     wxID_HTML_INDEXBUTTONALL,
 
1367     wxID_HTML_SEARCHPAGE,
 
1368     wxID_HTML_SEARCHTEXT,
 
1369     wxID_HTML_SEARCHLIST,
 
1370     wxID_HTML_SEARCHBUTTON,
 
1371     wxID_HTML_SEARCHCHOICE,
 
1377 MustHaveApp(wxHtmlHelpWindow);
 
1379 class wxHtmlHelpWindow : public wxWindow
 
1382     %pythonAppend wxHtmlHelpWindow    "self._setOORInfo(self)"
 
1383     %pythonAppend wxHtmlHelpWindow()       ""
 
1384     %typemap(out) wxHtmlHelpWindow*;    // turn off this typemap
 
1386     wxHtmlHelpWindow(wxWindow* parent, wxWindowID wxWindowID,
 
1387                      const wxPoint& pos = wxDefaultPosition,
 
1388                      const wxSize& size = wxDefaultSize,
 
1389                      int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1390                      int helpStyle = wxHF_DEFAULT_STYLE,
 
1391                      wxHtmlHelpData* data = NULL);
 
1392     %RenameCtor(PreHtmlHelpWindow, wxHtmlHelpWindow(wxHtmlHelpData* data = NULL));
 
1394     // Turn it back on again
 
1395     %typemap(out) wxHtmlHelpWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
1397     bool Create(wxWindow* parent, wxWindowID id,
 
1398                 const wxPoint& pos = wxDefaultPosition,
 
1399                 const wxSize& size = wxDefaultSize,
 
1400                 int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1401                 int helpStyle = wxHF_DEFAULT_STYLE);
 
1403     wxHtmlHelpData* GetData();
 
1404     wxHtmlHelpController* GetController() const;
 
1406     %disownarg( wxHtmlHelpController* controller );
 
1407     void SetController(wxHtmlHelpController* controller);
 
1408     %cleardisown( wxHtmlHelpController* controller );
 
1410     // Displays page x. If not found it will offect the user a choice of
 
1412     // Looking for the page runs in these steps:
 
1413     // 1. try to locate file named x (if x is for example "doc/howto.htm")
 
1414     // 2. try to open starting page of book x
 
1415     // 3. try to find x in contents (if x is for example "How To ...")
 
1416     // 4. try to find x in index (if x is for example "How To ...")
 
1417     bool Display(const wxString& x);
 
1419     // Alternative version that works with numeric ID.
 
1420     // (uses extension to MS format, <param name="ID" value=id>, see docs)
 
1421     %Rename(DisplayID,  bool,  Display(int id));
 
1423     // Displays help window and focuses contents.
 
1424     bool DisplayContents();
 
1426     // Displays help window and focuses index.
 
1427     bool DisplayIndex();
 
1429     // Searches for keyword. Returns true and display page if found, return
 
1431     // Syntax of keyword is Altavista-like:
 
1432     // * words are separated by spaces
 
1433     //   (but "\"hello world\"" is only one world "hello world")
 
1434     // * word may be pretended by + or -
 
1435     //   (+ : page must contain the word ; - : page can't contain the word)
 
1436     // * if there is no + or - before the word, + is default
 
1437     bool KeywordSearch(const wxString& keyword,
 
1438                        wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
 
1440     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
 
1442     // Saves custom settings into cfg config. it will use the path 'path'
 
1443     // if given, otherwise it will save info into currently selected path.
 
1444     // saved values : things set by SetFonts, SetBorders.
 
1445     void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1446     void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1448     // call this to let wxHtmlHelpWindow know page changed
 
1449     void NotifyPageChanged();
 
1451     // Refreshes Contents and Index tabs
 
1452     void RefreshLists();
 
1454     // Gets the HTML window
 
1455     wxHtmlWindow* GetHtmlWindow() const;
 
1457     // Gets the splitter window
 
1458     wxSplitterWindow* GetSplitterWindow();
 
1461     wxToolBar* GetToolBar() const;
 
1463     // Gets the configuration data
 
1464     wxHtmlHelpFrameCfg& GetCfgData();
 
1466     // Gets the tree control
 
1467     wxTreeCtrl *GetTreeCtrl() const;
 
1472 class wxHtmlWindowEvent: public wxNotifyEvent
 
1475     wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
 
1476         wxNotifyEvent(commandType, id);
 
1478     void SetURL(const wxString& url);
 
1479     const wxString& GetURL() const;
 
1484 MustHaveApp(wxHtmlHelpFrame);
 
1486 class wxHtmlHelpFrame : public wxFrame {
 
1488     %pythonAppend wxHtmlHelpFrame    "self._setOORInfo(self)"
 
1489     %pythonAppend wxHtmlHelpFrame()       ""
 
1490     %typemap(out) wxHtmlHelpFrame*;    // turn off this typemap
 
1492     wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
 
1493                     const wxString& title = wxPyEmptyString,
 
1494                     int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
 
1495     %RenameCtor(PreHtmlHelpFrame, wxHtmlHelpFrame(wxHtmlHelpData* data = NULL));
 
1497     // Turn it back on again
 
1498     %typemap(out) wxHtmlHelpFrame* { $result = wxPyMake_wxObject($1, $owner); }
 
1500     bool Create(wxWindow* parent, wxWindowID id,
 
1501                 const wxString& title = wxPyEmptyString,
 
1502                 int style = wxHF_DEFAULT_STYLE);
 
1504     wxHtmlHelpData* GetData();
 
1505     void SetTitleFormat(const wxString& format);
 
1507     void AddGrabIfNeeded();
 
1509     /// Returns the help controller associated with the window.
 
1510     wxHtmlHelpController* GetController() const;
 
1512     /// Sets the help controller associated with the window.
 
1513     %disownarg( wxHtmlHelpController* controller );
 
1514     void SetController(wxHtmlHelpController* controller);
 
1515     %cleardisown( wxHtmlHelpController* controller );
 
1517     /// Returns the help window.
 
1518     wxHtmlHelpWindow* GetHelpWindow() const;
 
1521         %# For compatibility from before the refactor
 
1522         def Display(self, x):
 
1523             return self.GetHelpWindow().Display(x)
 
1524         def DisplayID(self, x):
 
1525             return self.GetHelpWindow().DisplayID(id)
 
1526         def DisplayContents(self):
 
1527             return self.GetHelpWindow().DisplayContents()
 
1528         def DisplayIndex(self):
 
1529             return self.GetHelpWindow().DisplayIndex()
 
1531         def KeywordSearch(self, keyword):
 
1532             return self.GetHelpWindow().KeywordSearch(keyword)
 
1534         def UseConfig(self, config, rootpath=""):
 
1535             return self.GetHelpWindow().UseConfig(config, rootpath)
 
1536         def ReadCustomization(self, config, rootpath=""):
 
1537             return self.GetHelpWindow().ReadCustomization(config, rootpath)
 
1538         def WriteCustomization(self, config, rootpath=""):
 
1539             return self.GetHelpWindow().WriteCustomization(config, rootpath)
 
1545 MustHaveApp(wxHtmlHelpDialog);
 
1547 class wxHtmlHelpDialog : public wxDialog
 
1550     %pythonAppend wxHtmlHelpDialog    "self._setOORInfo(self)"
 
1551     %pythonAppend wxHtmlHelpDialog()       ""
 
1552     %typemap(out) wxHtmlHelpDialog*;    // turn off this typemap
 
1554     wxHtmlHelpDialog(wxWindow* parent, wxWindowID wxWindowID,
 
1555                     const wxString& title = wxPyEmptyString,
 
1556                     int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
 
1557     %RenameCtor(PreHtmlHelpDialog, wxHtmlHelpDialog(wxHtmlHelpData* data = NULL));
 
1559     // Turn it back on again
 
1560     %typemap(out) wxHtmlHelpDialog* { $result = wxPyMake_wxObject($1, $owner); }
 
1562     bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxPyEmptyString,
 
1563                 int style = wxHF_DEFAULT_STYLE);
 
1565     /// Returns the data associated with this dialog.
 
1566     wxHtmlHelpData* GetData();
 
1568     /// Returns the controller that created this dialog.
 
1569     wxHtmlHelpController* GetController() const;
 
1571     /// Sets the controller associated with this dialog.
 
1572     %disownarg( wxHtmlHelpController* controller );
 
1573     void SetController(wxHtmlHelpController* controller);
 
1574     %cleardisown( wxHtmlHelpController* controller );
 
1576     /// Returns the help window.
 
1577     wxHtmlHelpWindow* GetHelpWindow() const;
 
1579     // Sets format of title of the frame. Must contain exactly one "%s"
 
1580     // (for title of displayed HTML page)
 
1581     void SetTitleFormat(const wxString& format);
 
1583     // Override to add custom buttons to the toolbar
 
1584 //    virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {};
 
1589 //---------------------------------------------------------------------------
 
1592 // TODO: Make virtual methods of this class overridable in Python.
 
1594 MustHaveApp(wxHelpControllerBase);
 
1596 class wxHelpControllerBase: public wxObject
 
1599 //    wxHelpControllerBase(wxWindow* parentWindow = NULL);
 
1600 //    ~wxHelpControllerBase();
 
1602     %nokwargs Initialize;
 
1603     virtual bool Initialize(const wxString& file, int server );
 
1604     virtual bool Initialize(const wxString& file);
 
1606     virtual void SetViewer(const wxString& viewer, long flags = 0);
 
1608     // If file is "", reloads file given  in Initialize
 
1609     virtual bool LoadFile(const wxString& file = wxEmptyString) /* = 0 */;
 
1611     // Displays the contents
 
1612     virtual bool DisplayContents(void) /* = 0 */;
 
1614     %nokwargs DisplaySection;
 
1616     // Display the given section
 
1617     virtual bool DisplaySection(int sectionNo) /* = 0 */;
 
1619     // Display the section using a context id
 
1620     virtual bool DisplayContextPopup(int contextId);
 
1622     // Display the text in a popup, if possible
 
1623     virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
 
1625     // By default, uses KeywordSection to display a topic. Implementations
 
1626     // may override this for more specific behaviour.
 
1627     virtual bool DisplaySection(const wxString& section);
 
1629     virtual bool DisplayBlock(long blockNo) /* = 0 */;
 
1630     virtual bool KeywordSearch(const wxString& k,
 
1631                                wxHelpSearchMode mode = wxHELP_SEARCH_ALL) /* = 0 */;
 
1633     /// Allows one to override the default settings for the help frame.
 
1634     virtual void SetFrameParameters(const wxString& title,
 
1636                                     const wxPoint& pos = wxDefaultPosition,
 
1637                                     bool newFrameEachTime = false);
 
1639     /// Obtains the latest settings used by the help frame and the help
 
1641     virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
 
1642                                         wxPoint *pos = NULL,
 
1643                                         bool *newFrameEachTime = NULL);
 
1645     virtual bool Quit() /* = 0 */;
 
1647     virtual void OnQuit();
 
1649     /// Set the window that can optionally be used for the help window's parent.
 
1650     virtual void SetParentWindow(wxWindow* win);
 
1652     /// Get the window that can optionally be used for the help window's parent.
 
1653     virtual wxWindow* GetParentWindow() const;
 
1660 MustHaveApp(wxHtmlHelpController);
 
1662 class wxHtmlHelpController : public wxHelpControllerBase
 
1665 //    %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
 
1667     wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
 
1668     ~wxHtmlHelpController();
 
1670     wxHtmlHelpWindow* GetHelpWindow();
 
1671     void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
 
1673     wxHtmlHelpFrame* GetFrame();
 
1674     wxHtmlHelpDialog* GetDialog();
 
1676     void SetTitleFormat(const wxString& format);
 
1677     void SetTempDir(const wxString& path);
 
1678     bool AddBook(const wxString& book, int show_wait_msg = false);
 
1679     void Display(const wxString& x);
 
1680     %Rename(DisplayID,  void,  Display(int id));
 
1681     void DisplayContents();
 
1682     void DisplayIndex();
 
1683     bool KeywordSearch(const wxString& keyword);
 
1684     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
 
1685     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1686     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1688     void MakeModalIfNeeded();
 
1689     wxWindow* FindTopLevelWindow();
 
1695  * A convenience class particularly for use on wxMac,
 
1696  * where you can only show modal dialogs from a modal
 
1701  * wxHtmlModalHelp help(parent, filename, topic);
 
1703  * If topic is empty, the help contents is displayed.
 
1706 class wxHtmlModalHelp
 
1709     wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
 
1710                     const wxString& topic = wxEmptyString,
 
1711                     int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
 
1715 //---------------------------------------------------------------------------
 
1717     wxPyPtrTypeMap_Add("wxHtmlTagHandler",    "wxPyHtmlTagHandler");
 
1718     wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
 
1719     wxPyPtrTypeMap_Add("wxHtmlWindow",        "wxPyHtmlWindow");
 
1720     wxPyPtrTypeMap_Add("wxHtmlFilter",        "wxPyHtmlFilter");
 
1722 //---------------------------------------------------------------------------
 
1723 //---------------------------------------------------------------------------