- event.m_x += origin.x ;
- event.m_y += origin.y ;
-*/
-
- event.m_timeStamp = ev->when;
- event.SetEventObject(this);
- if ( wxTheApp->s_captureWindow )
- {
- int x = event.m_x ;
- int y = event.m_y ;
- wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ;
- event.m_x = x ;
- event.m_y = y ;
- wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ;
- if ( ev->what == mouseUp )
- {
- wxTheApp->s_captureWindow = NULL ;
- if ( wxBusyCursorCount == 0 )
- {
- m_cursor.MacInstall() ;
- }
- }
- }
- else
- {
- MacDispatchMouseEvent( event ) ;
- }
-}
-
-void wxWindow::MacMouseDown( EventRecord *ev , short part)
-{
- MacFireMouseEvent( ev ) ;
-}
-
-void wxWindow::MacMouseUp( EventRecord *ev , short part)
-{
- WindowPtr frontWindow ;
- switch (part)
- {
- case inContent:
- {
- MacFireMouseEvent( ev ) ;
- }
- break ;
- }
-}
-
-void wxWindow::MacMouseMoved( EventRecord *ev , short part)
-{
- WindowPtr frontWindow ;
- switch (part)
- {
- case inContent:
- {
- MacFireMouseEvent( ev ) ;
- }
- break ;
- }
-}
-void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating )
-{
- wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating);
- event.m_timeStamp = ev->when ;
- event.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(event);
-
- UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ;
-}
-
-void wxWindow::MacRedraw( RgnHandle updatergn , long time)
-{
- // updatergn is always already clipped to our boundaries
- WindowRef window = GetMacRootWindow() ;
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- {
- wxMacDrawingClientHelper focus( this ) ;
- if ( focus.Ok() )
- {
- WindowRef window = GetMacRootWindow() ;
- bool eraseBackground = false ;
- if ( m_macWindowData )
- eraseBackground = true ;
- if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
- {
- UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
- }
- else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
- {
- // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
- // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
- // either a non gray background color or a non control window
-
-
- wxWindow* parent = GetParent() ;
- while( parent )
- {
- if ( parent->GetMacRootWindow() != window )
- {
- // we are in a different window on the mac system
- parent = NULL ;
- break ;
- }
-
- if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() )
- {
- if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
- {
- // if we have any other colours in the hierarchy
- RGBBackColor( &parent->m_backgroundColour.GetPixel()) ;
- break ;
- }
- // if we have the normal colours in the hierarchy but another control etc. -> use it's background
- if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
- {
- ApplyThemeBackground(kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true);
- break ;
- }
- }
- else
- {
- parent = NULL ;
- break ;
- }
- parent = parent->GetParent() ;
- }
- if ( !parent )
- {
- // if there is nothing special -> use default
- UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ;
- }
- }
- else
- {
- RGBBackColor( &m_backgroundColour.GetPixel()) ;
- }
- if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
- eraseBackground = true ;
- SetClip( updatergn ) ;
- if ( eraseBackground )
- {
- EraseRgn( updatergn ) ;
- }
- }
- }
-
-
- m_updateRegion = updatergn ;
- wxPaintEvent event;
- event.m_timeStamp = time ;
- event.SetEventObject(this);
-
- wxPaintEvent event2( event ) ;
- GetEventHandler()->ProcessEvent(event);
- MacPaint( event2 ) ;
-
- RgnHandle childupdate = NewRgn() ;
-
- for (wxNode *node = GetChildren().First(); node; node = node->Next())
- {
- wxWindow *child = (wxWindow*)node->Data();
- int width ;
- int height ;
-
- child->GetClientSize( &width , &height ) ;
-
- SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x +width , child->m_y + height ) ;
- SectRgn( childupdate , m_updateRegion.GetWXHRGN() , childupdate ) ;
- OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
- if ( child->GetMacRootWindow() == window && child->IsShown() )
- {
- // because dialogs may also be children
- child->MacRedraw( childupdate , time ) ;
- }
- }
- DisposeRgn( childupdate ) ;
- // eventually a draw grow box here
-}
-
-void wxWindow::MacUpdateImmediately()
-{
- WindowRef window = GetMacRootWindow() ;
- if ( window )
- {
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- BeginUpdate( window ) ;
- if ( win )
- {
- #if ! TARGET_CARBON
- if ( !EmptyRgn( window->visRgn ) )
- #endif
- {
- win->MacRedraw( window->visRgn , wxTheApp->sm_lastMessageTime ) ;
-/*
- {
- wxMacDrawingHelper help( win ) ;
- SetOrigin( 0 , 0 ) ;
- UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
- UMAUpdateControls( window , window->visRgn ) ;
- UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
- }
-*/
- }
- }
- EndUpdate( window ) ;
- }
-}
-
-void wxWindow::MacUpdate( EventRecord *ev )
-{
- WindowRef window = (WindowRef) ev->message ;
- wxWindow * win = wxFindWinFromMacWindow( window ) ;
-
- BeginUpdate( window ) ;
- if ( win )
- {
- // if windowshade gives incompatibility , take the follwing out
- #if ! TARGET_CARBON
- if ( !EmptyRgn( window->visRgn ) )
- #endif
- {
- MacRedraw( window->visRgn , ev->when ) ;
- /*
- {
- wxMacDrawingHelper help( this ) ;
- SetOrigin( 0 , 0 ) ;
- UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
- UMAUpdateControls( window , window->visRgn ) ;
- UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ;
- }
- */
- }
- }
- EndUpdate( window ) ;
-}
-
-WindowRef wxWindow::GetMacRootWindow() const
-{
- WindowRef window = NULL ;
- wxWindow *iter = (wxWindow*)this ;
-
- while( iter )
- {
- if ( iter->m_macWindowData )
- return iter->m_macWindowData->m_macWindow ;
-
- iter = iter->GetParent() ;
- }
- wxASSERT_MSG( 1 , "No valid mac root window" ) ;
- return NULL ;
-}
-
-void wxWindow::MacCreateScrollBars( long style )
-{
- wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ;
- bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ;
-
- if ( style & wxVSCROLL )
- {
- m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0),
- wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL);
-// m_vScrollBar->PushEventHandler( this ) ;
- }
- if ( style & wxHSCROLL )
- {
- m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ),
- wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL);
-// m_hScrollBar->PushEventHandler( this ) ;
- }
-
- // because the create does not take into account the client area origin
- MacRepositionScrollBars() ; // we might have a real position shift
-}
-
-void wxWindow::MacRepositionScrollBars()
-{
- bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ;
-
- if ( m_vScrollBar )
- {
- m_vScrollBar->SetSize( m_width-MAC_SCROLLBAR_SIZE, 0, MAC_SCROLLBAR_SIZE, m_height - adjust , wxSIZE_USE_EXISTING);
- }
- if ( m_hScrollBar )
- {
- m_hScrollBar->SetSize( 0 , m_height-MAC_SCROLLBAR_SIZE ,m_width - adjust, MAC_SCROLLBAR_SIZE, wxSIZE_USE_EXISTING);
- }
-}
-
-void wxWindow::MacKeyDown( EventRecord *ev )
-{
-}
-
-
-bool wxWindow::AcceptsFocus() const
+ width += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
+ height += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
+
+ DoSetSize( -1 , -1 , width , height ) ;
+ }
+}
+
+
+wxWindowMac* wxWindowMac::s_lastMouseWindow = NULL ;
+
+bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin )
+{
+ if ( IsTopLevel() )
+ {
+ if ((point.x < 0) || (point.y < 0) ||
+ (point.x > (m_width)) || (point.y > (m_height)))
+ return FALSE;
+ }
+ else
+ {
+ if ((point.x < m_x) || (point.y < m_y) ||
+ (point.x > (m_x + m_width)) || (point.y > (m_y + m_height)))
+ return FALSE;
+ }
+
+ WindowRef window = (WindowRef) MacGetRootWindow() ;
+
+ wxPoint newPoint( point ) ;
+
+ if ( !IsTopLevel() )
+ {
+ newPoint.x -= m_x;
+ newPoint.y -= m_y;
+ }
+
+ for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->GetData();
+ // added the m_isShown test --dmazzoni
+ if ( child->MacGetRootWindow() == window && child->m_isShown )
+ {
+ if (child->MacGetWindowFromPointSub(newPoint , outWin ))
+ return TRUE;
+ }
+ }
+
+ *outWin = this ;
+ return TRUE;
+}
+
+bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin )
+{
+ WindowRef window ;
+
+ Point pt = { screenpoint.y , screenpoint.x } ;
+ if ( ::FindWindow( pt , &window ) == 3 )
+ {
+
+ wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
+ if ( win )
+ {
+ // No, this yields the CLIENT are, we need the whole frame. RR.
+ // point = win->ScreenToClient( point ) ;
+
+ GrafPtr port;
+ ::GetPort( &port ) ;
+ ::SetPort( UMAGetWindowPort( window ) ) ;
+ ::GlobalToLocal( &pt ) ;
+ ::SetPort( port ) ;
+
+ wxPoint point( pt.h, pt.v ) ;
+
+ return win->MacGetWindowFromPointSub( point , outWin ) ;
+ }
+ }
+ return FALSE ;
+}
+
+static wxWindow *gs_lastWhich = NULL;
+
+bool wxWindowMac::MacSetupCursor( const wxPoint& pt)
+{
+ // first trigger a set cursor event
+
+ wxPoint clientorigin = GetClientAreaOrigin() ;
+ wxSize clientsize = GetClientSize() ;
+ wxCursor cursor ;
+ if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) )
+ {
+ wxSetCursorEvent event( pt.x , pt.y );
+
+ bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
+ if ( processedEvtSetCursor && event.HasCursor() )
+ {
+ cursor = event.GetCursor() ;
+ }
+ else
+ {
+
+ // the test for processedEvtSetCursor is here to prevent using m_cursor
+ // if the user code caught EVT_SET_CURSOR() and returned nothing from
+ // it - this is a way to say that our cursor shouldn't be used for this
+ // point
+ if ( !processedEvtSetCursor && m_cursor.Ok() )
+ {
+ cursor = m_cursor ;
+ }
+ if ( wxIsBusy() )
+ {
+ }
+ else
+ {
+ if ( !GetParent() )
+ cursor = *wxSTANDARD_CURSOR ;
+ }
+ }
+ if ( cursor.Ok() )
+ cursor.MacInstall() ;
+ }
+ return cursor.Ok() ;
+}
+
+bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
+{
+ if ((event.m_x < m_x) || (event.m_y < m_y) ||
+ (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height)))
+ return FALSE;
+
+
+ if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */)
+ return FALSE ;
+
+ WindowRef window = (WindowRef) MacGetRootWindow() ;
+
+ event.m_x -= m_x;
+ event.m_y -= m_y;
+
+ int x = event.m_x ;
+ int y = event.m_y ;
+
+ for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->GetData();
+ if ( child->MacGetRootWindow() == window && child->IsShown() && child->IsEnabled() )
+ {
+ if (child->MacDispatchMouseEvent(event))
+ return TRUE;
+ }
+ }
+
+ wxWindow* cursorTarget = this ;
+ wxPoint cursorPoint( x , y ) ;
+
+ while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
+ {
+ cursorTarget = cursorTarget->GetParent() ;
+ if ( cursorTarget )
+ cursorPoint += cursorTarget->GetPosition() ;
+ }
+ event.m_x = x ;
+ event.m_y = y ;
+ event.SetEventObject( this ) ;
+
+ if ( event.GetEventType() == wxEVT_LEFT_DOWN )
+ {
+ // set focus to this window
+ if (AcceptsFocus() && FindFocus()!=this)
+ SetFocus();
+ }
+
+#if wxUSE_TOOLTIPS
+ if ( event.GetEventType() == wxEVT_MOTION
+ || event.GetEventType() == wxEVT_ENTER_WINDOW
+ || event.GetEventType() == wxEVT_LEAVE_WINDOW )
+ wxToolTip::RelayEvent( this , event);
+#endif // wxUSE_TOOLTIPS
+
+ if (gs_lastWhich != this)
+ {
+ gs_lastWhich = this;
+
+ // Double clicks must always occur on the same window
+ if (event.GetEventType() == wxEVT_LEFT_DCLICK)
+ event.SetEventType( wxEVT_LEFT_DOWN );
+ if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
+ event.SetEventType( wxEVT_RIGHT_DOWN );
+
+ // Same for mouse up events
+ if (event.GetEventType() == wxEVT_LEFT_UP)
+ return TRUE;
+ if (event.GetEventType() == wxEVT_RIGHT_UP)
+ return TRUE;
+ }
+
+ GetEventHandler()->ProcessEvent( event ) ;
+
+ return TRUE;
+}
+
+wxString wxWindowMac::MacGetToolTipString( wxPoint &pt )
+{
+ if ( m_tooltip )
+ {
+ return m_tooltip->GetTip() ;
+ }
+ return "" ;
+}
+
+void wxWindowMac::Update()
+{
+ wxTopLevelWindowMac* win = MacGetTopLevelWindow( ) ;
+ if ( win )
+ {
+ win->MacUpdate( 0 ) ;
+#if TARGET_API_MAC_CARBON
+ if ( QDIsPortBuffered( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) ) )
+ {
+ QDFlushPortBuffer( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) , NULL ) ;
+ }
+#endif
+ }
+}
+
+wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const
+{
+ wxTopLevelWindowMac* win = NULL ;
+ WindowRef window = (WindowRef) MacGetRootWindow() ;
+ if ( window )
+ {
+ win = wxFindWinFromMacWindow( window ) ;
+ }
+ return win ;
+}
+
+const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings )
+{
+ RgnHandle visRgn = NewRgn() ;
+ RgnHandle tempRgn = NewRgn() ;
+ RgnHandle tempStaticBoxRgn = NewRgn() ;
+
+ SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ;
+
+ //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
+ if ( IsKindOf( CLASSINFO( wxStaticBox ) ) )
+ {
+ int borderTop = 14 ;
+ int borderOther = 4 ;
+
+ SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ;
+ DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ;
+ }
+
+ if ( !IsTopLevel() )
+ {
+ wxWindow* parent = GetParent() ;
+ while( parent )
+ {
+ wxSize size = parent->GetSize() ;
+ int x , y ;
+ x = y = 0 ;
+ parent->MacWindowToRootWindow( &x, &y ) ;
+ MacRootWindowToWindow( &x , &y ) ;
+
+ SetRectRgn( tempRgn ,
+ x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
+ x + size.x - parent->MacGetRightBorderSize(),
+ y + size.y - parent->MacGetBottomBorderSize()) ;
+
+ SectRgn( visRgn , tempRgn , visRgn ) ;
+ if ( parent->IsTopLevel() )
+ break ;
+ parent = parent->GetParent() ;
+ }
+ }
+ if ( respectChildrenAndSiblings )
+ {
+ if ( GetWindowStyle() & wxCLIP_CHILDREN )
+ {
+ for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->GetData();
+
+ if ( !child->IsTopLevel() && child->IsShown() )
+ {
+ SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) )
+ {
+ int borderTop = 14 ;
+ int borderOther = 4 ;
+
+ SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ;
+ DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
+ }
+ DiffRgn( visRgn , tempRgn , visRgn ) ;
+ }
+ }
+ }
+
+ if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() )
+ {
+ bool thisWindowThrough = false ;
+ for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ wxWindowMac *sibling = (wxWindowMac*)node->GetData();
+ if ( sibling == this )
+ {
+ thisWindowThrough = true ;
+ continue ;
+ }
+ if( !thisWindowThrough )
+ {
+ continue ;
+ }
+
+ if ( !sibling->IsTopLevel() && sibling->IsShown() )
+ {
+ SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ;
+ if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) )
+ {
+ int borderTop = 14 ;
+ int borderOther = 4 ;
+
+ SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ;
+ DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
+ }
+ DiffRgn( visRgn , tempRgn , visRgn ) ;
+ }
+ }
+ }
+ }
+ m_macVisibleRegion = visRgn ;
+ DisposeRgn( visRgn ) ;
+ DisposeRgn( tempRgn ) ;
+ DisposeRgn( tempStaticBoxRgn ) ;
+ return m_macVisibleRegion ;
+}
+
+void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
+{
+ RgnHandle updatergn = (RgnHandle) updatergnr ;
+ // updatergn is always already clipped to our boundaries
+ // it is in window coordinates, not in client coordinates
+
+ WindowRef window = (WindowRef) MacGetRootWindow() ;
+
+ {
+ // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
+ RgnHandle ownUpdateRgn = NewRgn() ;
+ CopyRgn( updatergn , ownUpdateRgn ) ;
+
+ SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ;
+
+ // newupdate is the update region in client coordinates
+ RgnHandle newupdate = NewRgn() ;
+ wxSize point = GetClientSize() ;
+ wxPoint origin = GetClientAreaOrigin() ;
+ SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ;
+ SectRgn( newupdate , ownUpdateRgn , newupdate ) ;
+ OffsetRgn( newupdate , -origin.x , -origin.y ) ;
+ m_updateRegion = newupdate ;
+ DisposeRgn( newupdate ) ; // it's been cloned to m_updateRegion
+
+ if ( erase && !EmptyRgn(ownUpdateRgn) )
+ {
+ wxWindowDC dc(this);
+ if (!EmptyRgn(ownUpdateRgn))
+ dc.SetClippingRegion(wxRegion(ownUpdateRgn));
+ wxEraseEvent eevent( GetId(), &dc );
+ eevent.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( eevent );
+
+ wxNcPaintEvent eventNc( GetId() );
+ eventNc.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( eventNc );
+ }
+ DisposeRgn( ownUpdateRgn ) ;
+ if ( !m_updateRegion.Empty() )
+ {
+ wxPaintEvent event;
+ event.m_timeStamp = time ;
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+ }
+ }
+
+ // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
+
+ RgnHandle childupdate = NewRgn() ;
+ for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ // calculate the update region for the child windows by intersecting the window rectangle with our own
+ // passed in update region and then offset it to be client-wise window coordinates again
+ wxWindowMac *child = (wxWindowMac*)node->GetData();
+ SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ SectRgn( childupdate , updatergn , childupdate ) ;
+ OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
+ if ( child->MacGetRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) )
+ {
+ // because dialogs may also be children
+ child->MacRedraw( childupdate , time , erase ) ;
+ }
+ }
+ DisposeRgn( childupdate ) ;
+ // eventually a draw grow box here
+
+}
+
+WXHWND wxWindowMac::MacGetRootWindow() const
+{
+ wxWindowMac *iter = (wxWindowMac*)this ;
+
+ while( iter )
+ {
+ if ( iter->IsTopLevel() )
+ return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ;
+
+ iter = iter->GetParent() ;
+ }
+ wxASSERT_MSG( 1 , "No valid mac root window" ) ;
+ return NULL ;
+}
+
+void wxWindowMac::MacCreateScrollBars( long style )
+{
+ wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ;
+
+ bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ;
+ int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ;
+ int width, height ;
+ GetClientSize( &width , &height ) ;
+
+ wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
+ wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
+ wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
+ wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
+
+ m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint,
+ vSize , wxVERTICAL);
+
+ if ( style & wxVSCROLL )
+ {
+
+ }
+ else
+ {
+ m_vScrollBar->Show(false) ;
+ }
+ m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint,
+ hSize , wxHORIZONTAL);
+ if ( style & wxHSCROLL )
+ {
+ }
+ else
+ {
+ m_hScrollBar->Show(false) ;
+ }
+
+ // because the create does not take into account the client area origin
+ MacRepositionScrollBars() ; // we might have a real position shift
+}
+
+void wxWindowMac::MacRepositionScrollBars()
+{
+ bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
+ int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ;
+
+ // get real client area
+
+ int width = m_width ;
+ int height = m_height ;
+
+ width -= MacGetLeftBorderSize() + MacGetRightBorderSize();
+ height -= MacGetTopBorderSize() + MacGetBottomBorderSize();
+
+ wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
+ wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
+ wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
+ wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
+
+ int x = 0 ;
+ int y = 0 ;
+ int w = m_width ;
+ int h = m_height ;
+
+ MacClientToRootWindow( &x , &y ) ;
+ MacClientToRootWindow( &w , &h ) ;
+
+ wxWindowMac *iter = (wxWindowMac*)this ;
+
+ int totW = 10000 , totH = 10000;
+ while( iter )
+ {
+ if ( iter->IsTopLevel() )
+ {
+ totW = iter->m_width ;
+ totH = iter->m_height ;
+ break ;
+ }
+
+ iter = iter->GetParent() ;
+ }
+
+ if ( x == 0 )
+ {
+ hPoint.x = -1 ;
+ hSize.x += 1 ;
+ }
+ if ( y == 0 )
+ {
+ vPoint.y = -1 ;
+ vSize.y += 1 ;
+ }
+
+ if ( w-x >= totW )
+ {
+ hSize.x += 1 ;
+ vPoint.x += 1 ;
+ }
+
+ if ( h-y >= totH )
+ {
+ vSize.y += 1 ;
+ hPoint.y += 1 ;
+ }
+
+ if ( m_vScrollBar )
+ {
+ m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE);
+ }
+ if ( m_hScrollBar )
+ {
+ m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE);
+ }
+}
+
+bool wxWindowMac::AcceptsFocus() const