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 void SetEditable(bool enable = true);
|
||||||
virtual bool IsEditable();
|
virtual bool IsEditable();
|
||||||
|
|
||||||
|
//Selection
|
||||||
|
virtual void DeleteSelection();
|
||||||
|
virtual bool HasSelection();
|
||||||
|
virtual void SelectAll();
|
||||||
|
|
||||||
/** FIXME: hack to work around signals being received too early */
|
/** FIXME: hack to work around signals being received too early */
|
||||||
bool m_ready;
|
bool m_ready;
|
||||||
|
|
||||||
|
@@ -97,6 +97,12 @@ public:
|
|||||||
virtual void SetEditable(bool enable = true);
|
virtual void SetEditable(bool enable = true);
|
||||||
virtual bool IsEditable();
|
virtual bool IsEditable();
|
||||||
|
|
||||||
|
//Selection
|
||||||
|
virtual void SelectAll();
|
||||||
|
virtual bool HasSelection();
|
||||||
|
virtual void DeleteSelection();
|
||||||
|
|
||||||
|
|
||||||
// ---- IE-specific methods
|
// ---- IE-specific methods
|
||||||
|
|
||||||
// FIXME: I seem to be able to access remote webpages even in offline mode...
|
// FIXME: I seem to be able to access remote webpages even in offline mode...
|
||||||
|
@@ -99,8 +99,13 @@ public:
|
|||||||
virtual void Paste();
|
virtual void Paste();
|
||||||
|
|
||||||
//Editing functions
|
//Editing functions
|
||||||
void SetEditable(bool enable = true);
|
virtual void SetEditable(bool enable = true);
|
||||||
bool IsEditable();
|
virtual bool IsEditable();
|
||||||
|
|
||||||
|
//Selection
|
||||||
|
virtual void DeleteSelection();
|
||||||
|
virtual bool HasSelection() { return false };
|
||||||
|
virtual void SelectAll() {};
|
||||||
|
|
||||||
// ---- methods not from the parent (common) interface
|
// ---- methods not from the parent (common) interface
|
||||||
wxString GetSelectedText();
|
wxString GetSelectedText();
|
||||||
|
@@ -284,6 +284,10 @@ public:
|
|||||||
virtual void SetEditable(bool enable = true) = 0;
|
virtual void SetEditable(bool enable = true) = 0;
|
||||||
virtual bool IsEditable() = 0;
|
virtual bool IsEditable() = 0;
|
||||||
|
|
||||||
|
virtual void SelectAll() = 0;
|
||||||
|
virtual bool HasSelection() = 0;
|
||||||
|
virtual void DeleteSelection() = 0;
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// wxString GetSelection(); // maybe?
|
// wxString GetSelection(); // maybe?
|
||||||
// void SetSelection(...); // maybe?
|
// void SetSelection(...); // maybe?
|
||||||
|
@@ -382,6 +382,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) = 0;
|
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
|
@name Undo / Redo
|
||||||
*/
|
*/
|
||||||
|
@@ -712,6 +712,22 @@ bool wxWebViewWebKit::IsEditable()
|
|||||||
return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(web_view));
|
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
|
// static
|
||||||
wxVisualAttributes
|
wxVisualAttributes
|
||||||
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||||
|
@@ -564,6 +564,26 @@ bool wxWebViewIE::IsEditable()
|
|||||||
return false;
|
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)
|
bool wxWebViewIE::CanExecCommand(wxString command)
|
||||||
{
|
{
|
||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
|
@@ -980,6 +980,14 @@ void wxWebViewWebKit::Paste()
|
|||||||
[(WebView*)m_webView paste];
|
[(WebView*)m_webView paste];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWebViewWebKit::DeleteSelection()
|
||||||
|
{
|
||||||
|
if ( !m_webView )
|
||||||
|
return;
|
||||||
|
|
||||||
|
[(WebView*)m_webView deleteSelection];
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
// Listener interfaces
|
// Listener interfaces
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user