]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textentrycmn.cpp
Use wxCOMPtr throughout wxWebViewIE to simplify the code and reduce the chance of...
[wxWidgets.git] / src / common / textentrycmn.cpp
index 51020ddcb40cf7e130645c488545d2a8100b074a..971f5626688ed50faab56148b1f5a62469327d04 100644 (file)
@@ -31,6 +31,7 @@
 #endif //WX_PRECOMP
 
 #include "wx/textentry.h"
+#include "wx/textcompleter.h"
 #include "wx/clipbrd.h"
 
 // ----------------------------------------------------------------------------
@@ -223,10 +224,20 @@ void wxTextEntryBase::AppendText(const wxString& text)
 
 void wxTextEntryBase::DoSetValue(const wxString& value, int flags)
 {
-    EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
+    if ( value != GetValue() )
+    {
+        EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
 
-    SelectAll();
-    WriteText(value);
+        SelectAll();
+        WriteText(value);
+    }
+    else // Same value, no need to do anything.
+    {
+        // Except that we still need to generate the event for consistency with
+        // the normal case when the text does change.
+        if ( flags & SetValue_SendEvent )
+            SendTextUpdatedEvent(GetEditableWindow());
+    }
 
     SetInsertionPoint(0);
 }
@@ -368,4 +379,39 @@ bool wxTextEntryBase::SendTextUpdatedEvent(wxWindow *win)
     return win->HandleWindowEvent(event);
 }
 
+// ----------------------------------------------------------------------------
+// auto-completion stubs
+// ----------------------------------------------------------------------------
+
+wxTextCompleter::~wxTextCompleter()
+{
+}
+
+bool wxTextCompleterSimple::Start(const wxString& prefix)
+{
+    m_index = 0;
+    m_completions.clear();
+    GetCompletions(prefix, m_completions);
+
+    return !m_completions.empty();
+}
+
+wxString wxTextCompleterSimple::GetNext()
+{
+    if ( m_index == m_completions.size() )
+        return wxString();
+
+    return m_completions[m_index++];
+}
+
+bool wxTextEntryBase::DoAutoCompleteCustom(wxTextCompleter *completer)
+{
+    // We don't do anything here but we still need to delete the completer for
+    // consistency with the ports that do implement this method and take
+    // ownership of the pointer.
+    delete completer;
+
+    return false;
+}
+
 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX