2012-03-18 01:12:27 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: include/wx/osx/webkit.h
|
|
|
|
// Purpose: wxWebViewWebKit - embeddable web kit control,
|
|
|
|
// OS X implementation of web view component
|
|
|
|
// Author: Jethro Grassie / Kevin Ollivier / Marianne Gagnon
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2004-4-16
|
|
|
|
// Copyright: (c) Jethro Grassie / Kevin Ollivier / Marianne Gagnon
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_WEBKIT_H
|
|
|
|
#define _WX_WEBKIT_H
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
#include "wx/defs.h"
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__)
|
2012-03-18 01:12:27 +00:00
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/webview.h"
|
|
|
|
|
2013-09-22 22:44:55 +00:00
|
|
|
#include "wx/osx/core/objcid.h"
|
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Web Kit Control
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
|
|
|
|
|
|
|
|
wxWebViewWebKit() {}
|
|
|
|
wxWebViewWebKit(wxWindow *parent,
|
|
|
|
wxWindowID winID = wxID_ANY,
|
|
|
|
const wxString& strURL = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, winID, strURL, pos, size, style, name);
|
|
|
|
}
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID winID = wxID_ANY,
|
|
|
|
const wxString& strURL = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2016-06-26 05:25:29 +00:00
|
|
|
const wxString& name = wxWebViewNameStr) wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
virtual ~wxWebViewWebKit();
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool CanGoBack() const wxOVERRIDE;
|
|
|
|
virtual bool CanGoForward() const wxOVERRIDE;
|
|
|
|
virtual void GoBack() wxOVERRIDE;
|
|
|
|
virtual void GoForward() wxOVERRIDE;
|
|
|
|
virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) wxOVERRIDE;
|
|
|
|
virtual void Stop() wxOVERRIDE;
|
|
|
|
virtual wxString GetPageSource() const wxOVERRIDE;
|
|
|
|
virtual wxString GetPageText() const wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void Print() wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void LoadURL(const wxString& url) wxOVERRIDE;
|
|
|
|
virtual wxString GetCurrentURL() const wxOVERRIDE;
|
|
|
|
virtual wxString GetCurrentTitle() const wxOVERRIDE;
|
|
|
|
virtual wxWebViewZoom GetZoom() const wxOVERRIDE;
|
|
|
|
virtual void SetZoom(wxWebViewZoom zoom) wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetZoomType(wxWebViewZoomType zoomType) wxOVERRIDE;
|
|
|
|
virtual wxWebViewZoomType GetZoomType() const wxOVERRIDE;
|
|
|
|
virtual bool CanSetZoomType(wxWebViewZoomType type) const wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool IsBusy() const wxOVERRIDE { return m_busy; }
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//History functions
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void ClearHistory() wxOVERRIDE;
|
|
|
|
virtual void EnableHistory(bool enable = true) wxOVERRIDE;
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory() wxOVERRIDE;
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory() wxOVERRIDE;
|
|
|
|
virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item) wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//Undo / redo functionality
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool CanUndo() const wxOVERRIDE;
|
|
|
|
virtual bool CanRedo() const wxOVERRIDE;
|
|
|
|
virtual void Undo() wxOVERRIDE;
|
|
|
|
virtual void Redo() wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2013-09-22 22:44:55 +00:00
|
|
|
//Find function
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT) wxOVERRIDE
|
2013-09-22 22:44:55 +00:00
|
|
|
{
|
|
|
|
wxUnusedVar(text);
|
|
|
|
wxUnusedVar(flags);
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//Clipboard functions
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool CanCut() const wxOVERRIDE { return true; }
|
|
|
|
virtual bool CanCopy() const wxOVERRIDE { return true; }
|
|
|
|
virtual bool CanPaste() const wxOVERRIDE { return true; }
|
|
|
|
virtual void Cut() wxOVERRIDE;
|
|
|
|
virtual void Copy() wxOVERRIDE;
|
|
|
|
virtual void Paste() wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//Editing functions
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetEditable(bool enable = true) wxOVERRIDE;
|
|
|
|
virtual bool IsEditable() const wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//Selection
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void DeleteSelection() wxOVERRIDE;
|
|
|
|
virtual bool HasSelection() const wxOVERRIDE;
|
|
|
|
virtual void SelectAll() wxOVERRIDE;
|
|
|
|
virtual wxString GetSelectedText() const wxOVERRIDE;
|
|
|
|
virtual wxString GetSelectedSource() const wxOVERRIDE;
|
|
|
|
virtual void ClearSelection() wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
void RunScript(const wxString& javascript) wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
//Virtual Filesystem Support
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void* GetNativeBackend() const wxOVERRIDE { return m_webView; }
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
// ---- methods not from the parent (common) interface
|
|
|
|
bool CanGetPageSource() const;
|
|
|
|
|
|
|
|
void SetScrollPos(int pos);
|
|
|
|
int GetScrollPos();
|
|
|
|
|
|
|
|
bool CanIncreaseTextSize() const;
|
|
|
|
void IncreaseTextSize();
|
|
|
|
bool CanDecreaseTextSize() const;
|
|
|
|
void DecreaseTextSize();
|
|
|
|
|
|
|
|
float GetWebkitZoom() const;
|
|
|
|
void SetWebkitZoom(float zoom);
|
|
|
|
|
|
|
|
// don't hide base class virtuals
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetScrollPos( int orient, int pos, bool refresh = true ) wxOVERRIDE
|
2012-03-18 01:12:27 +00:00
|
|
|
{ return wxControl::SetScrollPos(orient, pos, refresh); }
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual int GetScrollPos( int orient ) const wxOVERRIDE
|
2012-03-18 01:12:27 +00:00
|
|
|
{ return wxControl::GetScrollPos(orient); }
|
|
|
|
|
|
|
|
//we need to resize the webview when the control size changes
|
|
|
|
void OnSize(wxSizeEvent &event);
|
|
|
|
void OnMove(wxMoveEvent &event);
|
|
|
|
void OnMouseEvents(wxMouseEvent &event);
|
|
|
|
|
|
|
|
bool m_busy;
|
2016-06-26 05:25:29 +00:00
|
|
|
bool m_nextNavigationIsNewWindow;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
|
|
|
protected:
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE;
|
2013-09-22 22:44:55 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
void MacVisibilityChanged() wxOVERRIDE;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxWindow *m_parent;
|
|
|
|
wxWindowID m_windowID;
|
|
|
|
wxString m_pageTitle;
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
OSXWebViewPtr m_webView;
|
2012-03-18 01:12:27 +00:00
|
|
|
|
|
|
|
// we may use this later to setup our own mouse events,
|
|
|
|
// so leave it in for now.
|
|
|
|
void* m_webKitCtrlEventHandler;
|
|
|
|
//It should be WebView*, but WebView is an Objective-C class
|
|
|
|
//TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
|
|
|
|
};
|
|
|
|
|
2013-09-22 22:44:55 +00:00
|
|
|
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual wxWebView* Create() { return new wxWebViewWebKit; }
|
|
|
|
virtual wxWebView* Create(wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& url = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr)
|
|
|
|
{ return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
|
2012-03-18 01:12:27 +00:00
|
|
|
|
|
|
|
#endif // _WX_WEBKIT_H_
|