removal of pc-mac charset conversion for wxMac

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23579 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2003-09-14 18:40:43 +00:00
parent a2b436fb40
commit 939fba6c17
26 changed files with 131 additions and 572 deletions

View File

@@ -291,12 +291,6 @@ public:
int argc; int argc;
wxChar **argv; wxChar **argv;
#ifdef __WXMAC__
// This is needed in the wxAppConsole class because it is refereced from
// the wxBase library
static bool s_macDefaultEncodingIsPC ;
#endif
protected: protected:
// the function which creates the traits object when GetTraits() needs it // the function which creates the traits object when GetTraits() needs it
// for the first time // for the first time

View File

@@ -157,18 +157,11 @@ enum wxSeekMode
WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf ); WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf );
WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode ); WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode );
WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode ); WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode );
#else
#if defined(__WXMAC__) && !defined(__DARWIN__) && !wxUSE_UNICODE
#include <sys/stat.h>
WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf );
WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode );
WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode );
#else #else
#define wxOpen open #define wxOpen open
#define wxStat stat #define wxStat stat
#define wxAccess access #define wxAccess access
#endif #endif
#endif
#endif // VC++ #endif // VC++

View File

@@ -161,11 +161,6 @@ void wxMacCleanupConverters() ;
void wxMacStringToPascal( const wxString&from , StringPtr to ) ; void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
wxCharBuffer wxMacStringToCString( const wxString &from ) ;
wxWCharBuffer wxMacStringToWString( const wxString &from ) ;
wxString wxMacMakeStringFromCString( const char * from , int len ) ;
wxString wxMacMakeStringFromCString( const char * from ) ;
#if TARGET_CARBON #if TARGET_CARBON
class wxMacCFStringHolder class wxMacCFStringHolder
@@ -227,81 +222,7 @@ private:
bool m_release ; bool m_release ;
} ; } ;
// CFStringRef wxMacStringToCFString( const wxString &str ) ;
// wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
#endif #endif
#if 0
void wxMacConvertToPC( const char *from , char *to , int len ) ;
void wxMacConvertFromPC( const char *from , char *to , int len ) ;
void wxMacConvertToPC( const char *from , char *to , int len ) ;
wxString wxMacMakeMacStringFromPC( const wxChar * p ) ;
wxString wxMacMakePCStringFromMac( const wxChar * p ) ;
// converts this c string into a wxString with optional mac 2 pc encoding
wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) ;
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromMacString( const wxChar* from )
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
#if wxUSE_UNICODE
wxString wxMacMakeMacStringFromPC( const char * p ) ;
wxString wxMacMakePCStringFromMac( const char * p ) ;
// converts this c string into a wxString with optional mac 2 pc encoding
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromMacString( const char* from )
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
#endif
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromMacString( const wxString& from )
{ return wxApp::s_macDefaultEncodingIsPC ?
wxMacMakeStringFromMacString( from.c_str() , true ) : from ; }
//
// Pascal Strings
//
// converts this string into a pascal with optional pc 2 mac encoding
void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) ;
// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline void wxMacStringToPascal( const wxChar * from , StringPtr to )
{ wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
// converts this string into a pascal with optional mac 2 pc encoding
wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) ;
// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromPascal( ConstStringPtr from )
{ return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
//
// CFStringRefs (Carbon only)
//
#if TARGET_CARBON
// converts this string into a carbon foundation string with optional pc 2 mac encoding
CFStringRef wxMacStringToCFString( const wxString &str , bool pc2macEncoding ) ;
// converts this string into a carbon foundation string with optional pc 2 mac encoding
inline CFStringRef wxMacStringToCFString( const wxString &str )
{ return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; }
#endif //TARGET_CARBON
#endif // 0
#endif #endif
// _WX_PRIVATE_H_ // _WX_PRIVATE_H_

View File

@@ -580,18 +580,11 @@
#define wxStrxfrm strxfrm #define wxStrxfrm strxfrm
// stdio.h functions // stdio.h functions
#if defined(__WXMAC__) && !defined(__DARWIN__) && !wxUSE_UNICODE
#include <stdio.h>
WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
#else
#define wxFopen fopen #define wxFopen fopen
#define wxFreopen freopen #define wxFreopen freopen
#define wxRemove remove #define wxRemove remove
#define wxRename rename #define wxRename rename
#endif
#define wxPerror perror #define wxPerror perror
#define wxTmpnam tmpnam #define wxTmpnam tmpnam

View File

@@ -93,10 +93,6 @@ wxAppConsole *wxAppConsole::ms_appInstance = NULL;
wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL; wxAppInitializerFunction wxAppConsole::ms_appInitFn = NULL;
#ifdef __WXMAC__
bool wxAppConsole::s_macDefaultEncodingIsPC = true ;
#endif
// ============================================================================ // ============================================================================
// wxAppConsole implementation // wxAppConsole implementation
// ============================================================================ // ============================================================================

View File

@@ -196,25 +196,6 @@ const off_t wxInvalidOffset = (off_t)-1;
// implementation // implementation
// ============================================================================ // ============================================================================
#if defined(__WXMAC__) && !defined(__DARWIN__) && !wxUSE_UNICODE
WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf )
{
return stat( wxMacStringToCString( file_name ), buf );
}
WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode )
{
return access( wxMacStringToCString( pathname ), mode );
}
WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode )
{
return open( wxMacStringToCString( pathname ), flags, mode );
}
#endif
#ifdef wxNEED_WX_UNISTD_H #ifdef wxNEED_WX_UNISTD_H
WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf ) WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf )
@@ -991,7 +972,7 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
(*myPath)[length-1] = 0 ; (*myPath)[length-1] = 0 ;
// create path string for return value // create path string for return value
wxString result = wxMacMakeStringFromCString( *myPath ) ; wxString result( *myPath , wxConvLocal) ;
// free allocated handle // free allocated handle
::HUnlock( myPath ) ; ::HUnlock( myPath ) ;
@@ -1037,7 +1018,7 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
#if wxUSE_UNICODE #if wxUSE_UNICODE
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec )
{ {
return wxMacFilename2FSSpec( wxMacStringToCString( wxString( path ) ) , spec ) ; return wxMacFilename2FSSpec( wxConvFile.cWC2MB(path) , spec ) ;
} }
#endif #endif

