]>
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 | ||
9d2f31db | 15 | #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) |
61b98a2d | 16 | |
19fc1a2f | 17 | #include "wx/sharedptr.h" |
61b98a2d SL |
18 | #include "wx/webview.h" |
19 | ||
20 | //----------------------------------------------------------------------------- | |
b64b4e70 | 21 | // wxWebViewWebKit |
61b98a2d SL |
22 | //----------------------------------------------------------------------------- |
23 | ||
467d261e | 24 | class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView |
61b98a2d SL |
25 | { |
26 | public: | |
b64b4e70 | 27 | wxWebViewWebKit() { Init(); } |
61b98a2d | 28 | |
b64b4e70 | 29 | wxWebViewWebKit(wxWindow *parent, |
61b98a2d SL |
30 | wxWindowID id = wxID_ANY, |
31 | const wxString& url = wxWebViewDefaultURLStr, | |
32 | const wxPoint& pos = wxDefaultPosition, | |
33 | const wxSize& size = wxDefaultSize, long style = 0, | |
34 | const wxString& name = wxWebViewNameStr) | |
35 | { | |
36 | Init(); | |
37 | ||
38 | Create(parent, id, url, pos, size, style, name); | |
39 | } | |
40 | ||
41 | virtual bool Create(wxWindow *parent, | |
42 | wxWindowID id = wxID_ANY, | |
43 | const wxString& url = wxWebViewDefaultURLStr, | |
44 | const wxPoint& pos = wxDefaultPosition, | |
45 | const wxSize& size = wxDefaultSize, long style = 0, | |
46 | const wxString& name = wxWebViewNameStr); | |
47 | ||
48 | virtual bool Enable( bool enable = true ); | |
49 | ||
50 | // implementation | |
51 | // -------------- | |
52 | ||
53 | static wxVisualAttributes | |
54 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
55 | ||
61b98a2d | 56 | virtual void Stop(); |
4d0dddc7 | 57 | virtual void LoadURL(const wxString& url); |
61b98a2d SL |
58 | virtual void GoBack(); |
59 | virtual void GoForward(); | |
a703012a | 60 | virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); |
e669ddde SL |
61 | virtual bool CanGoBack() const; |
62 | virtual bool CanGoForward() const; | |
152a5808 SL |
63 | virtual void ClearHistory(); |
64 | virtual void EnableHistory(bool enable = true); | |
c13d6ac1 SL |
65 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory(); |
66 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory(); | |
67 | virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item); | |
e669ddde SL |
68 | virtual wxString GetCurrentURL() const; |
69 | virtual wxString GetCurrentTitle() const; | |
70 | virtual wxString GetPageSource() const; | |
71 | virtual wxString GetPageText() const; | |
3dffc2ae SL |
72 | //We do not want to hide the other overloads |
73 | using wxWebView::SetPage; | |
61b98a2d SL |
74 | virtual void SetPage(const wxString& html, const wxString& baseUrl); |
75 | virtual void Print(); | |
e669ddde | 76 | virtual bool IsBusy() const; |
61b98a2d SL |
77 | |
78 | void SetZoomType(wxWebViewZoomType); | |
79 | wxWebViewZoomType GetZoomType() const; | |
80 | bool CanSetZoomType(wxWebViewZoomType) const; | |
e669ddde | 81 | virtual wxWebViewZoom GetZoom() const; |
61b98a2d SL |
82 | virtual void SetZoom(wxWebViewZoom); |
83 | ||
ae26e17b | 84 | //Clipboard functions |
e669ddde SL |
85 | virtual bool CanCut() const; |
86 | virtual bool CanCopy() const; | |
87 | virtual bool CanPaste() const; | |
ae26e17b SL |
88 | virtual void Cut(); |
89 | virtual void Copy(); | |
90 | virtual void Paste(); | |
61b98a2d | 91 | |
97e49559 | 92 | //Undo / redo functionality |
e669ddde SL |
93 | virtual bool CanUndo() const; |
94 | virtual bool CanRedo() const; | |
97e49559 SL |
95 | virtual void Undo(); |
96 | virtual void Redo(); | |
97 | ||
c7cbe308 SL |
98 | //Editing functions |
99 | virtual void SetEditable(bool enable = true); | |
e669ddde | 100 | virtual bool IsEditable() const; |
c7cbe308 | 101 | |
63a65070 SL |
102 | //Selection |
103 | virtual void DeleteSelection(); | |
e669ddde | 104 | virtual bool HasSelection() const; |
63a65070 | 105 | virtual void SelectAll(); |
e669ddde SL |
106 | virtual wxString GetSelectedText() const; |
107 | virtual wxString GetSelectedSource() const; | |
41933aa5 | 108 | virtual void ClearSelection(); |
63a65070 | 109 | |
c9ccc09c | 110 | virtual void RunScript(const wxString& javascript); |
eff8f795 SL |
111 | |
112 | //Virtual Filesystem Support | |
7d8d6163 SL |
113 | virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler); |
114 | virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; } | |
c9ccc09c | 115 | |
61b98a2d SL |
116 | /** FIXME: hack to work around signals being received too early */ |
117 | bool m_ready; | |
118 | ||
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; | |
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; | |
133 | ||
61b98a2d SL |
134 | protected: |
135 | ||
136 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; | |
137 | ||
138 | private: | |
139 | ||
fba4c7c9 SL |
140 | void ZoomIn(); |
141 | void ZoomOut(); | |
142 | void SetWebkitZoom(float level); | |
143 | float GetWebkitZoom() const; | |
144 | ||
61b98a2d SL |
145 | // focus event handler: calls GTKUpdateBitmap() |
146 | void GTKOnFocus(wxFocusEvent& event); | |
147 | ||
148 | GtkWidget *web_view; | |
a0ff3611 | 149 | int m_historyLimit; |
61b98a2d | 150 | |
7d8d6163 | 151 | wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList; |
f2049b68 | 152 | |
cddf4541 | 153 | wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); |
61b98a2d SL |
154 | }; |
155 | ||
9d2f31db | 156 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__) |
61b98a2d | 157 | |
384b8d9f | 158 | #endif |