- if ( m_macControl )
- {
- WindowRef window = GetMacRootWindow() ;
- if ( window )
- {
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- {
- wxMacDrawingHelper help( win ) ;
- // the mac control manager always assumes to have the origin at 0,0
- SetOrigin( 0 , 0 ) ;
-
- wxWindow* parent = GetParent() ;
- while ( parent )
- {
- if( parent->MacGetWindowData() )
- {
- ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
- break ;
- }
-
- if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
- {
- if ( ((wxControl*)parent)->m_macControl )
- SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
- break ;
- }
-
- parent = parent->GetParent() ;
- }
-
- UMADrawControl( m_macControl ) ;
- ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
- }
- }
- }
+ if ( (ControlHandle) m_macControl && MacGetRootWindow() )
+ {
+ wxClientDC dc(this) ;
+ wxMacPortSetter helper(&dc) ;
+/*
+ Rect r = { 0 , 0 , 32000 , 32000 } ;
+ ClipRect( &r ) ;
+*/
+ int x = 0 , y = 0;
+ wxWindow *parent = GetParent() ;
+ parent->MacWindowToRootWindow( &x,&y ) ;
+ RgnHandle clrgn = NewRgn() ;
+ RgnHandle insidergn = NewRgn() ;
+ wxSize size = parent->GetSize() ;
+ SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
+ size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(),
+ size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ;
+
+ CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , clrgn ) ;
+ SectRgn( clrgn , insidergn , clrgn ) ;
+ OffsetRgn( clrgn , x , y ) ;
+ SetClip( clrgn ) ;
+ DisposeRgn( clrgn ) ;
+ DisposeRgn( insidergn ) ;
+
+ wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
+ UMADrawControl( (ControlHandle) m_macControl ) ;
+ }