Add start of selection api, support for HasSelection, SelectAll and DeleteSelection along with documentation. Implement for IE and WebKitGTK and add stubs for OSX WebKit.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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;
|
||||
|
||||
|
@@ -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...
|
||||
|
@@ -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();
|
||||
|
@@ -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?
|
||||
|
@@ -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
|
||||
|
@@ -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))
|
||||
|
@@ -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();
|
||||
|
@@ -980,6 +980,14 @@ void wxWebViewWebKit::Paste()
|
||||
[(WebView*)m_webView paste];
|
||||
}
|
||||
|
||||
void wxWebViewWebKit::DeleteSelection()
|
||||
{
|
||||
if ( !m_webView )
|
||||
return;
|
||||
|
||||
[(WebView*)m_webView deleteSelection];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Listener interfaces
|
||||
//------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user