]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/textctrl.cpp
remove the vertical scrollbar completely if the control is empty
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
index 61cdda06539b4a876a42097ca12939f7bf47e85f..fddd31d2bc6987539bba26bef7d1276e542e5eff 100644 (file)
 
 #if wxUSE_TEXTCTRL
 
+#include "wx/textctrl.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+#endif
 
 #ifdef __DARWIN__
-  #include <sys/types.h>
-  #include <sys/stat.h>
+    #include <sys/types.h>
+    #include <sys/stat.h>
 #else
-  #include <stat.h>
+    #include <stat.h>
 #endif
 
 #include "wx/msgdlg.h"
 #include "wx/dc.h"
 #include "wx/button.h"
 #include "wx/toplevel.h"
-#include "wx/textctrl.h"
 #include "wx/settings.h"
 #include "wx/filefn.h"
 #include "wx/utils.h"
 #include "wx/sysopt.h"
 #include "wx/menu.h"
-#include "wx/intl.h"
 
 #if defined(__BORLANDC__) && !defined(__WIN32__)
   #include <alloc.h>
@@ -435,6 +438,7 @@ void wxTextCtrl::Init()
 
     m_maxLength = 0;
     m_privateContextMenu = NULL;
+    m_triggerOnSetValue = true ;
 }
 
 wxTextCtrl::~wxTextCtrl()
@@ -545,10 +549,13 @@ void wxTextCtrl::SetValue(const wxString& str)
 
     GetPeer()->SetStringValue( str ) ;
 
-    wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
-    event.SetString( GetValue() );
-    event.SetEventObject( this );
-    GetEventHandler()->ProcessEvent( event );
+    if ( m_triggerOnSetValue )
+    {
+        wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
+        event.SetString( GetValue() );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    }
 }
 
 void wxTextCtrl::SetMaxLength(unsigned long len)
@@ -876,6 +883,13 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     int key = event.GetKeyCode() ;
     bool eat_key = false ;
 
+    if ( key == 'a' && event.MetaDown() )
+    {
+        SelectAll() ;
+
+        return ;
+    }
+
     if ( key == 'c' && event.MetaDown() )
     {
         if ( CanCopy() )
@@ -885,7 +899,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     }
 
     if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
-        !( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
+        !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
 //        && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
         )
     {
@@ -897,7 +911,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     // allow navigation and deletion
     if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
         key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
-        key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
+        key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) )
        )
     {
         // eat it, we don't want to add more than allowed # of characters
@@ -928,7 +942,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     switch ( key )
     {
         case WXK_RETURN:
-            if (m_windowStyle & wxPROCESS_ENTER)
+            if (m_windowStyle & wxTE_PROCESS_ENTER)
             {
                 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
                 event.SetEventObject( this );
@@ -1563,9 +1577,11 @@ wxString wxMacMLTEControl::GetStringValue() const
                 (((UniChar*)*theText)[actualSize]) = 0 ;
                 wxMBConvUTF16 converter ;
                 size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
+                wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
                 ptr = new wxChar[noChars + 1] ;
 
-                noChars = converter.MB2WC( ptr , (const char*)*theText , noChars ) ;
+                noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ;
+                wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
                 ptr[noChars] = 0 ;
                 HUnlock( theText ) ;
 #endif