X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7ea087b7218956709b57731228736126114411b9..e11898f903183f897a2b2a50a4447ea73ba7273f:/src/mac/carbon/utils.cpp diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index f9b1d82641..cf7d76b624 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -33,12 +33,7 @@ #include #include -#ifdef __DARWIN__ -# include "MoreFilesX.h" -#else -# include "MoreFiles.h" -# include "MoreFilesExtras.h" -#endif +#include "MoreFilesX.h" #ifndef __DARWIN__ #include @@ -524,18 +519,12 @@ wxString wxMacFindFolder( short vol, OSType folderType, Boolean createFolder) { - short vRefNum ; - long dirID ; + FSRef fsRef ; wxString strDir ; - if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr) - { - FSSpec file ; - if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr ) - { - strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ; - } - } + if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr) + strDir = wxMacFSRefToPath( &fsRef ) + wxFILE_SEP_PATH ; + return strDir ; } @@ -667,20 +656,28 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) p = p + wxT(":") ; - Str255 volumeName ; - XVolumeParam pb ; - - wxMacStringToPascal( p , volumeName ) ; - OSErr err = XGetVolumeInfoNoName( volumeName , 0 , &pb ) ; - if ( err == noErr ) { - if ( pTotal ) { - (*pTotal) = wxLongLong( pb.ioVTotalBytes ) ; - } - if ( pFree ) { - (*pFree) = wxLongLong( pb.ioVFreeBytes ) ; - } + OSErr err = noErr ; + + FSRef fsRef ; + err = wxMacPathToFSRef( p , &fsRef ) ; + if ( noErr == err ) + { + FSVolumeRefNum vRefNum ; + err = FSGetVRefNum( &fsRef , &vRefNum ) ; + if ( noErr == err ) + { + UInt64 freeBytes , totalBytes ; + err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes ) ; + if ( noErr == err ) + { + if ( pTotal ) + *pTotal = wxLongLong( totalBytes ) ; + if ( pFree ) + *pFree = wxLongLong( freeBytes ) ; + } + } } - + return err == noErr ; } #endif // !__DARWIN__ @@ -1709,7 +1706,9 @@ void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to void wxMacControl::SetRect( Rect *r ) { #if TARGET_API_MAC_OSX - HIRect hir = { r->left , r->top , r->right - r->left , r->bottom - r->top } ; + //A HIRect is actually a CGRect on OSX - which consists of two structures - + //CGPoint and CGSize, which have two floats each + HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } } ; HIViewSetFrame ( m_controlRef , &hir ) ; #else SetControlBounds( m_controlRef , r ) ; @@ -1735,7 +1734,14 @@ void wxMacControl::GetBestRect( Rect *r ) void wxMacControl::SetTitle( const wxString &title ) { - UMASetControlTitle( m_controlRef , title , m_font.GetEncoding() ) ; + wxFontEncoding encoding; + + if ( m_font.Ok() ) + encoding = m_font.GetEncoding(); + else + encoding = wxFont::GetDefaultEncoding(); + + UMASetControlTitle( m_controlRef , title , encoding ) ; } void wxMacControl::GetFeatures( UInt32 * features )