X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae25e5cc8c7d538190079056b1778b7edc5e04ec..7b25d8e7bd0eca9f0f6efe62b3721d14c394dac9:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 953ffd15c4..92e971a019 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -2,7 +2,7 @@ // Name: textctrl.cpp // Purpose: wxTextCtrl // Author: Stefan Csomor -// Modified by: +// Modified by: Ryan Norton (MLTE GetLineLength and GetLineText) // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor @@ -300,6 +300,7 @@ public : const wxSize& size, long style ) ; ~wxMacMLTEClassicControl() ; virtual void VisibilityChanged(bool shown) ; + virtual bool NeedsFocusRect() const; protected : OSStatus DoCreate(); public : @@ -389,7 +390,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, { // this control draws the border itself if ( !HasFlag(wxNO_BORDER) ) + { m_windowStyle &= ~wxSUNKEN_BORDER ; + bounds = wxMacGetBoundsForControl( this , pos , size ) ; + } m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ; } @@ -764,6 +768,7 @@ void wxTextCtrl::OnEraseBackground(wxEraseEvent& event) // while this is true for MLTE under classic, the HITextView is somehow // transparent but background erase is not working correctly, so intercept // things while we can... + event.Skip() ; } void wxTextCtrl::OnChar(wxKeyEvent& event) @@ -1153,7 +1158,7 @@ wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxWindow *wxPeer, m_windowStyle = style ; Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; wxMacCFStringHolder cf(st , m_font.GetEncoding()) ; CFStringRef cfr = cf ; Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ; @@ -1195,13 +1200,17 @@ wxString wxMacUnicodeTextControl::GetStringValue() const wxMacCFStringHolder cf(value) ; result = cf.AsString() ; } +#if '\n' == 10 + wxMacConvertNewlines13To10( &result ) ; +#else wxMacConvertNewlines10To13( &result ) ; +#endif return result ; } void wxMacUnicodeTextControl::SetStringValue( const wxString &str) { wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ; verify_noerr( SetData( 0, m_valueTag , cf ) ) ; } @@ -1248,7 +1257,7 @@ void wxMacUnicodeTextControl::SetSelection( long from , long to ) void wxMacUnicodeTextControl::WriteText(const wxString& str) { wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ; CFStringRef value = cf ; @@ -1369,14 +1378,19 @@ wxString wxMacMLTEControl::GetStringValue() const } #endif } +#if '\n' == 10 + wxMacConvertNewlines13To10( &result ) ; +#else wxMacConvertNewlines10To13( &result ) ; +#endif return result ; } void wxMacMLTEControl::SetStringValue( const wxString &str) { wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + + wxMacConvertNewlines10To13( &st ) ; EditHelper help(m_txn) ; // wxMacWindowClipper c( this ) ; @@ -1598,13 +1612,13 @@ long wxMacMLTEControl::GetLastPosition() const void wxMacMLTEControl::Replace( long from , long to , const wxString str ) { wxString value = str ; - wxMacConvertNewlines13To10( &value ) ; + wxMacConvertNewlines10To13( &value ) ; EditHelper help( m_txn ) ; TXNSetSelection(m_txn , from , to ) ; TXNClear( m_txn ) ; - SetTXNData( str , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ; + SetTXNData( value , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ; } void wxMacMLTEControl::Remove( long from , long to ) @@ -1634,7 +1648,7 @@ void wxMacMLTEControl::WriteText(const wxString& str) { EditHelper helper( m_txn ) ; wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; long start , end , dummy ; GetSelection( &start , &dummy ) ; @@ -1825,7 +1839,7 @@ wxString wxMacMLTEControl::GetLineText(long lineNo) const currentHeight += lineHeight; } - Point thePoint = { firstPoint.v + Fix2Long(currentHeight), firstPoint.h + Fix2Long(0) }; + Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) }; TXNOffset theOffset; TXNPointToOffset(m_txn, thePoint, &theOffset); @@ -1864,7 +1878,7 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const currentHeight += lineHeight; } - Point thePoint = { firstPoint.v + Fix2Long(currentHeight), firstPoint.h + Fix2Long(0) }; + Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) }; TXNOffset theOffset; TXNPointToOffset(m_txn, thePoint, &theOffset); @@ -2343,9 +2357,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxWindow *wxPeer, m_windowStyle = style ; Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; - - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; short featurSet; @@ -2461,6 +2473,21 @@ OSStatus wxMacMLTEClassicControl::DoCreate() return err; } +// +// HACKHACK: (RN) +// Classic controls are not initially focused and +// smaller ones are focused badly with the focus rect +// this "fixes" the above issue - but there is probably a +// a better way. +// +// Still, on smaller text controls the focus rect is off +// + +bool wxMacMLTEClassicControl::NeedsFocusRect() const +{ + return m_windowStyle & wxNO_BORDER ? false : true; +} + // ---------------------------------------------------------------------------- // MLTE control implementation (OSX part) // ---------------------------------------------------------------------------- @@ -2478,7 +2505,7 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer, m_windowStyle = style ; Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; - wxMacConvertNewlines13To10( &st ) ; + wxMacConvertNewlines10To13( &st ) ; HIRect hr = { bounds.left , bounds.top , bounds.right - bounds.left , bounds.bottom- bounds.top } ;