]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/webview_webkit.h
Add support for loading resources in custom schemes for the WebKitGTK+ backend.
[wxWidgets.git] / include / wx / osx / webview_webkit.h
CommitLineData
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
fdc255cf
SL
18#if 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
24// ----------------------------------------------------------------------------
25// Web Kit Control
26// ----------------------------------------------------------------------------
27
61d3188b
SL
28class wxMacControl;
29class wxWidgetCocoaImpl;
30
0a6c8516 31class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView
61b98a2d
SL
32{
33public:
0a6c8516 34 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
61b98a2d 35
0a6c8516
SL
36 wxWebViewWebKit() {}
37 wxWebViewWebKit(wxWindow *parent,
61b98a2d
SL
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)
43 {
44 Create(parent, winID, strURL, pos, size, style, name);
45 }
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);
0a6c8516 52 virtual ~wxWebViewWebKit();
61b98a2d
SL
53
54 void InternalLoadURL(const wxString &url);
55
56 virtual bool CanGoBack();
57 virtual bool CanGoForward();
58 virtual void GoBack();
59 virtual void GoForward();
a703012a 60 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
61b98a2d
SL
61 virtual void Stop();
62 virtual wxString GetPageSource();
241b769f 63 virtual wxString GetPageText() { return ""; }
61b98a2d
SL
64 virtual void SetPageTitle(const wxString& title) { m_pageTitle = title; }
65 virtual wxString GetPageTitle(){ return m_pageTitle; }
66
e28cc3ca
SL
67 //We do not want to hide the other overloads
68 using wxWebView::SetPage;
61b98a2d
SL
69 virtual void SetPage(const wxString& html, const wxString& baseUrl);
70
71 virtual void Print();
72
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);
78
79 virtual void SetZoomType(wxWebViewZoomType zoomType);
80 virtual wxWebViewZoomType GetZoomType() const;
81 virtual bool CanSetZoomType(wxWebViewZoomType type) const;
82
83 virtual bool IsBusy() { return m_busy; }
0e37936e
SL
84
85 //History functions
86 virtual void ClearHistory() {}
8ba4faba 87 virtual void EnableHistory(bool enable = true);
0e37936e 88 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory()
b132a83b 89 { return wxVector<wxSharedPtr<wxWebHistoryItem> >(); }
0e37936e 90 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory()
b132a83b 91 { return wxVector<wxSharedPtr<wxWebHistoryItem> >(); }
e28cc3ca 92 virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> WXUNUSED(item)) {}
0e37936e
SL
93
94 //Undo / redo functionality
028894b4
SL
95 virtual bool CanUndo() { return false; }
96 virtual bool CanRedo() { return false; }
0e37936e
SL
97 virtual void Undo() {}
98 virtual void Redo() {}
61b98a2d 99
e2392c45 100 //Clipboard functions
028894b4
SL
101 virtual bool CanCut() { return false; }
102 virtual bool CanCopy() { return false; }
103 virtual bool CanPaste() { return false; }
104 virtual void Cut();
105 virtual void Copy();
106 virtual void Paste();
c7cbe308
SL
107
108 //Editing functions
63a65070
SL
109 virtual void SetEditable(bool enable = true);
110 virtual bool IsEditable();
111
112 //Selection
113 virtual void DeleteSelection();
7bd30a12 114 virtual bool HasSelection();
63a65070 115 virtual void SelectAll() {};
c9355a3d 116 virtual wxString GetSelectedText();
97ba4d81 117 virtual wxString GetSelectedSource() { return ""; }
41933aa5 118 virtual void ClearSelection() {}
c9ccc09c
SL
119
120 void RunScript(const wxString& javascript);
eff8f795
SL
121
122 //Virtual Filesystem Support
e28cc3ca 123 virtual void RegisterHandler(wxWebHandler* WXUNUSED(handler)) {};
e2392c45 124
61b98a2d 125 // ---- methods not from the parent (common) interface
61b98a2d
SL
126 bool CanGetPageSource();
127
128 void SetScrollPos(int pos);
129 int GetScrollPos();
130
61b98a2d
SL
131 wxString GetSelection();
132
133 bool CanIncreaseTextSize();
134 void IncreaseTextSize();
135 bool CanDecreaseTextSize();
136 void DecreaseTextSize();
137
138 float GetWebkitZoom();
139 void SetWebkitZoom(float zoom);
140
141 // don't hide base class virtuals
142 virtual void SetScrollPos( int orient, int pos, bool refresh = true )
143 { return wxControl::SetScrollPos(orient, pos, refresh); }
144 virtual int GetScrollPos( int orient ) const
145 { return wxControl::GetScrollPos(orient); }
146
147 //we need to resize the webview when the control size changes
148 void OnSize(wxSizeEvent &event);
149 void OnMove(wxMoveEvent &event);
150 void OnMouseEvents(wxMouseEvent &event);
151
152 bool m_busy;
153
154protected:
155 DECLARE_EVENT_TABLE()
156 void MacVisibilityChanged();
157
158private:
159 wxWindow *m_parent;
160 wxWindowID m_windowID;
161 wxString m_pageTitle;
162
163 struct objc_object *m_webView;
164
165 // we may use this later to setup our own mouse events,
166 // so leave it in for now.
167 void* m_webKitCtrlEventHandler;
168 //It should be WebView*, but WebView is an Objective-C class
169 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
b132a83b
SL
170
171#if wxOSX_USE_CARBON
172 wxMacControl *m_peer;
173#else
174 wxWidgetCocoaImpl *m_peer;
175#endif
61b98a2d
SL
176};
177
47943187 178#endif // wxUSE_WEBKIT
61b98a2d
SL
179
180#endif // _WX_WEBKIT_H_