X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6ea4a2661dc767c74acf652ea0c97fe1b3f90c36..6c6ea7bed145bc5bb8a5c9ac3704af914ca57171:/src/mac/carbon/utils.cpp?ds=inline diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index cc1caf7c10..3e999b65e7 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -33,18 +33,14 @@ #include #include -#ifdef __DARWIN__ -# include "MoreFilesX.h" -#else -# include "MoreFiles.h" -# include "MoreFilesExtras.h" -#endif +#include "MoreFilesX.h" #ifndef __DARWIN__ #include #include #endif +#if wxUSE_GUI #if TARGET_API_MAC_OSX #include #else @@ -55,6 +51,7 @@ #include #include #include +#endif // wxUSE_GUI #include "wx/mac/private.h" // includes mac headers @@ -524,18 +521,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 +658,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 +1596,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 ) ; @@ -1703,7 +1708,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 ) ; @@ -1729,7 +1736,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 )