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,
119 wxEVT_WEBKIT_BEFORE_LOAD = 0
123 wxWEBKIT_NAV_LINK_CLICKED = 0,
124 wxWEBKIT_NAV_BACK_NEXT = 0,
125 wxWEBKIT_NAV_FORM_SUBMITTED = 0,
126 wxWEBKIT_NAV_RELOAD = 0,
127 wxWEBKIT_NAV_FORM_RESUBMITTED = 0,
128 wxWEBKIT_NAV_OTHER = 0
132 class wxWebKitStateChangedEvent : public wxCommandEvent
135 wxWebKitStateChangedEvent( wxWindow* win = NULL )
136 { wxPyRaiseNotImplemented(); }
138 int GetState() { return 0; }
139 void SetState(const int state) {}
140 wxString GetURL() { return wxEmptyString; }
141 void SetURL(const wxString& url) {}
144 class wxWebKitBeforeLoadEvent : public wxCommandEvent
147 bool IsCancelled() { return false; }
148 void Cancel(bool cancel = true) { }
149 wxString GetURL() { return wxEmptyString; }
150 void SetURL(const wxString& url) { }
151 void SetNavigationType(int navType) { }
152 int GetNavigationType() { return 0; }
154 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL ) { wxPyRaiseNotImplemented(); }
160 // Now define it for SWIG, using either the real class or the dummy above.
162 MustHaveApp(wxWebKitCtrl);
164 class wxWebKitCtrl : public wxControl
167 %pythonAppend wxWebKitCtrl "self._setOORInfo(self)"
168 %pythonAppend wxWebKitCtrl() ""
170 wxWebKitCtrl(wxWindow *parent,
171 wxWindowID winID = -1,
172 const wxString& strURL = wxPyEmptyString,
173 const wxPoint& pos = wxDefaultPosition,
174 const wxSize& size = wxDefaultSize, long style = 0,
175 const wxValidator& validator = wxDefaultValidator,
176 const wxString& name = wxPyWebKitNameStr);
178 %RenameCtor(PreWebKitCtrl, wxWebKitCtrl());
181 bool Create(wxWindow *parent,
182 wxWindowID winID = -1,
183 const wxString& strURL = wxPyEmptyString,
184 const wxPoint& pos = wxDefaultPosition,
185 const wxSize& size = wxDefaultSize, long style = 0,
186 const wxValidator& validator = wxDefaultValidator,
187 const wxString& name = wxPyWebKitNameStr);
189 void LoadURL(const wxString &url);
197 bool CanGetPageSource();
198 wxString GetPageSource();
199 void SetPageSource(wxString& source, const wxString& baseUrl = wxPyEmptyString);
200 wxString GetPageURL();
201 wxString GetPageTitle();
203 wxString GetSelection();
205 bool CanIncreaseTextSize();
206 void IncreaseTextSize();
207 bool CanDecreaseTextSize();
208 void DecreaseTextSize();
210 void Print(bool showPrompt=false);
212 void MakeEditable(bool enable=true);
215 wxString RunScript(const wxString& javascript);
217 void SetScrollPos(int pos);
221 %property(PageSource, GetPageSource, SetPageSource, doc="See `GetPageSource` and `SetPageSource`");
222 %property(PageTitle, GetPageTitle, doc="See `GetPageTitle`");
223 %property(PageURL, GetPageURL, doc="See `GetPageURL`");
224 %property(ScrollPos, GetScrollPos, SetScrollPos, doc="See `GetScrollPos and SetScrollPos`");
225 %property(Selection, GetSelection, doc="See `GetSelection`");
229 //---------------------------------------------------------------------------
233 wxWEBKIT_STATE_START,
234 wxWEBKIT_STATE_NEGOTIATING,
235 wxWEBKIT_STATE_REDIRECTING,
236 wxWEBKIT_STATE_TRANSFERRING,
238 wxWEBKIT_STATE_FAILED,
242 wxWEBKIT_NAV_LINK_CLICKED,
243 wxWEBKIT_NAV_BACK_NEXT,
244 wxWEBKIT_NAV_FORM_SUBMITTED,
246 wxWEBKIT_NAV_FORM_RESUBMITTED,
251 %constant wxEventType wxEVT_WEBKIT_STATE_CHANGED;
252 %constant wxEventType wxEVT_WEBKIT_BEFORE_LOAD;
254 class wxWebKitBeforeLoadEvent : public wxCommandEvent
258 void Cancel(bool cancel = true);
260 void SetURL(const wxString& url);
261 void SetNavigationType(int navType);
262 int GetNavigationType();
264 wxWebKitBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL );
266 %property(NavigationType, GetNavigationType, SetNavigationType, doc="See `GetNavigationType` and `SetNavigationType`");
267 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
271 class wxWebKitStateChangedEvent : public wxCommandEvent
274 wxWebKitStateChangedEvent( wxWindow* win = NULL );
277 void SetState(const int state);
279 void SetURL(const wxString& url);
281 %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
282 %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
287 EVT_WEBKIT_STATE_CHANGED = wx.PyEventBinder(wxEVT_WEBKIT_STATE_CHANGED)
288 EVT_WEBKIT_BEFORE_LOAD = wx.PyEventBinder(wxEVT_WEBKIT_BEFORE_LOAD)
292 //---------------------------------------------------------------------------
298 //---------------------------------------------------------------------------