From c731eb47101d4656e5b736ce8e377830911bbe1d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 3 Jul 2002 22:05:30 +0000 Subject: [PATCH] Added wxIEHtmlWin wrappers to wxPython. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/CHANGES.txt | 2 + wxPython/MANIFEST.in | 7 + wxPython/contrib/iewin/IEHtmlWin.cpp | 515 ++++++++++ wxPython/contrib/iewin/IEHtmlWin.h | 93 ++ wxPython/contrib/iewin/_iewinextras.py | 4 + wxPython/contrib/iewin/iewin.cpp | 894 +++++++++++++++++ wxPython/contrib/iewin/iewin.i | 124 +++ wxPython/contrib/iewin/iewin.py | 166 ++++ wxPython/contrib/iewin/readme.txt | 138 +++ wxPython/contrib/iewin/wxactivex.cpp | 1247 ++++++++++++++++++++++++ wxPython/contrib/iewin/wxactivex.h | 300 ++++++ wxPython/demo/Main.py | 2 + wxPython/demo/wxIEHtmlWin.py | 198 ++++ wxPython/distrib/make_installer.py | 1 + wxPython/setup.py | 7 +- 15 files changed, 3696 insertions(+), 2 deletions(-) create mode 100644 wxPython/contrib/iewin/IEHtmlWin.cpp create mode 100644 wxPython/contrib/iewin/IEHtmlWin.h create mode 100644 wxPython/contrib/iewin/_iewinextras.py create mode 100644 wxPython/contrib/iewin/iewin.cpp create mode 100644 wxPython/contrib/iewin/iewin.i create mode 100644 wxPython/contrib/iewin/iewin.py create mode 100644 wxPython/contrib/iewin/readme.txt create mode 100644 wxPython/contrib/iewin/wxactivex.cpp create mode 100644 wxPython/contrib/iewin/wxactivex.h create mode 100644 wxPython/demo/wxIEHtmlWin.py diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index 022ca00977..92b0948b71 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -134,6 +134,8 @@ Fixed a boatload of reference leaks. Added a demo of using a sizer in a wxScrolledWindow, in effect creating a ScrolledPanel. +Added wxIEHtmlWin. + diff --git a/wxPython/MANIFEST.in b/wxPython/MANIFEST.in index 5bd7866968..844ec9f2df 100644 --- a/wxPython/MANIFEST.in +++ b/wxPython/MANIFEST.in @@ -186,6 +186,13 @@ include contrib/gizmos/contrib/src/gizmos/*.cpp include contrib/gizmos/contrib/src/gizmos/*.xpm include contrib/gizmos/contrib/src/gizmos/*.txt +include contrib/iewin/*.txt +include contrib/iewin/*.i +include contrib/iewin/*.py +include contrib/iewin/*.cpp +include contrib/iewin/*.c +include contrib/iewin/*.h + include contrib/dllwidget/*.txt include contrib/dllwidget/*.i include contrib/dllwidget/*.py diff --git a/wxPython/contrib/iewin/IEHtmlWin.cpp b/wxPython/contrib/iewin/IEHtmlWin.cpp new file mode 100644 index 0000000000..ac4131569f --- /dev/null +++ b/wxPython/contrib/iewin/IEHtmlWin.cpp @@ -0,0 +1,515 @@ +#include "IEHtmlWin.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_NEWWINDOW2); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE); +DEFINE_EVENT_TYPE(wxEVT_COMMAND_MSHTML_TITLECHANGE); + +IMPLEMENT_DYNAMIC_CLASS(wxMSHTMLEvent, wxNotifyEvent); + + +////////////////////////////////////////////////////////////////////// +BEGIN_EVENT_TABLE(wxIEHtmlWin, wxActiveX) +END_EVENT_TABLE() + +class FS_DWebBrowserEvents2 : public IDispatch +{ +private: + DECLARE_OLE_UNKNOWN(FS_DWebBrowserEvents2); + + + wxIEHtmlWin *m_iewin; + +public: + FS_DWebBrowserEvents2(wxIEHtmlWin *iewin) : m_iewin(iewin) {} + ~FS_DWebBrowserEvents2() + { + } + + //IDispatch + STDMETHODIMP GetIDsOfNames(REFIID r, OLECHAR** o, unsigned int i, LCID l, DISPID* d) + { + return E_NOTIMPL; + }; + + STDMETHODIMP GetTypeInfo(unsigned int i, LCID l, ITypeInfo** t) + { + return E_NOTIMPL; + }; + + STDMETHODIMP GetTypeInfoCount(unsigned int* i) + { + return E_NOTIMPL; + }; + + void Post(WXTYPE etype, wxString text, long l1 = 0, long l2 = 0) + { + if (! m_iewin || ! m_iewin->GetParent()) + return; + + wxMSHTMLEvent event; + event.SetId(m_iewin->GetId()); + event.SetEventType(etype); + event.m_text1 = text; + event.m_long1 = l1; + event.m_long2 = l2; + + m_iewin->GetParent()->AddPendingEvent(event); + }; + + bool Process(WXTYPE etype, wxString text = "", long l1 = 0, long l2 = 0) + { + if (! m_iewin || ! m_iewin->GetParent()) + return true; + + wxMSHTMLEvent event; + event.SetId(m_iewin->GetId()); + event.SetEventType(etype); + event.m_text1 = text; + event.m_long1 = l1; + event.m_long2 = l2; + + m_iewin->GetParent()->ProcessEvent(event); + + return event.IsAllowed(); + }; + + wxString GetStrArg(VARIANT& v) + { + VARTYPE vt = v.vt & ~VT_BYREF; + + if (vt == VT_VARIANT) + return GetStrArg(*v.pvarVal); + else if (vt == VT_BSTR) + { + if (v.vt & VT_BYREF) + return (v.pbstrVal ? *v.pbstrVal : L""); + else + return v.bstrVal; + } + else + return ""; + }; + +#define STR_ARG(arg) GetStrArg(pDispParams->rgvarg[arg]) + +#define LONG_ARG(arg)\ + (pDispParams->rgvarg[arg].lVal) + + + STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, + WORD wFlags, DISPPARAMS * pDispParams, + VARIANT * pVarResult, EXCEPINFO * pExcepInfo, + unsigned int * puArgErr) + { + if (wFlags & DISPATCH_PROPERTYGET) + return E_NOTIMPL; + + switch (dispIdMember) + { + case DISPID_BEFORENAVIGATE2: + if (Process(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, STR_ARG(5))) + *pDispParams->rgvarg->pboolVal = VARIANT_FALSE; + else + *pDispParams->rgvarg->pboolVal = VARIANT_TRUE; + break; + + case DISPID_NEWWINDOW2: + if (Process(wxEVT_COMMAND_MSHTML_NEWWINDOW2)) + *pDispParams->rgvarg->pboolVal = VARIANT_FALSE; + else + *pDispParams->rgvarg->pboolVal = VARIANT_TRUE; + break; + + case DISPID_PROGRESSCHANGE: + Post(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, "", LONG_ARG(1), LONG_ARG(0)); + break; + + case DISPID_DOCUMENTCOMPLETE: + Post(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, STR_ARG(0)); + break; + + case DISPID_STATUSTEXTCHANGE: + Post(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, STR_ARG(0)); + break; + + case DISPID_TITLECHANGE: + Post(wxEVT_COMMAND_MSHTML_TITLECHANGE, STR_ARG(0)); + break; + } + + return S_OK; + } +}; + +#undef STR_ARG + +DEFINE_OLE_TABLE(FS_DWebBrowserEvents2) + OLE_IINTERFACE(IUnknown) + OLE_INTERFACE(DIID_DWebBrowserEvents2, DWebBrowserEvents2) +END_OLE_TABLE; + + +static const CLSID CLSID_MozillaBrowser = +{ 0x1339B54C, 0x3453, 0x11D2, + { 0x93, 0xB9, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 } }; + + +//#define PROGID L"Shell.Explorer" +#define PROGID CLSID_WebBrowser +//#define PROGID CLSID_HTMLDocument +//#define PROGID L"MSCAL.Calendar" +//#define PROGID L"WordPad.Document.1" +//#define PROGID L"SoftwareFX.ChartFX.20" + + +wxIEHtmlWin::wxIEHtmlWin(wxWindow * parent, wxWindowID id) + : wxActiveX(parent, PROGID, id) +{ + SetupBrowser(); +} + +wxIEHtmlWin::~wxIEHtmlWin() +{ +} + +void wxIEHtmlWin::SetupBrowser() +{ + HRESULT hret; + + // Get IWebBrowser2 Interface + hret = m_webBrowser.QueryInterface(IID_IWebBrowser2, m_ActiveX); + assert(SUCCEEDED(hret)); + + // Web Browser Events + FS_DWebBrowserEvents2 *events = new FS_DWebBrowserEvents2(this); + hret = ConnectAdvise(DIID_DWebBrowserEvents2, events); + if (! SUCCEEDED(hret)) + delete events; + + // web browser setup + m_webBrowser->put_MenuBar(VARIANT_FALSE); + m_webBrowser->put_AddressBar(VARIANT_FALSE); + m_webBrowser->put_StatusBar(VARIANT_FALSE); + m_webBrowser->put_ToolBar(VARIANT_FALSE); + + m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE); + m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE); + + m_webBrowser->Navigate( L"about:blank", NULL, NULL, NULL, NULL ); +} + + +void wxIEHtmlWin::SetEditMode(bool seton) +{ + m_bAmbientUserMode = ! seton; + AmbientPropertyChanged(DISPID_AMBIENT_USERMODE); +}; + +bool wxIEHtmlWin::GetEditMode() +{ + return ! m_bAmbientUserMode; +}; + + +void wxIEHtmlWin::SetCharset(wxString charset) +{ + // HTML Document ? + IDispatch *pDisp = NULL; + HRESULT hret = m_webBrowser->get_Document(&pDisp); + wxAutoOleInterface disp(pDisp); + + if (disp.Ok()) + { + wxAutoOleInterface doc(IID_IHTMLDocument2, disp); + if (doc.Ok()) + doc->put_charset((BSTR) wxConvUTF8.cMB2WC(charset).data()); + }; +}; + + +class IStreamAdaptorBase : public IStream +{ +private: + DECLARE_OLE_UNKNOWN(IStreamAdaptorBase); + +public: + IStreamAdaptorBase() {} + virtual ~IStreamAdaptorBase() {} + + // ISequentialStream + HRESULT STDMETHODCALLTYPE Read(void __RPC_FAR *pv, ULONG cb, ULONG __RPC_FAR *pcbRead) = 0; + HRESULT STDMETHODCALLTYPE Write(const void __RPC_FAR *pv, ULONG cb, ULONG __RPC_FAR *pcbWritten) {return E_NOTIMPL;} + + // IStream + HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER __RPC_FAR *plibNewPosition) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER libNewSize) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE CopyTo(IStream __RPC_FAR *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER __RPC_FAR *pcbRead, ULARGE_INTEGER __RPC_FAR *pcbWritten) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE Commit(DWORD grfCommitFlags) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE Revert(void) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE Stat(STATSTG __RPC_FAR *pstatstg, DWORD grfStatFlag) {return E_NOTIMPL;} + HRESULT STDMETHODCALLTYPE Clone(IStream __RPC_FAR *__RPC_FAR *ppstm) {return E_NOTIMPL;} +}; + +DEFINE_OLE_TABLE(IStreamAdaptorBase) + OLE_IINTERFACE(IUnknown) + OLE_IINTERFACE(ISequentialStream) + OLE_IINTERFACE(IStream) +END_OLE_TABLE; + +class IStreamAdaptor : public IStreamAdaptorBase +{ +private: + istream *m_is; + +public: + + IStreamAdaptor(istream *is) : IStreamAdaptorBase(), m_is(is) + { + wxASSERT(m_is != NULL); + } + ~IStreamAdaptor() + { + delete m_is; + } + + // ISequentialStream + HRESULT STDMETHODCALLTYPE Read(void __RPC_FAR *pv, ULONG cb, ULONG __RPC_FAR *pcbRead) + { + m_is->read((char *) pv, cb); + if (pcbRead) + *pcbRead = m_is->gcount(); + + return S_OK; + }; +}; + + +void wxIEHtmlWin::LoadUrl(const wxString& url) +{ + VARIANTARG navFlag, targetFrame, postData, headers; + navFlag.vt = VT_EMPTY; + navFlag.vt = VT_I2; + navFlag.iVal = navNoReadFromCache; + targetFrame.vt = VT_EMPTY; + postData.vt = VT_EMPTY; + headers.vt = VT_EMPTY; + + HRESULT hret = 0; + hret = m_webBrowser->Navigate((BSTR) wxConvUTF8.cMB2WC(url).data(), + &navFlag, &targetFrame, &postData, &headers); +}; + + +bool wxIEHtmlWin::LoadString(wxString html) +{ + string s = html.c_str(); + istringstream *is = new istringstream(s); + return LoadStream(is); +}; + +bool wxIEHtmlWin::LoadStream(istream *is) +{ + // wrap refernce around stream + IStreamAdaptor *pstrm = new IStreamAdaptor(is); + pstrm->AddRef(); + + wxAutoOleInterface strm(pstrm); + + // Document Interface + IDispatch *pDisp = NULL; + HRESULT hret = m_webBrowser->get_Document(&pDisp); + if (! pDisp) + return false; + wxAutoOleInterface disp(pDisp); + + + // get IPersistStreamInit + wxAutoOleInterface + pPersistStreamInit(IID_IPersistStreamInit, disp); + + if (pPersistStreamInit.Ok()) + { + HRESULT hr = pPersistStreamInit->InitNew(); + if (SUCCEEDED(hr)) + hr = pPersistStreamInit->Load(strm); + }; + + return true; +}; + +bool wxIEHtmlWin::GoBack() +{ + HRESULT hret = 0; + hret = m_webBrowser->GoBack(); + return hret == S_OK; +} + +bool wxIEHtmlWin::GoForward() +{ + HRESULT hret = 0; + hret = m_webBrowser->GoForward(); + return hret == S_OK; +} + +bool wxIEHtmlWin::GoHome() +{ + HRESULT hret = 0; + hret = m_webBrowser->GoHome(); + return hret == S_OK; +} + +bool wxIEHtmlWin::GoSearch() +{ + HRESULT hret = 0; + hret = m_webBrowser->GoSearch(); + return hret == S_OK; +} + +bool wxIEHtmlWin::Refresh(wxIEHtmlRefreshLevel level) +{ + VARIANTARG levelArg; + HRESULT hret = 0; + + levelArg.vt = VT_I2; + levelArg.iVal = level; + hret = m_webBrowser->Refresh2(&levelArg); + return hret == S_OK; +} + +bool wxIEHtmlWin::Stop() +{ + HRESULT hret = 0; + hret = m_webBrowser->Stop(); + return hret == S_OK; +} + +/////////////////////////////////////////////////////////////////////////////// + +static wxAutoOleInterface GetSelObject(IOleObject *oleObject) +{ + // Query for IWebBrowser interface + wxAutoOleInterface wb(IID_IWebBrowser2, oleObject); + if (! wb.Ok()) + return wxAutoOleInterface(); + + IDispatch *iDisp = NULL; + HRESULT hr = wb->get_Document(&iDisp); + if (hr != S_OK) + return wxAutoOleInterface(); + + // Query for Document Interface + wxAutoOleInterface hd(IID_IHTMLDocument2, iDisp); + iDisp->Release(); + + if (! hd.Ok()) + return wxAutoOleInterface(); + + IHTMLSelectionObject *_so = NULL; + hr = hd->get_selection(&_so); + + // take ownership of selection object + wxAutoOleInterface so(_so); + + return so; +}; + +static wxAutoOleInterface GetSelRange(IOleObject *oleObject) +{ + wxAutoOleInterface tr; + + wxAutoOleInterface so(GetSelObject(oleObject)); + if (! so) + return tr; + + IDispatch *iDisp = NULL; + HRESULT hr = so->createRange(&iDisp); + if (hr != S_OK) + return tr; + + // Query for IHTMLTxtRange interface + tr.QueryInterface(IID_IHTMLTxtRange, iDisp); + iDisp->Release(); + return tr; +}; + + +wxString wxIEHtmlWin::GetStringSelection(bool asHTML) +{ + wxAutoOleInterface tr(GetSelRange(m_oleObject)); + if (! tr) + return ""; + + BSTR text = NULL; + HRESULT hr = E_FAIL; + + if (asHTML) + hr = tr->get_htmlText(&text); + else + hr = tr->get_text(&text); + if (hr != S_OK) + return ""; + + wxString s = text; + SysFreeString(text); + + return s; +}; + +wxString wxIEHtmlWin::GetText(bool asHTML) +{ + if (! m_webBrowser.Ok()) + return ""; + + // get document dispatch interface + IDispatch *iDisp = NULL; + HRESULT hr = m_webBrowser->get_Document(&iDisp); + if (hr != S_OK) + return ""; + + // Query for Document Interface + wxAutoOleInterface hd(IID_IHTMLDocument2, iDisp); + iDisp->Release(); + + if (! hd.Ok()) + return ""; + + // get body element + IHTMLElement *_body = NULL; + hd->get_body(&_body); + if (! _body) + return ""; + wxAutoOleInterface body(_body); + + // get inner text + BSTR text = NULL; + hr = E_FAIL; + + if (asHTML) + hr = body->get_innerHTML(&text); + else + hr = body->get_innerText(&text); + if (hr != S_OK) + return ""; + + wxString s = text; + SysFreeString(text); + + return s; +}; diff --git a/wxPython/contrib/iewin/IEHtmlWin.h b/wxPython/contrib/iewin/IEHtmlWin.h new file mode 100644 index 0000000000..c62f1d7b8d --- /dev/null +++ b/wxPython/contrib/iewin/IEHtmlWin.h @@ -0,0 +1,93 @@ +#ifndef _IEHTMLWIN_H_ +#define _IEHTMLWIN_H_ +#pragma warning( disable : 4101 4786) +#pragma warning( disable : 4786) + + +#include +#include +#include +#include +using namespace std; + +#include "wxactivex.h" + +class wxMSHTMLEvent : public wxNotifyEvent +{ +public: + wxMSHTMLEvent(wxEventType commandType = wxEVT_NULL, int id = 0) + : wxNotifyEvent(commandType, id) + {} + + wxString GetText() { return m_text1; } + long GetLong1() { return m_long1; } + long GetLong2() { return m_long2; } + + wxString m_text1; + long m_long1, m_long2; + + virtual wxEvent *Clone() const { return new wxMSHTMLEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS(wxMSHTMLEvent) +}; + +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, 0) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_NEWWINDOW2, 0) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, 0) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, 0) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, 0) + DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MSHTML_TITLECHANGE, 0) +END_DECLARE_EVENT_TYPES() + +typedef void (wxEvtHandler::*wxMSHTMLEventFunction)(wxMSHTMLEvent&); + +#define EVT_MSHTML_BEFORENAVIGATE2(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), +#define EVT_MSHTML_NEWWINDOW2(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_NEWWINDOW2, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), +#define EVT_MSHTML_DOCUMENTCOMPLETE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), +#define EVT_MSHTML_PROGRESSCHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), +#define EVT_MSHTML_STATUSTEXTCHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), +#define EVT_MSHTML_TITLECHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_TITLECHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMSHTMLEventFunction) & fn, NULL ), + + +enum wxIEHtmlRefreshLevel { + wxIEHTML_REFRESH_NORMAL = 0, + wxIEHTML_REFRESH_IFEXPIRED = 1, + wxIEHTML_REFRESH_CONTINUE = 2, + wxIEHTML_REFRESH_COMPLETELY = 3 +}; + + +class wxIEHtmlWin : public wxActiveX +{ +public: + wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1); + virtual ~wxIEHtmlWin(); + + void LoadUrl(const wxString&); + bool LoadString(wxString html); + bool LoadStream(istream *strm); + + void SetCharset(wxString charset); + void SetEditMode(bool seton); + bool GetEditMode(); + wxString GetStringSelection(bool asHTML = false); + wxString GetText(bool asHTML = false); + + bool GoBack(); + bool GoForward(); + bool GoHome(); + bool GoSearch(); + bool Refresh(wxIEHtmlRefreshLevel level); + bool Stop(); + + DECLARE_EVENT_TABLE(); + +protected: + void SetupBrowser(); + + wxAutoOleInterface m_webBrowser; +}; + +#endif /* _IEHTMLWIN_H_ */ diff --git a/wxPython/contrib/iewin/_iewinextras.py b/wxPython/contrib/iewin/_iewinextras.py new file mode 100644 index 0000000000..d813dcfcfc --- /dev/null +++ b/wxPython/contrib/iewin/_iewinextras.py @@ -0,0 +1,4 @@ +# Stuff these names into the wx namespace so wxPyConstructObject can find them + +wx.wxMSHTMLEventPtr = wxMSHTMLEventPtr +wx.wxIEHtmlWinPtr = wxIEHtmlWinPtr diff --git a/wxPython/contrib/iewin/iewin.cpp b/wxPython/contrib/iewin/iewin.cpp new file mode 100644 index 0000000000..9ef26c1bc4 --- /dev/null +++ b/wxPython/contrib/iewin/iewin.cpp @@ -0,0 +1,894 @@ +/* + * FILE : contrib/iewin/iewin.cpp + * + * This file was automatically generated by : + * Simplified Wrapper and Interface Generator (SWIG) + * Version 1.1 (Build 883) + * + * Portions Copyright (c) 1995-1998 + * The University of Utah and The Regents of the University of California. + * Permission is granted to distribute this file in any manner provided + * this notice remains intact. + * + * Do not make changes to this file--changes will be lost! + * + */ + + +#define SWIGCODE +/* Implementation : PYTHON */ + +#define SWIGPYTHON +#include +#include +/* Definitions for Windows/Unix exporting */ +#if defined(__WIN32__) +# if defined(_MSC_VER) +# define SWIGEXPORT(a) __declspec(dllexport) a +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a) a _export +# else +# define SWIGEXPORT(a) a +# endif +# endif +#else +# define SWIGEXPORT(a) a +#endif + +#include "Python.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void SWIG_MakePtr(char *, void *, char *); +extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *)); +extern char *SWIG_GetPtr(char *, void **, char *); +extern char *SWIG_GetPtrObj(PyObject *, void **, char *); +extern void SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); +extern PyObject *SWIG_newvarlink(void); +#ifdef __cplusplus +} +#endif +#define SWIG_init initiewinc + +#define SWIG_name "iewinc" + +#include "wxPython.h" +#include "IEHtmlWin.h" + + +static PyObject* t_output_helper(PyObject* target, PyObject* o) { + PyObject* o2; + PyObject* o3; + + if (!target) { + target = o; + } else if (target == Py_None) { + Py_DECREF(Py_None); + target = o; + } else { + if (!PyTuple_Check(target)) { + o2 = target; + target = PyTuple_New(1); + PyTuple_SetItem(target, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SetItem(o3, 0, o); + + o2 = target; + target = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return target; +} +#ifdef __cplusplus +extern "C" { +#endif +static void *SwigwxMSHTMLEventTowxNotifyEvent(void *ptr) { + wxMSHTMLEvent *src; + wxNotifyEvent *dest; + src = (wxMSHTMLEvent *) ptr; + dest = (wxNotifyEvent *) src; + return (void *) dest; +} + +static void *SwigwxMSHTMLEventTowxCommandEvent(void *ptr) { + wxMSHTMLEvent *src; + wxCommandEvent *dest; + src = (wxMSHTMLEvent *) ptr; + dest = (wxCommandEvent *) src; + return (void *) dest; +} + +static void *SwigwxMSHTMLEventTowxEvent(void *ptr) { + wxMSHTMLEvent *src; + wxEvent *dest; + src = (wxMSHTMLEvent *) ptr; + dest = (wxEvent *) src; + return (void *) dest; +} + +static void *SwigwxMSHTMLEventTowxObject(void *ptr) { + wxMSHTMLEvent *src; + wxObject *dest; + src = (wxMSHTMLEvent *) ptr; + dest = (wxObject *) src; + return (void *) dest; +} + +#define new_wxMSHTMLEvent(_swigarg0,_swigarg1) (new wxMSHTMLEvent(_swigarg0,_swigarg1)) +static PyObject *_wrap_new_wxMSHTMLEvent(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxMSHTMLEvent * _result; + wxEventType _arg0 = (wxEventType ) wxEVT_NULL; + int _arg1 = (int ) 0; + char *_kwnames[] = { "commandType","id", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|ii:new_wxMSHTMLEvent",_kwnames,&_arg0,&_arg1)) + return NULL; +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (wxMSHTMLEvent *)new_wxMSHTMLEvent(_arg0,_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxMSHTMLEvent_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + +#define wxMSHTMLEvent_GetText(_swigobj) (_swigobj->GetText()) +static PyObject *_wrap_wxMSHTMLEvent_GetText(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxString * _result; + wxMSHTMLEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMSHTMLEvent_GetText",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMSHTMLEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMSHTMLEvent_GetText. Expected _wxMSHTMLEvent_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = new wxString (wxMSHTMLEvent_GetText(_arg0)); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +}{ +#if wxUSE_UNICODE + _resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len()); +#else + _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); +#endif +} +{ + delete _result; +} + return _resultobj; +} + +#define wxMSHTMLEvent_GetLong1(_swigobj) (_swigobj->GetLong1()) +static PyObject *_wrap_wxMSHTMLEvent_GetLong1(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + long _result; + wxMSHTMLEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMSHTMLEvent_GetLong1",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMSHTMLEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMSHTMLEvent_GetLong1. Expected _wxMSHTMLEvent_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (long )wxMSHTMLEvent_GetLong1(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("l",_result); + return _resultobj; +} + +#define wxMSHTMLEvent_GetLong2(_swigobj) (_swigobj->GetLong2()) +static PyObject *_wrap_wxMSHTMLEvent_GetLong2(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + long _result; + wxMSHTMLEvent * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMSHTMLEvent_GetLong2",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMSHTMLEvent_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMSHTMLEvent_GetLong2. Expected _wxMSHTMLEvent_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (long )wxMSHTMLEvent_GetLong2(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("l",_result); + return _resultobj; +} + +static void *SwigwxIEHtmlWinTowxWindow(void *ptr) { + wxIEHtmlWin *src; + wxWindow *dest; + src = (wxIEHtmlWin *) ptr; + dest = (wxWindow *) src; + return (void *) dest; +} + +static void *SwigwxIEHtmlWinTowxEvtHandler(void *ptr) { + wxIEHtmlWin *src; + wxEvtHandler *dest; + src = (wxIEHtmlWin *) ptr; + dest = (wxEvtHandler *) src; + return (void *) dest; +} + +static void *SwigwxIEHtmlWinTowxObject(void *ptr) { + wxIEHtmlWin *src; + wxObject *dest; + src = (wxIEHtmlWin *) ptr; + dest = (wxObject *) src; + return (void *) dest; +} + +#define new_wxIEHtmlWin(_swigarg0,_swigarg1) (new wxIEHtmlWin(_swigarg0,_swigarg1)) +static PyObject *_wrap_new_wxIEHtmlWin(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxIEHtmlWin * _result; + wxWindow * _arg0; + wxWindowID _arg1 = (wxWindowID ) -1; + PyObject * _argo0 = 0; + char *_kwnames[] = { "parent","id", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:new_wxIEHtmlWin",_kwnames,&_argo0,&_arg1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of new_wxIEHtmlWin. Expected _wxWindow_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (wxIEHtmlWin *)new_wxIEHtmlWin(_arg0,_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxIEHtmlWin_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + +#define wxIEHtmlWin_LoadUrl(_swigobj,_swigarg0) (_swigobj->LoadUrl(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_LoadUrl(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxIEHtmlWin * _arg0; + wxString * _arg1; + PyObject * _argo0 = 0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","arg2", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxIEHtmlWin_LoadUrl",_kwnames,&_argo0,&_obj1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_LoadUrl. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + _arg1 = wxString_in_helper(_obj1); + if (_arg1 == NULL) + return NULL; +} +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxIEHtmlWin_LoadUrl(_arg0,*_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; +{ + if (_obj1) + delete _arg1; +} + return _resultobj; +} + +#define wxIEHtmlWin_LoadString(_swigobj,_swigarg0) (_swigobj->LoadString(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_LoadString(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + wxString * _arg1; + PyObject * _argo0 = 0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","html", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxIEHtmlWin_LoadString",_kwnames,&_argo0,&_obj1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_LoadString. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + _arg1 = wxString_in_helper(_obj1); + if (_arg1 == NULL) + return NULL; +} +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_LoadString(_arg0,*_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); +{ + if (_obj1) + delete _arg1; +} + return _resultobj; +} + +#define wxIEHtmlWin_SetCharset(_swigobj,_swigarg0) (_swigobj->SetCharset(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_SetCharset(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxIEHtmlWin * _arg0; + wxString * _arg1; + PyObject * _argo0 = 0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","charset", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxIEHtmlWin_SetCharset",_kwnames,&_argo0,&_obj1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_SetCharset. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + _arg1 = wxString_in_helper(_obj1); + if (_arg1 == NULL) + return NULL; +} +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxIEHtmlWin_SetCharset(_arg0,*_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; +{ + if (_obj1) + delete _arg1; +} + return _resultobj; +} + +#define wxIEHtmlWin_SetEditMode(_swigobj,_swigarg0) (_swigobj->SetEditMode(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_SetEditMode(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxIEHtmlWin * _arg0; + bool _arg1; + PyObject * _argo0 = 0; + int tempbool1; + char *_kwnames[] = { "self","seton", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxIEHtmlWin_SetEditMode",_kwnames,&_argo0,&tempbool1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_SetEditMode. Expected _wxIEHtmlWin_p."); + return NULL; + } + } + _arg1 = (bool ) tempbool1; +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxIEHtmlWin_SetEditMode(_arg0,_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +#define wxIEHtmlWin_GetEditMode(_swigobj) (_swigobj->GetEditMode()) +static PyObject *_wrap_wxIEHtmlWin_GetEditMode(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_GetEditMode",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GetEditMode. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_GetEditMode(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_GetStringSelection(_swigobj,_swigarg0) (_swigobj->GetStringSelection(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_GetStringSelection(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxString * _result; + wxIEHtmlWin * _arg0; + bool _arg1 = (bool ) FALSE; + PyObject * _argo0 = 0; + int tempbool1 = (int) FALSE; + char *_kwnames[] = { "self","asHTML", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:wxIEHtmlWin_GetStringSelection",_kwnames,&_argo0,&tempbool1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GetStringSelection. Expected _wxIEHtmlWin_p."); + return NULL; + } + } + _arg1 = (bool ) tempbool1; +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = new wxString (wxIEHtmlWin_GetStringSelection(_arg0,_arg1)); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +}{ +#if wxUSE_UNICODE + _resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len()); +#else + _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); +#endif +} +{ + delete _result; +} + return _resultobj; +} + +#define wxIEHtmlWin_GetText(_swigobj,_swigarg0) (_swigobj->GetText(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_GetText(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxString * _result; + wxIEHtmlWin * _arg0; + bool _arg1 = (bool ) FALSE; + PyObject * _argo0 = 0; + int tempbool1 = (int) FALSE; + char *_kwnames[] = { "self","asHTML", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:wxIEHtmlWin_GetText",_kwnames,&_argo0,&tempbool1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GetText. Expected _wxIEHtmlWin_p."); + return NULL; + } + } + _arg1 = (bool ) tempbool1; +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = new wxString (wxIEHtmlWin_GetText(_arg0,_arg1)); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +}{ +#if wxUSE_UNICODE + _resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len()); +#else + _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); +#endif +} +{ + delete _result; +} + return _resultobj; +} + +#define wxIEHtmlWin_GoBack(_swigobj) (_swigobj->GoBack()) +static PyObject *_wrap_wxIEHtmlWin_GoBack(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_GoBack",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GoBack. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_GoBack(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_GoForward(_swigobj) (_swigobj->GoForward()) +static PyObject *_wrap_wxIEHtmlWin_GoForward(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_GoForward",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GoForward. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_GoForward(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_GoHome(_swigobj) (_swigobj->GoHome()) +static PyObject *_wrap_wxIEHtmlWin_GoHome(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_GoHome",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GoHome. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_GoHome(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_GoSearch(_swigobj) (_swigobj->GoSearch()) +static PyObject *_wrap_wxIEHtmlWin_GoSearch(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_GoSearch",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_GoSearch. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_GoSearch(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_Refresh(_swigobj,_swigarg0) (_swigobj->Refresh(_swigarg0)) +static PyObject *_wrap_wxIEHtmlWin_Refresh(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + wxIEHtmlRefreshLevel _arg1; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self","level", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxIEHtmlWin_Refresh",_kwnames,&_argo0,&_arg1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_Refresh. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_Refresh(_arg0,_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +#define wxIEHtmlWin_Stop(_swigobj) (_swigobj->Stop()) +static PyObject *_wrap_wxIEHtmlWin_Stop(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + bool _result; + wxIEHtmlWin * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIEHtmlWin_Stop",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIEHtmlWin_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIEHtmlWin_Stop. Expected _wxIEHtmlWin_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (bool )wxIEHtmlWin_Stop(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyMethodDef iewincMethods[] = { + { "wxIEHtmlWin_Stop", (PyCFunction) _wrap_wxIEHtmlWin_Stop, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_Refresh", (PyCFunction) _wrap_wxIEHtmlWin_Refresh, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GoSearch", (PyCFunction) _wrap_wxIEHtmlWin_GoSearch, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GoHome", (PyCFunction) _wrap_wxIEHtmlWin_GoHome, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GoForward", (PyCFunction) _wrap_wxIEHtmlWin_GoForward, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GoBack", (PyCFunction) _wrap_wxIEHtmlWin_GoBack, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GetText", (PyCFunction) _wrap_wxIEHtmlWin_GetText, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GetStringSelection", (PyCFunction) _wrap_wxIEHtmlWin_GetStringSelection, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_GetEditMode", (PyCFunction) _wrap_wxIEHtmlWin_GetEditMode, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_SetEditMode", (PyCFunction) _wrap_wxIEHtmlWin_SetEditMode, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_SetCharset", (PyCFunction) _wrap_wxIEHtmlWin_SetCharset, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_LoadString", (PyCFunction) _wrap_wxIEHtmlWin_LoadString, METH_VARARGS | METH_KEYWORDS }, + { "wxIEHtmlWin_LoadUrl", (PyCFunction) _wrap_wxIEHtmlWin_LoadUrl, METH_VARARGS | METH_KEYWORDS }, + { "new_wxIEHtmlWin", (PyCFunction) _wrap_new_wxIEHtmlWin, METH_VARARGS | METH_KEYWORDS }, + { "wxMSHTMLEvent_GetLong2", (PyCFunction) _wrap_wxMSHTMLEvent_GetLong2, METH_VARARGS | METH_KEYWORDS }, + { "wxMSHTMLEvent_GetLong1", (PyCFunction) _wrap_wxMSHTMLEvent_GetLong1, METH_VARARGS | METH_KEYWORDS }, + { "wxMSHTMLEvent_GetText", (PyCFunction) _wrap_wxMSHTMLEvent_GetText, METH_VARARGS | METH_KEYWORDS }, + { "new_wxMSHTMLEvent", (PyCFunction) _wrap_new_wxMSHTMLEvent, METH_VARARGS | METH_KEYWORDS }, + { NULL, NULL } +}; +#ifdef __cplusplus +} +#endif +/* + * This table is used by the pointer type-checker + */ +static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { + { "_wxEvent","_wxMSHTMLEvent",SwigwxMSHTMLEventTowxEvent}, + { "_signed_long","_long",0}, + { "_wxPrintQuality","_wxCoord",0}, + { "_wxPrintQuality","_int",0}, + { "_wxPrintQuality","_signed_int",0}, + { "_wxPrintQuality","_unsigned_int",0}, + { "_wxPrintQuality","_wxWindowID",0}, + { "_wxPrintQuality","_uint",0}, + { "_wxPrintQuality","_EBool",0}, + { "_wxPrintQuality","_size_t",0}, + { "_wxPrintQuality","_time_t",0}, + { "_wxNotifyEvent","_wxMSHTMLEvent",SwigwxMSHTMLEventTowxNotifyEvent}, + { "_byte","_unsigned_char",0}, + { "_long","_unsigned_long",0}, + { "_long","_signed_long",0}, + { "_size_t","_wxCoord",0}, + { "_size_t","_wxPrintQuality",0}, + { "_size_t","_time_t",0}, + { "_size_t","_unsigned_int",0}, + { "_size_t","_int",0}, + { "_size_t","_wxWindowID",0}, + { "_size_t","_uint",0}, + { "_uint","_wxCoord",0}, + { "_uint","_wxPrintQuality",0}, + { "_uint","_time_t",0}, + { "_uint","_size_t",0}, + { "_uint","_unsigned_int",0}, + { "_uint","_int",0}, + { "_uint","_wxWindowID",0}, + { "_wxChar","_char",0}, + { "_wxCommandEvent","_wxMSHTMLEvent",SwigwxMSHTMLEventTowxCommandEvent}, + { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, + { "_EBool","_wxCoord",0}, + { "_EBool","_wxPrintQuality",0}, + { "_EBool","_signed_int",0}, + { "_EBool","_int",0}, + { "_EBool","_wxWindowID",0}, + { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, + { "_signed_int","_wxCoord",0}, + { "_signed_int","_wxPrintQuality",0}, + { "_signed_int","_EBool",0}, + { "_signed_int","_wxWindowID",0}, + { "_signed_int","_int",0}, + { "_WXTYPE","_wxDateTime_t",0}, + { "_WXTYPE","_short",0}, + { "_WXTYPE","_signed_short",0}, + { "_WXTYPE","_unsigned_short",0}, + { "_unsigned_short","_wxDateTime_t",0}, + { "_unsigned_short","_WXTYPE",0}, + { "_unsigned_short","_short",0}, + { "_wxObject","_wxIEHtmlWin",SwigwxIEHtmlWinTowxObject}, + { "_wxObject","_wxMSHTMLEvent",SwigwxMSHTMLEventTowxObject}, + { "_signed_short","_WXTYPE",0}, + { "_signed_short","_short",0}, + { "_unsigned_char","_byte",0}, + { "_unsigned_int","_wxCoord",0}, + { "_unsigned_int","_wxPrintQuality",0}, + { "_unsigned_int","_time_t",0}, + { "_unsigned_int","_size_t",0}, + { "_unsigned_int","_uint",0}, + { "_unsigned_int","_wxWindowID",0}, + { "_unsigned_int","_int",0}, + { "_short","_wxDateTime_t",0}, + { "_short","_WXTYPE",0}, + { "_short","_unsigned_short",0}, + { "_short","_signed_short",0}, + { "_wxWindowID","_wxCoord",0}, + { "_wxWindowID","_wxPrintQuality",0}, + { "_wxWindowID","_time_t",0}, + { "_wxWindowID","_size_t",0}, + { "_wxWindowID","_EBool",0}, + { "_wxWindowID","_uint",0}, + { "_wxWindowID","_int",0}, + { "_wxWindowID","_signed_int",0}, + { "_wxWindowID","_unsigned_int",0}, + { "_int","_wxCoord",0}, + { "_int","_wxPrintQuality",0}, + { "_int","_time_t",0}, + { "_int","_size_t",0}, + { "_int","_EBool",0}, + { "_int","_uint",0}, + { "_int","_wxWindowID",0}, + { "_int","_unsigned_int",0}, + { "_int","_signed_int",0}, + { "_wxDateTime_t","_unsigned_short",0}, + { "_wxDateTime_t","_short",0}, + { "_wxDateTime_t","_WXTYPE",0}, + { "_time_t","_wxCoord",0}, + { "_time_t","_wxPrintQuality",0}, + { "_time_t","_unsigned_int",0}, + { "_time_t","_int",0}, + { "_time_t","_wxWindowID",0}, + { "_time_t","_uint",0}, + { "_time_t","_size_t",0}, + { "_wxCoord","_int",0}, + { "_wxCoord","_signed_int",0}, + { "_wxCoord","_unsigned_int",0}, + { "_wxCoord","_wxWindowID",0}, + { "_wxCoord","_uint",0}, + { "_wxCoord","_EBool",0}, + { "_wxCoord","_size_t",0}, + { "_wxCoord","_time_t",0}, + { "_wxCoord","_wxPrintQuality",0}, + { "_wxEvtHandler","_wxIEHtmlWin",SwigwxIEHtmlWinTowxEvtHandler}, + { "_wxWindow","_wxIEHtmlWin",SwigwxIEHtmlWinTowxWindow}, +{0,0,0}}; + +static PyObject *SWIG_globals; +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT(void) initiewinc() { + PyObject *m, *d; + SWIG_globals = SWIG_newvarlink(); + m = Py_InitModule("iewinc", iewincMethods); + d = PyModule_GetDict(m); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2)); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_NEWWINDOW2", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_NEWWINDOW2)); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE)); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_PROGRESSCHANGE", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_PROGRESSCHANGE)); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE)); + PyDict_SetItemString(d,"wxEVT_COMMAND_MSHTML_TITLECHANGE", PyInt_FromLong((long) wxEVT_COMMAND_MSHTML_TITLECHANGE)); + PyDict_SetItemString(d,"wxIEHTML_REFRESH_NORMAL", PyInt_FromLong((long) wxIEHTML_REFRESH_NORMAL)); + PyDict_SetItemString(d,"wxIEHTML_REFRESH_IFEXPIRED", PyInt_FromLong((long) wxIEHTML_REFRESH_IFEXPIRED)); + PyDict_SetItemString(d,"wxIEHTML_REFRESH_CONTINUE", PyInt_FromLong((long) wxIEHTML_REFRESH_CONTINUE)); + PyDict_SetItemString(d,"wxIEHTML_REFRESH_COMPLETELY", PyInt_FromLong((long) wxIEHTML_REFRESH_COMPLETELY)); + + + wxClassInfo::CleanUpClasses(); + wxClassInfo::InitializeClasses(); + +{ + int i; + for (i = 0; _swig_mapping[i].n1; i++) + SWIG_RegisterMapping(_swig_mapping[i].n1,_swig_mapping[i].n2,_swig_mapping[i].pcnv); +} +} diff --git a/wxPython/contrib/iewin/iewin.i b/wxPython/contrib/iewin/iewin.i new file mode 100644 index 0000000000..0259c427a2 --- /dev/null +++ b/wxPython/contrib/iewin/iewin.i @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: iewin.i +// Purpose: Internet Explorer in a wxWindow +// +// Author: Robin Dunn +// +// Created: 20-Apr-2001 +// RCS-ID: $Id$ +// Copyright: (c) 2001 by Total Control Software +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + + +%module iewin + +%{ +#include "wxPython.h" +#include "IEHtmlWin.h" +%} + +//--------------------------------------------------------------------------- + +%include typemaps.i +%include my_typemaps.i + +%extern wx.i +%extern windows.i +%extern _defs.i +%extern misc.i +%extern events.i + +%pragma(python) code = "import wx" + +//--------------------------------------------------------------------------- + +class wxMSHTMLEvent : public wxNotifyEvent +{ +public: + wxMSHTMLEvent(wxEventType commandType = wxEVT_NULL, int id = 0); + wxString GetText(); + long GetLong1(); + long GetLong2(); +}; + + +enum { + wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, + wxEVT_COMMAND_MSHTML_NEWWINDOW2, + wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, + wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, + wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, + wxEVT_COMMAND_MSHTML_TITLECHANGE, +}; + + +%pragma(python) code = " +def EVT_MSHTML_BEFORENAVIGATE2(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, func) + +def EVT_MSHTML_NEWWINDOW2(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_NEWWINDOW2, func) + +def EVT_MSHTML_DOCUMENTCOMPLETE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, func) + +def EVT_MSHTML_PROGRESSCHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, func) + +def EVT_MSHTML_STATUSTEXTCHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, func) + +def EVT_MSHTML_TITLECHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_TITLECHANGE, func) +" + +//--------------------------------------------------------------------------- + +enum wxIEHtmlRefreshLevel { + wxIEHTML_REFRESH_NORMAL = 0, + wxIEHTML_REFRESH_IFEXPIRED = 1, + wxIEHTML_REFRESH_CONTINUE = 2, + wxIEHTML_REFRESH_COMPLETELY = 3 +}; + + +class wxIEHtmlWin : public wxWindow /* wxActiveX */ +{ +public: + wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1); + + void LoadUrl(const wxString&); + bool LoadString(wxString html); + /* bool LoadStream(istream *strm); */ + + void SetCharset(wxString charset); + void SetEditMode(bool seton); + bool GetEditMode(); + wxString GetStringSelection(bool asHTML = FALSE); + wxString GetText(bool asHTML = FALSE); + + bool GoBack(); + bool GoForward(); + bool GoHome(); + bool GoSearch(); + bool Refresh(wxIEHtmlRefreshLevel level); + bool Stop(); + +}; + + +//--------------------------------------------------------------------------- + +%init %{ + + wxClassInfo::CleanUpClasses(); + wxClassInfo::InitializeClasses(); + +%} + +//---------------------------------------------------------------------- + +%pragma(python) include="_iewinextras.py"; + +//--------------------------------------------------------------------------- diff --git a/wxPython/contrib/iewin/iewin.py b/wxPython/contrib/iewin/iewin.py new file mode 100644 index 0000000000..d6cd068c54 --- /dev/null +++ b/wxPython/contrib/iewin/iewin.py @@ -0,0 +1,166 @@ +# This file was created automatically by SWIG. +import iewinc + +from misc import * + +from misc2 import * + +from windows import * + +from gdi import * + +from fonts import * + +from clip_dnd import * + +from events import * + +from streams import * + +from utils import * + +from mdi import * + +from frames import * + +from stattool import * + +from controls import * + +from controls2 import * + +from windows2 import * + +from cmndlgs import * + +from windows3 import * + +from image import * + +from printfw import * + +from sizers import * + +from filesys import * +import wx + +def EVT_MSHTML_BEFORENAVIGATE2(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, func) + +def EVT_MSHTML_NEWWINDOW2(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_NEWWINDOW2, func) + +def EVT_MSHTML_DOCUMENTCOMPLETE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, func) + +def EVT_MSHTML_PROGRESSCHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, func) + +def EVT_MSHTML_STATUSTEXTCHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, func) + +def EVT_MSHTML_TITLECHANGE(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_MSHTML_TITLECHANGE, func) + +class wxMSHTMLEventPtr(wxNotifyEventPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def GetText(self, *_args, **_kwargs): + val = apply(iewinc.wxMSHTMLEvent_GetText,(self,) + _args, _kwargs) + return val + def GetLong1(self, *_args, **_kwargs): + val = apply(iewinc.wxMSHTMLEvent_GetLong1,(self,) + _args, _kwargs) + return val + def GetLong2(self, *_args, **_kwargs): + val = apply(iewinc.wxMSHTMLEvent_GetLong2,(self,) + _args, _kwargs) + return val + def __repr__(self): + return "" % (self.this,) +class wxMSHTMLEvent(wxMSHTMLEventPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(iewinc.new_wxMSHTMLEvent,_args,_kwargs) + self.thisown = 1 + + + + +class wxIEHtmlWinPtr(wxWindowPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def LoadUrl(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_LoadUrl,(self,) + _args, _kwargs) + return val + def LoadString(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_LoadString,(self,) + _args, _kwargs) + return val + def SetCharset(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_SetCharset,(self,) + _args, _kwargs) + return val + def SetEditMode(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_SetEditMode,(self,) + _args, _kwargs) + return val + def GetEditMode(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GetEditMode,(self,) + _args, _kwargs) + return val + def GetStringSelection(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GetStringSelection,(self,) + _args, _kwargs) + return val + def GetText(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GetText,(self,) + _args, _kwargs) + return val + def GoBack(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GoBack,(self,) + _args, _kwargs) + return val + def GoForward(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GoForward,(self,) + _args, _kwargs) + return val + def GoHome(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GoHome,(self,) + _args, _kwargs) + return val + def GoSearch(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_GoSearch,(self,) + _args, _kwargs) + return val + def Refresh(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_Refresh,(self,) + _args, _kwargs) + return val + def Stop(self, *_args, **_kwargs): + val = apply(iewinc.wxIEHtmlWin_Stop,(self,) + _args, _kwargs) + return val + def __repr__(self): + return "" % (self.this,) +class wxIEHtmlWin(wxIEHtmlWinPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(iewinc.new_wxIEHtmlWin,_args,_kwargs) + self.thisown = 1 + + + + + + +#-------------- FUNCTION WRAPPERS ------------------ + + + +#-------------- VARIABLE WRAPPERS ------------------ + +wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2 = iewinc.wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2 +wxEVT_COMMAND_MSHTML_NEWWINDOW2 = iewinc.wxEVT_COMMAND_MSHTML_NEWWINDOW2 +wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE = iewinc.wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE +wxEVT_COMMAND_MSHTML_PROGRESSCHANGE = iewinc.wxEVT_COMMAND_MSHTML_PROGRESSCHANGE +wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE = iewinc.wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE +wxEVT_COMMAND_MSHTML_TITLECHANGE = iewinc.wxEVT_COMMAND_MSHTML_TITLECHANGE +wxIEHTML_REFRESH_NORMAL = iewinc.wxIEHTML_REFRESH_NORMAL +wxIEHTML_REFRESH_IFEXPIRED = iewinc.wxIEHTML_REFRESH_IFEXPIRED +wxIEHTML_REFRESH_CONTINUE = iewinc.wxIEHTML_REFRESH_CONTINUE +wxIEHTML_REFRESH_COMPLETELY = iewinc.wxIEHTML_REFRESH_COMPLETELY + + +#-------------- USER INCLUDE ----------------------- + +# Stuff these names into the wx namespace so wxPyConstructObject can find them + +wx.wxMSHTMLEventPtr = wxMSHTMLEventPtr +wx.wxIEHtmlWinPtr = wxIEHtmlWinPtr diff --git a/wxPython/contrib/iewin/readme.txt b/wxPython/contrib/iewin/readme.txt new file mode 100644 index 0000000000..13dd413a94 --- /dev/null +++ b/wxPython/contrib/iewin/readme.txt @@ -0,0 +1,138 @@ +Lindsay Mathieson +Email : + +This is prelimanary stuff - the controls need extra methods and events etc, +feel free to email with suggestions &/or patches. + +Tested with wxWindows 2.3.2. +Built with MS Visual C++ 6.0 & DevStudio +Minor use of templates and STL + +----------------------------------------------------------- +This sample illustrates using wxActiveX and wxIEHtmlWin too: +1. Host an arbitrary ActiveX control +2. Specifically host the MSHTML Control + + +wxActiveX: +========== +wxActiveX is used to host and siplay any activeX control, all the wxWindows developer +needs to know is either the ProgID or CLSID of the control in question. + +Derived From: +- wxWindow + +Include Files: +- wxactivex.h + +Source Files: +- wxactivex.cpp + +Event Handling: +--------------- +- None currently + +Members: +-------- +wxActiveX::wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id = -1); +- Creates a activeX control identified by clsid +e.g + wxFrame *frame = new wxFrame(this, -1, "test"); + wxActiveX *X = new wxActiveX(frame, CLSID_WebBrowser); + +wxActiveX::wxActiveX(wxWindow * parent, wxString progId, wxWindowID id = -1); +- Creates a activeX control identified by progId +e.g. + wxFrame *frame = new wxFrame(this, -1, "test"); + wxActiveX *X = new wxActiveX(frame, "MSCAL.Calendar"); + + +wxActiveX::~wxActiveX(); +- Destroys the control +- disconnects all connection points + +HRESULT wxActiveX::ConnectAdvise(REFIID riid, IUnknown *eventSink); +- Connects a event sink. Connections are automaticlly diconnected in the destructor +e.g. + FS_DWebBrowserEvents2 *events = new FS_DWebBrowserEvents2(iecontrol); + hret = iecontrol->ConnectAdvise(DIID_DWebBrowserEvents2, events); + if (! SUCCEEDED(hret)) + delete events; + + + + +wxIEHtmlWin: +============ +wxIEHtmlWin is a specialisation of the wxActiveX control for hosting the MSHTML control. + +Derived From: +- wxActiveX +- wxWindow + +Event Handling: +--------------- +- class wxMSHTMLEvent + +- EVT_MSHTML_BEFORENAVIGATE2 +* url = event.m_text1 +* event.Veto() to cancel +Generated before an attempt to browse a new url + +- EVT_MSHTML_NEWWINDOW2 +* event.Veto() to cancel +Generated when the control is asked create a new window (e.g a popup) + +- EVT_MSHTML_DOCUMENTCOMPLETE +* url = event.m_text1 +Generated after the document has finished loading + +- EVT_MSHTML_PROGRESSCHANGE +* event.m_long1 = progress so far +* event.m_long2 = max range of progress + +- EVT_MSHTML_STATUSTEXTCHANGE +* status = event.m_text1 + +- EVT_MSHTML_TITLECHANGE +* title = event.m_text1 + +Members: +-------- +wxIEHtmlWin::wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1); +- Constructs and initialises the MSHTML control +- LoadUrl("about:blank") is called + +wxIEHtmlWin::~wxIEHtmlWin(); +- destroys the control + +void wxIEHtmlWin::LoadUrl(const wxString&); +- Attempts to browse to the url, the control uses its internal (MS) + network streams + +bool wxIEHtmlWin::LoadString(wxString html); +- Load the passed HTML string + +bool wxIEHtmlWin::LoadStream(istream *strm); +- load the passed HTML stream. The control takes ownership of + the pointer, deleting when finished. + +void wxIEHtmlWin::SetCharset(wxString charset); +- Sets the charset of the loaded document + +void wxIEHtmlWin::SetEditMode(bool seton); +- Sets edit mode. + NOTE: This does work, but is bare bones - we need more events exposed before + this is usable as an HTML editor. + +bool wxIEHtmlWin::GetEditMode(); +- Returns the edit mode setting + +wxString wxIEHtmlWin::GetStringSelection(bool asHTML = false); +- Returns the currently selected text (plain or HTML text) + +wxString GetText(bool asHTML = false); +- Returns the body text (plain or HTML text) + +Lindsay Mathieson +Email : diff --git a/wxPython/contrib/iewin/wxactivex.cpp b/wxPython/contrib/iewin/wxactivex.cpp new file mode 100644 index 0000000000..9e7d716b9d --- /dev/null +++ b/wxPython/contrib/iewin/wxactivex.cpp @@ -0,0 +1,1247 @@ +#include "wxActiveX.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +// Depending on compilation mode, the wx headers may have undef'd +// this, but in this case we need it so the virtual method in +// FrameSite will match what is in oleidl.h. +#ifndef GetObject + #ifdef _UNICODE + #define GetObject GetObjectW + #else + #define GetObject GetObjectA + #endif +#endif + +////////////////////////////////////////////////////////////////////// +BEGIN_EVENT_TABLE(wxActiveX, wxWindow) + EVT_SIZE(OnSize) + EVT_SET_FOCUS(OnSetFocus) + EVT_KILL_FOCUS(OnKillFocus) +END_EVENT_TABLE() + +class wxActiveX; + +class FrameSite : + public IOleClientSite, + public IOleInPlaceSiteEx, + public IOleInPlaceFrame, + public IOleItemContainer, + public IDispatch, + public IOleCommandTarget, + public IOleDocumentSite, + public IAdviseSink, + public IOleControlSite +{ +private: + DECLARE_OLE_UNKNOWN(FrameSite); + +public: + FrameSite(wxActiveX * win); + ~FrameSite(); + + //IOleWindow + STDMETHODIMP GetWindow(HWND*); + STDMETHODIMP ContextSensitiveHelp(BOOL); + + //IOleInPlaceUIWindow + STDMETHODIMP GetBorder(LPRECT); + STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS); + STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS); + STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*, LPCOLESTR); + + //IOleInPlaceFrame + STDMETHODIMP InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS); + STDMETHODIMP SetMenu(HMENU, HOLEMENU, HWND); + STDMETHODIMP RemoveMenus(HMENU); + STDMETHODIMP SetStatusText(LPCOLESTR); + STDMETHODIMP EnableModeless(BOOL); + STDMETHODIMP TranslateAccelerator(LPMSG, WORD); + + //IOleInPlaceSite + STDMETHODIMP CanInPlaceActivate(); + STDMETHODIMP OnInPlaceActivate(); + STDMETHODIMP OnUIActivate(); + STDMETHODIMP GetWindowContext(IOleInPlaceFrame**, IOleInPlaceUIWindow**, + LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO); + STDMETHODIMP Scroll(SIZE); + STDMETHODIMP OnUIDeactivate(BOOL); + STDMETHODIMP OnInPlaceDeactivate(); + STDMETHODIMP DiscardUndoState(); + STDMETHODIMP DeactivateAndUndo(); + STDMETHODIMP OnPosRectChange(LPCRECT); + + //IOleInPlaceSiteEx + STDMETHODIMP OnInPlaceActivateEx(BOOL*, DWORD); + STDMETHODIMP OnInPlaceDeactivateEx(BOOL); + STDMETHODIMP RequestUIActivate(); + + //IOleClientSite + STDMETHODIMP SaveObject(); + STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker**); + STDMETHODIMP GetContainer(LPOLECONTAINER FAR*); + STDMETHODIMP ShowObject(); + STDMETHODIMP OnShowWindow(BOOL); + STDMETHODIMP RequestNewObjectLayout(); + + //IOleControlSite + STDMETHODIMP OnControlInfoChanged(); + STDMETHODIMP LockInPlaceActive(BOOL); + STDMETHODIMP GetExtendedControl(IDispatch**); + STDMETHODIMP TransformCoords(POINTL*, POINTF*, DWORD); + STDMETHODIMP TranslateAccelerator(LPMSG, DWORD); + STDMETHODIMP OnFocus(BOOL); + STDMETHODIMP ShowPropertyFrame(); + + //IOleCommandTarget + STDMETHODIMP QueryStatus(const GUID*, ULONG, OLECMD[], OLECMDTEXT*); + STDMETHODIMP Exec(const GUID*, DWORD, DWORD, VARIANTARG*, VARIANTARG*); + + //IParseDisplayName + STDMETHODIMP ParseDisplayName(IBindCtx*, LPOLESTR, ULONG*, IMoniker**); + + //IOleContainer + STDMETHODIMP EnumObjects(DWORD, IEnumUnknown**); + STDMETHODIMP LockContainer(BOOL); + + //IOleItemContainer + STDMETHODIMP GetObject(LPOLESTR, DWORD, IBindCtx*, REFIID, void**); + STDMETHODIMP GetObjectStorage(LPOLESTR, IBindCtx*, REFIID, void**); + STDMETHODIMP IsRunning(LPOLESTR); + + //IDispatch + STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*); + STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**); + STDMETHODIMP GetTypeInfoCount(unsigned int*); + STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*); + + //IAdviseSink + void STDMETHODCALLTYPE OnDataChange(FORMATETC*, STGMEDIUM*); + void STDMETHODCALLTYPE OnViewChange(DWORD, LONG); + void STDMETHODCALLTYPE OnRename(IMoniker*); + void STDMETHODCALLTYPE OnSave(); + void STDMETHODCALLTYPE OnClose(); + + // IOleDocumentSite + HRESULT STDMETHODCALLTYPE ActivateMe(IOleDocumentView __RPC_FAR *pViewToActivate); + +protected: + + wxActiveX * m_window; + + HDC m_hDCBuffer; + HWND m_hWndParent; + + bool m_bSupportsWindowlessActivation; + bool m_bInPlaceLocked; + bool m_bInPlaceActive; + bool m_bUIActive; + bool m_bWindowless; + + + + LCID m_nAmbientLocale; + COLORREF m_clrAmbientForeColor; + COLORREF m_clrAmbientBackColor; + bool m_bAmbientShowHatching; + bool m_bAmbientShowGrabHandles; + bool m_bAmbientAppearance; +}; + +DEFINE_OLE_TABLE(FrameSite) + OLE_INTERFACE(IID_IUnknown, IOleClientSite) + + OLE_IINTERFACE(IOleClientSite) + + OLE_INTERFACE(IID_IOleWindow, IOleInPlaceSite) + OLE_IINTERFACE(IOleInPlaceSite) + OLE_IINTERFACE(IOleInPlaceSiteEx) + + //OLE_IINTERFACE(IOleWindow) + OLE_IINTERFACE(IOleInPlaceUIWindow) + OLE_IINTERFACE(IOleInPlaceFrame) + + OLE_IINTERFACE(IParseDisplayName) + OLE_IINTERFACE(IOleContainer) + OLE_IINTERFACE(IOleItemContainer) + + OLE_IINTERFACE(IDispatch) + + OLE_IINTERFACE(IOleCommandTarget) + + OLE_IINTERFACE(IOleDocumentSite) + + OLE_IINTERFACE(IAdviseSink) + + OLE_IINTERFACE(IOleControlSite) +END_OLE_TABLE; + + +wxActiveX::wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id) : + wxWindow(parent, id) +{ + m_bAmbientUserMode = true; + m_docAdviseCookie = 0; + CreateActiveX(clsid); +} + +wxActiveX::wxActiveX(wxWindow * parent, wxString progId, wxWindowID id) : + wxWindow(parent, id) +{ + m_bAmbientUserMode = true; + m_docAdviseCookie = 0; + CreateActiveX((LPOLESTR) wxConvUTF8.cMB2WC(progId).data()); +} + +wxActiveX::~wxActiveX() +{ + // disconnect connection points + wxOleConnectionArray::iterator it = m_connections.begin(); + while (it != m_connections.end()) + { + wxOleConnectionPoint& cp = it->first; + cp->Unadvise(it->second); + + it++; + }; + m_connections.clear(); + + if (m_oleInPlaceObject.Ok()) + { + m_oleInPlaceObject->InPlaceDeactivate(); + m_oleInPlaceObject->UIDeactivate(); + } + + + if (m_oleObject.Ok()) + { + if (m_docAdviseCookie != 0) + m_oleObject->Unadvise(m_docAdviseCookie); + + m_oleObject->DoVerb(OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL); + m_oleObject->Close(OLECLOSE_NOSAVE); + m_oleObject->SetClientSite(NULL); + } +} + +void wxActiveX::CreateActiveX(REFCLSID clsid) +{ + SetTransparent(); + + HRESULT hret; + + //////////////////////////////////////////////////////// + // FrameSite + FrameSite *frame = new FrameSite(this); + // oleClientSite + hret = m_clientSite.QueryInterface(IID_IOleClientSite, (IDispatch *) frame); + wxASSERT(SUCCEEDED(hret)); + // adviseSink + wxAutoOleInterface adviseSink(IID_IAdviseSink, (IDispatch *) frame); + wxASSERT(adviseSink.Ok()); + + + + + // // Create Object, get IUnknown interface + m_ActiveX.CreateInstance(clsid, IID_IUnknown); + wxASSERT(m_ActiveX.Ok()); + + // Get IOleObject interface + hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX); + wxASSERT(SUCCEEDED(hret)); + // Get IOleInPlaceObject interface + hret = m_oleInPlaceObject.QueryInterface(IID_IOleInPlaceObject, m_ActiveX); + wxASSERT(SUCCEEDED(hret)); + + // status + DWORD dwMiscStatus; + m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus); + wxASSERT(SUCCEEDED(hret)); + + // set client site first ? + if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) + m_oleObject->SetClientSite(m_clientSite); + + + // stream init + wxAutoOleInterface + pPersistStreamInit(IID_IPersistStreamInit, m_oleObject); + + if (pPersistStreamInit.Ok()) + { + hret = pPersistStreamInit->InitNew(); + WXOLE_WARN(hret, "CreateActiveX::pPersistStreamInit->InitNew()"); + }; + + // document advise + m_docAdviseCookie = 0; + hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie); + WXOLE_WARN(hret, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")"); + m_oleObject->SetHostNames(L"wxActiveXContainer", NULL); + OleSetContainedObject(m_oleObject, TRUE); + + if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)) + m_oleObject->SetClientSite(m_clientSite); + + + int w, h; + GetClientSize(&w, &h); + RECT posRect; + posRect.left = 0; + posRect.top = 0; + posRect.right = w; + posRect.bottom = h; + + m_oleObjectHWND = 0; + hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND); + WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)"); + if (SUCCEEDED(hret)) + ::SetActiveWindow(m_oleObjectHWND); + + + if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME)) + { + m_oleInPlaceObject->SetObjectRects(&posRect, &posRect); + + hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)GetHWND(), &posRect); + hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)GetHWND(), &posRect); + }; + +} + +void wxActiveX::CreateActiveX(LPOLESTR progId) +{ + CLSID clsid; + if (CLSIDFromProgID(progId, &clsid) != S_OK) + return; + + CreateActiveX(clsid); +}; + +HRESULT wxActiveX::ConnectAdvise(REFIID riid, IUnknown *events) +{ + wxOleConnectionPoint cp; + DWORD adviseCookie = 0; + + wxAutoOleInterface cpContainer(IID_IConnectionPointContainer, m_ActiveX); + if (! cpContainer.Ok()) + return E_FAIL; + + HRESULT hret = cpContainer->FindConnectionPoint(riid, cp.GetRef()); + if (! SUCCEEDED(hret)) + return hret; + + hret = cp->Advise(events, &adviseCookie); + + if (SUCCEEDED(hret)) + m_connections.push_back(wxOleConnection(cp, adviseCookie)); + + return hret; +}; + +HRESULT wxActiveX::AmbientPropertyChanged(DISPID dispid) +{ + wxAutoOleInterface oleControl(IID_IOleControl, m_oleObject); + + if (oleControl.Ok()) + return oleControl->OnAmbientPropertyChange(dispid); + else + return S_FALSE; +}; + +#define HIMETRIC_PER_INCH 2540 +#define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli)) + +static void PixelsToHimetric(SIZEL &sz) +{ + static int logX = 0; + static int logY = 0; + + if (logY == 0) + { + // initaliase + HDC dc = GetDC(NULL); + logX = GetDeviceCaps(dc, LOGPIXELSX); + logY = GetDeviceCaps(dc, LOGPIXELSY); + ReleaseDC(NULL, dc); + }; + +#define HIMETRIC_INCH 2540 +#define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels)) + + sz.cx = CONVERT(sz.cx, logX); + sz.cy = CONVERT(sz.cy, logY); + +#undef CONVERT +#undef HIMETRIC_INCH +} + + +void wxActiveX::OnSize(wxSizeEvent& event) +{ + int w, h; + GetClientSize(&w, &h); + + RECT posRect; + posRect.left = 0; + posRect.top = 0; + posRect.right = w; + posRect.bottom = h; + + if (m_oleInPlaceObject) + m_oleInPlaceObject->SetObjectRects(&posRect, &posRect); + + // extents are in HIMETRIC units + SIZEL sz = {w, h}; + PixelsToHimetric(sz); + + SIZEL sz2; + m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2); + if (sz2.cx != sz.cx || sz.cy != sz2.cy) + m_oleObject->SetExtent(DVASPECT_CONTENT, &sz); +} + +void wxActiveX::OnSetFocus(wxFocusEvent& event) +{ + if (m_oleInPlaceActiveObject.Ok()) + m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE); +} + +void wxActiveX::OnKillFocus(wxFocusEvent& event) +{ + if (m_oleInPlaceActiveObject.Ok()) + m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE); +} + + +FrameSite::FrameSite(wxActiveX * win) +{ + m_window = win; + m_bSupportsWindowlessActivation = true; + m_bInPlaceLocked = false; + m_bUIActive = false; + m_bInPlaceActive = false; + m_bWindowless = false; + + m_nAmbientLocale = 0; + m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT); + m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW); + m_bAmbientShowHatching = true; + m_bAmbientShowGrabHandles = true; + m_bAmbientAppearance = true; + + m_hDCBuffer = NULL; + m_hWndParent = (HWND)m_window->GetHWND(); +} + +FrameSite::~FrameSite() +{ +} + + +//IDispatch + +HRESULT FrameSite::GetIDsOfNames(REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, + LCID lcid, DISPID * rgDispId) +{ + WXOLE_TRACE("IDispatch::GetIDsOfNames"); + return E_NOTIMPL; +} + +HRESULT FrameSite::GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo ** ppTInfo) +{ + WXOLE_TRACE("IDispatch::GetTypeInfo"); + return E_NOTIMPL; +} + +HRESULT FrameSite::GetTypeInfoCount(unsigned int * pcTInfo) +{ + WXOLE_TRACE("IDispatch::GetTypeInfoCount"); + return E_NOTIMPL; +} + +HRESULT FrameSite::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, + WORD wFlags, DISPPARAMS * pDispParams, + VARIANT * pVarResult, EXCEPINFO * pExcepInfo, + unsigned int * puArgErr) +{ + WXOLE_TRACE("IDispatch::Invoke"); + + if (!(wFlags & DISPATCH_PROPERTYGET)) + return S_OK; + + HRESULT hr; + + if (pVarResult == NULL) + return E_INVALIDARG; + + //The most common case is boolean, use as an initial type + V_VT(pVarResult) = VT_BOOL; + + switch (dispIdMember) + { + case DISPID_AMBIENT_MESSAGEREFLECT: + WXOLE_TRACE("Invoke::DISPID_AMBIENT_MESSAGEREFLECT"); + V_BOOL(pVarResult)= FALSE; + return S_OK; + + case DISPID_AMBIENT_DISPLAYASDEFAULT: + WXOLE_TRACE("Invoke::DISPID_AMBIENT_DISPLAYASDEFAULT"); + V_BOOL(pVarResult)= TRUE; + return S_OK; + + case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED: + WXOLE_TRACE("Invoke::DISPID_AMBIENT_OFFLINEIFNOTCONNECTED"); + V_BOOL(pVarResult) = TRUE; + return S_OK; + + + case DISPID_AMBIENT_SILENT: + WXOLE_TRACE("Invoke::DISPID_AMBIENT_SILENT"); + V_BOOL(pVarResult)= TRUE; + return S_OK; + + case DISPID_AMBIENT_APPEARANCE: + pVarResult->vt = VT_BOOL; + pVarResult->boolVal = m_bAmbientAppearance; + break; + + case DISPID_AMBIENT_FORECOLOR: + pVarResult->vt = VT_I4; + pVarResult->lVal = (long) m_clrAmbientForeColor; + break; + + case DISPID_AMBIENT_BACKCOLOR: + pVarResult->vt = VT_I4; + pVarResult->lVal = (long) m_clrAmbientBackColor; + break; + + case DISPID_AMBIENT_LOCALEID: + pVarResult->vt = VT_I4; + pVarResult->lVal = (long) m_nAmbientLocale; + break; + + case DISPID_AMBIENT_USERMODE: + pVarResult->vt = VT_BOOL; + pVarResult->boolVal = m_window->m_bAmbientUserMode; + break; + + case DISPID_AMBIENT_SHOWGRABHANDLES: + pVarResult->vt = VT_BOOL; + pVarResult->boolVal = m_bAmbientShowGrabHandles; + break; + + case DISPID_AMBIENT_SHOWHATCHING: + pVarResult->vt = VT_BOOL; + pVarResult->boolVal = m_bAmbientShowHatching; + break; + + default: + return DISP_E_MEMBERNOTFOUND; + } + + return S_OK; +} + +//IOleWindow + +HRESULT FrameSite::GetWindow(HWND * phwnd) +{ + WXOLE_TRACE("IOleWindow::GetWindow"); + if (phwnd == NULL) + return E_INVALIDARG; + (*phwnd) = m_hWndParent; + return S_OK; +} + +HRESULT FrameSite::ContextSensitiveHelp(BOOL fEnterMode) +{ + WXOLE_TRACE("IOleWindow::ContextSensitiveHelp"); + return S_OK; +} + +//IOleInPlaceUIWindow + +HRESULT FrameSite::GetBorder(LPRECT lprectBorder) +{ + WXOLE_TRACE("IOleInPlaceUIWindow::GetBorder"); + if (lprectBorder == NULL) + return E_INVALIDARG; + return INPLACE_E_NOTOOLSPACE; +} + +HRESULT FrameSite::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths) +{ + WXOLE_TRACE("IOleInPlaceUIWindow::RequestBorderSpace"); + if (pborderwidths == NULL) + return E_INVALIDARG; + return INPLACE_E_NOTOOLSPACE; +} + +HRESULT FrameSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths) +{ + WXOLE_TRACE("IOleInPlaceUIWindow::SetBorderSpace"); + return S_OK; +} + +HRESULT FrameSite::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName) +{ + WXOLE_TRACE("IOleInPlaceUIWindow::SetActiveObject"); + + if (pActiveObject) + pActiveObject->AddRef(); + + m_window->m_oleInPlaceActiveObject = pActiveObject; + return S_OK; +} + +//IOleInPlaceFrame + +HRESULT FrameSite::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths) +{ + WXOLE_TRACE("IOleInPlaceFrame::InsertMenus"); + return S_OK; +} + +HRESULT FrameSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject) +{ + WXOLE_TRACE("IOleInPlaceFrame::SetMenu"); + return S_OK; +} + +HRESULT FrameSite::RemoveMenus(HMENU hmenuShared) +{ + WXOLE_TRACE("IOleInPlaceFrame::RemoveMenus"); + return S_OK; +} + +HRESULT FrameSite::SetStatusText(LPCOLESTR pszStatusText) +{ + WXOLE_TRACE("IOleInPlaceFrame::SetStatusText"); + //((wxFrame*)wxGetApp().GetTopWindow())->GetStatusBar()->SetStatusText(pszStatusText); + return S_OK; +} + +HRESULT FrameSite::EnableModeless(BOOL fEnable) +{ + WXOLE_TRACE("IOleInPlaceFrame::EnableModeless"); + return S_OK; +} + +HRESULT FrameSite::TranslateAccelerator(LPMSG lpmsg, WORD wID) +{ + WXOLE_TRACE("IOleInPlaceFrame::TranslateAccelerator"); + // TODO: send an event with this id + if (m_window->m_oleInPlaceActiveObject.Ok()) + m_window->m_oleInPlaceActiveObject->TranslateAccelerator(lpmsg); + + return S_FALSE; +} + +//IOleInPlaceSite + +HRESULT FrameSite::CanInPlaceActivate() +{ + WXOLE_TRACE("IOleInPlaceSite::CanInPlaceActivate"); + return S_OK; +} + +HRESULT FrameSite::OnInPlaceActivate() +{ + WXOLE_TRACE("IOleInPlaceSite::OnInPlaceActivate"); + m_bInPlaceActive = true; + return S_OK; +} + +HRESULT FrameSite::OnUIActivate() +{ + WXOLE_TRACE("IOleInPlaceSite::OnUIActivate"); + m_bUIActive = true; + return S_OK; +} + +HRESULT FrameSite::GetWindowContext(IOleInPlaceFrame **ppFrame, + IOleInPlaceUIWindow **ppDoc, + LPRECT lprcPosRect, + LPRECT lprcClipRect, + LPOLEINPLACEFRAMEINFO lpFrameInfo) +{ + WXOLE_TRACE("IOleInPlaceSite::GetWindowContext"); + if (ppFrame == NULL || ppDoc == NULL || lprcPosRect == NULL || + lprcClipRect == NULL || lpFrameInfo == NULL) + { + if (ppFrame != NULL) + (*ppFrame) = NULL; + if (ppDoc != NULL) + (*ppDoc) = NULL; + return E_INVALIDARG; + } + + HRESULT hr = QueryInterface(IID_IOleInPlaceFrame, (void **) ppFrame); + if (! SUCCEEDED(hr)) + { + WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceFrame Error !"); + return E_UNEXPECTED; + }; + + hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc); + if (! SUCCEEDED(hr)) + { + WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceUIWindow Error !"); + (*ppFrame)->Release(); + *ppFrame = NULL; + return E_UNEXPECTED; + }; + + int w, h; + m_window->GetClientSize(&w, &h); + if (lprcPosRect) + { + lprcPosRect->left = lprcPosRect->top = 0; + lprcPosRect->right = w; + lprcPosRect->bottom = h; + }; + if (lprcClipRect) + { + lprcClipRect->left = lprcClipRect->top = 0; + lprcClipRect->right = w; + lprcClipRect->bottom = h; + }; + + memset(lpFrameInfo, 0, sizeof(OLEINPLACEFRAMEINFO)); + lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO); + lpFrameInfo->hwndFrame = m_hWndParent; + + return S_OK; +} + +HRESULT FrameSite::Scroll(SIZE scrollExtent) +{ + WXOLE_TRACE("IOleInPlaceSite::Scroll"); + return S_OK; +} + +HRESULT FrameSite::OnUIDeactivate(BOOL fUndoable) +{ + WXOLE_TRACE("IOleInPlaceSite::OnUIDeactivate"); + m_bUIActive = false; + return S_OK; +} + +HRESULT FrameSite::OnInPlaceDeactivate() +{ + WXOLE_TRACE("IOleInPlaceSite::OnInPlaceDeactivate"); + m_bInPlaceActive = false; + return S_OK; +} + +HRESULT FrameSite::DiscardUndoState() +{ + WXOLE_TRACE("IOleInPlaceSite::DiscardUndoState"); + return S_OK; +} + +HRESULT FrameSite::DeactivateAndUndo() +{ + WXOLE_TRACE("IOleInPlaceSite::DeactivateAndUndo"); + return S_OK; +} + +HRESULT FrameSite::OnPosRectChange(LPCRECT lprcPosRect) +{ + WXOLE_TRACE("IOleInPlaceSite::OnPosRectChange"); + if (m_window->m_oleInPlaceObject.Ok() && lprcPosRect) + m_window->m_oleInPlaceObject->SetObjectRects(lprcPosRect, lprcPosRect); + + return S_OK; +} + +//IOleInPlaceSiteEx + +HRESULT FrameSite::OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD dwFlags) +{ + WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceActivateEx"); + OleLockRunning(m_window->m_ActiveX, TRUE, FALSE); + if (pfNoRedraw) + (*pfNoRedraw) = FALSE; + return S_OK; +} + +HRESULT FrameSite::OnInPlaceDeactivateEx(BOOL fNoRedraw) +{ + WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceDeactivateEx"); + OleLockRunning(m_window->m_ActiveX, FALSE, FALSE); + return S_OK; +} + +HRESULT FrameSite::RequestUIActivate() +{ + WXOLE_TRACE("IOleInPlaceSiteEx::RequestUIActivate"); + return S_OK; +} + + +//IOleClientSite + +HRESULT FrameSite::SaveObject() +{ + WXOLE_TRACE("IOleClientSite::SaveObject"); + return S_OK; +} + +HRESULT FrameSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, + IMoniker ** ppmk) +{ + WXOLE_TRACE("IOleClientSite::GetMoniker"); + return E_NOTIMPL; +} + +HRESULT FrameSite::GetContainer(LPOLECONTAINER * ppContainer) +{ + WXOLE_TRACE("IOleClientSite::GetContainer"); + if (ppContainer == NULL) + return E_INVALIDARG; + + HRESULT hr = QueryInterface(IID_IOleContainer, (void**)(ppContainer)); + wxASSERT(SUCCEEDED(hr)); + + return hr; +} + +HRESULT FrameSite::ShowObject() +{ + WXOLE_TRACE("IOleClientSite::ShowObject"); + return S_OK; +} + +HRESULT FrameSite::OnShowWindow(BOOL fShow) +{ + WXOLE_TRACE("IOleClientSite::OnShowWindow"); + return S_OK; +} + +HRESULT FrameSite::RequestNewObjectLayout() +{ + WXOLE_TRACE("IOleClientSite::RequestNewObjectLayout"); + return E_NOTIMPL; +} + +// IParseDisplayName + +HRESULT FrameSite::ParseDisplayName(IBindCtx *pbc, LPOLESTR pszDisplayName, + ULONG *pchEaten, IMoniker **ppmkOut) +{ + WXOLE_TRACE("IParseDisplayName::ParseDisplayName"); + return E_NOTIMPL; +} + +//IOleContainer + +HRESULT FrameSite::EnumObjects(DWORD grfFlags, IEnumUnknown **ppenum) +{ + WXOLE_TRACE("IOleContainer::EnumObjects"); + return E_NOTIMPL; +} + +HRESULT FrameSite::LockContainer(BOOL fLock) +{ + WXOLE_TRACE("IOleContainer::LockContainer"); + // TODO + return S_OK; +} + +//IOleItemContainer + +HRESULT FrameSite::GetObject(LPOLESTR pszItem, DWORD dwSpeedNeeded, + IBindCtx * pbc, REFIID riid, void ** ppvObject) +{ + WXOLE_TRACE("IOleItemContainer::GetObject"); + if (pszItem == NULL) + return E_INVALIDARG; + if (ppvObject == NULL) + return E_INVALIDARG; + + *ppvObject = NULL; + return MK_E_NOOBJECT; +} + +HRESULT FrameSite::GetObjectStorage(LPOLESTR pszItem, IBindCtx * pbc, + REFIID riid, void ** ppvStorage) +{ + WXOLE_TRACE("IOleItemContainer::GetObjectStorage"); + if (pszItem == NULL) + return E_INVALIDARG; + if (ppvStorage == NULL) + return E_INVALIDARG; + + *ppvStorage = NULL; + return MK_E_NOOBJECT; +} + +HRESULT FrameSite::IsRunning(LPOLESTR pszItem) +{ + WXOLE_TRACE("IOleItemContainer::IsRunning"); + if (pszItem == NULL) + return E_INVALIDARG; + + return MK_E_NOOBJECT; +} + + + +//IOleControlSite + +HRESULT FrameSite::OnControlInfoChanged() +{ + WXOLE_TRACE("IOleControlSite::OnControlInfoChanged"); + return S_OK; +} + +HRESULT FrameSite::LockInPlaceActive(BOOL fLock) +{ + WXOLE_TRACE("IOleControlSite::LockInPlaceActive"); + m_bInPlaceLocked = (fLock) ? true : false; + return S_OK; +} + +HRESULT FrameSite::GetExtendedControl(IDispatch ** ppDisp) +{ + WXOLE_TRACE("IOleControlSite::GetExtendedControl"); + return E_NOTIMPL; +} + +HRESULT FrameSite::TransformCoords(POINTL * pPtlHimetric, POINTF * pPtfContainer, DWORD dwFlags) +{ + WXOLE_TRACE("IOleControlSite::TransformCoords"); + HRESULT hr = S_OK; + + if (pPtlHimetric == NULL) + return E_INVALIDARG; + + if (pPtfContainer == NULL) + return E_INVALIDARG; + + return E_NOTIMPL; + +} + +HRESULT FrameSite::TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers) +{ + WXOLE_TRACE("IOleControlSite::TranslateAccelerator"); + // TODO: send an event with this id + return E_NOTIMPL; +} + +HRESULT FrameSite::OnFocus(BOOL fGotFocus) +{ + WXOLE_TRACE("IOleControlSite::OnFocus"); + return S_OK; +} + +HRESULT FrameSite::ShowPropertyFrame() +{ + WXOLE_TRACE("IOleControlSite::ShowPropertyFrame"); + return E_NOTIMPL; +} + +//IOleCommandTarget + +HRESULT FrameSite::QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds, + OLECMD * prgCmds, OLECMDTEXT * pCmdTet) +{ + WXOLE_TRACE("IOleCommandTarget::QueryStatus"); + if (prgCmds == NULL) return E_INVALIDARG; + bool bCmdGroupFound = false; + + for (ULONG nCmd = 0; nCmd < cCmds; nCmd++) + { + // unsupported by default + prgCmds[nCmd].cmdf = 0; + + // TODO + } + + if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; } + return S_OK; +} + +HRESULT FrameSite::Exec(const GUID * pguidCmdGroup, DWORD nCmdID, + DWORD nCmdExecOpt, VARIANTARG * pVaIn, + VARIANTARG * pVaOut) +{ + WXOLE_TRACE("IOleCommandTarget::Exec"); + bool bCmdGroupFound = false; + + if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; } + return OLECMDERR_E_NOTSUPPORTED; +} + +//IAdviseSink + +void STDMETHODCALLTYPE FrameSite::OnDataChange(FORMATETC * pFormatEtc, STGMEDIUM * pgStgMed) +{ + WXOLE_TRACE("IAdviseSink::OnDataChange"); +} + +void STDMETHODCALLTYPE FrameSite::OnViewChange(DWORD dwAspect, LONG lIndex) +{ + WXOLE_TRACE("IAdviseSink::OnViewChange"); + // redraw the control +} + +void STDMETHODCALLTYPE FrameSite::OnRename(IMoniker * pmk) +{ + WXOLE_TRACE("IAdviseSink::OnRename"); +} + +void STDMETHODCALLTYPE FrameSite::OnSave() +{ + WXOLE_TRACE("IAdviseSink::OnSave"); +} + +void STDMETHODCALLTYPE FrameSite::OnClose() +{ + WXOLE_TRACE("IAdviseSink::OnClose"); +} + +///////////////////////////////////////////// +// IOleDocumentSite +HRESULT STDMETHODCALLTYPE FrameSite::ActivateMe( + /* [in] */ IOleDocumentView __RPC_FAR *pViewToActivate) +{ + wxAutoOleInterface inPlaceSite(IID_IOleInPlaceSite, (IDispatch *) this); + if (!inPlaceSite.Ok()) + return E_FAIL; + + if (pViewToActivate) + { + m_window->m_docView = pViewToActivate; + m_window->m_docView->SetInPlaceSite(inPlaceSite); + } + else + { + wxAutoOleInterface oleDoc(IID_IOleDocument, m_window->m_oleObject); + if (! oleDoc.Ok()) + return E_FAIL; + + HRESULT hr = oleDoc->CreateView(inPlaceSite, NULL, 0, m_window->m_docView.GetRef()); + if (hr != S_OK) + return E_FAIL; + + m_window->m_docView->SetInPlaceSite(inPlaceSite); + }; + + m_window->m_docView->UIActivate(TRUE); + + return S_OK; +}; + + + +static IMalloc *iMalloc = NULL; + +IMalloc *wxOleInit::GetIMalloc() +{ + assert(iMalloc); + return iMalloc; +}; + +wxOleInit::wxOleInit() +{ + if (OleInitialize(NULL) == S_OK && iMalloc == NULL) + CoGetMalloc(1, &iMalloc); + else if (iMalloc) + iMalloc->AddRef(); +}; + +wxOleInit::~wxOleInit() +{ + if (iMalloc) + { + if (iMalloc->Release() == 0) + iMalloc = NULL; + }; + + OleUninitialize(); +} + +wxString OLEHResultToString(HRESULT hr) +{ + switch (hr) + { + case S_OK: + return ""; + + case OLECMDERR_E_UNKNOWNGROUP: + return "The pguidCmdGroup parameter is not NULL but does not specify a recognized command group."; + + case OLECMDERR_E_NOTSUPPORTED: + return "The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup."; + + case OLECMDERR_E_DISABLED: + return "The command identified by nCmdID is currently disabled and cannot be executed."; + + case OLECMDERR_E_NOHELP: + return "The caller has asked for help on the command identified by nCmdID, but no help is available."; + + case OLECMDERR_E_CANCELED: + return "The user canceled the execution of the command."; + + case E_INVALIDARG: + return "E_INVALIDARG"; + + case E_OUTOFMEMORY: + return "E_OUTOFMEMORY"; + + case E_NOINTERFACE: + return "E_NOINTERFACE"; + + case E_UNEXPECTED: + return "E_UNEXPECTED"; + + case STG_E_INVALIDFLAG: + return "STG_E_INVALIDFLAG"; + + case E_FAIL: + return "E_FAIL"; + + case E_NOTIMPL: + return "E_NOTIMPL"; + + default: + { + char buf[64]; + sprintf(buf, "Unknown - 0x%X", hr); + return wxString(buf); + } + }; +}; + +// borrowed from src/msw/ole/oleutils.cpp +wxString GetIIDName(REFIID riid) +{ + // an association between symbolic name and numeric value of an IID + struct KNOWN_IID + { + const IID *pIid; + const wxChar *szName; + }; + + // construct the table containing all known interfaces + #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) } + + static const KNOWN_IID aKnownIids[] = + { + ADD_KNOWN_IID(AdviseSink), + ADD_KNOWN_IID(AdviseSink2), + ADD_KNOWN_IID(BindCtx), + ADD_KNOWN_IID(ClassFactory), +#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__) + ADD_KNOWN_IID(ContinueCallback), + ADD_KNOWN_IID(EnumOleDocumentViews), + ADD_KNOWN_IID(OleCommandTarget), + ADD_KNOWN_IID(OleDocument), + ADD_KNOWN_IID(OleDocumentSite), + ADD_KNOWN_IID(OleDocumentView), + ADD_KNOWN_IID(Print), +#endif + ADD_KNOWN_IID(DataAdviseHolder), + ADD_KNOWN_IID(DataObject), + ADD_KNOWN_IID(Debug), + ADD_KNOWN_IID(DebugStream), + ADD_KNOWN_IID(DfReserved1), + ADD_KNOWN_IID(DfReserved2), + ADD_KNOWN_IID(DfReserved3), + ADD_KNOWN_IID(Dispatch), + ADD_KNOWN_IID(DropSource), + ADD_KNOWN_IID(DropTarget), + ADD_KNOWN_IID(EnumCallback), + ADD_KNOWN_IID(EnumFORMATETC), + ADD_KNOWN_IID(EnumGeneric), + ADD_KNOWN_IID(EnumHolder), + ADD_KNOWN_IID(EnumMoniker), + ADD_KNOWN_IID(EnumOLEVERB), + ADD_KNOWN_IID(EnumSTATDATA), + ADD_KNOWN_IID(EnumSTATSTG), + ADD_KNOWN_IID(EnumString), + ADD_KNOWN_IID(EnumUnknown), + ADD_KNOWN_IID(EnumVARIANT), + ADD_KNOWN_IID(ExternalConnection), + ADD_KNOWN_IID(InternalMoniker), + ADD_KNOWN_IID(LockBytes), + ADD_KNOWN_IID(Malloc), + ADD_KNOWN_IID(Marshal), + ADD_KNOWN_IID(MessageFilter), + ADD_KNOWN_IID(Moniker), + ADD_KNOWN_IID(OleAdviseHolder), + ADD_KNOWN_IID(OleCache), + ADD_KNOWN_IID(OleCache2), + ADD_KNOWN_IID(OleCacheControl), + ADD_KNOWN_IID(OleClientSite), + ADD_KNOWN_IID(OleContainer), + ADD_KNOWN_IID(OleInPlaceActiveObject), + ADD_KNOWN_IID(OleInPlaceFrame), + ADD_KNOWN_IID(OleInPlaceObject), + ADD_KNOWN_IID(OleInPlaceSite), + ADD_KNOWN_IID(OleInPlaceUIWindow), + ADD_KNOWN_IID(OleItemContainer), + ADD_KNOWN_IID(OleLink), + ADD_KNOWN_IID(OleManager), + ADD_KNOWN_IID(OleObject), + ADD_KNOWN_IID(OlePresObj), + ADD_KNOWN_IID(OleWindow), + ADD_KNOWN_IID(PSFactory), + ADD_KNOWN_IID(ParseDisplayName), + ADD_KNOWN_IID(Persist), + ADD_KNOWN_IID(PersistFile), + ADD_KNOWN_IID(PersistStorage), + ADD_KNOWN_IID(PersistStream), + ADD_KNOWN_IID(ProxyManager), + ADD_KNOWN_IID(RootStorage), + ADD_KNOWN_IID(RpcChannel), + ADD_KNOWN_IID(RpcProxy), + ADD_KNOWN_IID(RpcStub), + ADD_KNOWN_IID(RunnableObject), + ADD_KNOWN_IID(RunningObjectTable), + ADD_KNOWN_IID(StdMarshalInfo), + ADD_KNOWN_IID(Storage), + ADD_KNOWN_IID(Stream), + ADD_KNOWN_IID(StubManager), + ADD_KNOWN_IID(Unknown), + ADD_KNOWN_IID(ViewObject), + ADD_KNOWN_IID(ViewObject2), + }; + + // don't clobber preprocessor name space + #undef ADD_KNOWN_IID + + // try to find the interface in the table + for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) + { + if ( riid == *aKnownIids[ui].pIid ) + { + return aKnownIids[ui].szName; + } + } + + // unknown IID, just transform to string + LPOLESTR str = NULL; + StringFromIID(riid, &str); + if (str) + { + wxString s = str; + CoTaskMemFree(str); + return s; + } + else + return "StringFromIID() error"; +} diff --git a/wxPython/contrib/iewin/wxactivex.h b/wxPython/contrib/iewin/wxactivex.h new file mode 100644 index 0000000000..2d36e37541 --- /dev/null +++ b/wxPython/contrib/iewin/wxactivex.h @@ -0,0 +1,300 @@ +#ifndef WX_ACTIVE_X +#define WX_ACTIVE_X +#pragma warning( disable : 4101 4786) +#pragma warning( disable : 4786) + + +#include +#include +#include +#include +#include +#include +using namespace std; + +////////////////////////////////////////// +// wxAutoOleInterface +// Template class for smart interface handling +// - Automatically dereferences ole interfaces +// - Smart Copy Semantics +// - Can Create Interfaces +// - Can query for other interfaces +template class wxAutoOleInterface +{ + protected: + I *m_interface; + + public: + // takes ownership of an existing interface + // Assumed to already have a AddRef() applied + explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} + + // queries for an interface + wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) + { + QueryInterface(riid, pUnk); + }; + // queries for an interface + wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) + { + QueryInterface(riid, pDispatch); + }; + + // Creates an Interface + wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL) + { + CreateInstance(clsid, riid); + }; + + // copy constructor + explicit wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL) + { + operator = (ti); + } + + // assignment operator + wxAutoOleInterface& operator = (const wxAutoOleInterface& ti) + { + if (ti.m_interface) + ti.m_interface->AddRef(); + Free(); + m_interface = ti.m_interface; + return *this; + } + + // takes ownership of an existing interface + // Assumed to already have a AddRef() applied + wxAutoOleInterface& operator = (I *&ti) + { + Free(); + m_interface = ti; + return *this; + } + + ~wxAutoOleInterface() + { + Free(); + }; + + + inline void Free() + { + if (m_interface) + m_interface->Release(); + m_interface = NULL; + }; + + // queries for an interface + HRESULT QueryInterface(REFIID riid, IUnknown *pUnk) + { + Free(); + wxASSERT(pUnk != NULL); + return pUnk->QueryInterface(riid, (void **) &m_interface); + }; + + // Create a Interface instance + HRESULT CreateInstance(REFCLSID clsid, REFIID riid) + { + Free(); + return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface); + }; + + + + inline operator I *() const {return m_interface;} + inline I* operator ->() {return m_interface;} + inline I** GetRef() {return &m_interface;} + + inline bool Ok() const {return m_interface != NULL;} +}; + + +wxString OLEHResultToString(HRESULT hr); +wxString GetIIDName(REFIID riid); + +//#define __WXOLEDEBUG + + +#ifdef __WXOLEDEBUG + #define WXOLE_TRACE(str) {OutputDebugString(str);OutputDebugString("\r\n");} + #define WXOLE_TRACEOUT(stuff)\ + {\ + ostringstream os;\ + os << stuff << ends;\ + WXOLE_TRACE(os.str().c_str());\ + } + + #define WXOLE_WARN(__hr,msg)\ + {\ + if (__hr != S_OK)\ + {\ + wxString s = "*** ";\ + s += msg;\ + s += " : "+ OLEHResultToString(__hr);\ + WXOLE_TRACE(s.c_str());\ + }\ + } +#else + #define WXOLE_TRACE(str) + #define WXOLE_TRACEOUT(stuff) + #define WXOLE_WARN(_proc,msg) {_proc;} +#endif + +// Auto Initialisation +class wxOleInit +{ + public: + static IMalloc *GetIMalloc(); + + wxOleInit(); + ~wxOleInit(); +}; + +#define DECLARE_OLE_UNKNOWN(cls)\ + private:\ + class TAutoInitInt\ + {\ + public:\ + LONG l;\ + TAutoInitInt() : l(0) {}\ + };\ + TAutoInitInt refCount, lockCount;\ + wxOleInit oleInit;\ + static void _GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc);\ + public:\ + LONG GetRefCount();\ + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);\ + ULONG STDMETHODCALLTYPE AddRef();\ + ULONG STDMETHODCALLTYPE Release();\ + ULONG STDMETHODCALLTYPE AddLock();\ + ULONG STDMETHODCALLTYPE ReleaseLock() + +#define DEFINE_OLE_TABLE(cls)\ + LONG cls::GetRefCount() {return refCount.l;}\ + HRESULT STDMETHODCALLTYPE cls::QueryInterface(REFIID iid, void ** ppvObject)\ + {\ + if (! ppvObject)\ + {\ + WXOLE_TRACE("*** NULL POINTER ***");\ + return E_FAIL;\ + };\ + const char *desc = NULL;\ + cls::_GetInterface(this, iid, ppvObject, desc);\ + if (! *ppvObject)\ + {\ + WXOLE_TRACEOUT("<" << GetIIDName(iid).c_str() << "> Not Found");\ + return E_NOINTERFACE;\ + };\ + WXOLE_TRACEOUT("QI : <" << desc <<">");\ + ((IUnknown * )(*ppvObject))->AddRef();\ + return S_OK;\ + };\ + ULONG STDMETHODCALLTYPE cls::AddRef()\ + {\ + WXOLE_TRACEOUT(# cls << "::Add ref(" << refCount.l << ")");\ + InterlockedIncrement(&refCount.l);\ + return refCount.l;\ + };\ + ULONG STDMETHODCALLTYPE cls::Release()\ + {\ + if (refCount.l > 0)\ + {\ + InterlockedDecrement(&refCount.l);\ + WXOLE_TRACEOUT(# cls << "::Del ref(" << refCount.l << ")");\ + if (refCount.l == 0)\ + {\ + delete this;\ + return 0;\ + };\ + return refCount.l;\ + }\ + else\ + return 0;\ + }\ + ULONG STDMETHODCALLTYPE cls::AddLock()\ + {\ + WXOLE_TRACEOUT(# cls << "::Add Lock(" << lockCount.l << ")");\ + InterlockedIncrement(&lockCount.l);\ + return lockCount.l;\ + };\ + ULONG STDMETHODCALLTYPE cls::ReleaseLock()\ + {\ + if (lockCount.l > 0)\ + {\ + InterlockedDecrement(&lockCount.l);\ + WXOLE_TRACEOUT(# cls << "::Del Lock(" << lockCount.l << ")");\ + return lockCount.l;\ + }\ + else\ + return 0;\ + }\ + DEFINE_OLE_BASE(cls) + +#define DEFINE_OLE_BASE(cls)\ + void cls::_GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc)\ + {\ + *_interface = NULL;\ + desc = NULL; + +#define OLE_INTERFACE(_iid, _type)\ + if (IsEqualIID(iid, _iid))\ + {\ + WXOLE_TRACE("Found Interface <" # _type ">");\ + *_interface = (IUnknown *) (_type *) self;\ + desc = # _iid;\ + return;\ + } + +#define OLE_IINTERFACE(_face) OLE_INTERFACE(IID_##_face, _face) + +#define OLE_INTERFACE_CUSTOM(func)\ + if (func(self, iid, _interface, desc))\ + return + +#define END_OLE_TABLE\ + } + + + +class wxActiveX : public wxWindow { +public: + wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id = -1); + wxActiveX(wxWindow * parent, wxString progId, wxWindowID id = -1); + virtual ~wxActiveX(); + + void CreateActiveX(REFCLSID clsid); + void CreateActiveX(LPOLESTR progId); + + HRESULT ConnectAdvise(REFIID riid, IUnknown *eventSink); + + void OnSize(wxSizeEvent&); + void OnSetFocus(wxFocusEvent&); + void OnKillFocus(wxFocusEvent&); + + DECLARE_EVENT_TABLE(); + +protected: + friend class FrameSite; + + typedef wxAutoOleInterface wxOleConnectionPoint; + typedef pair wxOleConnection; + typedef vector wxOleConnectionArray; + + wxAutoOleInterface m_clientSite; + wxAutoOleInterface m_ActiveX; + wxAutoOleInterface m_oleObject; + wxAutoOleInterface m_oleInPlaceObject; + wxAutoOleInterface + + m_oleInPlaceActiveObject; + wxAutoOleInterface m_docView; + HWND m_oleObjectHWND; + bool m_bAmbientUserMode; + DWORD m_docAdviseCookie; + wxOleConnectionArray m_connections; + + HRESULT AmbientPropertyChanged(DISPID dispid); + +}; + +#endif /* _IEHTMLWIN_H_ */ diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index e91c7cb8e3..05b92777aa 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -33,6 +33,7 @@ _treeList = [ 'wxArtProvider', 'ScrolledPanel', 'wxMenu', + 'wxIEHtmlWin', ]), # managed windows == things with a caption you can close @@ -117,6 +118,7 @@ _treeList = [ 'wxEditor', 'wxFloatBar', 'wxHtmlWindow', + 'wxIEHtmlWin', 'wxLEDNumberCtrl', 'wxMimeTypesManager', 'wxMVCTree', diff --git a/wxPython/demo/wxIEHtmlWin.py b/wxPython/demo/wxIEHtmlWin.py new file mode 100644 index 0000000000..12210cf03b --- /dev/null +++ b/wxPython/demo/wxIEHtmlWin.py @@ -0,0 +1,198 @@ + +from wxPython.wx import * + +if wxPlatform == '__WXMSW__': + from wxPython.iewin import * + +#---------------------------------------------------------------------- + +class TestPanel(wxWindow): + def __init__(self, parent, log, frame=None): + wxWindow.__init__(self, parent, -1, style=wxCLIP_CHILDREN) + self.log = log + self.current = "http://wxPython.org/" + self.frame = frame + if frame: + self.titleBase = frame.GetTitle() + + + sizer = wxBoxSizer(wxVERTICAL) + btnSizer = wxBoxSizer(wxHORIZONTAL) + + self.ie = wxIEHtmlWin(self, -1) ##, style=wxSUNKEN_BORDER) + + + btn = wxButton(self, wxNewId(), "Open", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnOpenButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "Home", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnHomeButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "<--", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "-->", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "Stop", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnStopButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "Search", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnSearchPageButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + btn = wxButton(self, wxNewId(), "Refresh", style=wxBU_EXACTFIT) + EVT_BUTTON(self, btn.GetId(), self.OnRefreshPageButton) + btnSizer.Add(btn, 0, wxEXPAND|wxALL, 2) + + txt = wxStaticText(self, -1, "Location:") + btnSizer.Add(txt, 0, wxCENTER|wxALL, 2) + + self.location = wxComboBox(self, wxNewId(), "", style=wxCB_DROPDOWN) + EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect) + EVT_KEY_UP(self.location, self.OnLocationKey) + EVT_CHAR(self.location, self.IgnoreReturn) + btnSizer.Add(self.location, 1, wxEXPAND|wxALL, 2) + + sizer.Add(btnSizer, 0, wxEXPAND) + sizer.Add(self.ie, 1, wxEXPAND) + + self.ie.LoadUrl(self.current) + self.location.Append(self.current) + + self.SetSizer(sizer) + self.SetAutoLayout(true) + EVT_SIZE(self, self.OnSize) + + # Hook up the event handlers for the IE window + EVT_MSHTML_BEFORENAVIGATE2(self, -1, self.OnBeforeNavigate2) + EVT_MSHTML_NEWWINDOW2(self, -1, self.OnNewWindow2) + EVT_MSHTML_DOCUMENTCOMPLETE(self, -1, self.OnDocumentComplete) + #EVT_MSHTML_PROGRESSCHANGE(self, -1, self.OnProgressChange) + EVT_MSHTML_STATUSTEXTCHANGE(self, -1, self.OnStatusTextChange) + EVT_MSHTML_TITLECHANGE(self, -1, self.OnTitleChange) + + + def OnSize(self, evt): + self.Layout() + + def OnLocationSelect(self, evt): + url = self.location.GetStringSelection() + self.log.write('OnLocationSelect: %s\n' % url) + self.ie.LoadUrl(url) + + def OnLocationKey(self, evt): + if evt.KeyCode() == WXK_RETURN: + URL = self.location.GetValue() + self.location.Append(URL) + self.ie.LoadUrl(URL) + else: + evt.Skip() + + def IgnoreReturn(self, evt): + print 'IgnoreReturn' + if evt.KeyCode() != WXK_RETURN: + evt.Skip() + + def OnOpenButton(self, event): + dlg = wxTextEntryDialog(self, "Open Location", + "Enter a full URL or local path", + self.current, wxOK|wxCANCEL) + dlg.CentreOnParent() + if dlg.ShowModal() == wxID_OK: + self.current = dlg.GetValue() + self.ie.LoadUrl(self.current) + dlg.Destroy() + + def OnHomeButton(self, event): + self.ie.GoHome() ## ET Phone Home! + + def OnPrevPageButton(self, event): + self.ie.GoBack() + + def OnNextPageButton(self, event): + self.ie.GoForward() + + def OnStopButton(self, evt): + self.ie.Stop() + + def OnSearchPageButton(self, evt): + self.ie.GoSearch() + + def OnRefreshPageButton(self, evt): + self.ie.Refresh(wxIEHTML_REFRESH_COMPLETELY) + + + + def logEvt(self, name, event): + self.log.write('%s: %s\n' % + (name, (event.GetLong1(), event.GetLong2(), event.GetText()))) + + def OnBeforeNavigate2(self, evt): + self.logEvt('OnBeforeNavigate2', evt) + + def OnNewWindow2(self, evt): + self.logEvt('OnNewWindow2', evt) + evt.Veto() # don't allow it + + def OnDocumentComplete(self, evt): + self.logEvt('OnDocumentComplete', evt) + self.current = evt.GetText() + self.location.SetValue(self.current) + + def OnTitleChange(self, evt): + self.logEvt('OnTitleChange', evt) + if self.frame: + self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText()) + + def OnStatusTextChange(self, evt): + self.logEvt('OnStatusTextChange', evt) + if self.frame: + self.frame.SetStatusText(evt.GetText()) + + +#---------------------------------------------------------------------- +# for the demo framework... + +def runTest(frame, nb, log): + if wxPlatform == '__WXMSW__': + win = TestPanel(nb, log, frame) + return win + else: + dlg = wxMessageDialog(frame, 'This demo only works on MSW.', + 'Sorry', wxOK | wxICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() + + + +overview = """\ + +

