+ SendDestroyEvent();
+
+ m_isBeingDeleted = TRUE;
+
+ if ( m_peer )
+ {
+ // deleting a window while it is shown invalidates the region occupied by border or
+ // focus
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( IsShown() && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+ }
+
+#ifndef __WXUNIVERSAL__
+ // VS: make sure there's no wxFrame with last focus set to us:
+ for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
+ {
+ wxFrame *frame = wxDynamicCast(win, wxFrame);
+ if ( frame )
+ {
+ if ( frame->GetLastFocus() == this )
+ {
+ frame->SetLastFocus((wxWindow*)NULL);
+ }
+ break;
+ }
+ }
+#endif // __WXUNIVERSAL__
+
+ // destroy children before destroying this window itself
+ DestroyChildren();
+
+ // wxRemoveMacControlAssociation( this ) ;
+ // If we delete an item, we should initialize the parent panel,
+ // because it could now be invalid.
+ wxWindow *parent = GetParent() ;
+ if ( parent )
+ {
+ if (parent->GetDefaultItem() == (wxButton*) this)
+ parent->SetDefaultItem(NULL);
+ }
+ if ( m_peer && m_peer->Ok() )
+ {
+ // in case the callback might be called during destruction
+ wxRemoveMacControlAssociation( this) ;
+ // we currently are not using this hook
+ // ::SetControlColorProc( *m_peer , NULL ) ;
+ m_peer->Dispose() ;
+ }
+
+ if ( g_MacLastWindow == this )
+ {
+ g_MacLastWindow = NULL ;
+ }
+
+ wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ;
+ if ( frame )
+ {
+ if ( frame->GetLastFocus() == this )
+ frame->SetLastFocus( NULL ) ;
+ }
+
+ // delete our drop target if we've got one
+#if wxUSE_DRAG_AND_DROP
+ if ( m_dropTarget != NULL )
+ {
+ delete m_dropTarget;
+ m_dropTarget = NULL;
+ }
+#endif // wxUSE_DRAG_AND_DROP
+ delete m_peer ;
+}
+
+WXWidget wxWindowMac::GetHandle() const
+{
+ return (WXWidget) m_peer->GetControlRef() ;
+}
+
+
+void wxWindowMac::MacInstallEventHandler( WXWidget control )
+{
+ wxAssociateControlWithMacControl( (ControlRef) control , this ) ;
+ InstallControlEventHandler( (ControlRef) control , GetwxMacWindowEventHandlerUPP(),
+ GetEventTypeCount(eventList), eventList, this,
+ (EventHandlerRef *)&m_macControlEventHandler);
+
+}
+
+// Constructor
+bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") );
+
+ if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
+ return FALSE;
+
+ parent->AddChild(this);
+
+ m_windowVariant = parent->GetWindowVariant() ;
+
+ if ( m_macIsUserPane )
+ {
+ Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+
+ UInt32 features = 0
+ | kControlSupportsEmbedding
+// | kControlSupportsLiveFeedback
+// | kControlHasSpecialBackground
+// | kControlSupportsCalcBestRect
+// | kControlHandlesTracking
+ | kControlSupportsFocus
+// | kControlWantsActivate
+// | kControlWantsIdle
+ ;
+
+ m_peer = new wxMacControl() ;
+ ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() );
+
+
+ MacPostControlCreate(pos,size) ;
+#if !TARGET_API_MAC_OSX
+ m_peer->SetData<ControlUserPaneDrawUPP>(kControlEntireControl,kControlUserPaneDrawProcTag,&gControlUserPaneDrawUPP) ;
+ m_peer->SetData<ControlUserPaneHitTestUPP>(kControlEntireControl,kControlUserPaneHitTestProcTag,&gControlUserPaneHitTestUPP) ;
+ m_peer->SetData<ControlUserPaneTrackingUPP>(kControlEntireControl,kControlUserPaneTrackingProcTag,&gControlUserPaneTrackingUPP) ;
+ m_peer->SetData<ControlUserPaneIdleUPP>(kControlEntireControl,kControlUserPaneIdleProcTag,&gControlUserPaneIdleUPP) ;
+ m_peer->SetData<ControlUserPaneKeyDownUPP>(kControlEntireControl,kControlUserPaneKeyDownProcTag,&gControlUserPaneKeyDownUPP) ;
+ m_peer->SetData<ControlUserPaneActivateUPP>(kControlEntireControl,kControlUserPaneActivateProcTag,&gControlUserPaneActivateUPP) ;
+ m_peer->SetData<ControlUserPaneFocusUPP>(kControlEntireControl,kControlUserPaneFocusProcTag,&gControlUserPaneFocusUPP) ;
+ m_peer->SetData<ControlUserPaneBackgroundUPP>(kControlEntireControl,kControlUserPaneBackgroundProcTag,&gControlUserPaneBackgroundUPP) ;
+#endif
+ }
+#ifndef __WXUNIVERSAL__
+ // Don't give scrollbars to wxControls unless they ask for them
+ if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) ||
+ (IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL)))
+ {
+ MacCreateScrollBars( style ) ;
+ }
+#endif
+
+ wxWindowCreateEvent event(this);
+ GetEventHandler()->AddPendingEvent(event);
+
+ return TRUE;
+}
+
+void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
+{
+ wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
+
+ m_peer->SetReference( (long) this ) ;
+
+ MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() );
+
+ ControlRef container = (ControlRef) GetParent()->GetHandle() ;
+ wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
+ ::EmbedControl( m_peer->GetControlRef() , container ) ;
+
+ // adjust font, controlsize etc
+ DoSetWindowVariant( m_windowVariant ) ;
+
+#if !TARGET_API_MAC_OSX
+ // eventually we can fix some clipping issues be reactivating this hook
+ //if ( m_macIsUserPane )
+ // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
+#endif
+ m_peer->SetTitle( wxStripMenuCodes(m_label) ) ;
+
+ if (!m_macIsUserPane)
+ {
+ SetInitialBestSize(size);
+ }
+
+ SetCursor( *wxSTANDARD_CURSOR ) ;
+}
+
+void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
+{
+ // Don't assert, in case we set the window variant before
+ // the window is created
+ // wxASSERT( m_peer->Ok() ) ;
+
+ m_windowVariant = variant ;
+
+ if (m_peer == NULL || !m_peer->Ok())
+ return;
+
+ ControlSize size ;
+ ThemeFontID themeFont = kThemeSystemFont ;
+
+ // we will get that from the settings later
+ // and make this NORMAL later, but first
+ // we have a few calculations that we must fix
+
+ switch ( variant )
+ {
+ case wxWINDOW_VARIANT_NORMAL :
+ size = kControlSizeNormal;
+ themeFont = kThemeSystemFont ;
+ break ;
+ case wxWINDOW_VARIANT_SMALL :
+ size = kControlSizeSmall;
+ themeFont = kThemeSmallSystemFont ;
+ break ;
+ case wxWINDOW_VARIANT_MINI :
+ if (UMAGetSystemVersion() >= 0x1030 )
+ {
+ // not always defined in the headers
+ size = 3 ;
+ themeFont = 109 ;
+ }
+ else
+ {
+ size = kControlSizeSmall;
+ themeFont = kThemeSmallSystemFont ;
+ }
+ break ;
+ case wxWINDOW_VARIANT_LARGE :
+ size = kControlSizeLarge;
+ themeFont = kThemeSystemFont ;
+ break ;
+ default:
+ wxFAIL_MSG(_T("unexpected window variant"));
+ break ;
+ }
+ m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag,&size ) ;
+
+ wxFont font ;
+ font.MacCreateThemeFont( themeFont ) ;
+ SetFont( font ) ;
+}
+
+void wxWindowMac::MacUpdateControlFont()
+{
+ m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
+ Refresh() ;
+}
+
+bool wxWindowMac::SetFont(const wxFont& font)
+{
+ bool retval = wxWindowBase::SetFont( font ) ;
+
+ MacUpdateControlFont() ;
+
+ return retval;
+}
+
+bool wxWindowMac::SetForegroundColour(const wxColour& col )
+{
+ if ( !wxWindowBase::SetForegroundColour(col) )
+ return false ;
+
+ MacUpdateControlFont() ;
+
+ return true ;
+}
+
+bool wxWindowMac::SetBackgroundColour(const wxColour& col )
+{
+ if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
+ return false ;
+
+ wxBrush brush ;
+ wxColour newCol(GetBackgroundColour());
+ if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) )
+ {
+ brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ;
+ }
+ else if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ brush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
+ }
+ else
+ {
+ brush.SetColour( newCol ) ;
+ }
+ MacSetBackgroundBrush( brush ) ;
+
+ MacUpdateControlFont() ;
+
+ return true ;
+}
+
+void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
+{
+ m_macBackgroundBrush = brush ;
+ m_peer->SetBackground( brush ) ;
+}
+
+bool wxWindowMac::MacCanFocus() const
+{
+ // there is currently no way to determine whether the window is running in full keyboard
+ // access mode, therefore we cannot rely on these features, yet the only other way would be
+ // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
+ // in event handlers...
+ UInt32 features = 0 ;
+ m_peer->GetFeatures( & features ) ;
+ return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ;
+}
+
+
+void wxWindowMac::SetFocus()
+{
+ if ( AcceptsFocus() )
+ {
+
+ wxWindow* former = FindFocus() ;
+ if ( former == this )
+ return ;
+
+ OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
+ // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
+ // leave in case of an error
+ if ( err == errCouldntSetFocus )
+ return ;
+
+#if !TARGET_API_MAC_OSX
+ // emulate carbon events when running under carbonlib where they are not natively available
+ if ( former )
+ {
+ EventRef evRef = NULL ;
+ verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent ,
+ &evRef ) );
+
+ wxMacCarbonEvent cEvent( evRef ) ;
+ cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) former->GetHandle() ) ;
+ cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNoPart ) ;
+
+ wxMacWindowEventHandler( NULL , evRef , former ) ;
+ ReleaseEvent(evRef) ;
+ }
+ // send new focus event
+ {
+ EventRef evRef = NULL ;
+ verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent ,
+ &evRef ) );
+
+ wxMacCarbonEvent cEvent( evRef ) ;
+ cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) GetHandle() ) ;
+ cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNextPart ) ;
+
+ wxMacWindowEventHandler( NULL , evRef , this ) ;
+ ReleaseEvent(evRef) ;
+ }
+#endif
+ }
+}
+
+
+void wxWindowMac::DoCaptureMouse()
+{
+ wxTheApp->s_captureWindow = this ;
+}
+
+wxWindow* wxWindowBase::GetCapture()
+{
+ return wxTheApp->s_captureWindow ;
+}
+
+void wxWindowMac::DoReleaseMouse()
+{
+ wxTheApp->s_captureWindow = NULL ;
+}
+
+#if wxUSE_DRAG_AND_DROP
+
+void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
+{
+ if ( m_dropTarget != 0 ) {
+ delete m_dropTarget;
+ }
+
+ m_dropTarget = pDropTarget;
+ if ( m_dropTarget != 0 )
+ {
+ // TODO
+ }
+}
+
+#endif
+
+// Old style file-manager drag&drop
+void wxWindowMac::DragAcceptFiles(bool accept)
+{
+ // TODO
+}
+
+// Returns the size of the native control. In the case of the toplevel window
+// this is the content area root control
+
+void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
+ int& w, int& h) const
+{
+ Rect bounds ;
+ m_peer->GetRect( &bounds ) ;
+
+
+ x = bounds.left ;
+ y = bounds.top ;
+ w = bounds.right - bounds.left ;
+ h = bounds.bottom - bounds.top ;
+}
+
+// From a wx position / size calculate the appropriate size of the native control
+
+bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos,
+ const wxSize& size,
+ int& x, int& y,
+ int& w, int& h , bool adjustOrigin ) const
+{
+ // the desired size, minus the border pixels gives the correct size of the control
+
+ x = (int)pos.x;
+ y = (int)pos.y;
+ // todo the default calls may be used as soon as PostCreateControl Is moved here
+ w = size.x ; // WidthDefault( size.x );
+ h = size.y ; // HeightDefault( size.y ) ;
+#if !TARGET_API_MAC_OSX
+ GetParent()->MacWindowToRootWindow( &x , &y ) ;
+#endif
+
+ x += MacGetLeftBorderSize() ;
+ y += MacGetTopBorderSize() ;
+ w -= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
+ h -= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
+
+ if ( adjustOrigin )
+ AdjustForParentClientOrigin( x , y ) ;
+#if TARGET_API_MAC_OSX
+ // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
+ if ( ! GetParent()->IsTopLevel() )
+ {
+ x -= GetParent()->MacGetLeftBorderSize() ;
+ y -= GetParent()->MacGetTopBorderSize() ;
+ }
+#endif
+ return true ;
+}
+
+// Get window size (not client size)
+void wxWindowMac::DoGetSize(int *x, int *y) const
+{
+ // take the size of the control and add the borders that have to be drawn outside
+ int x1 , y1 , w1 , h1 ;
+
+ MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ;
+
+ w1 += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
+ h1 += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
+
+ if(x) *x = w1 ;
+ if(y) *y = h1 ;
+}
+
+// get the position of the bounds of this window in client coordinates of its parent
+void wxWindowMac::DoGetPosition(int *x, int *y) const
+{
+ int x1 , y1 , w1 ,h1 ;
+ MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ;
+ x1 -= MacGetLeftBorderSize() ;
+ y1 -= MacGetTopBorderSize() ;
+ // to non-client
+ #if !TARGET_API_MAC_OSX
+ if ( !GetParent()->IsTopLevel() )
+ {
+ Rect bounds ;
+ GetControlBounds( (ControlRef) GetParent()->GetHandle() , &bounds ) ;
+ x1 -= bounds.left ;
+ y1 -= bounds.top ;
+ }
+#endif
+ if ( !IsTopLevel() )
+ {
+ wxWindow *parent = GetParent();
+ if ( parent )
+ {
+ // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix
+ x1 += parent->MacGetLeftBorderSize() ;
+ y1 += parent->MacGetTopBorderSize() ;
+ // and now to client coordinates
+ wxPoint pt(parent->GetClientAreaOrigin());
+ x1 -= pt.x ;
+ y1 -= pt.y ;
+ }
+ }
+ if(x) *x = x1 ;
+ if(y) *y = y1 ;
+}
+
+void wxWindowMac::DoScreenToClient(int *x, int *y) const
+{
+ WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
+
+ wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ;
+
+ {
+ Point localwhere = {0,0} ;
+
+ if(x) localwhere.h = * x ;
+ if(y) localwhere.v = * y ;
+
+ QDGlobalToLocalPoint( GetWindowPort( window ) , &localwhere ) ;
+ if(x) *x = localwhere.h ;
+ if(y) *y = localwhere.v ;
+
+ }
+ MacRootWindowToWindow( x , y ) ;
+
+ wxPoint origin = GetClientAreaOrigin() ;
+ if(x) *x -= origin.x ;
+ if(y) *y -= origin.y ;
+}
+
+void wxWindowMac::DoClientToScreen(int *x, int *y) const
+{
+ WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
+ wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ;
+
+ wxPoint origin = GetClientAreaOrigin() ;
+ if(x) *x += origin.x ;
+ if(y) *y += origin.y ;
+
+ MacWindowToRootWindow( x , y ) ;
+
+ {
+ Point localwhere = { 0,0 };
+ if(x) localwhere.h = * x ;
+ if(y) localwhere.v = * y ;
+ QDLocalToGlobalPoint( GetWindowPort( window ) , &localwhere ) ;
+ if(x) *x = localwhere.h ;
+ if(y) *y = localwhere.v ;
+ }
+}
+
+void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const
+{
+ wxPoint origin = GetClientAreaOrigin() ;
+ if(x) *x += origin.x ;
+ if(y) *y += origin.y ;
+
+ MacWindowToRootWindow( x , y ) ;
+}
+
+void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const
+{
+ MacRootWindowToWindow( x , y ) ;
+
+ wxPoint origin = GetClientAreaOrigin() ;
+ if(x) *x -= origin.x ;
+ if(y) *y -= origin.y ;
+}
+
+void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
+{
+ #if TARGET_API_MAC_OSX
+ wxPoint pt ;
+ if ( x ) pt.x = *x ;
+ if ( y ) pt.y = *y ;
+
+ if ( !IsTopLevel() )
+ {
+ wxTopLevelWindowMac* top = MacGetTopLevelWindow();
+ if (top)
+ {
+ pt.x -= MacGetLeftBorderSize() ;
+ pt.y -= MacGetTopBorderSize() ;
+ wxMacControl::Convert( &pt , m_peer , top->m_peer ) ;
+ }
+ }
+
+ if ( x ) *x = (int) pt.x ;
+ if ( y ) *y = (int) pt.y ;
+ #else
+ if ( !IsTopLevel() )
+ {
+ Rect bounds ;
+ m_peer->GetRect( &bounds ) ;
+ if(x) *x += bounds.left - MacGetLeftBorderSize() ;
+ if(y) *y += bounds.top - MacGetTopBorderSize() ;
+ }
+#endif
+}
+
+void wxWindowMac::MacWindowToRootWindow( short *x , short *y ) const
+{
+ int x1 , y1 ;
+ if ( x ) x1 = *x ;
+ if ( y ) y1 = *y ;
+ MacWindowToRootWindow( &x1 , &y1 ) ;
+ if ( x ) *x = x1 ;
+ if ( y ) *y = y1 ;
+}
+
+void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
+{
+ #if TARGET_API_MAC_OSX
+ wxPoint pt ;
+ if ( x ) pt.x = *x ;
+ if ( y ) pt.y = *y ;
+
+ if ( !IsTopLevel() )
+ {
+ wxMacControl::Convert( &pt , MacGetTopLevelWindow()->m_peer , m_peer ) ;
+ pt.x += MacGetLeftBorderSize() ;
+ pt.y += MacGetTopBorderSize() ;
+ }
+
+ if ( x ) *x = (int) pt.x ;
+ if ( y ) *y = (int) pt.y ;
+ #else
+ if ( !IsTopLevel() )
+ {
+ Rect bounds ;
+ m_peer->GetRect( &bounds ) ;
+ if(x) *x -= bounds.left + MacGetLeftBorderSize() ;
+ if(y) *y -= bounds.top + MacGetTopBorderSize() ;
+ }
+#endif
+}
+
+void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const
+{
+ int x1 , y1 ;
+ if ( x ) x1 = *x ;
+ if ( y ) y1 = *y ;
+ MacRootWindowToWindow( &x1 , &y1 ) ;
+ if ( x ) *x = x1 ;
+ if ( y ) *y = y1 ;
+}
+
+void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
+{
+ RgnHandle rgn = NewRgn() ;
+ Rect content ;
+ if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
+ {
+ GetRegionBounds( rgn , &content ) ;
+ DisposeRgn( rgn ) ;
+ }
+ else
+ {
+ m_peer->GetRect( &content ) ;
+ }
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+#if !TARGET_API_MAC_OSX
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+#endif
+ left = content.left - structure.left ;
+ top = content.top - structure.top ;
+ right = structure.right - content.right ;
+ bottom = structure.bottom - content.bottom ;
+}
+
+wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const
+{
+ wxSize sizeTotal = size;
+
+ RgnHandle rgn = NewRgn() ;
+
+ Rect content ;
+
+ if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
+ {
+ GetRegionBounds( rgn , &content ) ;
+ DisposeRgn( rgn ) ;
+ }
+ else
+ {
+ m_peer->GetRect( &content ) ;
+ }
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+#if !TARGET_API_MAC_OSX
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+#endif
+
+ sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ;
+ sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ;
+
+ sizeTotal.x += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
+ sizeTotal.y += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
+
+ return sizeTotal;
+}
+
+
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+void wxWindowMac::DoGetClientSize(int *x, int *y) const
+{
+ int ww, hh;
+
+ RgnHandle rgn = NewRgn() ;
+ Rect content ;
+ if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
+ {
+ GetRegionBounds( rgn , &content ) ;
+ DisposeRgn( rgn ) ;
+ }
+ else
+ {
+ m_peer->GetRect( &content ) ;
+ }
+#if !TARGET_API_MAC_OSX
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+#endif
+ ww = content.right - content.left ;
+ hh = content.bottom - content.top ;
+ /*
+ ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
+ hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
+ */
+ /*
+ if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
+ {
+ int x1 = 0 ;
+ int y1 = 0 ;
+ int w ;
+ int h ;
+ GetSize( &w , &h ) ;
+
+ MacClientToRootWindow( &x1 , &y1 ) ;
+ MacClientToRootWindow( &w , &h ) ;
+
+ wxWindowMac *iter = (wxWindowMac*)this ;
+
+ int totW = 10000 , totH = 10000;
+ while( iter )
+ {
+ if ( iter->IsTopLevel() )
+ {
+ iter->GetSize( &totW , &totH ) ;
+ break ;
+ }
+
+ iter = iter->GetParent() ;
+ }
+
+ if (m_hScrollBar && m_hScrollBar->IsShown() )
+ {
+ hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
+ if ( h-y1 >= totH )
+ {
+ hh += 1 ;
+ }
+ }
+ if (m_vScrollBar && m_vScrollBar->IsShown() )
+ {
+ ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
+ if ( w-x1 >= totW )
+ {
+ ww += 1 ;
+ }
+ }
+ }
+ */
+ if (m_hScrollBar && m_hScrollBar->IsShown() )
+ {
+ hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
+ }
+ if (m_vScrollBar && m_vScrollBar->IsShown() )
+ {
+ ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
+ }
+ if(x) *x = ww;
+ if(y) *y = hh;
+
+}
+
+bool wxWindowMac::SetCursor(const wxCursor& cursor)
+{
+ if (m_cursor == cursor)
+ return FALSE;
+
+ if (wxNullCursor == cursor)
+ {
+ if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
+ return FALSE ;
+ }
+ else
+ {
+ if ( ! wxWindowBase::SetCursor( cursor ) )
+ return FALSE ;
+ }
+
+ wxASSERT_MSG( m_cursor.Ok(),
+ wxT("cursor must be valid after call to the base version"));
+
+
+ wxWindowMac *mouseWin = 0 ;
+ {
+ WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
+ CGrafPtr savePort ;
+ Boolean swapped = QDSwapPort( GetWindowPort( window ) , &savePort ) ;
+
+ // TODO If we ever get a GetCurrentEvent.. replacement for the mouse
+ // position, use it...
+
+ Point pt ;
+ GetMouse( &pt ) ;
+ ControlPartCode part ;
+ ControlRef control ;
+ control = wxMacFindControlUnderMouse( pt , window , &part ) ;
+ if ( control )
+ mouseWin = wxFindControlFromMacControl( control ) ;
+
+ if ( swapped )
+ QDSwapPort( savePort , NULL ) ;
+ }
+
+ if ( mouseWin == this && !wxIsBusy() )
+ {
+ m_cursor.MacInstall() ;
+ }
+
+ return TRUE ;
+}
+
+#if wxUSE_MENUS
+bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
+{
+ menu->SetInvokingWindow(this);
+ menu->UpdateUI();
+
+ if ( x == -1 && y == -1 )
+ {
+ wxPoint mouse = wxGetMousePosition();
+ x = mouse.x; y = mouse.y;
+ }
+ else
+ {
+ ClientToScreen( &x , &y ) ;
+ }
+
+ menu->MacBeforeDisplay( true ) ;
+ long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
+ if ( HiWord(menuResult) != 0 )
+ {
+ MenuCommand id ;
+ GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
+ wxMenuItem* item = NULL ;
+ wxMenu* realmenu ;
+ item = menu->FindItem(id, &realmenu) ;
+ if (item->IsCheckable())
+ {
+ item->Check( !item->IsChecked() ) ;
+ }
+ menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
+ }
+ menu->MacAfterDisplay( true ) ;
+
+ menu->SetInvokingWindow(NULL);
+
+ return TRUE;
+}
+#endif
+
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+#if wxUSE_TOOLTIPS
+
+void wxWindowMac::DoSetToolTip(wxToolTip *tooltip)
+{
+ wxWindowBase::DoSetToolTip(tooltip);
+
+ if ( m_tooltip )
+ m_tooltip->SetWindow(this);
+}
+
+#endif // wxUSE_TOOLTIPS
+
+void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
+{
+ // this is never called for a toplevel window, so we know we have a parent
+ int former_x , former_y , former_w, former_h ;
+
+ // Get true coordinates of former position
+ DoGetPosition( &former_x , &former_y ) ;
+ DoGetSize( &former_w , &former_h ) ;
+
+ wxWindow *parent = GetParent();
+ if ( parent )
+ {
+ wxPoint pt(parent->GetClientAreaOrigin());
+ former_x += pt.x ;
+ former_y += pt.y ;
+ }
+
+ int actualWidth = width;
+ int actualHeight = height;
+ int actualX = x;
+ int actualY = y;
+
+ if ((m_minWidth != -1) && (actualWidth < m_minWidth))
+ actualWidth = m_minWidth;
+ if ((m_minHeight != -1) && (actualHeight < m_minHeight))
+ actualHeight = m_minHeight;
+ if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
+ actualWidth = m_maxWidth;
+ if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
+ actualHeight = m_maxHeight;
+
+ bool doMove = false ;
+ bool doResize = false ;
+
+ if ( actualX != former_x || actualY != former_y )
+ {
+ doMove = true ;
+ }
+ if ( actualWidth != former_w || actualHeight != former_h )
+ {
+ doResize = true ;
+ }
+
+ if ( doMove || doResize )
+ {
+ // we don't adjust twice for the origin
+ Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
+ bool vis = m_peer->IsVisible();
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( vis && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ rect = r ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ UnionRgn( updateOuter , updateTotal , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+
+ // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
+ if ( vis )
+ m_peer->SetVisibility( false , true ) ;
+
+ m_peer->SetRect( &r ) ;
+ if ( vis )
+ m_peer->SetVisibility( true , true ) ;
+
+ MacRepositionScrollBars() ;
+ if ( doMove )
+ {
+ wxPoint point(actualX,actualY);
+ wxMoveEvent event(point, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event) ;
+ }
+ if ( doResize )
+ {
+ MacRepositionScrollBars() ;
+ wxSize size(actualWidth, actualHeight);
+ wxSizeEvent event(size, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+ }
+ }
+
+}
+
+wxSize wxWindowMac::DoGetBestSize() const
+{
+ if ( m_macIsUserPane || IsTopLevel() )
+ return wxWindowBase::DoGetBestSize() ;
+
+ Rect bestsize = { 0 , 0 , 0 , 0 } ;
+ int bestWidth, bestHeight ;
+ m_peer->GetBestRect( &bestsize ) ;
+
+ if ( EmptyRect( &bestsize ) )
+ {
+ bestsize.left = bestsize.top = 0 ;
+ bestsize.right = 16 ;
+ bestsize.bottom = 16 ;
+ if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
+ {
+ bestsize.bottom = 16 ;
+ }
+ else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
+ {
+ bestsize.bottom = 24 ;
+ }
+ else
+ {
+ // return wxWindowBase::DoGetBestSize() ;
+ }
+ }
+
+ bestWidth = bestsize.right - bestsize.left ;
+ bestHeight = bestsize.bottom - bestsize.top ;
+ if ( bestHeight < 10 )
+ bestHeight = 13 ;
+
+ return wxSize(bestWidth, bestHeight);
+}
+
+
+// set the size of the window: if the dimensions are positive, just use them,
+// but if any of them is equal to -1, it means that we must find the value for
+// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
+// which case -1 is a valid value for x and y)
+//
+// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
+// the width/height to best suit our contents, otherwise we reuse the current
+// width/height
+void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ // get the current size and position...
+ int currentX, currentY;
+ GetPosition(¤tX, ¤tY);
+
+ int currentW,currentH;
+ GetSize(¤tW, ¤tH);
+
+ // ... and don't do anything (avoiding flicker) if it's already ok
+ if ( x == currentX && y == currentY &&
+ width == currentW && height == currentH && ( height != -1 && width != -1 ) )
+ {
+ // TODO REMOVE
+ MacRepositionScrollBars() ; // we might have a real position shift
+ return;
+ }
+
+ if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ x = currentX;
+ if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ y = currentY;
+
+ AdjustForParentClientOrigin(x, y, sizeFlags);
+
+ wxSize size(-1, -1);
+ if ( width == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ {
+ size = DoGetBestSize();
+ width = size.x;
+ }
+ else
+ {
+ // just take the current one
+ width = currentW;
+ }
+ }
+
+ if ( height == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ {
+ if ( size.x == -1 )
+ {
+ size = DoGetBestSize();
+ }
+ //else: already called DoGetBestSize() above
+
+ height = size.y;
+ }
+ else
+ {
+ // just take the current one
+ height = currentH;
+ }
+ }
+
+ DoMoveWindow(x, y, width, height);
+
+}
+
+wxPoint wxWindowMac::GetClientAreaOrigin() const
+{
+ RgnHandle rgn = NewRgn() ;
+ Rect content ;
+ m_peer->GetRegion( kControlContentMetaPart , rgn ) ;
+ GetRegionBounds( rgn , &content ) ;
+ DisposeRgn( rgn ) ;
+#if !TARGET_API_MAC_OSX
+ // if the content rgn is empty / not supported
+ // don't attempt to correct the coordinates to wxWindow relative ones
+ if (!::EmptyRect( &content ) )
+ {
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+ }
+#endif
+
+ return wxPoint( content.left + MacGetLeftBorderSize( ) , content.top + MacGetTopBorderSize( ) );
+}
+
+void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight)
+{
+ if ( clientheight != -1 || clientheight != -1 )
+ {
+ int currentclientwidth , currentclientheight ;
+ int currentwidth , currentheight ;
+
+ GetClientSize( ¤tclientwidth , ¤tclientheight ) ;
+ GetSize( ¤twidth , ¤theight ) ;
+
+ DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth ,
+ currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ;
+ }
+}
+
+void wxWindowMac::SetTitle(const wxString& title)
+{
+ m_label = wxStripMenuCodes(title) ;
+
+ if ( m_peer && m_peer->Ok() )
+ {
+ m_peer->SetTitle( m_label ) ;
+ }
+ Refresh() ;
+}
+
+wxString wxWindowMac::GetTitle() const
+{
+ return m_label ;
+}
+
+bool wxWindowMac::Show(bool show)
+{
+ if ( !wxWindowBase::Show(show) )
+ return FALSE;
+
+ // TODO use visibilityChanged Carbon Event for OSX
+ bool former = MacIsReallyShown() ;
+
+ m_peer->SetVisibility( show , true ) ;
+ if ( former != MacIsReallyShown() )
+ MacPropagateVisibilityChanged() ;
+ return TRUE;
+}
+
+bool wxWindowMac::Enable(bool enable)
+{
+ wxASSERT( m_peer->Ok() ) ;
+ if ( !wxWindowBase::Enable(enable) )
+ return FALSE;
+
+ bool former = MacIsReallyEnabled() ;
+ m_peer->Enable( enable ) ;
+
+ if ( former != MacIsReallyEnabled() )
+ MacPropagateEnabledStateChanged() ;
+ return TRUE;
+}
+
+//
+// status change propagations (will be not necessary for OSX later )
+//
+
+void wxWindowMac::MacPropagateVisibilityChanged()
+{
+#if !TARGET_API_MAC_OSX
+ MacVisibilityChanged() ;
+
+ wxWindowListNode *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindowMac *child = node->GetData();
+ if ( child->IsShown() )
+ child->MacPropagateVisibilityChanged( ) ;
+ node = node->GetNext();
+ }
+#endif
+}
+
+void wxWindowMac::MacPropagateEnabledStateChanged( )
+{
+#if !TARGET_API_MAC_OSX
+ MacEnabledStateChanged() ;
+
+ wxWindowListNode *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindowMac *child = node->GetData();
+ if ( child->IsEnabled() )
+ child->MacPropagateEnabledStateChanged() ;
+ node = node->GetNext();
+ }
+#endif
+}
+
+void wxWindowMac::MacPropagateHiliteChanged( )
+{
+#if !TARGET_API_MAC_OSX
+ MacHiliteChanged() ;
+
+ wxWindowListNode *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindowMac *child = node->GetData();
+ // if ( child->IsEnabled() )
+ child->MacPropagateHiliteChanged() ;
+ node = node->GetNext();
+ }
+#endif
+}
+
+//
+// status change notifications
+//
+
+void wxWindowMac::MacVisibilityChanged()
+{
+}
+
+void wxWindowMac::MacHiliteChanged()
+{
+}
+
+void wxWindowMac::MacEnabledStateChanged()
+{
+}
+
+//
+// status queries on the inherited window's state
+//
+
+bool wxWindowMac::MacIsReallyShown()
+{
+ // only under OSX the visibility of the TLW is taken into account
+#if TARGET_API_MAC_OSX
+ if ( m_peer && m_peer->Ok() )
+ return m_peer->IsVisible();
+#endif
+ wxWindow* win = this ;
+ while( win->IsShown() )
+ {
+ if ( win->IsTopLevel() )
+ return true ;
+
+ win = win->GetParent() ;
+ if ( win == NULL )
+ return true ;
+
+ } ;
+ return false ;
+}
+
+bool wxWindowMac::MacIsReallyEnabled()
+{
+ return m_peer->IsEnabled() ;
+}
+
+bool wxWindowMac::MacIsReallyHilited()
+{
+ return m_peer->IsActive();
+}
+
+void wxWindowMac::MacFlashInvalidAreas()
+{
+#if TARGET_API_MAC_OSX
+ HIViewFlashDirtyArea( (WindowRef) MacGetTopLevelWindowRef() ) ;
+#endif
+}
+
+//
+//
+//
+
+int wxWindowMac::GetCharHeight() const
+{
+ wxClientDC dc ( (wxWindowMac*)this ) ;
+ return dc.GetCharHeight() ;
+}
+
+int wxWindowMac::GetCharWidth() const
+{
+ wxClientDC dc ( (wxWindowMac*)this ) ;
+ return dc.GetCharWidth() ;
+}
+
+void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
+ int *descent, int *externalLeading, const wxFont *theFont ) const
+{
+ const wxFont *fontToUse = theFont;
+ if ( !fontToUse )
+ fontToUse = &m_font;
+
+ wxClientDC dc( (wxWindowMac*) this ) ;
+ long lx,ly,ld,le ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
+ if ( externalLeading )
+ *externalLeading = le ;
+ if ( descent )
+ *descent = ld ;
+ if ( x )
+ *x = lx ;
+ if ( y )
+ *y = ly ;
+}
+
+/*
+ * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
+ * we always intersect with the entire window, not only with the client area
+ */
+
+void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
+{
+ if ( m_peer == NULL )
+ return ;
+
+#if TARGET_API_MAC_OSX
+ if ( rect == NULL )
+ m_peer->SetNeedsDisplay( true ) ;
+ else
+ {
+ RgnHandle update = NewRgn() ;
+ SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
+ SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
+ wxPoint origin = GetClientAreaOrigin() ;
+ OffsetRgn( update, origin.x , origin.y ) ;
+ // right now this is wx' window coordinates, as our native peer does not have borders, this is
+ // inset
+ OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+ m_peer->SetNeedsDisplay( true , update) ;
+ DisposeRgn( update ) ;
+ }
+#else
+/*
+ RgnHandle updateRgn = NewRgn() ;
+ if ( rect == NULL )
+ {
+ CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
+ }
+ else
+ {
+ SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
+ SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
+ }
+ InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
+ DisposeRgn(updateRgn) ;
+*/
+ if ( m_peer->IsVisible())
+ {
+ m_peer->SetVisibility( false , false ) ;
+ m_peer->SetVisibility( true , true ) ;
+ }
+ /*
+ if ( MacGetTopLevelWindow() == NULL )
+ return ;
+
+ if ( !m_peer->IsVisible())
+ return ;
+
+ wxPoint client = GetClientAreaOrigin();
+ int x1 = -client.x;
+ int y1 = -client.y;
+ int x2 = m_width - client.x;
+ int y2 = m_height - client.y;
+
+ if (IsKindOf( CLASSINFO(wxButton)))
+ {
+ // buttons have an "aura"
+ y1 -= 5;
+ x1 -= 5;
+ y2 += 5;
+ x2 += 5;
+ }
+
+ Rect clientrect = { y1, x1, y2, x2 };
+
+ if ( rect )
+ {
+ Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
+ SectRect( &clientrect , &r , &clientrect ) ;
+ }
+
+ if ( !EmptyRect( &clientrect ) )
+ {
+ int top = 0 , left = 0 ;
+
+ MacClientToRootWindow( &left , &top ) ;
+ OffsetRect( &clientrect , left , top ) ;
+
+ MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
+ }
+ */
+#endif
+}
+
+void wxWindowMac::Freeze()
+{
+#if TARGET_API_MAC_OSX
+ if ( !m_frozenness++ )
+ {
+ if ( m_peer && m_peer->Ok() )
+ m_peer->SetDrawingEnabled( false ) ;
+ }
+#endif
+}
+
+
+void wxWindowMac::Thaw()
+{
+#if TARGET_API_MAC_OSX
+ wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") );
+
+ if ( !--m_frozenness )
+ {
+ if ( m_peer && m_peer->Ok() )
+ {
+ m_peer->SetDrawingEnabled( true ) ;
+ m_peer->InvalidateWithChildren() ;
+ }
+ }
+#endif
+}
+
+void wxWindowMac::MacRedrawControl()
+{
+/*
+ if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
+ {
+#if TARGET_API_MAC_CARBON
+ Update() ;
+#else
+ wxClientDC dc(this) ;
+ wxMacPortSetter helper(&dc) ;
+ wxMacWindowClipper clipper(this) ;
+ wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
+ UMADrawControl( *m_peer ) ;
+#endif
+ }
+*/
+}
+
+/* TODO
+void wxWindowMac::OnPaint(wxPaintEvent& event)
+{
+ // why don't we skip that here ?
+}
+*/
+
+wxWindowMac *wxGetActiveWindow()
+{
+ // actually this is a windows-only concept
+ return NULL;
+}