X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae26e17b93fd8c3dce7c66ce9f23475867160f62..9c34a216817028bc533e07873d047208a96b05a2:/include/wx/gtk/webview_webkit.h?ds=inline diff --git a/include/wx/gtk/webview_webkit.h b/include/wx/gtk/webview_webkit.h index 69fef706f8..24d30c89d9 100644 --- a/include/wx/gtk/webview_webkit.h +++ b/include/wx/gtk/webview_webkit.h @@ -10,52 +10,23 @@ #ifndef _WX_GTK_WEBKITCTRL_H_ #define _WX_GTK_WEBKITCTRL_H_ -#include "wx/setup.h" +#include "wx/defs.h" -#if wxUSE_WEBVIEW_WEBKIT +#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) -#include "webkit/webkit.h" #include "wx/sharedptr.h" #include "wx/webview.h" -//A set of hash function so we can map wxWebHistoryItems to WebKitWebHistoryItems -class SharedPtrHash -{ -public: - SharedPtrHash() { } - - unsigned long operator()( const wxSharedPtr & item ) const - { - - return wxPointerHash()(item.get()); - } - SharedPtrHash& operator=(const SharedPtrHash&) { return *this; } -}; - -class SharedPtrEqual -{ -public: - SharedPtrEqual() { } - bool operator()( const wxSharedPtr & a, - const wxSharedPtr & b ) const - { - return wxPointerEqual()(a.get(), b.get()); - } - - SharedPtrEqual& operator=(const SharedPtrEqual&) { return *this; } -}; - -WX_DECLARE_HASH_MAP(wxSharedPtr, WebKitWebHistoryItem*, - SharedPtrHash, SharedPtrEqual, HistoryItemHash); +typedef struct _WebKitWebView WebKitWebView; //----------------------------------------------------------------------------- // wxWebViewWebKit //----------------------------------------------------------------------------- -class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView +class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView { public: - wxWebViewWebKit() { Init(); } + wxWebViewWebKit(); wxWebViewWebKit(wxWindow *parent, wxWindowID id = wxID_ANY, @@ -64,8 +35,6 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxWebViewNameStr) { - Init(); - Create(parent, id, url, pos, size, style, name); } @@ -76,6 +45,8 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxWebViewNameStr); + virtual ~wxWebViewWebKit(); + virtual bool Enable( bool enable = true ); // implementation @@ -84,53 +55,68 @@ public: static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - // helper to allow access to protected member from GTK callback - void MoveWindow(int x, int y, int width, int height) - { - DoMoveWindow(x, y, width, height); - } - - void ZoomIn(); - void ZoomOut(); - void SetWebkitZoom(float level); - float GetWebkitZoom(); - virtual void Stop(); - virtual void LoadUrl(const wxString& url); + virtual void LoadURL(const wxString& url); virtual void GoBack(); virtual void GoForward(); - virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); - virtual bool CanGoBack(); - virtual bool CanGoForward(); + virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT); + virtual bool CanGoBack() const; + virtual bool CanGoForward() const; virtual void ClearHistory(); + virtual void EnableContextMenu(bool enable = true); virtual void EnableHistory(bool enable = true); - virtual wxVector > GetBackwardHistory(); - virtual wxVector > GetForwardHistory(); - virtual void LoadHistoryItem(wxSharedPtr item); - virtual wxString GetCurrentURL(); - virtual wxString GetCurrentTitle(); - virtual wxString GetPageSource(); - virtual void SetPage(const wxString& html, const wxString& baseUrl); + virtual wxVector > GetBackwardHistory(); + virtual wxVector > GetForwardHistory(); + virtual void LoadHistoryItem(wxSharedPtr item); + virtual wxString GetCurrentURL() const; + virtual wxString GetCurrentTitle() const; + virtual wxString GetPageSource() const; + virtual wxString GetPageText() const; virtual void Print(); - virtual bool IsBusy(); + virtual bool IsBusy() const; void SetZoomType(wxWebViewZoomType); wxWebViewZoomType GetZoomType() const; bool CanSetZoomType(wxWebViewZoomType) const; - virtual wxWebViewZoom GetZoom(); + virtual wxWebViewZoom GetZoom() const; virtual void SetZoom(wxWebViewZoom); //Clipboard functions - virtual bool CanCut(); - virtual bool CanCopy(); - virtual bool CanPaste(); + virtual bool CanCut() const; + virtual bool CanCopy() const; + virtual bool CanPaste() const; virtual void Cut(); virtual void Copy(); virtual void Paste(); - /** FIXME: hack to work around signals being received too early */ - bool m_ready; + //Undo / redo functionality + virtual bool CanUndo() const; + virtual bool CanRedo() const; + virtual void Undo(); + virtual void Redo(); + + //Find function + virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT); + + //Editing functions + virtual void SetEditable(bool enable = true); + virtual bool IsEditable() const; + + //Selection + virtual void DeleteSelection(); + virtual bool HasSelection() const; + virtual void SelectAll(); + virtual wxString GetSelectedText() const; + virtual wxString GetSelectedSource() const; + virtual void ClearSelection(); + + virtual void RunScript(const wxString& javascript); + //Virtual Filesystem Support + 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 @@ -140,23 +126,59 @@ public: */ bool m_busy; + wxString m_vfsurl; + + //We use this flag to stop recursion when we load a page from the navigation + //callback, mainly when loading a VFS page + bool m_guard; + protected: + virtual void DoSetPage(const wxString& html, const wxString& baseUrl); virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; private: + void ZoomIn(); + void ZoomOut(); + void SetWebkitZoom(float level); + float GetWebkitZoom() const; + + //Find helper function + void FindClear(); + // focus event handler: calls GTKUpdateBitmap() void GTKOnFocus(wxFocusEvent& event); - GtkWidget *web_view; - gint m_historyLimit; - HistoryItemHash m_historyMap; + WebKitWebView *m_web_view; + int m_historyLimit; + + wxVector > m_handlerList; + + //variables used for Find() + int m_findFlags; + wxString m_findText; + int m_findPosition; + int m_findCount; - // FIXME: try to get DECLARE_DYNAMIC_CLASS macros & stuff right - //DECLARE_DYNAMIC_CLASS(wxWebViewWebKit) + wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); }; -#endif // if wxHAVE_WEB_BACKEND_GTK_WEBKIT +class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory +{ +public: + virtual wxWebView* Create() { return new wxWebViewWebKit; } + 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) + { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); } +}; + + +#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) #endif