]> git.saurik.com Git - wxWidgets.git/commitdiff
Add start of selection api, support for HasSelection, SelectAll and DeleteSelection...
authorSteve Lamerton <steve.lamerton@gmail.com>
Sat, 9 Jul 2011 14:31:29 +0000 (14:31 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Sat, 9 Jul 2011 14:31:29 +0000 (14:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/webview_webkit.h
include/wx/msw/webview_ie.h
include/wx/osx/webview_webkit.h
include/wx/webview.h
interface/wx/webview.h
src/gtk/webview_webkit.cpp
src/msw/webview_ie.cpp
src/osx/webview_webkit.mm

index a52d8c06e4e293d852393bb29bc78453b856732f..3e4e0f7c88610ecd25b931cc90d023c1a883208b 100644 (file)
@@ -138,6 +138,11 @@ public:
     virtual void SetEditable(bool enable = true);
     virtual bool IsEditable();
 
+    //Selection
+    virtual void DeleteSelection();
+    virtual bool HasSelection();
+    virtual void SelectAll();
+
     /** FIXME: hack to work around signals being received too early */
     bool m_ready;
 
index 3ca29ebaa4a8c94acfcacc20c0af7a3b6e674b8e..2a8163c111780301ef7526da7213c15568241ccd 100644 (file)
@@ -97,6 +97,12 @@ public:
     virtual void SetEditable(bool enable = true);
     virtual bool IsEditable();
 
+    //Selection
+    virtual void SelectAll();
+    virtual bool HasSelection();
+    virtual void DeleteSelection();
+
+
     // ---- IE-specific methods
 
     // FIXME: I seem to be able to access remote webpages even in offline mode...
index ef41abb7fbe22b6e65dddbc4112cf384ad2caa48..37fbf22acceccf0ac82673970dd3752981900f60 100644 (file)
@@ -99,8 +99,13 @@ public:
     virtual void Paste();
     
     //Editing functions
-    void  SetEditable(bool enable = true);
-    bool  IsEditable();
+    virtual void SetEditable(bool enable = true);
+    virtual bool IsEditable();
+    
+    //Selection
+    virtual void DeleteSelection();
+    virtual bool HasSelection() { return false };
+    virtual void SelectAll() {};
 
     // ---- methods not from the parent (common) interface
     wxString GetSelectedText();
index 8e938ea9ee99f85c943c12cc5193e9c903bd1bba..ea241d606cfe5f2d43375b8b879c1ff146d16824 100644 (file)
@@ -284,6 +284,10 @@ public:
     virtual void SetEditable(bool enable = true) = 0;
     virtual bool IsEditable() = 0;
 
+    virtual void SelectAll() = 0;
+    virtual bool HasSelection() = 0;
+    virtual void DeleteSelection() = 0;
+
     // TODO:
     //     wxString GetSelection();                         // maybe?
     //     void SetSelection(...);                          // maybe?
index e28d43ba85c63a6d1383a82249c350b99baa06b3..5927871edde34f9d22e8d940595c73c55738731d 100644 (file)
@@ -381,6 +381,27 @@ public:
         Loads a history item. 
     */
     virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) = 0;
+    
+    /**
+        @name Selection
+    */
+    
+    /**
+        Deletes the current selection. Note that for @c wxWEB_VIEW_BACKEND_WEBKIT
+        the selection must be editable, either through SetEditable or the 
+        correct HTML attribute.
+    */
+    virtual void DeleteSelection() = 0;
+
+    /**
+        Returns @true if there is a current selection.
+    */
+    virtual bool HasSelection = 0;
+
+    /**
+        Selects the entire page.
+    */
+    virtual void SelectAll() = 0;
 
     /**
         @name Undo / Redo
index 9db8e7b24a3a2828afc07d58911cc2c55604236d..dd9a375a755e96f8bddc9b3f12a357675cbf244f 100644 (file)
@@ -712,6 +712,22 @@ bool wxWebViewWebKit::IsEditable()
     return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(web_view));
 }
 
+void wxWebViewWebKit::DeleteSelection()
+{
+    webkit_web_view_delete_selection(WEBKIT_WEB_VIEW(web_view));
+}
+
+bool wxWebViewWebKit::HasSelection()
+{
+    return webkit_web_view_has_selection(WEBKIT_WEB_VIEW(web_view));
+}
+
+void wxWebViewWebKit::SelectAll()
+{
+    webkit_web_view_select_all(WEBKIT_WEB_VIEW(web_view));
+}
+
+
 // static
 wxVisualAttributes
 wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
index 2d04aba3e49be87481771f0cc8c6c25624e6935f..3e0ce6c5e2c24bc677e744304b744e10ac8b05c7 100644 (file)
@@ -564,6 +564,26 @@ bool wxWebViewIE::IsEditable()
         return false;
 }
 
+void wxWebViewIE::SelectAll()
+{
+    ExecCommand("SelectAll");
+}
+
+bool wxWebViewIE::HasSelection()
+{
+    IHTMLDocument2* document = GetDocument();
+    IHTMLSelectionObject* selection;
+    document->get_selection(&selection);
+    BSTR type;
+    selection->get_type(&type);
+    return wxString(type) != "None";
+}
+
+void wxWebViewIE::DeleteSelection()
+{
+    ExecCommand("Delete");
+}
+
 bool wxWebViewIE::CanExecCommand(wxString command)
 {
     IHTMLDocument2* document = GetDocument();
index b33f48a68481c296b4951bd1d39c3dfa666e5b27..9ba00d6c634596f9497db7a5406ee83d1ef4b898 100644 (file)
@@ -980,6 +980,14 @@ void wxWebViewWebKit::Paste()
     [(WebView*)m_webView paste];
 }
 
+void wxWebViewWebKit::DeleteSelection()
+{
+    if ( !m_webView )
+        return;
+
+    [(WebView*)m_webView deleteSelection];
+}
+
 //------------------------------------------------------------
 // Listener interfaces
 //------------------------------------------------------------