]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/webview_webkit.h
9d3c500c0a94993249b4934cf31365d745527237
[wxWidgets.git] / include / wx / gtk / webview_webkit.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/gtk/wx/webview.h
3 // Purpose: GTK webkit backend for web view component
4 // Author: Robert Roebling, Marianne Gagnon
5 // Id: $Id$
6 // Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_WEBKITCTRL_H_
11 #define _WX_GTK_WEBKITCTRL_H_
12
13 #include "wx/setup.h"
14
15 #if wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
16
17 #include "webkit/webkit.h"
18 #include "wx/sharedptr.h"
19 #include "wx/webview.h"
20
21 //-----------------------------------------------------------------------------
22 // wxWebViewWebKit
23 //-----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView
26 {
27 public:
28 wxWebViewWebKit() { Init(); }
29
30 wxWebViewWebKit(wxWindow *parent,
31 wxWindowID id = wxID_ANY,
32 const wxString& url = wxWebViewDefaultURLStr,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize, long style = 0,
35 const wxString& name = wxWebViewNameStr)
36 {
37 Init();
38
39 Create(parent, id, url, pos, size, style, name);
40 }
41
42 virtual bool Create(wxWindow *parent,
43 wxWindowID id = wxID_ANY,
44 const wxString& url = wxWebViewDefaultURLStr,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize, long style = 0,
47 const wxString& name = wxWebViewNameStr);
48
49 virtual bool Enable( bool enable = true );
50
51 // implementation
52 // --------------
53
54 static wxVisualAttributes
55 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
56
57 // helper to allow access to protected member from GTK callback
58 void MoveWindow(int x, int y, int width, int height)
59 {
60 DoMoveWindow(x, y, width, height);
61 }
62
63 void ZoomIn();
64 void ZoomOut();
65 void SetWebkitZoom(float level);
66 float GetWebkitZoom();
67
68 virtual void Stop();
69 virtual void LoadUrl(const wxString& url);
70 virtual void GoBack();
71 virtual void GoForward();
72 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
73 virtual bool CanGoBack();
74 virtual bool CanGoForward();
75 virtual void ClearHistory();
76 virtual void EnableHistory(bool enable = true);
77 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory();
78 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory();
79 virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
80 virtual wxString GetCurrentURL();
81 virtual wxString GetCurrentTitle();
82 virtual wxString GetPageSource();
83 virtual wxString GetPageText();
84 //We do not want to hide the other overloads
85 using wxWebView::SetPage;
86 virtual void SetPage(const wxString& html, const wxString& baseUrl);
87 virtual void Print();
88 virtual bool IsBusy();
89
90 void SetZoomType(wxWebViewZoomType);
91 wxWebViewZoomType GetZoomType() const;
92 bool CanSetZoomType(wxWebViewZoomType) const;
93 virtual wxWebViewZoom GetZoom();
94 virtual void SetZoom(wxWebViewZoom);
95
96 //Clipboard functions
97 virtual bool CanCut();
98 virtual bool CanCopy();
99 virtual bool CanPaste();
100 virtual void Cut();
101 virtual void Copy();
102 virtual void Paste();
103
104 //Undo / redo functionality
105 virtual bool CanUndo();
106 virtual bool CanRedo();
107 virtual void Undo();
108 virtual void Redo();
109
110 //Editing functions
111 virtual void SetEditable(bool enable = true);
112 virtual bool IsEditable();
113
114 //Selection
115 virtual void DeleteSelection();
116 virtual bool HasSelection();
117 virtual void SelectAll();
118 virtual wxString GetSelectedText();
119 virtual wxString GetSelectedSource();
120 virtual void ClearSelection();
121
122 virtual void RunScript(const wxString& javascript);
123
124 //Virtual Filesystem Support
125 virtual void RegisterHandler(wxWebHandler* handler);
126 virtual wxVector<wxWebHandler*> GetHandlers() { return m_handlerList; }
127
128 /** FIXME: hack to work around signals being received too early */
129 bool m_ready;
130
131
132 /** TODO: check if this can be made private
133 * The native control has a getter to check for busy state, but except in
134 * very recent versions of webkit this getter doesn't say everything we need
135 * (namely it seems to stay indefinitely busy when loading is cancelled by
136 * user)
137 */
138 bool m_busy;
139
140 bool m_guard;
141 wxString m_vfsurl;
142
143 //We use this flag to stop recursion when we load a page from the navigation
144 //callback, mainly when loading a VFS page
145 bool m_guard;
146
147 protected:
148
149 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
150
151 private:
152
153 // focus event handler: calls GTKUpdateBitmap()
154 void GTKOnFocus(wxFocusEvent& event);
155
156 GtkWidget *web_view;
157 gint m_historyLimit;
158
159 wxVector<wxWebHandler*> m_handlerList;
160
161 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
162 };
163
164 #endif // wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
165
166 #endif