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_WEBKIT && (defined(__WXMAC__) || defined(__WXCOCOA__))
20 #include "wx/control.h"
21 #include "wx/webview.h"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
28 class wxWidgetCocoaImpl
;
30 class WXDLLIMPEXP_WEB 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 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
= wxWEB_VIEW_RELOAD_DEFAULT
);
61 virtual wxString
GetPageSource();
62 virtual wxString
GetPageText() { return ""; }
63 virtual void SetPageTitle(const wxString
& title
) { m_pageTitle
= title
; }
64 virtual wxString
GetPageTitle(){ return m_pageTitle
; }
66 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
70 virtual void LoadUrl(const wxString
& url
);
71 virtual wxString
GetCurrentURL();
72 virtual wxString
GetCurrentTitle();
73 virtual wxWebViewZoom
GetZoom();
74 virtual void SetZoom(wxWebViewZoom zoom
);
76 virtual void SetZoomType(wxWebViewZoomType zoomType
);
77 virtual wxWebViewZoomType
GetZoomType() const;
78 virtual bool CanSetZoomType(wxWebViewZoomType type
) const;
80 virtual bool IsBusy() { return m_busy
; }
83 virtual void ClearHistory() {}
84 virtual void EnableHistory(bool enable
= true) {}
85 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory()
86 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >(); }
87 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory()
88 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >(); }
89 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
) {}
91 //Undo / redo functionality
92 virtual bool CanUndo() { return false; }
93 virtual bool CanRedo() { return false; }
94 virtual void Undo() {}
95 virtual void Redo() {}
98 virtual bool CanCut() { return false; }
99 virtual bool CanCopy() { return false; }
100 virtual bool CanPaste() { return false; }
103 virtual void Paste();
106 virtual void SetEditable(bool enable
= true);
107 virtual bool IsEditable();
110 virtual void DeleteSelection();
111 virtual bool HasSelection() { return false; };
112 virtual void SelectAll() {};
113 virtual wxString
GetSelectedText();
114 virtual wxString
GetSelectedSource() { return ""; }
115 virtual void ClearSelection() {}
117 void RunScript(const wxString
& javascript
);
119 // ---- methods not from the parent (common) interface
120 bool CanGetPageSource();
122 void SetScrollPos(int pos
);
125 wxString
GetSelection();
127 bool CanIncreaseTextSize();
128 void IncreaseTextSize();
129 bool CanDecreaseTextSize();
130 void DecreaseTextSize();
132 float GetWebkitZoom();
133 void SetWebkitZoom(float zoom
);
135 // don't hide base class virtuals
136 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true )
137 { return wxControl::SetScrollPos(orient
, pos
, refresh
); }
138 virtual int GetScrollPos( int orient
) const
139 { return wxControl::GetScrollPos(orient
); }
141 //we need to resize the webview when the control size changes
142 void OnSize(wxSizeEvent
&event
);
143 void OnMove(wxMoveEvent
&event
);
144 void OnMouseEvents(wxMouseEvent
&event
);
149 DECLARE_EVENT_TABLE()
150 void MacVisibilityChanged();
154 wxWindowID m_windowID
;
155 wxString m_pageTitle
;
157 struct objc_object
*m_webView
;
159 // we may use this later to setup our own mouse events,
160 // so leave it in for now.
161 void* m_webKitCtrlEventHandler
;
162 //It should be WebView*, but WebView is an Objective-C class
163 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
166 wxMacControl
*m_peer
;
168 wxWidgetCocoaImpl
*m_peer
;
172 //#endif // wxUSE_WEBKIT
174 #endif // _WX_WEBKIT_H_