View File

@@ -1205,28 +1205,6 @@ WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base)
} }
#endif // wxNEED_WX_STRING_H #endif // wxNEED_WX_STRING_H
#if defined(__WXMAC__) && !defined(__DARWIN__) && !wxUSE_UNICODE
WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode)
{
return fopen( wxMacStringToCString(path), mode );
}
WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream)
{
return freopen( wxMacStringToCString(path), mode, stream );
}
WXDLLEXPORT int wxRemove(const wxChar *path)
{
return remove( wxMacStringToCString(path) );
}
WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath)
{
return rename( wxMacStringToCString(oldpath), wxMacStringToCString(newpath) );
}
#endif
#ifdef wxNEED_WX_STDIO_H #ifdef wxNEED_WX_STDIO_H
WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode) WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode)
{ {

View File

@@ -1171,14 +1171,7 @@ void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
wxString msg; wxString msg;
TimeStamp(&msg); TimeStamp(&msg);
#if defined(__WXMAC__)
// VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
// translation must be done in wxTextCtrl, not here! (FIXME)
msg << szString << wxT('\r');
#else
msg << szString << wxT('\n'); msg << szString << wxT('\n');
#endif
m_pTextCtrl->AppendText(msg); m_pTextCtrl->AppendText(msg);
} }

View File

@@ -600,7 +600,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
#endif #endif
#endif #endif
wxMacSetupConverters() ;
s_macCursorRgn = ::NewRgn() ; s_macCursorRgn = ::NewRgn() ;
@@ -702,7 +701,6 @@ void wxApp::CleanUp()
// __wxterminate in Mach-O shared libraries // __wxterminate in Mach-O shared libraries
wxStAppResource::CloseSharedLibraryResource(); wxStAppResource::CloseSharedLibraryResource();
#endif #endif
wxMacCleanupConverters() ;
UMACleanupToolbox() ; UMACleanupToolbox() ;
if (s_macCursorRgn) { if (s_macCursorRgn) {

View File

@@ -600,7 +600,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
#endif #endif
#endif #endif
wxMacSetupConverters() ;
s_macCursorRgn = ::NewRgn() ; s_macCursorRgn = ::NewRgn() ;
@@ -702,7 +701,6 @@ void wxApp::CleanUp()
// __wxterminate in Mach-O shared libraries // __wxterminate in Mach-O shared libraries
wxStAppResource::CloseSharedLibraryResource(); wxStAppResource::CloseSharedLibraryResource();
#endif #endif
wxMacCleanupConverters() ;
UMACleanupToolbox() ; UMACleanupToolbox() ;
if (s_macCursorRgn) { if (s_macCursorRgn) {

View File

@@ -272,8 +272,7 @@ wxSize wxChoice::DoGetBestSize() const
&baseline ); &baseline );
wLine = bounds.h ; wLine = bounds.h ;
#else #else
wxCharBuffer text = wxMacStringToCString( str ) ; wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
wLine = ::TextWidth( text , 0 , strlen(text) ) ;
#endif #endif
lbWidth = wxMax(lbWidth, wLine); lbWidth = wxMax(lbWidth, wLine);
} }

View File

@@ -136,18 +136,14 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
return NULL ; return NULL ;
} }
if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) if ( dataFormat.GetType() == wxDF_TEXT )
{ {
wxString st = wxMacMakeStringFromCString( (char*) data ) ; char * buf = (char*) data ;
#if wxUSE_UNICODE while( (buf=strchr(buf,0x0a)) != NULL )
wxCharBuffer buf = st.ToAscii() ; {
#else *buf = 13 ;
const char* buf = st ; buf++ ;
#endif }
char* newdata = new char[strlen(buf)+1] ;
memcpy( newdata , buf , strlen(buf)+1 ) ;
delete[] ((char*) data ) ;
data = newdata ;
} }
return data; return data;
@@ -252,8 +248,7 @@ bool wxClipboard::AddData( wxDataObject *data )
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
{ {
wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxTextDataObject* textDataObject = (wxTextDataObject*) data;
wxString str(textDataObject->GetText()); wxCharBuffer buf = textDataObject->GetText().mb_str() ;
wxCharBuffer buf = wxMacStringToCString( str ) ;
err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ; err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ;
} }
break ; break ;

View File

@@ -55,6 +55,8 @@ const double RAD2DEG = 180.0 / M_PI;
const short kEmulatedMode = -1 ; const short kEmulatedMode = -1 ;
const short kUnsupportedMode = -2 ; const short kUnsupportedMode = -2 ;
extern TECObjectRef s_TECNativeCToUnicode ;
// set to 0 if problems arise // set to 0 if problems arise
#define wxMAC_EXPERIMENTAL_DC 1 #define wxMAC_EXPERIMENTAL_DC 1
@@ -1353,24 +1355,9 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 , status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#else #else
TECObjectRef ec; wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
status = TECCreateConverter(&ec, int wlen = wxWcslen( wchar.data() ) ;
wxApp::s_macDefaultEncodingIsPC status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) wchar.data() , 0 , wlen , wlen , 1 ,
? (int)kTextEncodingWindowsLatin1
: (int)kTextEncodingMacRoman,
kTextEncodingUnicodeDefault);
wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ;
ByteCount byteOutLen ;
ByteCount byteInLen = str.Length() ;
ByteCount byteBufferLen = byteInLen *2 ;
char* buf = new char[byteBufferLen] ;
status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen);
wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ;
status = TECDisposeConverter(ec);
wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ;
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#endif #endif
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
@@ -1418,10 +1405,6 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
::ATSUDisposeTextLayout(atsuLayout); ::ATSUDisposeTextLayout(atsuLayout);
#if wxUSE_UNICODE
#else
delete[] buf ;
#endif
} }
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
@@ -1501,7 +1484,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ; ::DrawText( text , 0 , strlen(text) ) ;
line++ ; line++ ;
::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
@@ -1543,7 +1526,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ; ::DrawText( text , 0 , strlen(text) ) ;
} }
} }
@@ -1583,21 +1566,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
if ( externalLeading ) if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ; *externalLeading = YDEV2LOGREL( fi.leading ) ;
int length = strtext.Length() ; int length = strtext.Length() ;
/*
const char *text = NULL ;
wxString macText ;
if ( wxApp::s_macDefaultEncodingIsPC )
{
macText = wxMacMakeMacStringFromPC( string ) ;
text = macText ;
length = macText.Length() ;
}
else
{
text = string ;
length = string.Length() ;
}
*/
int laststop = 0 ; int laststop = 0 ;
int i = 0 ; int i = 0 ;
int curwidth = 0 ; int curwidth = 0 ;
@@ -1628,7 +1597,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ; curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
} }
if ( curwidth > *width ) if ( curwidth > *width )
@@ -1656,7 +1625,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ; curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
} }
if ( curwidth > *width ) if ( curwidth > *width )

