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 // ----------------------------------------------------------------------------
27 class WXDLLIMPEXP_WEB wxWebViewWebKit
: public wxWebView
30 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
33 wxWebViewWebKit(wxWindow
*parent
,
34 wxWindowID winID
= wxID_ANY
,
35 const wxString
& strURL
= wxWebViewDefaultURLStr
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
, long style
= 0,
38 const wxString
& name
= wxWebViewNameStr
)
40 Create(parent
, winID
, strURL
, pos
, size
, style
, name
);
42 bool Create(wxWindow
*parent
,
43 wxWindowID winID
= wxID_ANY
,
44 const wxString
& strURL
= wxWebViewDefaultURLStr
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
, long style
= 0,
47 const wxString
& name
= wxWebViewNameStr
);
48 virtual ~wxWebViewWebKit();
50 void InternalLoadURL(const wxString
&url
);
52 virtual bool CanGoBack();
53 virtual bool CanGoForward();
54 virtual void GoBack();
55 virtual void GoForward();
56 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
58 virtual wxString
GetPageSource();
59 virtual void SetPageTitle(const wxString
& title
) { m_pageTitle
= title
; }
60 virtual wxString
GetPageTitle(){ return m_pageTitle
; }
62 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
66 virtual void LoadUrl(const wxString
& url
);
67 virtual wxString
GetCurrentURL();
68 virtual wxString
GetCurrentTitle();
69 virtual wxWebViewZoom
GetZoom();
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() { return m_busy
; }
79 virtual void ClearHistory() {}
80 virtual void EnableHistory(bool enable
= true) {}
81 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory()
82 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >() }
83 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory()
84 { return wxVector
<wxSharedPtr
<wxWebHistoryItem
> >() }
85 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
) {}
87 //Undo / redo functionality
88 virtual bool CanUndo() { return false; }
89 virtual bool CanRedo() { return false; }
90 virtual void Undo() {}
91 virtual void Redo() {}
94 virtual bool CanCut() { return false; }
95 virtual bool CanCopy() { return false; }
96 virtual bool CanPaste() { return false; }
102 virtual void SetEditable(bool enable
= true);
103 virtual bool IsEditable();
106 virtual void DeleteSelection();
107 virtual bool HasSelection() { return false };
108 virtual void SelectAll() {};
110 // ---- methods not from the parent (common) interface
111 wxString
GetSelectedText();
113 wxString
RunScript(const wxString
& javascript
);
115 bool CanGetPageSource();
117 void SetScrollPos(int pos
);
120 wxString
GetSelection();
122 bool CanIncreaseTextSize();
123 void IncreaseTextSize();
124 bool CanDecreaseTextSize();
125 void DecreaseTextSize();
127 float GetWebkitZoom();
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_WEBKIT
163 #endif // _WX_WEBKIT_H_