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
);
71 //we need to resize the webview when the control size changes
72 void OnSize(wxSizeEvent
&event
);
75 void MacVisibilityChanged();
79 wxWindowID m_windowID
;
80 wxString m_currentURL
;
82 objc_object
* m_webView
;
83 //It should be WebView, but WebView is Cocoa only, so any class which included
84 //this header would have to link to Cocoa, so for now use void* instead.
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
92 wxWEBKIT_STATE_START
= 1,
93 wxWEBKIT_STATE_NEGOTIATING
= 2,
94 wxWEBKIT_STATE_REDIRECTING
= 4,
95 wxWEBKIT_STATE_TRANSFERRING
= 8,
96 wxWEBKIT_STATE_STOP
= 16,
97 wxWEBKIT_STATE_FAILED
= 32
100 class wxWebKitStateChangedEvent
: public wxCommandEvent
102 DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent
)
105 int GetState() { return m_state
; }
106 void SetState(const int state
) { m_state
= state
; }
107 wxString
GetURL() { return m_url
; }
108 void SetURL(const wxString
& url
) { m_url
= url
; }
110 wxWebKitStateChangedEvent( wxWindow
* win
= (wxWindow
*) NULL
);
111 wxEvent
*Clone(void) const { return new wxWebKitStateChangedEvent(*this); }
118 typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction
)(wxWebKitStateChangedEvent
&);
120 BEGIN_DECLARE_EVENT_TYPES()
121 DECLARE_LOCAL_EVENT_TYPE(wxEVT_WEBKIT_STATE_CHANGED
, wxID_ANY
)
122 END_DECLARE_EVENT_TYPES()
124 #define EVT_WEBKIT_STATE_CHANGED(func) \
125 DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \
128 (wxObjectEventFunction) \
129 (wxWebKitStateChangedEventFunction) & func, \
132 #endif // wxUSE_WEBKIT
134 #endif // _WX_WEBKIT_H_