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,
 
  91 // enums for wxHtmlWindow::OnOpeningURL
 
  92 enum wxHtmlOpeningStatus
 
 108 //---------------------------------------------------------------------------
 
 110 class wxHtmlLinkInfo : public wxObject {
 
 112     wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString);
 
 114     wxString GetTarget();
 
 115     wxMouseEvent* GetEvent();
 
 116     wxHtmlCell* GetHtmlCell();
 
 118     void SetEvent(const wxMouseEvent *e);
 
 119     void SetHtmlCell(const wxHtmlCell * e);
 
 121     %property(Event, GetEvent, SetEvent, doc="See `GetEvent` and `SetEvent`");
 
 122     %property(Href, GetHref, doc="See `GetHref`");
 
 123     %property(HtmlCell, GetHtmlCell, SetHtmlCell, doc="See `GetHtmlCell` and `SetHtmlCell`");
 
 124     %property(Target, GetTarget, doc="See `GetTarget`");
 
 127 //---------------------------------------------------------------------------
 
 129 class wxHtmlTag : public wxObject {
 
 131     // Never need to create a new tag from Python...
 
 132     //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
 
 135     bool HasParam(const wxString& par);
 
 136     wxString GetParam(const wxString& par, int with_commas = false);
 
 138     // Can't do this one as-is, but GetParam should be enough...
 
 139     //int ScanParam(const wxString& par, const char *format, void* param);
 
 141     wxString GetAllParams();
 
 147     %property(AllParams, GetAllParams, doc="See `GetAllParams`");
 
 148     %property(BeginPos, GetBeginPos, doc="See `GetBeginPos`");
 
 149     %property(EndPos1, GetEndPos1, doc="See `GetEndPos1`");
 
 150     %property(EndPos2, GetEndPos2, doc="See `GetEndPos2`");
 
 151     %property(Name, GetName, doc="See `GetName`");
 
 154 //---------------------------------------------------------------------------
 
 156 class wxHtmlParser : public wxObject {
 
 158     // wxHtmlParser();  This is an abstract base class...
 
 160     void SetFS(wxFileSystem *fs);
 
 161     wxFileSystem* GetFS();
 
 162     wxObject* Parse(const wxString& source);
 
 163     void InitParser(const wxString& source);
 
 165     void DoParsing(int begin_pos, int end_pos);
 
 167     // wxObject* GetProduct();
 
 169     void AddTagHandler(wxHtmlTagHandler *handler);
 
 170     wxString* GetSource();
 
 171     void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
 
 172     void PopTagHandler();
 
 174     // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
 
 176     // void AddText(const char* txt) = 0;
 
 177     // void AddTag(const wxHtmlTag& tag);
 
 180     // Returns HTML source inside the element (i.e. between the starting
 
 182     wxString GetInnerSource(const wxHtmlTag& tag);
 
 184     %property(FS, GetFS, SetFS, doc="See `GetFS` and `SetFS`");
 
 185     %property(Source, GetSource, doc="See `GetSource`");
 
 189 //---------------------------------------------------------------------------
 
 191 class wxHtmlWinParser : public wxHtmlParser {
 
 193     wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL);
 
 195     void SetDC(wxDC *dc);
 
 199     wxPyHtmlWindow* GetWindow();
 
 200     %pythoncode { GetWindow = wx._deprecated(GetWindow) }
 
 202     wxHtmlWindowInterface *GetWindowInterface();
 
 204     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
 206         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
 208             if (sizes) temp = int_LIST_helper(sizes);
 
 209             self->SetFonts(normal_face, fixed_face, temp);
 
 215     // Sets font sizes to be relative to the given size or the system
 
 216     // default size; use either specified or default font
 
 217     void SetStandardFonts(int size = -1,
 
 218                           const wxString& normal_face = wxPyEmptyString,
 
 219                           const wxString& fixed_face = wxPyEmptyString);
 
 222     wxHtmlContainerCell* GetContainer();
 
 223     wxHtmlContainerCell* OpenContainer();
 
 224     wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
 
 225     wxHtmlContainerCell* CloseContainer();
 
 228     void SetFontSize(int s);
 
 230     void SetFontBold(int x);
 
 232     void SetFontItalic(int x);
 
 233     int GetFontUnderlined();
 
 234     void SetFontUnderlined(int x);
 
 236     void SetFontFixed(int x);
 
 238     void SetAlign(int a);
 
 239     wxColour GetLinkColor();
 
 240     void SetLinkColor(const wxColour& clr);
 
 241     wxColour GetActualColor();
 
 242     void SetActualColor(const wxColour& clr);
 
 244         GetActualColour = GetActualColor
 
 245         SetActualColour = SetActualColor
 
 247     void SetLink(const wxString& link);
 
 248     wxFont* CreateCurrentFont();
 
 249     wxHtmlLinkInfo GetLink();
 
 251     %property(ActualColor, GetActualColor, SetActualColor, doc="See `GetActualColor` and `SetActualColor`");
 
 252     %property(ActualColour, GetActualColour, SetActualColour, doc="See `GetActualColour` and `SetActualColour`");
 
 253     %property(Align, GetAlign, SetAlign, doc="See `GetAlign` and `SetAlign`");
 
 254     %property(CharHeight, GetCharHeight, doc="See `GetCharHeight`");
 
 255     %property(CharWidth, GetCharWidth, doc="See `GetCharWidth`");
 
 256     %property(Container, GetContainer, SetContainer, doc="See `GetContainer` and `SetContainer`");
 
 257     %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
 
 258     %property(FontBold, GetFontBold, SetFontBold, doc="See `GetFontBold` and `SetFontBold`");
 
 259     %property(FontFixed, GetFontFixed, SetFontFixed, doc="See `GetFontFixed` and `SetFontFixed`");
 
 260     %property(FontItalic, GetFontItalic, SetFontItalic, doc="See `GetFontItalic` and `SetFontItalic`");
 
 261     %property(FontSize, GetFontSize, SetFontSize, doc="See `GetFontSize` and `SetFontSize`");
 
 262     %property(FontUnderlined, GetFontUnderlined, SetFontUnderlined, doc="See `GetFontUnderlined` and `SetFontUnderlined`");
 
 263     %property(Link, GetLink, SetLink, doc="See `GetLink` and `SetLink`");
 
 264     %property(LinkColor, GetLinkColor, SetLinkColor, doc="See `GetLinkColor` and `SetLinkColor`");
 
 265     %property(WindowInterface, GetWindowInterface, doc="See `GetWindowInterface`");
 
 269 //---------------------------------------------------------------------------
 
 272 class wxPyHtmlTagHandler : public wxHtmlTagHandler {
 
 273     DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler)
 
 275     wxPyHtmlTagHandler() : wxHtmlTagHandler() {};
 
 277     wxHtmlParser* GetParser() { return m_Parser; }
 
 278     void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); }
 
 280     DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
 
 281     DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
 
 286 IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler);
 
 288 IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
 
 289 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
 
 293 %rename(HtmlTagHandler) wxPyHtmlTagHandler;
 
 294 class wxPyHtmlTagHandler : public wxObject {
 
 296     %pythonAppend wxPyHtmlTagHandler   "self._setCallbackInfo(self, HtmlTagHandler)"
 
 297     wxPyHtmlTagHandler();
 
 299     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 301     void SetParser(wxHtmlParser *parser);
 
 302     wxHtmlParser* GetParser();
 
 303     void ParseInner(const wxHtmlTag& tag);
 
 305     %property(Parser, GetParser, SetParser, doc="See `GetParser` and `SetParser`");
 
 309 //---------------------------------------------------------------------------
 
 312 class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler {
 
 313     DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler)
 
 315     wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {};
 
 317     wxHtmlWinParser* GetParser() { return m_WParser; }
 
 318     void ParseInner(const wxHtmlTag& tag)
 
 319         { wxHtmlWinTagHandler::ParseInner(tag); }
 
 321     DEC_PYCALLBACK_STRING__pure(GetSupportedTags);
 
 322     DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag);
 
 327 IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler);
 
 329 IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
 
 330 IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
 
 334 %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler;
 
 335 class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler {
 
 337     %pythonAppend wxPyHtmlWinTagHandler    "self._setCallbackInfo(self, HtmlWinTagHandler)"
 
 338     wxPyHtmlWinTagHandler();
 
 340     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 342     void SetParser(wxHtmlParser *parser);
 
 343     wxHtmlWinParser* GetParser();
 
 344     void ParseInner(const wxHtmlTag& tag);
 
 346     %property(Parser, GetParser, SetParser, doc="See `GetParser` and `SetParser`");
 
 350 //---------------------------------------------------------------------------
 
 354 class wxPyHtmlTagsModule : public wxHtmlTagsModule {
 
 356     wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() {
 
 357         m_tagHandlerClass = thc;
 
 358         Py_INCREF(m_tagHandlerClass);
 
 359         RegisterModule(this);
 
 360         wxHtmlWinParser::AddModule(this);
 
 364         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 365         Py_DECREF(m_tagHandlerClass);
 
 366         m_tagHandlerClass = NULL;
 
 367         for (size_t x=0; x < m_objArray.GetCount(); x++) {
 
 368             PyObject* obj = (PyObject*)m_objArray.Item(x);
 
 371         wxPyEndBlockThreads(blocked);
 
 374     void FillHandlersTable(wxHtmlWinParser *parser) {
 
 375         // Wave our magic wand...  (if it works it's a miracle!  ;-)
 
 377         // First, make a new instance of the tag handler
 
 378         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 379         PyObject* arg = PyTuple_New(0);
 
 380         PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg);
 
 383         // now figure out where it's C++ object is...
 
 384         wxPyHtmlWinTagHandler* thPtr;
 
 385         if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) {
 
 386             wxPyEndBlockThreads(blocked);
 
 389         wxPyEndBlockThreads(blocked);
 
 392         parser->AddTagHandler(thPtr);
 
 399     PyObject*           m_tagHandlerClass;
 
 400     wxArrayPtrVoid      m_objArray;
 
 408     void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) {
 
 409         // Dynamically create a new wxModule.  Refcounts tagHandlerClass
 
 410         // and adds itself to the wxModules list and to the wxHtmlWinParser.
 
 411         new wxPyHtmlTagsModule(tagHandlerClass);
 
 416 //---------------------------------------------------------------------------
 
 418 %typemap(out) wxHtmlCell*         { $result = wxPyMake_wxObject($1, $owner); }
 
 419 %typemap(out) const wxHtmlCell*   { $result = wxPyMake_wxObject($1, $owner); }
 
 421 //---------------------------------------------------------------------------
 
 425 // wxHtmlSelection is data holder with information about text selection.
 
 426 // Selection is defined by two positions (beginning and end of the selection)
 
 427 // and two leaf(!) cells at these positions.
 
 428 class wxHtmlSelection
 
 434     void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
 
 435              const wxPoint& toPos, const wxHtmlCell *toCell);
 
 436     %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell));
 
 438     const wxHtmlCell *GetFromCell() const;
 
 439     const wxHtmlCell *GetToCell() const;
 
 441     // these values are in absolute coordinates:
 
 442     const wxPoint& GetFromPos() const;
 
 443     const wxPoint& GetToPos() const;
 
 445     // these are From/ToCell's private data
 
 446     const wxPoint& GetFromPrivPos() const;
 
 447     const wxPoint& GetToPrivPos() const;
 
 448     void SetFromPrivPos(const wxPoint& pos);
 
 449     void SetToPrivPos(const wxPoint& pos);
 
 452     const bool IsEmpty() const;
 
 454     %property(FromCell, GetFromCell, doc="See `GetFromCell`");
 
 455     %property(FromPos, GetFromPos, doc="See `GetFromPos`");
 
 456     %property(FromPrivPos, GetFromPrivPos, SetFromPrivPos, doc="See `GetFromPrivPos` and `SetFromPrivPos`");
 
 457     %property(ToCell, GetToCell, doc="See `GetToCell`");
 
 458     %property(ToPos, GetToPos, doc="See `GetToPos`");
 
 459     %property(ToPrivPos, GetToPrivPos, SetToPrivPos, doc="See `GetToPrivPos` and `SetToPrivPos`");
 
 463 enum wxHtmlSelectionState
 
 465     wxHTML_SEL_OUT,     // currently rendered cell is outside the selection
 
 466     wxHTML_SEL_IN,      // ... is inside selection
 
 467     wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
 
 472 // Selection state is passed to wxHtmlCell::Draw so that it can render itself
 
 473 // differently e.g. when inside text selection or outside it.
 
 474 class wxHtmlRenderingState
 
 477     wxHtmlRenderingState();
 
 478     ~wxHtmlRenderingState();
 
 480     void SetSelectionState(wxHtmlSelectionState s);
 
 481     wxHtmlSelectionState GetSelectionState() const;
 
 483     void SetFgColour(const wxColour& c);
 
 484     const wxColour& GetFgColour() const;
 
 485     void SetBgColour(const wxColour& c);
 
 486     const wxColour& GetBgColour() const;
 
 488     %property(BgColour, GetBgColour, SetBgColour, doc="See `GetBgColour` and `SetBgColour`");
 
 489     %property(FgColour, GetFgColour, SetFgColour, doc="See `GetFgColour` and `SetFgColour`");
 
 490     %property(SelectionState, GetSelectionState, SetSelectionState, doc="See `GetSelectionState` and `SetSelectionState`");
 
 495 // HTML rendering customization. This class is used when rendering wxHtmlCells
 
 497 class wxHtmlRenderingStyle
 
 500     virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
 
 501     virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
 
 503     %property(SelectedTextBgColour, GetSelectedTextBgColour, doc="See `GetSelectedTextBgColour`");
 
 504     %property(SelectedTextColour, GetSelectedTextColour, doc="See `GetSelectedTextColour`");
 
 508 class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
 
 515 // Information given to cells when drawing them. Contains rendering state,
 
 516 // selection information and rendering style object that can be used to
 
 517 // customize the output.
 
 518 class wxHtmlRenderingInfo
 
 521     wxHtmlRenderingInfo();
 
 522     ~wxHtmlRenderingInfo();
 
 524     void SetSelection(wxHtmlSelection *s);
 
 525     wxHtmlSelection *GetSelection() const;
 
 527     void SetStyle(wxHtmlRenderingStyle *style);
 
 528     wxHtmlRenderingStyle& GetStyle();
 
 530     wxHtmlRenderingState& GetState();
 
 532     %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
 
 533     %property(State, GetState, doc="See `GetState`");
 
 534     %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
 
 537 //---------------------------------------------------------------------------
 
 543     wxHTML_FIND_EXACT             = 1,
 
 544     wxHTML_FIND_NEAREST_BEFORE    = 2,
 
 545     wxHTML_FIND_NEAREST_AFTER     = 4
 
 549 class wxHtmlCell : public wxObject {
 
 551     %typemap(out) wxHtmlCell*;    // turn off this typemap
 
 556     // Turn it back on again
 
 557     %typemap(out) wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); }
 
 565     // Returns the maximum possible length of the cell.
 
 566     // Call Layout at least once before using GetMaxTotalWidth()
 
 567     int GetMaxTotalWidth() const;
 
 569     const wxString& GetId() const;
 
 570     void SetId(const wxString& id);
 
 571     wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
 
 572     wxHtmlCell* GetNext();
 
 573     wxHtmlContainerCell* GetParent();
 
 574     wxHtmlCell* GetFirstChild() const;
 
 576     // Returns cursor to be used when mouse is over the cell:
 
 577     virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const;
 
 579     // Returns cursor to be used when mouse is over the cell:
 
 580     wxCursor GetCursor() const;
 
 581     %pythoncode { GetCursor = wx._deprecated(GetCursor) }
 
 583     // Formatting cells are not visible on the screen, they only alter
 
 585     bool IsFormattingCell() const;
 
 588     void SetLink(const wxHtmlLinkInfo& link);
 
 590     %disownarg(wxHtmlCell*);
 
 591     void SetNext(wxHtmlCell *cell);
 
 592     %cleardisown(wxHtmlCell*);
 
 594     void SetParent(wxHtmlContainerCell *p);
 
 595     void SetPos(int x, int y);
 
 597     void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
 
 598               wxHtmlRenderingInfo& info);
 
 599     void DrawInvisible(wxDC& dc, int x, int y,
 
 600               wxHtmlRenderingInfo& info);
 
 601     const wxHtmlCell* Find(int condition, const void* param);
 
 604     virtual bool ProcessMouseClick(wxHtmlWindowInterface *window,
 
 606                                    const wxMouseEvent& event);
 
 608 // TODO:     bool AdjustPagebreak(int* INOUT,
 
 609 //                                 wxArrayInt& known_pagebreaks);
 
 610     void SetCanLiveOnPagebreak(bool can);
 
 612     // Can the line be broken before this cell?
 
 613     bool IsLinebreakAllowed() const;
 
 615     // Returns True for simple == terminal cells, i.e. not composite ones.
 
 616     // This if for internal usage only and may disappear in future versions!
 
 617     bool IsTerminalCell() const;
 
 619     // Find a cell inside this cell positioned at the given coordinates
 
 620     // (relative to this's positions). Returns NULL if no such cell exists.
 
 621     // The flag can be used to specify whether to look for terminal or
 
 622     // nonterminal cells or both. In either case, returned cell is deepest
 
 623     // cell in cells tree that contains [x,y].
 
 624     wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
 
 625                                   unsigned flags = wxHTML_FIND_EXACT) const;
 
 627     // Returns absolute position of the cell on HTML canvas
 
 628     // If rootCell is provided, then it's considered to be the root of the
 
 629     // hierarchy and the returned value is relative to it.
 
 630     wxPoint GetAbsPos(wxHtmlCell *rootCell = NULL) const;
 
 632     // Returns root cell of the hierarchy (i.e. grand-grand-...-parent that
 
 633     // doesn't have a parent itself)
 
 634     wxHtmlCell *GetRootCell() const;
 
 636     // Returns first (last) terminal cell inside this cell. It may return NULL,
 
 637     // but it is rare -- only if there are no terminals in the tree.
 
 638     wxHtmlCell *GetFirstTerminal() const ;
 
 639     wxHtmlCell *GetLastTerminal() const ;
 
 641     // Returns cell's depth, i.e. how far under the root cell it is
 
 642     // (if it is the root, depth is 0)
 
 643     unsigned GetDepth() const;
 
 645     // Returns True if the cell appears before 'cell' in natural order of
 
 646     // cells (= as they are read). If cell A is (grand)parent of cell B,
 
 647     // then both A.IsBefore(B) and B.IsBefore(A) always return True.
 
 648     bool IsBefore(wxHtmlCell *cell) const;
 
 650     // Converts the cell into text representation. If sel != NULL then
 
 651     // only part of the cell inside the selection is converted.
 
 652     wxString ConvertToText(wxHtmlSelection *sel) const;
 
 654     %property(Cursor, GetCursor, doc="See `GetCursor`");
 
 655     %property(Depth, GetDepth, doc="See `GetDepth`");
 
 656     %property(Descent, GetDescent, doc="See `GetDescent`");
 
 657     %property(FirstChild, GetFirstChild, doc="See `GetFirstChild`");
 
 658     %property(FirstTerminal, GetFirstTerminal, doc="See `GetFirstTerminal`");
 
 659     %property(Height, GetHeight, doc="See `GetHeight`");
 
 660     %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
 
 661     %property(LastTerminal, GetLastTerminal, doc="See `GetLastTerminal`");
 
 662     %property(Link, GetLink, SetLink, doc="See `GetLink` and `SetLink`");
 
 663     %property(MaxTotalWidth, GetMaxTotalWidth, doc="See `GetMaxTotalWidth`");
 
 664     %property(MouseCursor, GetMouseCursor, doc="See `GetMouseCursor`");
 
 665     %property(Next, GetNext, SetNext, doc="See `GetNext` and `SetNext`");
 
 666     %property(Parent, GetParent, SetParent, doc="See `GetParent` and `SetParent`");
 
 667     %property(PosX, GetPosX, doc="See `GetPosX`");
 
 668     %property(PosY, GetPosY, doc="See `GetPosY`");
 
 669     %property(RootCell, GetRootCell, doc="See `GetRootCell`");
 
 670     %property(Width, GetWidth, doc="See `GetWidth`");
 
 674 class  wxHtmlWordCell : public wxHtmlCell
 
 677     wxHtmlWordCell(const wxString& word, wxDC& dc);
 
 678     wxString ConvertToText(wxHtmlSelection *sel) const;
 
 679     bool IsLinebreakAllowed() const;
 
 680     void SetPreviousWord(wxHtmlWordCell *cell);
 
 684 class wxHtmlContainerCell : public wxHtmlCell {
 
 686     wxHtmlContainerCell(wxHtmlContainerCell *parent);
 
 688     %disownarg(wxHtmlCell*);
 
 689     void InsertCell(wxHtmlCell *cell);
 
 690     %cleardisown(wxHtmlCell*);
 
 692     void SetAlignHor(int al);
 
 694     void SetAlignVer(int al);
 
 696     void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
 
 697     int GetIndent(int ind);
 
 698     int GetIndentUnits(int ind);
 
 699     void SetAlign(const wxHtmlTag& tag);
 
 700     void SetWidthFloat(int w, int units);
 
 701     %Rename(SetWidthFloatFromTag, void,  SetWidthFloat(const wxHtmlTag& tag));
 
 702     void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
 
 703     void SetBackgroundColour(const wxColour& clr);
 
 704     wxColour GetBackgroundColour();
 
 705     void SetBorder(const wxColour& clr1, const wxColour& clr2);
 
 706     wxHtmlCell* GetFirstChild();
 
 707     %pragma(python) addtoclass = "GetFirstCell = GetFirstChild"
 
 709     %property(AlignHor, GetAlignHor, SetAlignHor, doc="See `GetAlignHor` and `SetAlignHor`");
 
 710     %property(AlignVer, GetAlignVer, SetAlignVer, doc="See `GetAlignVer` and `SetAlignVer`");
 
 711     %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
 
 712     %property(FirstChild, GetFirstChild, doc="See `GetFirstChild`");
 
 713     %property(Indent, GetIndent, SetIndent, doc="See `GetIndent` and `SetIndent`");
 
 714     %property(IndentUnits, GetIndentUnits, doc="See `GetIndentUnits`");
 
 719 class wxHtmlColourCell : public wxHtmlCell {
 
 721     wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
 
 726 class  wxHtmlFontCell : public wxHtmlCell
 
 729     wxHtmlFontCell(wxFont *font);
 
 733 class wxHtmlWidgetCell : public wxHtmlCell {
 
 735     wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
 
 742 //---------------------------------------------------------------------------
 
 744 //---------------------------------------------------------------------------
 
 748 %{ // here's the C++ version
 
 749 class wxPyHtmlFilter : public wxHtmlFilter {
 
 750     DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter)
 
 752     wxPyHtmlFilter() : wxHtmlFilter() {}
 
 754     // returns True if this filter is able to open&read given file
 
 755     virtual bool CanRead(const wxFSFile& file) const {
 
 758         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 759         if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
 
 760             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 761             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 764         wxPyEndBlockThreads(blocked);
 
 769     // Reads given file and returns HTML document.
 
 770     // Returns empty string if opening failed
 
 771     virtual wxString ReadFile(const wxFSFile& file) const {
 
 774         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 775         if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
 
 776             PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false);  // cast away const
 
 778             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
 
 781                 rval = Py2wxString(ro);
 
 785         wxPyEndBlockThreads(blocked);
 
 792 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter);
 
 796 // And now the version seen by SWIG
 
 798 %rename(HtmlFilter) wxPyHtmlFilter;
 
 799 class wxPyHtmlFilter : public wxObject {
 
 801     %pythonAppend wxPyHtmlFilter   "self._setCallbackInfo(self, HtmlFilter)"
 
 804     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 808 // TODO: wxHtmlFilterHTML
 
 811 //---------------------------------------------------------------------------
 
 814 class wxHtmlWindowInterface
 
 818     wxHtmlWindowInterface();
 
 819     virtual ~wxHtmlWindowInterface();
 
 822         Called by the parser to set window's title to given text.
 
 824     virtual void SetHTMLWindowTitle(const wxString& title) = 0;
 
 827 //         Called when a link is clicked.
 
 829 //         @param link information about the clicked link
 
 831 //     virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link) = 0;
 
 834 //         Called when the parser needs to open another URL (e.g. an image).
 
 836 //         @param type     Type of the URL request (e.g. image)
 
 837 //         @param url      URL the parser wants to open
 
 838 //         @param redirect If the return value is wxHTML_REDIRECT, then the
 
 839 //                         URL to redirect to will be stored in this variable
 
 840 //                         (the pointer must never be NULL)
 
 842 //         @return indicator of how to treat the request
 
 844 //     virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
 
 845 //                                                  const wxString& url,
 
 846 //                                                  wxString *redirect) const = 0;
 
 849         Converts coordinates @a pos relative to given @a cell to
 
 850         physical coordinates in the window.
 
 852     virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
 
 853                                        const wxPoint& pos) const = 0;
 
 855     /// Returns the window used for rendering (may be NULL).
 
 856     virtual wxWindow* GetHTMLWindow() = 0;
 
 858     /// Returns background colour to use by default.
 
 859     virtual wxColour GetHTMLBackgroundColour() const = 0;
 
 861     /// Sets window's background to colour @a clr.
 
 862     virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
 
 864     /// Sets window's background to given bitmap.
 
 865     virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0;
 
 867     /// Sets status bar text.
 
 868     virtual void SetHTMLStatusText(const wxString& text) = 0;
 
 870     /// Type of mouse cursor
 
 873         /// Standard mouse cursor (typically an arrow)
 
 875         /// Cursor shown over links
 
 877         /// Cursor shown over selectable text
 
 882         Returns mouse cursor of given @a type.
 
 884 //    virtual wxCursor GetHTMLCursor(HTMLCursor type) const = 0;
 
 886     %property(HTMLBackgroundColour, GetHTMLBackgroundColour, SetHTMLBackgroundColour, doc="See `GetHTMLBackgroundColour` and `SetHTMLBackgroundColour`");
 
 887     %property(HTMLWindow, GetHTMLWindow, doc="See `GetHTMLWindow`");
 
 891 //---------------------------------------------------------------------------
 
 893 //---------------------------------------------------------------------------
 
 897 //      wxHtmlWindowInterface and wxHtmlWindowMouseHelper
 
 901 class wxPyHtmlWindow : public wxHtmlWindow {
 
 902     DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow)
 
 904     wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1,
 
 905                    const wxPoint& pos = wxDefaultPosition,
 
 906                    const wxSize& size = wxDefaultSize,
 
 907                    long style = wxHW_DEFAULT_STYLE,
 
 908                    const wxString& name = wxPyHtmlWindowNameStr)
 
 909         : wxHtmlWindow(parent, id, pos, size, style, name)  {};
 
 910     wxPyHtmlWindow() : wxHtmlWindow() {};
 
 912     bool ScrollToAnchor(const wxString& anchor) {
 
 913         return wxHtmlWindow::ScrollToAnchor(anchor);
 
 916     bool HasAnchor(const wxString& anchor) {
 
 917         const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
 
 921     void OnLinkClicked(const wxHtmlLinkInfo& link);
 
 923     wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
 
 925                                       wxString *redirect) const;
 
 927     DEC_PYCALLBACK__STRING(OnSetTitle);
 
 928     DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover);
 
 929     DEC_PYCALLBACK_BOOL_CELLINTINTME(OnCellClicked);
 
 934 IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow );
 
 935 IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
 
 936 IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover);
 
 937 IMP_PYCALLBACK_BOOL_CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked);
 
 940 void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
 
 942     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 943     if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) {
 
 944         PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0);
 
 945         wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
 
 948     wxPyEndBlockThreads(blocked);
 
 950         wxHtmlWindow::OnLinkClicked(link);
 
 954 wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
 
 956                                                  wxString *redirect) const {
 
 958     wxHtmlOpeningStatus rval;
 
 959     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 960     if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
 
 962         PyObject* s = wx2PyString(url);
 
 963         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s));
 
 965         if (PyString_Check(ro)
 
 966 #if PYTHON_API_VERSION >= 1009
 
 967             || PyUnicode_Check(ro)
 
 970             *redirect = Py2wxString(ro);
 
 971             rval = wxHTML_REDIRECT;
 
 974             PyObject* num = PyNumber_Int(ro);
 
 975             rval = (wxHtmlOpeningStatus)PyInt_AsLong(num);
 
 980     wxPyEndBlockThreads(blocked);
 
 982         rval = wxHtmlWindow::OnOpeningURL(type, url, redirect);
 
 991 MustHaveApp(wxPyHtmlWindow);
 
 993 %rename(HtmlWindow) wxPyHtmlWindow;
 
 994 class wxPyHtmlWindow : public wxScrolledWindow //,
 
 995                        // public wxHtmlWindowInterface //,
 
 996                        // public wxHtmlWindowMouseHelper
 
 999     %pythonAppend wxPyHtmlWindow      "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
 
1000     %pythonAppend wxPyHtmlWindow()    ""
 
1001     %typemap(out) wxPyHtmlWindow*;    // turn off this typemap
 
1003     wxPyHtmlWindow(wxWindow *parent, int id = -1,
 
1004                  const wxPoint& pos = wxDefaultPosition,
 
1005                  const wxSize& size = wxDefaultSize,
 
1006                  int style=wxHW_DEFAULT_STYLE,
 
1007                  const wxString& name = wxPyHtmlWindowNameStr);
 
1008     %RenameCtor(PreHtmlWindow, wxPyHtmlWindow());
 
1010     // Turn it back on again
 
1011     %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
1013     bool Create(wxWindow *parent, int id = -1,
 
1014                 const wxPoint& pos = wxDefaultPosition,
 
1015                 const wxSize& size = wxDefaultSize,
 
1016                 int style=wxHW_SCROLLBAR_AUTO,
 
1017                 const wxString& name = wxPyHtmlWindowNameStr);
 
1020     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1023     // Set HTML page and display it. !! source is HTML document itself,
 
1024     // it is NOT address/filename of HTML document. If you want to
 
1025     // specify document location, use LoadPage() instead
 
1026     // Return value : False if an error occurred, True otherwise
 
1027     bool SetPage(const wxString& source);
 
1029     // Load HTML page from given location. Location can be either
 
1030     // a) /usr/wxGTK2/docs/html/wx.htm
 
1031     // b) http://www.somewhere.uk/document.htm
 
1032     // c) ftp://ftp.somesite.cz/pub/something.htm
 
1033     // In case there is no prefix (http:,ftp:), the method
 
1034     // will try to find it itself (1. local file, then http or ftp)
 
1035     // After the page is loaded, the method calls SetPage() to display it.
 
1036     // Note : you can also use path relative to previously loaded page
 
1037     // Return value : same as SetPage
 
1038     bool LoadPage(const wxString& location);
 
1040     // Loads HTML page from file
 
1041     bool LoadFile(const wxString& filename);
 
1043     // Append to current page
 
1044     bool AppendToPage(const wxString& source);
 
1046      // Returns full location of opened page
 
1047     wxString GetOpenedPage();
 
1049     // Returns anchor within opened page
 
1050     wxString GetOpenedAnchor();
 
1052     // Returns <TITLE> of opened page or empty string otherwise
 
1053     wxString GetOpenedPageTitle();
 
1055     // Sets frame in which page title will  be displayed. Format is format of
 
1056     // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
 
1057     void SetRelatedFrame(wxFrame* frame, const wxString& format);
 
1058     wxFrame* GetRelatedFrame();
 
1060     // After(!) calling SetRelatedFrame, this sets statusbar slot where messages
 
1061     // will be displayed. Default is -1 = no messages.
 
1062     void SetRelatedStatusBar(int bar);
 
1064     // Sets fonts to be used when displaying HTML page.
 
1066         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1068             if (sizes) temp = int_LIST_helper(sizes);
 
1069             self->SetFonts(normal_face, fixed_face, temp);
 
1075     // Sets font sizes to be relative to the given size or the system
 
1076     // default size; use either specified or default font
 
1077     void SetStandardFonts(int size = -1,
 
1078                           const wxString& normal_face = wxPyEmptyString,
 
1079                           const wxString& fixed_face = wxPyEmptyString);
 
1082         void, SetLabel(const wxString& title),
 
1085     // Sets space between text and window borders.
 
1086     void SetBorders(int b);
 
1088     // Sets the bitmap to use for background (currnetly it will be tiled,
 
1089     // when/if we have CSS support we could add other possibilities...)
 
1090     void SetBackgroundImage(const wxBitmap& bmpBg);
 
1092     // Saves custom settings into cfg config. it will use the path 'path'
 
1093     // if given, otherwise it will save info into currently selected path.
 
1094     // saved values : things set by SetFonts, SetBorders.
 
1095     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1096     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1098     // Goes to previous/next page (in browsing history)
 
1099     // Returns True if successful, False otherwise
 
1101     bool HistoryForward();
 
1102     bool HistoryCanBack();
 
1103     bool HistoryCanForward();
 
1106     void HistoryClear();
 
1108     // Returns pointer to conteiners/cells structure.
 
1109     wxHtmlContainerCell* GetInternalRepresentation();
 
1111     // Returns a pointer to the parser.
 
1112     wxHtmlWinParser* GetParser();
 
1114     bool ScrollToAnchor(const wxString& anchor);
 
1115     bool HasAnchor(const wxString& anchor);
 
1118     static void AddFilter(wxPyHtmlFilter *filter);
 
1120     // Helper functions to select parts of page:
 
1121     void SelectWord(const wxPoint& pos);
 
1122     void SelectLine(const wxPoint& pos);
 
1125     // Convert selection to text:
 
1126     wxString SelectionToText();
 
1128     // Converts current page to text:
 
1131     void OnLinkClicked(const wxHtmlLinkInfo& link);
 
1132     void OnSetTitle(const wxString& title);
 
1133     void OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y);
 
