From b6a49c2b759e24ff997e577ad491f18a44cccc00 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 24 Jul 2012 21:59:21 +0000 Subject: [PATCH] Add wxWebView::GetNativeBackend() method. This allows to use platform-specific methods in user code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/webview_webkit.h | 2 ++ include/wx/msw/webview_ie.h | 2 ++ include/wx/osx/webview_webkit.h | 2 ++ include/wx/webview.h | 3 +++ interface/wx/webview.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+) diff --git a/include/wx/gtk/webview_webkit.h b/include/wx/gtk/webview_webkit.h index a4e89fc313..d130b827e3 100644 --- a/include/wx/gtk/webview_webkit.h +++ b/include/wx/gtk/webview_webkit.h @@ -114,6 +114,8 @@ public: virtual void RegisterHandler(wxSharedPtr handler); virtual wxVector > GetHandlers() { return m_handlerList; } + virtual void* GetNativeBackend() const { return m_web_view; } + /** TODO: check if this can be made private * The native control has a getter to check for busy state, but except in * very recent versions of webkit this getter doesn't say everything we need diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index ccc1acce4c..99b41af174 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -337,6 +337,8 @@ public: //Virtual Filesystem Support virtual void RegisterHandler(wxSharedPtr handler); + virtual void* GetNativeBackend() const { return m_webBrowser; } + // ---- IE-specific methods // FIXME: I seem to be able to access remote webpages even in offline mode... diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index 281530f53a..193057fcdf 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -111,6 +111,8 @@ public: //Virtual Filesystem Support virtual void RegisterHandler(wxSharedPtr handler); + virtual void* GetNativeBackend() const { return m_webView; } + // ---- methods not from the parent (common) interface bool CanGetPageSource() const; diff --git a/include/wx/webview.h b/include/wx/webview.h index 4173f2e2f9..72f9f180de 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -179,6 +179,9 @@ public: virtual void Undo() = 0; virtual void Redo() = 0; + //Get the pointer to the underlying native engine. + virtual void* GetNativeBackend() const = 0; + protected: virtual void DoSetPage(const wxString& html, const wxString& baseUrl) = 0; diff --git a/interface/wx/webview.h b/interface/wx/webview.h index 20e914e3a5..e7a75785f7 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -304,6 +304,34 @@ public: */ virtual wxString GetCurrentURL() const = 0; + /** + Return the pointer to the native backend used by this control. + + This method can be used to retrieve the pointer to the native rendering + engine used by this control. The return value needs to be down-casted + to the appropriate type depending on the platform: under Windows, it's + a pointer to IWebBrowser2 interface, under OS X it's a WebView pointer + and under GTK it's a WebKitWebView. + + For example, you could set the WebKit options using this method: + @code + #include + + #ifdef __WXGTK__ + WebKitWebView* + wv = static_cast(m_window->GetNativeBackend()); + + WebKitWebSettings* settings = webkit_web_view_get_settings(wv); + g_object_set(G_OBJECT(settings), + "enable-frame-flattening", TRUE, + NULL); + #endif + @endcode + + @since 2.9.5 + */ + virtual void* GetNativeBackend() const = 0; + /** Get the HTML source code of the currently displayed document. @return The HTML source code, or an empty string if no page is currently -- 2.45.2