Implement IDocHostUIHandler in wxWebViewIE to improve the default behaviour. Disable built-in keyboard handlers, remove the 3D border and enable themes.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70362 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1f7d05f019
commit
accc94d55c
@ -480,6 +480,8 @@ MSW:
|
||||
- Set wxMenu being closed in wxEVT_MENU_CLOSE events (Marcin Malich).
|
||||
- Fix coordinates and Z-position for joystick events (Markus Juergens).
|
||||
- Fix size of the font returned by wxTextCtrl::GetStyle() (Igor Korot).
|
||||
- Add wxActiveXContainer::QueryClientSiteInterface and implement it in
|
||||
wxWebViewIE to improve the default behaviour (Allonii)
|
||||
|
||||
OSX:
|
||||
|
||||
|
@ -150,9 +150,103 @@ class wxIInternetSession : public IUnknown
|
||||
|
||||
/* END OF URLMON.H implementation */
|
||||
|
||||
/* Same goes for the mshtmhst.h, these are also taken
|
||||
* from mingw-w64 headers.
|
||||
*/
|
||||
|
||||
typedef enum _tagwxDOCHOSTUIFLAG
|
||||
{
|
||||
DOCHOSTUIFLAG_DIALOG = 0x1,
|
||||
DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2,
|
||||
DOCHOSTUIFLAG_NO3DBORDER = 0x4,
|
||||
DOCHOSTUIFLAG_SCROLL_NO = 0x8,
|
||||
DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10,
|
||||
DOCHOSTUIFLAG_OPENNEWWIN = 0x20,
|
||||
DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40,
|
||||
DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80,
|
||||
DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100,
|
||||
DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200,
|
||||
DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400,
|
||||
DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800,
|
||||
DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000,
|
||||
DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000,
|
||||
DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000,
|
||||
DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000,
|
||||
DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000,
|
||||
DOCHOSTUIFLAG_THEME = 0x40000,
|
||||
DOCHOSTUIFLAG_NOTHEME = 0x80000,
|
||||
DOCHOSTUIFLAG_NOPICS = 0x100000,
|
||||
DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000,
|
||||
DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000,
|
||||
DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000,
|
||||
DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000
|
||||
} DOCHOSTUIFLAG;
|
||||
|
||||
typedef struct _tagwxDOCHOSTUIINFO
|
||||
{
|
||||
ULONG cbSize;
|
||||
DWORD dwFlags;
|
||||
DWORD dwDoubleClick;
|
||||
OLECHAR *pchHostCss;
|
||||
OLECHAR *pchHostNS;
|
||||
} DOCHOSTUIINFO;
|
||||
|
||||
class wxIDocHostUIHandler : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
|
||||
IUnknown *pcmdtReserved,
|
||||
IDispatch *pdispReserved) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
|
||||
IOleInPlaceActiveObject *pActiveObject,
|
||||
IOleCommandTarget *pCommandTarget,
|
||||
IOleInPlaceFrame *pFrame,
|
||||
IOleInPlaceUIWindow *pDoc) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL HideUI(void) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL UpdateUI(void) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
|
||||
IOleInPlaceUIWindow *pUIWindow,
|
||||
BOOL fRameWindow) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
|
||||
const GUID *pguidCmdGroup,
|
||||
DWORD nCmdID) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL GetOptionKeyPath(__out LPOLESTR *pchKey,
|
||||
DWORD dw) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
|
||||
IDropTarget **ppDropTarget) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
|
||||
__in __nullterminated OLECHAR *pchURLIn,
|
||||
__out OLECHAR **ppchURLOut) = 0;
|
||||
|
||||
virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
|
||||
IDataObject **ppDORet) = 0;
|
||||
};
|
||||
|
||||
/* END OF MSHTMHST.H implementation */
|
||||
|
||||
struct IHTMLDocument2;
|
||||
class wxFSFile;
|
||||
class ClassFactory;
|
||||
class wxIEContainer;
|
||||
class DocHostUIHandler;
|
||||
|
||||
class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
|
||||
{
|
||||
@ -262,10 +356,11 @@ public:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
private:
|
||||
wxActiveXContainer* m_container;
|
||||
wxIEContainer* m_container;
|
||||
wxAutomationObject m_ie;
|
||||
IWebBrowser2* m_webBrowser;
|
||||
DWORD m_dwCookie;
|
||||
DocHostUIHandler* m_uiHandler;
|
||||
|
||||
//We store the current zoom type;
|
||||
wxWebViewZoomType m_zoomType;
|
||||
@ -353,6 +448,69 @@ private:
|
||||
wxSharedPtr<wxWebViewHandler> m_handler;
|
||||
};
|
||||
|
||||
class wxIEContainer : public wxActiveXContainer
|
||||
{
|
||||
public:
|
||||
wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL);
|
||||
virtual ~wxIEContainer();
|
||||
virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc);
|
||||
private:
|
||||
DocHostUIHandler* m_uiHandler;
|
||||
};
|
||||
|
||||
class DocHostUIHandler : public wxIDocHostUIHandler
|
||||
{
|
||||
public:
|
||||
DocHostUIHandler() {};
|
||||
~DocHostUIHandler() {};
|
||||
virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
|
||||
IUnknown *pcmdtReserved,
|
||||
IDispatch *pdispReserved);
|
||||
|
||||
virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo);
|
||||
|
||||
virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
|
||||
IOleInPlaceActiveObject *pActiveObject,
|
||||
IOleCommandTarget *pCommandTarget,
|
||||
IOleInPlaceFrame *pFrame,
|
||||
IOleInPlaceUIWindow *pDoc);
|
||||
|
||||
virtual HRESULT wxSTDCALL HideUI(void);
|
||||
|
||||
virtual HRESULT wxSTDCALL UpdateUI(void);
|
||||
|
||||
virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable);
|
||||
|
||||
virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate);
|
||||
|
||||
virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate);
|
||||
|
||||
virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
|
||||
IOleInPlaceUIWindow *pUIWindow,
|
||||
BOOL fRameWindow);
|
||||
|
||||
virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
|
||||
const GUID *pguidCmdGroup,
|
||||
DWORD nCmdID);
|
||||
|
||||
virtual HRESULT wxSTDCALL GetOptionKeyPath(__out LPOLESTR *pchKey,
|
||||
DWORD dw);
|
||||
|
||||
virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
|
||||
IDropTarget **ppDropTarget);
|
||||
|
||||
virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch);
|
||||
|
||||
virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
|
||||
__in __nullterminated OLECHAR *pchURLIn,
|
||||
__out OLECHAR **ppchURLOut);
|
||||
|
||||
virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
|
||||
IDataObject **ppDORet);
|
||||
//IUnknown
|
||||
DECLARE_IUNKNOWN_METHODS;
|
||||
};
|
||||
|
||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
||||
|
||||
#endif // wxWebViewIE_H
|
||||
|
@ -37,6 +37,7 @@ namespace {
|
||||
|
||||
DEFINE_GUID(wxIID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
|
||||
DEFINE_GUID(wxIID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
|
||||
DEFINE_GUID(wxIID_IDocHostUIHandler, 0xbd3f23c0, 0xd43e, 0x11cf, 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a);
|
||||
|
||||
}
|
||||
|
||||
@ -81,7 +82,10 @@ bool wxWebViewIE::Create(wxWindow* parent,
|
||||
m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
|
||||
m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
|
||||
|
||||
m_container = new wxActiveXContainer(this, IID_IWebBrowser2, m_webBrowser);
|
||||
m_uiHandler = new DocHostUIHandler;
|
||||
m_uiHandler->AddRef();
|
||||
|
||||
m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
|
||||
|
||||
LoadURL(url);
|
||||
return true;
|
||||
@ -93,6 +97,8 @@ wxWebViewIE::~wxWebViewIE()
|
||||
{
|
||||
m_factories[i]->Release();
|
||||
}
|
||||
|
||||
m_uiHandler->Release();
|
||||
}
|
||||
|
||||
void wxWebViewIE::LoadURL(const wxString& url)
|
||||
@ -112,7 +118,7 @@ void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
|
||||
param->bstrVal = bstr;
|
||||
|
||||
hr = SafeArrayUnaccessData(psaStrings);
|
||||
|
||||
|
||||
IHTMLDocument2* document = GetDocument();
|
||||
document->write(psaStrings);
|
||||
document->close();
|
||||
@ -1155,4 +1161,169 @@ STDMETHODIMP ClassFactory::LockServer(BOOL fLock)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
wxIEContainer::wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk,
|
||||
DocHostUIHandler* uiHandler) :
|
||||
wxActiveXContainer(parent,iid,pUnk)
|
||||
{
|
||||
m_uiHandler = uiHandler;
|
||||
}
|
||||
|
||||
wxIEContainer::~wxIEContainer()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxIEContainer::QueryClientSiteInterface(REFIID iid, void **_interface,
|
||||
const char *&desc)
|
||||
{
|
||||
if (m_uiHandler && IsEqualIID(iid, wxIID_IDocHostUIHandler))
|
||||
{
|
||||
*_interface = (IUnknown *) (wxIDocHostUIHandler *) m_uiHandler;
|
||||
desc = "IDocHostUIHandler";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::ShowContextMenu(DWORD dwID, POINT *ppt,
|
||||
IUnknown *pcmdtReserved,
|
||||
IDispatch *pdispReserved)
|
||||
{
|
||||
wxUnusedVar(dwID);
|
||||
wxUnusedVar(ppt);
|
||||
wxUnusedVar(pcmdtReserved);
|
||||
wxUnusedVar(pdispReserved);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::GetHostInfo(DOCHOSTUIINFO *pInfo)
|
||||
{
|
||||
//don't show 3d border and ebales themes.
|
||||
pInfo->dwFlags = pInfo->dwFlags | DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::ShowUI(DWORD dwID,
|
||||
IOleInPlaceActiveObject *pActiveObject,
|
||||
IOleCommandTarget *pCommandTarget,
|
||||
IOleInPlaceFrame *pFrame,
|
||||
IOleInPlaceUIWindow *pDoc)
|
||||
{
|
||||
wxUnusedVar(dwID);
|
||||
wxUnusedVar(pActiveObject);
|
||||
wxUnusedVar(pCommandTarget);
|
||||
wxUnusedVar(pFrame);
|
||||
wxUnusedVar(pDoc);
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::HideUI(void)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::UpdateUI(void)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::EnableModeless(BOOL fEnable)
|
||||
{
|
||||
wxUnusedVar(fEnable);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
|
||||
{
|
||||
wxUnusedVar(fActivate);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
|
||||
{
|
||||
wxUnusedVar(fActivate);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::ResizeBorder(LPCRECT prcBorder,
|
||||
IOleInPlaceUIWindow *pUIWindow,
|
||||
BOOL fFrameWindow)
|
||||
{
|
||||
wxUnusedVar(prcBorder);
|
||||
wxUnusedVar(pUIWindow);
|
||||
wxUnusedVar(fFrameWindow);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::TranslateAccelerator(LPMSG lpMsg,
|
||||
const GUID *pguidCmdGroup,
|
||||
DWORD nCmdID)
|
||||
{
|
||||
if(lpMsg && lpMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
//control is down?
|
||||
if((GetKeyState(VK_CONTROL) & 0x8000 ))
|
||||
{
|
||||
//skip CTRL-N, CTRL-F and CTRL-P
|
||||
if(lpMsg->wParam == 'N' || lpMsg->wParam == 'P' || lpMsg->wParam == 'F')
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
//skip F5
|
||||
if(lpMsg->wParam == VK_F5)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
wxUnusedVar(pguidCmdGroup);
|
||||
wxUnusedVar(nCmdID);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::GetOptionKeyPath(LPOLESTR *pchKey,DWORD dw)
|
||||
{
|
||||
wxUnusedVar(pchKey);
|
||||
wxUnusedVar(dw);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::GetDropTarget(IDropTarget *pDropTarget,
|
||||
IDropTarget **ppDropTarget)
|
||||
{
|
||||
wxUnusedVar(pDropTarget);
|
||||
wxUnusedVar(ppDropTarget);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::GetExternal(IDispatch **ppDispatch)
|
||||
{
|
||||
wxUnusedVar(ppDispatch);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::TranslateUrl(DWORD dwTranslate,
|
||||
OLECHAR *pchURLIn,
|
||||
OLECHAR **ppchURLOut)
|
||||
{
|
||||
wxUnusedVar(dwTranslate);
|
||||
wxUnusedVar(pchURLIn);
|
||||
wxUnusedVar(ppchURLOut);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT DocHostUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
|
||||
{
|
||||
wxUnusedVar(pDO);
|
||||
wxUnusedVar(ppDORet);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
BEGIN_IID_TABLE(DocHostUIHandler)
|
||||
ADD_IID(Unknown)
|
||||
ADD_RAW_IID(wxIID_IDocHostUIHandler)
|
||||
END_IID_TABLE;
|
||||
|
||||
IMPLEMENT_IUNKNOWN_METHODS(DocHostUIHandler)
|
||||
|
||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
|
||||
|
Loading…
Reference in New Issue
Block a user