]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/webview_webkit.h
Use proper format in wxGTK clipboard selection handler.
[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
50 virtual bool Enable( bool enable = true );
51
52 // implementation
53 // --------------
54
55 static wxVisualAttributes
56 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
57
61b98a2d 58 virtual void Stop();
4d0dddc7 59 virtual void LoadURL(const wxString& url);
61b98a2d
SL
60 virtual void GoBack();
61 virtual void GoForward();
a703012a 62 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
e669ddde
SL
63 virtual bool CanGoBack() const;
64 virtual bool CanGoForward() const;
152a5808
SL
65 virtual void ClearHistory();
66 virtual void EnableHistory(bool enable = true);
c13d6ac1
SL
67 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
68 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
69 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
e669ddde
SL
70 virtual wxString GetCurrentURL() const;
71 virtual wxString GetCurrentTitle() const;
72 virtual wxString GetPageSource() const;
73 virtual wxString GetPageText() const;
3dffc2ae
SL
74 //We do not want to hide the other overloads
75 using wxWebView::SetPage;
61b98a2d
SL
76 virtual void SetPage(const wxString& html, const wxString& baseUrl);
77 virtual void Print();
e669ddde 78 virtual bool IsBusy() const;
61b98a2d
SL
79
80 void SetZoomType(wxWebViewZoomType);
81 wxWebViewZoomType GetZoomType() const;
82 bool CanSetZoomType(wxWebViewZoomType) const;
e669ddde 83 virtual wxWebViewZoom GetZoom() const;
61b98a2d
SL
84 virtual void SetZoom(wxWebViewZoom);
85
ae26e17b 86 //Clipboard functions
e669ddde
SL
87 virtual bool CanCut() const;
88 virtual bool CanCopy() const;
89 virtual bool CanPaste() const;
ae26e17b
SL
90 virtual void Cut();
91 virtual void Copy();
92 virtual void Paste();
61b98a2d 93
97e49559 94 //Undo / redo functionality
e669ddde
SL
95 virtual bool CanUndo() const;
96 virtual bool CanRedo() const;
97e49559
SL
97 virtual void Undo();
98 virtual void Redo();
99
c7cbe308
SL
100 //Editing functions
101 virtual void SetEditable(bool enable = true);
e669ddde 102 virtual bool IsEditable() const;
c7cbe308 103
63a65070
SL
104 //Selection
105 virtual void DeleteSelection();
e669ddde 106 virtual bool HasSelection() const;
63a65070 107 virtual void SelectAll();
e669ddde
SL
108 virtual wxString GetSelectedText() const;
109 virtual wxString GetSelectedSource() const;
41933aa5 110 virtual void ClearSelection();
63a65070 111
c9ccc09c 112 virtual void RunScript(const wxString& javascript);
34326da7 113
eff8f795 114 //Virtual Filesystem Support
7d8d6163
SL
115 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
116 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
c9ccc09c 117
61b98a2d
SL
118 /** TODO: check if this can be made private
119 * The native control has a getter to check for busy state, but except in
120 * very recent versions of webkit this getter doesn't say everything we need
121 * (namely it seems to stay indefinitely busy when loading is cancelled by
122 * user)
123 */
124 bool m_busy;
3baf235f 125
211da8a5 126 wxString m_vfsurl;
61b98a2d 127
36b52591
SL
128 //We use this flag to stop recursion when we load a page from the navigation
129 //callback, mainly when loading a VFS page
130 bool m_guard;
131
61b98a2d
SL
132protected:
133
134 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
135
136private:
137
fba4c7c9
SL
138 void ZoomIn();
139 void ZoomOut();
140 void SetWebkitZoom(float level);
141 float GetWebkitZoom() const;
142
61b98a2d
SL
143 // focus event handler: calls GTKUpdateBitmap()
144 void GTKOnFocus(wxFocusEvent& event);
145
4c9bde5e 146 WebKitWebView *m_web_view;
a0ff3611 147 int m_historyLimit;
61b98a2d 148
7d8d6163 149 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
f2049b68 150
cddf4541 151 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
61b98a2d
SL
152};
153
9d2f31db 154#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
61b98a2d 155
384b8d9f 156#endif