]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/webview_webkit.h
Remove SetPageTitle and GetPageTitle and make GetCurrentTitle actually return the...
[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_COCOA__) \
19 || defined(__WXOSX_CARBON__))
20
21 #include "wx/control.h"
22 #include "wx/webview.h"
23
24 // ----------------------------------------------------------------------------
25 // Web Kit Control
26 // ----------------------------------------------------------------------------
27
28 class wxMacControl;
29 class wxWidgetCocoaImpl;
30
31 class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView
32 {
33 public:
34 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
35
36 wxWebViewWebKit() {}
37 wxWebViewWebKit(wxWindow *parent,
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);
52 virtual ~wxWebViewWebKit();
53
54 void InternalLoadURL(const wxString &url);
55
56 virtual bool CanGoBack();
57 virtual bool CanGoForward();
58 virtual void GoBack();
59 virtual void GoForward();
60 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
61 virtual void Stop();
62 virtual wxString GetPageSource();
63 virtual wxString GetPageText() { return ""; }
64
65 //We do not want to hide the other overloads
66 using wxWebView::SetPage;
67 virtual void SetPage(const wxString& html, const wxString& baseUrl);
68
69 virtual void Print();
70
71 virtual void LoadUrl(const wxString& url);
72 virtual wxString GetCurrentURL();
73 virtual wxString GetCurrentTitle();
74 virtual wxWebViewZoom GetZoom();
75 virtual void SetZoom(wxWebViewZoom zoom);
76
77 virtual void SetZoomType(wxWebViewZoomType zoomType);
78 virtual wxWebViewZoomType GetZoomType() const;
79 virtual bool CanSetZoomType(wxWebViewZoomType type) const;
80
81 virtual bool IsBusy() { return m_busy; }
82
83 //History functions
84 virtual void ClearHistory();
85 virtual void EnableHistory(bool enable = true);
86 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory();
87 virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory();
88 virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
89
90 //Undo / redo functionality
91 virtual bool CanUndo();
92 virtual bool CanRedo();
93 virtual void Undo();
94 virtual void Redo();
95
96 //Clipboard functions
97 virtual bool CanCut() { return false; }
98 virtual bool CanCopy() { return false; }
99 virtual bool CanPaste() { return false; }
100 virtual void Cut();
101 virtual void Copy();
102 virtual void Paste();
103
104 //Editing functions
105 virtual void SetEditable(bool enable = true);
106 virtual bool IsEditable();
107
108 //Selection
109 virtual void DeleteSelection();
110 virtual bool HasSelection();
111 virtual void SelectAll() {};
112 virtual wxString GetSelectedText();
113 virtual wxString GetSelectedSource() { return ""; }
114 virtual void ClearSelection() {}
115
116 void RunScript(const wxString& javascript);
117
118 //Virtual Filesystem Support
119 virtual void RegisterHandler(wxWebHandler* WXUNUSED(handler)) {};
120
121 // ---- methods not from the parent (common) interface
122 bool CanGetPageSource();
123
124 void SetScrollPos(int pos);
125 int GetScrollPos();
126
127 bool CanIncreaseTextSize();
128 void IncreaseTextSize();
129 bool CanDecreaseTextSize();
130 void DecreaseTextSize();
131
132 float GetWebkitZoom();
133 void SetWebkitZoom(float zoom);
134
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); }
140
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);
145
146 bool m_busy;
147
148 protected:
149 DECLARE_EVENT_TABLE()
150 void MacVisibilityChanged();
151
152 private:
153 wxWindow *m_parent;
154 wxWindowID m_windowID;
155 wxString m_pageTitle;
156
157 struct objc_object *m_webView;
158
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.
164
165 #if wxOSX_USE_CARBON
166 wxMacControl *m_peer;
167 #else
168 wxWidgetCocoaImpl *m_peer;
169 #endif
170 };
171
172 #endif // wxUSE_WEBKIT
173
174 #endif // _WX_WEBKIT_H_