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