]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/webview_webkit.h
removing NSWindow based mouse tracking in favour of 10.5+ trackingArea implementation
[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 // ----------------------------------------------------------------------------
25 // Web Kit Control
26 // ----------------------------------------------------------------------------
27
28 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
29 {
30 public:
31 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
32
33 wxWebViewWebKit() {}
34 wxWebViewWebKit(wxWindow *parent,
35 wxWindowID winID = wxID_ANY,
36 const wxString& strURL = wxWebViewDefaultURLStr,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize, long style = 0,
39 const wxString& name = wxWebViewNameStr)
40 {
41 Create(parent, winID, strURL, pos, size, style, name);
42 }
43 bool Create(wxWindow *parent,
44 wxWindowID winID = wxID_ANY,
45 const wxString& strURL = wxWebViewDefaultURLStr,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize, long style = 0,
48 const wxString& name = wxWebViewNameStr);
49 virtual ~wxWebViewWebKit();
50
51 virtual bool CanGoBack() const;
52 virtual bool CanGoForward() const;
53 virtual void GoBack();
54 virtual void GoForward();
55 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
56 virtual void Stop();
57 virtual wxString GetPageSource() const;
58 virtual wxString GetPageText() const;
59
60 //We do not want to hide the other overloads
61 using wxWebView::SetPage;
62 virtual void SetPage(const wxString& html, const wxString& baseUrl);
63
64 virtual void Print();
65
66 virtual void LoadURL(const wxString& url);
67 virtual wxString GetCurrentURL() const;
68 virtual wxString GetCurrentTitle() const;
69 virtual wxWebViewZoom GetZoom() const;
70 virtual void SetZoom(wxWebViewZoom zoom);
71
72 virtual void SetZoomType(wxWebViewZoomType zoomType);
73 virtual wxWebViewZoomType GetZoomType() const;
74 virtual bool CanSetZoomType(wxWebViewZoomType type) const;
75
76 virtual bool IsBusy() const { return m_busy; }
77
78 //History functions
79 virtual void ClearHistory();
80 virtual void EnableHistory(bool enable = true);
81 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
82 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
83 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
84
85 //Undo / redo functionality
86 virtual bool CanUndo() const;
87 virtual bool CanRedo() const;
88 virtual void Undo();
89 virtual void Redo();
90
91 //Clipboard functions
92 virtual bool CanCut() const { return true; }
93 virtual bool CanCopy() const { return true; }
94 virtual bool CanPaste() const { return true; }
95 virtual void Cut();
96 virtual void Copy();
97 virtual void Paste();
98
99 //Editing functions
100 virtual void SetEditable(bool enable = true);
101 virtual bool IsEditable() const;
102
103 //Selection
104 virtual void DeleteSelection();
105 virtual bool HasSelection() const;
106 virtual void SelectAll();
107 virtual wxString GetSelectedText() const;
108 virtual wxString GetSelectedSource() const;
109 virtual void ClearSelection();
110
111 void RunScript(const wxString& javascript);
112
113 //Virtual Filesystem Support
114 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
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 DECLARE_EVENT_TABLE()
145 void MacVisibilityChanged();
146
147 private:
148 wxWindow *m_parent;
149 wxWindowID m_windowID;
150 wxString m_pageTitle;
151
152 struct objc_object *m_webView;
153
154 // we may use this later to setup our own mouse events,
155 // so leave it in for now.
156 void* m_webKitCtrlEventHandler;
157 //It should be WebView*, but WebView is an Objective-C class
158 //TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
159 };
160
161 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
162
163 #endif // _WX_WEBKIT_H_