X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/152a58083fbe9ad9ff15f41472e0a2fdf9f73fb3..7bd30a12ade503fd135c686ecc98a6f6d5fecbeb:/include/wx/webview.h diff --git a/include/wx/webview.h b/include/wx/webview.h index 53317c3421..0bc9f8547e 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -3,7 +3,7 @@ // Purpose: Common interface and events for web view component // Author: Marianne Gagnon // Id: $Id$ -// Copyright: (c) 2010 Marianne Gagnon +// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,6 +17,16 @@ #include #include #include +#include "wx/sharedptr.h" +#include "wx/vector.h" + +#include "wx/osx/webhistoryitem_webkit.h" +#include "wx/gtk/webhistoryitem_webkit.h" +#include "wx/msw/webhistoryitem_ie.h" + +class wxFSFile; +class wxFileSystem; + /** * Zoom level in web view component @@ -83,16 +93,22 @@ enum wxWebViewBackend * engine for the current platform*/ wxWEB_VIEW_BACKEND_DEFAULT, - /** The OSX-native WebKit web engine */ - wxWEB_VIEW_BACKEND_OSX_WEBKIT, - - /** The GTK port of the WebKit engine */ - wxWEB_VIEW_BACKEND_GTK_WEBKIT, + /** The WebKit web engine */ + wxWEB_VIEW_BACKEND_WEBKIT, /** Use Microsoft Internet Explorer as web engine */ wxWEB_VIEW_BACKEND_IE }; +//Base class for custom scheme handlers +class WXDLLIMPEXP_WEB wxWebHandler +{ +public: + virtual wxString GetName() const = 0; + virtual wxFSFile* GetFile(const wxString &uri) = 0; + virtual wxString CombineURIs(const wxString &baseuri, const wxString &newuri) = 0; +}; + extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewNameStr[]; extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewDefaultURLStr[]; @@ -175,6 +191,9 @@ public: virtual void ClearHistory() = 0; virtual void EnableHistory(bool enable = true) = 0; + virtual wxVector > GetBackwardHistory() = 0; + virtual wxVector > GetForwardHistory() = 0; + virtual void LoadHistoryItem(wxSharedPtr item) = 0; /** * Stop the current page loading process, if any. @@ -208,6 +227,7 @@ public: * shown */ virtual wxString GetPageSource() = 0; + virtual wxString GetPageText() = 0; /** * Get the zoom factor of the page @@ -267,15 +287,21 @@ public: SetPage(stream.GetString(), baseUrl); } - // TODO: - // wxString GetSelection(); // maybe? - // void SetSelection(...); // maybe? + virtual void SetEditable(bool enable = true) = 0; + virtual bool IsEditable() = 0; - // void MakeEditable(bool enable = true); // maybe? - // bool IsEditable(); // maybe? + virtual void SelectAll() = 0; + virtual bool HasSelection() = 0; + virtual void DeleteSelection() = 0; + virtual wxString GetSelectedText() = 0; + virtual wxString GetSelectedSource() = 0; + virtual void ClearSelection() = 0; + virtual void RunScript(const wxString& javascript) = 0; + + // TODO: // void EnableJavascript(bool enabled); // maybe? - // wxString RunScript(const wxString& javascript); // maybe? + // // maybe? // void SetScrollPos(int pos); // maybe? // int GetScrollPos(); // maybe? @@ -288,16 +314,6 @@ public: // virtual bool IsOfflineMode() = 0; // maybe? // virtual void SetOfflineMode(bool offline) = 0; // maybe? - // TODO: offer API to control the opening of new frames - // (through as well as through javascript), OR - // provide a behavior consistent across ports. - // - OSX : I receive an event for new frames opened with HTML target, and - // currently block them all. - // - IE : An event is recieved for new frames and they are currently - // blocked - // - GTK : All frame open requests are blocked. A slot exists that I could - // connect to to be notified if ever needed - /** * Opens a print dialog so that the user may print the currently * displayed page. @@ -308,17 +324,36 @@ public: * Returns whether the web control is currently busy (e.g. loading a page) */ virtual bool IsBusy() = 0; + + //Clipboard functions + virtual bool CanCut() = 0; + virtual bool CanCopy() = 0; + virtual bool CanPaste() = 0; + virtual void Cut() = 0; + virtual void Copy() = 0; + virtual void Paste() = 0; + + //Undo / redo functionality + virtual bool CanUndo() = 0; + virtual bool CanRedo() = 0; + virtual void Undo() = 0; + virtual void Redo() = 0; + + //Virtual Filesystem Support + virtual void RegisterHandler(wxWebHandler* handler) = 0; + + wxDECLARE_ABSTRACT_CLASS(wxWebView); }; class WXDLLIMPEXP_WEB wxWebNavigationEvent : public wxCommandEvent { public: wxWebNavigationEvent() {} - wxWebNavigationEvent(wxEventType type, int id, const wxString href, + wxWebNavigationEvent(wxEventType type, int id, const wxString url, const wxString target, bool canVeto) : wxCommandEvent(type, id) { - m_href = href; + m_url = url; m_target = target; m_vetoed = false; m_canVeto = canVeto; @@ -327,7 +362,7 @@ public: /** * Get the URL being visited */ - const wxString& GetHref() const { return m_href; } + const wxString& GetURL() const { return m_url; } /** * Get the target (frame or window) in which the URL that caused this event @@ -354,7 +389,7 @@ public: void Veto() { wxASSERT(m_canVeto); m_vetoed = true; } private: - wxString m_href; + wxString m_url; wxString m_target; bool m_canVeto; bool m_vetoed; @@ -367,6 +402,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEB, wxEVT_COMMAND_WEB_VIEW_NAVIGATED, wxW wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEB, wxEVT_COMMAND_WEB_VIEW_LOADED, wxWebNavigationEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEB, wxEVT_COMMAND_WEB_VIEW_ERROR, wxWebNavigationEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEB, wxEVT_COMMAND_WEB_VIEW_NEWWINDOW, wxWebNavigationEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEB, wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED, wxWebNavigationEvent ); typedef void (wxEvtHandler::*wxWebNavigationEventFunction) (wxWebNavigationEvent&); @@ -394,6 +430,10 @@ typedef void (wxEvtHandler::*wxWebNavigationEventFunction) wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW, id, \ wxHtmlNavigatingEventHandler(fn)) +#define EVT_WEB_VIEW_TITLE_CHANGED(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED, id, \ + wxHtmlNavigatingEventHandler(fn)) + #endif // wxUSE_WEB #endif // _WX_WEB_VIEW_H_