X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bf2d09ed0902c9990308cc38ec474662ba76cf3..5f3f0f1725cc5e906caa6a81e368d0c8b29702ea:/src/mac/carbon/utils.cpp diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 2148fc4886..780fee8956 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -18,7 +18,10 @@ #include "wx/utils.h" #include "wx/app.h" #include "wx/apptrait.h" -#include "wx/mac/uma.h" + +#if wxUSE_GUI + #include "wx/mac/uma.h" +#endif #include @@ -51,6 +54,32 @@ #include #endif +// --------------------------------------------------------------------------- +// code used in both base and GUI compilation +// --------------------------------------------------------------------------- + +// our OS version is the same in non GUI and GUI cases +static int DoGetOSVersion(int *majorVsn, int *minorVsn) +{ + long theSystem ; + + // are there x-platform conventions ? + + Gestalt(gestaltSystemVersion, &theSystem) ; + if (minorVsn != NULL) { + *minorVsn = (theSystem & 0xFF ) ; + } + if (majorVsn != NULL) { + *majorVsn = (theSystem >> 8 ) ; + } +#ifdef __DARWIN__ + return wxMAC_DARWIN; +#else + return wxMAC; +#endif +} + +#if wxUSE_BASE #ifndef __DARWIN__ // defined in unix/utilsunx.cpp for Mac OS X @@ -193,24 +222,29 @@ void wxBell() SysBeep(30); } -int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn) +wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo() { - long theSystem ; + static wxToolkitInfo info; + info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor); + info.name = _T("wxBase"); + return info; +} - // are there x-platform conventions ? +#endif // wxUSE_BASE - Gestalt(gestaltSystemVersion, &theSystem) ; - if (minorVsn != NULL) { - *minorVsn = (theSystem & 0xFF ) ; - } - if (majorVsn != NULL) { - *majorVsn = (theSystem >> 8 ) ; - } -#ifdef __DARWIN__ - return wxMAC_DARWIN; -#else - return wxMAC; +#if wxUSE_GUI + +wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() +{ + static wxToolkitInfo info; + info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor); + info.shortName = _T("mac"); + info.name = _T("wxMac"); +#ifdef __WXUNIVERSAL__ + info.shortName << _T("univ"); + info.name << _T("/wxUniversal"); #endif + return info; } // Reading and writing resources (eg WIN.INI, .Xdefaults) @@ -344,48 +378,6 @@ wxString wxMacFindFolder( short vol, return strDir ; } -#ifndef __DARWIN__ -wxChar *wxGetUserHome (const wxString& user) -{ - // TODO - return NULL; -} - -bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) -{ - if ( path.empty() ) - return FALSE; - - wxString p = path ; - if (p[0] == ':' ) { - p = wxGetCwd() + p ; - } - - int pos = p.Find(':') ; - if ( pos != wxNOT_FOUND ) { - p = p.Mid(1,pos) ; - } - - 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 ) ; - } - } - - return err == noErr ; -} -#endif - // Check whether this window wants to process messages, e.g. Stop button // in long calculations. bool wxCheckForInterrupt(wxWindow *wnd) @@ -486,16 +478,66 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) return wxGenericFindWindowAtPoint(pt); } +#endif // wxUSE_GUI + +#if wxUSE_BASE + wxString wxGetOsDescription() { #ifdef WXWIN_OS_DESCRIPTION // use configure generated description if available - return wxString("MacOS (") + WXWIN_OS_DESCRIPTION + wxString(")"); + return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")")); #else return wxT("MacOS") ; //TODO:define further #endif } +#ifndef __DARWIN__ +wxChar *wxGetUserHome (const wxString& user) +{ + // TODO + return NULL; +} + +bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) +{ + if ( path.empty() ) + return FALSE; + + wxString p = path ; + if (p[0] == ':' ) { + p = wxGetCwd() + p ; + } + + int pos = p.Find(':') ; + if ( pos != wxNOT_FOUND ) { + p = p.Mid(1,pos) ; + } + + 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 ) ; + } + } + + return err == noErr ; +} +#endif // !__DARWIN__ + +#endif // wxUSE_BASE + +#if wxUSE_GUI + //--------------------------------------------------------------------------- // wxMac Specific utility functions //--------------------------------------------------------------------------- @@ -861,8 +903,7 @@ void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncodi #include - EXTERN_API_C( long ) - CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...); + extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...); ProcPtr gCallUniversalProc_Proc = NULL; @@ -982,3 +1023,5 @@ extern bool WXDLLEXPORT wxIsDebuggerRunning() #endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400) +#endif // wxUSE_GUI +