2011-05-04 14:24:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: include/gtk/wx/webview.h
|
|
|
|
// Purpose: GTK webkit backend for web view component
|
|
|
|
// Author: Robert Roebling, Marianne Gagnon
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GTK_WEBKITCTRL_H_
|
|
|
|
#define _WX_GTK_WEBKITCTRL_H_
|
|
|
|
|
|
|
|
#include "wx/setup.h"
|
|
|
|
|
2011-09-12 14:35:39 -04:00
|
|
|
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-07-01 15:46:31 -04:00
|
|
|
#include "wx/sharedptr.h"
|
2011-05-04 14:24:30 -04:00
|
|
|
#include "wx/webview.h"
|
|
|
|
|
2012-03-01 11:36:58 -05:00
|
|
|
typedef struct _WebKitWebView WebKitWebView;
|
|
|
|
|
2011-05-04 14:24:30 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2011-06-28 12:57:49 -04:00
|
|
|
// wxWebViewWebKit
|
2011-05-04 14:24:30 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-08-19 06:45:16 -04:00
|
|
|
class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
|
2011-05-04 14:24:30 -04:00
|
|
|
{
|
|
|
|
public:
|
2011-06-28 12:57:49 -04:00
|
|
|
wxWebViewWebKit() { Init(); }
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-06-28 12:57:49 -04:00
|
|
|
wxWebViewWebKit(wxWindow *parent,
|
2011-05-04 14:24:30 -04:00
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& url = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
Create(parent, id, url, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& url = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr);
|
|
|
|
|
|
|
|
virtual bool Enable( bool enable = true );
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
// --------------
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
|
|
|
|
|
|
|
virtual void Stop();
|
2011-08-17 06:55:59 -04:00
|
|
|
virtual void LoadURL(const wxString& url);
|
2011-05-04 14:24:30 -04:00
|
|
|
virtual void GoBack();
|
|
|
|
virtual void GoForward();
|
2011-05-06 09:37:01 -04:00
|
|
|
virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool CanGoBack() const;
|
|
|
|
virtual bool CanGoForward() const;
|
2011-06-30 06:03:25 -04:00
|
|
|
virtual void ClearHistory();
|
|
|
|
virtual void EnableHistory(bool enable = true);
|
2011-08-15 08:31:31 -04:00
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
|
|
|
|
virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual wxString GetCurrentURL() const;
|
|
|
|
virtual wxString GetCurrentTitle() const;
|
|
|
|
virtual wxString GetPageSource() const;
|
|
|
|
virtual wxString GetPageText() const;
|
2011-07-11 08:52:07 -04:00
|
|
|
//We do not want to hide the other overloads
|
|
|
|
using wxWebView::SetPage;
|
2011-05-04 14:24:30 -04:00
|
|
|
virtual void SetPage(const wxString& html, const wxString& baseUrl);
|
|
|
|
virtual void Print();
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool IsBusy() const;
|
2011-05-04 14:24:30 -04:00
|
|
|
|
|
|
|
void SetZoomType(wxWebViewZoomType);
|
|
|
|
wxWebViewZoomType GetZoomType() const;
|
|
|
|
bool CanSetZoomType(wxWebViewZoomType) const;
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual wxWebViewZoom GetZoom() const;
|
2011-05-04 14:24:30 -04:00
|
|
|
virtual void SetZoom(wxWebViewZoom);
|
|
|
|
|
2011-07-02 10:32:02 -04:00
|
|
|
//Clipboard functions
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool CanCut() const;
|
|
|
|
virtual bool CanCopy() const;
|
|
|
|
virtual bool CanPaste() const;
|
2011-07-02 10:32:02 -04:00
|
|
|
virtual void Cut();
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Paste();
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-07-02 11:07:46 -04:00
|
|
|
//Undo / redo functionality
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool CanUndo() const;
|
|
|
|
virtual bool CanRedo() const;
|
2011-07-02 11:07:46 -04:00
|
|
|
virtual void Undo();
|
|
|
|
virtual void Redo();
|
|
|
|
|
2011-07-08 15:34:56 -04:00
|
|
|
//Editing functions
|
|
|
|
virtual void SetEditable(bool enable = true);
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool IsEditable() const;
|
2011-07-08 15:34:56 -04:00
|
|
|
|
2011-07-09 10:31:29 -04:00
|
|
|
//Selection
|
|
|
|
virtual void DeleteSelection();
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual bool HasSelection() const;
|
2011-07-09 10:31:29 -04:00
|
|
|
virtual void SelectAll();
|
2011-08-17 06:26:09 -04:00
|
|
|
virtual wxString GetSelectedText() const;
|
|
|
|
virtual wxString GetSelectedSource() const;
|
2011-07-15 05:36:08 -04:00
|
|
|
virtual void ClearSelection();
|
2011-07-09 10:31:29 -04:00
|
|
|
|
2011-07-15 08:38:47 -04:00
|
|
|
virtual void RunScript(const wxString& javascript);
|
2012-03-28 14:00:30 -04:00
|
|
|
|
2011-07-28 12:49:48 -04:00
|
|
|
//Virtual Filesystem Support
|
2011-08-14 08:15:34 -04:00
|
|
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
|
2011-07-15 08:38:47 -04:00
|
|
|
|
2011-05-04 14:24:30 -04:00
|
|
|
/** TODO: check if this can be made private
|
|
|
|
* The native control has a getter to check for busy state, but except in
|
|
|
|
* very recent versions of webkit this getter doesn't say everything we need
|
|
|
|
* (namely it seems to stay indefinitely busy when loading is cancelled by
|
|
|
|
* user)
|
|
|
|
*/
|
|
|
|
bool m_busy;
|
2011-08-08 11:12:33 -04:00
|
|
|
|
2011-08-05 05:06:45 -04:00
|
|
|
wxString m_vfsurl;
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-08-04 04:30:37 -04:00
|
|
|
//We use this flag to stop recursion when we load a page from the navigation
|
|
|
|
//callback, mainly when loading a VFS page
|
|
|
|
bool m_guard;
|
|
|
|
|
2011-05-04 14:24:30 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2011-08-17 06:36:14 -04:00
|
|
|
void ZoomIn();
|
|
|
|
void ZoomOut();
|
|
|
|
void SetWebkitZoom(float level);
|
|
|
|
float GetWebkitZoom() const;
|
|
|
|
|
2011-05-04 14:24:30 -04:00
|
|
|
// focus event handler: calls GTKUpdateBitmap()
|
|
|
|
void GTKOnFocus(wxFocusEvent& event);
|
|
|
|
|
2012-03-01 11:36:58 -05:00
|
|
|
WebKitWebView *m_web_view;
|
2011-11-16 20:23:03 -05:00
|
|
|
int m_historyLimit;
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-08-14 08:15:34 -04:00
|
|
|
wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
|
2011-08-03 05:29:30 -04:00
|
|
|
|
2011-08-01 11:49:05 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
|
2011-05-04 14:24:30 -04:00
|
|
|
};
|
|
|
|
|
2011-09-12 14:35:39 -04:00
|
|
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-05-05 09:01:54 -04:00
|
|
|
#endif
|