]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/textctrl.cpp
Reverted wxChoice size fix due to problems in W2K and below
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
index ddc9c6261dc5c0e497d34f976d8de7c758589871..b536e37c44ab9001565d4e2bd4819685a1ae96f0 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        textctrl.cpp
+// Name:        src/mac/carbon/textctrl.cpp
 // Purpose:     wxTextCtrl
 // Author:      Stefan Csomor
 // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
 // Purpose:     wxTextCtrl
 // Author:      Stefan Csomor
 // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
@@ -401,8 +401,6 @@ private :
 #endif
 };
 
 #endif
 };
 
-#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
-
 
 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
 
@@ -435,7 +433,7 @@ void wxTextCtrl::Init()
     m_editable = true ;
     m_dirty = false;
 
     m_editable = true ;
     m_dirty = false;
 
-    m_maxLength = TE_UNLIMITED_LENGTH ;
+    m_maxLength = 0;
     m_privateContextMenu = NULL;
 }
 
     m_privateContextMenu = NULL;
 }
 
@@ -887,21 +885,24 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     }
 
     if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
     }
 
     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_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END
+        !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
+//        && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
         )
     {
         // eat it
         return ;
     }
 
         )
     {
         // eat it
         return ;
     }
 
-    // Check if we have reached the max # of chars, but still allow navigation and deletion
-    if ( !IsMultiLine() && GetValue().Length() >= m_maxLength &&
+    // Check if we have reached the max # of chars (if it is set), but still
+    // allow navigation and deletion
+    if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
         key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
         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
        )
     {
         // eat it, we don't want to add more than allowed # of characters
+
+        // TODO: generate EVT_TEXT_MAXLEN()
         return;
     }
 
         return;
     }
 
@@ -927,7 +928,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     switch ( key )
     {
         case WXK_RETURN:
     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 );
             {
                 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
                 event.SetEventObject( this );
@@ -1207,7 +1208,7 @@ void wxMacTextControl::SetEditable(bool editable)
 
 wxTextPos wxMacTextControl::GetLastPosition() const
 {
 
 wxTextPos wxMacTextControl::GetLastPosition() const
 {
-    return GetStringValue().Length() ;
+    return GetStringValue().length() ;
 }
 
 void wxMacTextControl::Replace( long from , long to , const wxString &val )
 }
 
 void wxMacTextControl::Replace( long from , long to , const wxString &val )
@@ -1265,7 +1266,7 @@ int wxMacTextControl::GetNumberOfLines() const
     wxString content = GetStringValue() ;
     lines = 1;
 
     wxString content = GetStringValue() ;
     lines = 1;
 
-    for (size_t i = 0; i < content.Length() ; i++)
+    for (size_t i = 0; i < content.length() ; i++)
     {
         if (content[i] == '\r')
             lines++;
     {
         if (content[i] == '\r')
             lines++;
@@ -1281,14 +1282,14 @@ wxString wxMacTextControl::GetLineText(long lineNo) const
 
     // Find line first
     int count = 0;
 
     // Find line first
     int count = 0;
-    for (size_t i = 0; i < content.Length() ; i++)
+    for (size_t i = 0; i < content.length() ; i++)
     {
         if (count == lineNo)
         {
             // Add chars in line then
             wxString tmp;
 
     {
         if (count == lineNo)
         {
             // Add chars in line then
             wxString tmp;
 
-            for (size_t j = i; j < content.Length(); j++)
+            for (size_t j = i; j < content.length(); j++)
             {
                 if (content[j] == '\n')
                     return tmp;
             {
                 if (content[j] == '\n')
                     return tmp;
@@ -1313,13 +1314,13 @@ int wxMacTextControl::GetLineLength(long lineNo) const
 
     // Find line first
     int count = 0;
 
     // Find line first
     int count = 0;
-    for (size_t i = 0; i < content.Length() ; i++)
+    for (size_t i = 0; i < content.length() ; i++)
     {
         if (count == lineNo)
         {
             // Count chars in line then
             count = 0;
     {
         if (count == lineNo)
         {
             // Count chars in line then
             count = 0;
-            for (size_t j = i; j < content.Length(); j++)
+            for (size_t j = i; j < content.length(); j++)
             {
                 count++;
                 if (content[j] == '\n')
             {
                 count++;
                 if (content[j] == '\n')
@@ -1438,7 +1439,9 @@ bool wxMacUnicodeTextControl::CanPaste() const
 
 void wxMacUnicodeTextControl::SetEditable(bool editable)
 {
 
 void wxMacUnicodeTextControl::SetEditable(bool editable)
 {
-    SetData<Boolean>( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#if 0 // leads to problem because text cannot be selected anymore
+    SetData<Boolean>( kControlEditTextPart , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#endif
 }
 
 void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
 }
 
 void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
@@ -1481,7 +1484,7 @@ void wxMacUnicodeTextControl::WriteText( const wxString& str )
         val.Remove( start , end - start ) ;
         val.insert( start , str ) ;
         SetStringValue( val ) ;
         val.Remove( start , end - start ) ;
         val.insert( start , str ) ;
         SetStringValue( val ) ;
-        SetSelection( start + str.Length() , start + str.Length() ) ;
+        SetSelection( start + str.length() , start + str.length() ) ;
 #endif
 }
 
 #endif
 }