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