X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de20db997ddf7ee903076e72e9918caa2e269c19..bf44306ebca5d26e204ef17851516d844bc2f0a7:/wxPython/src/html.i?ds=sidebyside diff --git a/wxPython/src/html.i b/wxPython/src/html.i index 5ec1deae66..04932f374e 100644 --- a/wxPython/src/html.i +++ b/wxPython/src/html.i @@ -14,7 +14,7 @@ %module html %{ -#include "helpers.h" +#include "export.h" #include #include #include @@ -40,16 +40,6 @@ %extern utils.i -//--------------------------------------------------------------------------- - -%{ -// #ifdef __WXMSW__ -// wxString wxPyEmptyStr(""); -// wxPoint wxPyDefaultPosition(wxDefaultPosition); -// wxSize wxPyDefaultSize(wxDefaultSize); -// #endif -%} - %pragma(python) code = "import wx" @@ -85,18 +75,21 @@ enum { //--------------------------------------------------------------------------- -class wxHtmlLinkInfo { +class wxHtmlLinkInfo : public wxObject { public: wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString); wxString GetHref(); wxString GetTarget(); wxMouseEvent* GetEvent(); wxHtmlCell* GetHtmlCell(); + + void SetEvent(const wxMouseEvent *e); + void SetHtmlCell(const wxHtmlCell * e); }; //--------------------------------------------------------------------------- -class wxHtmlTag { +class wxHtmlTag : public wxObject { public: // Never need to create a new tag from Python... //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); @@ -109,7 +102,6 @@ public: //int ScanParam(const wxString& par, const char *format, void* param); wxString GetAllParams(); - bool IsEnding(); bool HasEnding(); int GetBeginPos(); int GetEndPos1(); @@ -119,7 +111,7 @@ public: //--------------------------------------------------------------------------- -class wxHtmlParser { +class wxHtmlParser : public wxObject { public: // wxHtmlParser(); This is an abstract base class... @@ -196,6 +188,7 @@ public: %{ class wxPyHtmlTagHandler : public wxHtmlTagHandler { + DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler); public: wxPyHtmlTagHandler() : wxHtmlTagHandler() {}; @@ -208,12 +201,14 @@ public: PYPRIVATE; }; +IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler); + IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags); IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag); %} -%name(wxHtmlTagHandler) class wxPyHtmlTagHandler { +%name(wxHtmlTagHandler) class wxPyHtmlTagHandler : public wxObject { public: wxPyHtmlTagHandler(); @@ -230,6 +225,7 @@ public: %{ class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler { + DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler); public: wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {}; @@ -243,6 +239,8 @@ public: PYPRIVATE; }; +IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler); + IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags); IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag); %} @@ -275,25 +273,25 @@ public: } void OnExit() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_DECREF(m_tagHandlerClass); m_tagHandlerClass = NULL; for (size_t x=0; x < m_objArray.GetCount(); x++) { PyObject* obj = (PyObject*)m_objArray.Item(x); Py_DECREF(obj); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); }; void FillHandlersTable(wxHtmlWinParser *parser) { // Wave our magic wand... (if it works it's a miracle! ;-) // First, make a new instance of the tag handler - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arg = Py_BuildValue("()"); PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL); Py_DECREF(arg); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); // now figure out where it's C++ object is... wxPyHtmlWinTagHandler* thPtr; @@ -328,7 +326,7 @@ private: //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -class wxHtmlCell { +class wxHtmlCell : public wxObject { public: wxHtmlCell(); @@ -355,6 +353,13 @@ public: }; +class wxHtmlWordCell : public wxHtmlCell +{ +public: + wxHtmlWordCell(const wxString& word, wxDC& dc); +}; + + class wxHtmlContainerCell : public wxHtmlCell { public: wxHtmlContainerCell(wxHtmlContainerCell *parent); @@ -385,6 +390,12 @@ public: }; +class wxHtmlFontCell : public wxHtmlCell +{ +public: + wxHtmlFontCell(wxFont *font); +}; + class wxHtmlWidgetCell : public wxHtmlCell { public: @@ -398,21 +409,9 @@ public: //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -// item of history list -class HtmlHistoryItem { -public: - HtmlHistoryItem(const char* p, const char* a); - - int GetPos(); - void SetPos(int p); - const wxString& GetPage(); - const wxString& GetAnchor(); -}; - - -//--------------------------------------------------------------------------- %{ class wxPyHtmlWindow : public wxHtmlWindow { + DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow); public: wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, @@ -428,19 +427,20 @@ public: PYPRIVATE; }; - +IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); - void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { - bool doSave = wxPyRestoreThread(); - if (m_myInst.findCallback("OnLinkClicked")) { - PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo"); - m_myInst.callCallback(Py_BuildValue("(O)", obj)); +void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked)"))) { + PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo", 0); + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); Py_DECREF(obj); } - else + wxPyEndBlockThreads(state); + if (! found) wxHtmlWindow::OnLinkClicked(link); - wxPySaveThread(doSave); } void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { wxHtmlWindow::OnLinkClicked(link); @@ -452,8 +452,8 @@ void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { %name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow { public: wxPyHtmlWindow(wxWindow *parent, int id = -1, - wxPoint& pos = wxPyDefaultPosition, - wxSize& size = wxPyDefaultSize, + wxPoint& pos = wxDefaultPosition, + wxSize& size = wxDefaultSize, int flags=wxHW_SCROLLBAR_AUTO, char* name = "htmlWindow"); @@ -463,9 +463,12 @@ public: %pragma(python) addtomethod = "__init__:#wx._StdOnScrollCallbacks(self)" - bool SetPage(const char* source); - bool LoadPage(const char* location); + bool SetPage(const wxString& source); + bool LoadPage(const wxString& location); wxString GetOpenedPage(); + wxString GetOpenedAnchor(); + wxString GetOpenedPageTitle(); + void SetRelatedFrame(wxFrame* frame, const char* format); wxFrame* GetRelatedFrame(); void SetRelatedStatusBar(int bar); @@ -481,12 +484,14 @@ public: } } - void SetTitle(const char* title); + void SetTitle(const wxString& title); void SetBorders(int b); - void ReadCustomization(wxConfigBase *cfg, char* path = ""); - void WriteCustomization(wxConfigBase *cfg, char* path = ""); + void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); + void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); bool HistoryBack(); bool HistoryForward(); + bool HistoryCanBack(); + bool HistoryCanForward(); void HistoryClear(); wxHtmlContainerCell* GetInternalRepresentation(); wxHtmlWinParser* GetParser(); @@ -507,7 +512,7 @@ public: //--------------------------------------------------------------------------- -class wxHtmlDCRenderer { +class wxHtmlDCRenderer : public wxObject { public: wxHtmlDCRenderer(); ~wxHtmlDCRenderer(); @@ -533,7 +538,7 @@ enum { class wxHtmlPrintout : public wxPyPrintout { public: wxHtmlPrintout(const char* title = "Printout"); - ~wxHtmlPrintout(); + //~wxHtmlPrintout(); wxPrintPreview object takes ownership... void SetHtmlText(const wxString& html, const wxString &basepath = wxEmptyString, @@ -548,7 +553,7 @@ public: -class wxHtmlEasyPrinting { +class wxHtmlEasyPrinting : public wxObject { public: wxHtmlEasyPrinting(const char* name = "Printing", wxFrame *parent_frame = NULL); @@ -582,9 +587,12 @@ public: inithtmlhelpc(); - //wxClassInfo::CleanUpClasses(); - //wxClassInfo::InitializeClasses(); + wxClassInfo::CleanUpClasses(); + wxClassInfo::InitializeClasses(); + wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler"); + wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler"); + wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow"); %} //---------------------------------------------------------------------- @@ -594,4 +602,3 @@ public: %pragma(python) include="_htmlextras.py"; //--------------------------------------------------------------------------- -