1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/osx/webkit.h
3 // Purpose: wxOSXWebKitCtrl - embeddable web kit control,
4 // OS X implementation of web view component
5 // Author: Jethro Grassie / Kevin Ollivier / Marianne Gagnon
9 // Copyright: (c) Jethro Grassie / Kevin Ollivier / Marianne Gagnon
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
18 #if wxUSE_WEBKIT && (defined(__WXMAC__) || defined(__WXCOCOA__))
20 // TODO: define this in setup.h ?
21 #define wxHAVE_WEB_BACKEND_OSX_WEBKIT 1
23 #include "wx/control.h"
24 #include "wx/webview.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxOSXWebKitCtrl
: public wxWebView
33 wxDECLARE_DYNAMIC_CLASS(wxOSXWebKitCtrl
);
36 wxOSXWebKitCtrl(wxWindow
*parent
,
37 wxWindowID winID
= wxID_ANY
,
38 const wxString
& strURL
= wxWebViewDefaultURLStr
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
, long style
= 0,
41 const wxString
& name
= wxWebViewNameStr
)
43 Create(parent
, winID
, strURL
, pos
, size
, style
, name
);
45 bool Create(wxWindow
*parent
,
46 wxWindowID winID
= wxID_ANY
,
47 const wxString
& strURL
= wxWebViewDefaultURLStr
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
, long style
= 0,
50 const wxString
& name
= wxWebViewNameStr
);
51 virtual ~wxOSXWebKitCtrl();
53 void InternalLoadURL(const wxString
&url
);
55 virtual bool CanGoBack();
56 virtual bool CanGoForward();
57 virtual void GoBack();
58 virtual void GoForward();
59 virtual void Reload(wxWebViewReloadFlags flags
= 0);
61 virtual wxString
GetPageSource();
62 virtual void SetPageTitle(const wxString
& title
) { m_pageTitle
= title
; }
63 virtual wxString
GetPageTitle(){ return m_pageTitle
; }
65 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
69 virtual void LoadUrl(const wxString
& url
);
70 virtual wxString
GetCurrentURL();
71 virtual wxString
GetCurrentTitle();
72 virtual wxWebViewZoom
GetZoom();
73 virtual void SetZoom(wxWebViewZoom zoom
);
75 virtual void SetZoomType(wxWebViewZoomType zoomType
);
76 virtual wxWebViewZoomType
GetZoomType() const;
77 virtual bool CanSetZoomType(wxWebViewZoomType type
) const;
79 virtual bool IsBusy() { return m_busy
; }
81 // ---- methods not from the parent (common) interface
82 wxString
GetSelectedText();
84 wxString
RunScript(const wxString
& javascript
);
86 bool CanGetPageSource();
88 void SetScrollPos(int pos
);
91 void MakeEditable(bool enable
= true);
94 wxString
GetSelection();
96 bool CanIncreaseTextSize();
97 void IncreaseTextSize();
98 bool CanDecreaseTextSize();
99 void DecreaseTextSize();
101 float GetWebkitZoom();
102 void SetWebkitZoom(float zoom
);
104 // don't hide base class virtuals
105 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true )
106 { return wxControl::SetScrollPos(orient
, pos
, refresh
); }
107 virtual int GetScrollPos( int orient
) const
108 { return wxControl::GetScrollPos(orient
); }
110 //we need to resize the webview when the control size changes
111 void OnSize(wxSizeEvent
&event
);
112 void OnMove(wxMoveEvent
&event
);
113 void OnMouseEvents(wxMouseEvent
&event
);
118 DECLARE_EVENT_TABLE()
119 void MacVisibilityChanged();
123 wxWindowID m_windowID
;
124 wxString m_pageTitle
;
126 struct objc_object
*m_webView
;
128 // we may use this later to setup our own mouse events,
129 // so leave it in for now.
130 void* m_webKitCtrlEventHandler
;
131 //It should be WebView*, but WebView is an Objective-C class
132 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
137 // TODO: define this in setup.h ?
138 #define wxHAVE_WEB_BACKEND_OSX_WEBKIT 0
140 #endif // wxUSE_WEBKIT
142 #endif // _WX_WEBKIT_H_