]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textentrycmn.cpp
fix bad typo in the code: wxIMAGE_OPTION_RESOLUTION option was used where wxIMAGE_OPT...
[wxWidgets.git] / src / common / textentrycmn.cpp
index 956d5d591407408e4b8e0809341c050ef612d05a..8e0551c3dbac703c86d23859cbc64cf0ace15b9e 100644 (file)
@@ -26,6 +26,8 @@
 #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
 
 #ifndef WX_PRECOMP
+    #include "wx/window.h"
+    #include "wx/dataobj.h"
 #endif //WX_PRECOMP
 
 #include "wx/textentry.h"
 wxString wxTextEntryBase::GetRange(long from, long to) const
 {
     wxString sel;
-    if ( from < to )
+    wxString value = GetValue();
+
+    if ( from < to && (long)value.length() >= to )
     {
-        sel = GetValue().substr(from, to - from);
+        sel = value.substr(from, to - from);
     }
 
     return sel;
@@ -58,6 +62,8 @@ void wxTextEntryBase::DoSetValue(const wxString& value, int flags)
 
     SelectAll();
     WriteText(value);
+
+    SetInsertionPoint(0);
 }
 
 void wxTextEntryBase::Replace(long from, long to, const wxString& value)
@@ -78,6 +84,14 @@ bool wxTextEntryBase::HasSelection() const
     return from < to;
 }
 
+void wxTextEntryBase::RemoveSelection()
+{
+    long from, to;
+    GetSelection(& from, & to);
+    if (from != -1 && to != -1)
+        Remove(from, to);
+}
+
 wxString wxTextEntryBase::GetStringSelection() const
 {
     long from, to;
@@ -102,8 +116,14 @@ bool wxTextEntryBase::CanPaste() const
     {
 #if wxUSE_CLIPBOARD
         // check if there is any text on the clipboard
-        if ( wxTheClipboard->IsSupported(wxDF_TEXT) )
+        if ( wxTheClipboard->IsSupported(wxDF_TEXT)
+#if wxUSE_UNICODE
+                || wxTheClipboard->IsSupported(wxDF_UNICODETEXT)
+#endif // wxUSE_UNICODE
+           )
+        {
             return true;
+        }
 #endif // wxUSE_CLIPBOARD
     }