From 03561a3c073b2453bd10a0a011c5a9b9e058eb6b Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 17 Nov 2007 10:37:02 +0000 Subject: [PATCH] cleanup mac git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/databrow.cpp | 2 +- src/mac/carbon/dccg.cpp | 17 +-- src/mac/carbon/listbox.cpp | 3 +- src/mac/carbon/mediactrl.cpp | 2 +- src/mac/carbon/menu.cpp | 7 +- src/mac/carbon/menuitem.cpp | 4 +- src/mac/carbon/mimetmac.cpp | 75 +--------- src/mac/carbon/notebmac.cpp | 2 +- src/mac/carbon/printmac.cpp | 11 +- src/mac/carbon/sound.cpp | 2 +- src/mac/carbon/toplevel.cpp | 9 +- src/mac/carbon/utils.cpp | 273 +---------------------------------- 12 files changed, 26 insertions(+), 381 deletions(-) diff --git a/src/mac/carbon/databrow.cpp b/src/mac/carbon/databrow.cpp index 1527547d93..60d0a8005e 100644 --- a/src/mac/carbon/databrow.cpp +++ b/src/mac/carbon/databrow.cpp @@ -31,7 +31,7 @@ #include #if defined(__MWERKS__) && wxUSE_UNICODE -#if __MWERKS__ < 0x4100 || !defined(__DARWIN__) +#if __MWERKS__ < 0x4100 #include #endif #endif diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index 23d903065e..00d3094a9e 100644 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -2234,17 +2234,14 @@ void wxDC::Clear(void) wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 - if ( UMAGetSystemVersion() >= 0x1030 ) + HIThemeBackgroundDrawInfo drawInfo ; + drawInfo.version = 0 ; + drawInfo.state = kThemeStateActive ; + drawInfo.kind = m_backgroundBrush.MacGetThemeBackground( NULL ) ; + if ( drawInfo.kind == kThemeBackgroundMetal ) { - HIThemeBackgroundDrawInfo drawInfo ; - drawInfo.version = 0 ; - drawInfo.state = kThemeStateActive ; - drawInfo.kind = m_backgroundBrush.MacGetThemeBackground( NULL ) ; - if ( drawInfo.kind == kThemeBackgroundMetal ) - { - HIThemeDrawBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ; - HIThemeApplyBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ; - } + HIThemeDrawBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ; + HIThemeApplyBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ; } #endif } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index ab9e40f0c9..2cf0f52f50 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -613,8 +613,7 @@ static pascal void ListBoxDrawProc( // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor // is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor // for inactive browser highlighting - Gestalt( gestaltSystemVersion, &systemVersion ); - if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) ) + if ( !IsControlActive( browser ) ) colorBrushID = kThemeBrushSecondaryHighlightColor; else colorBrushID = kThemeBrushPrimaryHighlightColor; diff --git a/src/mac/carbon/mediactrl.cpp b/src/mac/carbon/mediactrl.cpp index f3ff582a13..c6e16665ac 100644 --- a/src/mac/carbon/mediactrl.cpp +++ b/src/mac/carbon/mediactrl.cpp @@ -57,7 +57,7 @@ #include #endif -#if !defined(__DARWIN__) || !defined(__LP64__) +#if !defined(__LP64__) #define USE_QUICKTIME 1 #else #define USE_QUICKTIME 0 diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index b717e52e6b..f3806a6a49 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -469,9 +469,8 @@ void wxMenu::MacBeforeDisplay( bool isSubMenu ) // shown in the application menu anyhow -- it doesn't make // sense to show them in their normal place as well if ( item->GetId() == wxApp::s_macAboutMenuItemId || - ( UMAGetSystemVersion() >= 0x1000 && ( item->GetId() == wxApp::s_macPreferencesMenuItemId || - item->GetId() == wxApp::s_macExitMenuItemId ) ) ) + item->GetId() == wxApp::s_macExitMenuItemId ) { ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ), @@ -749,7 +748,7 @@ void wxMenuBar::MacInstallMenuBar() helpMenuHandle = NULL ; } - if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId) + if ( wxApp::s_macPreferencesMenuItemId) { wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ; if ( item == NULL || !(item->IsEnabled()) ) @@ -762,7 +761,7 @@ void wxMenuBar::MacInstallMenuBar() // enabled unless it is added by the application and then disabled, otherwise // a program would be required to add an item with wxID_EXIT in order to get the // Quit menu item to be enabled, which seems a bit burdensome. - if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macExitMenuItemId) + if ( wxApp::s_macExitMenuItemId) { wxMenuItem *item = FindItem( wxApp::s_macExitMenuItemId , NULL ) ; if ( item != NULL && !(item->IsEnabled()) ) diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index bc6f0dd3d4..172c5b0ab1 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -100,7 +100,7 @@ void wxMenuItem::UpdateItemStatus() if ( IsSeparator() ) return ; - if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macPreferencesMenuItemId) + if ( GetId() == wxApp::s_macPreferencesMenuItemId) { if ( !IsEnabled() ) DisableMenuCommand( NULL , kHICommandPreferences ) ; @@ -108,7 +108,7 @@ void wxMenuItem::UpdateItemStatus() EnableMenuCommand( NULL , kHICommandPreferences ) ; } - if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macExitMenuItemId) + if ( GetId() == wxApp::s_macExitMenuItemId) { if ( !IsEnabled() ) DisableMenuCommand( NULL , kHICommandQuit ) ; diff --git a/src/mac/carbon/mimetmac.cpp b/src/mac/carbon/mimetmac.cpp index c06fb8775e..7d6818ba37 100644 --- a/src/mac/carbon/mimetmac.cpp +++ b/src/mac/carbon/mimetmac.cpp @@ -398,9 +398,8 @@ wxFileTypeImpl::GetPrintCommand( // we need to go straight to launch services // -#if defined(__DARWIN__) - //on darwin, use launch services + #include wxString wxFileTypeImpl::GetCommand(const wxString& verb) const @@ -457,74 +456,6 @@ wxString wxFileTypeImpl::GetCommand(const wxString& verb) const return wxEmptyString; } -#else //carbon/classic implementation - - -wxString wxFileTypeImpl::GetCommand(const wxString& verb) const -{ - wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") ); - - if (verb == wxT("open")) - { - ICMapEntry entry; - ICGetMapEntry( (ICInstance) m_manager->m_hIC, - (Handle) m_manager->m_hDatabase, - m_lIndex, &entry); - - //The entry in the mimetype database only contains the app - //that's registered - it may not exist... we need to remap the creator - //type and find the right application - - // THIS IS REALLY COMPLICATED :\. - // There are a lot of conversions going on here. - Str255 outName; - FSSpec outSpec; - OSErr err = FindApplication( entry.fileCreator, false, outName, &outSpec ); - if (err != noErr) - return wxEmptyString; - - Handle outPathHandle; - short outPathSize; - err = FSpGetFullPath( &outSpec, &outPathSize, &outPathHandle ); - if (err == noErr) - { - char* szPath = *outPathHandle; - wxString sClassicPath(szPath, wxConvLocal, outPathSize); - -#if defined(__DARWIN__) - // Classic Path --> Unix (OSX) Path - CFURLRef finalURL = CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, - wxMacCFStringHolder(sClassicPath, wxLocale::GetSystemEncoding()), - kCFURLHFSPathStyle, - false ); //false == not a directory - - //clean up memory from the classic path handle - DisposeHandle( outPathHandle ); - - if (finalURL) - { - CFStringRef cfsUnixPath = CFURLCopyFileSystemPath(finalURL, kCFURLPOSIXPathStyle); - CFRelease(finalURL); - - // PHEW! Success! - if (cfsUnixPath) - return wxMacCFStringHolder(cfsUnixPath).AsString(wxLocale::GetSystemEncoding()); - } -#else //classic HFS path acceptable - return sClassicPath; -#endif - } - else - { - wxLogMimeDebug(wxT("FSpGetFullPath failed."), (OSStatus)err); - } - } - - return wxEmptyString; -} -#endif //!DARWIN - bool wxFileTypeImpl::GetDescription(wxString *desc) const { wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") ); @@ -1681,10 +1612,8 @@ wxFileType* wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) wxLogDebug(wxT("No main bundle")); } -#if defined(__DARWIN__) if (!bInfoSuccess) return NULL; -#endif // on mac you have to embed it into the mac's file reference resource ('FREF' I believe) // or, alternately, you could just add an entry to m_hDatabase, but you'd need to get @@ -1991,10 +1920,8 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType) wxLogDebug(wxT("No main bundle")); } -#if defined(__DARWIN__) if (!bInfoSuccess) return false; -#endif // this should be as easy as removing the entry from the database // and then saving the database diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index e3ffb8f3ad..993f685d87 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -405,7 +405,7 @@ void wxNotebook::MacSetupTabs() info.name = cflabel ; m_peer->SetData( ii + 1, kControlTabInfoTag, &info ) ; - if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 ) + if ( GetImageList() && GetPageImage(ii) >= 0 ) { const wxBitmap bmap = GetImageList()->GetBitmap( GetPageImage( ii ) ) ; if ( bmap.Ok() ) diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 606e813946..d731e35033 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -509,17 +509,14 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) } else { - if ( UMAGetSystemVersion() >= 0x1000 ) - { #if !wxMAC_USE_CORE_GRAPHICS - GrafPtr thePort ; - GetPort( &thePort ) ; + GrafPtr thePort ; + GetPort( &thePort ) ; #endif - wxSafeYield(win,true); + wxSafeYield(win,true); #if !wxMAC_USE_CORE_GRAPHICS - SetPort( thePort ) ; + SetPort( thePort ) ; #endif - } dc->StartPage(); keepGoing = printout->OnPrintPage(pn); dc->EndPage(); diff --git a/src/mac/carbon/sound.cpp b/src/mac/carbon/sound.cpp index c3afc15e01..365b1e42a2 100644 --- a/src/mac/carbon/sound.cpp +++ b/src/mac/carbon/sound.cpp @@ -71,7 +71,7 @@ static wxTimer* lastSoundTimer=NULL; static bool lastSoundIsPlaying=false; -#if !defined(__DARWIN__) || !defined(__LP64__) +#if !defined(__LP64__) #define USE_QUICKTIME 1 #else #define USE_QUICKTIME 0 diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 572ff2e81d..0a007a12d5 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -1222,10 +1222,7 @@ void wxTopLevelWindowMac::DoMacCreateRealWindow( if ( HasFlag( wxCLOSE_BOX) ) attr |= kWindowCloseBoxAttribute ; } - - // turn on live resizing (OS X only) - if (UMAGetSystemVersion() >= 0x1000) - attr |= kWindowLiveResizeAttribute; + attr |= kWindowLiveResizeAttribute; if ( HasFlag(wxSTAY_ON_TOP) ) group = GetWindowGroupOfClass(kUtilityWindowClass) ; @@ -1399,11 +1396,9 @@ bool wxTopLevelWindowMac::Show(bool show) if ( !wxTopLevelWindowBase::Show(show) ) return false; - bool plainTransition = false; + bool plainTransition = true; #if wxUSE_SYSTEM_OPTIONS - // code contributed by Ryan Wilcox December 18, 2003 - plainTransition = UMAGetSystemVersion() >= 0x1000 ; if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ; #endif diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index e38a307434..ae1ef930d5 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -65,7 +65,7 @@ #include "wx/mac/private.h" #if defined(__MWERKS__) && wxUSE_UNICODE -#if __MWERKS__ < 0x4100 || !defined(__DARWIN__) +#if __MWERKS__ < 0x4100 #include #endif #endif @@ -91,281 +91,12 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) #endif } -// ---------------------------------------------------------------------------- -// debugging support -// ---------------------------------------------------------------------------- - -#if defined(__WXDEBUG__) && defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400) - -// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds... - -#ifndef __MetroNubUtils__ -#include "MetroNubUtils.h" -#endif - -#ifndef __GESTALT__ -#include -#endif - -#if TARGET_API_MAC_CARBON - -#include - -extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...); - -ProcPtr gCallUniversalProc_Proc = NULL; - -#endif - -static MetroNubUserEntryBlock* gMetroNubEntry = NULL; - -static long fRunOnce = false; - - -Boolean IsMetroNubInstalled() -{ - if (!fRunOnce) - { - long result, value; - - fRunOnce = true; - gMetroNubEntry = NULL; - - if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000) - { - // look for MetroNub's Gestalt selector - if (Gestalt(kMetroNubUserSignature, &result) == noErr) - { -#if TARGET_API_MAC_CARBON - if (gCallUniversalProc_Proc == NULL) - { - CFragConnectionID connectionID; - Ptr mainAddress; - Str255 errorString; - ProcPtr symbolAddress; - OSErr err; - CFragSymbolClass symbolClass; - - symbolAddress = NULL; - err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag, - &connectionID, &mainAddress, errorString); - - if (err != noErr) - { - gCallUniversalProc_Proc = NULL; - goto end; - } - - err = FindSymbol(connectionID, "\pCallUniversalProc", - (Ptr *) &gCallUniversalProc_Proc, &symbolClass); - - if (err != noErr) - { - gCallUniversalProc_Proc = NULL; - goto end; - } - } -#endif - - { - MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result; - - // make sure the version of the API is compatible - if (block->apiLowVersion <= kMetroNubUserAPIVersion && - kMetroNubUserAPIVersion <= block->apiHiVersion) - { - // success! - gMetroNubEntry = block; - } - } - } - } - } - -end: - -#if TARGET_API_MAC_CARBON - return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL); -#else - return (gMetroNubEntry != NULL); -#endif -} - -Boolean IsMWDebuggerRunning() -{ - if (IsMetroNubInstalled()) - return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning); - - return false; -} - -Boolean AmIBeingMWDebugged() -{ - if (IsMetroNubInstalled()) - return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged); - - return false; -} - extern bool WXDLLEXPORT wxIsDebuggerRunning() { - return IsMWDebuggerRunning() && AmIBeingMWDebugged(); -} - -#else - -extern bool WXDLLEXPORT wxIsDebuggerRunning() -{ - return false; -} - -#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400) - - -#ifndef __DARWIN__ -// defined in unix/utilsunx.cpp for Mac OS X - -// get full hostname (with domain name if possible) -bool wxGetFullHostName(wxChar *buf, int maxSize) -{ - return wxGetHostName(buf, maxSize); -} - -// Get user ID e.g. jacs -bool wxGetUserId(wxChar *buf, int maxSize) -{ - return wxGetUserName( buf , maxSize ); -} - -const wxChar* wxGetHomeDir(wxString *pstr) -{ - *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ); - return pstr->c_str(); -} - -// Get hostname only (without domain name) -bool wxGetHostName(wxChar *buf, int maxSize) -{ - // Gets Chooser name of user by examining a System resource. - buf[0] = 0; - - const short kComputerNameID = -16413; - - short oldResFile = CurResFile(); - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - HLock( (Handle) chooserName ); - wxString name = wxMacMakeStringFromPascal( *chooserName ); - HUnlock( (Handle) chooserName ); - ReleaseResource( (Handle) chooserName ); - wxStrncpy( buf , name , maxSize - 1 ); - } - - return true; -} - -// Get user name e.g. Stefan Csomor -bool wxGetUserName(wxChar *buf, int maxSize) -{ - // Gets Chooser name of user by examining a System resource. - buf[0] = 0; - - const short kChooserNameID = -16096; - - short oldResFile = CurResFile(); - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - HLock( (Handle) chooserName ); - wxString name = wxMacMakeStringFromPascal( *chooserName ); - HUnlock( (Handle) chooserName ); - ReleaseResource( (Handle) chooserName ); - wxStrncpy( buf , name , maxSize - 1 ); - } - - return true; -} - -int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags) -{ - // TODO - return 0; -} - -WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value) -{ - // TODO : under classic there is no environement support, under X yes - return false; -} - -// set the env var name to the given value, return true on success -WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxString& value) -{ - // TODO : under classic there is no environement support, under X yes - return false; -} - -WXDLLEXPORT bool wxUnsetEnv(const wxString& var) -{ - // TODO : under classic there is no environement support, under X yes + // TODO : try to find out ... return false; } -// Execute a program in an Interactive Shell -bool wxShell(const wxString& command) -{ - // TODO - return false; -} - -// Shutdown or reboot the PC -bool wxShutdown(wxShutdownFlags wFlags) -{ - // TODO - return false; -} - -// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) -wxMemorySize wxGetFreeMemory() -{ - return (wxMemorySize)FreeMem(); -} - -#ifndef __DARWIN__ - -void wxMicroSleep(unsigned long microseconds) -{ - AbsoluteTime wakeup = AddDurationToAbsolute( microseconds * durationMicrosecond , UpTime()); - MPDelayUntil( & wakeup); -} - -void wxMilliSleep(unsigned long milliseconds) -{ - AbsoluteTime wakeup = AddDurationToAbsolute( milliseconds, UpTime()); - MPDelayUntil( & wakeup); -} - -void wxSleep(int nSecs) -{ - wxMilliSleep(1000*nSecs); -} - -#endif - -// Consume all events until no more left -void wxFlushEvents() -{ -} - -#endif // !__DARWIN__ - // Emit a beeeeeep void wxBell() { -- 2.47.2