View File

@@ -206,7 +206,7 @@ bool wxDropTarget::GetData()
if( theType == 'TEXT' ) if( theType == 'TEXT' )
{ {
theData[dataSize]=0 ; theData[dataSize]=0 ;
wxString convert = wxMacMakeStringFromCString( theData ) ; wxString convert( theData , wxConvLocal ) ;
m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert ); m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert );
} }
else if ( theType == kDragFlavorTypeHFS ) else if ( theType == kDragFlavorTypeHFS )
@@ -302,7 +302,7 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
dataSize-- ; dataSize-- ;
dataPtr[ dataSize ] = 0 ; dataPtr[ dataSize ] = 0 ;
wxString st( (wxChar*) dataPtr ) ; wxString st( (wxChar*) dataPtr ) ;
wxCharBuffer buf = wxMacStringToCString( st ) ; wxCharBuffer buf = st.mb_str( wxConvLocal) ;
AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0); AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0);
} }
else if (type == kDragFlavorTypeHFS ) else if (type == kDragFlavorTypeHFS )

View File

@@ -137,7 +137,7 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect
} }
#else #else
{ {
wxCharBuffer text = wxMacStringToCString( linetext ) ; wxCharBuffer text = linetext.mb_str( wxConvLocal) ;
MoveTo(drawRect->left + 4 , drawRect->top + 10 ); MoveTo(drawRect->left + 4 , drawRect->top + 10 );
DrawText(text, 0 , strlen(text) ); DrawText(text, 0 , strlen(text) );
} }
@@ -633,8 +633,7 @@ wxSize wxListBox::DoGetBestSize() const
&baseline ); &baseline );
wLine = bounds.h ; wLine = bounds.h ;
#else #else
wxCharBuffer text = wxMacStringToCString( str ) ; wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
wLine = ::TextWidth( text , 0 , strlen(text) ) ;
#endif #endif
lbWidth = wxMax(lbWidth, wLine); lbWidth = wxMax(lbWidth, wLine);
} }

View File

@@ -687,7 +687,7 @@ const short kVerticalMargin = 2 ;
const short kHorizontalMargin = 2 ; const short kHorizontalMargin = 2 ;
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& st, const wxString& str,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
@@ -747,6 +747,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_editable = FALSE ; m_editable = FALSE ;
} }
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , false , 0 , 0 , 1, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , false , 0 , 0 , 1,
@@ -771,7 +773,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
} }
else else
@@ -785,7 +787,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2, TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#endif #endif
@@ -817,7 +819,7 @@ wxString wxTextCtrl::GetValue() const
::GetControlData( (ControlHandle) m_macControl, 0, ::GetControlData( (ControlHandle) m_macControl, 0,
( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag,
actualSize , buf.data() , &actualSize ) ; actualSize , buf.data() , &actualSize ) ;
result = wxMacMakeStringFromCString( buf ) ; result = wxString( buf , wxConvLocal) ;
} }
} }
else else
@@ -856,14 +858,14 @@ wxString wxTextCtrl::GetValue() const
if ( actualSize > 0 ) if ( actualSize > 0 )
{ {
HLock( theText ) ; HLock( theText ) ;
result = wxMacMakeStringFromCString( *theText , actualSize ) ; result = wxString( *theText , wxConvLocal , actualSize ) ;
HUnlock( theText ) ; HUnlock( theText ) ;
} }
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
#endif #endif
} }
result.Replace(wxT("\r"),wxT("\n")) ;
return result ; return result ;
} }
@@ -880,11 +882,13 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
} }
} }
void wxTextCtrl::SetValue(const wxString& st) void wxTextCtrl::SetValue(const wxString& str)
{ {
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
} }
else else
@@ -896,7 +900,7 @@ void wxTextCtrl::SetValue(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#endif #endif
@@ -1167,8 +1171,10 @@ long wxTextCtrl::GetLastPosition() const
} }
} }
void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Replace(long from, long to, const wxString& str)
{ {
wxString value = str ;
value.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
@@ -1270,11 +1276,13 @@ bool wxTextCtrl::LoadFile(const wxString& file)
return FALSE; return FALSE;
} }
void wxTextCtrl::WriteText(const wxString& st) void wxTextCtrl::WriteText(const wxString& str)
{ {
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ; TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ;
} }
else else
@@ -1288,7 +1296,7 @@ void wxTextCtrl::WriteText(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 ,
kTXNUseCurrentSelection, kTXNUseCurrentSelection); kTXNUseCurrentSelection, kTXNUseCurrentSelection);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNUseCurrentSelection, kTXNUseCurrentSelection); kTXNUseCurrentSelection, kTXNUseCurrentSelection);
#endif #endif
@@ -1477,12 +1485,12 @@ int wxTextCtrl::GetLineLength(long lineNo) const
for (size_t j = i; j < content.Length(); j++) for (size_t j = i; j < content.Length(); j++)
{ {
count++; count++;
if (content[j] == '\r') return count; if (content[j] == '\n') return count;
} }
return count; return count;
} }
if (content[i] == '\r') count++; if (content[i] == '\n') count++;
} }
return 0; return 0;
} }
@@ -1503,7 +1511,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
for (size_t j = i; j < content.Length(); j++) for (size_t j = i; j < content.Length(); j++)
{ {
if (content[j] == '\r') if (content[j] == '\n')
return tmp; return tmp;
tmp += content[j]; tmp += content[j];
@@ -1511,7 +1519,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
return tmp; return tmp;
} }
if (content[i] == '\r') count++; if (content[i] == '\n') count++;
} }
return wxEmptyString ; return wxEmptyString ;
} }

