]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/webview_webkit.h
Add generic wxFileSystem support to wxWebView using wxWebViewFSHandler.
[wxWidgets.git] / include / wx / gtk / webview_webkit.h
CommitLineData
61b98a2d
SL
1/////////////////////////////////////////////////////////////////////////////
2// Name: include/gtk/wx/webview.h
3// Purpose: GTK webkit backend for web view component
4// Author: Robert Roebling, Marianne Gagnon
5// Id: $Id$
6// Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_GTK_WEBKITCTRL_H_
11#define _WX_GTK_WEBKITCTRL_H_
12
13#include "wx/setup.h"
14
9d2f31db 15#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
61b98a2d 16
19fc1a2f 17#include "wx/sharedptr.h"
61b98a2d
SL
18#include "wx/webview.h"
19
4c9bde5e
PC
20typedef struct _WebKitWebView WebKitWebView;
21
61b98a2d 22//-----------------------------------------------------------------------------
b64b4e70 23// wxWebViewWebKit
61b98a2d
SL
24//-----------------------------------------------------------------------------
25
467d261e 26class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
61b98a2d
SL
27{
28public:
b64b4e70 29 wxWebViewWebKit() { Init(); }
61b98a2d 30
b64b4e70 31 wxWebViewWebKit(wxWindow *parent,
61b98a2d
SL
32 wxWindowID id = wxID_ANY,
33 const wxString& url = wxWebViewDefaultURLStr,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize, long style = 0,
36 const wxString& name = wxWebViewNameStr)
37 {
38 Init();
39
40 Create(parent, id, url, pos, size, style, name);
41 }
42
43 virtual bool Create(wxWindow *parent,
44 wxWindowID id = wxID_ANY,
45 const wxString& url = wxWebViewDefaultURLStr,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize, long style = 0,
48 const wxString& name = wxWebViewNameStr);
49
c3980646
VZ
50 virtual ~wxWebViewWebKit();
51
61b98a2d
SL
52 virtual bool Enable( bool enable = true );
53
54 // implementation
55 // --------------
56
57 static wxVisualAttributes
58 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
59
61b98a2d 60 virtual void Stop();
4d0dddc7 61 virtual void LoadURL(const wxString& url);
61b98a2d
SL
62 virtual void GoBack();
63 virtual void GoForward();
a703012a 64 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
e669ddde
SL
65 virtual bool CanGoBack() const;
66 virtual bool CanGoForward() const;
152a5808
SL
67 virtual void ClearHistory();
68 virtual void EnableHistory(bool enable = true);
c13d6ac1
SL
69 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
70 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
71 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
e669ddde
SL
72 virtual wxString GetCurrentURL() const;
73 virtual wxString GetCurrentTitle() const;
74 virtual wxString GetPageSource() const;
75 virtual wxString GetPageText() const;
61b98a2d 76 virtual void Print();
e669ddde 77 virtual bool IsBusy() const;
61b98a2d
SL
78
79 void SetZoomType(wxWebViewZoomType);
80 wxWebViewZoomType GetZoomType() const;
81 bool CanSetZoomType(wxWebViewZoomType) const;
e669ddde 82 virtual wxWebViewZoom GetZoom() const;
61b98a2d
SL
83 virtual void SetZoom(wxWebViewZoom);
84
ae26e17b 85 //Clipboard functions
e669ddde
SL
86 virtual bool CanCut() const;
87 virtual bool CanCopy() const;
88 virtual bool CanPaste() const;
ae26e17b
SL
89 virtual void Cut();
90 virtual void Copy();
91 virtual void Paste();
61b98a2d 92
97e49559 93 //Undo / redo functionality
e669ddde
SL
94 virtual bool CanUndo() const;
95 virtual bool CanRedo() const;
97e49559
SL
96 virtual void Undo();
97 virtual void Redo();
98
66ac0400
SL
99 //Find function
100 virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT);
101
c7cbe308
SL
102 //Editing functions
103 virtual void SetEditable(bool enable = true);
e669ddde 104 virtual bool IsEditable() const;
c7cbe308 105
63a65070
SL
106 //Selection
107 virtual void DeleteSelection();
e669ddde 108 virtual bool HasSelection() const;
63a65070 109 virtual void SelectAll();
e669ddde
SL
110 virtual wxString GetSelectedText() const;
111 virtual wxString GetSelectedSource() const;
41933aa5 112 virtual void ClearSelection();
63a65070 113
c9ccc09c 114 virtual void RunScript(const wxString& javascript);
34326da7 115
eff8f795 116 //Virtual Filesystem Support
7d8d6163
SL
117 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
118 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
c9ccc09c 119
b6a49c2b
VZ
120 virtual void* GetNativeBackend() const { return m_web_view; }
121
61b98a2d
SL
122 /** TODO: check if this can be made private
123 * The native control has a getter to check for busy state, but except in
124 * very recent versions of webkit this getter doesn't say everything we need
125 * (namely it seems to stay indefinitely busy when loading is cancelled by
126 * user)
127 */
128 bool m_busy;
3baf235f 129
211da8a5 130 wxString m_vfsurl;
61b98a2d 131
36b52591
SL
132 //We use this flag to stop recursion when we load a page from the navigation
133 //callback, mainly when loading a VFS page
134 bool m_guard;
135
61b98a2d 136protected:
a977376a 137 virtual void DoSetPage(const wxString& html, const wxString& baseUrl);
61b98a2d
SL
138
139 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
140
141private:
142
fba4c7c9
SL
143 void ZoomIn();
144 void ZoomOut();
145 void SetWebkitZoom(float level);
146 float GetWebkitZoom() const;
147
66ac0400
SL
148 //Find helper function
149 void FindClear();
150
61b98a2d
SL
151 // focus event handler: calls GTKUpdateBitmap()
152 void GTKOnFocus(wxFocusEvent& event);
153
4c9bde5e 154 WebKitWebView *m_web_view;
a0ff3611 155 int m_historyLimit;
61b98a2d 156
7d8d6163 157 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
f2049b68 158
66ac0400
SL
159 //variables used for Find()
160 int m_findFlags;
161 wxString m_findText;
162 int m_findPosition;
163 int m_findCount;
164
cddf4541 165 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
61b98a2d
SL
166};
167
9d2f31db 168#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
61b98a2d 169
384b8d9f 170#endif