]>
Commit | Line | Data |
---|---|---|
61b98a2d SL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: include/wx/osx/webkit.h | |
0a6c8516 | 3 | // Purpose: wxWebViewWebKit - embeddable web kit control, |
61b98a2d SL |
4 | // OS X implementation of web view component |
5 | // Author: Jethro Grassie / Kevin Ollivier / Marianne Gagnon | |
6 | // Modified by: | |
7 | // Created: 2004-4-16 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Jethro Grassie / Kevin Ollivier / Marianne Gagnon | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_WEBKIT_H | |
14 | #define _WX_WEBKIT_H | |
15 | ||
16 | #include "wx/setup.h" | |
17 | ||
9d2f31db SL |
18 | #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \ |
19 | || defined(__WXOSX_CARBON__)) | |
61b98a2d | 20 | |
61b98a2d SL |
21 | #include "wx/control.h" |
22 | #include "wx/webview.h" | |
23 | ||
fcb9299b | 24 | #include "wx/osx/core/objcid.h" |
d92f48bd | 25 | |
61b98a2d SL |
26 | // ---------------------------------------------------------------------------- |
27 | // Web Kit Control | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
467d261e | 30 | class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView |
61b98a2d SL |
31 | { |
32 | public: | |
0a6c8516 | 33 | wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); |
61b98a2d | 34 | |
0a6c8516 SL |
35 | wxWebViewWebKit() {} |
36 | wxWebViewWebKit(wxWindow *parent, | |
61b98a2d SL |
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) | |
42 | { | |
43 | Create(parent, winID, strURL, pos, size, style, name); | |
44 | } | |
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); | |
0a6c8516 | 51 | virtual ~wxWebViewWebKit(); |
61b98a2d | 52 | |
e669ddde SL |
53 | virtual bool CanGoBack() const; |
54 | virtual bool CanGoForward() const; | |
61b98a2d SL |
55 | virtual void GoBack(); |
56 | virtual void GoForward(); | |
236cff73 | 57 | virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT); |
61b98a2d | 58 | virtual void Stop(); |
e669ddde SL |
59 | virtual wxString GetPageSource() const; |
60 | virtual wxString GetPageText() const; | |
61b98a2d | 61 | |
61b98a2d SL |
62 | virtual void Print(); |
63 | ||
4d0dddc7 | 64 | virtual void LoadURL(const wxString& url); |
e669ddde SL |
65 | virtual wxString GetCurrentURL() const; |
66 | virtual wxString GetCurrentTitle() const; | |
67 | virtual wxWebViewZoom GetZoom() const; | |
61b98a2d SL |
68 | virtual void SetZoom(wxWebViewZoom zoom); |
69 | ||
70 | virtual void SetZoomType(wxWebViewZoomType zoomType); | |
71 | virtual wxWebViewZoomType GetZoomType() const; | |
72 | virtual bool CanSetZoomType(wxWebViewZoomType type) const; | |
73 | ||
e669ddde | 74 | virtual bool IsBusy() const { return m_busy; } |
34326da7 | 75 | |
0e37936e | 76 | //History functions |
7c36630b | 77 | virtual void ClearHistory(); |
8ba4faba | 78 | virtual void EnableHistory(bool enable = true); |
c13d6ac1 SL |
79 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory(); |
80 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory(); | |
81 | virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item); | |
34326da7 | 82 | |
0e37936e | 83 | //Undo / redo functionality |
e669ddde SL |
84 | virtual bool CanUndo() const; |
85 | virtual bool CanRedo() const; | |
6368d965 SL |
86 | virtual void Undo(); |
87 | virtual void Redo(); | |
61b98a2d | 88 | |
66ac0400 | 89 | //Find function |
236cff73 | 90 | virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT) |
fc95c9f7 SL |
91 | { |
92 | wxUnusedVar(text); | |
93 | wxUnusedVar(flags); | |
94 | return wxNOT_FOUND; | |
95 | } | |
66ac0400 | 96 | |
e2392c45 | 97 | //Clipboard functions |
6849a4b7 SL |
98 | virtual bool CanCut() const { return true; } |
99 | virtual bool CanCopy() const { return true; } | |
100 | virtual bool CanPaste() const { return true; } | |
028894b4 SL |
101 | virtual void Cut(); |
102 | virtual void Copy(); | |
103 | virtual void Paste(); | |
34326da7 | 104 | |
c7cbe308 | 105 | //Editing functions |
63a65070 | 106 | virtual void SetEditable(bool enable = true); |
e669ddde | 107 | virtual bool IsEditable() const; |
34326da7 | 108 | |
63a65070 SL |
109 | //Selection |
110 | virtual void DeleteSelection(); | |
e669ddde | 111 | virtual bool HasSelection() const; |
835165d5 | 112 | virtual void SelectAll(); |
e669ddde SL |
113 | virtual wxString GetSelectedText() const; |
114 | virtual wxString GetSelectedSource() const; | |
ef53bf2a | 115 | virtual void ClearSelection(); |
34326da7 | 116 | |
c9ccc09c | 117 | void RunScript(const wxString& javascript); |
34326da7 | 118 | |
eff8f795 | 119 | //Virtual Filesystem Support |
7d8d6163 | 120 | virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler); |
e2392c45 | 121 | |
b6a49c2b VZ |
122 | virtual void* GetNativeBackend() const { return m_webView; } |
123 | ||
61b98a2d | 124 | // ---- methods not from the parent (common) interface |
e669ddde | 125 | bool CanGetPageSource() const; |
61b98a2d SL |
126 | |
127 | void SetScrollPos(int pos); | |
128 | int GetScrollPos(); | |
129 | ||
e669ddde | 130 | bool CanIncreaseTextSize() const; |
61b98a2d | 131 | void IncreaseTextSize(); |
e669ddde | 132 | bool CanDecreaseTextSize() const; |
61b98a2d SL |
133 | void DecreaseTextSize(); |
134 | ||
e669ddde | 135 | float GetWebkitZoom() const; |
61b98a2d SL |
136 | void SetWebkitZoom(float zoom); |
137 | ||
138 | // don't hide base class virtuals | |
139 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ) | |
140 | { return wxControl::SetScrollPos(orient, pos, refresh); } | |
141 | virtual int GetScrollPos( int orient ) const | |
142 | { return wxControl::GetScrollPos(orient); } | |
143 | ||
144 | //we need to resize the webview when the control size changes | |
145 | void OnSize(wxSizeEvent &event); | |
146 | void OnMove(wxMoveEvent &event); | |
147 | void OnMouseEvents(wxMouseEvent &event); | |
148 | ||
149 | bool m_busy; | |
150 | ||
151 | protected: | |
a977376a VZ |
152 | virtual void DoSetPage(const wxString& html, const wxString& baseUrl); |
153 | ||
61b98a2d SL |
154 | DECLARE_EVENT_TABLE() |
155 | void MacVisibilityChanged(); | |
156 | ||
157 | private: | |
158 | wxWindow *m_parent; | |
159 | wxWindowID m_windowID; | |
160 | wxString m_pageTitle; | |
161 | ||
d92f48bd | 162 | wxObjCID m_webView; |
61b98a2d SL |
163 | |
164 | // we may use this later to setup our own mouse events, | |
165 | // so leave it in for now. | |
166 | void* m_webKitCtrlEventHandler; | |
167 | //It should be WebView*, but WebView is an Objective-C class | |
168 | //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this. | |
169 | }; | |
170 | ||
4c687fff SL |
171 | class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory |
172 | { | |
173 | public: | |
174 | virtual wxWebView* Create() { return new wxWebViewWebKit; } | |
175 | virtual wxWebView* Create(wxWindow* parent, | |
176 | wxWindowID id, | |
177 | const wxString& url = wxWebViewDefaultURLStr, | |
178 | const wxPoint& pos = wxDefaultPosition, | |
179 | const wxSize& size = wxDefaultSize, | |
180 | long style = 0, | |
181 | const wxString& name = wxWebViewNameStr) | |
182 | { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); } | |
183 | }; | |
184 | ||
34326da7 | 185 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT |
61b98a2d SL |
186 | |
187 | #endif // _WX_WEBKIT_H_ |