]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/textctrl.cpp
non-pch build fix
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
index 8657a5c7920682da196d5e127267da35678dc08e..7df6dba021e0bb6af6e6c44b9f0e93866bb0983e 100644 (file)
 
 #if wxUSE_TEXTCTRL
 
+#include "wx/textctrl.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/dc.h"
+    #include "wx/button.h"
+    #include "wx/menu.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"
     #endif
 #endif
 
-#include "wx/app.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>
+    #include <alloc.h>
 #elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
-  #include <malloc.h>
+    #include <malloc.h>
 #endif
 
 #ifndef __DARWIN__
@@ -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)
@@ -878,8 +885,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
 
     if ( key == 'a' && event.MetaDown() )
     {
-        SelectAll() ;     
-        
+        SelectAll() ;
+
         return ;
     }
 
@@ -1570,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
@@ -1776,6 +1785,8 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo
     if ( style.HasFont() )
     {
         const wxFont &font = style.GetFont() ;
+                
+#if 0 // old version
         wxMacStringToPascal( font.GetFaceName() , fontName ) ;
         fontSize = font.GetPointSize() ;
         if ( font.GetUnderlined() )
@@ -1799,6 +1810,12 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo
         typeAttr[attrCount].size = kTXNQDFontStyleAttributeSize ;
         typeAttr[attrCount].data.dataValue = fontStyle ;
         attrCount++ ;
+#else
+        typeAttr[attrCount].tag = kTXNATSUIStyle ;
+        typeAttr[attrCount].size = kTXNATSUIStyleSize ;
+        typeAttr[attrCount].data.dataValue = (UInt32)font.MacGetATSUStyle() ;
+        attrCount++ ;
+#endif
     }
 
     if ( style.HasTextColour() )