Convert to and from \n and \r in wxMac's text

control so that it always expects \n as in
     all other ports.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16172 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-07-14 16:51:35 +00:00
parent dda2e4fdca
commit 29e4a1901a
2 changed files with 502 additions and 472 deletions

View File

@@ -715,15 +715,18 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
wxString wxTextCtrl::GetValue() const wxString wxTextCtrl::GetValue() const
{ {
Size actualsize; Size actualsize;
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; ::GetControlData( (ControlHandle) m_macControl, 0,
( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag,
32767 , wxBuffer , &actualsize ) ;
} }
else else
{ {
Handle theText ; Handle theText ;
OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
/* all done */ // all done
if ( err ) if ( err )
{ {
actualsize = 0 ; actualsize = 0 ;
@@ -736,11 +739,19 @@ wxString wxTextCtrl::GetValue() const
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
} }
wxBuffer[actualsize] = 0 ; wxBuffer[actualsize] = 0 ;
wxString value;
if( wxApp::s_macDefaultEncodingIsPC ) if( wxApp::s_macDefaultEncodingIsPC )
return wxMacMakePCStringFromMac( wxBuffer ) ; value = wxMacMakePCStringFromMac( wxBuffer ) ;
else else
return wxString(wxBuffer); value = wxBuffer;
value.Replace( "\r", "\n" );
return value;
} }
void wxTextCtrl::GetSelection(long* from, long* to) const void wxTextCtrl::GetSelection(long* from, long* to) const
@@ -758,12 +769,15 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
void wxTextCtrl::SetValue(const wxString& st) void wxTextCtrl::SetValue(const wxString& st)
{ {
wxString value ; wxString value;
if( wxApp::s_macDefaultEncodingIsPC ) if( wxApp::s_macDefaultEncodingIsPC )
value = wxMacMakeMacStringFromPC( st ) ; value = wxMacMakeMacStringFromPC( st ) ;
else else
value = st ; value = st;
value.Replace( "\n", "\r" );
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
@@ -773,6 +787,7 @@ void wxTextCtrl::SetValue(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
} }
MacRedrawControl() ; MacRedrawControl() ;
} }

View File

@@ -715,15 +715,18 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
wxString wxTextCtrl::GetValue() const wxString wxTextCtrl::GetValue() const
{ {
Size actualsize; Size actualsize;
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; ::GetControlData( (ControlHandle) m_macControl, 0,
( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag,
32767 , wxBuffer , &actualsize ) ;
} }
else else
{ {
Handle theText ; Handle theText ;
OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
/* all done */ // all done
if ( err ) if ( err )
{ {
actualsize = 0 ; actualsize = 0 ;
@@ -736,11 +739,19 @@ wxString wxTextCtrl::GetValue() const
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
} }
wxBuffer[actualsize] = 0 ; wxBuffer[actualsize] = 0 ;
wxString value;
if( wxApp::s_macDefaultEncodingIsPC ) if( wxApp::s_macDefaultEncodingIsPC )
return wxMacMakePCStringFromMac( wxBuffer ) ; value = wxMacMakePCStringFromMac( wxBuffer ) ;
else else
return wxString(wxBuffer); value = wxBuffer;
value.Replace( "\r", "\n" );
return value;
} }
void wxTextCtrl::GetSelection(long* from, long* to) const void wxTextCtrl::GetSelection(long* from, long* to) const
@@ -758,12 +769,15 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
void wxTextCtrl::SetValue(const wxString& st) void wxTextCtrl::SetValue(const wxString& st)
{ {
wxString value ; wxString value;
if( wxApp::s_macDefaultEncodingIsPC ) if( wxApp::s_macDefaultEncodingIsPC )
value = wxMacMakeMacStringFromPC( st ) ; value = wxMacMakeMacStringFromPC( st ) ;
else else
value = st ; value = st;
value.Replace( "\n", "\r" );
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
@@ -773,6 +787,7 @@ void wxTextCtrl::SetValue(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
} }
MacRedrawControl() ; MacRedrawControl() ;
} }