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
|
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
|
||||||
@@ -764,6 +775,9 @@ void wxTextCtrl::SetValue(const wxString& st)
|
|||||||
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() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
||||||
@@ -764,6 +775,9 @@ void wxTextCtrl::SetValue(const wxString& st)
|
|||||||
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() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user