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 FindString(const wxString& string, bool forward = true,
129 bool caseSensitive = false, bool wrapSelection = true,
130 bool startInSelection = true);
132 bool CanIncreaseTextSize() const;
133 void IncreaseTextSize();
134 bool CanDecreaseTextSize() const;
135 void DecreaseTextSize();
136 void MakeEditable(bool enable);
137 bool IsEditable() const { return m_isEditable; }
139 wxString GetPageTitle() const { return m_title; }
140 void SetPageTitle(const wxString& title) { m_title = title; }
142 wxWebFrame* GetMainFrame() { return m_mainFrame; }
144 wxWebViewDOMElementInfo HitTest(const wxPoint& post) const;
148 // event handlers (these functions should _not_ be virtual)
149 void OnPaint(wxPaintEvent& event);
150 void OnSize(wxSizeEvent& event);
151 void OnMouseEvents(wxMouseEvent& event);
152 void OnKeyEvents(wxKeyEvent& event);
153 void OnSetFocus(wxFocusEvent& event);
154 void OnKillFocus(wxFocusEvent& event);
155 void OnActivate(wxActivateEvent& event);
158 // any class wishing to process wxWindows events must use this macro
160 DECLARE_EVENT_TABLE()
161 DECLARE_DYNAMIC_CLASS(wxWebView)
163 float m_textMagnifier;
165 bool m_isInitialized;
166 bool m_beingDestroyed;
167 WebViewPrivate* m_impl;
168 wxWebFrame* m_mainFrame;
173 // ----------------------------------------------------------------------------
175 // ----------------------------------------------------------------------------
178 wxWEBVIEW_LOAD_STARTED = 1,
179 wxWEBVIEW_LOAD_NEGOTIATING = 2,
180 wxWEBVIEW_LOAD_REDIRECTING = 4,
181 wxWEBVIEW_LOAD_TRANSFERRING = 8,
182 wxWEBVIEW_LOAD_STOPPED = 16,
183 wxWEBVIEW_LOAD_FAILED = 32,
184 wxWEBVIEW_LOAD_DL_COMPLETED = 64,
185 wxWEBVIEW_LOAD_DOC_COMPLETED = 128,
186 wxWEBVIEW_LOAD_ONLOAD_HANDLED = 256,
187 wxWEBVIEW_LOAD_WINDOW_OBJECT_CLEARED = 512
191 wxWEBVIEW_NAV_LINK_CLICKED = 1,
192 wxWEBVIEW_NAV_BACK_NEXT = 2,
193 wxWEBVIEW_NAV_FORM_SUBMITTED = 4,
194 wxWEBVIEW_NAV_RELOAD = 8,
195 wxWEBVIEW_NAV_FORM_RESUBMITTED = 16,
196 wxWEBVIEW_NAV_OTHER = 32
199 class WXDLLIMPEXP_WEBKIT wxWebViewBeforeLoadEvent : public wxCommandEvent
202 DECLARE_DYNAMIC_CLASS( wxWebViewBeforeLoadEvent )
206 bool IsCancelled() const { return m_cancelled; }
207 void Cancel(bool cancel = true) { m_cancelled = cancel; }
208 wxString GetURL() const { return m_url; }
209 void SetURL(const wxString& url) { m_url = url; }
210 void SetNavigationType(int navType) { m_navType = navType; }
211 int GetNavigationType() const { return m_navType; }
213 wxWebViewBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL );
214 wxEvent *Clone(void) const { return new wxWebViewBeforeLoadEvent(*this); }
222 class WXDLLIMPEXP_WEBKIT wxWebViewLoadEvent : public wxCommandEvent
225 DECLARE_DYNAMIC_CLASS( wxWebViewLoadEvent )
229 int GetState() const { return m_state; }
230 void SetState(const int state) { m_state = state; }
231 wxString GetURL() const { return m_url; }
232 void SetURL(const wxString& url) { m_url = url; }
234 wxWebViewLoadEvent( wxWindow* win = (wxWindow*) NULL );
235 wxEvent *Clone(void) const { return new wxWebViewLoadEvent(*this); }
242 class WXDLLIMPEXP_WEBKIT wxWebViewNewWindowEvent : public wxCommandEvent
245 DECLARE_DYNAMIC_CLASS( wxWebViewNewWindowEvent )
249 wxString GetURL() const { return m_url; }
250 void SetURL(const wxString& url) { m_url = url; }
251 wxString GetTargetName() const { return m_targetName; }
252 void SetTargetName(const wxString& name) { m_targetName = name; }
254 wxWebViewNewWindowEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
255 wxEvent *Clone(void) const { return new wxWebViewNewWindowEvent(*this); }
259 wxString m_targetName;
262 class WXDLLIMPEXP_WEBKIT wxWebViewRightClickEvent : public wxCommandEvent
265 DECLARE_DYNAMIC_CLASS( wxWebViewRightClickEvent )
269 wxWebViewRightClickEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
270 wxEvent *Clone(void) const { return new wxWebViewRightClickEvent(*this); }
272 wxWebViewDOMElementInfo GetInfo() const { return m_info; }
273 void SetInfo(wxWebViewDOMElementInfo info) { m_info = info; }
275 wxPoint GetPosition() const { return m_position; }
276 void SetPosition(wxPoint pos) { m_position = pos; }
279 wxWebViewDOMElementInfo m_info;
283 class WXDLLIMPEXP_WEBKIT wxWebViewConsoleMessageEvent : public wxCommandEvent
286 DECLARE_DYNAMIC_CLASS( wxWebViewConsoleMessageEvent )
290 wxString GetMessage() const { return m_message; }
291 void SetMessage(const wxString& message) { m_message = message; }
293 unsigned int GetLineNumber() const { return m_lineNumber; }
294 void SetLineNumber(unsigned int lineNumber) { m_lineNumber = lineNumber; }
296 wxString GetSourceID() const { return m_sourceID; }
297 void SetSourceID(const wxString& sourceID) { m_sourceID = sourceID; }
299 wxWebViewConsoleMessageEvent( wxWindow* win = (wxWindow*) NULL );
300 wxEvent *Clone(void) const { return new wxWebViewConsoleMessageEvent(*this); }
303 unsigned int m_lineNumber;
308 class WXDLLIMPEXP_WEBKIT wxWebViewReceivedTitleEvent : public wxCommandEvent
311 DECLARE_DYNAMIC_CLASS( wxWebViewReceivedTitleEvent )
315 wxString GetTitle() const { return m_title; }
316 void SetTitle(const wxString& title) { m_title = title; }
318 wxWebViewReceivedTitleEvent( wxWindow* win = static_cast<wxWindow*>(NULL));
319 wxEvent *Clone(void) const { return new wxWebViewReceivedTitleEvent(*this); }
326 typedef void (wxEvtHandler::*wxWebViewLoadEventFunction)(wxWebViewLoadEvent&);
327 typedef void (wxEvtHandler::*wxWebViewBeforeLoadEventFunction)(wxWebViewBeforeLoadEvent&);
328 typedef void (wxEvtHandler::*wxWebViewNewWindowEventFunction)(wxWebViewNewWindowEvent&);
329 typedef void (wxEvtHandler::*wxWebViewRightClickEventFunction)(wxWebViewRightClickEvent&);
330 typedef void (wxEvtHandler::*wxWebViewConsoleMessageEventFunction)(wxWebViewConsoleMessageEvent&);
331 typedef void (wxEvtHandler::*wxWebViewReceivedTitleEventFunction)(wxWebViewReceivedTitleEvent&);
334 BEGIN_DECLARE_EVENT_TYPES()
335 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_BEFORE_LOAD, wxID_ANY)
336 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_LOAD, wxID_ANY)
337 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_NEW_WINDOW, wxID_ANY)
338 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RIGHT_CLICK, wxID_ANY)
339 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_CONSOLE_MESSAGE, wxID_ANY)
340 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RECEIVED_TITLE, wxID_ANY)
341 END_DECLARE_EVENT_TYPES()
344 #define EVT_WEBVIEW_LOAD(winid, func) \
345 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_LOAD, \
348 (wxObjectEventFunction) \
349 (wxWebViewLoadEventFunction) & func, \
350 static_cast<wxObject*>(NULL)),
352 #define EVT_WEBVIEW_BEFORE_LOAD(winid, func) \
353 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_BEFORE_LOAD, \
356 (wxObjectEventFunction) \
357 (wxWebViewBeforeLoadEventFunction) & func, \
358 static_cast<wxObject*>(NULL)),
360 #define EVT_WEBVIEW_NEW_WINDOW(winid, func) \
361 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_NEW_WINDOW, \
364 (wxObjectEventFunction) \
365 (wxWebViewNewWindowEventFunction) & func, \
366 static_cast<wxObject*>(NULL)),
368 #define EVT_WEBVIEW_RIGHT_CLICK(winid, func) \
369 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_RIGHT_CLICK, \
372 (wxObjectEventFunction) \
373 (wxWebViewRightClickEventFunction) & func, \
374 static_cast<wxObject*>(NULL)),
376 #define EVT_WEBVIEW_CONSOLE_MESSAGE(winid, func) \
377 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_CONSOLE_MESSAGE, \
380 (wxObjectEventFunction) \
381 (wxWebViewConsoleMessageEventFunction) & func, \
382 static_cast<wxObject*>(NULL)),
384 #define EVT_WEBVIEW_RECEIVED_TITLE(winid, func) \
385 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_RECEIVED_TITLE, \
388 (wxObjectEventFunction) \
389 (wxWebViewReceivedTitleEventFunction) & func, \
390 static_cast<wxObject*>(NULL)),
392 #endif // ifndef WXWEBVIEW_H