View File

@@ -262,7 +262,7 @@ void wxMacToolTip::Draw()
int width = 0 ; int width = 0 ;
int thiswidth = 0 ; int thiswidth = 0 ;
int laststop = 0 ; int laststop = 0 ;
wxCharBuffer text = wxMacStringToCString( m_label ) ; wxCharBuffer text = m_label.mb_str( wxConvLocal) ;
while( i < length ) while( i < length )
{ {

View File

@@ -546,6 +546,8 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
// wxMac Specific utility functions // wxMac Specific utility functions
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#if 0
char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
@@ -632,17 +634,17 @@ void wxMacConvertToPC( const char *from , char *to , int len )
TECObjectRef s_TECNativeCToUnicode = NULL ; TECObjectRef s_TECNativeCToUnicode = NULL ;
TECObjectRef s_TECUnicodeToNativeC = NULL ; TECObjectRef s_TECUnicodeToNativeC = NULL ;
TECObjectRef s_TECPlatformToNativeC = NULL ;
TECObjectRef s_TECNativeCToPlatform = NULL ;
void wxMacSetupConverters() void wxMacSetupConverters()
{ {
// if we assume errors are happening here we need low level debugging // if we assume errors are happening here we need low level debugging
// since the high level assert will use the encoders that are not yet // since the high level assert will use the encoders that are not yet
// setup... // setup...
const int kEncoding = wxApp::s_macDefaultEncodingIsPC #if TARGET_CARBON
? (int)kTextEncodingWindowsLatin1 const TextEncodingBase kEncoding = CFStringGetSystemEncoding();
: (int)kTextEncodingMacRoman; #else
const TextEncodingBase kEncoding = kTextEncodingMacRoman;
#endif
OSStatus status = noErr ; OSStatus status = noErr ;
status = TECCreateConverter(&s_TECNativeCToUnicode, status = TECCreateConverter(&s_TECNativeCToUnicode,
kEncoding, kEncoding,
@@ -652,18 +654,6 @@ void wxMacSetupConverters()
status = TECCreateConverter(&s_TECUnicodeToNativeC, status = TECCreateConverter(&s_TECUnicodeToNativeC,
kTextEncodingUnicodeDefault, kTextEncodingUnicodeDefault,
kEncoding); kEncoding);
if ( wxApp::s_macDefaultEncodingIsPC )
{
status = TECCreateConverter(&s_TECPlatformToNativeC,
kTextEncodingMacRoman,
kTextEncodingWindowsLatin1);
status = TECCreateConverter(&s_TECNativeCToPlatform,
kTextEncodingWindowsLatin1,
kTextEncodingMacRoman);
}
} }
void wxMacCleanupConverters() void wxMacCleanupConverters()
@@ -672,10 +662,6 @@ void wxMacCleanupConverters()
status = TECDisposeConverter(s_TECNativeCToUnicode); status = TECDisposeConverter(s_TECNativeCToUnicode);
status = TECDisposeConverter(s_TECUnicodeToNativeC); status = TECDisposeConverter(s_TECUnicodeToNativeC);
status = TECDisposeConverter(s_TECPlatformToNativeC);
status = TECDisposeConverter(s_TECNativeCToPlatform);
} }
wxWCharBuffer wxMacStringToWString( const wxString &from ) wxWCharBuffer wxMacStringToWString( const wxString &from )
@@ -709,17 +695,7 @@ wxString wxMacMakeStringFromCString( const char * from , int len )
status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen, status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen); (TextPtr)buf, byteBufferLen, &byteOutLen);
#else #else
if ( !wxApp::s_macDefaultEncodingIsPC ) memcpy( buf , from , len ) ;
memcpy( buf , from , len ) ;
else
{
ByteCount byteOutLen ;
ByteCount byteInLen = len ;
ByteCount byteBufferLen = byteInLen ;
status = TECConvertText(s_TECPlatformToNativeC, (ConstTextPtr)from , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen);
}
#endif #endif
buf[len] = 0 ; buf[len] = 0 ;
result.UngetWriteBuf() ; result.UngetWriteBuf() ;
@@ -743,26 +719,14 @@ wxCharBuffer wxMacStringToCString( const wxString &from )
(TextPtr)result.data(), byteBufferLen, &byteOutLen); (TextPtr)result.data(), byteBufferLen, &byteOutLen);
return result ; return result ;
#else #else
if ( !wxApp::s_macDefaultEncodingIsPC ) return wxCharBuffer( from.c_str() ) ;
return wxCharBuffer( from.c_str() ) ;
else
{
wxCharBuffer result( from.Length() ) ;
OSStatus status = noErr ;
ByteCount byteOutLen ;
ByteCount byteInLen = from.Length() ;
ByteCount byteBufferLen = byteInLen ;
status = TECConvertText(s_TECNativeCToPlatform, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen,
(TextPtr)result.data(), byteBufferLen, &byteOutLen);
return result ;
}
#endif #endif
} }
#endif
void wxMacStringToPascal( const wxString&from , StringPtr to ) void wxMacStringToPascal( const wxString&from , StringPtr to )
{ {
wxCharBuffer buf = wxMacStringToCString( from ) ; wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
int len = strlen(buf) ; int len = strlen(buf) ;
if ( len > 255 ) if ( len > 255 )
@@ -773,7 +737,7 @@ void wxMacStringToPascal( const wxString&from , StringPtr to )
wxString wxMacMakeStringFromPascal( ConstStringPtr from ) wxString wxMacMakeStringFromPascal( ConstStringPtr from )
{ {
return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ;
} }
#endif // wxUSE_BASE #endif // wxUSE_BASE
@@ -794,8 +758,7 @@ void wxMacCFStringHolder::Assign( const wxString &str )
(const unsigned short*)str.wc_str(), str.Len() ); (const unsigned short*)str.wc_str(), str.Len() );
#else #else
m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
wxApp::s_macDefaultEncodingIsPC ? CFStringGetSystemEncoding() ) ;
kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
#endif #endif
m_release = true ; m_release = true ;
} }
@@ -808,89 +771,13 @@ wxString wxMacCFStringHolder::AsString()
#if wxUSE_UNICODE #if wxUSE_UNICODE
CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
#else #else
CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? CFStringGetCString( m_cfs , buf , len+1 , CFStringGetSystemEncoding() ) ;
kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
#endif #endif
buf[len] = 0 ; buf[len] = 0 ;
result.UngetWriteBuf() ; result.UngetWriteBuf() ;
return result ; return result ;
} }
#if 0
wxString wxMacMakeMacStringFromPC( const wxChar * p )
{
wxString result ;
int len = wxStrlen ( p ) ;
if ( len > 0 )
{
wxChar* ptr = result.GetWriteBuf(len) ;
wxMacConvertFromPC( p , ptr , len ) ;
ptr[len] = 0 ;
result.UngetWriteBuf( len ) ;
}
return result ;
}
wxString wxMacMakePCStringFromMac( const wxChar * p )
{
wxString result ;
int len = wxStrlen ( p ) ;
if ( len > 0 )
{
wxChar* ptr = result.GetWriteBuf(len) ;
wxMacConvertToPC( p , ptr , len ) ;
ptr[len] = 0 ;
result.UngetWriteBuf( len ) ;
}
return result ;
}
wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding )
{
if (mac2pcEncoding)
{
return wxMacMakePCStringFromMac( from ) ;
}
else
{
return wxString( from ) ;
}
}
//
// Pascal Strings
//
wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding )
{
// this is safe since a pascal string can never be larger than 256 bytes
char s[256] ;
CopyPascalStringToC( from , s ) ;
if (mac2pcEncoding)
{
return wxMacMakePCStringFromMac( s ) ;
}
else
{
return wxString( s ) ;
}
}
void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding )
{
if (pc2macEncoding)
{
CopyCStringToPascal( wxMacMakeMacStringFromPC( from ) , to ) ;
}
else
{
CopyCStringToPascal( from , to ) ;
}
}
#endif
#endif //TARGET_CARBON #endif //TARGET_CARBON
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -272,8 +272,7 @@ wxSize wxChoice::DoGetBestSize() const
&baseline ); &baseline );
wLine = bounds.h ; wLine = bounds.h ;
#else #else
wxCharBuffer text = wxMacStringToCString( str ) ; wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
wLine = ::TextWidth( text , 0 , strlen(text) ) ;
#endif #endif
lbWidth = wxMax(lbWidth, wLine); lbWidth = wxMax(lbWidth, wLine);
} }

