]>
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 | |
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 | ||
b64b4e70 | 15 | #if wxUSE_WEBVIEW_WEBKIT |
61b98a2d | 16 | |
19fc1a2f SL |
17 | #include "webkit/webkit.h" |
18 | #include "wx/sharedptr.h" | |
61b98a2d SL |
19 | #include "wx/webview.h" |
20 | ||
19fc1a2f SL |
21 | //A set of hash function so we can map wxWebHistoryItems to WebKitWebHistoryItems |
22 | class SharedPtrHash | |
23 | { | |
24 | public: | |
25 | SharedPtrHash() { } | |
26 | ||
27 | unsigned long operator()( const wxSharedPtr<wxWebHistoryItem> & item ) const | |
28 | { | |
29 | ||
30 | return wxPointerHash()(item.get()); | |
31 | } | |
32 | SharedPtrHash& operator=(const SharedPtrHash&) { return *this; } | |
33 | }; | |
34 | ||
35 | class SharedPtrEqual | |
36 | { | |
37 | public: | |
38 | SharedPtrEqual() { } | |
39 | bool operator()( const wxSharedPtr<wxWebHistoryItem> & a, | |
40 | const wxSharedPtr<wxWebHistoryItem> & b ) const | |
41 | { | |
42 | return wxPointerEqual()(a.get(), b.get()); | |
43 | } | |
44 | ||
45 | SharedPtrEqual& operator=(const SharedPtrEqual&) { return *this; } | |
46 | }; | |
47 | ||
48 | WX_DECLARE_HASH_MAP(wxSharedPtr<wxWebHistoryItem>, WebKitWebHistoryItem*, | |
49 | SharedPtrHash, SharedPtrEqual, HistoryItemHash); | |
50 | ||
61b98a2d | 51 | //----------------------------------------------------------------------------- |
b64b4e70 | 52 | // wxWebViewWebKit |
61b98a2d SL |
53 | //----------------------------------------------------------------------------- |
54 | ||
b64b4e70 | 55 | class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView |
61b98a2d SL |
56 | { |
57 | public: | |
b64b4e70 | 58 | wxWebViewWebKit() { Init(); } |
61b98a2d | 59 | |
b64b4e70 | 60 | wxWebViewWebKit(wxWindow *parent, |
61b98a2d SL |
61 | wxWindowID id = wxID_ANY, |
62 | const wxString& url = wxWebViewDefaultURLStr, | |
63 | const wxPoint& pos = wxDefaultPosition, | |
64 | const wxSize& size = wxDefaultSize, long style = 0, | |
65 | const wxString& name = wxWebViewNameStr) | |
66 | { | |
67 | Init(); | |
68 | ||
69 | Create(parent, id, url, pos, size, style, name); | |
70 | } | |
71 | ||
72 | virtual bool Create(wxWindow *parent, | |
73 | wxWindowID id = wxID_ANY, | |
74 | const wxString& url = wxWebViewDefaultURLStr, | |
75 | const wxPoint& pos = wxDefaultPosition, | |
76 | const wxSize& size = wxDefaultSize, long style = 0, | |
77 | const wxString& name = wxWebViewNameStr); | |
78 | ||
79 | virtual bool Enable( bool enable = true ); | |
80 | ||
81 | // implementation | |
82 | // -------------- | |
83 | ||
84 | static wxVisualAttributes | |
85 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
86 | ||
87 | // helper to allow access to protected member from GTK callback | |
88 | void MoveWindow(int x, int y, int width, int height) | |
89 | { | |
90 | DoMoveWindow(x, y, width, height); | |
91 | } | |
92 | ||
93 | void ZoomIn(); | |
94 | void ZoomOut(); | |
95 | void SetWebkitZoom(float level); | |
96 | float GetWebkitZoom(); | |
97 | ||
98 | virtual void Stop(); | |
99 | virtual void LoadUrl(const wxString& url); | |
100 | virtual void GoBack(); | |
101 | virtual void GoForward(); | |
a703012a | 102 | virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); |
61b98a2d SL |
103 | virtual bool CanGoBack(); |
104 | virtual bool CanGoForward(); | |
152a5808 SL |
105 | virtual void ClearHistory(); |
106 | virtual void EnableHistory(bool enable = true); | |
19fc1a2f SL |
107 | virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory(); |
108 | virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory(); | |
109 | virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item); | |
61b98a2d SL |
110 | virtual wxString GetCurrentURL(); |
111 | virtual wxString GetCurrentTitle(); | |
112 | virtual wxString GetPageSource(); | |
3dffc2ae SL |
113 | //We do not want to hide the other overloads |
114 | using wxWebView::SetPage; | |
61b98a2d SL |
115 | virtual void SetPage(const wxString& html, const wxString& baseUrl); |
116 | virtual void Print(); | |
117 | virtual bool IsBusy(); | |
118 | ||
119 | void SetZoomType(wxWebViewZoomType); | |
120 | wxWebViewZoomType GetZoomType() const; | |
121 | bool CanSetZoomType(wxWebViewZoomType) const; | |
122 | virtual wxWebViewZoom GetZoom(); | |
123 | virtual void SetZoom(wxWebViewZoom); | |
124 | ||
ae26e17b SL |
125 | //Clipboard functions |
126 | virtual bool CanCut(); | |
127 | virtual bool CanCopy(); | |
128 | virtual bool CanPaste(); | |
129 | virtual void Cut(); | |
130 | virtual void Copy(); | |
131 | virtual void Paste(); | |
61b98a2d | 132 | |
97e49559 SL |
133 | //Undo / redo functionality |
134 | virtual bool CanUndo(); | |
135 | virtual bool CanRedo(); | |
136 | virtual void Undo(); | |
137 | virtual void Redo(); | |
138 | ||
c7cbe308 SL |
139 | //Editing functions |
140 | virtual void SetEditable(bool enable = true); | |
141 | virtual bool IsEditable(); | |
142 | ||
63a65070 SL |
143 | //Selection |
144 | virtual void DeleteSelection(); | |
145 | virtual bool HasSelection(); | |
146 | virtual void SelectAll(); | |
c9355a3d | 147 | virtual wxString GetSelectedText(); |
0fe8a1b6 | 148 | virtual wxString GetSelectedHTML(); |
63a65070 | 149 | |
61b98a2d SL |
150 | /** FIXME: hack to work around signals being received too early */ |
151 | bool m_ready; | |
152 | ||
153 | ||
154 | /** TODO: check if this can be made private | |
155 | * The native control has a getter to check for busy state, but except in | |
156 | * very recent versions of webkit this getter doesn't say everything we need | |
157 | * (namely it seems to stay indefinitely busy when loading is cancelled by | |
158 | * user) | |
159 | */ | |
160 | bool m_busy; | |
161 | ||
162 | protected: | |
163 | ||
164 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; | |
165 | ||
166 | private: | |
167 | ||
168 | // focus event handler: calls GTKUpdateBitmap() | |
169 | void GTKOnFocus(wxFocusEvent& event); | |
170 | ||
171 | GtkWidget *web_view; | |
152a5808 | 172 | gint m_historyLimit; |
19fc1a2f | 173 | HistoryItemHash m_historyMap; |
61b98a2d SL |
174 | |
175 | // FIXME: try to get DECLARE_DYNAMIC_CLASS macros & stuff right | |
b64b4e70 | 176 | //DECLARE_DYNAMIC_CLASS(wxWebViewWebKit) |
61b98a2d SL |
177 | }; |
178 | ||
179 | #endif // if wxHAVE_WEB_BACKEND_GTK_WEBKIT | |
180 | ||
384b8d9f | 181 | #endif |