#include "wx/setup.h"
-#if wxUSE_WEBKIT && (defined(__WXMAC__) || defined(__WXCOCOA__))
+#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
+ || defined(__WXOSX_CARBON__))
#include "wx/control.h"
#include "wx/webview.h"
+#include "wx/osx/core/objcid.h"
+
// ----------------------------------------------------------------------------
// Web Kit Control
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_WEB wxWebViewWebKit : public wxWebView
+class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
{
public:
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
const wxString& name = wxWebViewNameStr);
virtual ~wxWebViewWebKit();
- void InternalLoadURL(const wxString &url);
-
- virtual bool CanGoBack();
- virtual bool CanGoForward();
+ virtual bool CanGoBack() const;
+ virtual bool CanGoForward() const;
virtual void GoBack();
virtual void GoForward();
- virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
+ virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT);
virtual void Stop();
- virtual wxString GetPageSource();
- virtual void SetPageTitle(const wxString& title) { m_pageTitle = title; }
- virtual wxString GetPageTitle(){ return m_pageTitle; }
-
- virtual void SetPage(const wxString& html, const wxString& baseUrl);
+ virtual wxString GetPageSource() const;
+ virtual wxString GetPageText() const;
virtual void Print();
- virtual void LoadUrl(const wxString& url);
- virtual wxString GetCurrentURL();
- virtual wxString GetCurrentTitle();
- virtual wxWebViewZoom GetZoom();
+ virtual void LoadURL(const wxString& url);
+ virtual wxString GetCurrentURL() const;
+ virtual wxString GetCurrentTitle() const;
+ virtual wxWebViewZoom GetZoom() const;
virtual void SetZoom(wxWebViewZoom zoom);
virtual void SetZoomType(wxWebViewZoomType zoomType);
virtual wxWebViewZoomType GetZoomType() const;
virtual bool CanSetZoomType(wxWebViewZoomType type) const;
- virtual bool IsBusy() { return m_busy; }
-
+ virtual bool IsBusy() const { return m_busy; }
+
//History functions
- virtual void ClearHistory() {}
- virtual void EnableHistory(bool enable = true) {}
- virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory()
- { return wxVector<wxSharedPtr<wxWebHistoryItem> >() }
- virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory()
- { return wxVector<wxSharedPtr<wxWebHistoryItem> >() }
- virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) {}
-
+ virtual void ClearHistory();
+ virtual void EnableHistory(bool enable = true);
+ virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
+ virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
+ virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
+
//Undo / redo functionality
- virtual bool CanUndo() {}
- virtual bool CanRedo() {}
- virtual void Undo() {}
- virtual void Redo() {}
+ virtual bool CanUndo() const;
+ virtual bool CanRedo() const;
+ virtual void Undo();
+ virtual void Redo();
+
+ //Find function
+ virtual long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT)
+ {
+ wxUnusedVar(text);
+ wxUnusedVar(flags);
+ return wxNOT_FOUND;
+ }
//Clipboard functions
- virtual bool CanCut() {}
- virtual bool CanCopy() {}
- virtual bool CanPaste() {}
- virtual void Cut() {}
- virtual void Copy() {}
- virtual void Paste() {}
+ virtual bool CanCut() const { return true; }
+ virtual bool CanCopy() const { return true; }
+ virtual bool CanPaste() const { return true; }
+ virtual void Cut();
+ virtual void Copy();
+ virtual void Paste();
- // ---- methods not from the parent (common) interface
- wxString GetSelectedText();
+ //Editing functions
+ virtual void SetEditable(bool enable = true);
+ virtual bool IsEditable() const;
- wxString RunScript(const wxString& javascript);
+ //Selection
+ virtual void DeleteSelection();
+ virtual bool HasSelection() const;
+ virtual void SelectAll();
+ virtual wxString GetSelectedText() const;
+ virtual wxString GetSelectedSource() const;
+ virtual void ClearSelection();
- bool CanGetPageSource();
+ void RunScript(const wxString& javascript);
- void SetScrollPos(int pos);
- int GetScrollPos();
+ //Virtual Filesystem Support
+ virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
- void MakeEditable(bool enable = true);
- bool IsEditable();
+ virtual void* GetNativeBackend() const { return m_webView; }
- wxString GetSelection();
+ // ---- methods not from the parent (common) interface
+ bool CanGetPageSource() const;
- bool CanIncreaseTextSize();
+ void SetScrollPos(int pos);
+ int GetScrollPos();
+
+ bool CanIncreaseTextSize() const;
void IncreaseTextSize();
- bool CanDecreaseTextSize();
+ bool CanDecreaseTextSize() const;
void DecreaseTextSize();
- float GetWebkitZoom();
+ float GetWebkitZoom() const;
void SetWebkitZoom(float zoom);
// don't hide base class virtuals
bool m_busy;
protected:
+ virtual void DoSetPage(const wxString& html, const wxString& baseUrl);
+
DECLARE_EVENT_TABLE()
void MacVisibilityChanged();
wxWindowID m_windowID;
wxString m_pageTitle;
- struct objc_object *m_webView;
+ wxObjCID m_webView;
// we may use this later to setup our own mouse events,
// so leave it in for now.
//TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
};
-#endif // wxUSE_WEBKIT
+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
#endif // _WX_WEBKIT_H_