Rename LoadUrl to LoadURL. This corrects the capitalisation as it is an acronym,...
[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 virtual void Stop();
64 virtual void LoadURL(const wxString& url);
65 virtual void GoBack();
66 virtual void GoForward();
67 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
68 virtual bool CanGoBack() const;
69 virtual bool CanGoForward() const;
70 virtual void ClearHistory();
71 virtual void EnableHistory(bool enable = true);
72 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
73 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
74 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
75 virtual wxString GetCurrentURL() const;
76 virtual wxString GetCurrentTitle() const;
77 virtual wxString GetPageSource() const;
78 virtual wxString GetPageText() const;
79 //We do not want to hide the other overloads
80 using wxWebView::SetPage;
81 virtual void SetPage(const wxString& html, const wxString& baseUrl);
82 virtual void Print();
83 virtual bool IsBusy() const;
84
85 void SetZoomType(wxWebViewZoomType);
86 wxWebViewZoomType GetZoomType() const;
87 bool CanSetZoomType(wxWebViewZoomType) const;
88 virtual wxWebViewZoom GetZoom() const;
89 virtual void SetZoom(wxWebViewZoom);
90
91 //Clipboard functions
92 virtual bool CanCut() const;
93 virtual bool CanCopy() const;
94 virtual bool CanPaste() const;
95 virtual void Cut();
96 virtual void Copy();
97 virtual void Paste();
98
99 //Undo / redo functionality
100 virtual bool CanUndo() const;
101 virtual bool CanRedo() const;
102 virtual void Undo();
103 virtual void Redo();
104
105 //Editing functions
106 virtual void SetEditable(bool enable = true);
107 virtual bool IsEditable() const;
108
109 //Selection
110 virtual void DeleteSelection();
111 virtual bool HasSelection() const;
112 virtual void SelectAll();
113 virtual wxString GetSelectedText() const;
114 virtual wxString GetSelectedSource() const;
115 virtual void ClearSelection();
116
117 virtual void RunScript(const wxString& javascript);
118
119 //Virtual Filesystem Support
120 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
121 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
122
123 /** FIXME: hack to work around signals being received too early */
124 bool m_ready;
125
126
127 /** TODO: check if this can be made private
128 * The native control has a getter to check for busy state, but except in
129 * very recent versions of webkit this getter doesn't say everything we need
130 * (namely it seems to stay indefinitely busy when loading is cancelled by
131 * user)
132 */
133 bool m_busy;
134
135 wxString m_vfsurl;
136
137 //We use this flag to stop recursion when we load a page from the navigation
138 //callback, mainly when loading a VFS page
139 bool m_guard;
140
141 protected:
142
143 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
144
145 private:
146
147 void ZoomIn();
148 void ZoomOut();
149 void SetWebkitZoom(float level);
150 float GetWebkitZoom() const;
151
152 // focus event handler: calls GTKUpdateBitmap()
153 void GTKOnFocus(wxFocusEvent& event);
154
155 GtkWidget *web_view;
156 gint m_historyLimit;
157
158 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
159
160 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
161 };
162
163 #endif // wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
164
165 #endif