]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/webkit.h
Applied rowspan patch #15276 (dghart)
[wxWidgets.git] / include / wx / html / webkit.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/html/webkit.h
3 // Purpose: wxWebKitCtrl - embeddable web kit control
4 // Author: Jethro Grassie / Kevin Ollivier
5 // Modified by:
6 // Created: 2004-4-16
7 // RCS-ID: $Id$
8 // Copyright: (c) Jethro Grassie / Kevin Ollivier
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WEBKIT_H
13 #define _WX_WEBKIT_H
14
15 #if wxUSE_WEBKIT
16
17 #if !defined(__WXMAC__) && !defined(__WXCOCOA__)
18 #error "wxWebKitCtrl not implemented for this platform"
19 #endif
20
21 #include "wx/control.h"
22 DECLARE_WXCOCOA_OBJC_CLASS(WebView);
23
24 // ----------------------------------------------------------------------------
25 // Web Kit Control
26 // ----------------------------------------------------------------------------
27
28 extern WXDLLIMPEXP_DATA_CORE(const char) wxWebKitCtrlNameStr[];
29
30 class WXDLLIMPEXP_CORE wxWebKitCtrl : public wxControl
31 {
32 public:
33 DECLARE_DYNAMIC_CLASS(wxWebKitCtrl)
34
35 wxWebKitCtrl() {}
36 wxWebKitCtrl(wxWindow *parent,
37 wxWindowID winID,
38 const wxString& strURL,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize, long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString& name = wxWebKitCtrlNameStr)
43 {
44 Create(parent, winID, strURL, pos, size, style, validator, name);
45 }
46 bool Create(wxWindow *parent,
47 wxWindowID winID,
48 const wxString& strURL,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize, long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxWebKitCtrlNameStr);
53 virtual ~wxWebKitCtrl();
54
55 void LoadURL(const wxString &url);
56
57 bool CanGoBack();
58 bool CanGoForward();
59 bool GoBack();
60 bool GoForward();
61 void Reload();
62 void Stop();
63 bool CanGetPageSource();
64 wxString GetPageSource();
65 void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
66 wxString GetPageURL(){ return m_currentURL; }
67 void SetPageTitle(const wxString& title) { m_pageTitle = title; }
68 wxString GetPageTitle(){ return m_pageTitle; }
69
70 // since these worked in 2.6, add wrappers
71 void SetTitle(const wxString& title) { SetPageTitle(title); }
72 wxString GetTitle() { return GetPageTitle(); }
73
74 wxString GetSelection();
75
76 bool CanIncreaseTextSize();
77 void IncreaseTextSize();
78 bool CanDecreaseTextSize();
79 void DecreaseTextSize();
80
81 void Print(bool showPrompt = false);
82
83 void MakeEditable(bool enable = true);
84 bool IsEditable();
85
86 wxString RunScript(const wxString& javascript);
87
88 void SetScrollPos(int pos);
89 int GetScrollPos();
90
91 // don't hide base class virtuals
92 virtual void SetScrollPos( int orient, int pos, bool refresh = true )
93 { return wxControl::SetScrollPos(orient, pos, refresh); }
94 virtual int GetScrollPos( int orient ) const
95 { return wxControl::GetScrollPos(orient); }
96
97 //we need to resize the webview when the control size changes
98 void OnSize(wxSizeEvent &event);
99 void OnMove(wxMoveEvent &event);
100 void OnMouseEvents(wxMouseEvent &event);
101 protected:
102 DECLARE_EVENT_TABLE()
103 void MacVisibilityChanged();
104
105 private:
106 wxWindow *m_parent;
107 wxWindowID m_windowID;
108 wxString m_currentURL;
109 wxString m_pageTitle;
110
111 WX_WebView m_webView;
112
113 // we may use this later to setup our own mouse events,
114 // so leave it in for now.
115 void* m_webKitCtrlEventHandler;
116 };
117
118 // ----------------------------------------------------------------------------
119 // Web Kit Events
120 // ----------------------------------------------------------------------------
121
122 enum {
123 wxWEBKIT_STATE_START = 1,
124 wxWEBKIT_STATE_NEGOTIATING = 2,
125 wxWEBKIT_STATE_REDIRECTING = 4,
126 wxWEBKIT_STATE_TRANSFERRING = 8,
127 wxWEBKIT_STATE_STOP = 16,
128 wxWEBKIT_STATE_FAILED = 32
129 };
130
131 enum {
132 wxWEBKIT_NAV_LINK_CLICKED = 1,
133 wxWEBKIT_NAV_BACK_NEXT = 2,
134 wxWEBKIT_NAV_FORM_SUBMITTED = 4,
135 wxWEBKIT_NAV_RELOAD = 8,
136 wxWEBKIT_NAV_FORM_RESUBMITTED = 16,
137 wxWEBKIT_NAV_OTHER = 32
138
139 };
140
141
142
143 class WXDLLIMPEXP_CORE wxWebKitBeforeLoadEvent : public wxCommandEvent
144 {
145 DECLARE_DYNAMIC_CLASS( wxWebKitBeforeLoadEvent )
146
147 public:
148 bool IsCancelled() { return m_cancelled; }
149 void Cancel(bool cancel = true) { m_cancelled = cancel; }
150 wxString GetURL() { return m_url; }
151 void SetURL(const wxString& url) { m_url = url; }
152 void SetNavigationType(int navType) { m_navType = navType; }
153 int GetNavigationType() { return m_navType; }
154
155 wxWebKitBeforeLoadEvent( wxWindow* win = NULL );
156 wxEvent *Clone(void) const { return new wxWebKitBeforeLoadEvent(*this); }
157
158 protected:
159 bool m_cancelled;
160 wxString m_url;
161 int m_navType;
162 };
163
164 class WXDLLIMPEXP_CORE wxWebKitStateChangedEvent : public wxCommandEvent
165 {
166 DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent )
167
168 public:
169 int GetState() { return m_state; }
170 void SetState(const int state) { m_state = state; }
171 wxString GetURL() { return m_url; }
172 void SetURL(const wxString& url) { m_url = url; }
173
174 wxWebKitStateChangedEvent( wxWindow* win = NULL );
175 wxEvent *Clone(void) const { return new wxWebKitStateChangedEvent(*this); }
176
177 protected:
178 int m_state;
179 wxString m_url;
180 };
181
182
183 class WXDLLIMPEXP_CORE wxWebKitNewWindowEvent : public wxCommandEvent
184 {
185 DECLARE_DYNAMIC_CLASS( wxWebKitNewWindowEvent )
186 public:
187 wxString GetURL() const { return m_url; }
188 void SetURL(const wxString& url) { m_url = url; }
189 wxString GetTargetName() const { return m_targetName; }
190 void SetTargetName(const wxString& name) { m_targetName = name; }
191
192 wxWebKitNewWindowEvent( wxWindow* win = (wxWindow*)(NULL));
193 wxEvent *Clone(void) const { return new wxWebKitNewWindowEvent(*this); }
194
195 private:
196 wxString m_url;
197 wxString m_targetName;
198 };
199
200 typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction)(wxWebKitStateChangedEvent&);
201 typedef void (wxEvtHandler::*wxWebKitBeforeLoadEventFunction)(wxWebKitBeforeLoadEvent&);
202 typedef void (wxEvtHandler::*wxWebKitNewWindowEventFunction)(wxWebKitNewWindowEvent&);
203
204 #define wxWebKitStateChangedEventHandler( func ) \
205 wxEVENT_HANDLER_CAST( wxWebKitStateChangedEventFunction, func )
206
207 #define wxWebKitBeforeLoadEventHandler( func ) \
208 wxEVENT_HANDLER_CAST( wxWebKitBeforeLoadEventFunction, func )
209
210 #define wxWebKitNewWindowEventHandler( func ) \
211 wxEVENT_HANDLER_CAST( wxWebKitNewWindowEventFunction, func )
212
213 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_STATE_CHANGED, wxWebKitStateChangedEvent );
214 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_BEFORE_LOAD, wxWebKitBeforeLoadEvent );
215 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_NEW_WINDOW, wxWebKitNewWindowEvent );
216
217 #define EVT_WEBKIT_STATE_CHANGED(func) \
218 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \
219 wxID_ANY, \
220 wxID_ANY, \
221 wxWebKitStateChangedEventHandler( func ), \
222 NULL ),
223
224 #define EVT_WEBKIT_BEFORE_LOAD(func) \
225 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_BEFORE_LOAD, \
226 wxID_ANY, \
227 wxID_ANY, \
228 wxWebKitBeforeLoadEventHandler( func ), \
229 NULL ),
230
231 #define EVT_WEBKIT_NEW_WINDOW(func) \
232 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_NEW_WINDOW, \
233 wxID_ANY, \
234 wxID_ANY, \
235 wxWebKitNewWindowEventHandler( func ), \
236 NULL ),
237 #endif // wxUSE_WEBKIT
238
239 #endif
240 // _WX_WEBKIT_H_