1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/osx/webkit.h
3 // Purpose: wxWebViewWebKit - 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_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
19 || defined(__WXOSX_CARBON__))
21 #include "wx/control.h"
22 #include "wx/webview.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit
: public wxWebView
31 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
34 wxWebViewWebKit(wxWindow
*parent
,
35 wxWindowID winID
= wxID_ANY
,
36 const wxString
& strURL
= wxWebViewDefaultURLStr
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
, long style
= 0,
39 const wxString
& name
= wxWebViewNameStr
)
41 Create(parent
, winID
, strURL
, pos
, size
, style
, name
);
43 bool Create(wxWindow
*parent
,
44 wxWindowID winID
= wxID_ANY
,
45 const wxString
& strURL
= wxWebViewDefaultURLStr
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
, long style
= 0,
48 const wxString
& name
= wxWebViewNameStr
);
49 virtual ~wxWebViewWebKit();
51 virtual bool CanGoBack() const;
52 virtual bool CanGoForward() const;
53 virtual void GoBack();
54 virtual void GoForward();
55 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
57 virtual wxString
GetPageSource() const;
58 virtual wxString
GetPageText() const;
60 //We do not want to hide the other overloads
61 using wxWebView::SetPage
;
62 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
66 virtual void LoadURL(const wxString
& url
);
67 virtual wxString
GetCurrentURL() const;
68 virtual wxString
GetCurrentTitle() const;
69 virtual wxWebViewZoom
GetZoom() const;
70 virtual void SetZoom(wxWebViewZoom zoom
);
72 virtual void SetZoomType(wxWebViewZoomType zoomType
);
73 virtual wxWebViewZoomType
GetZoomType() const;
74 virtual bool CanSetZoomType(wxWebViewZoomType type
) const;
76 virtual bool IsBusy() const { return m_busy
; }
79 virtual void ClearHistory();
80 virtual void EnableHistory(bool enable
= true);
81 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetBackwardHistory();
82 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetForwardHistory();
83 virtual void LoadHistoryItem(wxSharedPtr
<wxWebViewHistoryItem
> item
);
85 //Undo / redo functionality
86 virtual bool CanUndo() const;
87 virtual bool CanRedo() const;
92 virtual bool CanCut() const { return true; }
93 virtual bool CanCopy() const { return true; }
94 virtual bool CanPaste() const { return true; }
100 virtual void SetEditable(bool enable
= true);
101 virtual bool IsEditable() const;
104 virtual void DeleteSelection();
105 virtual bool HasSelection() const;
106 virtual void SelectAll();
107 virtual wxString
GetSelectedText() const;
108 virtual wxString
GetSelectedSource() const;
109 virtual void ClearSelection();
111 void RunScript(const wxString
& javascript
);
113 //Virtual Filesystem Support
114 virtual void RegisterHandler(wxSharedPtr
<wxWebViewHandler
> handler
);
116 // ---- methods not from the parent (common) interface
117 bool CanGetPageSource() const;
119 void SetScrollPos(int pos
);
122 bool CanIncreaseTextSize() const;
123 void IncreaseTextSize();
124 bool CanDecreaseTextSize() const;
125 void DecreaseTextSize();
127 float GetWebkitZoom() const;
128 void SetWebkitZoom(float zoom
);
130 // don't hide base class virtuals
131 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true )
132 { return wxControl::SetScrollPos(orient
, pos
, refresh
); }
133 virtual int GetScrollPos( int orient
) const
134 { return wxControl::GetScrollPos(orient
); }
136 //we need to resize the webview when the control size changes
137 void OnSize(wxSizeEvent
&event
);
138 void OnMove(wxMoveEvent
&event
);
139 void OnMouseEvents(wxMouseEvent
&event
);
144 DECLARE_EVENT_TABLE()
145 void MacVisibilityChanged();
149 wxWindowID m_windowID
;
150 wxString m_pageTitle
;
152 struct objc_object
*m_webView
;
154 // we may use this later to setup our own mouse events,
155 // so leave it in for now.
156 void* m_webKitCtrlEventHandler
;
157 //It should be WebView*, but WebView is an Objective-C class
158 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
161 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
163 #endif // _WX_WEBKIT_H_