wxIEHtmlWin

+ +The wxIEHtmlWin class is the first example of using a contributed +wxActiveX class in wxWindows C++. It is still experimental, but +I think it is useful. + +

Using this class is simpler than ActiveXWrapper, doesn't rely on +the win32all extensions, and is more "wx\'ish", meaning that it uses +events and etc. as would be expected from any other wx window. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + +#---------------------------------------------------------------------- + diff --git a/wxPython/distrib/make_installer.py b/wxPython/distrib/make_installer.py index 06812c4e80..2a948b7451 100644 --- a/wxPython/distrib/make_installer.py +++ b/wxPython/distrib/make_installer.py @@ -81,6 +81,7 @@ Source: "wxPython\oglc.pyd"; DestDir: "{app}\wxPython"; Component Source: "wxPython\stc_c.pyd"; DestDir: "{app}\wxPython"; Components: core Source: "wxPython\xrcc.pyd"; DestDir: "{app}\wxPython"; Components: core Source: "wxPython\gizmosc.pyd"; DestDir: "{app}\wxPython"; Components: core +Source: "wxPython\iewinc.pyd"; DestDir: "{app}\wxPython"; Components: core Source: "wxPython\dllwidget_c.pyd"; DestDir: "{app}\wxPython"; Components: core Source: "wxPython\*.py"; DestDir: "{app}\wxPython"; Components: core diff --git a/wxPython/setup.py b/wxPython/setup.py index c95cc98d7c..4704c47588 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -36,7 +36,8 @@ BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library BUILD_DLLWIDGET = 1# Build a module that enables unknown wx widgets # to be loaded from a DLL and to be used from Python. -BUILD_IEWIN = 0 # Internet Explorer wrapper (experimental) + # Internet Explorer wrapper (experimental) +BUILD_IEWIN = (os.name == 'nt') CORE_ONLY = 0 # if true, don't build any of the above @@ -136,7 +137,7 @@ if bcpp_compiling: # Boolean (int) flags for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC', - 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', + 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN', 'CORE_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'UNICODE', 'UNDEF_NDEBUG', 'FINAL', 'HYBRID', ]: for x in range(len(sys.argv)): @@ -169,6 +170,7 @@ if CORE_ONLY: BUILD_XRC = 0 BUILD_GIZMOS = 0 BUILD_DLLWIDGET = 0 + BUILD_IEWIN = 0 if UNICODE and os.name != 'nt': @@ -685,6 +687,7 @@ if not GL_ONLY and BUILD_IEWIN: ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location, + '%s/wxactivex.cpp' % location, ] + swig_sources, include_dirs = includes, -- 2.45.2