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_WEBKIT && (defined(__WXOSX_COCOA__) \
19 || defined(__WXOSX_CARBON__))
21 #include "wx/control.h"
22 #include "wx/webview.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
29 class wxWidgetCocoaImpl
;
31 class WXDLLIMPEXP_WEB wxWebViewWebKit
: public wxWebView
34 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
37 wxWebViewWebKit(wxWindow
*parent
,
38 wxWindowID winID
= wxID_ANY
,
39 const wxString
& strURL
= wxWebViewDefaultURLStr
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
, long style
= 0,
42 const wxString
& name
= wxWebViewNameStr
)
44 Create(parent
, winID
, strURL
, pos
, size
, style
, name
);
46 bool Create(wxWindow
*parent
,
47 wxWindowID winID
= wxID_ANY
,
48 const wxString
& strURL
= wxWebViewDefaultURLStr
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
, long style
= 0,
51 const wxString
& name
= wxWebViewNameStr
);
52 virtual ~wxWebViewWebKit();
54 void InternalLoadURL(const wxString
&url
);
56 virtual bool CanGoBack();
57 virtual bool CanGoForward();
58 virtual void GoBack();
59 virtual void GoForward();
60 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
62 virtual wxString
GetPageSource();
63 virtual wxString
GetPageText() { return ""; }
64 virtual void SetPageTitle(const wxString
& title
) { m_pageTitle
= title
; }
65 virtual wxString
GetPageTitle(){ return m_pageTitle
; }
67 //We do not want to hide the other overloads
68 using wxWebView::SetPage
;
69 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
73 virtual void LoadUrl(const wxString
& url
);
74 virtual wxString
GetCurrentURL();
75 virtual wxString
GetCurrentTitle();
76 virtual wxWebViewZoom
GetZoom();
77 virtual void SetZoom(wxWebViewZoom zoom
);
79 virtual void SetZoomType(wxWebViewZoomType zoomType
);
80 virtual wxWebViewZoomType
GetZoomType() const;
81 virtual bool CanSetZoomType(wxWebViewZoomType type
) const;
83 virtual bool IsBusy() { return m_busy
; }
86 virtual void ClearHistory();
87 virtual void EnableHistory(bool enable
= true);
88 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory()
89 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >(); }
90 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory()
91 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >(); }
92 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> WXUNUSED(item
)) {}
94 //Undo / redo functionality
95 virtual bool CanUndo();
96 virtual bool CanRedo();
100 //Clipboard functions
101 virtual bool CanCut() { return false; }
102 virtual bool CanCopy() { return false; }
103 virtual bool CanPaste() { return false; }
106 virtual void Paste();
109 virtual void SetEditable(bool enable
= true);
110 virtual bool IsEditable();
113 virtual void DeleteSelection();
114 virtual bool HasSelection();
115 virtual void SelectAll() {};
116 virtual wxString
GetSelectedText();
117 virtual wxString
GetSelectedSource() { return ""; }
118 virtual void ClearSelection() {}
120 void RunScript(const wxString
& javascript
);
122 //Virtual Filesystem Support
123 virtual void RegisterHandler(wxWebHandler
* WXUNUSED(handler
)) {};
125 // ---- methods not from the parent (common) interface
126 bool CanGetPageSource();
128 void SetScrollPos(int pos
);
131 bool CanIncreaseTextSize();
132 void IncreaseTextSize();
133 bool CanDecreaseTextSize();
134 void DecreaseTextSize();
136 float GetWebkitZoom();
137 void SetWebkitZoom(float zoom
);
139 // don't hide base class virtuals
140 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true )
141 { return wxControl::SetScrollPos(orient
, pos
, refresh
); }
142 virtual int GetScrollPos( int orient
) const
143 { return wxControl::GetScrollPos(orient
); }
145 //we need to resize the webview when the control size changes
146 void OnSize(wxSizeEvent
&event
);
147 void OnMove(wxMoveEvent
&event
);
148 void OnMouseEvents(wxMouseEvent
&event
);
153 DECLARE_EVENT_TABLE()
154 void MacVisibilityChanged();
158 wxWindowID m_windowID
;
159 wxString m_pageTitle
;
161 struct objc_object
*m_webView
;
163 // we may use this later to setup our own mouse events,
164 // so leave it in for now.
165 void* m_webKitCtrlEventHandler
;
166 //It should be WebView*, but WebView is an Objective-C class
167 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
170 wxMacControl
*m_peer
;
172 wxWidgetCocoaImpl
*m_peer
;
176 #endif // wxUSE_WEBKIT
178 #endif // _WX_WEBKIT_H_