cleanup mac

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2007-11-17 10:37:02 +00:00
parent 6719c06a97
commit 03561a3c07
12 changed files with 26 additions and 381 deletions

View File

@ -31,7 +31,7 @@
#include <limits>
#if defined(__MWERKS__) && wxUSE_UNICODE
#if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
#if __MWERKS__ < 0x4100
#include <wtime.h>
#endif
#endif

View File

@ -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
}

View File

@ -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;

View File

@ -57,7 +57,7 @@
#include <QuickTime/QuickTimeComponents.h>
#endif
#if !defined(__DARWIN__) || !defined(__LP64__)
#if !defined(__LP64__)
#define USE_QUICKTIME 1
#else
#define USE_QUICKTIME 0

View File

@ -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()) )

View File

@ -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 ) ;

View File

@ -398,9 +398,8 @@ wxFileTypeImpl::GetPrintCommand(
// we need to go straight to launch services
//
#if defined(__DARWIN__)
//on darwin, use launch services
#include <ApplicationServices/ApplicationServices.h>
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

View File

@ -405,7 +405,7 @@ void wxNotebook::MacSetupTabs()
info.name = cflabel ;
m_peer->SetData<ControlTabInfoRecV1>( 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() )

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -65,7 +65,7 @@
#include "wx/mac/private.h"
#if defined(__MWERKS__) && wxUSE_UNICODE
#if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
#if __MWERKS__ < 0x4100
#include <wtime.h>
#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 <Gestalt.h>
#endif
#if TARGET_API_MAC_CARBON
#include <CodeFragments.h>
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()
{
// TODO : try to find out ...
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
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()
{