1 /////////////////////////////////////////////////////////////////////////////
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 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "webkit.h"
21 #if !defined(__WXMAC__) && !defined(__WXCOCOA__)
22 #error "wxWebKitCtrl not implemented for this platform"
26 #include <WebKit/WebKit.h>
28 #include "wx/control.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class wxWebKitCtrl
: public wxControl
37 DECLARE_DYNAMIC_CLASS(wxWebKitCtrl
)
40 wxWebKitCtrl(wxWindow
*parent
,
42 const wxString
& strURL
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
, long style
= 0,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxT("webkitctrl"))
48 Create(parent
, winID
, strURL
, pos
, size
, style
, validator
, name
);
50 bool Create(wxWindow
*parent
,
52 const wxString
& strURL
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
, long style
= 0,
55 const wxValidator
& validator
= wxDefaultValidator
,
56 const wxString
& name
= wxT("webkitctrl"));
57 virtual ~wxWebKitCtrl();
59 void LoadURL(const wxString
&url
);
67 bool CanGetPageSource();
68 wxString
GetPageSource();
69 void SetPageSource(wxString
& source
, const wxString
& baseUrl
= wxEmptyString
);
70 wxString
GetPageURL(){ return m_currentURL
; }
71 wxString
GetPageTitle(){ return m_pageTitle
; }
73 //we need to resize the webview when the control size changes
74 void OnSize(wxSizeEvent
&event
);
77 void MacVisibilityChanged();
81 wxWindowID m_windowID
;
82 wxString m_currentURL
;
84 struct objc_object
*m_webView
;
85 //It should be WebView*, but WebView is an Objective-C class
86 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
89 // ----------------------------------------------------------------------------
91 // ----------------------------------------------------------------------------
94 wxWEBKIT_STATE_START
= 1,
95 wxWEBKIT_STATE_NEGOTIATING
= 2,
96 wxWEBKIT_STATE_REDIRECTING
= 4,
97 wxWEBKIT_STATE_TRANSFERRING
= 8,
98 wxWEBKIT_STATE_STOP
= 16,
99 wxWEBKIT_STATE_FAILED
= 32
102 class wxWebKitStateChangedEvent
: public wxCommandEvent
104 DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent
)
107 int GetState() { return m_state
; }
108 void SetState(const int state
) { m_state
= state
; }
109 wxString
GetURL() { return m_url
; }
110 void SetURL(const wxString
& url
) { m_url
= url
; }
112 wxWebKitStateChangedEvent( wxWindow
* win
= (wxWindow
*) NULL
);
113 wxEvent
*Clone(void) const { return new wxWebKitStateChangedEvent(*this); }
120 typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction
)(wxWebKitStateChangedEvent
&);
122 BEGIN_DECLARE_EVENT_TYPES()
123 DECLARE_LOCAL_EVENT_TYPE(wxEVT_WEBKIT_STATE_CHANGED
, wxID_ANY
)
124 END_DECLARE_EVENT_TYPES()
126 #define EVT_WEBKIT_STATE_CHANGED(func) \
127 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \
130 (wxObjectEventFunction) \
131 (wxWebKitStateChangedEventFunction) & func, \
134 #endif // wxUSE_WEBKIT
136 #endif // _WX_WEBKIT_H_