]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/textctrl.cpp
overwrote with src\wxBase.dsp
[wxWidgets.git] / src / mac / textctrl.cpp
index cda4bcd0de5e581b3a3e8e64bee03f5fd38f3826..c6a6d86e092aec816ccd0c601333fc1677a232e1 100644 (file)
 #pragma implementation "textctrl.h"
 #endif
 
 #pragma implementation "textctrl.h"
 #endif
 
+#include "wx/defs.h"
+
+#if wxUSE_TEXTCTRL
+
 #ifdef __DARWIN__
   #include <sys/types.h>
   #include <sys/stat.h>
 #ifdef __DARWIN__
   #include <sys/types.h>
   #include <sys/stat.h>
@@ -553,8 +557,16 @@ void wxTextCtrl::DiscardEdits()
 
 int wxTextCtrl::GetNumberOfLines() const
 {
 
 int wxTextCtrl::GetNumberOfLines() const
 {
-    // TODO
-    return 0;
+       Size actualsize;
+       UMAGetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
+       
+       int count = 1;
+       for (int i = 0; i < actualsize; i++)
+       {
+           if (wxBuffer[i] == '\r') count++;
+       }
+       
+    return count;
 }
 
 long wxTextCtrl::XYToPosition(long x, long y) const
 }
 
 long wxTextCtrl::XYToPosition(long x, long y) const
@@ -575,12 +587,59 @@ void wxTextCtrl::ShowPosition(long pos)
 
 int wxTextCtrl::GetLineLength(long lineNo) const
 {
 
 int wxTextCtrl::GetLineLength(long lineNo) const
 {
-    return GetValue().Length();
+       Size actualsize;
+       UMAGetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
+       
+       // Find line first
+       int count = 0;
+       for (int i = 0; i < actualsize; i++)
+       {
+           if (count == lineNo)
+           {
+               // Count chars in line then
+               count = 0;
+               for (int j = i; j < actualsize; j++)
+               {
+                   count++;
+                   if (wxBuffer[j] == '\r') return count;
+               }
+               
+               return count;
+           }
+           if (wxBuffer[i] == '\r') count++;
+       }
+       
+    return 0;
 }
 
 wxString wxTextCtrl::GetLineText(long lineNo) const
 {
 }
 
 wxString wxTextCtrl::GetLineText(long lineNo) const
 {
-    return GetValue();
+       Size actualsize;
+       UMAGetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
+       
+       // Find line first
+       int count = 0;
+       for (int i = 0; i < actualsize; i++)
+       {
+           if (count == lineNo)
+           {
+               // Add chars in line then
+               wxString tmp("");
+               
+               for (int j = i; j < actualsize; j++)
+               {
+                   if (wxBuffer[j] == '\r')
+                       return tmp;
+                       
+                   tmp += wxBuffer[j];
+               }
+               
+               return tmp;
+           }
+           if (wxBuffer[i] == '\r') count++;
+       }
+       
+    return wxString("");
 }
 
 /*
 }
 
 /*
@@ -625,12 +684,15 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
                        }
                        if ( panel && panel->GetDefaultItem() )
                        {
                        }
                        if ( panel && panel->GetDefaultItem() )
                        {
-                               wxButton *def = panel->GetDefaultItem() ;
-                               wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
-                                       event.SetEventObject(def);
-                                       def->Command(event);
-                               event.Skip() ;
-                       return ;
+                    wxButton *def = wxDynamicCast(panel->GetDefaultItem(),
+                                                          wxButton);
+                               if ( def && def->IsEnabled() )
+                               {
+                                   wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+                                           event.SetEventObject(def);
+                                           def->Command(event);
+                       return ;
+                   }
                        }
             }
             //else: multiline controls need Enter for themselves
                        }
             }
             //else: multiline controls need Enter for themselves
@@ -726,3 +788,5 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
     event.Enable( CanRedo() );
 }
 
     event.Enable( CanRedo() );
 }
 
+#endif
+    // wxUSE_TEXTCTRL