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