View File

@@ -136,18 +136,14 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
return NULL ; return NULL ;
} }
if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) if ( dataFormat.GetType() == wxDF_TEXT )
{ {
wxString st = wxMacMakeStringFromCString( (char*) data ) ; char * buf = (char*) data ;
#if wxUSE_UNICODE while( (buf=strchr(buf,0x0a)) != NULL )
wxCharBuffer buf = st.ToAscii() ; {
#else *buf = 13 ;
const char* buf = st ; buf++ ;
#endif }
char* newdata = new char[strlen(buf)+1] ;
memcpy( newdata , buf , strlen(buf)+1 ) ;
delete[] ((char*) data ) ;
data = newdata ;
} }
return data; return data;
@@ -252,8 +248,7 @@ bool wxClipboard::AddData( wxDataObject *data )
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
{ {
wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxTextDataObject* textDataObject = (wxTextDataObject*) data;
wxString str(textDataObject->GetText()); wxCharBuffer buf = textDataObject->GetText().mb_str() ;
wxCharBuffer buf = wxMacStringToCString( str ) ;
err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ; err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ;
} }
break ; break ;

View File

@@ -55,6 +55,8 @@ const double RAD2DEG = 180.0 / M_PI;
const short kEmulatedMode = -1 ; const short kEmulatedMode = -1 ;
const short kUnsupportedMode = -2 ; const short kUnsupportedMode = -2 ;
extern TECObjectRef s_TECNativeCToUnicode ;
// set to 0 if problems arise // set to 0 if problems arise
#define wxMAC_EXPERIMENTAL_DC 1 #define wxMAC_EXPERIMENTAL_DC 1
@@ -1353,24 +1355,9 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 , status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#else #else
TECObjectRef ec; wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
status = TECCreateConverter(&ec, int wlen = wxWcslen( wchar.data() ) ;
wxApp::s_macDefaultEncodingIsPC status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) wchar.data() , 0 , wlen , wlen , 1 ,
? (int)kTextEncodingWindowsLatin1
: (int)kTextEncodingMacRoman,
kTextEncodingUnicodeDefault);
wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ;
ByteCount byteOutLen ;
ByteCount byteInLen = str.Length() ;
ByteCount byteBufferLen = byteInLen *2 ;
char* buf = new char[byteBufferLen] ;
status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen);
wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ;
status = TECDisposeConverter(ec);
wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ;
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#endif #endif
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
@@ -1418,10 +1405,6 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
::ATSUDisposeTextLayout(atsuLayout); ::ATSUDisposeTextLayout(atsuLayout);
#if wxUSE_UNICODE
#else
delete[] buf ;
#endif
} }
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
@@ -1501,7 +1484,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ; ::DrawText( text , 0 , strlen(text) ) ;
line++ ; line++ ;
::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
@@ -1543,7 +1526,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ; ::DrawText( text , 0 , strlen(text) ) ;
} }
} }
@@ -1583,21 +1566,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
if ( externalLeading ) if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ; *externalLeading = YDEV2LOGREL( fi.leading ) ;
int length = strtext.Length() ; int length = strtext.Length() ;
/*
const char *text = NULL ;
wxString macText ;
if ( wxApp::s_macDefaultEncodingIsPC )
{
macText = wxMacMakeMacStringFromPC( string ) ;
text = macText ;
length = macText.Length() ;
}
else
{
text = string ;
length = string.Length() ;
}
*/
int laststop = 0 ; int laststop = 0 ;
int i = 0 ; int i = 0 ;
int curwidth = 0 ; int curwidth = 0 ;
@@ -1628,7 +1597,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ; curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
} }
if ( curwidth > *width ) if ( curwidth > *width )
@@ -1656,7 +1625,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
else else
#endif #endif
{ {
wxCharBuffer text = wxMacStringToCString(linetext) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ; curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
} }
if ( curwidth > *width ) if ( curwidth > *width )

