]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/webkit.i
Several wxWebKitCtrl enhancements/fixes. Including:
[wxWidgets.git] / wxPython / src / webkit.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: webkit.i
3 // Purpose: Embedding Apple's WebKit in wxWidgets
4 //
5 // Author: Robin Dunn / Kevin Ollivier
6 //
7 // Created: 18-Oct-2004
8 // RCS-ID: $Id$
9 // Copyright: (c) 2004 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %define DOCSTRING
14 "wx.webkit.WebKitCtrl for Mac OSX."
15 %enddef
16
17 %module(package="wx", docstring=DOCSTRING) webkit
18
19 %{
20
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "wx/wxPython/pyistream.h"
24
25 #ifdef __WXMAC__ // avoid a bug in Carbon headers
26 #define scalb scalbn
27 #endif
28
29 #if wxUSE_WEBKIT
30 #include "wx/html/webkit.h"
31 #endif
32 %}
33
34 //---------------------------------------------------------------------------
35
36 %import core.i
37 %pythoncode { wx = _core }
38 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
39
40
41 //---------------------------------------------------------------------------
42
43 // Put some wx default wxChar* values into wxStrings.
44 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
45 MAKE_CONST_WXSTRING2(WebKitNameStr, wxT("webkitctrl"))
46
47
48
49
50 %{
51 #if !wxUSE_WEBKIT
52 // a dummy class for ports that don't have wxWebKitCtrl
53 class wxWebKitCtrl : public wxControl
54 {
55 public:
56 wxWebKitCtrl(wxWindow *parent,
57 wxWindowID winID,
58 const wxString& strURL,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize, long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxPyWebKitNameStr)
63 { wxPyRaiseNotImplemented(); }
64
65 wxWebKitCtrl() { wxPyRaiseNotImplemented(); }
66
67 bool Create(wxWindow *parent,
68 wxWindowID winID,
69 const wxString& strURL,
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize, long style = 0,
72 const wxValidator& validator = wxDefaultValidator,
73 const wxString& name = wxPyWebKitNameStr)
74 { return false; }
75
76 void LoadURL(const wxString &url) {}
77
78 bool CanGoBack() { return false; }
79 bool CanGoForward() { return false; }
80 bool GoBack() { return false; }
81 bool GoForward() { return false; }
82 void Reload() {}
83 void Stop() {}
84 bool CanGetPageSource() { return false; }
85 wxString GetPageSource() { return wxEmptyString; }
86 void SetPageSource(wxString& source, const wxString& baseUrl = wxEmptyString) {}
87 wxString GetPageURL() { return wxEmptyString; }
88 wxString GetPageTitle() { return wxEmptyString; }
89
90 wxString GetSelection() { return wxEmptyString; }
91
92 bool CanIncreaseTextSize() { return false; }
93 void IncreaseTextSize() { }
94 bool CanDecreaseTextSize() { return false; }
95 void DecreaseTextSize() { }
96
97 void Print(bool showPrompt=false) { }
98
99 void MakeEditable(bool enable=true) { }
100 bool IsEditable() { return false; }
101
102 wxString RunScript(const wxString& javascript) { return wxEmptyString; }
103
104 void SetScrollPos(int pos) { }
105 int GetScrollPos() { return 0; }
106
107 };
108
109
110 enum {
111 wxWEBKIT_STATE_START = 0,
112 wxWEBKIT_STATE_NEGOTIATING = 0,
113 wxWEBKIT_STATE_REDIRECTING = 0,
114 wxWEBKIT_STATE_TRANSFERRING = 0,
115 wxWEBKIT_STATE_STOP = 0,
116 wxWEBKIT_STATE_FAILED = 0,
117
118 wxEVT_WEBKIT_STATE_CHANGED = 0
119 };
120
121 enum {
122 wxWEBKIT_NAV_LINK_CLICKED = 0,
123 wxWEBKIT_NAV_BACK_NEXT = 0,
124 wxWEBKIT_NAV_FORM_SUBMITTED = 0,
125 wxWEBKIT_NAV_RELOAD = 0,
126 wxWEBKIT_NAV_FORM_RESUBMITTED = 0,
127 wxWEBKIT_NAV_OTHER = 0
128
129 };
130
131 class wxWebKitStateChangedEvent : public wxCommandEvent
132 {
133 public:
134 wxWebKitStateChangedEvent( wxWindow* win = NULL )
135 { wxPyRaiseNotImplemented(); }
136
137 int GetState() { return 0; }
138 void SetState(const int state) {}
139 wxString GetURL() { return wxEmptyString; }
140 void SetURL(const wxString& url) {}
141 };
142
143 class wxWebKitBeforeLoadEvent : public wxCommandEvent
144 {
145 public:
146 bool IsCancelled() { return false; }
147 void Cancel(bool cancel = true) { }
148 wxString GetURL() { return wxEmptyString; }
149 void SetURL(const wxString& url) { }
150 void SetNavigationType(int navType) { }
151 int GetNavigationType() { return 0; }
152
153 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL ) { wxPyRaiseNotImplemented }
154 };
155
156 #endif
157 %}
158
159 // Now define it for SWIG, using either the real class or the dummy above.
160
161 MustHaveApp(wxWebKitCtrl);
162
163 class wxWebKitCtrl : public wxControl
164 {
165 public:
166 %pythonAppend wxWebKitCtrl "self._setOORInfo(self)"
167 %pythonAppend wxWebKitCtrl() ""
168
169 wxWebKitCtrl(wxWindow *parent,
170 wxWindowID winID = -1,
171 const wxString& strURL = wxPyEmptyString,
172 const wxPoint& pos = wxDefaultPosition,
173 const wxSize& size = wxDefaultSize, long style = 0,
174 const wxValidator& validator = wxDefaultValidator,
175 const wxString& name = wxPyWebKitNameStr);
176
177 %RenameCtor(PreWebKitCtrl, wxWebKitCtrl());
178
179
180 bool Create(wxWindow *parent,
181 wxWindowID winID = -1,
182 const wxString& strURL = wxPyEmptyString,
183 const wxPoint& pos = wxDefaultPosition,
184 const wxSize& size = wxDefaultSize, long style = 0,
185 const wxValidator& validator = wxDefaultValidator,
186 const wxString& name = wxPyWebKitNameStr);
187
188 void LoadURL(const wxString &url);
189
190 bool CanGoBack();
191 bool CanGoForward();
192 bool GoBack();
193 bool GoForward();
194 void Reload();
195 void Stop();
196 bool CanGetPageSource();
197 wxString GetPageSource();
198 void SetPageSource(wxString& source, const wxString& baseUrl = wxPyEmptyString);
199 wxString GetPageURL();
200 wxString GetPageTitle();
201
202 wxString GetSelection();
203
204 bool CanIncreaseTextSize();
205 void IncreaseTextSize();
206 bool CanDecreaseTextSize();
207 void DecreaseTextSize();
208
209 void Print(bool showPrompt=false);
210
211 void MakeEditable(bool enable=true);
212 bool IsEditable();
213
214 wxString RunScript(const wxString& javascript);
215
216 void SetScrollPos(int pos);
217 int GetScrollPos();
218
219
220 %property(PageSource, GetPageSource, SetPageSource, doc="See `GetPageSource` and `SetPageSource`");
221 %property(PageTitle, GetPageTitle, doc="See `GetPageTitle`");
222 %property(PageURL, GetPageURL, doc="See `GetPageURL`");
223 %property(ScrollPos, GetScrollPos, SetScrollPos, doc="See `GetScrollPos and SetScrollPos`");
224 %property(Selection, GetSelection, doc="See `GetSelection`");
225 };
226
227
228 //---------------------------------------------------------------------------
229
230
231 enum {
232 wxWEBKIT_STATE_START,
233 wxWEBKIT_STATE_NEGOTIATING,
234 wxWEBKIT_STATE_REDIRECTING,
235 wxWEBKIT_STATE_TRANSFERRING,
236 wxWEBKIT_STATE_STOP,
237 wxWEBKIT_STATE_FAILED,
238 };
239
240 enum {
241 wxWEBKIT_NAV_LINK_CLICKED,
242 wxWEBKIT_NAV_BACK_NEXT,
243 wxWEBKIT_NAV_FORM_SUBMITTED,
244 wxWEBKIT_NAV_RELOAD,
245 wxWEBKIT_NAV_FORM_RESUBMITTED,
246 wxWEBKIT_NAV_OTHER
247
248 };
249
250 %constant wxEventType wxEVT_WEBKIT_STATE_CHANGED;
251 %constant wxEventType wxEVT_WEBKIT_BEFORE_LOAD;
252
253 class wxWebKitBeforeLoadEvent : public wxCommandEvent
254 {
255 public:
256 bool IsCancelled();
257 void Cancel(bool cancel = true);
258 wxString GetURL();
259 void SetURL(const wxString& url);
260 void SetNavigationType(int navType);
261 int GetNavigationType();
262
263 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL );
264
265 %property(NavigationType, GetNavigationType, SetNavigationType, doc="See `GetNavigationType` and `SetNavigationType`");
266 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
267 };
268
269
270 class wxWebKitStateChangedEvent : public wxCommandEvent
271 {
272 public:
273 wxWebKitStateChangedEvent( wxWindow* win = NULL );
274
275 int GetState();
276 void SetState(const int state);
277 wxString GetURL();
278 void SetURL(const wxString& url);
279
280 %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
281 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
282 };
283
284
285 %pythoncode %{
286 EVT_WEBKIT_STATE_CHANGED = wx.PyEventBinder(wxEVT_WEBKIT_STATE_CHANGED)
287 EVT_WEBKIT_BEFORE_LOAD = wx.PyEventBinder(wxEVT_WEBKIT_BEFORE_LOAD)
288 %}
289
290
291 //---------------------------------------------------------------------------
292
293 %init %{
294
295 %}
296
297 //---------------------------------------------------------------------------