-// window manager
-
-#if wxMAC_USE_QUICKDRAW
-
-GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
-
- return (GrafPtr) GetWindowPort( inWindowRef ) ;
-}
-
-void UMADisposeWindow( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
-
- DisposeWindow( inWindowRef ) ;
-}
-
-void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding )
-{
- SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title , encoding) ) ;
-}
-
-// appearance additions
-
-void UMASetControlTitle( ControlRef inControl , const wxString& title , wxFontEncoding encoding )
-{
- SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ;
-}
-
-void UMAActivateControl( ControlRef inControl )
-{
- ::ActivateControl( inControl ) ;
-}
-
-void UMAMoveControl( ControlRef inControl , short x , short y )
-{
- ::MoveControl( inControl , x , y ) ;
-}
-
-void UMASizeControl( ControlRef inControl , short x , short y )
-{
- ::SizeControl( inControl , x , y ) ;
-}
-
-void UMADeactivateControl( ControlRef inControl )
-{
- ::DeactivateControl( inControl ) ;
-}
-
-// 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 );
-}
-
-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;
-#endif
-}
-
-Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
-{
- GetControlBounds( theControl , bounds ) ;
-
- WindowRef tlwref = GetControlOwner( theControl ) ;
-
- wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
- if ( tlwwx != NULL )
- {
- ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ;
- HIPoint hiPoint = CGPointMake( 0 , 0 ) ;
- HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
- OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ;
- }
-
- return bounds ;
-}
-
-#endif
-
-#ifndef __LP64__
-
-wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport )
-{
- m_clip = NULL ;
- Setup( newport ) ;
-}
-
-wxMacPortStateHelper::wxMacPortStateHelper()
-{
- m_clip = NULL ;
-}
-
-void wxMacPortStateHelper::Setup( GrafPtr newport )
-{
- GetPort( &m_oldPort ) ;
- SetPort( newport ) ;
- SetOrigin(0, 0);
-
- wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ;
- m_clip = NewRgn() ;
- GetClip( m_clip );
- m_textFont = GetPortTextFont( (CGrafPtr) newport );
- m_textSize = GetPortTextSize( (CGrafPtr) newport );
- m_textStyle = GetPortTextFace( (CGrafPtr) newport );
- m_textMode = GetPortTextMode( (CGrafPtr) newport );
- GetThemeDrawingState( &m_drawingState ) ;
- m_currentPort = newport ;
-}
-
-void wxMacPortStateHelper::Clear()
-{
- if ( m_clip )
- {
- DisposeRgn( m_clip ) ;
- DisposeThemeDrawingState( m_drawingState ) ;
- m_clip = NULL ;
- }
-}
-
-wxMacPortStateHelper::~wxMacPortStateHelper()
-{
- if ( m_clip )
- {
- SetPort( m_currentPort ) ;
- SetClip( m_clip ) ;
- DisposeRgn( m_clip ) ;
- TextFont( m_textFont );
- TextSize( m_textSize );
- TextFace( m_textStyle );
- TextMode( m_textMode );
- SetThemeDrawingState( m_drawingState , true ) ;
- SetPort( m_oldPort ) ;
- }
-}
-
-#endif
-
-size_t UMAPutBytesCFRefCallback( void *info, const void *bytes, size_t count )
-{
- CFMutableDataRef data = (CFMutableDataRef) info;
- if ( data )
- {
- CFDataAppendBytes( data, (const UInt8*) bytes, count );
- }
- return count;
-}
-
-void UMAReleaseCFDataProviderCallback(void *info,
- const void *WXUNUSED(data),
- size_t WXUNUSED(count))
-{
- if ( info )
- CFRelease( (CFDataRef) info );
-}
-
-void UMAReleaseCFDataConsumerCallback( void *info )
-{
- if ( info )
- CFRelease( (CFDataRef) info );
-}
-
-CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data )
-{
- if ( data == NULL )
- return NULL;
-
- return CGDataProviderCreateWithCFData( data );
-}
-
-CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
-{
- if ( data == NULL )
- return NULL;
-
- return CGDataConsumerCreateWithCFData( data );
-}