View File

@@ -206,7 +206,7 @@ bool wxDropTarget::GetData()
if( theType == 'TEXT' ) if( theType == 'TEXT' )
{ {
theData[dataSize]=0 ; theData[dataSize]=0 ;
wxString convert = wxMacMakeStringFromCString( theData ) ; wxString convert( theData , wxConvLocal ) ;
m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert ); m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert );
} }
else if ( theType == kDragFlavorTypeHFS ) else if ( theType == kDragFlavorTypeHFS )
@@ -302,7 +302,7 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
dataSize-- ; dataSize-- ;
dataPtr[ dataSize ] = 0 ; dataPtr[ dataSize ] = 0 ;
wxString st( (wxChar*) dataPtr ) ; wxString st( (wxChar*) dataPtr ) ;
wxCharBuffer buf = wxMacStringToCString( st ) ; wxCharBuffer buf = st.mb_str( wxConvLocal) ;
AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0); AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0);
} }
else if (type == kDragFlavorTypeHFS ) else if (type == kDragFlavorTypeHFS )

View File

@@ -137,7 +137,7 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect
} }
#else #else
{ {
wxCharBuffer text = wxMacStringToCString( linetext ) ; wxCharBuffer text = linetext.mb_str( wxConvLocal) ;
MoveTo(drawRect->left + 4 , drawRect->top + 10 ); MoveTo(drawRect->left + 4 , drawRect->top + 10 );
DrawText(text, 0 , strlen(text) ); DrawText(text, 0 , strlen(text) );
} }
@@ -633,8 +633,7 @@ wxSize wxListBox::DoGetBestSize() const
&baseline ); &baseline );
wLine = bounds.h ; wLine = bounds.h ;
#else #else
wxCharBuffer text = wxMacStringToCString( str ) ; wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
wLine = ::TextWidth( text , 0 , strlen(text) ) ;
#endif #endif
lbWidth = wxMax(lbWidth, wLine); lbWidth = wxMax(lbWidth, wLine);
} }

View File

