1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/gtk/wx/webview.h
3 // Purpose: GTK webkit backend for web view component
4 // Author: Robert Roebling, Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_WEBKITCTRL_H_
11 #define _WX_GTK_WEBKITCTRL_H_
15 #if wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
17 #include "webkit/webkit.h"
18 #include "wx/sharedptr.h"
19 #include "wx/webview.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLIMPEXP_WEB wxWebViewWebKit
: public wxWebView
28 wxWebViewWebKit() { Init(); }
30 wxWebViewWebKit(wxWindow
*parent
,
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
)
39 Create(parent
, id
, url
, pos
, size
, style
, name
);
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
);
49 virtual bool Enable( bool enable
= true );
54 static wxVisualAttributes
55 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
57 // helper to allow access to protected member from GTK callback
58 void MoveWindow(int x
, int y
, int width
, int height
)
60 DoMoveWindow(x
, y
, width
, height
);
65 void SetWebkitZoom(float level
);
66 float GetWebkitZoom();
69 virtual void LoadUrl(const wxString
& url
);
70 virtual void GoBack();
71 virtual void GoForward();
72 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
73 virtual bool CanGoBack();
74 virtual bool CanGoForward();
75 virtual void ClearHistory();
76 virtual void EnableHistory(bool enable
= true);
77 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory();
78 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory();
79 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
);
80 virtual wxString
GetCurrentURL();
81 virtual wxString
GetCurrentTitle();
82 virtual wxString
GetPageSource();
83 virtual wxString
GetPageText();
84 //We do not want to hide the other overloads
85 using wxWebView::SetPage
;
86 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
88 virtual bool IsBusy();
90 void SetZoomType(wxWebViewZoomType
);
91 wxWebViewZoomType
GetZoomType() const;
92 bool CanSetZoomType(wxWebViewZoomType
) const;
93 virtual wxWebViewZoom
GetZoom();
94 virtual void SetZoom(wxWebViewZoom
);
97 virtual bool CanCut();
98 virtual bool CanCopy();
99 virtual bool CanPaste();
102 virtual void Paste();
104 //Undo / redo functionality
105 virtual bool CanUndo();
106 virtual bool CanRedo();
111 virtual void SetEditable(bool enable
= true);
112 virtual bool IsEditable();
115 virtual void DeleteSelection();
116 virtual bool HasSelection();
117 virtual void SelectAll();
118 virtual wxString
GetSelectedText();
119 virtual wxString
GetSelectedSource();
120 virtual void ClearSelection();
122 virtual void RunScript(const wxString
& javascript
);
124 //Virtual Filesystem Support
125 virtual void RegisterHandler(wxWebHandler
* handler
);
126 virtual wxVector
<wxWebHandler
*> GetHandlers() { return m_handlerList
; }
128 /** FIXME: hack to work around signals being received too early */
132 /** TODO: check if this can be made private
133 * The native control has a getter to check for busy state, but except in
134 * very recent versions of webkit this getter doesn't say everything we need
135 * (namely it seems to stay indefinitely busy when loading is cancelled by
143 //We use this flag to stop recursion when we load a page from the navigation
144 //callback, mainly when loading a VFS page
149 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
153 // focus event handler: calls GTKUpdateBitmap()
154 void GTKOnFocus(wxFocusEvent
& event
);
159 wxVector
<wxWebHandler
*> m_handlerList
;
161 wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit
);
164 #endif // wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)