X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5ca0d8122ab2ecbce178aa9f21f13270c4ffaca0..68379eaf0ae64d105f8244b1db83e793f7dd83b0:/src/mac/carbon/utils.cpp diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index be4535ea94..679bf3d1e5 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__ @@ -1597,6 +1594,12 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l ::SetControlFontStyle( m_controlRef , &fontStyle ); } +void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) ) +{ + // TODO + // setting up a color proc is not recommended anymore +} + void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum ) { ::SetControl32BitMinimum( m_controlRef , minimum ) ; @@ -1695,8 +1698,8 @@ void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to hiPoint.x = pt->x ; hiPoint.y = pt->y ; HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef ) ; - pt->x = hiPoint.x ; - pt->y = hiPoint.y ; + pt->x = (int)hiPoint.x ; + pt->y = (int)hiPoint.y ; #endif } @@ -1723,14 +1726,20 @@ void wxMacControl::GetRectInWindowCoords( Rect *r ) void wxMacControl::GetBestRect( Rect *r ) { - Rect bestsize = { 0 , 0 , 0 , 0 } ; short baselineoffset ; GetBestControlRect( m_controlRef , r , &baselineoffset ) ; } 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 )