]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/webview_webkit.h
Add wxWebView::GetNativeBackend() method.
[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 && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
19 || defined(__WXOSX_CARBON__))
20
21 #include "wx/control.h"
22 #include "wx/webview.h"
23
24 #include "wx/osx/core/objcid.h"
25
26 // ----------------------------------------------------------------------------
27 // Web Kit Control
28 // ----------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_WEBVIEW 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 virtual bool CanGoBack() const;
54 virtual bool CanGoForward() const;
55 virtual void GoBack();
56 virtual void GoForward();
57 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
58 virtual void Stop();
59 virtual wxString GetPageSource() const;
60 virtual wxString GetPageText() const;
61
62 virtual void Print();
63
64 virtual void LoadURL(const wxString& url);
65 virtual wxString GetCurrentURL() const;
66 virtual wxString GetCurrentTitle() const;
67 virtual wxWebViewZoom GetZoom() const;
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
74 virtual bool IsBusy() const { return m_busy; }
75
76 //History functions
77 virtual void ClearHistory();
78 virtual void EnableHistory(bool enable = true);
79 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
80 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
81 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
82
83 //Undo / redo functionality
84 virtual bool CanUndo() const;
85 virtual bool CanRedo() const;
86 virtual void Undo();
87 virtual void Redo();
88
89 //Clipboard functions
90 virtual bool CanCut() const { return true; }
91 virtual bool CanCopy() const { return true; }
92 virtual bool CanPaste() const { return true; }
93 virtual void Cut();
94 virtual void Copy();
95 virtual void Paste();
96
97 //Editing functions
98 virtual void SetEditable(bool enable = true);
99 virtual bool IsEditable() const;
100
101 //Selection
102 virtual void DeleteSelection();
103 virtual bool HasSelection() const;
104 virtual void SelectAll();
105 virtual wxString GetSelectedText() const;
106 virtual wxString GetSelectedSource() const;
107 virtual void ClearSelection();
108
109 void RunScript(const wxString& javascript);
110
111 //Virtual Filesystem Support
112 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
113
114 virtual void* GetNativeBackend() const { return m_webView; }
115
116 // ---- methods not from the parent (common) interface
117 bool CanGetPageSource() const;
118
119 void SetScrollPos(int pos);
120 int GetScrollPos();
121
122 bool CanIncreaseTextSize() const;
123 void IncreaseTextSize();
124 bool CanDecreaseTextSize() const;
125 void DecreaseTextSize();
126
127 float GetWebkitZoom() const;
128 void SetWebkitZoom(float zoom);
129
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); }
135
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);
140
141 bool m_busy;
142
143 protected:
144 virtual void DoSetPage(const wxString& html, const wxString& baseUrl);
145
146 DECLARE_EVENT_TABLE()
147 void MacVisibilityChanged();
148
149 private:
150 wxWindow *m_parent;
151 wxWindowID m_windowID;
152 wxString m_pageTitle;
153
154 wxObjCID m_webView;
155
156 // we may use this later to setup our own mouse events,
157 // so leave it in for now.
158 void* m_webKitCtrlEventHandler;
159 //It should be WebView*, but WebView is an Objective-C class
160 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
161 };
162
163 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
164
165 #endif // _WX_WEBKIT_H_