]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | #if wxUSE_WEBKIT && (defined(__WXMAC__) || defined(__WXCOCOA__)) | |
19 | ||
61b98a2d SL |
20 | #include "wx/control.h" |
21 | #include "wx/webview.h" | |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // Web Kit Control | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
0a6c8516 | 27 | class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView |
61b98a2d SL |
28 | { |
29 | public: | |
0a6c8516 | 30 | wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); |
61b98a2d | 31 | |
0a6c8516 SL |
32 | wxWebViewWebKit() {} |
33 | wxWebViewWebKit(wxWindow *parent, | |
61b98a2d SL |
34 | wxWindowID winID = wxID_ANY, |
35 | const wxString& strURL = wxWebViewDefaultURLStr, | |
36 | const wxPoint& pos = wxDefaultPosition, | |
37 | const wxSize& size = wxDefaultSize, long style = 0, | |
38 | const wxString& name = wxWebViewNameStr) | |
39 | { | |
40 | Create(parent, winID, strURL, pos, size, style, name); | |
41 | } | |
42 | bool Create(wxWindow *parent, | |
43 | wxWindowID winID = wxID_ANY, | |
44 | const wxString& strURL = wxWebViewDefaultURLStr, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, long style = 0, | |
47 | const wxString& name = wxWebViewNameStr); | |
0a6c8516 | 48 | virtual ~wxWebViewWebKit(); |
61b98a2d SL |
49 | |
50 | void InternalLoadURL(const wxString &url); | |
51 | ||
52 | virtual bool CanGoBack(); | |
53 | virtual bool CanGoForward(); | |
54 | virtual void GoBack(); | |
55 | virtual void GoForward(); | |
a703012a | 56 | virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); |
61b98a2d SL |
57 | virtual void Stop(); |
58 | virtual wxString GetPageSource(); | |
241b769f | 59 | virtual wxString GetPageText() { return ""; } |
61b98a2d SL |
60 | virtual void SetPageTitle(const wxString& title) { m_pageTitle = title; } |
61 | virtual wxString GetPageTitle(){ return m_pageTitle; } | |
62 | ||
63 | virtual void SetPage(const wxString& html, const wxString& baseUrl); | |
64 | ||
65 | virtual void Print(); | |
66 | ||
67 | virtual void LoadUrl(const wxString& url); | |
68 | virtual wxString GetCurrentURL(); | |
69 | virtual wxString GetCurrentTitle(); | |
70 | virtual wxWebViewZoom GetZoom(); | |
71 | virtual void SetZoom(wxWebViewZoom zoom); | |
72 | ||
73 | virtual void SetZoomType(wxWebViewZoomType zoomType); | |
74 | virtual wxWebViewZoomType GetZoomType() const; | |
75 | virtual bool CanSetZoomType(wxWebViewZoomType type) const; | |
76 | ||
77 | virtual bool IsBusy() { return m_busy; } | |
0e37936e SL |
78 | |
79 | //History functions | |
80 | virtual void ClearHistory() {} | |
81 | virtual void EnableHistory(bool enable = true) {} | |
82 | virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory() | |
83 | { return wxVector<wxSharedPtr<wxWebHistoryItem> >() } | |
84 | virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory() | |
85 | { return wxVector<wxSharedPtr<wxWebHistoryItem> >() } | |
86 | virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) {} | |
87 | ||
88 | //Undo / redo functionality | |
028894b4 SL |
89 | virtual bool CanUndo() { return false; } |
90 | virtual bool CanRedo() { return false; } | |
0e37936e SL |
91 | virtual void Undo() {} |
92 | virtual void Redo() {} | |
61b98a2d | 93 | |
e2392c45 | 94 | //Clipboard functions |
028894b4 SL |
95 | virtual bool CanCut() { return false; } |
96 | virtual bool CanCopy() { return false; } | |
97 | virtual bool CanPaste() { return false; } | |
98 | virtual void Cut(); | |
99 | virtual void Copy(); | |
100 | virtual void Paste(); | |
c7cbe308 SL |
101 | |
102 | //Editing functions | |
63a65070 SL |
103 | virtual void SetEditable(bool enable = true); |
104 | virtual bool IsEditable(); | |
105 | ||
106 | //Selection | |
107 | virtual void DeleteSelection(); | |
108 | virtual bool HasSelection() { return false }; | |
109 | virtual void SelectAll() {}; | |
c9355a3d | 110 | virtual wxString GetSelectedText(); |
97ba4d81 | 111 | virtual wxString GetSelectedSource() { return ""; } |
41933aa5 | 112 | virtual void ClearSelection() {} |
c9ccc09c SL |
113 | |
114 | void RunScript(const wxString& javascript); | |
e2392c45 | 115 | |
61b98a2d | 116 | // ---- methods not from the parent (common) interface |
61b98a2d SL |
117 | bool CanGetPageSource(); |
118 | ||
119 | void SetScrollPos(int pos); | |
120 | int GetScrollPos(); | |
121 | ||
61b98a2d SL |
122 | wxString GetSelection(); |
123 | ||
124 | bool CanIncreaseTextSize(); | |
125 | void IncreaseTextSize(); | |
126 | bool CanDecreaseTextSize(); | |
127 | void DecreaseTextSize(); | |
128 | ||
129 | float GetWebkitZoom(); | |
130 | void SetWebkitZoom(float zoom); | |
131 | ||
132 | // don't hide base class virtuals | |
133 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ) | |
134 | { return wxControl::SetScrollPos(orient, pos, refresh); } | |
135 | virtual int GetScrollPos( int orient ) const | |
136 | { return wxControl::GetScrollPos(orient); } | |
137 | ||
138 | //we need to resize the webview when the control size changes | |
139 | void OnSize(wxSizeEvent &event); | |
140 | void OnMove(wxMoveEvent &event); | |
141 | void OnMouseEvents(wxMouseEvent &event); | |
142 | ||
143 | bool m_busy; | |
144 | ||
145 | protected: | |
146 | DECLARE_EVENT_TABLE() | |
147 | void MacVisibilityChanged(); | |
148 | ||
149 | private: | |
150 | wxWindow *m_parent; | |
151 | wxWindowID m_windowID; | |
152 | wxString m_pageTitle; | |
153 | ||
154 | struct objc_object *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 | ||
61b98a2d SL |
163 | #endif // wxUSE_WEBKIT |
164 | ||
165 | #endif // _WX_WEBKIT_H_ |