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 #include "wx/osx/private/objcid.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit
: public wxWebView
33 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
36 wxWebViewWebKit(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 ~wxWebViewWebKit();
53 virtual bool CanGoBack() const;
54 virtual bool CanGoForward() const;
55 virtual void GoBack();
56 virtual void GoForward();
57 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
59 virtual wxString
GetPageSource() const;
60 virtual wxString
GetPageText() const;
62 //We do not want to hide the other overloads
63 using wxWebView::SetPage
;
64 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
68 virtual void LoadURL(const wxString
& url
);
69 virtual wxString
GetCurrentURL() const;
70 virtual wxString
GetCurrentTitle() const;
71 virtual wxWebViewZoom
GetZoom() const;
72 virtual void SetZoom(wxWebViewZoom zoom
);
74 virtual void SetZoomType(wxWebViewZoomType zoomType
);
75 virtual wxWebViewZoomType
GetZoomType() const;
76 virtual bool CanSetZoomType(wxWebViewZoomType type
) const;
78 virtual bool IsBusy() const { return m_busy
; }
81 virtual void ClearHistory();
82 virtual void EnableHistory(bool enable
= true);
83 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetBackwardHistory();
84 virtual wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > GetForwardHistory();
85 virtual void LoadHistoryItem(wxSharedPtr
<wxWebViewHistoryItem
> item
);
87 //Undo / redo functionality
88 virtual bool CanUndo() const;
89 virtual bool CanRedo() const;
94 virtual bool CanCut() const { return true; }
95 virtual bool CanCopy() const { return true; }
96 virtual bool CanPaste() const { return true; }
102 virtual void SetEditable(bool enable
= true);
103 virtual bool IsEditable() const;
106 virtual void DeleteSelection();
107 virtual bool HasSelection() const;
108 virtual void SelectAll();
109 virtual wxString
GetSelectedText() const;
110 virtual wxString
GetSelectedSource() const;
111 virtual void ClearSelection();
113 void RunScript(const wxString
& javascript
);
115 //Virtual Filesystem Support
116 virtual void RegisterHandler(wxSharedPtr
<wxWebViewHandler
> handler
);
118 // ---- methods not from the parent (common) interface
119 bool CanGetPageSource() const;
121 void SetScrollPos(int pos
);
124 bool CanIncreaseTextSize() const;
125 void IncreaseTextSize();
126 bool CanDecreaseTextSize() const;
127 void DecreaseTextSize();
129 float GetWebkitZoom() const;
130 void SetWebkitZoom(float zoom
);
132 // don't hide base class virtuals
133 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true )
134 { return wxControl::SetScrollPos(orient
, pos
, refresh
); }
135 virtual int GetScrollPos( int orient
) const
136 { return wxControl::GetScrollPos(orient
); }
138 //we need to resize the webview when the control size changes
139 void OnSize(wxSizeEvent
&event
);
140 void OnMove(wxMoveEvent
&event
);
141 void OnMouseEvents(wxMouseEvent
&event
);
146 DECLARE_EVENT_TABLE()
147 void MacVisibilityChanged();
151 wxWindowID m_windowID
;
152 wxString m_pageTitle
;
156 // we may use this later to setup our own mouse events,
157 // so leave it in for now.
158 void* m_webKitCtrlEventHandler
;
159 //It should be WebView*, but WebView is an Objective-C class
160 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
163 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
165 #endif // _WX_WEBKIT_H_