X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a977376af3ab98aeac4ed638f2e9adc495494007..f35f5a7a1ac547ced9881ffea30dcb42178d3272:/include/wx/webview.h diff --git a/include/wx/webview.h b/include/wx/webview.h index 4173f2e2f9..2ff23c6a76 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -32,6 +32,7 @@ class wxFSFile; class wxFileSystem; +class wxWebView; enum wxWebViewZoom { @@ -68,11 +69,14 @@ enum wxWebViewReloadFlags wxWEB_VIEW_RELOAD_NO_CACHE }; -enum wxWebViewBackend +enum wxWebViewFindFlags { - wxWEB_VIEW_BACKEND_DEFAULT, - wxWEB_VIEW_BACKEND_WEBKIT, - wxWEB_VIEW_BACKEND_IE + wxWEB_VIEW_FIND_WRAP = 0x0001, + wxWEB_VIEW_FIND_ENTIRE_WORD = 0x0002, + wxWEB_VIEW_FIND_MATCH_CASE = 0x0004, + wxWEB_VIEW_FIND_HIGHLIGHT_RESULT = 0x0008, + wxWEB_VIEW_FIND_BACKWARDS = 0x0010, + wxWEB_VIEW_FIND_DEFAULT = 0 }; //Base class for custom scheme handlers @@ -89,10 +93,33 @@ private: extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[]; extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr[]; +extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[]; +extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE[]; +extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[]; + +class WXDLLIMPEXP_WEBVIEW wxWebViewFactory : public wxObject +{ +public: + virtual wxWebView* Create() = 0; + virtual wxWebView* Create(wxWindow* parent, + wxWindowID id, + const wxString& url = wxWebViewDefaultURLStr, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxWebViewNameStr) = 0; +}; + +WX_DECLARE_STRING_HASH_MAP(wxSharedPtr, wxStringWebViewFactoryMap); class WXDLLIMPEXP_WEBVIEW wxWebView : public wxControl { public: + wxWebView() + { + m_showMenu = true; + } + virtual ~wxWebView() {} virtual bool Create(wxWindow* parent, @@ -103,23 +130,33 @@ public: long style = 0, const wxString& name = wxWebViewNameStr) = 0; - static wxWebView* New(wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT); + // Factory methods allowing the use of custom factories registered with + // RegisterFactory + static wxWebView* New(const wxString& backend = wxWebViewBackendDefault); static wxWebView* New(wxWindow* parent, - wxWindowID id, - const wxString& url = wxWebViewDefaultURLStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT, - long style = 0, - const wxString& name = wxWebViewNameStr); - - //General methods + wxWindowID id, + const wxString& url = wxWebViewDefaultURLStr, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const wxString& backend = wxWebViewBackendDefault, + long style = 0, + const wxString& name = wxWebViewNameStr); + + static void RegisterFactory(const wxString& backend, + wxSharedPtr factory); + + // General methods + virtual void EnableContextMenu(bool enable = true) + { + m_showMenu = enable; + } virtual wxString GetCurrentTitle() const = 0; virtual wxString GetCurrentURL() const = 0; // TODO: handle choosing a frame when calling GetPageSource()? virtual wxString GetPageSource() const = 0; virtual wxString GetPageText() const = 0; virtual bool IsBusy() const = 0; + virtual bool IsContextMenuEnabled() const { return m_showMenu; } virtual bool IsEditable() const = 0; virtual void LoadURL(const wxString& url) = 0; virtual void Print() = 0; @@ -179,9 +216,21 @@ public: virtual void Undo() = 0; virtual void Redo() = 0; + //Get the pointer to the underlying native engine. + virtual void* GetNativeBackend() const = 0; + //Find function + virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT) = 0; + protected: virtual void DoSetPage(const wxString& html, const wxString& baseUrl) = 0; +private: + static void InitFactoryMap(); + static wxStringWebViewFactoryMap::iterator FindFactory(const wxString &backend); + + bool m_showMenu; + static wxStringWebViewFactoryMap m_factoryMap; + wxDECLARE_ABSTRACT_CLASS(wxWebView); };