]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/textctrl.cpp
Applied patch [ 666379 ] CalCtrl doesn't use best sizes for the year combobox
[wxWidgets.git] / src / motif / textctrl.cpp
index fe48ec22b6de1f8f80273c0d03bff4b2e8b27c15..7bb9799cae4a5f6d2e0cd2656115631bb65ae002 100644 (file)
     #pragma implementation "textctrl.h"
 #endif
 
+#ifdef __VMS
+#define XtParent XTPARENT
+#endif
+
+#include "wx/defs.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <fstream.h>
 #include <ctype.h>
 
 #include "wx/textctrl.h"
@@ -57,7 +62,6 @@ static void wxTextWindowGainFocusProc(Widget w, XtPointer clientData, XmAnyCallb
 static void wxTextWindowLoseFocusProc(Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
 static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallbackStruct *ptr);
 
-#if !USE_SHARED_LIBRARY
     IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
 
     BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
@@ -77,7 +81,6 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallba
     EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
 
     END_EVENT_TABLE()
-#endif
 
 // ============================================================================
 // implementation
@@ -302,7 +305,7 @@ bool wxTextCtrl::CanCut() const
     // Can cut if there's a selection
     long from, to;
     GetSelection(& from, & to);
-    return (from != to) ;
+    return (from != to) && (IsEditable());
 }
 
 bool wxTextCtrl::CanPaste() const
@@ -391,6 +394,9 @@ void wxTextCtrl::Remove(long from, long to)
 
 void wxTextCtrl::SetSelection(long from, long to)
 {
+    if( to == -1 )
+        to = GetLastPosition();
+
     XmTextSetSelection ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
                       (Time) 0);
 }
@@ -663,7 +669,7 @@ void wxTextCtrl::ChangeBackgroundColour()
             XmNhorizontalScrollBar, &hsb,
             XmNverticalScrollBar, &vsb,
             NULL);
-        wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+        wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
         if (hsb)
             DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
         if (vsb)
@@ -758,7 +764,9 @@ static void MergeChangesIntoString(wxString& value,
         const char * const passwd = value;
         int len = value.length();
 
-        len += strlen(cbs->text->ptr) + 1;     // + new text (if any) + NUL
+        len += ( cbs->text->ptr ?
+                 strlen(cbs->text->ptr) :
+                 0 ) + 1;                      // + new text (if any) + NUL
         len -= cbs->endPos - cbs->startPos;    // - text from affected region.
 
         char * newS = new char [len];
@@ -772,8 +780,9 @@ static void MergeChangesIntoString(wxString& value,
             *dest++ = *p++;
 
         // Copy the text to be inserted).
-        while (*insert)
-            *dest++ = *insert++;
+        if (insert)
+            while (*insert)
+                *dest++ = *insert++;
 
         // Finally, copy into newS any remaining text from passwd[endPos] on.
         for (p = passwd + cbs->endPos; *p; )