X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0eaa1d68c29cd273971be9d60008045e470c2d46..d9f9aa2d8fcb956444588b2c19ffe8d4a3f5d2bb:/src/mac/carbon/window.cpp?ds=sidebyside diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index b3b459a0d3..95e1077a9b 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -152,6 +152,20 @@ void wxWindow::Init() // Destructor wxWindow::~wxWindow() { + // deleting a window while it is shown invalidates the region + if ( IsShown() ) { + wxWindow* iter = this ; + while( iter ) { + if ( iter->m_macWindowData ) + { + Refresh() ; + break ; + } + iter = iter->GetParent() ; + + } + } + m_isBeingDeleted = TRUE; if ( s_lastMouseWindow == this ) @@ -413,11 +427,19 @@ void wxWindow::MacRootWindowToClient( int *x , int *y ) const bool wxWindow::SetCursor(const wxCursor& cursor) { - if ( !wxWindowBase::SetCursor(cursor) ) - { - // no change + 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")); @@ -432,7 +454,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor) { if ( mouseWin == this && !wxIsBusy() ) { - cursor.MacInstall() ; + m_cursor.MacInstall() ; } } @@ -621,7 +643,7 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) if ( focus.Ok() ) { Rect clientrect = { 0 , 0 , m_height , m_width } ; - ClipRect( &clientrect ) ; + // ClipRect( &clientrect ) ; InvalWindowRect( GetMacRootWindow() , &clientrect ) ; } } @@ -656,7 +678,7 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) if ( focus.Ok() ) { Rect clientrect = { 0 , 0 , m_height , m_width } ; - ClipRect( &clientrect ) ; + // ClipRect( &clientrect ) ; InvalWindowRect( GetMacRootWindow() , &clientrect ) ; } } @@ -746,8 +768,6 @@ bool wxWindow::Show(bool show) } MacSuperShown( show ) ; Refresh() ; - if(m_macWindowData) - MacUpdateImmediately() ; return TRUE; } @@ -889,11 +909,14 @@ void wxWindow::MacEraseBackground( Rect *rect ) void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { +// if ( !IsShown() ) +// return ; + wxMacDrawingHelper focus( this ) ; if ( focus.Ok() ) { Rect clientrect = { 0 , 0 , m_height , m_width } ; - ClipRect( &clientrect ) ; + // ClipRect( &clientrect ) ; if ( rect ) { @@ -902,6 +925,10 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) } InvalWindowRect( GetMacRootWindow() , &clientrect ) ; } + if ( !eraseBack ) + m_macEraseOnRedraw = false ; + else + m_macEraseOnRedraw = true ; } // Responds to colour changes: passes event on to children. @@ -1129,6 +1156,7 @@ void wxWindow::MacCreateRealWindow( const wxString& title, UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; m_macWindowData->m_macFocus = NULL ; + m_macWindowData->m_macHasReceivedFirstActivate = true ; } void wxWindow::MacPaint( wxPaintEvent &event ) @@ -1265,7 +1293,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, { if ( !m_hScrollBar->IsShown() ) m_hScrollBar->Show(true) ; - m_hScrollBar->SetScrollbar( pos , thumbVisible , range , refresh ) ; + m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } } @@ -1282,7 +1310,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, { if ( !m_vScrollBar->IsShown() ) m_vScrollBar->Show(true) ; - m_vScrollBar->SetScrollbar( pos , thumbVisible , range , refresh ) ; + m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } } @@ -1680,8 +1708,12 @@ void wxWindow::MacFireMouseEvent( EventRecord *ev ) else event.SetEventType(wxEVT_LEFT_DCLICK ) ; } + lastWhen = 0 ; + } + else + { + lastWhen = ev->when ; } - lastWhen = ev->when ; lastWhere = localwhere ; } @@ -1754,19 +1786,27 @@ void wxWindow::MacMouseMoved( EventRecord *ev , short part) } void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating ) { + if ( !m_macWindowData->m_macHasReceivedFirstActivate ) + m_macWindowData->m_macHasReceivedFirstActivate = true ; + wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId); event.m_timeStamp = ev->when ; event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); + Refresh(false) ; UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ; +// MacUpdateImmediately() ; } void wxWindow::MacRedraw( RgnHandle updatergn , long time) { // updatergn is always already clipped to our boundaries WindowRef window = GetMacRootWindow() ; + // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children + RgnHandle ownUpdateRgn = NewRgn() ; + CopyRgn( updatergn , ownUpdateRgn ) ; wxWindow* win = wxFindWinFromMacWindow( window ) ; { wxMacDrawingHelper focus( this ) ; // was client @@ -1831,25 +1871,45 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) { RGBBackColor( &m_backgroundColour.GetPixel()) ; } + // subtract all non transparent children from updatergn + + RgnHandle childarea = NewRgn() ; + for (wxNode *node = GetChildren().First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + // eventually test for transparent windows + if ( child->GetMacRootWindow() == window && child->IsShown() ) + { + if ( child->GetBackgroundColour() != m_backgroundColour && !child->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)child)->GetMacControl() ) + { + SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; + DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ; + } + } + } + DisposeRgn( childarea ) ; + if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() ) eraseBackground = true ; - SetClip( updatergn ) ; - if ( eraseBackground && m_macEraseOnRedraw ) - { - // todo : find a clever algorithm, which only will do this - // if really necessary - EraseRgn( updatergn ) ; - } + SetClip( ownUpdateRgn ) ; + if ( m_macEraseOnRedraw ) { + if ( eraseBackground ) + { + EraseRgn( ownUpdateRgn ) ; + } + } + else { + m_macEraseOnRedraw = true ; + } } - m_macUpdateRgn = updatergn ; { 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 , m_macUpdateRgn , newupdate ) ; + SectRgn( newupdate , ownUpdateRgn , newupdate ) ; OffsetRgn( newupdate , -origin.x , -origin.y ) ; m_updateRegion = newupdate ; DisposeRgn( newupdate ) ; @@ -1869,7 +1929,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) { wxWindow *child = (wxWindow*)node->Data(); SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; - SectRgn( childupdate , m_macUpdateRgn , childupdate ) ; + SectRgn( childupdate , updatergn , childupdate ) ; OffsetRgn( childupdate , -child->m_x , -child->m_y ) ; if ( child->GetMacRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) ) { @@ -1903,7 +1963,7 @@ void wxWindow::MacUpdateImmediately() GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ; } @@ -1934,7 +1994,7 @@ void wxWindow::MacUpdate( EventRecord *ev ) GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { MacRedraw( region , ev->when ) ; }