X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90b959aee428b26304ee0056864af48775051496..f2616db56739e4962f683f59ac9e207756efe23c:/src/mac/textctrl.cpp diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 0724fe9da9..f522366b32 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -13,7 +13,7 @@ #pragma implementation "textctrl.h" #endif -#ifdef __UNIX__ +#ifdef __DARWIN__ #include #include #else @@ -34,7 +34,7 @@ #if defined(__BORLANDC__) && !defined(__WIN32__) #include -#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__WXMAC_X__) +#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__) #include #endif @@ -553,8 +553,16 @@ void wxTextCtrl::DiscardEdits() 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 @@ -575,12 +583,59 @@ void wxTextCtrl::ShowPosition(long pos) 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 { - 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 +680,15 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } 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