]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/html/webkit.h
Export recently added wxRichTextXMLHelper to fix link errors.
[wxWidgets.git] / include / wx / html / webkit.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/html/webkit.h
3// Purpose: wxWebKitCtrl - embeddable web kit control
4// Author: Jethro Grassie / Kevin Ollivier
5// Modified by:
6// Created: 2004-4-16
7// Copyright: (c) Jethro Grassie / Kevin Ollivier
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_WEBKIT_H
12#define _WX_WEBKIT_H
13
14#if wxUSE_WEBKIT
15
16#if !defined(__WXMAC__) && !defined(__WXCOCOA__)
17#error "wxWebKitCtrl not implemented for this platform"
18#endif
19
20#include "wx/control.h"
21DECLARE_WXCOCOA_OBJC_CLASS(WebView);
22
23// ----------------------------------------------------------------------------
24// Web Kit Control
25// ----------------------------------------------------------------------------
26
27extern WXDLLIMPEXP_DATA_CORE(const char) wxWebKitCtrlNameStr[];
28
29class WXDLLIMPEXP_CORE wxWebKitCtrl : public wxControl
30{
31public:
32 DECLARE_DYNAMIC_CLASS(wxWebKitCtrl)
33
34 wxWebKitCtrl() {}
35 wxWebKitCtrl(wxWindow *parent,
36 wxWindowID winID,
37 const wxString& strURL,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize, long style = 0,
40 const wxValidator& validator = wxDefaultValidator,
41 const wxString& name = wxWebKitCtrlNameStr)
42 {
43 Create(parent, winID, strURL, pos, size, style, validator, name);
44 }
45 bool Create(wxWindow *parent,
46 wxWindowID winID,
47 const wxString& strURL,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize, long style = 0,
50 const wxValidator& validator = wxDefaultValidator,
51 const wxString& name = wxWebKitCtrlNameStr);
52 virtual ~wxWebKitCtrl();
53
54 void LoadURL(const wxString &url);
55
56 bool CanGoBack();
57 bool CanGoForward();
58 bool GoBack();
59 bool GoForward();
60 void Reload();
61 void Stop();
62 bool CanGetPageSource();
63 wxString GetPageSource();
64 void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
65 wxString GetPageURL(){ return m_currentURL; }
66 void SetPageTitle(const wxString& title) { m_pageTitle = title; }
67 wxString GetPageTitle(){ return m_pageTitle; }
68
69 // since these worked in 2.6, add wrappers
70 void SetTitle(const wxString& title) { SetPageTitle(title); }
71 wxString GetTitle() { return GetPageTitle(); }
72
73 wxString GetSelection();
74
75 bool CanIncreaseTextSize();
76 void IncreaseTextSize();
77 bool CanDecreaseTextSize();
78 void DecreaseTextSize();
79
80 void Print(bool showPrompt = false);
81
82 void MakeEditable(bool enable = true);
83 bool IsEditable();
84
85 wxString RunScript(const wxString& javascript);
86
87 void SetScrollPos(int pos);
88 int GetScrollPos();
89
90 // don't hide base class virtuals
91 virtual void SetScrollPos( int orient, int pos, bool refresh = true )
92 { return wxControl::SetScrollPos(orient, pos, refresh); }
93 virtual int GetScrollPos( int orient ) const
94 { return wxControl::GetScrollPos(orient); }
95
96 //we need to resize the webview when the control size changes
97 void OnSize(wxSizeEvent &event);
98 void OnMove(wxMoveEvent &event);
99 void OnMouseEvents(wxMouseEvent &event);
100protected:
101 DECLARE_EVENT_TABLE()
102 void MacVisibilityChanged();
103
104private:
105 wxWindow *m_parent;
106 wxWindowID m_windowID;
107 wxString m_currentURL;
108 wxString m_pageTitle;
109
110 WX_WebView m_webView;
111
112 // we may use this later to setup our own mouse events,
113 // so leave it in for now.
114 void* m_webKitCtrlEventHandler;
115};
116
117// ----------------------------------------------------------------------------
118// Web Kit Events
119// ----------------------------------------------------------------------------
120
121enum {
122 wxWEBKIT_STATE_START = 1,
123 wxWEBKIT_STATE_NEGOTIATING = 2,
124 wxWEBKIT_STATE_REDIRECTING = 4,
125 wxWEBKIT_STATE_TRANSFERRING = 8,
126 wxWEBKIT_STATE_STOP = 16,
127 wxWEBKIT_STATE_FAILED = 32
128};
129
130enum {
131 wxWEBKIT_NAV_LINK_CLICKED = 1,
132 wxWEBKIT_NAV_BACK_NEXT = 2,
133 wxWEBKIT_NAV_FORM_SUBMITTED = 4,
134 wxWEBKIT_NAV_RELOAD = 8,
135 wxWEBKIT_NAV_FORM_RESUBMITTED = 16,
136 wxWEBKIT_NAV_OTHER = 32
137
138};
139
140
141
142class WXDLLIMPEXP_CORE wxWebKitBeforeLoadEvent : public wxCommandEvent
143{
144 DECLARE_DYNAMIC_CLASS( wxWebKitBeforeLoadEvent )
145
146public:
147 bool IsCancelled() { return m_cancelled; }
148 void Cancel(bool cancel = true) { m_cancelled = cancel; }
149 wxString GetURL() { return m_url; }
150 void SetURL(const wxString& url) { m_url = url; }
151 void SetNavigationType(int navType) { m_navType = navType; }
152 int GetNavigationType() { return m_navType; }
153
154 wxWebKitBeforeLoadEvent( wxWindow* win = NULL );
155 wxEvent *Clone(void) const { return new wxWebKitBeforeLoadEvent(*this); }
156
157protected:
158 bool m_cancelled;
159 wxString m_url;
160 int m_navType;
161};
162
163class WXDLLIMPEXP_CORE wxWebKitStateChangedEvent : public wxCommandEvent
164{
165 DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent )
166
167public:
168 int GetState() { return m_state; }
169 void SetState(const int state) { m_state = state; }
170 wxString GetURL() { return m_url; }
171 void SetURL(const wxString& url) { m_url = url; }
172
173 wxWebKitStateChangedEvent( wxWindow* win = NULL );
174 wxEvent *Clone(void) const { return new wxWebKitStateChangedEvent(*this); }
175
176protected:
177 int m_state;
178 wxString m_url;
179};
180
181
182class WXDLLIMPEXP_CORE wxWebKitNewWindowEvent : public wxCommandEvent
183{
184 DECLARE_DYNAMIC_CLASS( wxWebKitNewWindowEvent )
185public:
186 wxString GetURL() const { return m_url; }
187 void SetURL(const wxString& url) { m_url = url; }
188 wxString GetTargetName() const { return m_targetName; }
189 void SetTargetName(const wxString& name) { m_targetName = name; }
190
191 wxWebKitNewWindowEvent( wxWindow* win = (wxWindow*)(NULL));
192 wxEvent *Clone(void) const { return new wxWebKitNewWindowEvent(*this); }
193
194private:
195 wxString m_url;
196 wxString m_targetName;
197};
198
199typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction)(wxWebKitStateChangedEvent&);
200typedef void (wxEvtHandler::*wxWebKitBeforeLoadEventFunction)(wxWebKitBeforeLoadEvent&);
201typedef void (wxEvtHandler::*wxWebKitNewWindowEventFunction)(wxWebKitNewWindowEvent&);
202
203#define wxWebKitStateChangedEventHandler( func ) \
204 wxEVENT_HANDLER_CAST( wxWebKitStateChangedEventFunction, func )
205
206#define wxWebKitBeforeLoadEventHandler( func ) \
207 wxEVENT_HANDLER_CAST( wxWebKitBeforeLoadEventFunction, func )
208
209#define wxWebKitNewWindowEventHandler( func ) \
210 wxEVENT_HANDLER_CAST( wxWebKitNewWindowEventFunction, func )
211
212wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_STATE_CHANGED, wxWebKitStateChangedEvent );
213wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_BEFORE_LOAD, wxWebKitBeforeLoadEvent );
214wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_WEBKIT_NEW_WINDOW, wxWebKitNewWindowEvent );
215
216#define EVT_WEBKIT_STATE_CHANGED(func) \
217 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \
218 wxID_ANY, \
219 wxID_ANY, \
220 wxWebKitStateChangedEventHandler( func ), \
221 NULL ),
222
223#define EVT_WEBKIT_BEFORE_LOAD(func) \
224 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_BEFORE_LOAD, \
225 wxID_ANY, \
226 wxID_ANY, \
227 wxWebKitBeforeLoadEventHandler( func ), \
228 NULL ),
229
230#define EVT_WEBKIT_NEW_WINDOW(func) \
231 wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_NEW_WINDOW, \
232 wxID_ANY, \
233 wxID_ANY, \
234 wxWebKitNewWindowEventHandler( func ), \
235 NULL ),
236#endif // wxUSE_WEBKIT
237
238#endif
239 // _WX_WEBKIT_H_