1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Embedding Apple's WebKit in wxWidgets
5 // Author: Robin Dunn / Kevin Ollivier
7 // Created: 18-Oct-2004
9 // Copyright: (c) 2004 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
14 "wx.webkit.WebKitCtrl for Mac OSX."
17 %module(package="wx", docstring=DOCSTRING) webkit
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "wx/wxPython/pyistream.h"
25 #ifdef __WXMAC__ // avoid a bug in Carbon headers
30 #include "wx/html/webkit.h"
34 //---------------------------------------------------------------------------
37 %pythoncode { wx = _core }
38 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
41 //---------------------------------------------------------------------------
43 // Put some wx default wxChar* values into wxStrings.
44 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
45 MAKE_CONST_WXSTRING2(WebKitNameStr, wxT("webkitctrl"))
52 // a dummy class for ports that don't have wxWebKitCtrl
53 class wxWebKitCtrl : public wxControl
56 wxWebKitCtrl(wxWindow *parent,
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(); }
65 wxWebKitCtrl() { wxPyRaiseNotImplemented(); }
67 bool Create(wxWindow *parent,
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)
76 void LoadURL(const wxString &url) {}
78 bool CanGoBack() { return false; }
79 bool CanGoForward() { return false; }
80 bool GoBack() { return false; }
81 bool GoForward() { return false; }
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; }
90 wxString GetSelection() { return wxEmptyString; }
92 bool CanIncreaseTextSize() { return false; }
93 void IncreaseTextSize() { }
94 bool CanDecreaseTextSize() { return false; }
95 void DecreaseTextSize() { }
97 void Print(bool showPrompt=false) { }
99 void MakeEditable(bool enable=true) { }
100 bool IsEditable() { return false; }
102 wxString RunScript(const wxString& javascript) { return wxEmptyString; }
104 void SetScrollPos(int pos) { }
105 int GetScrollPos() { return 0; }
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,
118 wxEVT_WEBKIT_STATE_CHANGED = 0
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
131 class wxWebKitStateChangedEvent : public wxCommandEvent
134 wxWebKitStateChangedEvent( wxWindow* win = NULL )
135 { wxPyRaiseNotImplemented(); }
137 int GetState() { return 0; }
138 void SetState(const int state) {}
139 wxString GetURL() { return wxEmptyString; }
140 void SetURL(const wxString& url) {}
143 class wxWebKitBeforeLoadEvent : public wxCommandEvent
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; }
153 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL ) { wxPyRaiseNotImplemented }
159 // Now define it for SWIG, using either the real class or the dummy above.
161 MustHaveApp(wxWebKitCtrl);
163 class wxWebKitCtrl : public wxControl
166 %pythonAppend wxWebKitCtrl "self._setOORInfo(self)"
167 %pythonAppend wxWebKitCtrl() ""
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);
177 %RenameCtor(PreWebKitCtrl, wxWebKitCtrl());
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);
188 void LoadURL(const wxString &url);
196 bool CanGetPageSource();
197 wxString GetPageSource();
198 void SetPageSource(wxString& source, const wxString& baseUrl = wxPyEmptyString);
199 wxString GetPageURL();
200 wxString GetPageTitle();
202 wxString GetSelection();
204 bool CanIncreaseTextSize();
205 void IncreaseTextSize();
206 bool CanDecreaseTextSize();
207 void DecreaseTextSize();
209 void Print(bool showPrompt=false);
211 void MakeEditable(bool enable=true);
214 wxString RunScript(const wxString& javascript);
216 void SetScrollPos(int pos);
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`");
228 //---------------------------------------------------------------------------
232 wxWEBKIT_STATE_START,
233 wxWEBKIT_STATE_NEGOTIATING,
234 wxWEBKIT_STATE_REDIRECTING,
235 wxWEBKIT_STATE_TRANSFERRING,
237 wxWEBKIT_STATE_FAILED,
241 wxWEBKIT_NAV_LINK_CLICKED,
242 wxWEBKIT_NAV_BACK_NEXT,
243 wxWEBKIT_NAV_FORM_SUBMITTED,
245 wxWEBKIT_NAV_FORM_RESUBMITTED,
250 %constant wxEventType wxEVT_WEBKIT_STATE_CHANGED;
251 %constant wxEventType wxEVT_WEBKIT_BEFORE_LOAD;
253 class wxWebKitBeforeLoadEvent : public wxCommandEvent
257 void Cancel(bool cancel = true);
259 void SetURL(const wxString& url);
260 void SetNavigationType(int navType);
261 int GetNavigationType();
263 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL );
265 %property(NavigationType, GetNavigationType, SetNavigationType, doc="See `GetNavigationType` and `SetNavigationType`");
266 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
270 class wxWebKitStateChangedEvent : public wxCommandEvent
273 wxWebKitStateChangedEvent( wxWindow* win = NULL );
276 void SetState(const int state);
278 void SetURL(const wxString& url);
280 %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
281 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
286 EVT_WEBKIT_STATE_CHANGED = wx.PyEventBinder(wxEVT_WEBKIT_STATE_CHANGED)
287 EVT_WEBKIT_BEFORE_LOAD = wx.PyEventBinder(wxEVT_WEBKIT_BEFORE_LOAD)
291 //---------------------------------------------------------------------------
297 //---------------------------------------------------------------------------