]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/webview_webkit.h
Rework the GTK WebKit backend history to remove the need for the map between wxWebHis...
[wxWidgets.git] / include / wx / osx / webview_webkit.h
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
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
18 #if wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX_MAC__)
19
20 #include "wx/control.h"
21 #include "wx/webview.h"
22
23 // ----------------------------------------------------------------------------
24 // Web Kit Control
25 // ----------------------------------------------------------------------------
26
27 class wxMacControl;
28 class wxWidgetCocoaImpl;
29
30 class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView
31 {
32 public:
33 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
34
35 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)
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);
51 virtual ~wxWebViewWebKit();
52
53 void InternalLoadURL(const wxString &url);
54
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);
60 virtual void Stop();
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; }
65
66 virtual void SetPage(const wxString& html, const wxString& baseUrl);
67
68 virtual void Print();
69
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);
75
76 virtual void SetZoomType(wxWebViewZoomType zoomType);
77 virtual wxWebViewZoomType GetZoomType() const;
78 virtual bool CanSetZoomType(wxWebViewZoomType type) const;
79
80 virtual bool IsBusy() { return m_busy; }
81
82 //History functions
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) {}
90
91 //Undo / redo functionality
92 virtual bool CanUndo() { return false; }
93 virtual bool CanRedo() { return false; }
94 virtual void Undo() {}
95 virtual void Redo() {}
96
97 //Clipboard functions
98 virtual bool CanCut() { return false; }
99 virtual bool CanCopy() { return false; }
100 virtual bool CanPaste() { return false; }
101 virtual void Cut();
102 virtual void Copy();
103 virtual void Paste();
104
105 //Editing functions
106 virtual void SetEditable(bool enable = true);
107 virtual bool IsEditable();
108
109 //Selection
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() {}
116
117 void RunScript(const wxString& javascript);
118
119 //Virtual Filesystem Support
120 virtual void RegisterHandler(wxWebHandler* handler) {};
121
122 // ---- methods not from the parent (common) interface
123 bool CanGetPageSource();
124
125 void SetScrollPos(int pos);
126 int GetScrollPos();
127
128 wxString GetSelection();
129
130 bool CanIncreaseTextSize();
131 void IncreaseTextSize();
132 bool CanDecreaseTextSize();
133 void DecreaseTextSize();
134
135 float GetWebkitZoom();
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:
152 DECLARE_EVENT_TABLE()
153 void MacVisibilityChanged();
154
155 private:
156 wxWindow *m_parent;
157 wxWindowID m_windowID;
158 wxString m_pageTitle;
159
160 struct objc_object *m_webView;
161
162 // we may use this later to setup our own mouse events,
163 // so leave it in for now.
164 void* m_webKitCtrlEventHandler;
165 //It should be WebView*, but WebView is an Objective-C class
166 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
167
168 #if wxOSX_USE_CARBON
169 wxMacControl *m_peer;
170 #else
171 wxWidgetCocoaImpl *m_peer;
172 #endif
173 };
174
175 #endif // wxUSE_WEBKIT
176
177 #endif // _WX_WEBKIT_H_