-// quickdraw
-
-#if !TARGET_CARBON
-
-int gPrOpenCounter = 0 ;
-
-OSStatus UMAPrOpen()
-{
- OSErr err = noErr ;
-
- ++gPrOpenCounter ;
-
- if ( gPrOpenCounter == 1 )
- {
- PrOpen() ;
- err = PrError() ;
- wxASSERT( err == noErr ) ;
- }
-
- return err ;
-}
-
-OSStatus UMAPrClose()
-{
- OSErr err = noErr ;
-
- wxASSERT( gPrOpenCounter >= 1 ) ;
-
- if ( gPrOpenCounter == 1 )
- {
- PrClose() ;
- err = PrError() ;
- wxASSERT( err == noErr ) ;
- }
-
- --gPrOpenCounter ;
-
- return err ;
-}
-
-pascal QDGlobalsPtr GetQDGlobalsPtr() ;
-pascal QDGlobalsPtr GetQDGlobalsPtr()
-{
- return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
-}
-
-#endif
-
-void UMAShowWatchCursor()
-{
- SetThemeCursor(kThemeWatchCursor);
-}
-
-void UMAShowArrowCursor()
-{
- SetThemeCursor(kThemeArrowCursor);
-}
-
-// window manager
-
-GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
-
-#if TARGET_CARBON
- return (GrafPtr) GetWindowPort( inWindowRef ) ;
-#else
- return (GrafPtr) inWindowRef ;
-#endif
-}
-
-void UMADisposeWindow( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
-
- DisposeWindow( inWindowRef ) ;
-}
-
-void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding )
-{
-#if TARGET_CARBON
- SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title , encoding) ) ;
-
-#else
- Str255 ptitle ;
- wxMacStringToPascal( title , ptitle ) ;
- SetWTitle( inWindowRef , ptitle ) ;
-#endif
-}
-
-// appearance additions
-
-void UMASetControlTitle( ControlRef inControl , const wxString& title , wxFontEncoding encoding )
-{
-#if TARGET_CARBON
- SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ;
-
-#else
- Str255 ptitle ;
- wxMacStringToPascal( title , ptitle ) ;
- SetControlTitle( inControl , ptitle ) ;
-#endif
-}
-
-void UMAActivateControl( ControlRef inControl )
-{
-#if TARGET_API_MAC_OSX
- ::ActivateControl( inControl ) ;
-
-#else
- // we have to add the control after again to the update rgn
- // otherwise updates get lost
- if ( !IsControlActive( inControl ) )
- {
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- SetControlVisibility( inControl , false , false ) ;
-
- ::ActivateControl( inControl ) ;
-
- if ( visible )
- {
- SetControlVisibility( inControl , true , false ) ;
-
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), UMAGetControlBoundsInWindowCoords(inControl, &ctrlBounds) ) ;
- }
- }
-#endif
-}
-
-void UMAMoveControl( ControlRef inControl , short x , short y )
-{
-#if TARGET_API_MAC_OSX
- ::MoveControl( inControl , x , y ) ;
-
-#else
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- {
- SetControlVisibility( inControl , false , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), GetControlBounds(inControl, &ctrlBounds) ) ;
- }
-
- ::MoveControl( inControl , x , y ) ;
-
- if ( visible )
- {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), GetControlBounds(inControl, &ctrlBounds) ) ;
- }
-#endif
-}
-
-void UMASizeControl( ControlRef inControl , short x , short y )
-{
-#if TARGET_API_MAC_OSX
- ::SizeControl( inControl , x , y ) ;
-
-#else
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- {
- SetControlVisibility( inControl , false , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), GetControlBounds(inControl, &ctrlBounds) ) ;
- }
-
- ::SizeControl( inControl , x , y ) ;
-
- if ( visible )
- {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), GetControlBounds(inControl, &ctrlBounds) ) ;
- }
-#endif
-}
-
-void UMADeactivateControl( ControlRef inControl )
-{
-#if TARGET_API_MAC_OSX
- ::DeactivateControl( inControl ) ;
-
-#else
- // we have to add the control after again to the update rgn
- // otherwise updates get lost
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- SetControlVisibility( inControl , false , false ) ;
-
- ::DeactivateControl( inControl ) ;
-
- if ( visible )
- {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect( GetControlOwner(inControl), UMAGetControlBoundsInWindowCoords(inControl, &ctrlBounds) ) ;
- }
-#endif
-}
-
-// shows the control and adds the region to the update region
-void UMAShowControl( ControlRef inControl )
-{
- SetControlVisibility( inControl , true , false ) ;
- HIViewSetNeedsDisplay( inControl, true );
-}
-
-// hides the control and adds the region to the update region
-void UMAHideControl( ControlRef inControl )
-{
- SetControlVisibility( inControl , false , false ) ;
- HIViewSetNeedsDisplay( inControl, true );
-}
-
-// keyboard focus
-OSErr UMASetKeyboardFocus( WindowPtr inWindow,
- ControlRef inControl,
- ControlFocusPart inPart )
-{
- OSErr err = noErr;
-#ifndef __LP64__
- GrafPtr port ;
-
- GetPort( &port ) ;
- SetPortWindowPort( inWindow ) ;
-#endif
-
- err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
-#ifndef __LP64__
- SetPort( port ) ;
-#endif
-
- return err ;
-}
-
-bool UMAIsWindowFloating( WindowRef inWindow )
-{
- WindowClass cl ;
-
- GetWindowClass( inWindow , &cl ) ;
- return cl == kFloatingWindowClass ;
-}
-
-bool UMAIsWindowModal( WindowRef inWindow )
-{
- WindowClass cl ;
-
- GetWindowClass( inWindow , &cl ) ;
- return cl < kFloatingWindowClass ;
-}
-
-// others
-
-void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
-{
- if ( inWindowRef )
- {
-// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
-// if ( inActivate != isHighlighted )
-#ifndef __LP64__
- GrafPtr port ;
- GetPort( &port ) ;
- SetPortWindowPort( inWindowRef ) ;
-#endif
- HiliteWindow( inWindowRef , inActivate ) ;
- ControlRef control = NULL ;
- ::GetRootControl( inWindowRef , &control ) ;
- if ( control )
- {
- if ( inActivate )
- UMAActivateControl( control ) ;
- else
- UMADeactivateControl( control ) ;
- }
-#ifndef __LP64__
- SetPort( port ) ;
-#endif
- }
-}
-
-OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
-{
-#ifndef __LP64__
- return ::DrawThemePlacard( inRect , inState ) ;
-#else
- return noErr;