@@ -687,7 +687,7 @@ const short kVerticalMargin = 2 ;
const short kHorizontalMargin = 2 ; const short kHorizontalMargin = 2 ;
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& st, const wxString& str,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
@@ -747,6 +747,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_editable = FALSE ; m_editable = FALSE ;
} }
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , false , 0 , 0 , 1, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , false , 0 , 0 , 1,
@@ -771,7 +773,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
} }
else else
@@ -785,7 +787,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2, TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#endif #endif
@@ -817,7 +819,7 @@ wxString wxTextCtrl::GetValue() const
::GetControlData( (ControlHandle) m_macControl, 0, ::GetControlData( (ControlHandle) m_macControl, 0,
( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag,
actualSize , buf.data() , &actualSize ) ; actualSize , buf.data() , &actualSize ) ;
result = wxMacMakeStringFromCString( buf ) ; result = wxString( buf , wxConvLocal) ;
} }
} }
else else
@@ -856,14 +858,14 @@ wxString wxTextCtrl::GetValue() const
if ( actualSize > 0 ) if ( actualSize > 0 )
{ {
HLock( theText ) ; HLock( theText ) ;
result = wxMacMakeStringFromCString( *theText , actualSize ) ; result = wxString( *theText , wxConvLocal , actualSize ) ;
HUnlock( theText ) ; HUnlock( theText ) ;
} }
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
#endif #endif
} }
result.Replace(wxT("\r"),wxT("\n")) ;
return result ; return result ;
} }
@@ -880,11 +882,13 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
} }
} }
void wxTextCtrl::SetValue(const wxString& st) void wxTextCtrl::SetValue(const wxString& str)
{ {
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
} }
else else
@@ -896,7 +900,7 @@ void wxTextCtrl::SetValue(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNStartOffset, kTXNEndOffset); kTXNStartOffset, kTXNEndOffset);
#endif #endif
@@ -1167,8 +1171,10 @@ long wxTextCtrl::GetLastPosition() const
} }
} }
void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Replace(long from, long to, const wxString& str)
{ {
wxString value = str ;
value.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
@@ -1270,11 +1276,13 @@ bool wxTextCtrl::LoadFile(const wxString& file)
return FALSE; return FALSE;
} }
void wxTextCtrl::WriteText(const wxString& st) void wxTextCtrl::WriteText(const wxString& str)
{ {
wxString st = str ;
st.Replace(wxT("\n"), wxT("\r"));
if ( !m_macUsesTXN ) if ( !m_macUsesTXN )
{ {
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ; TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ;
} }
else else
@@ -1288,7 +1296,7 @@ void wxTextCtrl::WriteText(const wxString& st)
TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 ,
kTXNUseCurrentSelection, kTXNUseCurrentSelection); kTXNUseCurrentSelection, kTXNUseCurrentSelection);
#else #else
wxCharBuffer text = wxMacStringToCString( st ) ; wxCharBuffer text = st.mb_str(wxConvLocal) ;
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) ,
kTXNUseCurrentSelection, kTXNUseCurrentSelection); kTXNUseCurrentSelection, kTXNUseCurrentSelection);
#endif #endif
@@ -1477,12 +1485,12 @@ int wxTextCtrl::GetLineLength(long lineNo) const
for (size_t j = i; j < content.Length(); j++) for (size_t j = i; j < content.Length(); j++)
{ {
count++; count++;
if (content[j] == '\r') return count; if (content[j] == '\n') return count;
} }
return count; return count;
} }
if (content[i] == '\r') count++; if (content[i] == '\n') count++;
} }
return 0; return 0;
} }
@@ -1503,7 +1511,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
for (size_t j = i; j < content.Length(); j++) for (size_t j = i; j < content.Length(); j++)
{ {
if (content[j] == '\r') if (content[j] == '\n')
return tmp; return tmp;
tmp += content[j]; tmp += content[j];
@@ -1511,7 +1519,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
return tmp; return tmp;
} }
if (content[i] == '\r') count++; if (content[i] == '\n') count++;
} }
return wxEmptyString ; return wxEmptyString ;
} }

View File

