X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03561a3c073b2453bd10a0a011c5a9b9e058eb6b..cd66beb3439485e49fac308f54dc10fe01c92895:/src/mac/carbon/utils.cpp?ds=sidebyside diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index ae1ef930d5..cd21f9999a 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -35,7 +35,7 @@ #include #include -#include "MoreFilesX.h" +// #include "MoreFilesX.h" #ifndef __DARWIN__ #include @@ -43,22 +43,9 @@ #endif #if wxUSE_GUI -#if TARGET_API_MAC_OSX #include -#else - #include - #include -#endif - -#ifdef __DARWIN__ #include -#else - #include - #include - #include -#endif - -#include "wx/mac/private/timer.h" + #include "wx/mac/private/timer.h" #endif // wxUSE_GUI #include "wx/evtloop.h" @@ -202,15 +189,12 @@ bool wxCheckForInterrupt(wxWindow *WXUNUSED(wnd)) void wxGetMousePosition( int* x, int* y ) { +#if wxMAC_USE_QUICKDRAW Point pt; -#if wxMAC_USE_CORE_GRAPHICS GetGlobalMouse(&pt); -#else - GetMouse( &pt ); - LocalToGlobal( &pt ); -#endif *x = pt.h; *y = pt.v; +#endif }; // Return true if we have a colour display @@ -222,10 +206,8 @@ bool wxColourDisplay() // Returns depth of screen int wxDisplayDepth() { - int theDepth = 8; -#if wxMAC_USE_CORE_GRAPHICS - theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID()); -#else +#if wxMAC_USE_QUICKDRAW + int theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID()); Rect globRect; SetRect(&globRect, -32760, -32760, 32760, 32760); GDHandle theMaxDevice; @@ -233,30 +215,22 @@ int wxDisplayDepth() theMaxDevice = GetMaxDevice(&globRect); if (theMaxDevice != NULL) theDepth = (**(**theMaxDevice).gdPMap).pixelSize; -#endif + return theDepth; +#else + return 32; +#endif } // Get size of display void wxDisplaySize(int *width, int *height) { -#if wxMAC_USE_CORE_GRAPHICS // TODO adapt for multi-displays CGRect bounds = CGDisplayBounds(CGMainDisplayID()); if ( width ) *width = (int)bounds.size.width ; if ( height ) *height = (int)bounds.size.height; -#else - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - - if (width != NULL) - *width = screenBits.bounds.right - screenBits.bounds.left; - - if (height != NULL) - *height = screenBits.bounds.bottom - screenBits.bounds.top; -#endif } void wxDisplaySizeMM(int *width, int *height) @@ -275,6 +249,8 @@ void wxDisplaySizeMM(int *width, int *height) void wxClientDisplayRect(int *x, int *y, int *width, int *height) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 +#if wxMAC_USE_QUICKDRAW + HIRect bounds ; HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, &bounds); @@ -286,6 +262,18 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) *width = bounds.size.width; if ( height ) *height = bounds.size.height; +#else + int w, h; + wxDisplaySize(&w,&h); + if ( x ) + *x = 0; + if ( y ) + *y = 24; + if ( width ) + *width = w; + if ( height ) + *height = h-24; +#endif #else Rect r; GetAvailableWindowPositioningBounds( GetMainDevice() , &r ); @@ -489,6 +477,8 @@ OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType in // Control Access Support // ---------------------------------------------------------------------------- +#if wxMAC_USE_QUICKDRAW + IMPLEMENT_DYNAMIC_CLASS( wxMacControl , wxObject ) wxMacControl::wxMacControl() @@ -564,13 +554,8 @@ OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions ) { -#if TARGET_API_MAC_OSX return SendEventToEventTargetWithOptions( event, HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions ); -#else - #pragma unused(inOptions) - return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) ); -#endif } OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions ) @@ -716,7 +701,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l if ( foreground != *wxBLACK ) { - fontStyle.foreColor = MAC_WXCOLORREF( foreground.GetPixel() ); + foreground.GetRGBColor( &fontStyle.foreColor ); fontStyle.flags |= kControlUseForeColorMask; } @@ -724,7 +709,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l #endif } -void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) ) +void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) ) { // TODO // setting up a color proc is not recommended anymore @@ -772,11 +757,7 @@ void wxMacControl::SetVisibility( bool visible , bool redraw ) bool wxMacControl::IsEnabled() const { -#if TARGET_API_MAC_OSX return IsControlEnabled( m_controlRef ); -#else - return IsControlActive( m_controlRef ); -#endif } bool wxMacControl::IsActive() const @@ -889,15 +870,10 @@ OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region ) OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other ) { -#if TARGET_API_MAC_OSX return HIViewSetZOrder( m_controlRef,above ? kHIViewZOrderAbove : kHIViewZOrderBelow, (other != NULL) ? other->m_controlRef : NULL); -#else - return 0; -#endif } -#if TARGET_API_MAC_OSX // SetNeedsDisplay would not invalidate the children static void InvalidateControlAndChildren( HIViewRef control ) { @@ -920,13 +896,10 @@ static void InvalidateControlAndChildren( HIViewRef control ) InvalidateControlAndChildren( child ); } } -#endif void wxMacControl::InvalidateWithChildren() { -#if TARGET_API_MAC_OSX InvalidateControlAndChildren( m_controlRef ); -#endif } void wxMacControl::ScrollRect( wxRect *r , int dx , int dy ) @@ -1034,11 +1007,7 @@ wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer, if ( gDataBrowserItemNotificationUPP == NULL ) { gDataBrowserItemNotificationUPP = -#if TARGET_API_MAC_OSX (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc); -#else - NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc); -#endif } DataBrowserCallbacks callbacks; @@ -1623,9 +1592,7 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp columnDesc.propertyDesc.propertyType = colType; columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn; columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; -#endif verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) ); @@ -1930,41 +1897,12 @@ OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable ) return ::SetTabEnabled( m_controlRef , tabNo , enable ); } +#endif + // // Quartz Support // -// snippets from Sketch Sample from Apple : - -#define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc" - -/* - This function locates, opens, and returns the profile reference for the calibrated - Generic RGB color space. It is up to the caller to call CMCloseProfile when done - with the profile reference this function returns. -*/ -CMProfileRef wxMacOpenGenericProfile() -{ - static CMProfileRef cachedRGBProfileRef = NULL; - - // we only create the profile reference once - if (cachedRGBProfileRef == NULL) - { - CMProfileLocation loc; - - loc.locType = cmPathBasedProfile; - strcpy(loc.u.pathLoc.path, kGenericRGBProfilePathStr); - - verify_noerr( CMOpenProfile(&cachedRGBProfileRef, &loc) ); - } - - // clone the profile reference so that the caller has their own reference, not our cached one - if (cachedRGBProfileRef) - CMCloneProfileRef(cachedRGBProfileRef); - - return cachedRGBProfileRef; -} - /* Return the generic RGB color space. This is a 'get' function and the caller should not release the returned value unless the caller retains it first. Usually callers @@ -1981,29 +1919,19 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace() if (genericRGBColorSpace == NULL) { - if ( UMAGetSystemVersion() >= 0x1040 ) - { - genericRGBColorSpace.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) ); - } - else - { - CMProfileRef genericRGBProfile = wxMacOpenGenericProfile(); - - if (genericRGBProfile) - { - genericRGBColorSpace.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile) ); - - wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") ); - - // we opened the profile so it is up to us to close it - CMCloseProfile(genericRGBProfile); - } - } + genericRGBColorSpace.Set( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) ); } return genericRGBColorSpace; } +CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush ) +{ + CGColorRef color ; + HIThemeBrushCreateCGColor( brush, &color ); + return color; +} + #ifndef __LP64__ wxMacPortSaver::wxMacPortSaver( GrafPtr port ) @@ -2018,9 +1946,10 @@ wxMacPortSaver::~wxMacPortSaver() } #endif +#if wxMAC_USE_QUICKDRAW + void wxMacGlobalToLocal( WindowRef window , Point*pt ) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 HIPoint p = CGPointMake( pt->h, pt->v ); HIViewRef contentView ; // TODO check toolbar offset @@ -2028,14 +1957,10 @@ void wxMacGlobalToLocal( WindowRef window , Point*pt ) HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView ); pt->h = p.x; pt->v = p.y; -#else - QDGlobalToLocalPoint( GetWindowPort(window), pt ) ; -#endif } void wxMacLocalToGlobal( WindowRef window , Point*pt ) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 HIPoint p = CGPointMake( pt->h, pt->v ); HIViewRef contentView ; // TODO check toolbar offset @@ -2043,9 +1968,7 @@ void wxMacLocalToGlobal( WindowRef window , Point*pt ) HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL ); pt->h = p.x; pt->v = p.y; -#else - QDLocalToGlobalPoint( GetWindowPort(window), pt ) ; -#endif } +#endif #endif // wxUSE_GUI