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:
@@ -715,15 +715,18 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
Size actualsize;
|
||||
|
||||
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
|
||||
{
|
||||
Handle theText ;
|
||||
OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
|
||||
/* all done */
|
||||
// all done
|
||||
if ( err )
|
||||
{
|
||||
actualsize = 0 ;
|
||||
@@ -736,11 +739,19 @@ wxString wxTextCtrl::GetValue() const
|
||||
DisposeHandle( theText ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxBuffer[actualsize] = 0 ;
|
||||
|
||||
wxString value;
|
||||
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
return wxMacMakePCStringFromMac( wxBuffer ) ;
|
||||
value = wxMacMakePCStringFromMac( wxBuffer ) ;
|
||||
else
|
||||
return wxString(wxBuffer);
|
||||
value = wxBuffer;
|
||||
|
||||
value.Replace( "\r", "\n" );
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void wxTextCtrl::GetSelection(long* from, long* to) const
|
||||
@@ -764,6 +775,9 @@ void wxTextCtrl::SetValue(const wxString& st)
|
||||
value = wxMacMakeMacStringFromPC( st ) ;
|
||||
else
|
||||
value = st;
|
||||
|
||||
value.Replace( "\n", "\r" );
|
||||
|
||||
if ( !m_macUsesTXN )
|
||||
{
|
||||
::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(),
|
||||
kTXNStartOffset, kTXNEndOffset);
|
||||
}
|
||||
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
|
@@ -715,15 +715,18 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
Size actualsize;
|
||||
|
||||
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
|
||||
{
|
||||
Handle theText ;
|
||||
OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
|
||||
/* all done */
|
||||
// all done
|
||||
if ( err )
|
||||
{
|
||||
actualsize = 0 ;
|
||||
@@ -736,11 +739,19 @@ wxString wxTextCtrl::GetValue() const
|
||||
DisposeHandle( theText ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxBuffer[actualsize] = 0 ;
|
||||
|
||||
wxString value;
|
||||
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
return wxMacMakePCStringFromMac( wxBuffer ) ;
|
||||
value = wxMacMakePCStringFromMac( wxBuffer ) ;
|
||||
else
|
||||
return wxString(wxBuffer);
|
||||
value = wxBuffer;
|
||||
|
||||
value.Replace( "\r", "\n" );
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void wxTextCtrl::GetSelection(long* from, long* to) const
|
||||
@@ -764,6 +775,9 @@ void wxTextCtrl::SetValue(const wxString& st)
|
||||
value = wxMacMakeMacStringFromPC( st ) ;
|
||||
else
|
||||
value = st;
|
||||
|
||||
value.Replace( "\n", "\r" );
|
||||
|
||||
if ( !m_macUsesTXN )
|
||||
{
|
||||
::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(),
|
||||
kTXNStartOffset, kTXNEndOffset);
|
||||
}
|
||||
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user