1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/html/webkit.h
3 // Purpose: wxWebKitCtrl - embeddable web kit control
4 // Author: Jethro Grassie / Kevin Ollivier
8 // Copyright: (c) Jethro Grassie / Kevin Ollivier
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #if !defined(__WXMAC__) && !defined(__WXCOCOA__)
18 #error "wxWebKitCtrl not implemented for this platform"
22 #include <WebKit/WebKit.h>
24 #include "wx/control.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class wxWebKitCtrl
: public wxControl
33 DECLARE_DYNAMIC_CLASS(wxWebKitCtrl
)
36 wxWebKitCtrl(wxWindow
*parent
,
38 const wxString
& strURL
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
, long style
= 0,
41 const wxValidator
& validator
= wxDefaultValidator
,
42 const wxString
& name
= wxT("webkitctrl"))
44 Create(parent
, winID
, strURL
, pos
, size
, style
, validator
, name
);
46 bool Create(wxWindow
*parent
,
48 const wxString
& strURL
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
, long style
= 0,
51 const wxValidator
& validator
= wxDefaultValidator
,
52 const wxString
& name
= wxT("webkitctrl"));
53 virtual ~wxWebKitCtrl();
55 void LoadURL(const wxString
&url
);
63 bool CanGetPageSource();
64 wxString
GetPageSource();
65 void SetPageSource(wxString
& source
, const wxString
& baseUrl
= wxEmptyString
);
66 wxString
GetPageURL(){ return m_currentURL
; }
67 wxString
GetPageTitle(){ return m_pageTitle
; }
69 //we need to resize the webview when the control size changes
70 void OnSize(wxSizeEvent
&event
);
73 void MacVisibilityChanged();
77 wxWindowID m_windowID
;
78 wxString m_currentURL
;
80 struct objc_object
*m_webView
;
81 //It should be WebView*, but WebView is an Objective-C class
82 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
90 wxWEBKIT_STATE_START
= 1,
91 wxWEBKIT_STATE_NEGOTIATING
= 2,
92 wxWEBKIT_STATE_REDIRECTING
= 4,
93 wxWEBKIT_STATE_TRANSFERRING
= 8,
94 wxWEBKIT_STATE_STOP
= 16,
95 wxWEBKIT_STATE_FAILED
= 32
98 class wxWebKitStateChangedEvent
: public wxCommandEvent
100 DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent
)
103 int GetState() { return m_state
; }
104 void SetState(const int state
) { m_state
= state
; }
105 wxString
GetURL() { return m_url
; }
106 void SetURL(const wxString
& url
) { m_url
= url
; }
108 wxWebKitStateChangedEvent( wxWindow
* win
= (wxWindow
*) NULL
);
109 wxEvent
*Clone(void) const { return new wxWebKitStateChangedEvent(*this); }
116 typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction
)(wxWebKitStateChangedEvent
&);
118 BEGIN_DECLARE_EVENT_TYPES()
119 DECLARE_LOCAL_EVENT_TYPE(wxEVT_WEBKIT_STATE_CHANGED
, wxID_ANY
)
120 END_DECLARE_EVENT_TYPES()
122 #define EVT_WEBKIT_STATE_CHANGED(func) \
123 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \
126 (wxObjectEventFunction) \
127 (wxWebKitStateChangedEventFunction) & func, \
130 #endif // wxUSE_WEBKIT