1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/gtk/wx/webview.h
3 // Purpose: GTK webkit backend for web view component
4 // Author: Robert Roebling, Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_WEBKITCTRL_H_
11 #define _WX_GTK_WEBKITCTRL_H_
15 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
17 #include "wx/sharedptr.h"
18 #include "wx/webview.h"
20 typedef struct _WebKitWebView WebKitWebView
;
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit
: public wxWebView
31 wxWebViewWebKit(wxWindow
*parent
,
32 wxWindowID id
= wxID_ANY
,
33 const wxString
& url
= wxWebViewDefaultURLStr
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
, long style
= 0,
36 const wxString
& name
= wxWebViewNameStr
)
38 Create(parent
, id
, url
, pos
, size
, style
, name
);
41 virtual bool Create(wxWindow
*parent
,
42 wxWindowID id
= wxID_ANY
,
43 const wxString
& url
= wxWebViewDefaultURLStr
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
, long style
= 0,
46 const wxString
& name
= wxWebViewNameStr
);
48 virtual ~wxWebViewWebKit();
50 virtual bool Enable( bool enable
= true );
55 static wxVisualAttributes
56 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
59 virtual void LoadURL(const wxString
& url
);
60 virtual void GoBack();
61 virtual void GoForward();
62 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
63 virtual bool CanGoBack() const;
64 virtual bool CanGoForward() const;
65 virtual void ClearHistory();
66 virtual void EnableContextMenu(bool enable
= true);
67 virtual void EnableHistory(bool enable
= true);
68 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetBackwardHistory();
69 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetForwardHistory();
70 virtual void LoadHistoryItem(wxSharedPtr
<wxWebViewHistoryItem
> item
);
71 virtual wxString
GetCurrentURL() const;
72 virtual wxString
GetCurrentTitle() const;
73 virtual wxString
GetPageSource() const;
74 virtual wxString
GetPageText() const;
76 virtual bool IsBusy() const;
78 void SetZoomType(wxWebViewZoomType
);
79 wxWebViewZoomType
GetZoomType() const;
80 bool CanSetZoomType(wxWebViewZoomType
) const;
81 virtual wxWebViewZoom
GetZoom() const;
82 virtual void SetZoom(wxWebViewZoom
);
85 virtual bool CanCut() const;
86 virtual bool CanCopy() const;
87 virtual bool CanPaste() const;
92 //Undo / redo functionality
93 virtual bool CanUndo() const;
94 virtual bool CanRedo() const;
99 virtual long Find(const wxString
& text
, int flags
= wxWEB_VIEW_FIND_DEFAULT
);
102 virtual void SetEditable(bool enable
= true);
103 virtual bool IsEditable() const;
106 virtual void DeleteSelection();
107 virtual bool HasSelection() const;
108 virtual void SelectAll();
109 virtual wxString
GetSelectedText() const;
110 virtual wxString
GetSelectedSource() const;
111 virtual void ClearSelection();
113 virtual void RunScript(const wxString
& javascript
);
115 //Virtual Filesystem Support
116 virtual void RegisterHandler(wxSharedPtr
<wxWebViewHandler
> handler
);
117 virtual wxVector
<wxSharedPtr
<wxWebViewHandler
> > GetHandlers() { return m_handlerList
; }
119 virtual void* GetNativeBackend() const { return m_web_view
; }
121 /** TODO: check if this can be made private
122 * The native control has a getter to check for busy state, but except in
123 * very recent versions of webkit this getter doesn't say everything we need
124 * (namely it seems to stay indefinitely busy when loading is cancelled by
131 //We use this flag to stop recursion when we load a page from the navigation
132 //callback, mainly when loading a VFS page
136 virtual void DoSetPage(const wxString
& html
, const wxString
& baseUrl
);
138 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
144 void SetWebkitZoom(float level
);
145 float GetWebkitZoom() const;
147 //Find helper function
150 // focus event handler: calls GTKUpdateBitmap()
151 void GTKOnFocus(wxFocusEvent
& event
);
153 WebKitWebView
*m_web_view
;
156 wxVector
<wxSharedPtr
<wxWebViewHandler
> > m_handlerList
;
158 //variables used for Find()
164 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
167 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)