1134     bool OnCellClicked(wxHtmlCell *cell,
 
1135                        wxCoord x, wxCoord y,
 
1136                        const wxMouseEvent& event);
 
1137     wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
 
1138                                       const wxString& url,
 
1139                                       wxString *redirect) const;
 
1140     %MAKE_BASE_FUNC(HtmlWindow, OnLinkClicked);
 
1141     %MAKE_BASE_FUNC(HtmlWindow, OnSetTitle);
 
1142     %MAKE_BASE_FUNC(HtmlWindow, OnCellMouseHover);
 
1143     %MAKE_BASE_FUNC(HtmlWindow, OnCellClicked);
 
1145     static wxVisualAttributes
 
1146     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
1148     /// Type of mouse cursor
 
1151         /// Standard mouse cursor (typically an arrow)
 
1153         /// Cursor shown over links
 
1155         /// Cursor shown over selectable text
 
1159     // Returns standard HTML cursor as used by wxHtmlWindow
 
1160     static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
 
1164 //     // wxHtmlWindowInterface methods:
 
1165 //     virtual void SetHTMLWindowTitle(const wxString& title);
 
1166 //     virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link);
 
1167 //     virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
 
1168 //                                                  const wxString& url,
 
1169 //                                                  wxString *redirect) const;
 
