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-06-28 12:57:49 -04:00
|
|
|
#if wxUSE_WEBVIEW_WEBKIT
|
2011-05-04 14:24:30 -04:00
|
|
|
|
2011-07-01 15:46:31 -04:00
|
|
|
#include "webkit/webkit.h"
|
|
|
|
#include "wx/sharedptr.h"
|
2011-05-04 14:24:30 -04:00
|
|
|
#include "wx/webview.h"
|
|
|
|
|
2011-07-01 15:46:31 -04:00
|
|
|
//A set of hash function so we can map wxWebHistoryItems to WebKitWebHistoryItems
|
|
|
|
class SharedPtrHash
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SharedPtrHash() { }
|
|
|
|
|
|
|
|
unsigned long operator()( const wxSharedPtr<wxWebHistoryItem> & item ) const
|
|
|
|
{
|
|
|
|
|
|
|
|
return wxPointerHash()(item.get());
|
|
|
|
}
|
|
|
|
SharedPtrHash& operator=(const SharedPtrHash&) { return *this; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class SharedPtrEqual
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SharedPtrEqual() { }
|
|
|
|
bool operator()( const wxSharedPtr<wxWebHistoryItem> & a,
|
|
|
|
const wxSharedPtr<wxWebHistoryItem> & b ) const
|
|
|
|
{
|
|
|
|
return wxPointerEqual()(a.get(), b.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedPtrEqual& operator=(const SharedPtrEqual&) { return *this; }
|
|
|
|
};
|
|
|
|
|
|
|
|
WX_DECLARE_HASH_MAP(wxSharedPtr<wxWebHistoryItem>, WebKitWebHistoryItem*,
|
|
|
|
SharedPtrHash, SharedPtrEqual, HistoryItemHash);
|
|
|
|
|
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-06-28 12:57:49 -04:00
|
|
|
class WXDLLIMPEXP_WEB 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);
|
|
|
|
|
|
|
|
// helper to allow access to protected member from GTK callback
|
|
|
|
void MoveWindow(int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
DoMoveWindow(x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZoomIn();
|
|
|
|
void ZoomOut();
|
|
|
|
void SetWebkitZoom(float level);
|
|
|
|
float GetWebkitZoom();
|
|
|
|
|
|
|
|
virtual void Stop();
|
|
|
|
virtual void LoadUrl(const wxString& url);
|
|
|
|
virtual void GoBack();
|
|
|
|
virtual void GoForward();
|
2011-05-06 09:37:01 -04:00
|
|
|
virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
|
2011-05-04 14:24:30 -04:00
|
|
|
virtual bool CanGoBack();
|
|
|
|
virtual bool CanGoForward();
|
2011-06-30 06:03:25 -04:00
|
|
|
virtual void ClearHistory();
|
|
|
|
virtual void EnableHistory(bool enable = true);
|
2011-07-01 15:46:31 -04:00
|
|
|
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory();
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory();
|
|
|
|
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
|
2011-05-04 14:24:30 -04:00
|
|
|
virtual wxString GetCurrentURL();
|
|
|
|
virtual wxString GetCurrentTitle();
|
|
|
|
virtual wxString GetPageSource();
|
|
|
|
virtual void SetPage(const wxString& html, const wxString& baseUrl);
|
|
|
|
virtual void Print();
|
|
|
|
virtual bool IsBusy();
|
|
|
|
|
|
|
|
void SetZoomType(wxWebViewZoomType);
|
|
|
|
wxWebViewZoomType GetZoomType() const;
|
|
|
|
bool CanSetZoomType(wxWebViewZoomType) const;
|
|
|
|
virtual wxWebViewZoom GetZoom();
|
|
|
|
virtual void SetZoom(wxWebViewZoom);
|
|
|
|
|
2011-07-02 10:32:02 -04:00
|
|
|
//Clipboard functions
|
|
|
|
virtual bool CanCut();
|
|
|
|
virtual bool CanCopy();
|
|
|
|
virtual bool CanPaste();
|
|
|
|
virtual void Cut();
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Paste();
|
2011-05-04 14:24:30 -04:00
|
|
|
|
|
|
|
/** FIXME: hack to work around signals being received too early */
|
|
|
|
bool m_ready;
|
|
|
|
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// focus event handler: calls GTKUpdateBitmap()
|
|
|
|
void GTKOnFocus(wxFocusEvent& event);
|
|
|
|
|
|
|
|
GtkWidget *web_view;
|
2011-06-30 06:03:25 -04:00
|
|
|
gint m_historyLimit;
|
2011-07-01 15:46:31 -04:00
|
|
|
HistoryItemHash m_historyMap;
|
2011-05-04 14:24:30 -04:00
|
|
|
|
|
|
|
// FIXME: try to get DECLARE_DYNAMIC_CLASS macros & stuff right
|
2011-06-28 12:57:49 -04:00
|
|
|
//DECLARE_DYNAMIC_CLASS(wxWebViewWebKit)
|
2011-05-04 14:24:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // if wxHAVE_WEB_BACKEND_GTK_WEBKIT
|
|
|
|
|
2011-05-05 09:01:54 -04:00
|
|
|
#endif
|