]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/webview_webkit.h
No real changes, just make wxWindow::CanScroll() virtual.
[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 // Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_GTK_WEBKITCTRL_H_
10 #define _WX_GTK_WEBKITCTRL_H_
11
12 #include "wx/defs.h"
13
14 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
15
16 #include "wx/sharedptr.h"
17 #include "wx/webview.h"
18
19 typedef struct _WebKitWebView WebKitWebView;
20
21 //-----------------------------------------------------------------------------
22 // wxWebViewWebKit
23 //-----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
26 {
27 public:
28 wxWebViewWebKit();
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 Create(parent, id, url, pos, size, style, name);
38 }
39
40 virtual bool Create(wxWindow *parent,
41 wxWindowID id = wxID_ANY,
42 const wxString& url = wxWebViewDefaultURLStr,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize, long style = 0,
45 const wxString& name = wxWebViewNameStr);
46
47 virtual ~wxWebViewWebKit();
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 virtual void Stop();
58 virtual void LoadURL(const wxString& url);
59 virtual void GoBack();
60 virtual void GoForward();
61 virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT);
62 virtual bool CanGoBack() const;
63 virtual bool CanGoForward() const;
64 virtual void ClearHistory();
65 virtual void EnableContextMenu(bool enable = true);
66 virtual void EnableHistory(bool enable = true);
67 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
68 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
69 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
70 virtual wxString GetCurrentURL() const;
71 virtual wxString GetCurrentTitle() const;
72 virtual wxString GetPageSource() const;
73 virtual wxString GetPageText() const;
74 virtual void Print();
75 virtual bool IsBusy() const;
76
77 void SetZoomType(wxWebViewZoomType);
78 wxWebViewZoomType GetZoomType() const;
79 bool CanSetZoomType(wxWebViewZoomType) const;
80 virtual wxWebViewZoom GetZoom() const;
81 virtual void SetZoom(wxWebViewZoom);
82
83 //Clipboard functions
84 virtual bool CanCut() const;
85 virtual bool CanCopy() const;
86 virtual bool CanPaste() const;
87 virtual void Cut();
88 virtual void Copy();
89 virtual void Paste();
90
91 //Undo / redo functionality
92 virtual bool CanUndo() const;
93 virtual bool CanRedo() const;
94 virtual void Undo();
95 virtual void Redo();
96
97 //Find function
98 virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT);
99
100 //Editing functions
101 virtual void SetEditable(bool enable = true);
102 virtual bool IsEditable() const;
103
104 //Selection
105 virtual void DeleteSelection();
106 virtual bool HasSelection() const;
107 virtual void SelectAll();
108 virtual wxString GetSelectedText() const;
109 virtual wxString GetSelectedSource() const;
110 virtual void ClearSelection();
111
112 virtual void RunScript(const wxString& javascript);
113
114 //Virtual Filesystem Support
115 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
116 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
117
118 virtual void* GetNativeBackend() const { return m_web_view; }
119
120 /** TODO: check if this can be made private
121 * The native control has a getter to check for busy state, but except in
122 * very recent versions of webkit this getter doesn't say everything we need
123 * (namely it seems to stay indefinitely busy when loading is cancelled by
124 * user)
125 */
126 bool m_busy;
127
128 wxString m_vfsurl;
129
130 //We use this flag to stop recursion when we load a page from the navigation
131 //callback, mainly when loading a VFS page
132 bool m_guard;
133
134 protected:
135 virtual void DoSetPage(const wxString& html, const wxString& baseUrl);
136
137 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
138
139 private:
140
141 void ZoomIn();
142 void ZoomOut();
143 void SetWebkitZoom(float level);
144 float GetWebkitZoom() const;
145
146 //Find helper function
147 void FindClear();
148
149 // focus event handler: calls GTKUpdateBitmap()
150 void GTKOnFocus(wxFocusEvent& event);
151
152 WebKitWebView *m_web_view;
153 int m_historyLimit;
154
155 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
156
157 //variables used for Find()
158 int m_findFlags;
159 wxString m_findText;
160 int m_findPosition;
161 int m_findCount;
162
163 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
164 };
165
166 class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
167 {
168 public:
169 virtual wxWebView* Create() { return new wxWebViewWebKit; }
170 virtual wxWebView* Create(wxWindow* parent,
171 wxWindowID id,
172 const wxString& url = wxWebViewDefaultURLStr,
173 const wxPoint& pos = wxDefaultPosition,
174 const wxSize& size = wxDefaultSize,
175 long style = 0,
176 const wxString& name = wxWebViewNameStr)
177 { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
178 };
179
180
181 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
182
183 #endif