1170 //     virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
 
1171 //                                        const wxPoint& pos) const;
 
1172 //     virtual wxWindow* GetHTMLWindow();
 
1173 //     virtual wxColour GetHTMLBackgroundColour() const;
 
1174 //     virtual void SetHTMLBackgroundColour(const wxColour& clr);
 
1175 //     virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
 
1176 //     virtual void SetHTMLStatusText(const wxString& text);
 
1177 //     virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
 
1179     %property(InternalRepresentation, GetInternalRepresentation, doc="See `GetInternalRepresentation`");
 
1180     %property(OpenedAnchor, GetOpenedAnchor, doc="See `GetOpenedAnchor`");
 
1181     %property(OpenedPage, GetOpenedPage, doc="See `GetOpenedPage`");
 
1182     %property(OpenedPageTitle, GetOpenedPageTitle, doc="See `GetOpenedPageTitle`");
 
1183     %property(Parser, GetParser, doc="See `GetParser`");
 
1184     %property(RelatedFrame, GetRelatedFrame, doc="See `GetRelatedFrame`");
 
1190 //---------------------------------------------------------------------------
 
1191 //---------------------------------------------------------------------------
 
1195 MustHaveApp(wxHtmlDCRenderer);
 
1197 class wxHtmlDCRenderer : public wxObject {
 
1200     ~wxHtmlDCRenderer();
 
1202     void SetDC(wxDC *dc, int maxwidth);
 
1203     void SetSize(int width, int height);
 
1204     void SetHtmlText(const wxString& html,
 
1205                      const wxString& basepath = wxPyEmptyString,
 
1207     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
1209         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1211             if (sizes) temp = int_LIST_helper(sizes);
 
1212             self->SetFonts(normal_face, fixed_face, temp);
 
1218     // Sets font sizes to be relative to the given size or the system
 
1219     // default size; use either specified or default font
 
1220     void SetStandardFonts(int size = -1,
 
1221                           const wxString& normal_face = wxPyEmptyString,
 
1222                           const wxString& fixed_face = wxPyEmptyString);
 
1224     int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
 
1225                int dont_render = FALSE, int to = INT_MAX);
 
1226     int GetTotalHeight();
 
1227                 // returns total height of the html document
 
1228                 // (compare Render's return value with this)
 
1230     %property(TotalHeight, GetTotalHeight, doc="See `GetTotalHeight`");
 
1241 MustHaveApp(wxHtmlPrintout);
 
1243 class wxHtmlPrintout : public wxPyPrintout {
 
1245     wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr);
 
1246     //~wxHtmlPrintout();   wxPrintPreview object takes ownership...
 
1248     void SetHtmlText(const wxString& html,
 
1249                      const wxString &basepath = wxPyEmptyString,
 
1251     void SetHtmlFile(const wxString &htmlfile);
 
1252     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1253     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1255     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
 
1257         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1259             if (sizes) temp = int_LIST_helper(sizes);
 
1260             self->SetFonts(normal_face, fixed_face, temp);
 
1266     // Sets font sizes to be relative to the given size or the system
 
1267     // default size; use either specified or default font
 
1268     void SetStandardFonts(int size = -1,
 
1269                           const wxString& normal_face = wxPyEmptyString,
 
1270                           const wxString& fixed_face = wxPyEmptyString);
 
1272     void SetMargins(float top = 25.2, float bottom = 25.2,
 
1273                     float left = 25.2, float right = 25.2,
 
1276     // Adds input filter
 
1277     static void AddFilter(wxHtmlFilter *filter);
 
1280     static void CleanUpStatics();
 
1285 MustHaveApp(wxHtmlEasyPrinting);
 
1287 class wxHtmlEasyPrinting : public wxObject {
 
1289     wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr,
 
1290                        wxWindow *parentWindow = NULL);
 
1291     ~wxHtmlEasyPrinting();
 
1293     void PreviewFile(const wxString &htmlfile);
 
1294     void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1295     void PrintFile(const wxString &htmlfile);
 
1296     void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString);
 
1297 //    void PrinterSetup();
 
1299     void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
 
1300     void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
 
1303         void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) {
 
1305             if (sizes) temp = int_LIST_helper(sizes);
 
1306             self->SetFonts(normal_face, fixed_face, temp);
 
1312     // Sets font sizes to be relative to the given size or the system
 
1313     // default size; use either specified or default font
 
1314     void SetStandardFonts(int size = -1,
 
1315                           const wxString& normal_face = wxPyEmptyString,
 
1316                           const wxString& fixed_face = wxPyEmptyString);
 
1318     wxPrintData *GetPrintData() {return m_PrintData;}
 
1319     wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
 
1321     %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
 
1322     %property(PrintData, GetPrintData, doc="See `GetPrintData`");
 
1326 //---------------------------------------------------------------------------
 
1327 //---------------------------------------------------------------------------
 
1331 class wxHtmlBookRecord {
 
1333     wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
 
1334                      const wxString& title, const wxString& start);
 
1336     wxString GetBookFile();
 
1337     wxString GetTitle();
 
1338     wxString GetStart();
 
1339     wxString GetBasePath();
 
1341     void SetContentsRange(int start, int end);
 
1342     int GetContentsStart();
 
1343     int GetContentsEnd();
 
1345     void SetTitle(const wxString& title);
 
1346     void SetBasePath(const wxString& path);
 
1347     void SetStart(const wxString& start);
 
1349     wxString GetFullPath(const wxString &page) const;
 
1351     %property(BasePath, GetBasePath, SetBasePath, doc="See `GetBasePath` and `SetBasePath`");
 
1352     %property(BookFile, GetBookFile, doc="See `GetBookFile`");
 
1353     %property(ContentsEnd, GetContentsEnd, doc="See `GetContentsEnd`");
 
1354     %property(ContentsStart, GetContentsStart, doc="See `GetContentsStart`");
 
1355     %property(FullPath, GetFullPath, doc="See `GetFullPath`");
 
1356     %property(Start, GetStart, SetStart, doc="See `GetStart` and `SetStart`");
 
1357     %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
 
1360 //---------------------------------------------------------------------------
 
1361 // WXWIN_COMPATIBILITY_2_4
 
1363 struct wxHtmlContentsItem
 
1366         int GetLevel() { return self->m_Level; }
 
1367         int GetID() { return self->m_ID; }
 
1368         wxString GetName() { return self->m_Name; }
 
1369         wxString GetPage() { return self->m_Page; }
 
1370         wxHtmlBookRecord* GetBook() { return self->m_Book; }
 
1374 //---------------------------------------------------------------------------
 
1376 class wxHtmlSearchStatus
 
1379     //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
 
1380     //                   const wxString& book = wxPyEmptyString);
 
1385     const wxString& GetName();
 
1387     %property(CurIndex, GetCurIndex, doc="See `GetCurIndex`");
 
1388     %property(MaxIndex, GetMaxIndex, doc="See `GetMaxIndex`");
 
1389     %property(Name, GetName, doc="See `GetName`");
 
1392 //---------------------------------------------------------------------------
 
1394 class wxHtmlHelpData {
 
1399     void SetTempDir(const wxString& path);
 
1400     bool AddBook(const wxString& book);
 
1401 //      bool AddBookParam(const wxString& title, const wxString& contfile,
 
1402 //                    const wxString& indexfile=wxPyEmptyString,
 
1403 //                    const wxString& deftopic=wxPyEmptyString,
 
1404 //                    const wxString& path=wxPyEmptyString);
 
1406     wxString FindPageByName(const wxString& page);
 
1407     wxString FindPageById(int id);
 
1409     // TODO: this one needs fixed...
 
1410     const wxHtmlBookRecArray& GetBookRecArray();
 
1412     %property(BookRecArray, GetBookRecArray, doc="See `GetBookRecArray`");
 
1415 //---------------------------------------------------------------------------
 
1428     wxHF_ICONS_BOOK_CHAPTER,
 
1448     wxID_HTML_BOOKMARKSLIST,
 
1449     wxID_HTML_BOOKMARKSADD,
 
1450     wxID_HTML_BOOKMARKSREMOVE,
 
1452     wxID_HTML_INDEXPAGE,
 
1453     wxID_HTML_INDEXLIST,
 
1454     wxID_HTML_INDEXTEXT,
 
1455     wxID_HTML_INDEXBUTTON,
 
1456     wxID_HTML_INDEXBUTTONALL,
 
1458     wxID_HTML_SEARCHPAGE,
 
1459     wxID_HTML_SEARCHTEXT,
 
1460     wxID_HTML_SEARCHLIST,
 
1461     wxID_HTML_SEARCHBUTTON,
 
1462     wxID_HTML_SEARCHCHOICE,
 
1468     typedef wxTreeCtrl wxPyTreeCtrl;
 
1471 MustHaveApp(wxHtmlHelpWindow);
 
1473 class wxHtmlHelpWindow : public wxWindow
 
1476     %pythonAppend wxHtmlHelpWindow    "self._setOORInfo(self)"
 
1477     %pythonAppend wxHtmlHelpWindow()       ""
 
1478     %typemap(out) wxHtmlHelpWindow*;    // turn off this typemap
 
1480     wxHtmlHelpWindow(wxWindow* parent, wxWindowID wxWindowID,
 
1481                      const wxPoint& pos = wxDefaultPosition,
 
1482                      const wxSize& size = wxDefaultSize,
 
1483                      int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1484                      int helpStyle = wxHF_DEFAULT_STYLE,
 
1485                      wxHtmlHelpData* data = NULL);
 
1486     %RenameCtor(PreHtmlHelpWindow, wxHtmlHelpWindow(wxHtmlHelpData* data = NULL));
 
1488     // Turn it back on again
 
1489     %typemap(out) wxHtmlHelpWindow* { $result = wxPyMake_wxObject($1, $owner); }
 
1491     bool Create(wxWindow* parent, wxWindowID id,
 
1492                 const wxPoint& pos = wxDefaultPosition,
 
1493                 const wxSize& size = wxDefaultSize,
 
1494                 int style = wxTAB_TRAVERSAL|wxNO_BORDER,
 
1495                 int helpStyle = wxHF_DEFAULT_STYLE);
 
1497     wxHtmlHelpData* GetData();
 
1498     wxHtmlHelpController* GetController() const;
 
1500     %disownarg( wxHtmlHelpController* controller );
 
1501     void SetController(wxHtmlHelpController* controller);
 
1502     %cleardisown( wxHtmlHelpController* controller );
 
1504     // Displays page x. If not found it will offect the user a choice of
 
1506     // Looking for the page runs in these steps:
 
1507     // 1. try to locate file named x (if x is for example "doc/howto.htm")
 
1508     // 2. try to open starting page of book x
 
1509     // 3. try to find x in contents (if x is for example "How To ...")
 
1510     // 4. try to find x in index (if x is for example "How To ...")
 
1511     bool Display(const wxString& x);
 
1513     // Alternative version that works with numeric ID.
 
1514     // (uses extension to MS format, <param name="ID" value=id>, see docs)
 
1515     %Rename(DisplayID,  bool,  Display(int id));
 
1517     // Displays help window and focuses contents.
 
1518     bool DisplayContents();
 
1520     // Displays help window and focuses index.
 
1521     bool DisplayIndex();
 
1523     // Searches for keyword. Returns true and display page if found, return
 
1525     // Syntax of keyword is Altavista-like:
 
1526     // * words are separated by spaces
 
1527     //   (but "\"hello world\"" is only one world "hello world")
 
1528     // * word may be pretended by + or -
 
1529     //   (+ : page must contain the word ; - : page can't contain the word)
 
1530     // * if there is no + or - before the word, + is default
 
1531     bool KeywordSearch(const wxString& keyword,
 
1532                        wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
 
1534     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
 
1536     // Saves custom settings into cfg config. it will use the path 'path'
 
1537     // if given, otherwise it will save info into currently selected path.
 
1538     // saved values : things set by SetFonts, SetBorders.
 
1539     void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1540     void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
 
1542     // call this to let wxHtmlHelpWindow know page changed
 
1543     void NotifyPageChanged();
 
1545     // Refreshes Contents and Index tabs
 
1546     void RefreshLists();
 
1548     // Gets the HTML window
 
1549     wxHtmlWindow* GetHtmlWindow() const;
 
1551     // Gets the splitter window
 
1552     wxSplitterWindow* GetSplitterWindow();
 
1555     wxToolBar* GetToolBar() const;
 
1557     // Gets the configuration data
 
1558     wxHtmlHelpFrameCfg& GetCfgData();
 
1560     // Gets the tree control
 
1561     wxPyTreeCtrl *GetTreeCtrl() const;
 
1563     %property(CfgData, GetCfgData, doc="See `GetCfgData`");
 
1564     %property(Controller, GetController, SetController, doc="See `GetController` and `SetController`");
 
1565     %property(Data, GetData, doc="See `GetData`");
 
1566     %property(HtmlWindow, GetHtmlWindow, doc="See `GetHtmlWindow`");
 
1567     %property(SplitterWindow, GetSplitterWindow, doc="See `GetSplitterWindow`");
 
1568     %property(ToolBar, GetToolBar, doc="See `GetToolBar`");
 
1569     %property(TreeCtrl, GetTreeCtrl, doc="See `GetTreeCtrl`");
 
1573 class wxHtmlWindowEvent: public wxNotifyEvent
 
1576     wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
 
1577         wxNotifyEvent(commandType, id);
 
1579     void SetURL(const wxString& url);
 
1580     const wxString& GetURL() const;
 
1582     %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
 
1587 MustHaveApp(wxHtmlHelpFrame);
 
1589 class wxHtmlHelpFrame : public wxFrame {
 
1591     %pythonAppend wxHtmlHelpFrame    "self._setOORInfo(self)"
 
1592     %pythonAppend wxHtmlHelpFrame()       ""
 
1593     %typemap(out) wxHtmlHelpFrame*;    // turn off this typemap
 
1595     wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
 
1596                     const wxString& title = wxPyEmptyString,
 
1597                     int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL,
 
1598                     wxConfigBase *config=NULL,
 
1599                     const wxString& rootpath = wxPyEmptyString);
 
1600     %RenameCtor(PreHtmlHelpFrame, wxHtmlHelpFrame(wxHtmlHelpData* data = NULL));
 
1602     // Turn it back on again
 
1603     %typemap(out) wxHtmlHelpFrame* { $result = wxPyMake_wxObject($1, $owner); }
 
1605     bool Create(wxWindow* parent, wxWindowID id,
 
1606                 const wxString& title = wxPyEmptyString,
 
1607                 int style = wxHF_DEFAULT_STYLE,
 
1608                 wxConfigBase *config=NULL,
 
1609                 const wxString& rootpath = wxPyEmptyString);
 
1611     wxHtmlHelpData* GetData();
 
1612     void SetTitleFormat(const wxString& format);
 
1614     void AddGrabIfNeeded();
 
1616     /// Returns the help controller associated with the window.
 
1617     wxHtmlHelpController* GetController() const;
 
1619     /// Sets the help controller associated with the window.
 
1620     %disownarg( wxHtmlHelpController* controller );
 
1621     void SetController(wxHtmlHelpController* controller);
 
1622     %cleardisown( wxHtmlHelpController* controller );
 
1624     /// Returns the help window.
 
1625     wxHtmlHelpWindow* GetHelpWindow() const;
 
1628         %# For compatibility from before the refactor
 
1629         def Display(self, x):
 
1630             return self.GetHelpWindow().Display(x)
 
1631         def DisplayID(self, x):
 
1632             return self.GetHelpWindow().DisplayID(id)
 
1633         def DisplayContents(self):
 
1634             return self.GetHelpWindow().DisplayContents()
 
1635         def DisplayIndex(self):
 
1636             return self.GetHelpWindow().DisplayIndex()
 
1638         def KeywordSearch(self, keyword):
 
1639             return self.GetHelpWindow().KeywordSearch(keyword)
 
1641         def UseConfig(self, config, rootpath=""):
 
1642             return self.GetHelpWindow().UseConfig(config, rootpath)
 
1643         def ReadCustomization(self, config, rootpath=""):
 
1644             return self.GetHelpWindow().ReadCustomization(config, rootpath)
 
1645         def WriteCustomization(self, config, rootpath=""):
 
1646             return self.GetHelpWindow().WriteCustomization(config, rootpath)
 
1649     %property(Controller, GetController, SetController, doc="See `GetController` and `SetController`");
 
1650     %property(Data, GetData, doc="See `GetData`");
 
1651     %property(HelpWindow, GetHelpWindow, doc="See `GetHelpWindow`");
 
1656 MustHaveApp(wxHtmlHelpDialog);
 
1658 class wxHtmlHelpDialog : public wxDialog
 
1661     %pythonAppend wxHtmlHelpDialog    "self._setOORInfo(self)"
 
1662     %pythonAppend wxHtmlHelpDialog()       ""
 
1663     %typemap(out) wxHtmlHelpDialog*;    // turn off this typemap
 
1665     wxHtmlHelpDialog(wxWindow* parent, wxWindowID wxWindowID,
 
1666                     const wxString& title = wxPyEmptyString,
 
1667                     int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
 
1668     %RenameCtor(PreHtmlHelpDialog, wxHtmlHelpDialog(wxHtmlHelpData* data = NULL));
 
1670     // Turn it back on again
 
1671     %typemap(out) wxHtmlHelpDialog* { $result = wxPyMake_wxObject($1, $owner); }
 
1673     bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxPyEmptyString,
 
1674                 int style = wxHF_DEFAULT_STYLE);
 
1676     /// Returns the data associated with this dialog.
 
1677     wxHtmlHelpData* GetData();
 
1679     /// Returns the controller that created this dialog.
 
1680     wxHtmlHelpController* GetController() const;
 
1682     /// Sets the controller associated with this dialog.
 
1683     %disownarg( wxHtmlHelpController* controller );
 
1684     void SetController(wxHtmlHelpController* controller);
 
1685     %cleardisown( wxHtmlHelpController* controller );
 
1687     /// Returns the help window.
 
1688     wxHtmlHelpWindow* GetHelpWindow() const;
 
1690     // Sets format of title of the frame. Must contain exactly one "%s"
 
1691     // (for title of displayed HTML page)
 
1692     void SetTitleFormat(const wxString& format);
 
1694     // Override to add custom buttons to the toolbar
 
1695 //    virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {};
 
1697     %property(Controller, GetController, SetController, doc="See `GetController` and `SetController`");
 
1698     %property(Data, GetData, doc="See `GetData`");
 
1699     %property(HelpWindow, GetHelpWindow, doc="See `GetHelpWindow`");
 
1703 //---------------------------------------------------------------------------
 
1706 // TODO: Make virtual methods of this class overridable in Python.
 
1708 MustHaveApp(wxHelpControllerBase);
 
1710 class wxHelpControllerBase: public wxObject
 
1713 //    wxHelpControllerBase(wxWindow* parentWindow = NULL);
 
1714 //    ~wxHelpControllerBase();
 
1716     %nokwargs Initialize;
 
1717     virtual bool Initialize(const wxString& file, int server );
 
1718     virtual bool Initialize(const wxString& file);
 
1720     virtual void SetViewer(const wxString& viewer, long flags = 0);
 
1722     // If file is "", reloads file given  in Initialize
 
1723     virtual bool LoadFile(const wxString& file = wxEmptyString) /* = 0 */;
 
1725     // Displays the contents
 
1726     virtual bool DisplayContents(void) /* = 0 */;
 
1728     %nokwargs DisplaySection;
 
1730     // Display the given section
 
1731     virtual bool DisplaySection(int sectionNo) /* = 0 */;
 
1733     // Display the section using a context id
 
1734     virtual bool DisplayContextPopup(int contextId);
 
1736     // Display the text in a popup, if possible
 
1737     virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
 
1739     // By default, uses KeywordSection to display a topic. Implementations
 
1740     // may override this for more specific behaviour.
 
1741     virtual bool DisplaySection(const wxString& section);
 
1743     virtual bool DisplayBlock(long blockNo) /* = 0 */;
 
1744     virtual bool KeywordSearch(const wxString& k,
 
1745                                wxHelpSearchMode mode = wxHELP_SEARCH_ALL) /* = 0 */;
 
1747     /// Allows one to override the default settings for the help frame.
 
1748     virtual void SetFrameParameters(const wxString& title,
 
1750                                     const wxPoint& pos = wxDefaultPosition,
 
1751                                     bool newFrameEachTime = false);
 
1753     /// Obtains the latest settings used by the help frame and the help
 
1755     virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
 
1756                                         wxPoint *pos = NULL,
 
1757                                         bool *newFrameEachTime = NULL);
 
1759     virtual bool Quit() /* = 0 */;
 
1761     virtual void OnQuit();
 
1763     /// Set the window that can optionally be used for the help window's parent.
 
1764     virtual void SetParentWindow(wxWindow* win);
 
1766     /// Get the window that can optionally be used for the help window's parent.
 
1767     virtual wxWindow* GetParentWindow() const;
 
1769     %property(ParentWindow, GetParentWindow, SetParentWindow, doc="See `GetParentWindow` and `SetParentWindow`");
 
1775 MustHaveApp(wxHtmlHelpController);
 
1777 class wxHtmlHelpController : public wxHelpControllerBase
 
1780 //    %pythonAppend wxHtmlHelpController "self._setOORInfo(self)"
 
1782     wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
 
1783     ~wxHtmlHelpController();
 
1785     wxHtmlHelpWindow* GetHelpWindow();
 
1786     void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
 
1788     wxHtmlHelpFrame* GetFrame();
 
1789     wxHtmlHelpDialog* GetDialog();
 
1791     void SetTitleFormat(const wxString& format);
 
1792     void SetTempDir(const wxString& path);
 
1793     bool AddBook(const wxString& book, int show_wait_msg = false);
 
1794     void Display(const wxString& x);
 
1795     %Rename(DisplayID,  void,  Display(int id));
 
1796     void DisplayContents();
 
1797     void DisplayIndex();
 
1798     bool KeywordSearch(const wxString& keyword);
 
1799     void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString);
 
1800     void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1801     void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString);
 
1803     void MakeModalIfNeeded();
 
1804     wxWindow* FindTopLevelWindow();
 
1806     %property(Dialog, GetDialog, doc="See `GetDialog`");
 
1807     %property(Frame, GetFrame, doc="See `GetFrame`");
 
1808     %property(HelpWindow, GetHelpWindow, SetHelpWindow, doc="See `GetHelpWindow` and `SetHelpWindow`");
 
1814  * A convenience class particularly for use on wxMac,
 
1815  * where you can only show modal dialogs from a modal
 
1820  * wxHtmlModalHelp help(parent, filename, topic);
 
1822  * If topic is empty, the help contents is displayed.
 
1825 class wxHtmlModalHelp
 
1828     wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
 
1829                     const wxString& topic = wxEmptyString,
 
1830                     int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
 
1834 //---------------------------------------------------------------------------
 
1836     wxPyPtrTypeMap_Add("wxHtmlTagHandler",    "wxPyHtmlTagHandler");
 
1837     wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler");
 
1838     wxPyPtrTypeMap_Add("wxHtmlWindow",        "wxPyHtmlWindow");
 
1839     wxPyPtrTypeMap_Add("wxHtmlFilter",        "wxPyHtmlFilter");
 
1841 //---------------------------------------------------------------------------
 
1842 //---------------------------------------------------------------------------