From 427ff66291af2d8dd34ff5ee68c81436997144a1 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 27 Mar 2003 20:33:32 +0000 Subject: [PATCH] wxMac Unicode support git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19841 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 18 +- src/mac/bitmap.cpp | 20 +- src/mac/bmpbuttn.cpp | 4 +- src/mac/button.cpp | 2 +- src/mac/carbon/app.cpp | 18 +- src/mac/carbon/bitmap.cpp | 20 +- src/mac/carbon/bmpbuttn.cpp | 4 +- src/mac/carbon/button.cpp | 2 +- src/mac/carbon/checklst.cpp | 2 +- src/mac/carbon/choice.cpp | 6 +- src/mac/carbon/clipbrd.cpp | 68 +++-- src/mac/carbon/combobox.cpp | 2 +- src/mac/carbon/control.cpp | 28 +-- src/mac/carbon/cursor.cpp | 8 +- src/mac/carbon/dataobj.cpp | 34 +-- src/mac/carbon/dc.cpp | 105 ++++---- src/mac/carbon/dcprint.cpp | 44 ++-- src/mac/carbon/dirdlg.cpp | 8 +- src/mac/carbon/dirmac.cpp | 23 +- src/mac/carbon/dnd.cpp | 18 +- src/mac/carbon/filedlg.cpp | 109 ++++---- src/mac/carbon/font.cpp | 11 +- src/mac/carbon/gauge.cpp | 2 +- src/mac/carbon/glcanvas.cpp | 4 +- src/mac/carbon/icon.cpp | 16 +- src/mac/carbon/joystick.cpp | 2 +- src/mac/carbon/listbox.cpp | 145 ++++------- src/mac/carbon/macnotfy.cpp | 2 +- src/mac/carbon/menu.cpp | 12 +- src/mac/carbon/menuitem.cpp | 6 +- src/mac/carbon/metafile.cpp | 10 +- src/mac/carbon/mimetmac.cpp | 36 +-- src/mac/carbon/msgdlg.cpp | 40 +-- src/mac/carbon/notebmac.cpp | 12 +- src/mac/carbon/pnghand.cpp | 9 +- src/mac/carbon/printdlg.cpp | 16 +- src/mac/carbon/printmac.cpp | 4 +- src/mac/carbon/radiobox.cpp | 6 +- src/mac/carbon/scrolbar.cpp | 4 +- src/mac/carbon/slider.cpp | 24 +- src/mac/carbon/spinbutt.cpp | 4 +- src/mac/carbon/statlmac.cpp | 2 +- src/mac/carbon/stattext.cpp | 8 +- src/mac/carbon/tabctrl.cpp | 4 +- src/mac/carbon/textctrl.cpp | 134 +++++----- src/mac/carbon/thread.cpp | 2 +- src/mac/carbon/toolbar.cpp | 4 +- src/mac/carbon/tooltip.cpp | 344 ++++++++++--------------- src/mac/carbon/toplevel.cpp | 19 +- src/mac/carbon/uma.cpp | 37 +-- src/mac/carbon/utils.cpp | 255 +++++++++++++++---- src/mac/carbon/wave.cpp | 17 +- src/mac/carbon/window.cpp | 6 +- src/mac/checklst.cpp | 2 +- src/mac/choice.cpp | 6 +- src/mac/clipbrd.cpp | 68 +++-- src/mac/combobox.cpp | 2 +- src/mac/control.cpp | 28 +-- src/mac/cursor.cpp | 8 +- src/mac/dataobj.cpp | 34 +-- src/mac/dc.cpp | 105 ++++---- src/mac/dcprint.cpp | 44 ++-- src/mac/dirdlg.cpp | 8 +- src/mac/dirmac.cpp | 23 +- src/mac/dnd.cpp | 18 +- src/mac/filedlg.cpp | 109 ++++---- src/mac/font.cpp | 11 +- src/mac/gauge.cpp | 2 +- src/mac/glcanvas.cpp | 4 +- src/mac/icon.cpp | 16 +- src/mac/joystick.cpp | 2 +- src/mac/listbox.cpp | 145 ++++------- src/mac/macnotfy.cpp | 2 +- src/mac/menu.cpp | 12 +- src/mac/menuitem.cpp | 6 +- src/mac/metafile.cpp | 10 +- src/mac/mimetmac.cpp | 36 +-- src/mac/msgdlg.cpp | 40 +-- src/mac/notebmac.cpp | 12 +- src/mac/pnghand.cpp | 9 +- src/mac/printdlg.cpp | 16 +- src/mac/printmac.cpp | 4 +- src/mac/radiobox.cpp | 6 +- src/mac/scrolbar.cpp | 4 +- src/mac/slider.cpp | 24 +- src/mac/spinbutt.cpp | 4 +- src/mac/statlmac.cpp | 2 +- src/mac/stattext.cpp | 8 +- src/mac/tabctrl.cpp | 4 +- src/mac/textctrl.cpp | 134 +++++----- src/mac/thread.cpp | 2 +- src/mac/toolbar.cpp | 4 +- src/mac/tooltip.cpp | 344 ++++++++++--------------- src/mac/toplevel.cpp | 19 +- src/mac/uma.cpp | 37 +-- src/mac/utils.cpp | 255 +++++++++++++++---- src/mac/wave.cpp | 17 +- src/mac/window.cpp | 6 +- src/wxWindowsM8.xml | 488 ++---------------------------------- 99 files changed, 1716 insertions(+), 2164 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index b100ef0b8c..5766c82f22 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -116,7 +116,7 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macPreferencesMenuItemId = 0 ; long wxApp::s_macExitMenuItemId = wxID_EXIT ; -wxString wxApp::s_macHelpMenuTitleName = "&Help" ; +wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; //---------------------------------------------------------------------- // Core Apple Event Support @@ -538,7 +538,8 @@ bool wxApp::Initialize() #endif #endif - + wxMacSetupConverters() ; + s_macCursorRgn = ::NewRgn() ; wxClassInfo::InitializeClasses(); @@ -719,7 +720,8 @@ void wxApp::CleanUp() // __wxterminate in Mach-O shared libraries wxStAppResource::CloseSharedLibraryResource(); #endif - + wxMacCleanupConverters() ; + UMACleanupToolbox() ; if (s_macCursorRgn) { ::DisposeRgn((RgnHandle)s_macCursorRgn); @@ -961,7 +963,17 @@ int wxEntry( int argc, char *argv[] , bool enterLoop ) // we could try to get the open apple events here to adjust argc and argv better wxTheApp->argc = argc; +#if wxUSE_UNICODE + wxTheApp->argv = new wxChar*[argc+1]; + int mb_argc ; + for ( mb_argc = 0; mb_argc < argc; mb_argc++ ) + { + wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc])); + } + wxTheApp->argv[mb_argc] = (wxChar *)NULL; +#else wxTheApp->argv = argv; +#endif // GUI-specific initialization, such as creating an app context. wxEntryInitGui(); diff --git a/src/mac/bitmap.cpp b/src/mac/bitmap.cpp index ba28f7c08b..5974622370 100644 --- a/src/mac/bitmap.cpp +++ b/src/mac/bitmap.cpp @@ -694,7 +694,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return true; } } - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return false; } @@ -707,7 +707,7 @@ bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int wxBitmapHandler *handler = FindHandler(type); if ( handler == NULL ) { - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return FALSE; } @@ -944,7 +944,7 @@ bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, return image.SaveFile(filename, type); } - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return false; } @@ -1282,8 +1282,8 @@ class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler public: inline wxPICTResourceHandler() { - m_name = "Macintosh Pict resource"; - m_extension = ""; + m_name = wxT("Macintosh Pict resource"); + m_extension = wxEmptyString; m_type = wxBITMAP_TYPE_PICT_RESOURCE; }; @@ -1296,14 +1296,8 @@ bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo int desiredWidth, int desiredHeight) { Str255 theName ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; -#else - strcpy( (char *) theName , name ) ; - c2pstr( (char *)theName ) ; -#endif - + wxMacStringToPascal( name , theName ) ; + PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; if ( thePict ) { diff --git a/src/mac/bmpbuttn.cpp b/src/mac/bmpbuttn.cpp index ebf8021262..046d548058 100644 --- a/src/mac/bmpbuttn.cpp +++ b/src/mac/bmpbuttn.cpp @@ -58,14 +58,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit if ( m_bmpNormal.Ok() ) bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; - MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorOffsetContents + ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0, (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ControlButtonContentInfo info ; wxMacCreateBitmapButton( &info , m_bmpNormal ) ; diff --git a/src/mac/button.cpp b/src/mac/button.cpp index 763048808e..49c0586734 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -47,7 +47,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlPushButtonProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index b100ef0b8c..5766c82f22 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -116,7 +116,7 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macPreferencesMenuItemId = 0 ; long wxApp::s_macExitMenuItemId = wxID_EXIT ; -wxString wxApp::s_macHelpMenuTitleName = "&Help" ; +wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; //---------------------------------------------------------------------- // Core Apple Event Support @@ -538,7 +538,8 @@ bool wxApp::Initialize() #endif #endif - + wxMacSetupConverters() ; + s_macCursorRgn = ::NewRgn() ; wxClassInfo::InitializeClasses(); @@ -719,7 +720,8 @@ void wxApp::CleanUp() // __wxterminate in Mach-O shared libraries wxStAppResource::CloseSharedLibraryResource(); #endif - + wxMacCleanupConverters() ; + UMACleanupToolbox() ; if (s_macCursorRgn) { ::DisposeRgn((RgnHandle)s_macCursorRgn); @@ -961,7 +963,17 @@ int wxEntry( int argc, char *argv[] , bool enterLoop ) // we could try to get the open apple events here to adjust argc and argv better wxTheApp->argc = argc; +#if wxUSE_UNICODE + wxTheApp->argv = new wxChar*[argc+1]; + int mb_argc ; + for ( mb_argc = 0; mb_argc < argc; mb_argc++ ) + { + wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc])); + } + wxTheApp->argv[mb_argc] = (wxChar *)NULL; +#else wxTheApp->argv = argv; +#endif // GUI-specific initialization, such as creating an app context. wxEntryInitGui(); diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index ba28f7c08b..5974622370 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -694,7 +694,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return true; } } - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return false; } @@ -707,7 +707,7 @@ bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int wxBitmapHandler *handler = FindHandler(type); if ( handler == NULL ) { - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return FALSE; } @@ -944,7 +944,7 @@ bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, return image.SaveFile(filename, type); } - wxLogWarning("no bitmap handler for type %d defined.", type); + wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return false; } @@ -1282,8 +1282,8 @@ class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler public: inline wxPICTResourceHandler() { - m_name = "Macintosh Pict resource"; - m_extension = ""; + m_name = wxT("Macintosh Pict resource"); + m_extension = wxEmptyString; m_type = wxBITMAP_TYPE_PICT_RESOURCE; }; @@ -1296,14 +1296,8 @@ bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo int desiredWidth, int desiredHeight) { Str255 theName ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; -#else - strcpy( (char *) theName , name ) ; - c2pstr( (char *)theName ) ; -#endif - + wxMacStringToPascal( name , theName ) ; + PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; if ( thePict ) { diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index ebf8021262..046d548058 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -58,14 +58,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit if ( m_bmpNormal.Ok() ) bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; - MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorOffsetContents + ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0, (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ControlButtonContentInfo info ; wxMacCreateBitmapButton( &info , m_bmpNormal ) ; diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index 763048808e..49c0586734 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -47,7 +47,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlPushButtonProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/checklst.cpp b/src/mac/carbon/checklst.cpp index c50773b137..d987d94994 100644 --- a/src/mac/carbon/checklst.cpp +++ b/src/mac/carbon/checklst.cpp @@ -211,7 +211,7 @@ bool wxCheckListBox::Create(wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 863b944cb4..19f8e405d2 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -49,7 +49,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; @@ -169,7 +169,7 @@ wxString wxChoice::GetString(int n) const void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(), - "invalid index in wxChoice::SetClientData" ); + wxT("invalid index in wxChoice::SetClientData") ); m_datas[n] = (char*) clientData ; } @@ -177,7 +177,7 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) void *wxChoice::DoGetItemClientData(int n) const { wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL, - "invalid index in wxChoice::GetClientData" ); + wxT("invalid index in wxChoice::GetClientData") ); return (void *)m_datas[n]; } diff --git a/src/mac/carbon/clipbrd.cpp b/src/mac/carbon/clipbrd.cpp index 47a2b428f9..942a17c6fb 100644 --- a/src/mac/carbon/clipbrd.cpp +++ b/src/mac/carbon/clipbrd.cpp @@ -55,6 +55,8 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) case wxDF_TEXT: break; + case wxDF_UNICODETEXT: + break; case wxDF_BITMAP : case wxDF_METAFILE : break ; @@ -77,15 +79,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) { if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr) { - if ( dataFormat.GetType() == wxDF_TEXT ) - byteCount++ ; + Size allocSize = byteCount ; + if ( dataFormat.GetType() == wxDF_TEXT ) + allocSize += 1 ; + else if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + allocSize += 2 ; - data = new char[ byteCount ] ; + data = new char[ allocSize ] ; + if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) { - *len = byteCount ; + *len = allocSize ; if ( dataFormat.GetType() == wxDF_TEXT ) ((char*)data)[byteCount] = 0 ; + if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + ((wxChar*)data)[byteCount/2] = 0 ; } else { @@ -105,14 +113,19 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) if ( GetHandleSize( datahandle ) > 0 ) { byteCount = GetHandleSize( datahandle ) ; + Size allocSize = byteCount ; if ( dataFormat.GetType() == wxDF_TEXT ) - data = new char[ byteCount + 1] ; - else - data = new char[ byteCount ] ; - + allocSize += 1 ; + else if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + allocSize += 2 ; + + data = new char[ allocSize ] ; + memcpy( (char*) data , (char*) *datahandle , byteCount ) ; if ( dataFormat.GetType() == wxDF_TEXT ) ((char*)data)[byteCount] = 0 ; + if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + ((wxChar*)data)[byteCount/2] = 0 ; *len = byteCount ; } DisposeHandle( datahandle ) ; @@ -123,10 +136,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) return NULL ; } + if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)data,(char*)data,byteCount) ; + wxString st = wxMacMakeStringFromCString( (char*) data ) ; +#if wxUSE_UNICODE + wxCharBuffer buf = st.ToAscii() ; +#else + char* buf = st ; +#endif + char* newdata = new char[strlen(buf)+1] ; + memcpy( newdata , buf , strlen(buf)+1 ) ; + delete[] ((char*) data ) ; + data = newdata ; } + return data; } @@ -234,19 +258,19 @@ bool wxClipboard::AddData( wxDataObject *data ) { wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxString str(textDataObject->GetText()); - wxString mac ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - mac = wxMacMakeMacStringFromPC(textDataObject->GetText()) ; - } - else - { - mac = textDataObject->GetText() ; - } - err = UMAPutScrap( mac.Length() , 'TEXT' , (void*) mac.c_str() ) ; + wxCharBuffer buf = wxMacStringToCString( str ) ; + err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ; } break ; - +#if wxUSE_UNICODE + case wxDF_UNICODETEXT : + { + wxTextDataObject* textDataObject = (wxTextDataObject*) data; + wxString str(textDataObject->GetText()); + err = UMAPutScrap( str.Length() * sizeof(wxChar) , kScrapFlavorTypeUnicode , (void*) str.wc_str() ) ; + } + break ; +#endif #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { @@ -255,7 +279,7 @@ bool wxClipboard::AddData( wxDataObject *data ) wxMetafile metaFile = metaFileDataObject->GetMetafile(); PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , kScrapFlavorTypePicture , *pict ) ; HUnlock( (Handle) pict ) ; } break ; @@ -270,7 +294,7 @@ bool wxClipboard::AddData( wxDataObject *data ) pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , kScrapFlavorTypePicture , *pict ) ; HUnlock( (Handle) pict ) ; if ( created ) KillPicture( pict ) ; diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 7d2a6819ea..8ffecd0489 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -456,7 +456,7 @@ wxString wxComboBox::GetStringSelection() const if (sel > -1) return wxString(this->GetString (sel)); else - return wxString(""); + return wxEmptyString; } bool wxComboBox::SetStringSelection(const wxString& sel) diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index e12f3f63da..f0dc6ee7a4 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -208,23 +208,9 @@ void wxControl::SetLabel(const wxString& title) { m_label = wxStripMenuCodes(title) ; - if ( (ControlHandle) m_macControl ) + if ( m_macControl ) { - Str255 maclabel ; - wxString label ; - - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( m_label ) ; - else - label = m_label ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) maclabel , label ) ; -#else - strcpy( (char *) maclabel , label ) ; - c2pstr( (char *) maclabel ) ; -#endif - ::SetControlTitle( (ControlHandle) m_macControl , maclabel ) ; + UMASetControlTitle( (ControlHandle) m_macControl , m_label ) ; } Refresh() ; } @@ -311,7 +297,7 @@ void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *contro { // adding NULL WindowRef is (first) surely a result of an error and // (secondly) breaks menu command processing - wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" ); + wxCHECK_RET( inControl != (ControlHandle) NULL, wxT("attempt to add a NULL WindowRef to window list") ); if ( !wxWinMacControlList->Find((long)inControl) ) wxWinMacControlList->Append((long)inControl, control); @@ -361,7 +347,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l void wxControl::MacPostControlCreate() { - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) { @@ -438,6 +424,10 @@ void wxControl::MacPostControlCreate() SetSize(pos.x, pos.y, new_size.x, new_size.y); +#if wxUSE_UNICODE + UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) ) ; +#endif + UMAShowControl( (ControlHandle) m_macControl ) ; SetCursor( *wxSTANDARD_CURSOR ) ; @@ -907,6 +897,6 @@ bool wxControl::MacCanFocus() const void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; } diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index d698913890..1200fb9c69 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -292,13 +292,7 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) { Str255 theName ; - - #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , cursor_file ) ; - #else - strcpy( (char *) theName , cursor_file ) ; - c2pstr( (char *) theName ) ; - #endif + wxMacStringToPascal( cursor_file , theName ) ; wxStAppResource resload ; Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index c1a443a7e5..5949c6300b 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -1,11 +1,11 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: os2/dataobj.cpp -// Purpose: implementation of wx[I]DataObject class -// Author: David Webster +// Name: mac/dataobj.cpp +// Purpose: implementation of wxDataObject class +// Author: Stefan Csomor // Modified by: // Created: 10/21/99 // RCS-ID: $Id$ -// Copyright: (c) 1999 David Webster +// Copyright: (c) 1999 Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,6 +34,7 @@ #include "wx/mstream.h" #include "wx/image.h" #include "wx/mac/private.h" +#include "Scrap.h" // ---------------------------------------------------------------------------- // functions @@ -73,10 +74,12 @@ void wxDataFormat::SetType( wxDataFormatId Type ) { m_type = Type; - if (m_type == wxDF_TEXT) - m_format = 'TEXT'; + if (m_type == wxDF_TEXT ) + m_format = kScrapFlavorTypeText; + else if (m_type == wxDF_UNICODETEXT ) + m_format = kScrapFlavorTypeUnicode ; else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE ) - m_format = 'PICT'; + m_format = kScrapFlavorTypePicture; else if (m_type == wxDF_FILENAME) m_format = kDragFlavorTypeHFS ; else @@ -92,18 +95,23 @@ wxDataFormatId wxDataFormat::GetType() const wxString wxDataFormat::GetId() const { - wxString sRet(""); // TODO: to name of ( m_format ) ); - return sRet; + char text[5] ; + strncpy( text , (char*) m_format , 4 ) ; + text[4] = 0 ; + return wxString::FromAscii( text ) ; } void wxDataFormat::SetId( NativeFormat format ) { m_format = format; - if (m_format == 'TEXT') + if (m_format == kScrapFlavorTypeText) m_type = wxDF_TEXT; else - if (m_format == 'PICT') + if (m_format == kScrapFlavorTypeUnicode ) + m_type = wxDF_UNICODETEXT; + else + if (m_format == kScrapFlavorTypePicture) m_type = wxDF_BITMAP; else if (m_format == kDragFlavorTypeHFS ) @@ -201,9 +209,7 @@ bool wxFileDataObject::SetData( { m_filenames.Empty(); - wxString sFile( (const char *)pBuf); /* char, not wxChar */ - - AddFile(sFile); + AddFile(wxString::FromAscii((char*)pBuf)); return TRUE; } diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index ed0648f9dc..9bcf525f26 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -1111,7 +1111,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, } if ( mode == kUnsupportedMode ) { - wxFAIL_MSG("unsupported blitting mode" ); + wxFAIL_MSG(wxT("unsupported blitting mode" )); return FALSE ; } CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; @@ -1295,17 +1295,10 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, } if ( str.Length() == 0 ) return ; + wxMacPortSetter helper(this) ; MacInstallFont() ; - wxString text ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - text = wxMacMakeMacStringFromPC( str ) ; - } - else - { - text = str ; - } + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { @@ -1314,23 +1307,30 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, m_macAliasWasEnabled = true ; } OSStatus status = noErr ; + ATSUTextLayout atsuLayout ; + UniCharCount chars = str.Length() ; +#if wxUSE_UNICODE + status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 , + &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; +#else TECObjectRef ec; - status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); - wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; + status = TECCreateConverter(&ec, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + + wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ; ByteCount byteOutLen ; - ByteCount byteInLen = text.Length() ; + ByteCount byteInLen = str.Length() ; ByteCount byteBufferLen = byteInLen *2 ; char* buf = new char[byteBufferLen] ; - status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, + status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen, (TextPtr)buf, byteBufferLen, &byteOutLen); - wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ; status = TECDisposeConverter(ec); - wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; - ATSUTextLayout atsuLayout ; - UniCharCount chars = byteOutLen / 2 ; + wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ; status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; - wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); +#endif + wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); int iAngle = int( angle ); int drawX = XLOG2DEVMAC(x) ; int drawY = YLOG2DEVMAC(y) ; @@ -1366,16 +1366,19 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) ); - wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); + wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); Rect rect ; status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) , &rect ); - wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); + wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); ::ATSUDisposeTextLayout(atsuLayout); +#if wxUSE_UNICODE +#else delete[] buf ; +#endif } void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) @@ -1411,33 +1414,22 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { ::TextMode( srcCopy ) ; } - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( strtext ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = strtext ; - length = strtext.Length() ; - } + int length = strtext.Length() ; + int laststop = 0 ; int i = 0 ; int line = 0 ; { while( i < length ) { - if( text[i] == 13 || text[i] == 10) + if( strtext[i] == 13 || strtext[i] == 10) { + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; if ( m_backgroundMode != wxTRANSPARENT ) { Point bounds={0,0} ; @@ -1460,13 +1452,13 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) &frame, teJustLeft, nil ); - CFRelease( mString ) ; line++ ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + ::DrawText( text , 0 , strlen(text) ) ; line++ ; ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); } @@ -1474,11 +1466,12 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) } i++ ; } + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + wxMacCFStringHolder mString( linetext ) ; if ( m_backgroundMode != wxTRANSPARENT ) { @@ -1502,13 +1495,13 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) &frame, teJustLeft, nil ); - CFRelease( mString ) ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; - } + wxCharBuffer text = wxMacStringToCString(linetext) ; + ::DrawText( text , 0 , strlen(text) ) ; + } } ::TextMode( srcOr ) ; } @@ -1519,7 +1512,7 @@ bool wxDC::CanGetTextExtent() const return true ; } -void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, +void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading , wxFont *theFont ) const { @@ -1545,8 +1538,9 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he *descent =YDEV2LOGREL( fi.descent ); if ( externalLeading ) *externalLeading = YDEV2LOGREL( fi.leading ) ; + int length = strtext.Length() ; + /* const char *text = NULL ; - int length = 0 ; wxString macText ; if ( wxApp::s_macDefaultEncodingIsPC ) { @@ -1559,6 +1553,7 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he text = string ; length = string.Length() ; } + */ int laststop = 0 ; int i = 0 ; int curwidth = 0 ; @@ -1567,8 +1562,9 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he *width = 0 ; while( i < length ) { - if( text[i] == 13 || text[i] == 10) + if( strtext[i] == 13 || strtext[i] == 10) { + wxString linetext = strtext.Mid( laststop , i - laststop ) ; if ( height ) *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; #if TARGET_CARBON @@ -1576,20 +1572,20 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he { Point bounds={0,0} ; SInt16 baseline ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); - CFRelease( mString ) ; curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + curwidth = ::TextWidth( text , 0 , strlen(text) ) ; } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; @@ -1598,25 +1594,26 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he i++ ; } + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); - CFRelease( mString ) ; curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + curwidth = ::TextWidth( text , 0 , strlen(text) ) ; } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; @@ -1773,7 +1770,7 @@ void wxDC::MacInstallFont() const Style qdStyle = font->m_macFontStyle ; ATSUFontID atsuFont = font->m_macATSUFontID ; status = ::ATSUCreateStyle(&(ATSUStyle)m_macATSUIStyle) ; - wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; ATSUAttributeTag atsuTags[] = { kATSUFontTag , @@ -1819,7 +1816,7 @@ void wxDC::MacInstallFont() const } ; status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), atsuTags, atsuSizes, atsuValues); - wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; } Pattern gHatchPatterns[] = diff --git a/src/mac/carbon/dcprint.cpp b/src/mac/carbon/dcprint.cpp index 82bdecd0cf..a841324bd3 100644 --- a/src/mac/carbon/dcprint.cpp +++ b/src/mac/carbon/dcprint.cpp @@ -62,8 +62,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) if ( err != noErr ) #endif { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease( m_macPrintSessionPort ) ; @@ -88,8 +88,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); UMAPrClose(NULL) ; m_ok = FALSE; @@ -150,8 +150,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -234,8 +234,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) err = PrError() ; if ( err ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); UMAPrClose(NULL) ; m_ok = FALSE; @@ -258,8 +258,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) if ( err != noErr || m_macPrintSessionPort == kPMNoReference ) #endif { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -280,8 +280,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -321,8 +321,8 @@ void wxPrinterDC::EndDoc(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } } @@ -363,8 +363,8 @@ void wxPrinterDC::StartPage(void) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; @@ -382,8 +382,8 @@ void wxPrinterDC::StartPage(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); @@ -421,8 +421,8 @@ void wxPrinterDC::EndPage(void) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld") , err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; ::UMAPrClose(NULL) ; @@ -437,8 +437,8 @@ void wxPrinterDC::EndPage(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); diff --git a/src/mac/carbon/dirdlg.cpp b/src/mac/carbon/dirdlg.cpp index 6864054234..0b4c7df195 100644 --- a/src/mac/carbon/dirdlg.cpp +++ b/src/mac/carbon/dirdlg.cpp @@ -40,7 +40,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; m_message = message; m_dialogStyle = style; m_parent = parent; @@ -92,7 +92,7 @@ int wxDirDialog::ShowModal() 0L); // User Data if ( (err != noErr) && (err != userCanceledErr) ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } @@ -104,7 +104,7 @@ int wxDirDialog::ShowModal() OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } folderInfo = **(FSSpec**) specDesc.dataHandle; @@ -130,7 +130,7 @@ int wxDirDialog::ShowModal() err = ::PBGetCatInfoSync(&thePB); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } // Create cannonical FSSpec diff --git a/src/mac/carbon/dirmac.cpp b/src/mac/carbon/dirmac.cpp index 9ea9415df4..ff168bafdc 100644 --- a/src/mac/carbon/dirmac.cpp +++ b/src/mac/carbon/dirmac.cpp @@ -133,7 +133,7 @@ wxDirData::wxDirData(const wxString& dirname) err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; #endif - wxASSERT_MSG( (err == noErr) || (err == nsvErr) , "Error accessing directory " + m_dirname) ; + wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ; m_CPB.hFileInfo.ioNamePtr = m_name ; m_index = 0 ; @@ -153,9 +153,6 @@ bool wxDirData::Read(wxString *filename) if ( !m_isDir ) return FALSE ; -#if TARGET_CARBON - char c_name[256] ; -#endif wxString result; short err = noErr ; @@ -169,18 +166,12 @@ bool wxDirData::Read(wxString *filename) if ( err != noErr ) break ; -#if TARGET_CARBON - p2cstrcpy( c_name, m_name ) ; - strcpy( (char *)m_name, c_name); -#else - p2cstr( m_name ) ; -#endif // its hidden but we don't want it if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) continue ; #ifdef __DARWIN__ // under X, names that start with '.' are hidden - if ( ( m_name[0] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) + if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) continue; #endif #if TARGET_CARBON @@ -196,18 +187,18 @@ bool wxDirData::Read(wxString *filename) if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) continue ; - wxString file( m_name ) ; - if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" ) + wxString file = wxMacMakeStringFromPascal( m_name ) ; + if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") ) { } - else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") ) { if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() ) { continue ; } } - else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") ) { if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() ) { @@ -226,7 +217,7 @@ bool wxDirData::Read(wxString *filename) return FALSE ; } - *filename = (char*) m_name ; + *filename = wxMacMakeStringFromPascal( m_name ) ; return TRUE; } diff --git a/src/mac/carbon/dnd.cpp b/src/mac/carbon/dnd.cpp index 2ea8ae7c90..d4eb35abba 100644 --- a/src/mac/carbon/dnd.cpp +++ b/src/mac/carbon/dnd.cpp @@ -205,12 +205,9 @@ bool wxDropTarget::GetData() GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); if( theType == 'TEXT' ) { - theData[dataSize]=0 ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; - } - m_dataObject->SetData( format, dataSize, theData ); + theData[dataSize]=0 ; + wxString convert = wxMacMakeStringFromCString( theData ) ; + m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert ); } else if ( theType == kDragFlavorTypeHFS ) { @@ -303,11 +300,10 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) if ( type == 'TEXT' ) { dataSize-- ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; - } - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + dataPtr[ dataSize ] = 0 ; + wxString st( (wxChar*) dataPtr ) ; + wxCharBuffer buf = wxMacStringToCString( st ) ; + AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0); } else if (type == kDragFlavorTypeHFS ) { diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index 5a65441f23..f2b6707baf 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -104,13 +104,12 @@ NavEventProc( Str255 filename ; // get the current filename NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); - CopyPascalStringToC( filename , (char*) filename ) ; - wxString sfilename( filename ) ; + wxString sfilename = wxMacMakeStringFromPascal( filename ) ; int pos = sfilename.Find('.',TRUE) ; if ( pos != wxNOT_FOUND ) { sfilename = sfilename.Left(pos+1)+extension ; - CopyCStringToPascal( sfilename.c_str() , filename ) ; + wxMacStringToPascal( sfilename , filename ) ; NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); } } @@ -118,11 +117,11 @@ NavEventProc( } } -const char * gfilters[] = +const wxChar * gfilters[] = { - "*.TXT" , - "*.TIF" , - "*.JPG" , + wxT("*.TXT") , + wxT("*.TIF") , + wxT("*.JPG") , NULL } ; @@ -162,7 +161,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) ++filterIndex ; } isName = !isName ; - current = "" ; + current = wxEmptyString ; } else { @@ -172,7 +171,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) // we allow for compatibility reason to have a single filter expression (like *.*) without // an explanatory text, in that case the first part is name and extension at the same time - wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; + wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; if ( current.IsEmpty() ) myData->extensions.Add( myData->name[filterIndex] ) ; else @@ -189,7 +188,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) int j ; for ( j = 0 ; gfilters[j] ; j++ ) { - if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) + if ( myData->extensions[i] == gfilters[j] ) { myData->filtermactypes.Add( gfiltersmac[j] ) ; break ; @@ -205,6 +204,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecPtr data) { +/* Str255 filename ; #if TARGET_CARBON @@ -214,20 +214,22 @@ static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecP p2cstr( filename ) ; #endif wxString file(filename) ; +*/ + wxString file = wxMacMakeStringFromPascal( name ) ; file.MakeUpper() ; if ( data->extensions.GetCount() > 0 ) { //for ( int i = 0 ; i < data->numfilters ; ++i ) int i = data->currentfilter ; - if ( data->extensions[i].Right(2) == ".*" ) + if ( data->extensions[i].Right(2) == wxT(".*") ) return true ; { if ( type == (OSType)data->filtermactypes[i] ) return true ; - wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; + wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ; while( tokenizer.HasMoreTokens() ) { wxString extension = tokenizer.GetNextToken() ; @@ -272,17 +274,17 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat // end wxmac -wxString wxFileSelector(const char *title, - const char *defaultDir, const char *defaultFileName, - const char *defaultExtension, const char *filter, int flags, +wxString wxFileSelector(const wxChar *title, + const wxChar *defaultDir, const wxChar *defaultFileName, + const wxChar *defaultExtension, const wxChar *filter, int flags, wxWindow *parent, int x, int y) { // If there's a default extension specified but no filter, we create a suitable // filter. - wxString filter2(""); + wxString filter2; if ( defaultExtension && !filter ) - filter2 = wxString("*.") + wxString(defaultExtension) ; + filter2 = wxString(wxT("*.")) + wxString(defaultExtension) ; else if ( filter ) filter2 = filter; @@ -290,13 +292,13 @@ wxString wxFileSelector(const char *title, if (defaultDir) defaultDirString = defaultDir; else - defaultDirString = ""; + defaultDirString = wxEmptyString ; wxString defaultFilenameString; if (defaultFileName) defaultFilenameString = defaultFileName; else - defaultFilenameString = ""; + defaultFilenameString = wxEmptyString; wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y)); @@ -308,19 +310,19 @@ wxString wxFileSelector(const char *title, return wxGetEmptyString(); } -WXDLLEXPORT wxString wxFileSelectorEx(const char *title, - const char *defaultDir, - const char *defaultFileName, +WXDLLEXPORT wxString wxFileSelectorEx(const wxChar *title, + const wxChar *defaultDir, + const wxChar *defaultFileName, int* defaultFilterIndex, - const char *filter, + const wxChar *filter, int flags, wxWindow* parent, int x, int y) { - wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "", - defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y)); + wxFileDialog fileDialog(parent, title ? title : wxT(""), defaultDir ? defaultDir : wxT(""), + defaultFileName ? defaultFileName : wxT(""), filter ? filter : wxT(""), flags, wxPoint(x, y)); if ( fileDialog.ShowModal() == wxID_OK ) { @@ -335,18 +337,17 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, long style, const wxPoint& pos) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; m_message = message; m_dialogStyle = style; m_parent = parent; - m_path = ""; + m_path = wxT(""); m_fileName = defaultFileName; m_dir = defaultDir; m_wildCard = wildCard; m_filterIndex = 0; } - pascal Boolean CrossPlatformFilterCallback ( AEDesc *theItem, void *info, @@ -417,19 +418,8 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; } } - -#if TARGET_CARBON - c2pstrcpy((StringPtr)mNavOptions.message, m_message) ; -#else - strcpy((char *)mNavOptions.message, m_message) ; - c2pstr((char *)mNavOptions.message ) ; -#endif -#if TARGET_CARBON - c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ; -#else - strcpy((char *)mNavOptions.savedFileName, m_fileName) ; - c2pstr((char *)mNavOptions.savedFileName ) ; -#endif + wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ; + wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ; // zero all data @@ -450,12 +440,7 @@ int wxFileDialog::ShowModal() (*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ; (*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ; (*mNavOptions.popupExtension)[i].menuType = i ; -#if TARGET_CARBON - c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ; -#else - strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ; - c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ; -#endif + wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ; } } if ( m_dialogStyle & wxSAVE ) @@ -519,7 +504,7 @@ int wxFileDialog::ShowModal() { OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } outFileSpec = **(FSSpec**) specDesc.dataHandle; @@ -543,28 +528,30 @@ int wxFileDialog::ShowModal() // Generic file load/save dialog static wxString -wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxDefaultFileSelector(bool load, const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { - char *ext = (char *)extension; - - char prompt[50]; + wxString prompt; + wxString str; if (load) - str = "Load %s file"; + str = wxT("Load %s file"); else - str = "Save %s file"; - sprintf(prompt, wxGetTranslation(str), what); + str = wxT("Save %s file"); + prompt.Printf( wxGetTranslation(str), what); - if (*ext == '.') ext++; - char wild[60]; - sprintf(wild, "*.%s", ext); + const wxChar *ext = extension; + if (*ext == wxT('.')) + ext++; + + wxString wild; + wild.Printf(wxT("*.%s"), ext); return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent); } // Generic file load dialog wxString -wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxLoadFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); } @@ -572,9 +559,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_ // Generic file save dialog wxString -wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); } - - diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index e134003482..5ffa4f828b 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -67,7 +67,7 @@ wxFontRefData::~wxFontRefData() void wxFontRefData::MacFindFont() { - if( m_faceName == "" ) + if( m_faceName.Length() == 0 ) { switch( m_family ) { @@ -92,14 +92,13 @@ void wxFontRefData::MacFindFont() } Str255 name ; GetFontName( m_macFontNum , name ) ; - CopyPascalStringToC( name , (char*) name ) ; - m_faceName = (char*) name ; + m_faceName = wxMacMakeStringFromPascal( name ) ; } else { - if ( m_faceName == "systemfont" ) + if ( m_faceName == wxT("systemfont") ) m_macFontNum = ::GetSysFont() ; - else if ( m_faceName == "applicationfont" ) + else if ( m_faceName == wxT("applicationfont") ) m_macFontNum = ::GetAppFont() ; else { @@ -126,7 +125,7 @@ void wxFontRefData::MacFindFont() status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; */ - wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index 1a61e4f723..de7dd8c90c 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -40,7 +40,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, size = wxSize( 200 , 16 ) ; } - MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, kControlProgressBarProc , (long) this ) ; diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp index aca2b5be13..e66592a619 100644 --- a/src/mac/carbon/glcanvas.cpp +++ b/src/mac/carbon/glcanvas.cpp @@ -91,7 +91,7 @@ void wxGLContext::Update() } } -void wxGLContext::SetColour(const char *colour) +void wxGLContext::SetColour(const wxChar *colour) { float r = 0.0; float g = 0.0; @@ -309,7 +309,7 @@ void wxGLCanvas::SetCurrent() } } -void wxGLCanvas::SetColour(const char *colour) +void wxGLCanvas::SetColour(const wxChar *colour) { if (m_glContext) m_glContext->SetColour(colour); diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index ef4526a670..bd1937bc2a 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -83,19 +83,19 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo int desiredWidth, int desiredHeight) { short theId = -1 ; - if ( name == "wxICON_INFORMATION" ) + if ( name == wxT("wxICON_INFORMATION") ) { theId = kNoteIcon ; } - else if ( name == "wxICON_QUESTION" ) + else if ( name == wxT("wxICON_QUESTION") ) { theId = kCautionIcon ; } - else if ( name == "wxICON_WARNING" ) + else if ( name == wxT("wxICON_WARNING") ) { theId = kCautionIcon ; } - else if ( name == "wxICON_ERROR" ) + else if ( name == wxT("wxICON_ERROR") ) { theId = kStopIcon ; } @@ -103,13 +103,7 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo { Str255 theName ; OSType theType ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; -#else - strcpy( (char *) theName , name ) ; - c2pstr( (char *) theName ) ; -#endif + wxMacStringToPascal( name , theName ) ; Handle resHandle = GetNamedResource( 'cicn' , theName ) ; if ( resHandle != 0L ) diff --git a/src/mac/carbon/joystick.cpp b/src/mac/carbon/joystick.cpp index 6a45f419fd..156b9b2657 100644 --- a/src/mac/carbon/joystick.cpp +++ b/src/mac/carbon/joystick.cpp @@ -113,7 +113,7 @@ int wxJoystick::GetProductId() const wxString wxJoystick::GetProductName() const { // TODO - return wxString(""); + return wxString(wxT("")); } int wxJoystick::GetXMin() const diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 2d7dff4fbc..12e2c048bb 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -94,7 +94,7 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect case lDrawMsg: { - const wxString text = list->m_stringArray[cell.v] ; + const wxString linetext = list->m_stringArray[cell.v] ; // Save the current clip region, and set the clip region to the area we are about // to draw. @@ -121,32 +121,27 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect } #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - - if ( useDrawThemeText ) - { - Rect frame = { drawRect->top, drawRect->left + 4, - drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; - CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ; - CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ; - CFRelease( sString ) ; - ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else -#endif - { + { + Rect frame = { drawRect->top, drawRect->left + 4, + drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; + CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext) ) ; + ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } +#else + { + wxCharBuffer text = wxMacStringToCString( linetext ) ; MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - DrawText(text, 0 , text.Length()); + DrawText(text, 0 , strlen(text) ); } - +#endif // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -213,7 +208,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; @@ -234,8 +229,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, fontSize = 9 ; fontStyle = normal ; #endif - CopyPascalStringToC( fontName , (char*) fontName ) ; - SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ; + SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ; #if TARGET_CARBON Size asize; @@ -388,15 +382,8 @@ void wxListBox::Delete(int N) int wxListBox::DoAppend(const wxString& item) { int index = m_noItems ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ; - m_dataArray.Add( NULL ); - } - else { - m_stringArray.Add( item ) ; - m_dataArray.Add( NULL ); - } + m_stringArray.Add( item ) ; + m_dataArray.Add( NULL ); m_noItems ++; DoSetItemClientData( index , NULL ) ; MacAppend( item ) ; @@ -451,47 +438,30 @@ bool wxListBox::HasMultipleSelection() const return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED); } -int wxListBox::FindString(const wxString& st) const +int wxListBox::FindString(const wxString& s) const { - wxString s ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - s = wxMacMakeMacStringFromPC( st ) ; - } - else - s = st ; - if ( s.Right(1) == "*" ) + if ( s.Right(1) == wxT("*") ) { wxString search = s.Left( s.Length() - 1 ) ; int len = search.Length() ; Str255 s1 , s2 ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s2 , search.c_str() ) ; -#else - strcpy( (char *) s2 , search.c_str() ) ; - c2pstr( (char *) s2 ) ; -#endif + wxMacStringToPascal( search , s2 ) ; for ( int i = 0 ; i < m_noItems ; ++ i ) { -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ; -#else - strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ; - c2pstr( (char *) s1 ) ; -#endif + wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ; + if ( EqualString( s1 , s2 , false , false ) ) return i ; } - if ( s.Left(1) == "*" && s.Length() > 1 ) + if ( s.Left(1) == wxT("*") && s.Length() > 1 ) { - s = st ; - s.MakeLower() ; + wxString st = s ; + st.MakeLower() ; for ( int i = 0 ; i < m_noItems ; ++i ) { - if ( GetString(i).Lower().Matches(s) ) + if ( GetString(i).Lower().Matches(st) ) return i ; } } @@ -501,21 +471,12 @@ int wxListBox::FindString(const wxString& st) const { Str255 s1 , s2 ; -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s2 , s.c_str() ) ; -#else - strcpy( (char *) s2 , s.c_str() ) ; - c2pstr( (char *) s2 ) ; -#endif + wxMacStringToPascal( s , s2 ) ; for ( int i = 0 ; i < m_noItems ; ++ i ) { -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ; -#else - strcpy( (char *) s1 , m_stringArray[i].c_str() ) ; - c2pstr( (char *) s1 ) ; -#endif + wxMacStringToPascal( m_stringArray[i] , s1 ) ; + if ( EqualString( s1 , s2 , false , false ) ) return i ; } @@ -535,7 +496,7 @@ void wxListBox::Clear() void wxListBox::SetSelection(int N, bool select) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetSelection" ); + wxT("invalid index in wxListBox::SetSelection") ); MacSetSelection( N , select ) ; GetSelections( m_selectionPreImage ) ; } @@ -543,7 +504,7 @@ void wxListBox::SetSelection(int N, bool select) bool wxListBox::IsSelected(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, - "invalid index in wxListBox::Selected" ); + wxT("invalid index in wxListBox::Selected") ); return MacIsSelected( N ) ; } @@ -564,7 +525,7 @@ wxClientData *wxListBox::DoGetItemClientObject(int N) const void wxListBox::DoSetItemClientData(int N, void *Client_data) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetClientData" ); + wxT("invalid index in wxListBox::SetClientData") ); #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) @@ -574,7 +535,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); } #endif // wxUSE_OWNER_DRAWN - wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ; + wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , wxT("invalid client_data array") ) ; if ( m_dataArray.GetCount() > (size_t) N ) { @@ -606,12 +567,7 @@ int wxListBox::GetSelection() const // Find string for position wxString wxListBox::GetString(int N) const { - if( wxApp::s_macDefaultEncodingIsPC ) - { - return wxMacMakePCStringFromMac( m_stringArray[N] ) ; - } - else - return m_stringArray[N] ; + return m_stringArray[N] ; } void wxListBox::DoInsertItems(const wxArrayString& items, int pos) @@ -633,14 +589,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) void wxListBox::SetString(int N, const wxString& s) { - wxString str ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - str = wxMacMakeMacStringFromPC( s ) ; - } - else - str = s ; - m_stringArray[N] = str ; + m_stringArray[N] = s ; MacSet( N , s ) ; } @@ -754,7 +703,7 @@ void wxListBox::MacDelete( int N ) Refresh(); } -void wxListBox::MacInsert( int n , const char * text) +void wxListBox::MacInsert( int n , const wxString& text) { Cell cell = { 0 , 0 } ; cell.v = n ; @@ -763,7 +712,7 @@ void wxListBox::MacInsert( int n , const char * text) Refresh(); } -void wxListBox::MacAppend( const char * text) +void wxListBox::MacAppend( const wxString& text) { Cell cell = { 0 , 0 } ; cell.v = (**(ListHandle)m_macList).dataBounds.bottom ; @@ -834,7 +783,7 @@ int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const return no_sel ; } -void wxListBox::MacSet( int n , const char * text ) +void wxListBox::MacSet( int n , const wxString& text ) { // our implementation does not store anything in the list // so we just have to redraw @@ -1011,11 +960,11 @@ void wxListBox::OnChar(wxKeyEvent& event) { if ( event.GetTimestamp() > m_lastTypeIn + 60 ) { - m_typeIn = "" ; + m_typeIn = wxEmptyString ; } m_lastTypeIn = event.GetTimestamp() ; m_typeIn += (char) event.GetKeyCode() ; - int line = FindString("*"+m_typeIn+"*") ; + int line = FindString(wxT("*")+m_typeIn+wxT("*")) ; if ( line >= 0 ) { if ( GetSelection() != line ) diff --git a/src/mac/carbon/macnotfy.cpp b/src/mac/carbon/macnotfy.cpp index b6a170c8ee..36d7fb3e61 100644 --- a/src/mac/carbon/macnotfy.cpp +++ b/src/mac/carbon/macnotfy.cpp @@ -88,7 +88,7 @@ void wxMacAddEvent( short wakeUp ) { wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; + wxASSERT_MSG( handler != NULL , wxT("illegal notification proc ptr") ) ; /* this should be protected eventually */ short index = e->top++ ; diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index cc0aba9ed1..417240fc09 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -107,7 +107,7 @@ void wxMenu::Attach(wxMenuBarBase *menubar) // append a new item or submenu to the menu bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { - wxASSERT_MSG( pItem != NULL, "can't append NULL item to the menu" ); + wxASSERT_MSG( pItem != NULL, wxT("can't append NULL item to the menu") ); if ( pItem->IsSeparator() ) { @@ -121,7 +121,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) wxMenu *pSubMenu = pItem->GetSubMenu() ; if ( pSubMenu != NULL ) { - wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); + wxASSERT_MSG( pSubMenu->m_hMenu != NULL , wxT("invalid submenu added")); pSubMenu->m_menuParent = this ; if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) @@ -140,12 +140,12 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { if ( pos == (size_t)-1 ) { - UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); + UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") ); pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; } else { - UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); + UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") , pos); } SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; @@ -503,7 +503,7 @@ void wxMenuBar::MacInstallMenuBar() Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; wxString message ; - wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); + wxCHECK_RET( menubar != NULL, wxT("can't read MBAR resource") ); ::SetMenuBar( menubar ) ; #if TARGET_API_MAC_CARBON ::DisposeMenuBar( menubar ) ; @@ -550,7 +550,7 @@ void wxMenuBar::MacInstallMenuBar() int pos ; wxMenu* menu = m_menus[i] , *subMenu = NULL ; - if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + if( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName ) { if ( mh == NULL ) { diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index ce04c08eda..807f2a8ee0 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -48,9 +48,9 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, { // In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines // therefore these item must not be translated - if ( wxStripMenuCodes(m_text).Upper() == "EXIT" ) + if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") ) { - m_text = "Quit\tCtrl+Q" ; + m_text =wxT("Quit\tCtrl+Q") ; } m_radioGroup.start = -1; @@ -152,7 +152,7 @@ void wxMenuItem::UncheckRadio() void wxMenuItem::Check(bool bDoCheck) { - wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); + wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") ); if ( m_isChecked != bDoCheck ) { diff --git a/src/mac/carbon/metafile.cpp b/src/mac/carbon/metafile.cpp index 1f87cb9f4a..aca4bc0ae5 100644 --- a/src/mac/carbon/metafile.cpp +++ b/src/mac/carbon/metafile.cpp @@ -72,7 +72,7 @@ wxMetaFile::wxMetaFile(const wxString& file) M_METAFILEDATA->m_metafile = 0; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ; /* if (!file.IsNull() && (file.Cmp("") == 0)) M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); @@ -145,9 +145,9 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file) m_maxX = -10000; m_maxY = -10000; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ; - m_metaFile = new wxMetaFile("") ; + m_metaFile = new wxMetaFile(wxEmptyString) ; Rect r={0,0,1000,1000} ; m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; @@ -167,9 +167,9 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, i m_maxX = -10000; m_maxY = -10000; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet")) ; - m_metaFile = new wxMetaFile("") ; + m_metaFile = new wxMetaFile(wxEmptyString) ; Rect r={yorg,xorg,yorg+yext,xorg+xext} ; m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; diff --git a/src/mac/carbon/mimetmac.cpp b/src/mac/carbon/mimetmac.cpp index 393c2870c4..296c7a81ba 100644 --- a/src/mac/carbon/mimetmac.cpp +++ b/src/mac/carbon/mimetmac.cpp @@ -129,66 +129,66 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e) { wxString ext = e ; ext = ext.Lower() ; - if ( ext == "txt" ) + if ( ext == wxT("txt") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("text/text"); + fileType->m_impl->SetFileType(wxT("text/text")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "htm" || ext == "html" ) + else if ( ext == wxT("htm") || ext == wxT("html") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("text/html"); + fileType->m_impl->SetFileType(wxT("text/html")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "gif" ) + else if ( ext == wxT("gif") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/gif"); + fileType->m_impl->SetFileType(wxT("image/gif")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "png" ) + else if ( ext == wxT("png" )) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/png"); + fileType->m_impl->SetFileType(wxT("image/png")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "jpg" || ext == "jpeg" ) + else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/jpeg"); + fileType->m_impl->SetFileType(wxT("image/jpeg")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "bmp" ) + else if ( ext == wxT("bmp") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/bmp"); + fileType->m_impl->SetFileType(wxT("image/bmp")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "tif" || ext == "tiff" ) + else if ( ext == wxT("tif") || ext == wxT("tiff") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/tiff"); + fileType->m_impl->SetFileType(wxT("image/tiff")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "xpm" ) + else if ( ext == wxT("xpm") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/xpm"); + fileType->m_impl->SetFileType(wxT("image/xpm")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "xbm" ) + else if ( ext == wxT("xbm") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/xbm"); + fileType->m_impl->SetFileType(wxT("image/xbm")); fileType->m_impl->SetExt(ext); return fileType; } diff --git a/src/mac/carbon/msgdlg.cpp b/src/mac/carbon/msgdlg.cpp index 732a2f48ba..670d30644e 100644 --- a/src/mac/carbon/msgdlg.cpp +++ b/src/mac/carbon/msgdlg.cpp @@ -67,7 +67,7 @@ int wxMessageDialog::ShowModal() short result ; - wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; + wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ; AlertType alertType = kAlertPlainAlert ; if (m_dialogStyle & wxICON_EXCLAMATION) @@ -83,17 +83,12 @@ int wxMessageDialog::ShowModal() if ( UMAGetSystemVersion() >= 0x1000 ) { AlertStdCFStringAlertParamRec param ; - CFStringRef cfNoString = NULL ; - CFStringRef cfYesString = NULL ; - - CFStringRef cfTitle = NULL; - CFStringRef cfText = NULL; - - cfTitle = wxMacCreateCFString( m_caption ) ; - cfText = wxMacCreateCFString( m_message ) ; - cfNoString = wxMacCreateCFString( _("No") ) ; - cfYesString = wxMacCreateCFString( _("Yes") ) ; + wxMacCFStringHolder cfNoString(_("No")) ; + wxMacCFStringHolder cfYesString( _("Yes")) ; + wxMacCFStringHolder cfTitle(m_caption); + wxMacCFStringHolder cfText(m_message); + param.movable = true; param.flags = 0 ; @@ -157,32 +152,13 @@ int wxMessageDialog::ShowModal() CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; RunStandardAlert( alertRef , NULL , &result ) ; } - if(cfTitle != NULL) - CFRelease(cfTitle); - if(cfText != NULL) - CFRelease(cfText); - if(cfNoString != NULL) - CFRelease(cfNoString); - if(cfYesString != NULL) - CFRelease(cfYesString); - if ( skipDialog ) + if ( skipDialog ) return wxID_CANCEL ; } else #endif { AlertStdAlertParamRec param; - char cText[2048] ; - - if (wxApp::s_macDefaultEncodingIsPC) - { - strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; - } - else - { - strcpy( cText , m_message ) ; - } - wxMacConvertNewlines( cText , cText ) ; Str255 yesPString ; Str255 noPString ; @@ -192,7 +168,7 @@ int wxMessageDialog::ShowModal() wxMacStringToPascal( m_caption , pascalTitle ) ; wxMacStringToPascal( _("Yes") , yesPString ) ; wxMacStringToPascal( _("No") , noPString ) ; - CopyCStringToPascal( cText , pascalText ) ; + wxMacStringToPascal( m_message , pascalText ) ; param.movable = true; param.filterProc = NULL ; diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index 56cacb02a2..d5f72a32d7 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -130,7 +130,7 @@ bool wxNotebook::Create(wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; int tabstyle = kControlTabSmallNorthProc ; if ( HasFlag(wxNB_LEFT) ) @@ -360,12 +360,8 @@ void wxNotebook::MacSetupTabs() page = m_pages[ii]; info.version = 0; info.iconSuiteID = 0; -#if TARGET_CARBON - c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; -#else - strcpy( (char *) info.name , page->GetLabel() ) ; - c2pstr( (char *) info.name ) ; -#endif + wxMacStringToPascal( page->GetLabel() , info.name ) ; + SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag, sizeof( ControlTabInfoRec) , (char*) &info ) ; SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ; @@ -488,7 +484,7 @@ bool wxNotebook::DoPhase(int /* nPhase */) void wxNotebook::Command(wxCommandEvent& event) { - wxFAIL_MSG("wxNotebook::Command not implemented"); + wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); } // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/pnghand.cpp b/src/mac/carbon/pnghand.cpp index a270cff9e7..583cbbab7a 100644 --- a/src/mac/carbon/pnghand.cpp +++ b/src/mac/carbon/pnghand.cpp @@ -57,7 +57,7 @@ extern void wxMacDestroyGWorld( GWorldPtr gw ) ; void ima_png_error(png_struct *png_ptr, char *message) { - wxMessageBox(message, "PNG error"); + wxMessageBox(wxString::FromAscii(message), wxT("PNG error")); longjmp(png_ptr->jmpbuf, 1); } @@ -819,8 +819,9 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) strcpy(nameStr, name); else { - strcpy(nameStr, filename); - wxStripExtension(nameStr); + wxString str = wxString::FromAscii(filename) ; + wxStripExtension( str ) ; + strcpy(nameStr, str.ToAscii() ); } if ( GetDepth() > 4 ) @@ -888,7 +889,7 @@ bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla int desiredWidth, int desiredHeight) { wxPNGReader reader; - if (reader.ReadFile((char*) (const char*) name)) + if (reader.ReadFile( (char*)(const char*) name.ToAscii() ) ) { return reader.InstantiateBitmap(bitmap); } diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index 779ee74edd..20bf8dedc7 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -97,8 +97,8 @@ int wxPrintDialog::ShowModal() } else { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxT(""), wxICON_HAND | wxOK) ; dialog.ShowModal(); } ::UMAPrClose(NULL) ; @@ -179,8 +179,8 @@ int wxPrintDialog::ShowModal() } if ((err != noErr) && (err != kPMCancel)) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } #else @@ -245,8 +245,8 @@ int wxPageSetupDialog::ShowModal() } else { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); } ::UMAPrClose(NULL) ; @@ -301,8 +301,8 @@ int wxPageSetupDialog::ShowModal() } if ((err != noErr) && (err != kPMCancel)) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } #else diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 5f3c79225e..274f8b1c9e 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -144,7 +144,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (!win) { wxEndBusyCursor(); - wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); + wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent); delete dc; return FALSE; } @@ -162,7 +162,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); - wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); + wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); break; } if (sm_abortIt) diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 15ac067af7..141c7971fc 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -203,7 +203,7 @@ wxString wxRadioBox::GetString(int item) const wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) - return wxString(""); + return wxEmptyString; i = 0; current = m_radioButtonCycle; @@ -409,7 +409,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) int totWidth,totHeight; SetFont(GetParent()->GetFont()); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); + GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); charWidth/=52; maxWidth=-1; @@ -490,7 +490,7 @@ wxSize wxRadioBox::DoGetBestSize() const int totWidth, totHeight; wxFont font = GetParent()->GetFont(); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), + GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font); charWidth /= 52; diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index 6f57b2c40d..ad843c3fd9 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -46,12 +46,12 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, kControlScrollBarLiveProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index 2a95191da2..87d4e58609 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -74,7 +74,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_pageSize = (int)((maxValue-minValue)/10); - MacPreControlCreate( parent, id, "", pos, size, style, + MacPreControlCreate( parent, id, wxEmptyString, pos, size, style, validator, name, &bounds, title ); procID = kControlSliderProc + kControlSliderLiveFeedback; @@ -86,15 +86,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, value, minValue, maxValue, procID, (long) this); - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; if(style & wxSL_LABELS) { - m_macMinimumStatic = new wxStaticText( this, -1, "" ); - m_macMaximumStatic = new wxStaticText( this, -1, "" ); - m_macValueStatic = new wxStaticText( this, -1, "" ); + m_macMinimumStatic = new wxStaticText( this, -1, wxEmptyString ); + m_macMaximumStatic = new wxStaticText( this, -1, wxEmptyString ); + m_macValueStatic = new wxStaticText( this, -1, wxEmptyString ); SetRange(minValue, maxValue); SetValue(value); } @@ -132,7 +132,7 @@ int wxSlider::GetValue() const void wxSlider::SetValue(int value) { wxString valuestring ; - valuestring.Printf( "%d" , value ) ; + valuestring.Printf( wxT("%d") , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; SetControl32BitValue( (ControlHandle) m_macControl , value ) ; @@ -149,11 +149,11 @@ void wxSlider::SetRange(int minValue, int maxValue) SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); if(m_macMinimumStatic) { - value.Printf("%d", m_rangeMin); + value.Printf(wxT("%d"), m_rangeMin); m_macMinimumStatic->SetLabel(value); } if(m_macMaximumStatic) { - value.Printf("%d", m_rangeMax); + value.Printf(wxT("%d"), m_rangeMax); m_macMaximumStatic->SetLabel(value); } SetValue(m_rangeMin); @@ -283,9 +283,9 @@ wxSize wxSlider::DoGetBestSize() const int ht, wd; // Get maximum text label width and height - text.Printf("%d", m_rangeMin); + text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &textwidth, &textheight); - text.Printf("%d", m_rangeMax); + text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &wd, &ht); if(ht > textheight) { textheight = ht; @@ -356,9 +356,9 @@ void wxSlider::MacUpdateDimensions() int ht; // Get maximum text label width and height - text.Printf("%d", m_rangeMin); + text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &minValWidth, &textheight); - text.Printf("%d", m_rangeMax); + text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &maxValWidth, &ht); if(ht > textheight) { textheight = ht; diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index b36c755f7e..0f4faca578 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -47,12 +47,12 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/statlmac.cpp b/src/mac/carbon/statlmac.cpp index dc00dcca0f..30305cc1cf 100644 --- a/src/mac/carbon/statlmac.cpp +++ b/src/mac/carbon/statlmac.cpp @@ -52,7 +52,7 @@ bool wxStaticLine::Create( wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlSeparatorLineProc , (long) this ) ; diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index fc0a5726f9..b2a7d103da 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -59,7 +59,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, return ret; } -const wxString punct = " ,.-;:!?"; +const wxString punct = wxT(" ,.-;:!?"); void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { @@ -68,7 +68,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) if (paragraph.Length() == 0) { // empty line - dc.GetTextExtent( "H", &width, &height ); + dc.GetTextExtent( wxT("H"), &width, &height ); y += height; return; @@ -127,7 +127,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) } dc.DrawText( paragraph, pos , y) ; - paragraph=""; + paragraph=wxEmptyString; y += height ; } } @@ -165,7 +165,7 @@ void wxStaticText::OnDraw( wxDC &dc ) if (text[i] == 13 || text[i] == 10) { DrawParagraph(dc, paragraph,y); - paragraph = "" ; + paragraph = wxEmptyString ; } else { diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index 6e79c88386..4fcf069286 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -39,7 +39,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons m_imageList = NULL; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; @@ -115,7 +115,7 @@ int wxTabCtrl::GetRowCount() const wxString wxTabCtrl::GetItemText(int item) const { // TODO - return wxString(""); + return wxEmptyString; } // Get the item image diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index ae6063d20c..0f6f9e9ab7 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -593,6 +593,7 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle ) kTXNStartOffset, kTXNEndOffset); /* set the field's background */ + tback.bgType = kTXNBackgroundTypeRGB; tback.bg.color = rgbWhite; TXNSetBackground( varsp->fTXNRec, &tback); @@ -701,7 +702,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, mySize.y += 2 * m_macVerticalBorder ; } */ - MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , mySize ,style, validator , name , &bounds , title ) ; if ( m_windowStyle & wxTE_MULTILINE ) { @@ -738,16 +739,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, } MacPostControlCreate() ; - wxString value ; - - if( wxApp::s_macDefaultEncodingIsPC ) - value = wxMacMakeMacStringFromPC( st ) ; - else - value = st ; - if ( !m_macUsesTXN ) { - ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else { @@ -755,9 +750,15 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, /* set up locals */ tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); /* set the text in the record */ - TXNSetData( (**tpvars).fTXNRec, kTXNTextData, (void*)value.c_str(), value.Length(), - kTXNStartOffset, kTXNEndOffset); m_macTXN = (**tpvars).fTXNRec ; +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2, + kTXNStartOffset, kTXNEndOffset); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) , + kTXNStartOffset, kTXNEndOffset); +#endif m_macTXNvars = tpvars ; m_macUsesTXN = true ; TXNSetSelection( (TXNObject) m_macTXN, 0, 0); @@ -777,25 +778,23 @@ wxString wxTextCtrl::GetValue() const err = ::GetControlDataSize((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; - if ( err ) - return wxEmptyString ; - - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxCharBuffer buf(actualSize) ; ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - actualSize , ptr , &actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf(actualSize) ; + actualSize , buf.data() , &actualSize ) ; + result = wxMacMakeStringFromCString( buf ) ; } - } else { +#if wxUSE_UNICODE Handle theText ; - err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNUnicodeTextData ); // all done if ( err ) { @@ -804,18 +803,38 @@ wxString wxTextCtrl::GetValue() const else { actualSize = GetHandleSize( theText ) ; - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - strncpy( ptr , *theText , actualSize ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ; + wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ; ptr[actualSize] = 0 ; result.UngetWriteBuf( actualSize ) ; } DisposeHandle( theText ) ; } +#else + Handle theText ; + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + // all done + if ( err ) + { + actualSize = 0 ; + } + else + { + actualSize = GetHandleSize( theText ) ; + if ( actualSize > 0 ) + { + HLock( theText ) ; + result = wxMacMakeStringFromCString( *theText , actualSize ) ; + HUnlock( theText ) ; + } + DisposeHandle( theText ) ; + } +#endif } - return wxMacMakeStringFromMacString( result ) ; + return result ; } void wxTextCtrl::GetSelection(long* from, long* to) const @@ -833,28 +852,24 @@ void wxTextCtrl::GetSelection(long* from, long* to) const void wxTextCtrl::SetValue(const wxString& st) { - wxString value; - - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakeMacStringFromPC( st ) ; - // value.Replace( "\n", "\r" ); TODO this should be handled by the conversion - } - else - value = st; - - if ( !m_macUsesTXN ) { - ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else { bool formerEditable = IsEditable() ; if ( !formerEditable ) SetEditable(true) ; - TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , + kTXNStartOffset, kTXNEndOffset); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , kTXNStartOffset, kTXNEndOffset); +#endif TXNSetSelection( (TXNObject) m_macTXN, 0, 0); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); if ( !formerEditable ) @@ -884,7 +899,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) if ( style.HasFont() ) { const wxFont &font = style.GetFont() ; - CopyCStringToPascal( font.GetFaceName().c_str() , fontName ) ; + wxMacStringToPascal( font.GetFaceName() , fontName ) ; fontSize = font.GetPointSize() ; if ( font.GetUnderlined() ) fontStyle |= underline ; @@ -918,7 +933,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) { OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr, start,end); - wxASSERT_MSG( status == noErr , "Couldn't set text attributes" ) ; + wxASSERT_MSG( status == noErr , wxT("Couldn't set text attributes") ) ; } if ( !formerEditable ) SetEditable(formerEditable) ; @@ -1140,8 +1155,13 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) SetEditable(true) ; TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; TXNClear( ((TXNObject) m_macTXN) ) ; +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)value.wc_str(), value.Length() * 2 , + kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#else TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#endif if ( !formerEditable ) SetEditable( formerEditable ) ; } @@ -1208,20 +1228,12 @@ bool wxTextCtrl::LoadFile(const wxString& file) return FALSE; } -void wxTextCtrl::WriteText(const wxString& text) -{ - wxString value ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakeMacStringFromPC( text ) ; - // value.Replace( "\n", "\r" ); // TODO this should be handled by the conversion - } - else - value = text ; - +void wxTextCtrl::WriteText(const wxString& st) +{ if ( !m_macUsesTXN ) { - TEInsert( value , value.Length() , ((TEHandle) m_macTE) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ; } else { @@ -1230,8 +1242,14 @@ void wxTextCtrl::WriteText(const wxString& text) SetEditable(true) ; long start , end , dummy ; GetSelection( &start , &dummy ) ; - TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(), +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , + kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#endif GetSelection( &dummy , &end ) ; SetStyle( start , end , GetDefaultStyle() ) ; if ( !formerEditable ) @@ -1415,7 +1433,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const if (count == lineNo) { // Add chars in line then - wxString tmp(""); + wxString tmp; for (size_t j = i; j < content.Length(); j++) { @@ -1429,7 +1447,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const } if (content[i] == '\r') count++; } - return "" ; + return wxEmptyString ; } /* diff --git a/src/mac/carbon/thread.cpp b/src/mac/carbon/thread.cpp index 3e4b1dfc49..e31c812c02 100644 --- a/src/mac/carbon/thread.cpp +++ b/src/mac/carbon/thread.cpp @@ -852,7 +852,7 @@ bool wxThreadModule::OnInit() #endif if ( !hasThreadManager ) { - wxMessageBox( "Error" , "Thread Support is not available on this System" , wxOK ) ; + wxMessageBox( wxT("Error") , wxT("Thread Support is not available on this System") , wxOK ) ; return FALSE ; } diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 33da0a2d4b..42dfe72bab 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -255,7 +255,7 @@ bool wxToolBar::Realize() ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ; */ ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ; - wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; + wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; ::EmbedControl( m_macToolHandle , container ) ; if ( GetWindowStyleFlag() & wxTB_VERTICAL ) @@ -507,7 +507,7 @@ wxString wxToolBar::MacGetToolTipString( wxPoint &pt ) { return tool->GetShortHelp() ; } - return "" ; + return wxEmptyString ; } void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) diff --git a/src/mac/carbon/tooltip.cpp b/src/mac/carbon/tooltip.cpp index 4b00c6f750..bee14fc9fb 100644 --- a/src/mac/carbon/tooltip.cpp +++ b/src/mac/carbon/tooltip.cpp @@ -35,7 +35,7 @@ class wxMacToolTip wxMacToolTip( ) ; ~wxMacToolTip() ; - void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; + void Setup( WindowRef window , const wxString& text , wxPoint localPosition ) ; long GetMark() { return m_mark ; } void Draw() ; void Clear() ; @@ -50,8 +50,8 @@ class wxMacToolTip bool m_shown ; long m_mark ; wxMacToolTipTimer* m_timer ; -#ifdef TARGET_CARBON - CFStringRef m_helpTextRef ; +#if TARGET_CARBON + wxMacCFStringHolder m_helpTextRef ; #endif } ; @@ -186,18 +186,14 @@ wxMacToolTip::wxMacToolTip() m_mark = 0 ; m_shown = false ; m_timer = NULL ; - m_helpTextRef = NULL ; } -void wxMacToolTip::Setup( WindowRef win , wxString text , wxPoint localPosition ) +void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localPosition ) { m_mark++ ; Clear() ; m_position = localPosition ; - if( wxApp::s_macDefaultEncodingIsPC ) - m_label = wxMacMakeMacStringFromPC( text ) ; - else - m_label = text ; + m_label = text ; m_window =win; s_ToolTipWindowRef = m_window ; m_backpict = NULL ; @@ -228,209 +224,147 @@ void wxMacToolTip::Draw() { m_shown = true ; #if TARGET_CARBON - if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) - { - HMHelpContentRec tag ; - tag.version = kMacHelpVersion; - SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort(m_window) ; - LocalToGlobal( (Point *) &tag.absHotRect.top ); - LocalToGlobal( (Point *) &tag.absHotRect.bottom ); - SetPort( port ); - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } - m_helpTextRef = wxMacCreateCFString(m_label) ; - tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; - tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; - tag.tagSide = kHMDefaultSide; - HMDisplayTag( &tag ); - } - else -#endif + HMHelpContentRec tag ; + tag.version = kMacHelpVersion; + SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort(m_window) ; + LocalToGlobal( (Point *) &tag.absHotRect.top ); + LocalToGlobal( (Point *) &tag.absHotRect.bottom ); + SetPort( port ); + m_helpTextRef = m_label ; + tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; + tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; + tag.tagSide = kHMDefaultSide; + HMDisplayTag( &tag ); +#else + wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); + FontFamilyID fontId ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetFNum( fontName, &fontId ); + + TextFont( fontId ) ; + TextSize( fontSize ) ; + TextFace( fontStyle ) ; + FontInfo fontInfo; + ::GetFontInfo(&fontInfo); + short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; + short height = 0 ; + // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; + + int i = 0 ; + int length = m_label.Length() ; + int width = 0 ; + int thiswidth = 0 ; + int laststop = 0 ; + wxCharBuffer text = wxMacStringToCString( m_label ) ; + + while( i < length ) { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); -#if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; -#endif - - FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; - GetFNum( fontName, &fontId ); - - TextFont( fontId ) ; - TextSize( fontSize ) ; - TextFace( fontStyle ) ; - FontInfo fontInfo; - ::GetFontInfo(&fontInfo); - short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; - short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; - - int i = 0 ; - int length = m_label.Length() ; - int width = 0 ; - int thiswidth = 0 ; - int laststop = 0 ; - const char *text = m_label ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - - height += lineh ; - laststop = i+1 ; - } - i++ ; - } - if ( i - laststop > 0 ) + if( text[i] == 13 || text[i] == 10) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; + height += lineh ; + laststop = i+1 ; } - - - m_rect.left = m_position.x + kTipOffset; - m_rect.top = m_position.y + kTipOffset; - m_rect.right = m_rect.left + width + 2 * kTipBorder; -#if TARGET_CARBON - if ( useDrawThemeText ) - m_rect.right += kTipBorder ; -#endif - m_rect.bottom = m_rect.top + height + 2 * kTipBorder; - Rect r ; - GetPortBounds( GetWindowPort( m_window ) , &r ) ; - if ( m_rect.top < 0 ) - { - m_rect.bottom += -m_rect.top ; - m_rect.top = 0 ; - } - if ( m_rect.left < 0 ) - { - m_rect.right += -m_rect.left ; - m_rect.left = 0 ; - } - if ( m_rect.right > r.right ) - { - m_rect.left -= (m_rect.right - r.right ) ; - m_rect.right = r.right ; - } - if ( m_rect.bottom > r.bottom ) - { - m_rect.top -= (m_rect.bottom - r.bottom) ; - m_rect.bottom = r.bottom ; - } - ClipRect( &m_rect ) ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - GWorldPtr port ; - NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - SetGWorld( port , NULL ) ; - - m_backpict = OpenPicture(&m_rect); - - CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), - GetPortBitMapForCopyBits(port), - &m_rect, - &m_rect, - srcCopy, - NULL); - ClosePicture(); - SetGWorld( origPort , origDevice ) ; - DisposeGWorld( port ) ; - PenNormal() ; - - RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; - BackColor( whiteColor ) ; - RGBForeColor( &tooltipbackground ) ; - - PaintRect( &m_rect ) ; - ForeColor(blackColor ) ; - FrameRect( &m_rect ) ; - SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); - - i = 0 ; - laststop = 0 ; - height = 0 ; - - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { -#if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - height += lineh ; - } - else -#endif - { - ::DrawText( text , laststop , i - laststop ) ; - height += lineh ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); - } - laststop = i+1 ; - } - i++ ; - } -#if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else -#endif + i++ ; + } + if ( i - laststop > 0 ) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + height += lineh ; + } + + m_rect.left = m_position.x + kTipOffset; + m_rect.top = m_position.y + kTipOffset; + m_rect.right = m_rect.left + width + 2 * kTipBorder; + + m_rect.bottom = m_rect.top + height + 2 * kTipBorder; + Rect r ; + GetPortBounds( GetWindowPort( m_window ) , &r ) ; + if ( m_rect.top < 0 ) + { + m_rect.bottom += -m_rect.top ; + m_rect.top = 0 ; + } + if ( m_rect.left < 0 ) + { + m_rect.right += -m_rect.left ; + m_rect.left = 0 ; + } + if ( m_rect.right > r.right ) + { + m_rect.left -= (m_rect.right - r.right ) ; + m_rect.right = r.right ; + } + if ( m_rect.bottom > r.bottom ) + { + m_rect.top -= (m_rect.bottom - r.bottom) ; + m_rect.bottom = r.bottom ; + } + ClipRect( &m_rect ) ; + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + GWorldPtr port ; + NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( port , NULL ) ; + + m_backpict = OpenPicture(&m_rect); + + CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), + GetPortBitMapForCopyBits(port), + &m_rect, + &m_rect, + srcCopy, + NULL); + ClosePicture(); + SetGWorld( origPort , origDevice ) ; + DisposeGWorld( port ) ; + PenNormal() ; + + RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; + BackColor( whiteColor ) ; + RGBForeColor( &tooltipbackground ) ; + + PaintRect( &m_rect ) ; + ForeColor(blackColor ) ; + FrameRect( &m_rect ) ; + SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); + + i = 0 ; + laststop = 0 ; + height = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) { ::DrawText( text , laststop , i - laststop ) ; + height += lineh ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); + laststop = i+1 ; } - ::TextMode( srcOr ) ; - } + i++ ; + } + ::DrawText( text , laststop , i - laststop ) ; + ::TextMode( srcOr ) ; +#endif } } @@ -454,11 +388,7 @@ void wxMacToolTip::Clear() return ; #if TARGET_CARBON HMHideTag() ; - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } + m_helpTextRef.Release() ; #else if ( m_window == s_ToolTipWindowRef && m_backpict ) { diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 69708ed1a3..2f4de7a5eb 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -362,7 +362,7 @@ void wxAssociateWinWithMacWindow(WXWindow inWindowRef, wxTopLevelWindowMac *win) { // adding NULL WindowRef is (first) surely a result of an error and // (secondly) breaks menu command processing - wxCHECK_RET( inWindowRef != (WindowRef) NULL, "attempt to add a NULL WindowRef to window list" ); + wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); if ( !wxWinMacWindowList->Find((long)inWindowRef) ) wxWinMacWindowList->Append((long)inWindowRef, win); @@ -592,12 +592,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; wxAssociateWinWithMacWindow( m_macWindow , this ) ; - wxString label ; - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( title ) ; - else - label = title ; - UMASetWTitleC( (WindowRef)m_macWindow , label ) ; + UMASetWTitle( (WindowRef)m_macWindow , title ) ; ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ; #if TARGET_CARBON InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; @@ -836,15 +831,7 @@ void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev ) void wxTopLevelWindowMac::SetTitle(const wxString& title) { wxWindow::SetTitle( title ) ; - - wxString label ; - - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( m_label ) ; - else - label = m_label ; - - UMASetWTitleC( (WindowRef)m_macWindow , label ) ; + UMASetWTitle( (WindowRef)m_macWindow , title ) ; } bool wxTopLevelWindowMac::Show(bool show) diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 59daa769db..9ec67e6f54 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -189,10 +189,8 @@ MenuRef UMANewMenu( SInt16 id , const wxString& title ) wxString str = wxStripMenuCodes( title ) ; MenuRef menu ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; CreateNewMenu( id , 0 , &menu ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -205,9 +203,7 @@ void UMASetMenuTitle( MenuRef menu , const wxString& title ) { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -219,9 +215,7 @@ void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& tit { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuItemTextWithCFString( menu , item , cfs ) ; - CFRelease( cfs ) ; + SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -558,17 +552,15 @@ void UMADisposeWindow( WindowRef inWindowRef ) DisposeWindow( inWindowRef ) ; } -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) +void UMASetWTitle( WindowRef inWindowRef , const wxString& title ) { - Str255 ptitle ; - strncpy( (char*)ptitle , title , 96 ) ; - ptitle[96] = 0 ; #if TARGET_CARBON - c2pstrcpy( ptitle, (char *)ptitle ) ; + SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title) ) ; #else - c2pstr( (char*)ptitle ) ; -#endif + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; SetWTitle( inWindowRef , ptitle ) ; +#endif } void UMAGetWTitleC( WindowRef inWindowRef , char *title ) @@ -583,6 +575,17 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) // appearance additions +void UMASetControlTitle( ControlHandle inControl , const wxString& title ) +{ +#if TARGET_CARBON + SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title) ) ; +#else + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; + SetControlTitle( inControl , ptitle ) ; +#endif +} + void UMAActivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn @@ -795,7 +798,7 @@ void wxMacPortStateHelper::Setup( GrafPtr newport ) { GetPort( &m_oldPort ) ; SetPort( newport ) ; - wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; + wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ; m_clip = NewRgn() ; GetClip( m_clip ); m_textFont = GetPortTextFont( (CGrafPtr) newport); diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 3897dadd57..014225901c 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -38,6 +38,10 @@ #include #endif +#include "ATSUnicode.h" +#include "TextCommon.h" +#include "TextEncodingConverter.h" + #ifndef __DARWIN__ // defined in unix/utilsunx.cpp for Mac OS X @@ -48,7 +52,7 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) } // Get hostname only (without domain name) -bool wxGetHostName(char *buf, int maxSize) +bool wxGetHostName(wxChar *buf, int maxSize) { // Gets Chooser name of user by examining a System resource. @@ -61,13 +65,11 @@ bool wxGetHostName(char *buf, int maxSize) if (chooserName && *chooserName) { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; + HLock( (Handle) chooserName ) ; + wxString name = wxMacMakeStringFromPascal( *chooserName ) ; + HUnlock( (Handle) chooserName ) ; + ReleaseResource( (Handle) chooserName ) ; + wxStrncpy( buf , name , maxSize - 1 ) ; } else buf[0] = 0 ; @@ -76,7 +78,7 @@ bool wxGetHostName(char *buf, int maxSize) } // Get user ID e.g. jacs -bool wxGetUserId(char *buf, int maxSize) +bool wxGetUserId(wxChar *buf, int maxSize) { return wxGetUserName( buf , maxSize ) ; } @@ -88,7 +90,7 @@ const wxChar* wxGetHomeDir(wxString *pstr) } // Get user name e.g. Stefan Csomor -bool wxGetUserName(char *buf, int maxSize) +bool wxGetUserName(wxChar *buf, int maxSize) { // Gets Chooser name of user by examining a System resource. @@ -101,13 +103,11 @@ bool wxGetUserName(char *buf, int maxSize) if (chooserName && *chooserName) { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; + HLock( (Handle) chooserName ) ; + wxString name = wxMacMakeStringFromPascal( *chooserName ) ; + HUnlock( (Handle) chooserName ) ; + ReleaseResource( (Handle) chooserName ) ; + wxStrncpy( buf , name , maxSize - 1 ) ; } else buf[0] = 0 ; @@ -250,22 +250,25 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) { - char buf[50]; - sprintf(buf, "%.4f", value); + wxString buf; + buf.Printf(wxT("%.4f"), value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) { - char buf[50]; - sprintf(buf, "%ld", value); + wxString buf; + buf.Printf(wxT("%ld"), value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) { - char buf[50]; - sprintf(buf, "%d", value); + wxString buf; + buf.Printf(wxT("%d"), value); + return wxWriteResource(section, entry, buf, file); } @@ -369,7 +372,7 @@ wxString wxMacFindFolder( short vol, } #ifndef __DARWIN__ -char *wxGetUserHome (const wxString& user) +wxChar *wxGetUserHome (const wxString& user) { // TODO return NULL; @@ -390,7 +393,7 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) p = p.Mid(1,pos) ; } - p = p + ":" ; + p = p + wxT(":") ; Str255 volumeName ; XVolumeParam pb ; @@ -501,7 +504,7 @@ wxString wxGetOsDescription() // use configure generated description if available return wxString("MacOS (") + WXWIN_OS_DESCRIPTION + wxString(")"); #else - return "MacOS" ; //TODO:define further + return wxT("MacOS") ; //TODO:define further #endif } @@ -593,10 +596,185 @@ void wxMacConvertToPC( const char *from , char *to , int len ) } } -wxString wxMacMakeMacStringFromPC( const char * p ) +TECObjectRef s_TECNativeCToUnicode = NULL ; +TECObjectRef s_TECUnicodeToNativeC = NULL ; +TECObjectRef s_TECPCToNativeC = NULL ; +TECObjectRef s_TECNativeCToPC = NULL ; +void wxMacSetupConverters() { + // 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 setup... + + OSStatus status = noErr ; + status = TECCreateConverter(&s_TECNativeCToUnicode, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + + + status = TECCreateConverter(&s_TECUnicodeToNativeC, + kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + + if ( !wxApp::s_macDefaultEncodingIsPC ) + { + status = TECCreateConverter(&s_TECPCToNativeC, + kTextEncodingWindowsLatin1, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + + + status = TECCreateConverter(&s_TECNativeCToPC, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingWindowsLatin1 ); + } +} + +void wxMacCleanupConverters() +{ + OSStatus status = noErr ; + status = TECDisposeConverter(s_TECNativeCToUnicode); + + status = TECDisposeConverter(s_TECUnicodeToNativeC); + + status = TECDisposeConverter(s_TECPCToNativeC); + + status = TECDisposeConverter(s_TECNativeCToPC); +} + +wxWCharBuffer wxMacStringToWString( const wxString &from ) +{ +#if wxUSE_UNICODE + wxWCharBuffer result( from.wc_str() ) ; +#else + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = from.Length() ; + ByteCount byteBufferLen = byteInLen *2 ; + wxWCharBuffer result( from.Length() ) ; + status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + result.data()[byteOutLen/2] = 0 ; +#endif + return result ; +} + +wxString wxMacMakeStringFromCString( const char * from , int len ) +{ + OSStatus status = noErr ; wxString result ; - int len = strlen ( p ) ; + wxChar* buf = result.GetWriteBuf( len ) ; +#if wxUSE_UNICODE + ByteCount byteOutLen ; + ByteCount byteInLen = len ; + ByteCount byteBufferLen = len *2 ; + + status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); +#else + if ( wxApp::s_macDefaultEncodingIsPC ) + memcpy( buf , from , len ) ; + else + { + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = len ; + ByteCount byteBufferLen = byteInLen ; + + status = TECConvertText(s_TECNativeCToPC, (ConstTextPtr)from , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); + } +#endif + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} + +wxString wxMacMakeStringFromCString( const char * from ) +{ + return wxMacMakeStringFromCString( from , strlen(from) ) ; +} + +wxCharBuffer wxMacStringToCString( const wxString &from ) +{ +#if wxUSE_UNICODE + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = from.Length() * 2 ; + ByteCount byteBufferLen = from.Length() ; + wxCharBuffer result( from.Length() ) ; + status = TECConvertText(s_TECUnicodeToNativeC , (ConstTextPtr)from.wc_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + return result ; +#else + if ( wxApp::s_macDefaultEncodingIsPC ) + 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_TECPCToNativeC, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + return result ; + } +#endif +} + +void wxMacStringToPascal( const wxString&from , StringPtr to ) +{ + wxCharBuffer buf = wxMacStringToCString( from ) ; + int len = strlen(buf) ; + + if ( len > 255 ) + len = 255 ; + to[0] = len ; + memcpy( (char*) &to[1] , buf , len ) ; +} + +wxString wxMacMakeStringFromPascal( ConstStringPtr from ) +{ + return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; +} + +// +// CFStringRefs (Carbon only) +// + +#if TARGET_CARBON +// converts this string into a carbon foundation string with optional pc 2 mac encoding +void wxMacCFStringHolder::Assign( const wxString &str ) +{ +#if wxUSE_UNICODE + m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, + (const unsigned short*)str.wc_str(), str.Len() ); +#else + m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; +#endif + m_release = true ; +} + +wxString wxMacCFStringHolder::AsString() +{ + wxString result ; + Size len = CFStringGetLength( m_cfs ) ; + wxChar* buf = result.GetWriteBuf( len ) ; +#if wxUSE_UNICODE + CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; +#else + CFStringGetCString( m_cfs , buf , len+1 , s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; +#endif + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} + +#if 0 + +wxString wxMacMakeMacStringFromPC( const wxChar * p ) +{ + wxString result ; + int len = wxStrlen ( p ) ; if ( len > 0 ) { wxChar* ptr = result.GetWriteBuf(len) ; @@ -607,10 +785,10 @@ wxString wxMacMakeMacStringFromPC( const char * p ) return result ; } -wxString wxMacMakePCStringFromMac( const char * p ) +wxString wxMacMakePCStringFromMac( const wxChar * p ) { wxString result ; - int len = strlen ( p ) ; + int len = wxStrlen ( p ) ; if ( len > 0 ) { wxChar* ptr = result.GetWriteBuf(len) ; @@ -621,7 +799,7 @@ wxString wxMacMakePCStringFromMac( const char * p ) return result ; } -wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) +wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) { if (mac2pcEncoding) { @@ -652,7 +830,7 @@ wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) } } -void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) +void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) { if (pc2macEncoding) { @@ -663,19 +841,8 @@ void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding CopyCStringToPascal( from , to ) ; } } +#endif -// -// CFStringRefs (Carbon only) -// - -#if TARGET_CARBON -// converts this string into a carbon foundation string with optional pc 2 mac encoding -CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) -{ - return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - pc2macEncoding ? - kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; -} #endif //TARGET_CARBON diff --git a/src/mac/carbon/wave.cpp b/src/mac/carbon/wave.cpp index 0c5aac8bfc..35accb9167 100644 --- a/src/mac/carbon/wave.cpp +++ b/src/mac/carbon/wave.cpp @@ -135,23 +135,18 @@ bool wxWave::Create(const wxString& fileName, bool isResource) //don't know what to do with looped, wth bool wxWave::Play(bool async, bool looped) const { - char lpSnd[32]; bool ret = false; if (m_isResource) { -#if TARGET_CARBON - c2pstrcpy((unsigned char *)lpSnd, m_sndname); -#else - strcpy(lpSnd, m_sndname); - c2pstr((char *) lpSnd); -#endif - SndListHandle hSnd; + Str255 snd ; + wxMacStringToPascal( m_sndname , snd ) ; + SndListHandle hSnd; - hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); + hSnd = (SndListHandle) GetNamedResource('snd ', snd); - if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) - ret = true; + if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) + ret = true; } return ret; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 156527a083..9f7a20f4e7 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1642,7 +1642,7 @@ wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) { return m_tooltip->GetTip() ; } - return "" ; + return wxEmptyString ; } void wxWindowMac::Update() @@ -1855,13 +1855,13 @@ WXHWND wxWindowMac::MacGetRootWindow() const iter = iter->GetParent() ; } - wxASSERT_MSG( 1 , "No valid mac root window" ) ; + wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; return NULL ; } void wxWindowMac::MacCreateScrollBars( long style ) { - wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; + wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; diff --git a/src/mac/checklst.cpp b/src/mac/checklst.cpp index c50773b137..d987d94994 100644 --- a/src/mac/checklst.cpp +++ b/src/mac/checklst.cpp @@ -211,7 +211,7 @@ bool wxCheckListBox::Create(wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 863b944cb4..19f8e405d2 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -49,7 +49,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; @@ -169,7 +169,7 @@ wxString wxChoice::GetString(int n) const void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(), - "invalid index in wxChoice::SetClientData" ); + wxT("invalid index in wxChoice::SetClientData") ); m_datas[n] = (char*) clientData ; } @@ -177,7 +177,7 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) void *wxChoice::DoGetItemClientData(int n) const { wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL, - "invalid index in wxChoice::GetClientData" ); + wxT("invalid index in wxChoice::GetClientData") ); return (void *)m_datas[n]; } diff --git a/src/mac/clipbrd.cpp b/src/mac/clipbrd.cpp index 47a2b428f9..942a17c6fb 100644 --- a/src/mac/clipbrd.cpp +++ b/src/mac/clipbrd.cpp @@ -55,6 +55,8 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) case wxDF_TEXT: break; + case wxDF_UNICODETEXT: + break; case wxDF_BITMAP : case wxDF_METAFILE : break ; @@ -77,15 +79,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) { if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr) { - if ( dataFormat.GetType() == wxDF_TEXT ) - byteCount++ ; + Size allocSize = byteCount ; + if ( dataFormat.GetType() == wxDF_TEXT ) + allocSize += 1 ; + else if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + allocSize += 2 ; - data = new char[ byteCount ] ; + data = new char[ allocSize ] ; + if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) { - *len = byteCount ; + *len = allocSize ; if ( dataFormat.GetType() == wxDF_TEXT ) ((char*)data)[byteCount] = 0 ; + if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + ((wxChar*)data)[byteCount/2] = 0 ; } else { @@ -105,14 +113,19 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) if ( GetHandleSize( datahandle ) > 0 ) { byteCount = GetHandleSize( datahandle ) ; + Size allocSize = byteCount ; if ( dataFormat.GetType() == wxDF_TEXT ) - data = new char[ byteCount + 1] ; - else - data = new char[ byteCount ] ; - + allocSize += 1 ; + else if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + allocSize += 2 ; + + data = new char[ allocSize ] ; + memcpy( (char*) data , (char*) *datahandle , byteCount ) ; if ( dataFormat.GetType() == wxDF_TEXT ) ((char*)data)[byteCount] = 0 ; + if ( dataFormat.GetType() == wxDF_UNICODETEXT ) + ((wxChar*)data)[byteCount/2] = 0 ; *len = byteCount ; } DisposeHandle( datahandle ) ; @@ -123,10 +136,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) return NULL ; } + if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)data,(char*)data,byteCount) ; + wxString st = wxMacMakeStringFromCString( (char*) data ) ; +#if wxUSE_UNICODE + wxCharBuffer buf = st.ToAscii() ; +#else + char* buf = st ; +#endif + char* newdata = new char[strlen(buf)+1] ; + memcpy( newdata , buf , strlen(buf)+1 ) ; + delete[] ((char*) data ) ; + data = newdata ; } + return data; } @@ -234,19 +258,19 @@ bool wxClipboard::AddData( wxDataObject *data ) { wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxString str(textDataObject->GetText()); - wxString mac ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - mac = wxMacMakeMacStringFromPC(textDataObject->GetText()) ; - } - else - { - mac = textDataObject->GetText() ; - } - err = UMAPutScrap( mac.Length() , 'TEXT' , (void*) mac.c_str() ) ; + wxCharBuffer buf = wxMacStringToCString( str ) ; + err = UMAPutScrap( strlen(buf) , kScrapFlavorTypeText , (void*) buf.data() ) ; } break ; - +#if wxUSE_UNICODE + case wxDF_UNICODETEXT : + { + wxTextDataObject* textDataObject = (wxTextDataObject*) data; + wxString str(textDataObject->GetText()); + err = UMAPutScrap( str.Length() * sizeof(wxChar) , kScrapFlavorTypeUnicode , (void*) str.wc_str() ) ; + } + break ; +#endif #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { @@ -255,7 +279,7 @@ bool wxClipboard::AddData( wxDataObject *data ) wxMetafile metaFile = metaFileDataObject->GetMetafile(); PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , kScrapFlavorTypePicture , *pict ) ; HUnlock( (Handle) pict ) ; } break ; @@ -270,7 +294,7 @@ bool wxClipboard::AddData( wxDataObject *data ) pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , kScrapFlavorTypePicture , *pict ) ; HUnlock( (Handle) pict ) ; if ( created ) KillPicture( pict ) ; diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index 7d2a6819ea..8ffecd0489 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -456,7 +456,7 @@ wxString wxComboBox::GetStringSelection() const if (sel > -1) return wxString(this->GetString (sel)); else - return wxString(""); + return wxEmptyString; } bool wxComboBox::SetStringSelection(const wxString& sel) diff --git a/src/mac/control.cpp b/src/mac/control.cpp index e12f3f63da..f0dc6ee7a4 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -208,23 +208,9 @@ void wxControl::SetLabel(const wxString& title) { m_label = wxStripMenuCodes(title) ; - if ( (ControlHandle) m_macControl ) + if ( m_macControl ) { - Str255 maclabel ; - wxString label ; - - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( m_label ) ; - else - label = m_label ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) maclabel , label ) ; -#else - strcpy( (char *) maclabel , label ) ; - c2pstr( (char *) maclabel ) ; -#endif - ::SetControlTitle( (ControlHandle) m_macControl , maclabel ) ; + UMASetControlTitle( (ControlHandle) m_macControl , m_label ) ; } Refresh() ; } @@ -311,7 +297,7 @@ void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *contro { // adding NULL WindowRef is (first) surely a result of an error and // (secondly) breaks menu command processing - wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" ); + wxCHECK_RET( inControl != (ControlHandle) NULL, wxT("attempt to add a NULL WindowRef to window list") ); if ( !wxWinMacControlList->Find((long)inControl) ) wxWinMacControlList->Append((long)inControl, control); @@ -361,7 +347,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l void wxControl::MacPostControlCreate() { - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) { @@ -438,6 +424,10 @@ void wxControl::MacPostControlCreate() SetSize(pos.x, pos.y, new_size.x, new_size.y); +#if wxUSE_UNICODE + UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) ) ; +#endif + UMAShowControl( (ControlHandle) m_macControl ) ; SetCursor( *wxSTANDARD_CURSOR ) ; @@ -907,6 +897,6 @@ bool wxControl::MacCanFocus() const void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; } diff --git a/src/mac/cursor.cpp b/src/mac/cursor.cpp index d698913890..1200fb9c69 100644 --- a/src/mac/cursor.cpp +++ b/src/mac/cursor.cpp @@ -292,13 +292,7 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) { Str255 theName ; - - #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , cursor_file ) ; - #else - strcpy( (char *) theName , cursor_file ) ; - c2pstr( (char *) theName ) ; - #endif + wxMacStringToPascal( cursor_file , theName ) ; wxStAppResource resload ; Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; diff --git a/src/mac/dataobj.cpp b/src/mac/dataobj.cpp index c1a443a7e5..5949c6300b 100644 --- a/src/mac/dataobj.cpp +++ b/src/mac/dataobj.cpp @@ -1,11 +1,11 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: os2/dataobj.cpp -// Purpose: implementation of wx[I]DataObject class -// Author: David Webster +// Name: mac/dataobj.cpp +// Purpose: implementation of wxDataObject class +// Author: Stefan Csomor // Modified by: // Created: 10/21/99 // RCS-ID: $Id$ -// Copyright: (c) 1999 David Webster +// Copyright: (c) 1999 Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -34,6 +34,7 @@ #include "wx/mstream.h" #include "wx/image.h" #include "wx/mac/private.h" +#include "Scrap.h" // ---------------------------------------------------------------------------- // functions @@ -73,10 +74,12 @@ void wxDataFormat::SetType( wxDataFormatId Type ) { m_type = Type; - if (m_type == wxDF_TEXT) - m_format = 'TEXT'; + if (m_type == wxDF_TEXT ) + m_format = kScrapFlavorTypeText; + else if (m_type == wxDF_UNICODETEXT ) + m_format = kScrapFlavorTypeUnicode ; else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE ) - m_format = 'PICT'; + m_format = kScrapFlavorTypePicture; else if (m_type == wxDF_FILENAME) m_format = kDragFlavorTypeHFS ; else @@ -92,18 +95,23 @@ wxDataFormatId wxDataFormat::GetType() const wxString wxDataFormat::GetId() const { - wxString sRet(""); // TODO: to name of ( m_format ) ); - return sRet; + char text[5] ; + strncpy( text , (char*) m_format , 4 ) ; + text[4] = 0 ; + return wxString::FromAscii( text ) ; } void wxDataFormat::SetId( NativeFormat format ) { m_format = format; - if (m_format == 'TEXT') + if (m_format == kScrapFlavorTypeText) m_type = wxDF_TEXT; else - if (m_format == 'PICT') + if (m_format == kScrapFlavorTypeUnicode ) + m_type = wxDF_UNICODETEXT; + else + if (m_format == kScrapFlavorTypePicture) m_type = wxDF_BITMAP; else if (m_format == kDragFlavorTypeHFS ) @@ -201,9 +209,7 @@ bool wxFileDataObject::SetData( { m_filenames.Empty(); - wxString sFile( (const char *)pBuf); /* char, not wxChar */ - - AddFile(sFile); + AddFile(wxString::FromAscii((char*)pBuf)); return TRUE; } diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index ed0648f9dc..9bcf525f26 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -1111,7 +1111,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, } if ( mode == kUnsupportedMode ) { - wxFAIL_MSG("unsupported blitting mode" ); + wxFAIL_MSG(wxT("unsupported blitting mode" )); return FALSE ; } CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; @@ -1295,17 +1295,10 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, } if ( str.Length() == 0 ) return ; + wxMacPortSetter helper(this) ; MacInstallFont() ; - wxString text ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - text = wxMacMakeMacStringFromPC( str ) ; - } - else - { - text = str ; - } + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { @@ -1314,23 +1307,30 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, m_macAliasWasEnabled = true ; } OSStatus status = noErr ; + ATSUTextLayout atsuLayout ; + UniCharCount chars = str.Length() ; +#if wxUSE_UNICODE + status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 , + &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; +#else TECObjectRef ec; - status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); - wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; + status = TECCreateConverter(&ec, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + + wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ; ByteCount byteOutLen ; - ByteCount byteInLen = text.Length() ; + ByteCount byteInLen = str.Length() ; ByteCount byteBufferLen = byteInLen *2 ; char* buf = new char[byteBufferLen] ; - status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, + status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen, (TextPtr)buf, byteBufferLen, &byteOutLen); - wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ; status = TECDisposeConverter(ec); - wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; - ATSUTextLayout atsuLayout ; - UniCharCount chars = byteOutLen / 2 ; + wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ; status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; - wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); +#endif + wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); int iAngle = int( angle ); int drawX = XLOG2DEVMAC(x) ; int drawY = YLOG2DEVMAC(y) ; @@ -1366,16 +1366,19 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) ); - wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); + wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); Rect rect ; status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) , &rect ); - wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); + wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); ::ATSUDisposeTextLayout(atsuLayout); +#if wxUSE_UNICODE +#else delete[] buf ; +#endif } void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) @@ -1411,33 +1414,22 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { ::TextMode( srcCopy ) ; } - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( strtext ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = strtext ; - length = strtext.Length() ; - } + int length = strtext.Length() ; + int laststop = 0 ; int i = 0 ; int line = 0 ; { while( i < length ) { - if( text[i] == 13 || text[i] == 10) + if( strtext[i] == 13 || strtext[i] == 10) { + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; if ( m_backgroundMode != wxTRANSPARENT ) { Point bounds={0,0} ; @@ -1460,13 +1452,13 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) &frame, teJustLeft, nil ); - CFRelease( mString ) ; line++ ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + ::DrawText( text , 0 , strlen(text) ) ; line++ ; ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); } @@ -1474,11 +1466,12 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) } i++ ; } + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + wxMacCFStringHolder mString( linetext ) ; if ( m_backgroundMode != wxTRANSPARENT ) { @@ -1502,13 +1495,13 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) &frame, teJustLeft, nil ); - CFRelease( mString ) ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; - } + wxCharBuffer text = wxMacStringToCString(linetext) ; + ::DrawText( text , 0 , strlen(text) ) ; + } } ::TextMode( srcOr ) ; } @@ -1519,7 +1512,7 @@ bool wxDC::CanGetTextExtent() const return true ; } -void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, +void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading , wxFont *theFont ) const { @@ -1545,8 +1538,9 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he *descent =YDEV2LOGREL( fi.descent ); if ( externalLeading ) *externalLeading = YDEV2LOGREL( fi.leading ) ; + int length = strtext.Length() ; + /* const char *text = NULL ; - int length = 0 ; wxString macText ; if ( wxApp::s_macDefaultEncodingIsPC ) { @@ -1559,6 +1553,7 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he text = string ; length = string.Length() ; } + */ int laststop = 0 ; int i = 0 ; int curwidth = 0 ; @@ -1567,8 +1562,9 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he *width = 0 ; while( i < length ) { - if( text[i] == 13 || text[i] == 10) + if( strtext[i] == 13 || strtext[i] == 10) { + wxString linetext = strtext.Mid( laststop , i - laststop ) ; if ( height ) *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; #if TARGET_CARBON @@ -1576,20 +1572,20 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he { Point bounds={0,0} ; SInt16 baseline ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); - CFRelease( mString ) ; curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + curwidth = ::TextWidth( text , 0 , strlen(text) ) ; } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; @@ -1598,25 +1594,26 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he i++ ; } + wxString linetext = strtext.Mid( laststop , i - laststop ) ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + wxMacCFStringHolder mString( linetext ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); - CFRelease( mString ) ; curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + wxCharBuffer text = wxMacStringToCString(linetext) ; + curwidth = ::TextWidth( text , 0 , strlen(text) ) ; } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; @@ -1773,7 +1770,7 @@ void wxDC::MacInstallFont() const Style qdStyle = font->m_macFontStyle ; ATSUFontID atsuFont = font->m_macATSUFontID ; status = ::ATSUCreateStyle(&(ATSUStyle)m_macATSUIStyle) ; - wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; ATSUAttributeTag atsuTags[] = { kATSUFontTag , @@ -1819,7 +1816,7 @@ void wxDC::MacInstallFont() const } ; status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), atsuTags, atsuSizes, atsuValues); - wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; } Pattern gHatchPatterns[] = diff --git a/src/mac/dcprint.cpp b/src/mac/dcprint.cpp index 82bdecd0cf..a841324bd3 100644 --- a/src/mac/dcprint.cpp +++ b/src/mac/dcprint.cpp @@ -62,8 +62,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) if ( err != noErr ) #endif { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease( m_macPrintSessionPort ) ; @@ -88,8 +88,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); UMAPrClose(NULL) ; m_ok = FALSE; @@ -150,8 +150,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -234,8 +234,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) err = PrError() ; if ( err ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); UMAPrClose(NULL) ; m_ok = FALSE; @@ -258,8 +258,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) if ( err != noErr || m_macPrintSessionPort == kPMNoReference ) #endif { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -280,8 +280,8 @@ bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS PMRelease(&m_macPrintSessionPort) ; @@ -321,8 +321,8 @@ void wxPrinterDC::EndDoc(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } } @@ -363,8 +363,8 @@ void wxPrinterDC::StartPage(void) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; @@ -382,8 +382,8 @@ void wxPrinterDC::StartPage(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); @@ -421,8 +421,8 @@ void wxPrinterDC::EndPage(void) err = PrError() ; if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld") , err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; ::UMAPrClose(NULL) ; @@ -437,8 +437,8 @@ void wxPrinterDC::EndPage(void) #endif if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %ld"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); diff --git a/src/mac/dirdlg.cpp b/src/mac/dirdlg.cpp index 6864054234..0b4c7df195 100644 --- a/src/mac/dirdlg.cpp +++ b/src/mac/dirdlg.cpp @@ -40,7 +40,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; m_message = message; m_dialogStyle = style; m_parent = parent; @@ -92,7 +92,7 @@ int wxDirDialog::ShowModal() 0L); // User Data if ( (err != noErr) && (err != userCanceledErr) ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } @@ -104,7 +104,7 @@ int wxDirDialog::ShowModal() OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } folderInfo = **(FSSpec**) specDesc.dataHandle; @@ -130,7 +130,7 @@ int wxDirDialog::ShowModal() err = ::PBGetCatInfoSync(&thePB); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } // Create cannonical FSSpec diff --git a/src/mac/dirmac.cpp b/src/mac/dirmac.cpp index 9ea9415df4..ff168bafdc 100644 --- a/src/mac/dirmac.cpp +++ b/src/mac/dirmac.cpp @@ -133,7 +133,7 @@ wxDirData::wxDirData(const wxString& dirname) err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; #endif - wxASSERT_MSG( (err == noErr) || (err == nsvErr) , "Error accessing directory " + m_dirname) ; + wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ; m_CPB.hFileInfo.ioNamePtr = m_name ; m_index = 0 ; @@ -153,9 +153,6 @@ bool wxDirData::Read(wxString *filename) if ( !m_isDir ) return FALSE ; -#if TARGET_CARBON - char c_name[256] ; -#endif wxString result; short err = noErr ; @@ -169,18 +166,12 @@ bool wxDirData::Read(wxString *filename) if ( err != noErr ) break ; -#if TARGET_CARBON - p2cstrcpy( c_name, m_name ) ; - strcpy( (char *)m_name, c_name); -#else - p2cstr( m_name ) ; -#endif // its hidden but we don't want it if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) continue ; #ifdef __DARWIN__ // under X, names that start with '.' are hidden - if ( ( m_name[0] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) + if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) ) continue; #endif #if TARGET_CARBON @@ -196,18 +187,18 @@ bool wxDirData::Read(wxString *filename) if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) continue ; - wxString file( m_name ) ; - if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" ) + wxString file = wxMacMakeStringFromPascal( m_name ) ; + if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") ) { } - else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") ) { if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() ) { continue ; } } - else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" ) + else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") ) { if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() ) { @@ -226,7 +217,7 @@ bool wxDirData::Read(wxString *filename) return FALSE ; } - *filename = (char*) m_name ; + *filename = wxMacMakeStringFromPascal( m_name ) ; return TRUE; } diff --git a/src/mac/dnd.cpp b/src/mac/dnd.cpp index 2ea8ae7c90..d4eb35abba 100644 --- a/src/mac/dnd.cpp +++ b/src/mac/dnd.cpp @@ -205,12 +205,9 @@ bool wxDropTarget::GetData() GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); if( theType == 'TEXT' ) { - theData[dataSize]=0 ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; - } - m_dataObject->SetData( format, dataSize, theData ); + theData[dataSize]=0 ; + wxString convert = wxMacMakeStringFromCString( theData ) ; + m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert ); } else if ( theType == kDragFlavorTypeHFS ) { @@ -303,11 +300,10 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) if ( type == 'TEXT' ) { dataSize-- ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; - } - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + dataPtr[ dataSize ] = 0 ; + wxString st( (wxChar*) dataPtr ) ; + wxCharBuffer buf = wxMacStringToCString( st ) ; + AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0); } else if (type == kDragFlavorTypeHFS ) { diff --git a/src/mac/filedlg.cpp b/src/mac/filedlg.cpp index 5a65441f23..f2b6707baf 100644 --- a/src/mac/filedlg.cpp +++ b/src/mac/filedlg.cpp @@ -104,13 +104,12 @@ NavEventProc( Str255 filename ; // get the current filename NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); - CopyPascalStringToC( filename , (char*) filename ) ; - wxString sfilename( filename ) ; + wxString sfilename = wxMacMakeStringFromPascal( filename ) ; int pos = sfilename.Find('.',TRUE) ; if ( pos != wxNOT_FOUND ) { sfilename = sfilename.Left(pos+1)+extension ; - CopyCStringToPascal( sfilename.c_str() , filename ) ; + wxMacStringToPascal( sfilename , filename ) ; NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); } } @@ -118,11 +117,11 @@ NavEventProc( } } -const char * gfilters[] = +const wxChar * gfilters[] = { - "*.TXT" , - "*.TIF" , - "*.JPG" , + wxT("*.TXT") , + wxT("*.TIF") , + wxT("*.JPG") , NULL } ; @@ -162,7 +161,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) ++filterIndex ; } isName = !isName ; - current = "" ; + current = wxEmptyString ; } else { @@ -172,7 +171,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) // we allow for compatibility reason to have a single filter expression (like *.*) without // an explanatory text, in that case the first part is name and extension at the same time - wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; + wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; if ( current.IsEmpty() ) myData->extensions.Add( myData->name[filterIndex] ) ; else @@ -189,7 +188,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) int j ; for ( j = 0 ; gfilters[j] ; j++ ) { - if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) + if ( myData->extensions[i] == gfilters[j] ) { myData->filtermactypes.Add( gfiltersmac[j] ) ; break ; @@ -205,6 +204,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecPtr data) { +/* Str255 filename ; #if TARGET_CARBON @@ -214,20 +214,22 @@ static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecP p2cstr( filename ) ; #endif wxString file(filename) ; +*/ + wxString file = wxMacMakeStringFromPascal( name ) ; file.MakeUpper() ; if ( data->extensions.GetCount() > 0 ) { //for ( int i = 0 ; i < data->numfilters ; ++i ) int i = data->currentfilter ; - if ( data->extensions[i].Right(2) == ".*" ) + if ( data->extensions[i].Right(2) == wxT(".*") ) return true ; { if ( type == (OSType)data->filtermactypes[i] ) return true ; - wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; + wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ; while( tokenizer.HasMoreTokens() ) { wxString extension = tokenizer.GetNextToken() ; @@ -272,17 +274,17 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat // end wxmac -wxString wxFileSelector(const char *title, - const char *defaultDir, const char *defaultFileName, - const char *defaultExtension, const char *filter, int flags, +wxString wxFileSelector(const wxChar *title, + const wxChar *defaultDir, const wxChar *defaultFileName, + const wxChar *defaultExtension, const wxChar *filter, int flags, wxWindow *parent, int x, int y) { // If there's a default extension specified but no filter, we create a suitable // filter. - wxString filter2(""); + wxString filter2; if ( defaultExtension && !filter ) - filter2 = wxString("*.") + wxString(defaultExtension) ; + filter2 = wxString(wxT("*.")) + wxString(defaultExtension) ; else if ( filter ) filter2 = filter; @@ -290,13 +292,13 @@ wxString wxFileSelector(const char *title, if (defaultDir) defaultDirString = defaultDir; else - defaultDirString = ""; + defaultDirString = wxEmptyString ; wxString defaultFilenameString; if (defaultFileName) defaultFilenameString = defaultFileName; else - defaultFilenameString = ""; + defaultFilenameString = wxEmptyString; wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y)); @@ -308,19 +310,19 @@ wxString wxFileSelector(const char *title, return wxGetEmptyString(); } -WXDLLEXPORT wxString wxFileSelectorEx(const char *title, - const char *defaultDir, - const char *defaultFileName, +WXDLLEXPORT wxString wxFileSelectorEx(const wxChar *title, + const wxChar *defaultDir, + const wxChar *defaultFileName, int* defaultFilterIndex, - const char *filter, + const wxChar *filter, int flags, wxWindow* parent, int x, int y) { - wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "", - defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y)); + wxFileDialog fileDialog(parent, title ? title : wxT(""), defaultDir ? defaultDir : wxT(""), + defaultFileName ? defaultFileName : wxT(""), filter ? filter : wxT(""), flags, wxPoint(x, y)); if ( fileDialog.ShowModal() == wxID_OK ) { @@ -335,18 +337,17 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, long style, const wxPoint& pos) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; m_message = message; m_dialogStyle = style; m_parent = parent; - m_path = ""; + m_path = wxT(""); m_fileName = defaultFileName; m_dir = defaultDir; m_wildCard = wildCard; m_filterIndex = 0; } - pascal Boolean CrossPlatformFilterCallback ( AEDesc *theItem, void *info, @@ -417,19 +418,8 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; } } - -#if TARGET_CARBON - c2pstrcpy((StringPtr)mNavOptions.message, m_message) ; -#else - strcpy((char *)mNavOptions.message, m_message) ; - c2pstr((char *)mNavOptions.message ) ; -#endif -#if TARGET_CARBON - c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ; -#else - strcpy((char *)mNavOptions.savedFileName, m_fileName) ; - c2pstr((char *)mNavOptions.savedFileName ) ; -#endif + wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ; + wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ; // zero all data @@ -450,12 +440,7 @@ int wxFileDialog::ShowModal() (*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ; (*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ; (*mNavOptions.popupExtension)[i].menuType = i ; -#if TARGET_CARBON - c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ; -#else - strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ; - c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ; -#endif + wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ; } } if ( m_dialogStyle & wxSAVE ) @@ -519,7 +504,7 @@ int wxFileDialog::ShowModal() { OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc); if ( err != noErr ) { - m_path = "" ; + m_path = wxT("") ; return wxID_CANCEL ; } outFileSpec = **(FSSpec**) specDesc.dataHandle; @@ -543,28 +528,30 @@ int wxFileDialog::ShowModal() // Generic file load/save dialog static wxString -wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxDefaultFileSelector(bool load, const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { - char *ext = (char *)extension; - - char prompt[50]; + wxString prompt; + wxString str; if (load) - str = "Load %s file"; + str = wxT("Load %s file"); else - str = "Save %s file"; - sprintf(prompt, wxGetTranslation(str), what); + str = wxT("Save %s file"); + prompt.Printf( wxGetTranslation(str), what); - if (*ext == '.') ext++; - char wild[60]; - sprintf(wild, "*.%s", ext); + const wxChar *ext = extension; + if (*ext == wxT('.')) + ext++; + + wxString wild; + wild.Printf(wxT("*.%s"), ext); return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent); } // Generic file load dialog wxString -wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxLoadFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); } @@ -572,9 +559,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_ // Generic file save dialog wxString -wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent) { return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); } - - diff --git a/src/mac/font.cpp b/src/mac/font.cpp index e134003482..5ffa4f828b 100644 --- a/src/mac/font.cpp +++ b/src/mac/font.cpp @@ -67,7 +67,7 @@ wxFontRefData::~wxFontRefData() void wxFontRefData::MacFindFont() { - if( m_faceName == "" ) + if( m_faceName.Length() == 0 ) { switch( m_family ) { @@ -92,14 +92,13 @@ void wxFontRefData::MacFindFont() } Str255 name ; GetFontName( m_macFontNum , name ) ; - CopyPascalStringToC( name , (char*) name ) ; - m_faceName = (char*) name ; + m_faceName = wxMacMakeStringFromPascal( name ) ; } else { - if ( m_faceName == "systemfont" ) + if ( m_faceName == wxT("systemfont") ) m_macFontNum = ::GetSysFont() ; - else if ( m_faceName == "applicationfont" ) + else if ( m_faceName == wxT("applicationfont") ) m_macFontNum = ::GetAppFont() ; else { @@ -126,7 +125,7 @@ void wxFontRefData::MacFindFont() status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; */ - wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/gauge.cpp b/src/mac/gauge.cpp index 1a61e4f723..de7dd8c90c 100644 --- a/src/mac/gauge.cpp +++ b/src/mac/gauge.cpp @@ -40,7 +40,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, size = wxSize( 200 , 16 ) ; } - MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, kControlProgressBarProc , (long) this ) ; diff --git a/src/mac/glcanvas.cpp b/src/mac/glcanvas.cpp index aca2b5be13..e66592a619 100644 --- a/src/mac/glcanvas.cpp +++ b/src/mac/glcanvas.cpp @@ -91,7 +91,7 @@ void wxGLContext::Update() } } -void wxGLContext::SetColour(const char *colour) +void wxGLContext::SetColour(const wxChar *colour) { float r = 0.0; float g = 0.0; @@ -309,7 +309,7 @@ void wxGLCanvas::SetCurrent() } } -void wxGLCanvas::SetColour(const char *colour) +void wxGLCanvas::SetColour(const wxChar *colour) { if (m_glContext) m_glContext->SetColour(colour); diff --git a/src/mac/icon.cpp b/src/mac/icon.cpp index ef4526a670..bd1937bc2a 100644 --- a/src/mac/icon.cpp +++ b/src/mac/icon.cpp @@ -83,19 +83,19 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo int desiredWidth, int desiredHeight) { short theId = -1 ; - if ( name == "wxICON_INFORMATION" ) + if ( name == wxT("wxICON_INFORMATION") ) { theId = kNoteIcon ; } - else if ( name == "wxICON_QUESTION" ) + else if ( name == wxT("wxICON_QUESTION") ) { theId = kCautionIcon ; } - else if ( name == "wxICON_WARNING" ) + else if ( name == wxT("wxICON_WARNING") ) { theId = kCautionIcon ; } - else if ( name == "wxICON_ERROR" ) + else if ( name == wxT("wxICON_ERROR") ) { theId = kStopIcon ; } @@ -103,13 +103,7 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo { Str255 theName ; OSType theType ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; -#else - strcpy( (char *) theName , name ) ; - c2pstr( (char *) theName ) ; -#endif + wxMacStringToPascal( name , theName ) ; Handle resHandle = GetNamedResource( 'cicn' , theName ) ; if ( resHandle != 0L ) diff --git a/src/mac/joystick.cpp b/src/mac/joystick.cpp index 6a45f419fd..156b9b2657 100644 --- a/src/mac/joystick.cpp +++ b/src/mac/joystick.cpp @@ -113,7 +113,7 @@ int wxJoystick::GetProductId() const wxString wxJoystick::GetProductName() const { // TODO - return wxString(""); + return wxString(wxT("")); } int wxJoystick::GetXMin() const diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 2d7dff4fbc..12e2c048bb 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -94,7 +94,7 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect case lDrawMsg: { - const wxString text = list->m_stringArray[cell.v] ; + const wxString linetext = list->m_stringArray[cell.v] ; // Save the current clip region, and set the clip region to the area we are about // to draw. @@ -121,32 +121,27 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect } #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - - if ( useDrawThemeText ) - { - Rect frame = { drawRect->top, drawRect->left + 4, - drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; - CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ; - CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ; - CFRelease( sString ) ; - ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else -#endif - { + { + Rect frame = { drawRect->top, drawRect->left + 4, + drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; + CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext) ) ; + ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } +#else + { + wxCharBuffer text = wxMacStringToCString( linetext ) ; MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - DrawText(text, 0 , text.Length()); + DrawText(text, 0 , strlen(text) ); } - +#endif // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -213,7 +208,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; @@ -234,8 +229,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, fontSize = 9 ; fontStyle = normal ; #endif - CopyPascalStringToC( fontName , (char*) fontName ) ; - SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ; + SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ; #if TARGET_CARBON Size asize; @@ -388,15 +382,8 @@ void wxListBox::Delete(int N) int wxListBox::DoAppend(const wxString& item) { int index = m_noItems ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ; - m_dataArray.Add( NULL ); - } - else { - m_stringArray.Add( item ) ; - m_dataArray.Add( NULL ); - } + m_stringArray.Add( item ) ; + m_dataArray.Add( NULL ); m_noItems ++; DoSetItemClientData( index , NULL ) ; MacAppend( item ) ; @@ -451,47 +438,30 @@ bool wxListBox::HasMultipleSelection() const return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED); } -int wxListBox::FindString(const wxString& st) const +int wxListBox::FindString(const wxString& s) const { - wxString s ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - s = wxMacMakeMacStringFromPC( st ) ; - } - else - s = st ; - if ( s.Right(1) == "*" ) + if ( s.Right(1) == wxT("*") ) { wxString search = s.Left( s.Length() - 1 ) ; int len = search.Length() ; Str255 s1 , s2 ; - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s2 , search.c_str() ) ; -#else - strcpy( (char *) s2 , search.c_str() ) ; - c2pstr( (char *) s2 ) ; -#endif + wxMacStringToPascal( search , s2 ) ; for ( int i = 0 ; i < m_noItems ; ++ i ) { -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ; -#else - strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ; - c2pstr( (char *) s1 ) ; -#endif + wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ; + if ( EqualString( s1 , s2 , false , false ) ) return i ; } - if ( s.Left(1) == "*" && s.Length() > 1 ) + if ( s.Left(1) == wxT("*") && s.Length() > 1 ) { - s = st ; - s.MakeLower() ; + wxString st = s ; + st.MakeLower() ; for ( int i = 0 ; i < m_noItems ; ++i ) { - if ( GetString(i).Lower().Matches(s) ) + if ( GetString(i).Lower().Matches(st) ) return i ; } } @@ -501,21 +471,12 @@ int wxListBox::FindString(const wxString& st) const { Str255 s1 , s2 ; -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s2 , s.c_str() ) ; -#else - strcpy( (char *) s2 , s.c_str() ) ; - c2pstr( (char *) s2 ) ; -#endif + wxMacStringToPascal( s , s2 ) ; for ( int i = 0 ; i < m_noItems ; ++ i ) { -#if TARGET_CARBON - c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ; -#else - strcpy( (char *) s1 , m_stringArray[i].c_str() ) ; - c2pstr( (char *) s1 ) ; -#endif + wxMacStringToPascal( m_stringArray[i] , s1 ) ; + if ( EqualString( s1 , s2 , false , false ) ) return i ; } @@ -535,7 +496,7 @@ void wxListBox::Clear() void wxListBox::SetSelection(int N, bool select) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetSelection" ); + wxT("invalid index in wxListBox::SetSelection") ); MacSetSelection( N , select ) ; GetSelections( m_selectionPreImage ) ; } @@ -543,7 +504,7 @@ void wxListBox::SetSelection(int N, bool select) bool wxListBox::IsSelected(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, - "invalid index in wxListBox::Selected" ); + wxT("invalid index in wxListBox::Selected") ); return MacIsSelected( N ) ; } @@ -564,7 +525,7 @@ wxClientData *wxListBox::DoGetItemClientObject(int N) const void wxListBox::DoSetItemClientData(int N, void *Client_data) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetClientData" ); + wxT("invalid index in wxListBox::SetClientData") ); #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) @@ -574,7 +535,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); } #endif // wxUSE_OWNER_DRAWN - wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ; + wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , wxT("invalid client_data array") ) ; if ( m_dataArray.GetCount() > (size_t) N ) { @@ -606,12 +567,7 @@ int wxListBox::GetSelection() const // Find string for position wxString wxListBox::GetString(int N) const { - if( wxApp::s_macDefaultEncodingIsPC ) - { - return wxMacMakePCStringFromMac( m_stringArray[N] ) ; - } - else - return m_stringArray[N] ; + return m_stringArray[N] ; } void wxListBox::DoInsertItems(const wxArrayString& items, int pos) @@ -633,14 +589,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) void wxListBox::SetString(int N, const wxString& s) { - wxString str ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - str = wxMacMakeMacStringFromPC( s ) ; - } - else - str = s ; - m_stringArray[N] = str ; + m_stringArray[N] = s ; MacSet( N , s ) ; } @@ -754,7 +703,7 @@ void wxListBox::MacDelete( int N ) Refresh(); } -void wxListBox::MacInsert( int n , const char * text) +void wxListBox::MacInsert( int n , const wxString& text) { Cell cell = { 0 , 0 } ; cell.v = n ; @@ -763,7 +712,7 @@ void wxListBox::MacInsert( int n , const char * text) Refresh(); } -void wxListBox::MacAppend( const char * text) +void wxListBox::MacAppend( const wxString& text) { Cell cell = { 0 , 0 } ; cell.v = (**(ListHandle)m_macList).dataBounds.bottom ; @@ -834,7 +783,7 @@ int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const return no_sel ; } -void wxListBox::MacSet( int n , const char * text ) +void wxListBox::MacSet( int n , const wxString& text ) { // our implementation does not store anything in the list // so we just have to redraw @@ -1011,11 +960,11 @@ void wxListBox::OnChar(wxKeyEvent& event) { if ( event.GetTimestamp() > m_lastTypeIn + 60 ) { - m_typeIn = "" ; + m_typeIn = wxEmptyString ; } m_lastTypeIn = event.GetTimestamp() ; m_typeIn += (char) event.GetKeyCode() ; - int line = FindString("*"+m_typeIn+"*") ; + int line = FindString(wxT("*")+m_typeIn+wxT("*")) ; if ( line >= 0 ) { if ( GetSelection() != line ) diff --git a/src/mac/macnotfy.cpp b/src/mac/macnotfy.cpp index b6a170c8ee..36d7fb3e61 100644 --- a/src/mac/macnotfy.cpp +++ b/src/mac/macnotfy.cpp @@ -88,7 +88,7 @@ void wxMacAddEvent( short wakeUp ) { wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; + wxASSERT_MSG( handler != NULL , wxT("illegal notification proc ptr") ) ; /* this should be protected eventually */ short index = e->top++ ; diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index cc0aba9ed1..417240fc09 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -107,7 +107,7 @@ void wxMenu::Attach(wxMenuBarBase *menubar) // append a new item or submenu to the menu bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { - wxASSERT_MSG( pItem != NULL, "can't append NULL item to the menu" ); + wxASSERT_MSG( pItem != NULL, wxT("can't append NULL item to the menu") ); if ( pItem->IsSeparator() ) { @@ -121,7 +121,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) wxMenu *pSubMenu = pItem->GetSubMenu() ; if ( pSubMenu != NULL ) { - wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); + wxASSERT_MSG( pSubMenu->m_hMenu != NULL , wxT("invalid submenu added")); pSubMenu->m_menuParent = this ; if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) @@ -140,12 +140,12 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { if ( pos == (size_t)-1 ) { - UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); + UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") ); pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; } else { - UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); + UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") , pos); } SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; @@ -503,7 +503,7 @@ void wxMenuBar::MacInstallMenuBar() Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; wxString message ; - wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); + wxCHECK_RET( menubar != NULL, wxT("can't read MBAR resource") ); ::SetMenuBar( menubar ) ; #if TARGET_API_MAC_CARBON ::DisposeMenuBar( menubar ) ; @@ -550,7 +550,7 @@ void wxMenuBar::MacInstallMenuBar() int pos ; wxMenu* menu = m_menus[i] , *subMenu = NULL ; - if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + if( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName ) { if ( mh == NULL ) { diff --git a/src/mac/menuitem.cpp b/src/mac/menuitem.cpp index ce04c08eda..807f2a8ee0 100644 --- a/src/mac/menuitem.cpp +++ b/src/mac/menuitem.cpp @@ -48,9 +48,9 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, { // In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines // therefore these item must not be translated - if ( wxStripMenuCodes(m_text).Upper() == "EXIT" ) + if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") ) { - m_text = "Quit\tCtrl+Q" ; + m_text =wxT("Quit\tCtrl+Q") ; } m_radioGroup.start = -1; @@ -152,7 +152,7 @@ void wxMenuItem::UncheckRadio() void wxMenuItem::Check(bool bDoCheck) { - wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); + wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") ); if ( m_isChecked != bDoCheck ) { diff --git a/src/mac/metafile.cpp b/src/mac/metafile.cpp index 1f87cb9f4a..aca4bc0ae5 100644 --- a/src/mac/metafile.cpp +++ b/src/mac/metafile.cpp @@ -72,7 +72,7 @@ wxMetaFile::wxMetaFile(const wxString& file) M_METAFILEDATA->m_metafile = 0; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ; /* if (!file.IsNull() && (file.Cmp("") == 0)) M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); @@ -145,9 +145,9 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file) m_maxX = -10000; m_maxY = -10000; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ; - m_metaFile = new wxMetaFile("") ; + m_metaFile = new wxMetaFile(wxEmptyString) ; Rect r={0,0,1000,1000} ; m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; @@ -167,9 +167,9 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, i m_maxX = -10000; m_maxY = -10000; - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet")) ; - m_metaFile = new wxMetaFile("") ; + m_metaFile = new wxMetaFile(wxEmptyString) ; Rect r={yorg,xorg,yorg+yext,xorg+xext} ; m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; diff --git a/src/mac/mimetmac.cpp b/src/mac/mimetmac.cpp index 393c2870c4..296c7a81ba 100644 --- a/src/mac/mimetmac.cpp +++ b/src/mac/mimetmac.cpp @@ -129,66 +129,66 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e) { wxString ext = e ; ext = ext.Lower() ; - if ( ext == "txt" ) + if ( ext == wxT("txt") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("text/text"); + fileType->m_impl->SetFileType(wxT("text/text")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "htm" || ext == "html" ) + else if ( ext == wxT("htm") || ext == wxT("html") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("text/html"); + fileType->m_impl->SetFileType(wxT("text/html")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "gif" ) + else if ( ext == wxT("gif") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/gif"); + fileType->m_impl->SetFileType(wxT("image/gif")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "png" ) + else if ( ext == wxT("png" )) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/png"); + fileType->m_impl->SetFileType(wxT("image/png")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "jpg" || ext == "jpeg" ) + else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/jpeg"); + fileType->m_impl->SetFileType(wxT("image/jpeg")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "bmp" ) + else if ( ext == wxT("bmp") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/bmp"); + fileType->m_impl->SetFileType(wxT("image/bmp")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "tif" || ext == "tiff" ) + else if ( ext == wxT("tif") || ext == wxT("tiff") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/tiff"); + fileType->m_impl->SetFileType(wxT("image/tiff")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "xpm" ) + else if ( ext == wxT("xpm") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/xpm"); + fileType->m_impl->SetFileType(wxT("image/xpm")); fileType->m_impl->SetExt(ext); return fileType; } - else if ( ext == "xbm" ) + else if ( ext == wxT("xbm") ) { wxFileType *fileType = new wxFileType; - fileType->m_impl->SetFileType("image/xbm"); + fileType->m_impl->SetFileType(wxT("image/xbm")); fileType->m_impl->SetExt(ext); return fileType; } diff --git a/src/mac/msgdlg.cpp b/src/mac/msgdlg.cpp index 732a2f48ba..670d30644e 100644 --- a/src/mac/msgdlg.cpp +++ b/src/mac/msgdlg.cpp @@ -67,7 +67,7 @@ int wxMessageDialog::ShowModal() short result ; - wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; + wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ; AlertType alertType = kAlertPlainAlert ; if (m_dialogStyle & wxICON_EXCLAMATION) @@ -83,17 +83,12 @@ int wxMessageDialog::ShowModal() if ( UMAGetSystemVersion() >= 0x1000 ) { AlertStdCFStringAlertParamRec param ; - CFStringRef cfNoString = NULL ; - CFStringRef cfYesString = NULL ; - - CFStringRef cfTitle = NULL; - CFStringRef cfText = NULL; - - cfTitle = wxMacCreateCFString( m_caption ) ; - cfText = wxMacCreateCFString( m_message ) ; - cfNoString = wxMacCreateCFString( _("No") ) ; - cfYesString = wxMacCreateCFString( _("Yes") ) ; + wxMacCFStringHolder cfNoString(_("No")) ; + wxMacCFStringHolder cfYesString( _("Yes")) ; + wxMacCFStringHolder cfTitle(m_caption); + wxMacCFStringHolder cfText(m_message); + param.movable = true; param.flags = 0 ; @@ -157,32 +152,13 @@ int wxMessageDialog::ShowModal() CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; RunStandardAlert( alertRef , NULL , &result ) ; } - if(cfTitle != NULL) - CFRelease(cfTitle); - if(cfText != NULL) - CFRelease(cfText); - if(cfNoString != NULL) - CFRelease(cfNoString); - if(cfYesString != NULL) - CFRelease(cfYesString); - if ( skipDialog ) + if ( skipDialog ) return wxID_CANCEL ; } else #endif { AlertStdAlertParamRec param; - char cText[2048] ; - - if (wxApp::s_macDefaultEncodingIsPC) - { - strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; - } - else - { - strcpy( cText , m_message ) ; - } - wxMacConvertNewlines( cText , cText ) ; Str255 yesPString ; Str255 noPString ; @@ -192,7 +168,7 @@ int wxMessageDialog::ShowModal() wxMacStringToPascal( m_caption , pascalTitle ) ; wxMacStringToPascal( _("Yes") , yesPString ) ; wxMacStringToPascal( _("No") , noPString ) ; - CopyCStringToPascal( cText , pascalText ) ; + wxMacStringToPascal( m_message , pascalText ) ; param.movable = true; param.filterProc = NULL ; diff --git a/src/mac/notebmac.cpp b/src/mac/notebmac.cpp index 56cacb02a2..d5f72a32d7 100644 --- a/src/mac/notebmac.cpp +++ b/src/mac/notebmac.cpp @@ -130,7 +130,7 @@ bool wxNotebook::Create(wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; int tabstyle = kControlTabSmallNorthProc ; if ( HasFlag(wxNB_LEFT) ) @@ -360,12 +360,8 @@ void wxNotebook::MacSetupTabs() page = m_pages[ii]; info.version = 0; info.iconSuiteID = 0; -#if TARGET_CARBON - c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; -#else - strcpy( (char *) info.name , page->GetLabel() ) ; - c2pstr( (char *) info.name ) ; -#endif + wxMacStringToPascal( page->GetLabel() , info.name ) ; + SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag, sizeof( ControlTabInfoRec) , (char*) &info ) ; SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ; @@ -488,7 +484,7 @@ bool wxNotebook::DoPhase(int /* nPhase */) void wxNotebook::Command(wxCommandEvent& event) { - wxFAIL_MSG("wxNotebook::Command not implemented"); + wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); } // ---------------------------------------------------------------------------- diff --git a/src/mac/pnghand.cpp b/src/mac/pnghand.cpp index a270cff9e7..583cbbab7a 100644 --- a/src/mac/pnghand.cpp +++ b/src/mac/pnghand.cpp @@ -57,7 +57,7 @@ extern void wxMacDestroyGWorld( GWorldPtr gw ) ; void ima_png_error(png_struct *png_ptr, char *message) { - wxMessageBox(message, "PNG error"); + wxMessageBox(wxString::FromAscii(message), wxT("PNG error")); longjmp(png_ptr->jmpbuf, 1); } @@ -819,8 +819,9 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) strcpy(nameStr, name); else { - strcpy(nameStr, filename); - wxStripExtension(nameStr); + wxString str = wxString::FromAscii(filename) ; + wxStripExtension( str ) ; + strcpy(nameStr, str.ToAscii() ); } if ( GetDepth() > 4 ) @@ -888,7 +889,7 @@ bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla int desiredWidth, int desiredHeight) { wxPNGReader reader; - if (reader.ReadFile((char*) (const char*) name)) + if (reader.ReadFile( (char*)(const char*) name.ToAscii() ) ) { return reader.InstantiateBitmap(bitmap); } diff --git a/src/mac/printdlg.cpp b/src/mac/printdlg.cpp index 779ee74edd..20bf8dedc7 100644 --- a/src/mac/printdlg.cpp +++ b/src/mac/printdlg.cpp @@ -97,8 +97,8 @@ int wxPrintDialog::ShowModal() } else { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxT(""), wxICON_HAND | wxOK) ; dialog.ShowModal(); } ::UMAPrClose(NULL) ; @@ -179,8 +179,8 @@ int wxPrintDialog::ShowModal() } if ((err != noErr) && (err != kPMCancel)) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } #else @@ -245,8 +245,8 @@ int wxPageSetupDialog::ShowModal() } else { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ; dialog.ShowModal(); } ::UMAPrClose(NULL) ; @@ -301,8 +301,8 @@ int wxPageSetupDialog::ShowModal() } if ((err != noErr) && (err != kPMCancel)) { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + message.Printf( wxT("Print Error %d"), err ) ; + wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ; dialog.ShowModal(); } #else diff --git a/src/mac/printmac.cpp b/src/mac/printmac.cpp index 5f3c79225e..274f8b1c9e 100644 --- a/src/mac/printmac.cpp +++ b/src/mac/printmac.cpp @@ -144,7 +144,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (!win) { wxEndBusyCursor(); - wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); + wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent); delete dc; return FALSE; } @@ -162,7 +162,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); - wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); + wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); break; } if (sm_abortIt) diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index 15ac067af7..141c7971fc 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -203,7 +203,7 @@ wxString wxRadioBox::GetString(int item) const wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) - return wxString(""); + return wxEmptyString; i = 0; current = m_radioButtonCycle; @@ -409,7 +409,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) int totWidth,totHeight; SetFont(GetParent()->GetFont()); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); + GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); charWidth/=52; maxWidth=-1; @@ -490,7 +490,7 @@ wxSize wxRadioBox::DoGetBestSize() const int totWidth, totHeight; wxFont font = GetParent()->GetFont(); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), + GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font); charWidth /= 52; diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index 6f57b2c40d..ad843c3fd9 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -46,12 +46,12 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, kControlScrollBarLiveProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index 2a95191da2..87d4e58609 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -74,7 +74,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_pageSize = (int)((maxValue-minValue)/10); - MacPreControlCreate( parent, id, "", pos, size, style, + MacPreControlCreate( parent, id, wxEmptyString, pos, size, style, validator, name, &bounds, title ); procID = kControlSliderProc + kControlSliderLiveFeedback; @@ -86,15 +86,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, value, minValue, maxValue, procID, (long) this); - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; if(style & wxSL_LABELS) { - m_macMinimumStatic = new wxStaticText( this, -1, "" ); - m_macMaximumStatic = new wxStaticText( this, -1, "" ); - m_macValueStatic = new wxStaticText( this, -1, "" ); + m_macMinimumStatic = new wxStaticText( this, -1, wxEmptyString ); + m_macMaximumStatic = new wxStaticText( this, -1, wxEmptyString ); + m_macValueStatic = new wxStaticText( this, -1, wxEmptyString ); SetRange(minValue, maxValue); SetValue(value); } @@ -132,7 +132,7 @@ int wxSlider::GetValue() const void wxSlider::SetValue(int value) { wxString valuestring ; - valuestring.Printf( "%d" , value ) ; + valuestring.Printf( wxT("%d") , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; SetControl32BitValue( (ControlHandle) m_macControl , value ) ; @@ -149,11 +149,11 @@ void wxSlider::SetRange(int minValue, int maxValue) SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); if(m_macMinimumStatic) { - value.Printf("%d", m_rangeMin); + value.Printf(wxT("%d"), m_rangeMin); m_macMinimumStatic->SetLabel(value); } if(m_macMaximumStatic) { - value.Printf("%d", m_rangeMax); + value.Printf(wxT("%d"), m_rangeMax); m_macMaximumStatic->SetLabel(value); } SetValue(m_rangeMin); @@ -283,9 +283,9 @@ wxSize wxSlider::DoGetBestSize() const int ht, wd; // Get maximum text label width and height - text.Printf("%d", m_rangeMin); + text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &textwidth, &textheight); - text.Printf("%d", m_rangeMax); + text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &wd, &ht); if(ht > textheight) { textheight = ht; @@ -356,9 +356,9 @@ void wxSlider::MacUpdateDimensions() int ht; // Get maximum text label width and height - text.Printf("%d", m_rangeMin); + text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &minValWidth, &textheight); - text.Printf("%d", m_rangeMax); + text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &maxValWidth, &ht); if(ht > textheight) { textheight = ht; diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index b36c755f7e..0f4faca578 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -47,12 +47,12 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; MacPostControlCreate() ; diff --git a/src/mac/statlmac.cpp b/src/mac/statlmac.cpp index dc00dcca0f..30305cc1cf 100644 --- a/src/mac/statlmac.cpp +++ b/src/mac/statlmac.cpp @@ -52,7 +52,7 @@ bool wxStaticLine::Create( wxWindow *parent, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlSeparatorLineProc , (long) this ) ; diff --git a/src/mac/stattext.cpp b/src/mac/stattext.cpp index fc0a5726f9..b2a7d103da 100644 --- a/src/mac/stattext.cpp +++ b/src/mac/stattext.cpp @@ -59,7 +59,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, return ret; } -const wxString punct = " ,.-;:!?"; +const wxString punct = wxT(" ,.-;:!?"); void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { @@ -68,7 +68,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) if (paragraph.Length() == 0) { // empty line - dc.GetTextExtent( "H", &width, &height ); + dc.GetTextExtent( wxT("H"), &width, &height ); y += height; return; @@ -127,7 +127,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) } dc.DrawText( paragraph, pos , y) ; - paragraph=""; + paragraph=wxEmptyString; y += height ; } } @@ -165,7 +165,7 @@ void wxStaticText::OnDraw( wxDC &dc ) if (text[i] == 13 || text[i] == 10) { DrawParagraph(dc, paragraph,y); - paragraph = "" ; + paragraph = wxEmptyString ; } else { diff --git a/src/mac/tabctrl.cpp b/src/mac/tabctrl.cpp index 6e79c88386..4fcf069286 100644 --- a/src/mac/tabctrl.cpp +++ b/src/mac/tabctrl.cpp @@ -39,7 +39,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons m_imageList = NULL; - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; @@ -115,7 +115,7 @@ int wxTabCtrl::GetRowCount() const wxString wxTabCtrl::GetItemText(int item) const { // TODO - return wxString(""); + return wxEmptyString; } // Get the item image diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index ae6063d20c..0f6f9e9ab7 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -593,6 +593,7 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle ) kTXNStartOffset, kTXNEndOffset); /* set the field's background */ + tback.bgType = kTXNBackgroundTypeRGB; tback.bg.color = rgbWhite; TXNSetBackground( varsp->fTXNRec, &tback); @@ -701,7 +702,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, mySize.y += 2 * m_macVerticalBorder ; } */ - MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; + MacPreControlCreate( parent , id , wxEmptyString , pos , mySize ,style, validator , name , &bounds , title ) ; if ( m_windowStyle & wxTE_MULTILINE ) { @@ -738,16 +739,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, } MacPostControlCreate() ; - wxString value ; - - if( wxApp::s_macDefaultEncodingIsPC ) - value = wxMacMakeMacStringFromPC( st ) ; - else - value = st ; - if ( !m_macUsesTXN ) { - ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else { @@ -755,9 +750,15 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, /* set up locals */ tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); /* set the text in the record */ - TXNSetData( (**tpvars).fTXNRec, kTXNTextData, (void*)value.c_str(), value.Length(), - kTXNStartOffset, kTXNEndOffset); m_macTXN = (**tpvars).fTXNRec ; +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN) , kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2, + kTXNStartOffset, kTXNEndOffset); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN) , kTXNTextData, (void*)text.data(), strlen( text ) , + kTXNStartOffset, kTXNEndOffset); +#endif m_macTXNvars = tpvars ; m_macUsesTXN = true ; TXNSetSelection( (TXNObject) m_macTXN, 0, 0); @@ -777,25 +778,23 @@ wxString wxTextCtrl::GetValue() const err = ::GetControlDataSize((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; - if ( err ) - return wxEmptyString ; - - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxCharBuffer buf(actualSize) ; ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - actualSize , ptr , &actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf(actualSize) ; + actualSize , buf.data() , &actualSize ) ; + result = wxMacMakeStringFromCString( buf ) ; } - } else { +#if wxUSE_UNICODE Handle theText ; - err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNUnicodeTextData ); // all done if ( err ) { @@ -804,18 +803,38 @@ wxString wxTextCtrl::GetValue() const else { actualSize = GetHandleSize( theText ) ; - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - strncpy( ptr , *theText , actualSize ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ; + wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ; ptr[actualSize] = 0 ; result.UngetWriteBuf( actualSize ) ; } DisposeHandle( theText ) ; } +#else + Handle theText ; + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + // all done + if ( err ) + { + actualSize = 0 ; + } + else + { + actualSize = GetHandleSize( theText ) ; + if ( actualSize > 0 ) + { + HLock( theText ) ; + result = wxMacMakeStringFromCString( *theText , actualSize ) ; + HUnlock( theText ) ; + } + DisposeHandle( theText ) ; + } +#endif } - return wxMacMakeStringFromMacString( result ) ; + return result ; } void wxTextCtrl::GetSelection(long* from, long* to) const @@ -833,28 +852,24 @@ void wxTextCtrl::GetSelection(long* from, long* to) const void wxTextCtrl::SetValue(const wxString& st) { - wxString value; - - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakeMacStringFromPC( st ) ; - // value.Replace( "\n", "\r" ); TODO this should be handled by the conversion - } - else - value = st; - - if ( !m_macUsesTXN ) { - ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else { bool formerEditable = IsEditable() ; if ( !formerEditable ) SetEditable(true) ; - TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , + kTXNStartOffset, kTXNEndOffset); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , kTXNStartOffset, kTXNEndOffset); +#endif TXNSetSelection( (TXNObject) m_macTXN, 0, 0); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); if ( !formerEditable ) @@ -884,7 +899,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) if ( style.HasFont() ) { const wxFont &font = style.GetFont() ; - CopyCStringToPascal( font.GetFaceName().c_str() , fontName ) ; + wxMacStringToPascal( font.GetFaceName() , fontName ) ; fontSize = font.GetPointSize() ; if ( font.GetUnderlined() ) fontStyle |= underline ; @@ -918,7 +933,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) { OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr, start,end); - wxASSERT_MSG( status == noErr , "Couldn't set text attributes" ) ; + wxASSERT_MSG( status == noErr , wxT("Couldn't set text attributes") ) ; } if ( !formerEditable ) SetEditable(formerEditable) ; @@ -1140,8 +1155,13 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) SetEditable(true) ; TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; TXNClear( ((TXNObject) m_macTXN) ) ; +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)value.wc_str(), value.Length() * 2 , + kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#else TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#endif if ( !formerEditable ) SetEditable( formerEditable ) ; } @@ -1208,20 +1228,12 @@ bool wxTextCtrl::LoadFile(const wxString& file) return FALSE; } -void wxTextCtrl::WriteText(const wxString& text) -{ - wxString value ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakeMacStringFromPC( text ) ; - // value.Replace( "\n", "\r" ); // TODO this should be handled by the conversion - } - else - value = text ; - +void wxTextCtrl::WriteText(const wxString& st) +{ if ( !m_macUsesTXN ) { - TEInsert( value , value.Length() , ((TEHandle) m_macTE) ) ; + wxCharBuffer text = wxMacStringToCString( st ) ; + TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ; } else { @@ -1230,8 +1242,14 @@ void wxTextCtrl::WriteText(const wxString& text) SetEditable(true) ; long start , end , dummy ; GetSelection( &start , &dummy ) ; - TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(), +#if wxUSE_UNICODE + TXNSetData( ((TXNObject) m_macTXN), kTXNUnicodeTextData, (void*)st.wc_str(), st.Length() * 2 , kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#else + wxCharBuffer text = wxMacStringToCString( st ) ; + TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)text.data(), strlen( text ) , + kTXNUseCurrentSelection, kTXNUseCurrentSelection); +#endif GetSelection( &dummy , &end ) ; SetStyle( start , end , GetDefaultStyle() ) ; if ( !formerEditable ) @@ -1415,7 +1433,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const if (count == lineNo) { // Add chars in line then - wxString tmp(""); + wxString tmp; for (size_t j = i; j < content.Length(); j++) { @@ -1429,7 +1447,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const } if (content[i] == '\r') count++; } - return "" ; + return wxEmptyString ; } /* diff --git a/src/mac/thread.cpp b/src/mac/thread.cpp index 3e4b1dfc49..e31c812c02 100644 --- a/src/mac/thread.cpp +++ b/src/mac/thread.cpp @@ -852,7 +852,7 @@ bool wxThreadModule::OnInit() #endif if ( !hasThreadManager ) { - wxMessageBox( "Error" , "Thread Support is not available on this System" , wxOK ) ; + wxMessageBox( wxT("Error") , wxT("Thread Support is not available on this System") , wxOK ) ; return FALSE ; } diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 33da0a2d4b..42dfe72bab 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -255,7 +255,7 @@ bool wxToolBar::Realize() ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ; */ ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ; - wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; + wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; ::EmbedControl( m_macToolHandle , container ) ; if ( GetWindowStyleFlag() & wxTB_VERTICAL ) @@ -507,7 +507,7 @@ wxString wxToolBar::MacGetToolTipString( wxPoint &pt ) { return tool->GetShortHelp() ; } - return "" ; + return wxEmptyString ; } void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) diff --git a/src/mac/tooltip.cpp b/src/mac/tooltip.cpp index 4b00c6f750..bee14fc9fb 100644 --- a/src/mac/tooltip.cpp +++ b/src/mac/tooltip.cpp @@ -35,7 +35,7 @@ class wxMacToolTip wxMacToolTip( ) ; ~wxMacToolTip() ; - void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; + void Setup( WindowRef window , const wxString& text , wxPoint localPosition ) ; long GetMark() { return m_mark ; } void Draw() ; void Clear() ; @@ -50,8 +50,8 @@ class wxMacToolTip bool m_shown ; long m_mark ; wxMacToolTipTimer* m_timer ; -#ifdef TARGET_CARBON - CFStringRef m_helpTextRef ; +#if TARGET_CARBON + wxMacCFStringHolder m_helpTextRef ; #endif } ; @@ -186,18 +186,14 @@ wxMacToolTip::wxMacToolTip() m_mark = 0 ; m_shown = false ; m_timer = NULL ; - m_helpTextRef = NULL ; } -void wxMacToolTip::Setup( WindowRef win , wxString text , wxPoint localPosition ) +void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localPosition ) { m_mark++ ; Clear() ; m_position = localPosition ; - if( wxApp::s_macDefaultEncodingIsPC ) - m_label = wxMacMakeMacStringFromPC( text ) ; - else - m_label = text ; + m_label = text ; m_window =win; s_ToolTipWindowRef = m_window ; m_backpict = NULL ; @@ -228,209 +224,147 @@ void wxMacToolTip::Draw() { m_shown = true ; #if TARGET_CARBON - if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) - { - HMHelpContentRec tag ; - tag.version = kMacHelpVersion; - SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort(m_window) ; - LocalToGlobal( (Point *) &tag.absHotRect.top ); - LocalToGlobal( (Point *) &tag.absHotRect.bottom ); - SetPort( port ); - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } - m_helpTextRef = wxMacCreateCFString(m_label) ; - tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; - tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; - tag.tagSide = kHMDefaultSide; - HMDisplayTag( &tag ); - } - else -#endif + HMHelpContentRec tag ; + tag.version = kMacHelpVersion; + SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort(m_window) ; + LocalToGlobal( (Point *) &tag.absHotRect.top ); + LocalToGlobal( (Point *) &tag.absHotRect.bottom ); + SetPort( port ); + m_helpTextRef = m_label ; + tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; + tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; + tag.tagSide = kHMDefaultSide; + HMDisplayTag( &tag ); +#else + wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); + FontFamilyID fontId ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetFNum( fontName, &fontId ); + + TextFont( fontId ) ; + TextSize( fontSize ) ; + TextFace( fontStyle ) ; + FontInfo fontInfo; + ::GetFontInfo(&fontInfo); + short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; + short height = 0 ; + // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; + + int i = 0 ; + int length = m_label.Length() ; + int width = 0 ; + int thiswidth = 0 ; + int laststop = 0 ; + wxCharBuffer text = wxMacStringToCString( m_label ) ; + + while( i < length ) { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); -#if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; -#endif - - FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; - GetFNum( fontName, &fontId ); - - TextFont( fontId ) ; - TextSize( fontSize ) ; - TextFace( fontStyle ) ; - FontInfo fontInfo; - ::GetFontInfo(&fontInfo); - short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; - short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; - - int i = 0 ; - int length = m_label.Length() ; - int width = 0 ; - int thiswidth = 0 ; - int laststop = 0 ; - const char *text = m_label ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - - height += lineh ; - laststop = i+1 ; - } - i++ ; - } - if ( i - laststop > 0 ) + if( text[i] == 13 || text[i] == 10) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; + height += lineh ; + laststop = i+1 ; } - - - m_rect.left = m_position.x + kTipOffset; - m_rect.top = m_position.y + kTipOffset; - m_rect.right = m_rect.left + width + 2 * kTipBorder; -#if TARGET_CARBON - if ( useDrawThemeText ) - m_rect.right += kTipBorder ; -#endif - m_rect.bottom = m_rect.top + height + 2 * kTipBorder; - Rect r ; - GetPortBounds( GetWindowPort( m_window ) , &r ) ; - if ( m_rect.top < 0 ) - { - m_rect.bottom += -m_rect.top ; - m_rect.top = 0 ; - } - if ( m_rect.left < 0 ) - { - m_rect.right += -m_rect.left ; - m_rect.left = 0 ; - } - if ( m_rect.right > r.right ) - { - m_rect.left -= (m_rect.right - r.right ) ; - m_rect.right = r.right ; - } - if ( m_rect.bottom > r.bottom ) - { - m_rect.top -= (m_rect.bottom - r.bottom) ; - m_rect.bottom = r.bottom ; - } - ClipRect( &m_rect ) ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - GWorldPtr port ; - NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - SetGWorld( port , NULL ) ; - - m_backpict = OpenPicture(&m_rect); - - CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), - GetPortBitMapForCopyBits(port), - &m_rect, - &m_rect, - srcCopy, - NULL); - ClosePicture(); - SetGWorld( origPort , origDevice ) ; - DisposeGWorld( port ) ; - PenNormal() ; - - RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; - BackColor( whiteColor ) ; - RGBForeColor( &tooltipbackground ) ; - - PaintRect( &m_rect ) ; - ForeColor(blackColor ) ; - FrameRect( &m_rect ) ; - SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); - - i = 0 ; - laststop = 0 ; - height = 0 ; - - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { -#if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - height += lineh ; - } - else -#endif - { - ::DrawText( text , laststop , i - laststop ) ; - height += lineh ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); - } - laststop = i+1 ; - } - i++ ; - } -#if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else -#endif + i++ ; + } + if ( i - laststop > 0 ) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + height += lineh ; + } + + m_rect.left = m_position.x + kTipOffset; + m_rect.top = m_position.y + kTipOffset; + m_rect.right = m_rect.left + width + 2 * kTipBorder; + + m_rect.bottom = m_rect.top + height + 2 * kTipBorder; + Rect r ; + GetPortBounds( GetWindowPort( m_window ) , &r ) ; + if ( m_rect.top < 0 ) + { + m_rect.bottom += -m_rect.top ; + m_rect.top = 0 ; + } + if ( m_rect.left < 0 ) + { + m_rect.right += -m_rect.left ; + m_rect.left = 0 ; + } + if ( m_rect.right > r.right ) + { + m_rect.left -= (m_rect.right - r.right ) ; + m_rect.right = r.right ; + } + if ( m_rect.bottom > r.bottom ) + { + m_rect.top -= (m_rect.bottom - r.bottom) ; + m_rect.bottom = r.bottom ; + } + ClipRect( &m_rect ) ; + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + GWorldPtr port ; + NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( port , NULL ) ; + + m_backpict = OpenPicture(&m_rect); + + CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), + GetPortBitMapForCopyBits(port), + &m_rect, + &m_rect, + srcCopy, + NULL); + ClosePicture(); + SetGWorld( origPort , origDevice ) ; + DisposeGWorld( port ) ; + PenNormal() ; + + RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; + BackColor( whiteColor ) ; + RGBForeColor( &tooltipbackground ) ; + + PaintRect( &m_rect ) ; + ForeColor(blackColor ) ; + FrameRect( &m_rect ) ; + SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); + + i = 0 ; + laststop = 0 ; + height = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) { ::DrawText( text , laststop , i - laststop ) ; + height += lineh ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); + laststop = i+1 ; } - ::TextMode( srcOr ) ; - } + i++ ; + } + ::DrawText( text , laststop , i - laststop ) ; + ::TextMode( srcOr ) ; +#endif } } @@ -454,11 +388,7 @@ void wxMacToolTip::Clear() return ; #if TARGET_CARBON HMHideTag() ; - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } + m_helpTextRef.Release() ; #else if ( m_window == s_ToolTipWindowRef && m_backpict ) { diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp index 69708ed1a3..2f4de7a5eb 100644 --- a/src/mac/toplevel.cpp +++ b/src/mac/toplevel.cpp @@ -362,7 +362,7 @@ void wxAssociateWinWithMacWindow(WXWindow inWindowRef, wxTopLevelWindowMac *win) { // adding NULL WindowRef is (first) surely a result of an error and // (secondly) breaks menu command processing - wxCHECK_RET( inWindowRef != (WindowRef) NULL, "attempt to add a NULL WindowRef to window list" ); + wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); if ( !wxWinMacWindowList->Find((long)inWindowRef) ) wxWinMacWindowList->Append((long)inWindowRef, win); @@ -592,12 +592,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; wxAssociateWinWithMacWindow( m_macWindow , this ) ; - wxString label ; - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( title ) ; - else - label = title ; - UMASetWTitleC( (WindowRef)m_macWindow , label ) ; + UMASetWTitle( (WindowRef)m_macWindow , title ) ; ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ; #if TARGET_CARBON InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; @@ -836,15 +831,7 @@ void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev ) void wxTopLevelWindowMac::SetTitle(const wxString& title) { wxWindow::SetTitle( title ) ; - - wxString label ; - - if( wxApp::s_macDefaultEncodingIsPC ) - label = wxMacMakeMacStringFromPC( m_label ) ; - else - label = m_label ; - - UMASetWTitleC( (WindowRef)m_macWindow , label ) ; + UMASetWTitle( (WindowRef)m_macWindow , title ) ; } bool wxTopLevelWindowMac::Show(bool show) diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 59daa769db..9ec67e6f54 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -189,10 +189,8 @@ MenuRef UMANewMenu( SInt16 id , const wxString& title ) wxString str = wxStripMenuCodes( title ) ; MenuRef menu ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; CreateNewMenu( id , 0 , &menu ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -205,9 +203,7 @@ void UMASetMenuTitle( MenuRef menu , const wxString& title ) { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -219,9 +215,7 @@ void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& tit { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuItemTextWithCFString( menu , item , cfs ) ; - CFRelease( cfs ) ; + SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -558,17 +552,15 @@ void UMADisposeWindow( WindowRef inWindowRef ) DisposeWindow( inWindowRef ) ; } -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) +void UMASetWTitle( WindowRef inWindowRef , const wxString& title ) { - Str255 ptitle ; - strncpy( (char*)ptitle , title , 96 ) ; - ptitle[96] = 0 ; #if TARGET_CARBON - c2pstrcpy( ptitle, (char *)ptitle ) ; + SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title) ) ; #else - c2pstr( (char*)ptitle ) ; -#endif + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; SetWTitle( inWindowRef , ptitle ) ; +#endif } void UMAGetWTitleC( WindowRef inWindowRef , char *title ) @@ -583,6 +575,17 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) // appearance additions +void UMASetControlTitle( ControlHandle inControl , const wxString& title ) +{ +#if TARGET_CARBON + SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title) ) ; +#else + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; + SetControlTitle( inControl , ptitle ) ; +#endif +} + void UMAActivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn @@ -795,7 +798,7 @@ void wxMacPortStateHelper::Setup( GrafPtr newport ) { GetPort( &m_oldPort ) ; SetPort( newport ) ; - wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; + wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ; m_clip = NewRgn() ; GetClip( m_clip ); m_textFont = GetPortTextFont( (CGrafPtr) newport); diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index 3897dadd57..014225901c 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -38,6 +38,10 @@ #include #endif +#include "ATSUnicode.h" +#include "TextCommon.h" +#include "TextEncodingConverter.h" + #ifndef __DARWIN__ // defined in unix/utilsunx.cpp for Mac OS X @@ -48,7 +52,7 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) } // Get hostname only (without domain name) -bool wxGetHostName(char *buf, int maxSize) +bool wxGetHostName(wxChar *buf, int maxSize) { // Gets Chooser name of user by examining a System resource. @@ -61,13 +65,11 @@ bool wxGetHostName(char *buf, int maxSize) if (chooserName && *chooserName) { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; + HLock( (Handle) chooserName ) ; + wxString name = wxMacMakeStringFromPascal( *chooserName ) ; + HUnlock( (Handle) chooserName ) ; + ReleaseResource( (Handle) chooserName ) ; + wxStrncpy( buf , name , maxSize - 1 ) ; } else buf[0] = 0 ; @@ -76,7 +78,7 @@ bool wxGetHostName(char *buf, int maxSize) } // Get user ID e.g. jacs -bool wxGetUserId(char *buf, int maxSize) +bool wxGetUserId(wxChar *buf, int maxSize) { return wxGetUserName( buf , maxSize ) ; } @@ -88,7 +90,7 @@ const wxChar* wxGetHomeDir(wxString *pstr) } // Get user name e.g. Stefan Csomor -bool wxGetUserName(char *buf, int maxSize) +bool wxGetUserName(wxChar *buf, int maxSize) { // Gets Chooser name of user by examining a System resource. @@ -101,13 +103,11 @@ bool wxGetUserName(char *buf, int maxSize) if (chooserName && *chooserName) { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; + HLock( (Handle) chooserName ) ; + wxString name = wxMacMakeStringFromPascal( *chooserName ) ; + HUnlock( (Handle) chooserName ) ; + ReleaseResource( (Handle) chooserName ) ; + wxStrncpy( buf , name , maxSize - 1 ) ; } else buf[0] = 0 ; @@ -250,22 +250,25 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) { - char buf[50]; - sprintf(buf, "%.4f", value); + wxString buf; + buf.Printf(wxT("%.4f"), value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) { - char buf[50]; - sprintf(buf, "%ld", value); + wxString buf; + buf.Printf(wxT("%ld"), value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) { - char buf[50]; - sprintf(buf, "%d", value); + wxString buf; + buf.Printf(wxT("%d"), value); + return wxWriteResource(section, entry, buf, file); } @@ -369,7 +372,7 @@ wxString wxMacFindFolder( short vol, } #ifndef __DARWIN__ -char *wxGetUserHome (const wxString& user) +wxChar *wxGetUserHome (const wxString& user) { // TODO return NULL; @@ -390,7 +393,7 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) p = p.Mid(1,pos) ; } - p = p + ":" ; + p = p + wxT(":") ; Str255 volumeName ; XVolumeParam pb ; @@ -501,7 +504,7 @@ wxString wxGetOsDescription() // use configure generated description if available return wxString("MacOS (") + WXWIN_OS_DESCRIPTION + wxString(")"); #else - return "MacOS" ; //TODO:define further + return wxT("MacOS") ; //TODO:define further #endif } @@ -593,10 +596,185 @@ void wxMacConvertToPC( const char *from , char *to , int len ) } } -wxString wxMacMakeMacStringFromPC( const char * p ) +TECObjectRef s_TECNativeCToUnicode = NULL ; +TECObjectRef s_TECUnicodeToNativeC = NULL ; +TECObjectRef s_TECPCToNativeC = NULL ; +TECObjectRef s_TECNativeCToPC = NULL ; +void wxMacSetupConverters() { + // 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 setup... + + OSStatus status = noErr ; + status = TECCreateConverter(&s_TECNativeCToUnicode, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + + + status = TECCreateConverter(&s_TECUnicodeToNativeC, + kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + + if ( !wxApp::s_macDefaultEncodingIsPC ) + { + status = TECCreateConverter(&s_TECPCToNativeC, + kTextEncodingWindowsLatin1, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + + + status = TECCreateConverter(&s_TECNativeCToPC, + wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingWindowsLatin1 ); + } +} + +void wxMacCleanupConverters() +{ + OSStatus status = noErr ; + status = TECDisposeConverter(s_TECNativeCToUnicode); + + status = TECDisposeConverter(s_TECUnicodeToNativeC); + + status = TECDisposeConverter(s_TECPCToNativeC); + + status = TECDisposeConverter(s_TECNativeCToPC); +} + +wxWCharBuffer wxMacStringToWString( const wxString &from ) +{ +#if wxUSE_UNICODE + wxWCharBuffer result( from.wc_str() ) ; +#else + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = from.Length() ; + ByteCount byteBufferLen = byteInLen *2 ; + wxWCharBuffer result( from.Length() ) ; + status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + result.data()[byteOutLen/2] = 0 ; +#endif + return result ; +} + +wxString wxMacMakeStringFromCString( const char * from , int len ) +{ + OSStatus status = noErr ; wxString result ; - int len = strlen ( p ) ; + wxChar* buf = result.GetWriteBuf( len ) ; +#if wxUSE_UNICODE + ByteCount byteOutLen ; + ByteCount byteInLen = len ; + ByteCount byteBufferLen = len *2 ; + + status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); +#else + if ( wxApp::s_macDefaultEncodingIsPC ) + memcpy( buf , from , len ) ; + else + { + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = len ; + ByteCount byteBufferLen = byteInLen ; + + status = TECConvertText(s_TECNativeCToPC, (ConstTextPtr)from , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); + } +#endif + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} + +wxString wxMacMakeStringFromCString( const char * from ) +{ + return wxMacMakeStringFromCString( from , strlen(from) ) ; +} + +wxCharBuffer wxMacStringToCString( const wxString &from ) +{ +#if wxUSE_UNICODE + OSStatus status = noErr ; + ByteCount byteOutLen ; + ByteCount byteInLen = from.Length() * 2 ; + ByteCount byteBufferLen = from.Length() ; + wxCharBuffer result( from.Length() ) ; + status = TECConvertText(s_TECUnicodeToNativeC , (ConstTextPtr)from.wc_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + return result ; +#else + if ( wxApp::s_macDefaultEncodingIsPC ) + 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_TECPCToNativeC, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen, + (TextPtr)result.data(), byteBufferLen, &byteOutLen); + return result ; + } +#endif +} + +void wxMacStringToPascal( const wxString&from , StringPtr to ) +{ + wxCharBuffer buf = wxMacStringToCString( from ) ; + int len = strlen(buf) ; + + if ( len > 255 ) + len = 255 ; + to[0] = len ; + memcpy( (char*) &to[1] , buf , len ) ; +} + +wxString wxMacMakeStringFromPascal( ConstStringPtr from ) +{ + return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; +} + +// +// CFStringRefs (Carbon only) +// + +#if TARGET_CARBON +// converts this string into a carbon foundation string with optional pc 2 mac encoding +void wxMacCFStringHolder::Assign( const wxString &str ) +{ +#if wxUSE_UNICODE + m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, + (const unsigned short*)str.wc_str(), str.Len() ); +#else + m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + wxApp::s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; +#endif + m_release = true ; +} + +wxString wxMacCFStringHolder::AsString() +{ + wxString result ; + Size len = CFStringGetLength( m_cfs ) ; + wxChar* buf = result.GetWriteBuf( len ) ; +#if wxUSE_UNICODE + CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; +#else + CFStringGetCString( m_cfs , buf , len+1 , s_macDefaultEncodingIsPC ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; +#endif + buf[len] = 0 ; + result.UngetWriteBuf() ; + return result ; +} + +#if 0 + +wxString wxMacMakeMacStringFromPC( const wxChar * p ) +{ + wxString result ; + int len = wxStrlen ( p ) ; if ( len > 0 ) { wxChar* ptr = result.GetWriteBuf(len) ; @@ -607,10 +785,10 @@ wxString wxMacMakeMacStringFromPC( const char * p ) return result ; } -wxString wxMacMakePCStringFromMac( const char * p ) +wxString wxMacMakePCStringFromMac( const wxChar * p ) { wxString result ; - int len = strlen ( p ) ; + int len = wxStrlen ( p ) ; if ( len > 0 ) { wxChar* ptr = result.GetWriteBuf(len) ; @@ -621,7 +799,7 @@ wxString wxMacMakePCStringFromMac( const char * p ) return result ; } -wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) +wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) { if (mac2pcEncoding) { @@ -652,7 +830,7 @@ wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) } } -void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) +void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) { if (pc2macEncoding) { @@ -663,19 +841,8 @@ void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding CopyCStringToPascal( from , to ) ; } } +#endif -// -// CFStringRefs (Carbon only) -// - -#if TARGET_CARBON -// converts this string into a carbon foundation string with optional pc 2 mac encoding -CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) -{ - return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - pc2macEncoding ? - kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; -} #endif //TARGET_CARBON diff --git a/src/mac/wave.cpp b/src/mac/wave.cpp index 0c5aac8bfc..35accb9167 100644 --- a/src/mac/wave.cpp +++ b/src/mac/wave.cpp @@ -135,23 +135,18 @@ bool wxWave::Create(const wxString& fileName, bool isResource) //don't know what to do with looped, wth bool wxWave::Play(bool async, bool looped) const { - char lpSnd[32]; bool ret = false; if (m_isResource) { -#if TARGET_CARBON - c2pstrcpy((unsigned char *)lpSnd, m_sndname); -#else - strcpy(lpSnd, m_sndname); - c2pstr((char *) lpSnd); -#endif - SndListHandle hSnd; + Str255 snd ; + wxMacStringToPascal( m_sndname , snd ) ; + SndListHandle hSnd; - hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); + hSnd = (SndListHandle) GetNamedResource('snd ', snd); - if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) - ret = true; + if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) + ret = true; } return ret; diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 156527a083..9f7a20f4e7 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -1642,7 +1642,7 @@ wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) { return m_tooltip->GetTip() ; } - return "" ; + return wxEmptyString ; } void wxWindowMac::Update() @@ -1855,13 +1855,13 @@ WXHWND wxWindowMac::MacGetRootWindow() const iter = iter->GetParent() ; } - wxASSERT_MSG( 1 , "No valid mac root window" ) ; + wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; return NULL ; } void wxWindowMac::MacCreateScrollBars( long style ) { - wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; + wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; diff --git a/src/wxWindowsM8.xml b/src/wxWindowsM8.xml index 3b238dd0b2..98622f11b0 100755 --- a/src/wxWindowsM8.xml +++ b/src/wxWindowsM8.xml @@ -666,7 +666,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -1765,15 +1765,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -1846,15 +1837,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -4005,15 +3987,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -4655,13 +4628,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -4718,13 +4684,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -6395,13 +6354,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -7151,7 +7103,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -8241,15 +8193,6 @@ Text - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -8322,15 +8265,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -10490,15 +10424,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -11133,13 +11058,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -11196,13 +11114,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -12880,13 +12791,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -13230,7 +13134,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -14058,7 +13962,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -15199,7 +15103,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -16316,15 +16220,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -16397,15 +16292,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -18530,15 +18416,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -19194,13 +19071,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -19257,13 +19127,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -20916,13 +20779,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -21672,7 +21528,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -22749,15 +22605,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -22830,15 +22677,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -24782,15 +24620,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -25427,13 +25256,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -25490,13 +25312,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -27006,13 +26821,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -27769,7 +27577,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -28859,15 +28667,6 @@ Text - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -28940,15 +28739,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -30887,15 +30677,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -31539,13 +31320,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -31602,13 +31376,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -33115,13 +32882,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -33542,7 +33302,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -34709,7 +34469,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -35781,15 +35541,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -35862,15 +35613,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -38066,15 +37808,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -38702,13 +38435,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -38765,13 +38491,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -40470,13 +40189,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -41246,7 +40958,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -42409,7 +42121,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -43481,15 +43193,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -43562,15 +43265,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -45766,15 +45460,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -46395,13 +46080,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -46458,13 +46136,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -48170,13 +47841,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -48936,7 +48600,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -50008,15 +49672,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -50089,15 +49744,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -52077,15 +51723,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -52722,13 +52359,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -52785,13 +52415,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -54322,13 +53945,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -55095,7 +54711,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -56167,15 +55783,6 @@ Text Debug - - PathRelative - Project - :mac: - :aga.cpp - MacOS - Text - Debug - PathRelative Project @@ -56248,15 +55855,6 @@ Text Debug - - PathRelative - Project - :common: - :odbc.cpp - MacOS - Text - Debug - PathRelative Project @@ -58281,15 +57879,6 @@ Text Debug - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - Text - Debug - PathRelative Project @@ -58919,13 +58508,6 @@ :dcprint.cpp MacOS - - PathRelative - Project - :mac: - :aga.cpp - MacOS - PathRelative Project @@ -58982,13 +58564,6 @@ :appcmn.cpp MacOS - - PathRelative - Project - :common: - :odbc.cpp - MacOS - PathRelative Project @@ -60561,13 +60136,6 @@ :dcbuffer.cpp MacOS - - PathRelative - Project - :generic: - :gridg.cpp - MacOS - PathRelative Project @@ -61344,7 +60912,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -62517,7 +62085,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -63690,7 +63258,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0—ô0#Þ##ÞÈ + MWFTP_Post_password0ÿÄ æø"²¸ MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -64955,14 +64523,6 @@ :object.cpp MacOS - - wxlib PPC debug - PathRelative - Project - :common: - :odbc.cpp - MacOS - wxlib PPC debug PathRelative @@ -65435,14 +64995,6 @@ :gridctrl.cpp MacOS - - wxlib PPC debug - PathRelative - Project - :generic: - :gridg.cpp - MacOS - wxlib PPC debug PathRelative @@ -66023,14 +65575,6 @@ :accel.cpp MacOS - - wxlib PPC debug - PathRelative - Project - :mac: - :aga.cpp - MacOS - wxlib PPC debug PathRelative -- 2.45.2