]>
Commit | Line | Data |
---|---|---|
61b98a2d SL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: include/gtk/wx/webview.h | |
3 | // Purpose: GTK webkit backend for web view component | |
4 | // Author: Robert Roebling, Marianne Gagnon | |
61b98a2d SL |
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 | ||
8ab75332 | 12 | #include "wx/defs.h" |
61b98a2d | 13 | |
9d2f31db | 14 | #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) |
61b98a2d | 15 | |
19fc1a2f | 16 | #include "wx/sharedptr.h" |
61b98a2d SL |
17 | #include "wx/webview.h" |
18 | ||
4c9bde5e PC |
19 | typedef struct _WebKitWebView WebKitWebView; |
20 | ||
61b98a2d | 21 | //----------------------------------------------------------------------------- |
b64b4e70 | 22 | // wxWebViewWebKit |
61b98a2d SL |
23 | //----------------------------------------------------------------------------- |
24 | ||
467d261e | 25 | class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView |
61b98a2d SL |
26 | { |
27 | public: | |
8ab75332 | 28 | wxWebViewWebKit(); |
61b98a2d | 29 | |
b64b4e70 | 30 | wxWebViewWebKit(wxWindow *parent, |
61b98a2d SL |
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 | { | |
61b98a2d SL |
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 | ||
c3980646 VZ |
47 | virtual ~wxWebViewWebKit(); |
48 | ||
61b98a2d SL |
49 | virtual bool Enable( bool enable = true ); |
50 | ||
51 | // implementation | |
52 | // -------------- | |
53 | ||
54 | static wxVisualAttributes | |
55 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
56 | ||
61b98a2d | 57 | virtual void Stop(); |
4d0dddc7 | 58 | virtual void LoadURL(const wxString& url); |
61b98a2d SL |
59 | virtual void GoBack(); |
60 | virtual void GoForward(); | |
236cff73 | 61 | virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT); |
e669ddde SL |
62 | virtual bool CanGoBack() const; |
63 | virtual bool CanGoForward() const; | |
152a5808 | 64 | virtual void ClearHistory(); |
c420d57b | 65 | virtual void EnableContextMenu(bool enable = true); |
152a5808 | 66 | virtual void EnableHistory(bool enable = true); |
c13d6ac1 SL |
67 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory(); |
68 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory(); | |
69 | virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item); | |
e669ddde SL |
70 | virtual wxString GetCurrentURL() const; |
71 | virtual wxString GetCurrentTitle() const; | |
72 | virtual wxString GetPageSource() const; | |
73 | virtual wxString GetPageText() const; | |
61b98a2d | 74 | virtual void Print(); |
e669ddde | 75 | virtual bool IsBusy() const; |
61b98a2d SL |
76 | |
77 | void SetZoomType(wxWebViewZoomType); | |
78 | wxWebViewZoomType GetZoomType() const; | |
79 | bool CanSetZoomType(wxWebViewZoomType) const; | |
e669ddde | 80 | virtual wxWebViewZoom GetZoom() const; |
61b98a2d SL |
81 | virtual void SetZoom(wxWebViewZoom); |
82 | ||
ae26e17b | 83 | //Clipboard functions |
e669ddde SL |
84 | virtual bool CanCut() const; |
85 | virtual bool CanCopy() const; | |
86 | virtual bool CanPaste() const; | |
ae26e17b SL |
87 | virtual void Cut(); |
88 | virtual void Copy(); | |
89 | virtual void Paste(); | |
61b98a2d | 90 | |
97e49559 | 91 | //Undo / redo functionality |
e669ddde SL |
92 | virtual bool CanUndo() const; |
93 | virtual bool CanRedo() const; | |
97e49559 SL |
94 | virtual void Undo(); |
95 | virtual void Redo(); | |
96 | ||
66ac0400 | 97 | //Find function |
236cff73 | 98 | virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT); |
66ac0400 | 99 | |
c7cbe308 SL |
100 | //Editing functions |
101 | virtual void SetEditable(bool enable = true); | |
e669ddde | 102 | virtual bool IsEditable() const; |
c7cbe308 | 103 | |
63a65070 SL |
104 | //Selection |
105 | virtual void DeleteSelection(); | |
e669ddde | 106 | virtual bool HasSelection() const; |
63a65070 | 107 | virtual void SelectAll(); |
e669ddde SL |
108 | virtual wxString GetSelectedText() const; |
109 | virtual wxString GetSelectedSource() const; | |
41933aa5 | 110 | virtual void ClearSelection(); |
63a65070 | 111 | |
c9ccc09c | 112 | virtual void RunScript(const wxString& javascript); |
34326da7 | 113 | |
eff8f795 | 114 | //Virtual Filesystem Support |
7d8d6163 SL |
115 | virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler); |
116 | virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; } | |
c9ccc09c | 117 | |
b6a49c2b VZ |
118 | virtual void* GetNativeBackend() const { return m_web_view; } |
119 | ||
61b98a2d SL |
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; | |
3baf235f | 127 | |
211da8a5 | 128 | wxString m_vfsurl; |
61b98a2d | 129 | |
36b52591 SL |
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; | |
fe7cefd4 SL |
133 | //This flag is use to indicate when a navigation event is the result of a |
134 | //create-web-view signal and so we need to send a new window event | |
135 | bool m_creating; | |
36b52591 | 136 | |
61b98a2d | 137 | protected: |
a977376a | 138 | virtual void DoSetPage(const wxString& html, const wxString& baseUrl); |
61b98a2d SL |
139 | |
140 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; | |
141 | ||
142 | private: | |
143 | ||
fba4c7c9 SL |
144 | void ZoomIn(); |
145 | void ZoomOut(); | |
146 | void SetWebkitZoom(float level); | |
147 | float GetWebkitZoom() const; | |
148 | ||
66ac0400 SL |
149 | //Find helper function |
150 | void FindClear(); | |
151 | ||
61b98a2d SL |
152 | // focus event handler: calls GTKUpdateBitmap() |
153 | void GTKOnFocus(wxFocusEvent& event); | |
154 | ||
4c9bde5e | 155 | WebKitWebView *m_web_view; |
a0ff3611 | 156 | int m_historyLimit; |
61b98a2d | 157 | |
7d8d6163 | 158 | wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList; |
f2049b68 | 159 | |
66ac0400 SL |
160 | //variables used for Find() |
161 | int m_findFlags; | |
162 | wxString m_findText; | |
163 | int m_findPosition; | |
164 | int m_findCount; | |
165 | ||
cddf4541 | 166 | wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); |
61b98a2d SL |
167 | }; |
168 | ||
4c687fff SL |
169 | class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory |
170 | { | |
171 | public: | |
172 | virtual wxWebView* Create() { return new wxWebViewWebKit; } | |
173 | virtual wxWebView* Create(wxWindow* parent, | |
174 | wxWindowID id, | |
175 | const wxString& url = wxWebViewDefaultURLStr, | |
176 | const wxPoint& pos = wxDefaultPosition, | |
177 | const wxSize& size = wxDefaultSize, | |
178 | long style = 0, | |
179 | const wxString& name = wxWebViewNameStr) | |
180 | { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); } | |
181 | }; | |
182 | ||
183 | ||
9d2f31db | 184 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) |
61b98a2d | 185 | |
384b8d9f | 186 | #endif |