]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/textctrl.cpp
VC6 doesn't like 'return callToVoidFunc();' statements
[wxWidgets.git] / src / os2 / textctrl.cpp
index 0645fb3ed2218f3793fb6b5ce98527f405f6e563..1c7014d733d23ba0c6b57be535ba6966ee61b6a6 100644 (file)
@@ -125,6 +125,7 @@ bool wxTextCtrl::Create(
 
     m_windowStyle = lStyle;
     m_bIsMLE = false;
+    m_bSkipUpdate = false;
 
     long                            lSstyle = WS_VISIBLE | WS_TABSTOP;
 
@@ -159,7 +160,7 @@ bool wxTextCtrl::Create(
     {
         m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                            ,WC_MLE                   // Window class
-                                           ,(PSZ)rsValue.c_str()     // Initial Text
+                                           ,rsValue.c_str()     // Initial Text
                                            ,(ULONG)lSstyle           // Style flags
                                            ,(LONG)0                  // X pos of origin
                                            ,(LONG)0                  // Y pos of origin
@@ -176,7 +177,7 @@ bool wxTextCtrl::Create(
     {
         m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                            ,WC_ENTRYFIELD            // Window class
-                                           ,(PSZ)rsValue.c_str()     // Initial Text
+                                           ,rsValue.c_str()     // Initial Text
                                            ,(ULONG)lSstyle           // Style flags
                                            ,(LONG)0                  // X pos of origin
                                            ,(LONG)0                  // Y pos of origin
@@ -328,7 +329,8 @@ void wxTextCtrl::SetupColours()
 wxString wxTextCtrl::GetValue() const
 {
     wxString                        sStr = wxGetWindowText(GetHWND());
-    char*                           zStr = (char*)sStr.c_str();
+    wxCharBuffer                    buf(sStr.char_str());
+    char*                           zStr = buf.data();
 
     for ( ; *zStr; zStr++ )
     {
@@ -340,11 +342,12 @@ wxString wxTextCtrl::GetValue() const
         if (*zStr == '\r')
             *zStr = '\n';
     }
-    return sStr;
+    return zStr;
 } // end of wxTextCtrl::GetValue
 
-void wxTextCtrl::SetValue(
-  const wxString&                   rsValue
+void wxTextCtrl::DoSetValue(
+  const wxString&                   rsValue,
+  int flags
 )
 {
     //
@@ -355,7 +358,10 @@ void wxTextCtrl::SetValue(
     //
     if ((rsValue.length() > 0x400) || (rsValue != GetValue()))
     {
-        ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str());
+        if ( flags & SetValue_SendEvent )
+            m_bSkipUpdate = true;
+
+        ::WinSetWindowText(GetHwnd(), rsValue.c_str());
         AdjustSpaceLimit();
     }
 } // end of wxTextCtrl::SetValue
@@ -365,9 +371,9 @@ void wxTextCtrl::WriteText(
 )
 {
     if (m_bIsMLE)
-        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0));
+        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM(rsValue.wx_str()), MPARAM(0));
     else
-        ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str());
+        ::WinSetWindowText(GetHwnd(), rsValue.c_str());
     AdjustSpaceLimit();
 } // end of wxTextCtrl::WriteText
 
@@ -679,11 +685,12 @@ void wxTextCtrl::SetSelection(
         ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFromChar, (USHORT)lToChar), (MPARAM)0);
 } // end of wxTextCtrl::SetSelection
 
-bool wxTextCtrl::LoadFile(
-  const wxString&                   rsFile
+bool wxTextCtrl::DoLoadFile(
+  const wxString&                   rsFile,
+  int                               fileType
 )
 {
-    if ( wxTextCtrlBase::LoadFile(rsFile) )
+    if ( wxTextCtrlBase::DoLoadFile(rsFile, fileType) )
     {
         //
         // Update the size limit if needed
@@ -692,7 +699,7 @@ bool wxTextCtrl::LoadFile(
         return true;
     }
     return false;
-} // end of wxTextCtrl::LoadFile
+} // end of wxTextCtrl::DoLoadFile
 
 bool wxTextCtrl::IsModified() const
 {
@@ -1094,6 +1101,12 @@ bool wxTextCtrl::OS2Command(
 
         case EN_CHANGE:
             {
+                if (m_bSkipUpdate)
+                {
+                    m_bSkipUpdate = false;
+                    break;
+                }
+
                 wxCommandEvent      vEvent( wxEVT_COMMAND_TEXT_UPDATED
                                            ,m_windowId
                                           );
@@ -1158,11 +1171,17 @@ void wxTextCtrl::AdjustSpaceLimit()
     }
     if (uLen >= uLimit)
     {
-        uLimit = uLen + 0x8000;    // 32Kb
-        if (uLimit > 0xffff)
+        if (m_bIsMLE)
         {
-            uLimit = 0L;
+            uLimit = uLen + 0x8000;    // 32Kb
+            if (uLimit > 0xffff)
+            {
+                uLimit = 0L;
+            }
         }
+        else
+            uLimit = 0x7fff;
+
         if (m_bIsMLE)
             ::WinSendMsg(GetHwnd(), MLM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0);
         else