Removing old iewin extension. Replaced by activex/wxie.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36499 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f3c49b55b0
commit
4136a15d56
@ -1 +0,0 @@
|
||||
orig
|
@ -1,585 +0,0 @@
|
||||
#include "IEHtmlWin.h"
|
||||
#include <wx/strconv.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <oleidl.h>
|
||||
#include <winerror.h>
|
||||
#include <exdispid.h>
|
||||
#include <exdisp.h>
|
||||
#include <olectl.h>
|
||||
#include <Mshtml.h>
|
||||
#include <sstream>
|
||||
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) {}
|
||||
virtual ~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 = wxEmptyString, 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 wxEmptyString;
|
||||
};
|
||||
|
||||
#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, wxEmptyString, 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 "Shell.Explorer"
|
||||
#define PROGID CLSID_WebBrowser
|
||||
//#define PROGID CLSID_MozillaBrowser
|
||||
//#define PROGID CLSID_HTMLDocument
|
||||
//#define PROGID "MSCAL.Calendar"
|
||||
//#define PROGID "WordPad.Document.1"
|
||||
//#define PROGID "SoftwareFX.ChartFX.20"
|
||||
|
||||
wxIEHtmlWin::wxIEHtmlWin(wxWindow * parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name) :
|
||||
wxActiveX(parent, PROGID, id, pos, size, style, name)
|
||||
{
|
||||
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<IDispatch> disp(pDisp);
|
||||
|
||||
if (disp.Ok())
|
||||
{
|
||||
wxAutoOleInterface<IHTMLDocument2> doc(IID_IHTMLDocument2, disp);
|
||||
if (doc.Ok())
|
||||
doc->put_charset((BSTR) (const wchar_t *) charset.wc_str(wxConvUTF8));
|
||||
//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;
|
||||
};
|
||||
};
|
||||
|
||||
class IwxStreamAdaptor : public IStreamAdaptorBase
|
||||
{
|
||||
private:
|
||||
wxInputStream *m_is;
|
||||
|
||||
public:
|
||||
|
||||
IwxStreamAdaptor(wxInputStream *is) : IStreamAdaptorBase(), m_is(is)
|
||||
{
|
||||
wxASSERT(m_is != NULL);
|
||||
}
|
||||
~IwxStreamAdaptor()
|
||||
{
|
||||
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->LastRead();
|
||||
|
||||
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) (const wchar_t *) url.wc_str(wxConvUTF8),
|
||||
&navFlag, &targetFrame, &postData, &headers);
|
||||
};
|
||||
|
||||
class wxOwnedMemInputStream : public wxMemoryInputStream
|
||||
{
|
||||
public:
|
||||
char *m_data;
|
||||
|
||||
wxOwnedMemInputStream(char *data, size_t len) :
|
||||
wxMemoryInputStream(data, len), m_data(data)
|
||||
{}
|
||||
~wxOwnedMemInputStream()
|
||||
{
|
||||
free(m_data);
|
||||
}
|
||||
};
|
||||
|
||||
bool wxIEHtmlWin::LoadString(wxString html)
|
||||
{
|
||||
char *data = NULL;
|
||||
size_t len = html.length();
|
||||
#ifdef UNICODE
|
||||
len *= 2;
|
||||
#endif
|
||||
data = (char *) malloc(len);
|
||||
memcpy(data, html.c_str(), len);
|
||||
return LoadStream(new wxOwnedMemInputStream(data, len));
|
||||
};
|
||||
|
||||
bool wxIEHtmlWin::LoadStream(IStreamAdaptorBase *pstrm)
|
||||
{
|
||||
wxAutoOleInterface<IStream> strm(pstrm);
|
||||
|
||||
// Document Interface
|
||||
IDispatch *pDisp = NULL;
|
||||
HRESULT hret = m_webBrowser->get_Document(&pDisp);
|
||||
if (! pDisp)
|
||||
return false;
|
||||
wxAutoOleInterface<IDispatch> disp(pDisp);
|
||||
|
||||
|
||||
// get IPersistStreamInit
|
||||
wxAutoOleInterface<IPersistStreamInit>
|
||||
pPersistStreamInit(IID_IPersistStreamInit, disp);
|
||||
|
||||
if (pPersistStreamInit.Ok())
|
||||
{
|
||||
HRESULT hr = pPersistStreamInit->InitNew();
|
||||
if (SUCCEEDED(hr))
|
||||
hr = pPersistStreamInit->Load(strm);
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
bool wxIEHtmlWin::LoadStream(istream *is)
|
||||
{
|
||||
// wrap reference around stream
|
||||
IStreamAdaptor *pstrm = new IStreamAdaptor(is);
|
||||
pstrm->AddRef();
|
||||
|
||||
return LoadStream(pstrm);
|
||||
};
|
||||
|
||||
bool wxIEHtmlWin::LoadStream(wxInputStream *is)
|
||||
{
|
||||
// wrap reference around stream
|
||||
IwxStreamAdaptor *pstrm = new IwxStreamAdaptor(is);
|
||||
pstrm->AddRef();
|
||||
|
||||
return LoadStream(pstrm);
|
||||
};
|
||||
|
||||
|
||||
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<IHTMLSelectionObject> GetSelObject(IOleObject *oleObject)
|
||||
{
|
||||
// Query for IWebBrowser interface
|
||||
wxAutoOleInterface<IWebBrowser2> wb(IID_IWebBrowser2, oleObject);
|
||||
if (! wb.Ok())
|
||||
return wxAutoOleInterface<IHTMLSelectionObject>();
|
||||
|
||||
IDispatch *iDisp = NULL;
|
||||
HRESULT hr = wb->get_Document(&iDisp);
|
||||
if (hr != S_OK)
|
||||
return wxAutoOleInterface<IHTMLSelectionObject>();
|
||||
|
||||
// Query for Document Interface
|
||||
wxAutoOleInterface<IHTMLDocument2> hd(IID_IHTMLDocument2, iDisp);
|
||||
iDisp->Release();
|
||||
|
||||
if (! hd.Ok())
|
||||
return wxAutoOleInterface<IHTMLSelectionObject>();
|
||||
|
||||
IHTMLSelectionObject *_so = NULL;
|
||||
hr = hd->get_selection(&_so);
|
||||
|
||||
// take ownership of selection object
|
||||
wxAutoOleInterface<IHTMLSelectionObject> so(_so);
|
||||
|
||||
return so;
|
||||
};
|
||||
|
||||
static wxAutoOleInterface<IHTMLTxtRange> GetSelRange(IOleObject *oleObject)
|
||||
{
|
||||
wxAutoOleInterface<IHTMLTxtRange> tr;
|
||||
|
||||
wxAutoOleInterface<IHTMLSelectionObject> 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<IHTMLTxtRange> tr(GetSelRange(m_oleObject));
|
||||
if (! tr)
|
||||
return wxEmptyString;
|
||||
|
||||
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 wxEmptyString;
|
||||
|
||||
wxString s = text;
|
||||
SysFreeString(text);
|
||||
|
||||
return s;
|
||||
};
|
||||
|
||||
wxString wxIEHtmlWin::GetText(bool asHTML)
|
||||
{
|
||||
if (! m_webBrowser.Ok())
|
||||
return wxEmptyString;
|
||||
|
||||
// get document dispatch interface
|
||||
IDispatch *iDisp = NULL;
|
||||
HRESULT hr = m_webBrowser->get_Document(&iDisp);
|
||||
if (hr != S_OK)
|
||||
return wxEmptyString;
|
||||
|
||||
// Query for Document Interface
|
||||
wxAutoOleInterface<IHTMLDocument2> hd(IID_IHTMLDocument2, iDisp);
|
||||
iDisp->Release();
|
||||
|
||||
if (! hd.Ok())
|
||||
return wxEmptyString;
|
||||
|
||||
// get body element
|
||||
IHTMLElement *_body = NULL;
|
||||
hd->get_body(&_body);
|
||||
if (! _body)
|
||||
return wxEmptyString;
|
||||
wxAutoOleInterface<IHTMLElement> 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 wxEmptyString;
|
||||
|
||||
wxString s = text;
|
||||
SysFreeString(text);
|
||||
|
||||
return s;
|
||||
};
|
@ -1,104 +0,0 @@
|
||||
#ifndef _IEHTMLWIN_H_
|
||||
#define _IEHTMLWIN_H_
|
||||
#pragma warning( disable : 4101 4786)
|
||||
#pragma warning( disable : 4786)
|
||||
|
||||
|
||||
#include <wx/setup.h>
|
||||
#include <wx/wx.h>
|
||||
#include <exdisp.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include "wxactivex.h"
|
||||
|
||||
class wxMSHTMLEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
wxMSHTMLEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
||||
: wxNotifyEvent(commandType, id)
|
||||
{}
|
||||
|
||||
wxString GetText1() { 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) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
#define EVT_MSHTML_NEWWINDOW2(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_NEWWINDOW2, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
#define EVT_MSHTML_DOCUMENTCOMPLETE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
#define EVT_MSHTML_PROGRESSCHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
#define EVT_MSHTML_STATUSTEXTCHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
#define EVT_MSHTML_TITLECHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_MSHTML_TITLECHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxMSHTMLEventFunction, & fn ), NULL ),
|
||||
|
||||
|
||||
enum wxIEHtmlRefreshLevel
|
||||
{
|
||||
wxIEHTML_REFRESH_NORMAL = 0,
|
||||
wxIEHTML_REFRESH_IFEXPIRED = 1,
|
||||
wxIEHTML_REFRESH_CONTINUE = 2,
|
||||
wxIEHTML_REFRESH_COMPLETELY = 3
|
||||
};
|
||||
|
||||
class IStreamAdaptorBase;
|
||||
|
||||
class wxIEHtmlWin : public wxActiveX
|
||||
{
|
||||
|
||||
public:
|
||||
wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
virtual ~wxIEHtmlWin();
|
||||
|
||||
void LoadUrl(const wxString&);
|
||||
bool LoadString(wxString html);
|
||||
bool LoadStream(istream *strm);
|
||||
bool LoadStream(wxInputStream *is);
|
||||
|
||||
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();
|
||||
bool LoadStream(IStreamAdaptorBase *pstrm);
|
||||
|
||||
wxAutoOleInterface<IWebBrowser2> m_webBrowser;
|
||||
};
|
||||
|
||||
#endif /* _IEHTMLWIN_H_ */
|
@ -1,13 +0,0 @@
|
||||
// A bunch of %rename directives generated by BuildRenamers in config.py
|
||||
// in order to remove the wx prefix from all global scope names.
|
||||
|
||||
#ifndef BUILDING_RENAMERS
|
||||
|
||||
%rename(MSHTMLEvent) wxMSHTMLEvent;
|
||||
%rename(IEHTML_REFRESH_NORMAL) wxIEHTML_REFRESH_NORMAL;
|
||||
%rename(IEHTML_REFRESH_IFEXPIRED) wxIEHTML_REFRESH_IFEXPIRED;
|
||||
%rename(IEHTML_REFRESH_CONTINUE) wxIEHTML_REFRESH_CONTINUE;
|
||||
%rename(IEHTML_REFRESH_COMPLETELY) wxIEHTML_REFRESH_COMPLETELY;
|
||||
%rename(IEHtmlWin) wxIEHtmlWin;
|
||||
|
||||
#endif
|
@ -1,2 +0,0 @@
|
||||
|
||||
EVT*
|
@ -1,4 +0,0 @@
|
||||
# Stuff these names into the wx namespace so wxPyConstructObject can find them
|
||||
|
||||
wx.wxMSHTMLEventPtr = wxMSHTMLEventPtr
|
||||
wx.wxIEHtmlWinPtr = wxIEHtmlWinPtr
|
@ -1,118 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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(package="wx") iewin
|
||||
|
||||
%{
|
||||
#include "wx/wxPython/wxPython.h"
|
||||
#include "wx/wxPython/pyclasses.h"
|
||||
#include "wx/wxPython/pyistream.h"
|
||||
|
||||
#include "IEHtmlWin.h"
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%import core.i
|
||||
%pythoncode { wx = _core }
|
||||
%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
|
||||
%pythoncode {
|
||||
import warnings
|
||||
warnings.warn("This module is deprecated. Please use the wx.lib.iewin module instead.",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
}
|
||||
|
||||
MAKE_CONST_WXSTRING_NOSWIG(PanelNameStr);
|
||||
|
||||
%include _iewin_rename.i
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxMSHTMLEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
wxMSHTMLEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
|
||||
wxString GetText1();
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
%pythoncode {
|
||||
EVT_MSHTML_BEFORENAVIGATE2 = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, 1)
|
||||
EVT_MSHTML_NEWWINDOW2 = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_NEWWINDOW2, 1)
|
||||
EVT_MSHTML_DOCUMENTCOMPLETE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, 1)
|
||||
EVT_MSHTML_PROGRESSCHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, 1)
|
||||
EVT_MSHTML_STATUSTEXTCHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, 1)
|
||||
EVT_MSHTML_TITLECHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_TITLECHANGE, 1)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum wxIEHtmlRefreshLevel {
|
||||
wxIEHTML_REFRESH_NORMAL = 0,
|
||||
wxIEHTML_REFRESH_IFEXPIRED = 1,
|
||||
wxIEHTML_REFRESH_CONTINUE = 2,
|
||||
wxIEHTML_REFRESH_COMPLETELY = 3
|
||||
};
|
||||
|
||||
|
||||
MustHaveApp(wxIEHtmlWin);
|
||||
|
||||
class wxIEHtmlWin : public wxWindow /* wxActiveX */
|
||||
{
|
||||
public:
|
||||
%pythonAppend wxIEHtmlWin "self._setOORInfo(self)"
|
||||
|
||||
wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPyPanelNameStr);
|
||||
|
||||
void LoadUrl(const wxString&);
|
||||
bool LoadString(wxString html);
|
||||
bool LoadStream(wxInputStream *is);
|
||||
|
||||
%pythoncode { Navigate = LoadUrl }
|
||||
|
||||
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();
|
||||
%Rename(RefreshPage, bool, Refresh(wxIEHtmlRefreshLevel level));
|
||||
bool Stop();
|
||||
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,181 +0,0 @@
|
||||
# This file was created automatically by SWIG.
|
||||
# Don't modify this file, modify the SWIG interface instead.
|
||||
|
||||
import _iewin
|
||||
|
||||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
|
||||
if (name == "this"):
|
||||
if isinstance(value, class_type):
|
||||
self.__dict__[name] = value.this
|
||||
if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown
|
||||
del value.thisown
|
||||
return
|
||||
method = class_type.__swig_setmethods__.get(name,None)
|
||||
if method: return method(self,value)
|
||||
if (not static) or hasattr(self,name) or (name == "thisown"):
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
|
||||
def _swig_setattr(self,class_type,name,value):
|
||||
return _swig_setattr_nondynamic(self,class_type,name,value,0)
|
||||
|
||||
def _swig_getattr(self,class_type,name):
|
||||
method = class_type.__swig_getmethods__.get(name,None)
|
||||
if method: return method(self)
|
||||
raise AttributeError,name
|
||||
|
||||
import types
|
||||
try:
|
||||
_object = types.ObjectType
|
||||
_newclass = 1
|
||||
except AttributeError:
|
||||
class _object : pass
|
||||
_newclass = 0
|
||||
del types
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_method(set):
|
||||
def set_attr(self,name,value):
|
||||
if hasattr(self,name) or (name in ("this", "thisown")):
|
||||
set(self,name,value)
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
return set_attr
|
||||
|
||||
|
||||
import _core
|
||||
wx = _core
|
||||
__docfilter__ = wx.__DocFilter(globals())
|
||||
import warnings
|
||||
warnings.warn("This module is deprecated. Please use the wx.lib.iewin module instead.",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
class MSHTMLEvent(_core.NotifyEvent):
|
||||
"""Proxy of C++ MSHTMLEvent class"""
|
||||
def __repr__(self):
|
||||
return "<%s.%s; proxy of C++ wxMSHTMLEvent instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""__init__(self, wxEventType commandType=wxEVT_NULL, int id=0) -> MSHTMLEvent"""
|
||||
newobj = _iewin.new_MSHTMLEvent(*args, **kwargs)
|
||||
self.this = newobj.this
|
||||
self.thisown = 1
|
||||
del newobj.thisown
|
||||
def GetText1(*args, **kwargs):
|
||||
"""GetText1(self) -> String"""
|
||||
return _iewin.MSHTMLEvent_GetText1(*args, **kwargs)
|
||||
|
||||
def GetLong1(*args, **kwargs):
|
||||
"""GetLong1(self) -> long"""
|
||||
return _iewin.MSHTMLEvent_GetLong1(*args, **kwargs)
|
||||
|
||||
def GetLong2(*args, **kwargs):
|
||||
"""GetLong2(self) -> long"""
|
||||
return _iewin.MSHTMLEvent_GetLong2(*args, **kwargs)
|
||||
|
||||
|
||||
class MSHTMLEventPtr(MSHTMLEvent):
|
||||
def __init__(self, this):
|
||||
self.this = this
|
||||
if not hasattr(self,"thisown"): self.thisown = 0
|
||||
self.__class__ = MSHTMLEvent
|
||||
_iewin.MSHTMLEvent_swigregister(MSHTMLEventPtr)
|
||||
|
||||
wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2 = _iewin.wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2
|
||||
wxEVT_COMMAND_MSHTML_NEWWINDOW2 = _iewin.wxEVT_COMMAND_MSHTML_NEWWINDOW2
|
||||
wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE = _iewin.wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE
|
||||
wxEVT_COMMAND_MSHTML_PROGRESSCHANGE = _iewin.wxEVT_COMMAND_MSHTML_PROGRESSCHANGE
|
||||
wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE = _iewin.wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE
|
||||
wxEVT_COMMAND_MSHTML_TITLECHANGE = _iewin.wxEVT_COMMAND_MSHTML_TITLECHANGE
|
||||
EVT_MSHTML_BEFORENAVIGATE2 = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_BEFORENAVIGATE2, 1)
|
||||
EVT_MSHTML_NEWWINDOW2 = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_NEWWINDOW2, 1)
|
||||
EVT_MSHTML_DOCUMENTCOMPLETE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_DOCUMENTCOMPLETE, 1)
|
||||
EVT_MSHTML_PROGRESSCHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_PROGRESSCHANGE, 1)
|
||||
EVT_MSHTML_STATUSTEXTCHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_STATUSTEXTCHANGE, 1)
|
||||
EVT_MSHTML_TITLECHANGE = wx.PyEventBinder(wxEVT_COMMAND_MSHTML_TITLECHANGE, 1)
|
||||
|
||||
IEHTML_REFRESH_NORMAL = _iewin.IEHTML_REFRESH_NORMAL
|
||||
IEHTML_REFRESH_IFEXPIRED = _iewin.IEHTML_REFRESH_IFEXPIRED
|
||||
IEHTML_REFRESH_CONTINUE = _iewin.IEHTML_REFRESH_CONTINUE
|
||||
IEHTML_REFRESH_COMPLETELY = _iewin.IEHTML_REFRESH_COMPLETELY
|
||||
class IEHtmlWin(_core.Window):
|
||||
"""Proxy of C++ IEHtmlWin class"""
|
||||
def __repr__(self):
|
||||
return "<%s.%s; proxy of C++ wxIEHtmlWin instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
__init__(self, Window parent, int id=-1, Point pos=DefaultPosition,
|
||||
Size size=DefaultSize, long style=0, String name=PanelNameStr) -> IEHtmlWin
|
||||
"""
|
||||
newobj = _iewin.new_IEHtmlWin(*args, **kwargs)
|
||||
self.this = newobj.this
|
||||
self.thisown = 1
|
||||
del newobj.thisown
|
||||
self._setOORInfo(self)
|
||||
|
||||
def LoadUrl(*args, **kwargs):
|
||||
"""LoadUrl(self, String ??)"""
|
||||
return _iewin.IEHtmlWin_LoadUrl(*args, **kwargs)
|
||||
|
||||
def LoadString(*args, **kwargs):
|
||||
"""LoadString(self, String html) -> bool"""
|
||||
return _iewin.IEHtmlWin_LoadString(*args, **kwargs)
|
||||
|
||||
def LoadStream(*args, **kwargs):
|
||||
"""LoadStream(self, InputStream is) -> bool"""
|
||||
return _iewin.IEHtmlWin_LoadStream(*args, **kwargs)
|
||||
|
||||
Navigate = LoadUrl
|
||||
def SetCharset(*args, **kwargs):
|
||||
"""SetCharset(self, String charset)"""
|
||||
return _iewin.IEHtmlWin_SetCharset(*args, **kwargs)
|
||||
|
||||
def SetEditMode(*args, **kwargs):
|
||||
"""SetEditMode(self, bool seton)"""
|
||||
return _iewin.IEHtmlWin_SetEditMode(*args, **kwargs)
|
||||
|
||||
def GetEditMode(*args, **kwargs):
|
||||
"""GetEditMode(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_GetEditMode(*args, **kwargs)
|
||||
|
||||
def GetStringSelection(*args, **kwargs):
|
||||
"""GetStringSelection(self, bool asHTML=False) -> String"""
|
||||
return _iewin.IEHtmlWin_GetStringSelection(*args, **kwargs)
|
||||
|
||||
def GetText(*args, **kwargs):
|
||||
"""GetText(self, bool asHTML=False) -> String"""
|
||||
return _iewin.IEHtmlWin_GetText(*args, **kwargs)
|
||||
|
||||
def GoBack(*args, **kwargs):
|
||||
"""GoBack(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_GoBack(*args, **kwargs)
|
||||
|
||||
def GoForward(*args, **kwargs):
|
||||
"""GoForward(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_GoForward(*args, **kwargs)
|
||||
|
||||
def GoHome(*args, **kwargs):
|
||||
"""GoHome(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_GoHome(*args, **kwargs)
|
||||
|
||||
def GoSearch(*args, **kwargs):
|
||||
"""GoSearch(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_GoSearch(*args, **kwargs)
|
||||
|
||||
def RefreshPage(*args, **kwargs):
|
||||
"""RefreshPage(self, int level) -> bool"""
|
||||
return _iewin.IEHtmlWin_RefreshPage(*args, **kwargs)
|
||||
|
||||
def Stop(*args, **kwargs):
|
||||
"""Stop(self) -> bool"""
|
||||
return _iewin.IEHtmlWin_Stop(*args, **kwargs)
|
||||
|
||||
|
||||
class IEHtmlWinPtr(IEHtmlWin):
|
||||
def __init__(self, this):
|
||||
self.this = this
|
||||
if not hasattr(self,"thisown"): self.thisown = 0
|
||||
self.__class__ = IEHtmlWin
|
||||
_iewin.IEHtmlWin_swigregister(IEHtmlWinPtr)
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,158 +0,0 @@
|
||||
Lindsay Mathieson
|
||||
Email : <lmathieson@optusnet.com.au>
|
||||
|
||||
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:
|
||||
---------------
|
||||
- EVT_ACTIVEX(id, eventName, handler) (handler = void OnActiveX(wxActiveXEvent& event))
|
||||
class wxActiveXEvent : public wxNotifyEvent
|
||||
int ParamCount() const;
|
||||
wxVariant operator[] (int idx) const; // parameter by index
|
||||
wxVariant& operator[] (int idx);
|
||||
wxVariant operator[] (wxString name) const; // named parameters
|
||||
wxVariant& operator[] (wxString name);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
Sample Events:
|
||||
--------------
|
||||
EVT_ACTIVEX(ID_MSHTML, "BeforeNavigate2", OnMSHTMLBeforeNavigate2X)
|
||||
|
||||
void wxIEFrame::OnMSHTMLBeforeNavigate2X(wxActiveXEvent& event)
|
||||
{
|
||||
wxString url = event["Url"];
|
||||
|
||||
int rc = wxMessageBox(url, "Allow open url ?", wxYES_NO);
|
||||
|
||||
if (rc != wxYES)
|
||||
event["Cancel"] = true;
|
||||
};
|
||||
|
||||
|
||||
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 : <lmathieson@optusnet.com.au>
|
File diff suppressed because it is too large
Load Diff
@ -1,392 +0,0 @@
|
||||
#ifndef WX_ACTIVE_X
|
||||
#define WX_ACTIVE_X
|
||||
#pragma warning( disable : 4101 4786)
|
||||
#pragma warning( disable : 4786)
|
||||
|
||||
|
||||
#include <wx/setup.h>
|
||||
#include <wx/wx.h>
|
||||
#include <wx/variant.h>
|
||||
#include <oleidl.h>
|
||||
#include <exdisp.h>
|
||||
#include <docobj.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
//////////////////////////////////////////
|
||||
// wxAutoOleInterface<Interface>
|
||||
// Template class for smart interface handling
|
||||
// - Automatically dereferences ole interfaces
|
||||
// - Smart Copy Semantics
|
||||
// - Can Create Interfaces
|
||||
// - Can query for other interfaces
|
||||
template <class I> 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
|
||||
wxAutoOleInterface(const wxAutoOleInterface<I>& ti) : m_interface(NULL)
|
||||
{
|
||||
operator = (ti);
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
wxAutoOleInterface<I>& operator = (const wxAutoOleInterface<I>& 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<I>& 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:
|
||||
////////////////////////////////////////
|
||||
// type stuff
|
||||
class ParamX // refer to ELEMDESC, IDLDESC in MSDN
|
||||
{
|
||||
public:
|
||||
USHORT flags;
|
||||
bool isPtr, isSafeArray;
|
||||
VARTYPE vt;
|
||||
wxString name;
|
||||
|
||||
inline bool IsIn() const {return (flags & IDLFLAG_FIN) != 0;}
|
||||
inline bool IsOut() const {return (flags & IDLFLAG_FOUT) != 0;}
|
||||
inline bool IsRetVal() const {return (flags & IDLFLAG_FRETVAL) != 0;}
|
||||
};
|
||||
|
||||
typedef vector<ParamX> ParamXArray;
|
||||
|
||||
class FuncX // refer to FUNCDESC in MSDN
|
||||
{
|
||||
public:
|
||||
wxString name;
|
||||
MEMBERID memid;
|
||||
bool hasOut;
|
||||
|
||||
ParamXArray params;
|
||||
};
|
||||
|
||||
typedef vector<FuncX> FuncXArray;
|
||||
typedef map<MEMBERID, int> MemberIdList;
|
||||
|
||||
wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
wxActiveX(wxWindow * parent, wxString progId, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr);
|
||||
virtual ~wxActiveX();
|
||||
|
||||
void CreateActiveX(REFCLSID clsid);
|
||||
void CreateActiveX(LPOLESTR progId);
|
||||
|
||||
// expose type info
|
||||
inline int GetEventCount() const {return m_events.size();}
|
||||
const FuncX& GetEvent(int idx) const;
|
||||
|
||||
HRESULT ConnectAdvise(REFIID riid, IUnknown *eventSink);
|
||||
|
||||
void OnSize(wxSizeEvent&);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnMouse(wxMouseEvent& event);
|
||||
void OnSetFocus(wxFocusEvent&);
|
||||
void OnKillFocus(wxFocusEvent&);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
protected:
|
||||
friend class FrameSite;
|
||||
friend class wxActiveXEvents;
|
||||
|
||||
typedef wxAutoOleInterface<IConnectionPoint> wxOleConnectionPoint;
|
||||
typedef pair<wxOleConnectionPoint, DWORD> wxOleConnection;
|
||||
typedef vector<wxOleConnection> wxOleConnectionArray;
|
||||
|
||||
wxAutoOleInterface<IOleClientSite> m_clientSite;
|
||||
wxAutoOleInterface<IUnknown> m_ActiveX;
|
||||
wxAutoOleInterface<IOleObject> m_oleObject;
|
||||
wxAutoOleInterface<IOleInPlaceObject> m_oleInPlaceObject;
|
||||
wxAutoOleInterface<IOleInPlaceActiveObject>
|
||||
|
||||
m_oleInPlaceActiveObject;
|
||||
wxAutoOleInterface<IOleDocumentView> m_docView;
|
||||
wxAutoOleInterface<IViewObject> m_viewObject;
|
||||
HWND m_oleObjectHWND;
|
||||
bool m_bAmbientUserMode;
|
||||
DWORD m_docAdviseCookie;
|
||||
wxOleConnectionArray m_connections;
|
||||
|
||||
HRESULT AmbientPropertyChanged(DISPID dispid);
|
||||
|
||||
void GetTypeInfo();
|
||||
void GetTypeInfo(ITypeInfo *ti, bool defEventSink);
|
||||
|
||||
|
||||
// events
|
||||
FuncXArray m_events;
|
||||
MemberIdList m_eventsIdx;
|
||||
|
||||
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
};
|
||||
|
||||
// events
|
||||
class wxActiveXEvent : public wxCommandEvent
|
||||
{
|
||||
private:
|
||||
friend class wxActiveXEvents;
|
||||
|
||||
wxVariant m_params;
|
||||
|
||||
public:
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxActiveXEvent(*this); }
|
||||
|
||||
wxString EventName();
|
||||
int ParamCount() const;
|
||||
wxString ParamType(int idx);
|
||||
wxString ParamName(int idx);
|
||||
wxVariant operator[] (int idx) const;
|
||||
wxVariant& operator[] (int idx);
|
||||
wxVariant operator[] (wxString name) const;
|
||||
wxVariant& operator[] (wxString name);
|
||||
};
|
||||
|
||||
const wxEventType& RegisterActiveXEvent(const wxChar *eventName);
|
||||
const wxEventType& RegisterActiveXEvent(DISPID event);
|
||||
|
||||
typedef void (wxEvtHandler::*wxActiveXEventFunction)(wxActiveXEvent&);
|
||||
|
||||
#define EVT_ACTIVEX(id, eventName, fn) DECLARE_EVENT_TABLE_ENTRY(RegisterActiveXEvent(wxT(eventName)), id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxActiveXEventFunction, & fn ), (wxObject *) NULL ),
|
||||
#define EVT_ACTIVEX_DISPID(id, eventDispId, fn) DECLARE_EVENT_TABLE_ENTRY(RegisterActiveXEvent(eventDispId), id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxActiveXEventFunction, & fn ), (wxObject *) NULL ),
|
||||
|
||||
//util
|
||||
bool MSWVariantToVariant(VARIANTARG& va, wxVariant& vx);
|
||||
bool VariantToMSWVariant(wxVariant& vx, VARIANTARG& va);
|
||||
|
||||
#endif /* _IEHTMLWIN_H_ */
|
Loading…
Reference in New Issue
Block a user