2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "wx/wxprec.h"
39 class WebViewFrameData;
44 class FrameLoaderClientWx;
49 #if WXMAKINGDLL_WEBKIT
50 #define WXDLLIMPEXP_WEBKIT WXEXPORT
51 #elif defined(WXUSINGDLL_WEBKIT)
52 #define WXDLLIMPEXP_WEBKIT WXIMPORT
54 #define WXDLLIMPEXP_WEBKIT
58 #define WXDLLIMPEXP_WEBKIT
61 extern WXDLLIMPEXP_WEBKIT const wxChar* wxWebViewNameStr;
63 class WXDLLIMPEXP_WEBKIT wxWebView : public wxWindow
65 // ChromeClientWx needs to get the Page* stored by the wxWebView
66 // for the createWindow function.
67 friend class WebCore::ChromeClientWx;
68 friend class WebCore::FrameLoaderClientWx;
73 %pythonAppend wxWebView "self._setOORInfo(self)"
74 %pythonAppend wxWebView() ""
77 wxWebView(wxWindow* parent, int id = wxID_ANY,
78 const wxPoint& point = wxDefaultPosition,
79 const wxSize& size = wxDefaultSize,
81 const wxString& name = wxWebViewNameStr); // For wxWebView internal data passing
83 %rename(PreWebView) wxWebView();
88 bool Create(wxWindow* parent, int id = wxID_ANY,
89 const wxPoint& point = wxDefaultPosition,
90 const wxSize& size = wxDefaultSize,
92 const wxString& name = wxWebViewNameStr); // For wxWebView internal data passing
98 void LoadURL(const wxString& url);
115 //bool CanGetPageSource();
116 wxString GetPageSource();
117 void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
119 wxString GetInnerText();
120 wxString GetAsMarkup();
121 wxString GetExternalRepresentation();
123 void SetTransparent(bool transparent);
124 bool IsTransparent() const;
126 wxString RunScript(const wxString& javascript);
128 bool CanIncreaseTextSize() const;
129 void IncreaseTextSize();
130 bool CanDecreaseTextSize() const;
131 void DecreaseTextSize();
132 void MakeEditable(bool enable);
133 bool IsEditable() const { return m_isEditable; }
135 wxString GetPageTitle() const { return m_title; }
136 void SetPageTitle(const wxString& title) { m_title = title; }
138 wxWebFrame* GetMainFrame() { return m_mainFrame; }
140 wxWebViewDOMElementInfo HitTest(const wxPoint& post) const;
144 // event handlers (these functions should _not_ be virtual)
145 void OnPaint(wxPaintEvent& event);
146 void OnSize(wxSizeEvent& event);
147 void OnMouseEvents(wxMouseEvent& event);
148 void OnKeyEvents(wxKeyEvent& event);
149 void OnSetFocus(wxFocusEvent& event);
150 void OnKillFocus(wxFocusEvent& event);
151 void OnActivate(wxActivateEvent& event);
154 // any class wishing to process wxWindows events must use this macro
156 DECLARE_EVENT_TABLE()
157 DECLARE_DYNAMIC_CLASS(wxWebView)
159 float m_textMagnifier;
161 bool m_isInitialized;
162 bool m_beingDestroyed;
163 WebViewPrivate* m_impl;
164 wxWebFrame* m_mainFrame;
169 // ----------------------------------------------------------------------------
171 // ----------------------------------------------------------------------------
174 wxWEBVIEW_LOAD_STARTED = 1,
175 wxWEBVIEW_LOAD_NEGOTIATING = 2,
176 wxWEBVIEW_LOAD_REDIRECTING = 4,
177 wxWEBVIEW_LOAD_TRANSFERRING = 8,
178 wxWEBVIEW_LOAD_STOPPED = 16,
179 wxWEBVIEW_LOAD_FAILED = 32,
180 wxWEBVIEW_LOAD_DL_COMPLETED = 64,
181 wxWEBVIEW_LOAD_DOC_COMPLETED = 128,
182 wxWEBVIEW_LOAD_ONLOAD_HANDLED = 256,
183 wxWEBVIEW_LOAD_WINDOW_OBJECT_CLEARED = 512
187 wxWEBVIEW_NAV_LINK_CLICKED = 1,
188 wxWEBVIEW_NAV_BACK_NEXT = 2,
189 wxWEBVIEW_NAV_FORM_SUBMITTED = 4,
190 wxWEBVIEW_NAV_RELOAD = 8,
191 wxWEBVIEW_NAV_FORM_RESUBMITTED = 16,
192 wxWEBVIEW_NAV_OTHER = 32
195 class WXDLLIMPEXP_WEBKIT wxWebViewBeforeLoadEvent : public wxCommandEvent
198 DECLARE_DYNAMIC_CLASS( wxWebViewBeforeLoadEvent )
202 bool IsCancelled() const { return m_cancelled; }
203 void Cancel(bool cancel = true) { m_cancelled = cancel; }
204 wxString GetURL() const { return m_url; }
205 void SetURL(const wxString& url) { m_url = url; }
206 void SetNavigationType(int navType) { m_navType = navType; }
207 int GetNavigationType() const { return m_navType; }
209 wxWebViewBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL );
210 wxEvent *Clone(void) const { return new wxWebViewBeforeLoadEvent(*this); }
218 class WXDLLIMPEXP_WEBKIT wxWebViewLoadEvent : public wxCommandEvent
221 DECLARE_DYNAMIC_CLASS( wxWebViewLoadEvent )
225 int GetState() const { return m_state; }
226 void SetState(const int state) { m_state = state; }
227 wxString GetURL() const { return m_url; }
228 void SetURL(const wxString& url) { m_url = url; }
230 wxWebViewLoadEvent( wxWindow* win = (wxWindow*) NULL );
231 wxEvent *Clone(void) const { return new wxWebViewLoadEvent(*this); }
238 class WXDLLIMPEXP_WEBKIT wxWebViewNewWindowEvent : public wxCommandEvent
241 DECLARE_DYNAMIC_CLASS( wxWebViewNewWindowEvent )
245 wxString GetURL() const { return m_url; }
246 void SetURL(const wxString& url) { m_url = url; }
247 wxString GetTargetName() const { return m_targetName; }
248 void SetTargetName(const wxString& name) { m_targetName = name; }
250 wxWebViewNewWindowEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
251 wxEvent *Clone(void) const { return new wxWebViewNewWindowEvent(*this); }
255 wxString m_targetName;
258 class WXDLLIMPEXP_WEBKIT wxWebViewRightClickEvent : public wxCommandEvent
261 DECLARE_DYNAMIC_CLASS( wxWebViewRightClickEvent )
265 wxWebViewRightClickEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
266 wxEvent *Clone(void) const { return new wxWebViewRightClickEvent(*this); }
268 wxWebViewDOMElementInfo GetInfo() const { return m_info; }
269 void SetInfo(wxWebViewDOMElementInfo info) { m_info = info; }
271 wxPoint GetPosition() const { return m_position; }
272 void SetPosition(wxPoint pos) { m_position = pos; }
275 wxWebViewDOMElementInfo m_info;
279 class WXDLLIMPEXP_WEBKIT wxWebViewConsoleMessageEvent : public wxCommandEvent
282 DECLARE_DYNAMIC_CLASS( wxWebViewConsoleMessageEvent )
286 wxString GetMessage() const { return m_message; }
287 void SetMessage(const wxString& message) { m_message = message; }
289 unsigned int GetLineNumber() const { return m_lineNumber; }
290 void SetLineNumber(unsigned int lineNumber) { m_lineNumber = lineNumber; }
292 wxString GetSourceID() const { return m_sourceID; }
293 void SetSourceID(const wxString& sourceID) { m_sourceID = sourceID; }
295 wxWebViewConsoleMessageEvent( wxWindow* win = (wxWindow*) NULL );
296 wxEvent *Clone(void) const { return new wxWebViewConsoleMessageEvent(*this); }
299 unsigned int m_lineNumber;
304 class WXDLLIMPEXP_WEBKIT wxWebViewReceivedTitleEvent : public wxCommandEvent
307 DECLARE_DYNAMIC_CLASS( wxWebViewReceivedTitleEvent )
311 wxString GetTitle() const { return m_title; }
312 void SetTitle(const wxString& title) { m_title = title; }
314 wxWebViewReceivedTitleEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
315 wxEvent *Clone(void) const { return new wxWebViewReceivedTitleEvent(*this); }
322 typedef void (wxEvtHandler::*wxWebViewLoadEventFunction)(wxWebViewLoadEvent&);
323 typedef void (wxEvtHandler::*wxWebViewBeforeLoadEventFunction)(wxWebViewBeforeLoadEvent&);
324 typedef void (wxEvtHandler::*wxWebViewNewWindowEventFunction)(wxWebViewNewWindowEvent&);
325 typedef void (wxEvtHandler::*wxWebViewRightClickEventFunction)(wxWebViewRightClickEvent&);
326 typedef void (wxEvtHandler::*wxWebViewConsoleMessageEventFunction)(wxWebViewConsoleMessageEvent&);
327 typedef void (wxEvtHandler::*wxWebViewReceivedTitleEventFunction)(wxWebViewReceivedTitleEvent&);
330 BEGIN_DECLARE_EVENT_TYPES()
331 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_BEFORE_LOAD, wxID_ANY)
332 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_LOAD, wxID_ANY)
333 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_NEW_WINDOW, wxID_ANY)
334 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RIGHT_CLICK, wxID_ANY)
335 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_CONSOLE_MESSAGE, wxID_ANY)
336 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RECEIVED_TITLE, wxID_ANY)
337 END_DECLARE_EVENT_TYPES()
340 #define EVT_WEBVIEW_LOAD(winid, func) \
341 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_LOAD, \
344 (wxObjectEventFunction) \
345 (wxWebViewLoadEventFunction) & func, \
346 static_cast<wxObject*>(NULL)),
348 #define EVT_WEBVIEW_BEFORE_LOAD(winid, func) \
349 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_BEFORE_LOAD, \
352 (wxObjectEventFunction) \
353 (wxWebViewBeforeLoadEventFunction) & func, \
354 static_cast<wxObject*>(NULL)),
356 #define EVT_WEBVIEW_NEW_WINDOW(winid, func) \
357 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_NEW_WINDOW, \
360 (wxObjectEventFunction) \
361 (wxWebViewNewWindowEventFunction) & func, \
362 static_cast<wxObject*>(NULL)),
364 #define EVT_WEBVIEW_RIGHT_CLICK(winid, func) \
365 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_RIGHT_CLICK, \
368 (wxObjectEventFunction) \
369 (wxWebViewRightClickEventFunction) & func, \
370 static_cast<wxObject*>(NULL)),
372 #define EVT_WEBVIEW_CONSOLE_MESSAGE(winid, func) \
373 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_CONSOLE_MESSAGE, \
376 (wxObjectEventFunction) \
377 (wxWebViewConsoleMessageEventFunction) & func, \
378 static_cast<wxObject*>(NULL)),
380 #define EVT_WEBVIEW_RECEIVED_TITLE(winid, func) \
381 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_RECEIVED_TITLE, \
384 (wxObjectEventFunction) \
385 (wxWebViewReceivedTitleEventFunction) & func, \
386 static_cast<wxObject*>(NULL)),
388 #endif // ifndef WXWEBVIEW_H