]>
Commit | Line | Data |
---|---|---|
5ed68428 KO |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: webkit.i | |
3 | // Purpose: Embedding Apple's WebKit in wxWidgets | |
4 | // | |
5 | // Author: Robin Dunn / Kevin Ollivier | |
6 | // | |
f6f1e19f | 7 | // Created: 18-Oct-2004 |
5ed68428 | 8 | // RCS-ID: $Id$ |
f6f1e19f | 9 | // Copyright: (c) 2004 by Total Control Software |
5ed68428 KO |
10 | // Licence: wxWindows license |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
9d9cbcdd RD |
13 | %define DOCSTRING |
14 | "wx.webkit.WebKitCtrl for Mac OSX." | |
15 | %enddef | |
16 | ||
17 | %module(package="wx", docstring=DOCSTRING) webkit | |
5ed68428 KO |
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 | ||
f6f1e19f | 29 | #if wxUSE_WEBKIT |
5ed68428 | 30 | #include "wx/html/webkit.h" |
f6f1e19f | 31 | #endif |
5ed68428 KO |
32 | %} |
33 | ||
34 | //--------------------------------------------------------------------------- | |
35 | ||
5ed68428 | 36 | %import core.i |
f6f1e19f RD |
37 | %pythoncode { wx = _core } |
38 | %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } | |
5ed68428 | 39 | |
5ed68428 | 40 | |
f6f1e19f | 41 | %include _webkit_rename.i |
5ed68428 KO |
42 | |
43 | //--------------------------------------------------------------------------- | |
44 | ||
f6f1e19f RD |
45 | // Put some wx default wxChar* values into wxStrings. |
46 | MAKE_CONST_WXSTRING_NOSWIG(EmptyString); | |
47 | MAKE_CONST_WXSTRING2(WebKitNameStr, wxT("webkitctrl")) | |
48 | ||
49 | ||
5ed68428 | 50 | |
f6f1e19f | 51 | |
5ed68428 KO |
52 | %{ |
53 | #if !wxUSE_WEBKIT | |
f6f1e19f | 54 | // a dummy class for ports that don't have wxWebKitCtrl |
5ed68428 KO |
55 | class wxWebKitCtrl : public wxControl |
56 | { | |
57 | public: | |
58 | wxWebKitCtrl(wxWindow *parent, | |
f6f1e19f RD |
59 | wxWindowID winID, |
60 | const wxString& strURL, | |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, long style = 0, | |
63 | const wxValidator& validator = wxDefaultValidator, | |
64 | const wxString& name = wxPyWebKitNameStr) | |
65 | { wxPyRaiseNotImplemented(); } | |
66 | ||
67 | wxWebKitCtrl() { wxPyRaiseNotImplemented(); } | |
68 | ||
5ed68428 KO |
69 | bool Create(wxWindow *parent, |
70 | wxWindowID winID, | |
71 | const wxString& strURL, | |
72 | const wxPoint& pos = wxDefaultPosition, | |
73 | const wxSize& size = wxDefaultSize, long style = 0, | |
74 | const wxValidator& validator = wxDefaultValidator, | |
f6f1e19f RD |
75 | const wxString& name = wxPyWebKitNameStr) |
76 | { return false; } | |
5ed68428 KO |
77 | |
78 | void LoadURL(const wxString &url) {} | |
79 | ||
f6f1e19f RD |
80 | bool CanGoBack() { return false; } |
81 | bool CanGoForward() { return false; } | |
82 | bool GoBack() { return false; } | |
83 | bool GoForward() { return false; } | |
5ed68428 | 84 | void Reload() {} |
f6f1e19f RD |
85 | void Stop() {} |
86 | bool CanGetPageSource() { return false; } | |
87 | wxString GetPageSource() { return wxEmptyString; } | |
88 | void SetPageSource(wxString& source, const wxString& baseUrl = wxEmptyString) {} | |
f18ba20c RD |
89 | wxString GetPageURL() { return wxEmptyString; } |
90 | wxString GetPageTitle() { return wxEmptyString; } | |
5ed68428 | 91 | }; |
9d9cbcdd RD |
92 | |
93 | ||
94 | enum { | |
95 | wxWEBKIT_STATE_START = 0, | |
96 | wxWEBKIT_STATE_NEGOTIATING = 0, | |
97 | wxWEBKIT_STATE_REDIRECTING = 0, | |
98 | wxWEBKIT_STATE_TRANSFERRING = 0, | |
99 | wxWEBKIT_STATE_STOP = 0, | |
100 | wxWEBKIT_STATE_FAILED = 0, | |
4d00d250 RD |
101 | |
102 | wxEVT_WEBKIT_STATE_CHANGED = 0 | |
9d9cbcdd RD |
103 | }; |
104 | ||
105 | class wxWebKitStateChangedEvent : public wxCommandEvent | |
106 | { | |
107 | public: | |
108 | wxWebKitStateChangedEvent( wxWindow* win = NULL ) | |
109 | { wxPyRaiseNotImplemented(); } | |
110 | ||
4d00d250 | 111 | int GetState() { return 0; } |
9d9cbcdd RD |
112 | void SetState(const int state) {} |
113 | wxString GetURL() { return wxEmptyString; } | |
114 | void SetURL(const wxString& url) {} | |
115 | }; | |
116 | ||
117 | ||
5ed68428 KO |
118 | #endif |
119 | %} | |
120 | ||
b7a2ebe6 | 121 | // Now define it for SWIG, using either the real class or the dummy above. |
9d9cbcdd RD |
122 | |
123 | MustHaveApp(wxWebKitCtrl); | |
124 | ||
5ed68428 KO |
125 | class wxWebKitCtrl : public wxControl |
126 | { | |
127 | public: | |
9d9cbcdd RD |
128 | %pythonAppend wxWebKitCtrl "self._setOORInfo(self)" |
129 | %pythonAppend wxWebKitCtrl() "" | |
130 | ||
5ed68428 | 131 | wxWebKitCtrl(wxWindow *parent, |
9d9cbcdd RD |
132 | wxWindowID winID = -1, |
133 | const wxString& strURL = wxPyEmptyString, | |
5ed68428 KO |
134 | const wxPoint& pos = wxDefaultPosition, |
135 | const wxSize& size = wxDefaultSize, long style = 0, | |
136 | const wxValidator& validator = wxDefaultValidator, | |
f6f1e19f RD |
137 | const wxString& name = wxPyWebKitNameStr); |
138 | ||
1b8c7ba6 | 139 | %RenameCtor(PreWebKitCtrl, wxWebKitCtrl()); |
f6f1e19f RD |
140 | |
141 | ||
5ed68428 | 142 | bool Create(wxWindow *parent, |
9d9cbcdd RD |
143 | wxWindowID winID = -1, |
144 | const wxString& strURL = wxPyEmptyString, | |
5ed68428 KO |
145 | const wxPoint& pos = wxDefaultPosition, |
146 | const wxSize& size = wxDefaultSize, long style = 0, | |
147 | const wxValidator& validator = wxDefaultValidator, | |
f6f1e19f | 148 | const wxString& name = wxPyWebKitNameStr); |
5ed68428 KO |
149 | |
150 | void LoadURL(const wxString &url); | |
151 | ||
152 | bool CanGoBack(); | |
153 | bool CanGoForward(); | |
154 | bool GoBack(); | |
155 | bool GoForward(); | |
156 | void Reload(); | |
157 | void Stop(); | |
158 | bool CanGetPageSource(); | |
159 | wxString GetPageSource(); | |
f6f1e19f | 160 | void SetPageSource(wxString& source, const wxString& baseUrl = wxPyEmptyString); |
f18ba20c RD |
161 | wxString GetPageURL(); |
162 | wxString GetPageTitle(); | |
5ed68428 KO |
163 | }; |
164 | ||
f6f1e19f | 165 | |
9d9cbcdd RD |
166 | //--------------------------------------------------------------------------- |
167 | ||
168 | ||
169 | enum { | |
170 | wxWEBKIT_STATE_START, | |
171 | wxWEBKIT_STATE_NEGOTIATING, | |
172 | wxWEBKIT_STATE_REDIRECTING, | |
173 | wxWEBKIT_STATE_TRANSFERRING, | |
174 | wxWEBKIT_STATE_STOP, | |
175 | wxWEBKIT_STATE_FAILED, | |
176 | }; | |
177 | ||
178 | ||
179 | %constant wxEventType wxEVT_WEBKIT_STATE_CHANGED; | |
180 | ||
181 | ||
182 | class wxWebKitStateChangedEvent : public wxCommandEvent | |
183 | { | |
184 | public: | |
185 | wxWebKitStateChangedEvent( wxWindow* win = NULL ); | |
186 | ||
187 | int GetState(); | |
188 | void SetState(const int state); | |
189 | wxString GetURL(); | |
190 | void SetURL(const wxString& url); | |
191 | }; | |
192 | ||
193 | ||
194 | %pythoncode %{ | |
195 | EVT_WEBKIT_STATE_CHANGED = wx.PyEventBinder(wxEVT_WEBKIT_STATE_CHANGED) | |
196 | %} | |
197 | ||
198 | ||
199 | //--------------------------------------------------------------------------- | |
200 | ||
5ed68428 KO |
201 | %init %{ |
202 | ||
203 | %} | |
9d9cbcdd RD |
204 | |
205 | //--------------------------------------------------------------------------- |