]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/webview_webkit.h
Implement delayed destruction for wxPopupTransientWindow.
[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
SL
17#include "webkit/webkit.h"
18#include "wx/sharedptr.h"
61b98a2d
SL
19#include "wx/webview.h"
20
21//-----------------------------------------------------------------------------
b64b4e70 22// wxWebViewWebKit
61b98a2d
SL
23//-----------------------------------------------------------------------------
24
467d261e 25class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
61b98a2d
SL
26{
27public:
b64b4e70 28 wxWebViewWebKit() { Init(); }
61b98a2d 29
b64b4e70 30 wxWebViewWebKit(wxWindow *parent,
61b98a2d
SL
31 wxWindowID id = wxID_ANY,
32 const wxString& url = wxWebViewDefaultURLStr,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize, long style = 0,
35 const wxString& name = wxWebViewNameStr)
36 {
37 Init();
38
39 Create(parent, id, url, pos, size, style, name);
40 }
41
42 virtual bool Create(wxWindow *parent,
43 wxWindowID id = wxID_ANY,
44 const wxString& url = wxWebViewDefaultURLStr,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize, long style = 0,
47 const wxString& name = wxWebViewNameStr);
48
49 virtual bool Enable( bool enable = true );
50
51 // implementation
52 // --------------
53
54 static wxVisualAttributes
55 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
56
61b98a2d 57 virtual void Stop();
4d0dddc7 58 virtual void LoadURL(const wxString& url);
61b98a2d
SL
59 virtual void GoBack();
60 virtual void GoForward();
a703012a 61 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
e669ddde
SL
62 virtual bool CanGoBack() const;
63 virtual bool CanGoForward() const;
152a5808
SL
64 virtual void ClearHistory();
65 virtual void EnableHistory(bool enable = true);
c13d6ac1
SL
66 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
67 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
68 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
e669ddde
SL
69 virtual wxString GetCurrentURL() const;
70 virtual wxString GetCurrentTitle() const;
71 virtual wxString GetPageSource() const;
72 virtual wxString GetPageText() const;
3dffc2ae
SL
73 //We do not want to hide the other overloads
74 using wxWebView::SetPage;
61b98a2d
SL
75 virtual void SetPage(const wxString& html, const wxString& baseUrl);
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
c7cbe308
SL
99 //Editing functions
100 virtual void SetEditable(bool enable = true);
e669ddde 101 virtual bool IsEditable() const;
c7cbe308 102
63a65070
SL
103 //Selection
104 virtual void DeleteSelection();
e669ddde 105 virtual bool HasSelection() const;
63a65070 106 virtual void SelectAll();
e669ddde
SL
107 virtual wxString GetSelectedText() const;
108 virtual wxString GetSelectedSource() const;
41933aa5 109 virtual void ClearSelection();
63a65070 110
c9ccc09c 111 virtual void RunScript(const wxString& javascript);
eff8f795
SL
112
113 //Virtual Filesystem Support
7d8d6163
SL
114 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
115 virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
c9ccc09c 116
61b98a2d
SL
117 /** FIXME: hack to work around signals being received too early */
118 bool m_ready;
119
120
121 /** TODO: check if this can be made private
122 * The native control has a getter to check for busy state, but except in
123 * very recent versions of webkit this getter doesn't say everything we need
124 * (namely it seems to stay indefinitely busy when loading is cancelled by
125 * user)
126 */
127 bool m_busy;
3baf235f 128
211da8a5 129 wxString m_vfsurl;
61b98a2d 130
36b52591
SL
131 //We use this flag to stop recursion when we load a page from the navigation
132 //callback, mainly when loading a VFS page
133 bool m_guard;
134
61b98a2d
SL
135protected:
136
137 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
138
139private:
140
fba4c7c9
SL
141 void ZoomIn();
142 void ZoomOut();
143 void SetWebkitZoom(float level);
144 float GetWebkitZoom() const;
145
61b98a2d
SL
146 // focus event handler: calls GTKUpdateBitmap()
147 void GTKOnFocus(wxFocusEvent& event);
148
149 GtkWidget *web_view;
152a5808 150 gint m_historyLimit;
61b98a2d 151
7d8d6163 152 wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
f2049b68 153
cddf4541 154 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
61b98a2d
SL
155};
156
9d2f31db 157#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
61b98a2d 158
384b8d9f 159#endif