@@ -262,7 +262,7 @@ void wxMacToolTip::Draw()
int width = 0 ; int width = 0 ;
int thiswidth = 0 ; int thiswidth = 0 ;
int laststop = 0 ; int laststop = 0 ;
wxCharBuffer text = wxMacStringToCString( m_label ) ; wxCharBuffer text = m_label.mb_str( wxConvLocal) ;
while( i < length ) while( i < length )
{ {

View File

@@ -546,6 +546,8 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
// wxMac Specific utility functions // wxMac Specific utility functions
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#if 0
char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
@@ -632,17 +634,17 @@ void wxMacConvertToPC( const char *from , char *to , int len )
TECObjectRef s_TECNativeCToUnicode = NULL ; TECObjectRef s_TECNativeCToUnicode = NULL ;
TECObjectRef s_TECUnicodeToNativeC = NULL ; TECObjectRef s_TECUnicodeToNativeC = NULL ;
TECObjectRef s_TECPlatformToNativeC = NULL ;
TECObjectRef s_TECNativeCToPlatform = NULL ;
void wxMacSetupConverters() void wxMacSetupConverters()
{ {
// if we assume errors are happening here we need low level debugging // if we assume errors are happening here we need low level debugging
// since the high level assert will use the encoders that are not yet // since the high level assert will use the encoders that are not yet
// setup... // setup...
const int kEncoding = wxApp::s_macDefaultEncodingIsPC #if TARGET_CARBON
? (int)kTextEncodingWindowsLatin1 const TextEncodingBase kEncoding = CFStringGetSystemEncoding();
: (int)kTextEncodingMacRoman; #else
const TextEncodingBase kEncoding = kTextEncodingMacRoman;
#endif
OSStatus status = noErr ; OSStatus status = noErr ;
status = TECCreateConverter(&s_TECNativeCToUnicode, status = TECCreateConverter(&s_TECNativeCToUnicode,
kEncoding, kEncoding,
@@ -652,18 +654,6 @@ void wxMacSetupConverters()
status = TECCreateConverter(&s_TECUnicodeToNativeC, status = TECCreateConverter(&s_TECUnicodeToNativeC,
kTextEncodingUnicodeDefault, kTextEncodingUnicodeDefault,
kEncoding); kEncoding);
if ( wxApp::s_macDefaultEncodingIsPC )
{
status = TECCreateConverter(&s_TECPlatformToNativeC,
kTextEncodingMacRoman,
kTextEncodingWindowsLatin1);
status = TECCreateConverter(&s_TECNativeCToPlatform,
kTextEncodingWindowsLatin1,
kTextEncodingMacRoman);
}
} }
void wxMacCleanupConverters() void wxMacCleanupConverters()
@@ -672,10 +662,6 @@ void wxMacCleanupConverters()
status = TECDisposeConverter(s_TECNativeCToUnicode); status = TECDisposeConverter(s_TECNativeCToUnicode);
status = TECDisposeConverter(s_TECUnicodeToNativeC); status = TECDisposeConverter(s_TECUnicodeToNativeC);
status = TECDisposeConverter(s_TECPlatformToNativeC);
status = TECDisposeConverter(s_TECNativeCToPlatform);
} }
wxWCharBuffer wxMacStringToWString( const wxString &from ) wxWCharBuffer wxMacStringToWString( const wxString &from )
@@ -709,17 +695,7 @@ wxString wxMacMakeStringFromCString( const char * from , int len )
status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen, status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen); (TextPtr)buf, byteBufferLen, &byteOutLen);
#else #else
if ( !wxApp::s_macDefaultEncodingIsPC ) memcpy( buf , from , len ) ;
memcpy( buf , from , len ) ;
else
{
ByteCount byteOutLen ;
ByteCount byteInLen = len ;
ByteCount byteBufferLen = byteInLen ;
status = TECConvertText(s_TECPlatformToNativeC, (ConstTextPtr)from , byteInLen, &byteInLen,
(TextPtr)buf, byteBufferLen, &byteOutLen);
}
#endif #endif
buf[len] = 0 ; buf[len] = 0 ;
result.UngetWriteBuf() ; result.UngetWriteBuf() ;
@@ -743,26 +719,14 @@ wxCharBuffer wxMacStringToCString( const wxString &from )
(TextPtr)result.data(), byteBufferLen, &byteOutLen); (TextPtr)result.data(), byteBufferLen, &byteOutLen);
return result ; return result ;
#else #else
if ( !wxApp::s_macDefaultEncodingIsPC ) return wxCharBuffer( from.c_str() ) ;
return wxCharBuffer( from.c_str() ) ;
else
{
wxCharBuffer result( from.Length() ) ;
OSStatus status = noErr ;
ByteCount byteOutLen ;
ByteCount byteInLen = from.Length() ;
ByteCount byteBufferLen = byteInLen ;
status = TECConvertText(s_TECNativeCToPlatform, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen,
(TextPtr)result.data(), byteBufferLen, &byteOutLen);
return result ;
}
#endif #endif
} }
#endif
void wxMacStringToPascal( const wxString&from , StringPtr to ) void wxMacStringToPascal( const wxString&from , StringPtr to )
{ {
wxCharBuffer buf = wxMacStringToCString( from ) ; wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
int len = strlen(buf) ; int len = strlen(buf) ;
if ( len > 255 ) if ( len > 255 )
@@ -773,7 +737,7 @@ void wxMacStringToPascal( const wxString&from , StringPtr to )
wxString wxMacMakeStringFromPascal( ConstStringPtr from ) wxString wxMacMakeStringFromPascal( ConstStringPtr from )
{ {
return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ;
} }
#endif // wxUSE_BASE #endif // wxUSE_BASE
@@ -794,8 +758,7 @@ void wxMacCFStringHolder::Assign( const wxString &str )
(const unsigned short*)str.wc_str(), str.Len() ); (const unsigned short*)str.wc_str(), str.Len() );
#else #else
m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
wxApp::s_macDefaultEncodingIsPC ? CFStringGetSystemEncoding() ) ;
kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
#endif #endif
m_release = true ; m_release = true ;
} }
@@ -808,89 +771,13 @@ wxString wxMacCFStringHolder::AsString()
#if wxUSE_UNICODE #if wxUSE_UNICODE
CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
#else #else
CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? CFStringGetCString( m_cfs , buf , len+1 , CFStringGetSystemEncoding() ) ;
kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
#endif #endif
buf[len] = 0 ; buf[len] = 0 ;
result.UngetWriteBuf() ; result.UngetWriteBuf() ;
return result ; return result ;
} }
#if 0
wxString wxMacMakeMacStringFromPC( const wxChar * p )
{
wxString result ;
int len = wxStrlen ( p ) ;
if ( len > 0 )
{
wxChar* ptr = result.GetWriteBuf(len) ;
wxMacConvertFromPC( p , ptr , len ) ;
ptr[len] = 0 ;
result.UngetWriteBuf( len ) ;
}
return result ;
}
wxString wxMacMakePCStringFromMac( const wxChar * p )
{
wxString result ;
int len = wxStrlen ( p ) ;
if ( len > 0 )
{
wxChar* ptr = result.GetWriteBuf(len) ;
wxMacConvertToPC( p , ptr , len ) ;
ptr[len] = 0 ;
result.UngetWriteBuf( len ) ;
}
return result ;
}
wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding )
{
if (mac2pcEncoding)
{
return wxMacMakePCStringFromMac( from ) ;
}
else
{
return wxString( from ) ;
}
}
//
// Pascal Strings
//
wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding )
{
// this is safe since a pascal string can never be larger than 256 bytes
char s[256] ;
CopyPascalStringToC( from , s ) ;
if (mac2pcEncoding)
{
return wxMacMakePCStringFromMac( s ) ;
}
else
{
return wxString( s ) ;
}
}
void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding )
{
if (pc2macEncoding)
{
CopyCStringToPascal( wxMacMakeMacStringFromPC( from ) , to ) ;
}
else
{
CopyCStringToPascal( from , to ) ;
}
}
#endif
#endif //TARGET_CARBON #endif //TARGET_CARBON
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------