]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/webview_webkit.h
Really fix the problem with caret in wxGrid text editor under MSW.
[wxWidgets.git] / include / wx / gtk / webview_webkit.h
CommitLineData
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
8ab75332 13#include "wx/defs.h"
61b98a2d 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
4c9bde5e
PC
20typedef struct _WebKitWebView WebKitWebView;
21
61b98a2d 22//-----------------------------------------------------------------------------
b64b4e70 23// wxWebViewWebKit
61b98a2d
SL
24//-----------------------------------------------------------------------------
25
467d261e 26class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
61b98a2d
SL
27{
28public:
8ab75332 29 wxWebViewWebKit();
61b98a2d 30
b64b4e70 31 wxWebViewWebKit(wxWindow *parent,
61b98a2d
SL
32 wxWindowID id = wxID_ANY,
33 const wxString& url = wxWebViewDefaultURLStr,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize, long style = 0,
36 const wxString& name = wxWebViewNameStr)
37 {
61b98a2d
SL
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
c3980646
VZ
48 virtual ~wxWebViewWebKit();
49
61b98a2d
SL
50 virtual bool Enable( bool enable = true );
51
52 // implementation
53 // --------------
54
55 static wxVisualAttributes
56 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
57
61b98a2d 58 virtual void Stop();
4d0dddc7 59 virtual void LoadURL(const wxString& url);
61b98a2d
SL
60 virtual void GoBack();
61 virtual void GoForward();
236cff73 62 virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT);
e669ddde
SL
63 virtual bool CanGoBack() const;
64 virtual bool CanGoForward() const;
152a5808 65 virtual void ClearHistory();
c420d57b 66 virtual void EnableContextMenu(bool enable = true);
152a5808 67 virtual void EnableHistory(bool enable = true);
c13d6ac1
SL
68 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
69 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
70 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
e669ddde
SL
71 virtual wxString GetCurrentURL() const;
72 virtual wxString GetCurrentTitle() const;
73 virtual wxString GetPageSource() const;
74 virtual wxString GetPageText() const;
61b98a2d 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
66ac0400 98 //Find function
236cff73 99 virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT);
66ac0400 100
c7cbe308
SL
101 //Editing functions
102 virtual void SetEditable(bool enable = true);
e669ddde 103 virtual bool IsEditable() const;
c7cbe308 104
63a65070
SL
105 //Selection
106 virtual void DeleteSelection();
e669ddde 107 virtual bool HasSelection() const;
63a65070 108 virtual void SelectAll();
e669ddde
SL
109 virtual wxString GetSelectedText() const;
110 virtual wxString GetSelectedSource() const;
41933aa5 111 virtual void ClearSelection();
63a65070 112
c9ccc09c 113 virtual void RunScript(const wxString& javascript);
34326da7 114
eff8f795 115 //Virtual Filesystem Support
7d8d6163
SL
116 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
117 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
c9ccc09c 118
b6a49c2b
VZ
119 virtual void* GetNativeBackend() const { return m_web_view; }
120
61b98a2d
SL
121 /** TODO: check if this can be made private
122 * The native control has a getter to check for busy state, but except in
123 * very recent versions of webkit this getter doesn't say everything we need
124 * (namely it seems to stay indefinitely busy when loading is cancelled by
125 * user)
126 */
127 bool m_busy;
3baf235f 128
211da8a5 129 wxString m_vfsurl;
61b98a2d 130
36b52591
SL
131 //We use this flag to stop recursion when we load a page from the navigation
132 //callback, mainly when loading a VFS page
133 bool m_guard;
134
61b98a2d 135protected:
a977376a 136 virtual void DoSetPage(const wxString& html, const wxString& baseUrl);
61b98a2d
SL
137
138 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
139
140private:
141
fba4c7c9
SL
142 void ZoomIn();
143 void ZoomOut();
144 void SetWebkitZoom(float level);
145 float GetWebkitZoom() const;
146
66ac0400
SL
147 //Find helper function
148 void FindClear();
149
61b98a2d
SL
150 // focus event handler: calls GTKUpdateBitmap()
151 void GTKOnFocus(wxFocusEvent& event);
152
4c9bde5e 153 WebKitWebView *m_web_view;
a0ff3611 154 int m_historyLimit;
61b98a2d 155
7d8d6163 156 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
f2049b68 157
66ac0400
SL
158 //variables used for Find()
159 int m_findFlags;
160 wxString m_findText;
161 int m_findPosition;
162 int m_findCount;
163
cddf4541 164 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
61b98a2d
SL
165};
166
4c687fff
SL
167class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
168{
169public:
170 virtual wxWebView* Create() { return new wxWebViewWebKit; }
171 virtual wxWebView* Create(wxWindow* parent,
172 wxWindowID id,
173 const wxString& url = wxWebViewDefaultURLStr,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& size = wxDefaultSize,
176 long style = 0,
177 const wxString& name = wxWebViewNameStr)
178 { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
179};
180
181
9d2f31db 182#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
61b98a2d 183
384b8d9f 184#endif