X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9bd2d050ef9e22a05b66dc3e51a8bf7a29b3f437..1b69c815746d9ca7cbfcbe96423e2021ed3fbdb2:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index c73013d50e..563960faea 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -146,28 +146,33 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; } - else - { - // unfortunately this update region may be incorrect (tree ctrl sample ) - // so we have to reset it - // updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; - } // GrafPtr myport = cEvent.GetParameter(kEventParamGrafPort,typeGrafPtr) ; -#if 0 // in case we would need a coregraphics compliant background erase first +#if 0 + // in case we would need a coregraphics compliant background erase first + // now usable to track redraws CGContextRef cgContext = cEvent.GetParameter(kEventParamCGContextRef) ; if ( thisWindow->MacIsUserPane() ) { + static float color = 0.5 ; + static channel = 0 ; HIRect bounds; - err = HIViewGetBounds( controlRef, &bounds ); - CGContextSetRGBFillColor( cgContext, 1 , 1 , 1 , 1 ); -// CGContextSetRGBFillColor( cgContext, .95, .95, .95, 1 ); + HIViewGetBounds( controlRef, &bounds ); + CGContextSetRGBFillColor( cgContext, channel == 0 ? color : 0.5 , + channel == 1 ? color : 0.5 , channel == 2 ? color : 0.5 , 1 ); CGContextFillRect( cgContext, bounds ); + color += 0.1 ; + if ( color > 0.9 ) + { + color = 0.5 ; + channel++ ; + if ( channel == 3 ) + channel = 0 ; + } } #endif - if ( !thisWindow->MacIsUserPane() && thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) + if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) result = noErr ; - } break ; case kEventControlVisibilityChanged : @@ -264,7 +269,12 @@ static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, Contro void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part) { - MacDoRedraw( MacGetVisibleRegion().GetWXHRGN() , 0 ) ; + RgnHandle rgn = NewRgn() ; + GetClip( rgn ) ; + wxMacWindowStateSaver sv( this ) ; + SectRgn( rgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , rgn ) ; + MacDoRedraw( rgn , 0 ) ; + DisposeRgn( rgn ) ; } wxInt16 wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) @@ -559,9 +569,9 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, kControlSupportsEmbedding , (ControlRef*) &m_macControl); MacPostControlCreate(pos,size) ; +#if !TARGET_API_MAC_OSX SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneDrawProcTag, sizeof(gControlUserPaneDrawUPP),(Ptr) &gControlUserPaneDrawUPP); -#if !TARGET_API_MAC_OSX SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneHitTestProcTag, sizeof(gControlUserPaneHitTestUPP),(Ptr) &gControlUserPaneHitTestUPP); SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneTrackingProcTag, @@ -1349,13 +1359,25 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) if ( doMove || doResize ) { Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) ) ; + bool vis = IsControlVisible( (ControlRef) m_macControl ) ; #if TARGET_API_MAC_OSX - SetControlBounds( (ControlRef) m_macControl , &r ) ; + // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , false , true ) ; + HIRect hir = { r.left , r.top , r.right - r.left , r.bottom - r.top } ; + HIViewSetFrame ( (ControlRef) m_macControl , &hir ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , true , true ) ; #else +// TODO TEST SetControlBounds( (ControlRef) m_macControl , &r ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , false , true ) ; if ( doMove ) MoveControl( (ControlRef) m_macControl , r.left , r.top ) ; if ( doSize ) SizeControl( (ControlRef) m_macControl , r.right-r.left , r.bottom-r.top ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , true , true ) ; #endif MacRepositionScrollBars() ; if ( doMove ) @@ -1719,7 +1741,9 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) { RgnHandle update = NewRgn() ; SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; - SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; + SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; + wxPoint origin = GetClientAreaOrigin() ; + OffsetRgn( update, origin.x , origin.y ) ; HIViewSetNeedsDisplayInRegion( (ControlRef) m_macControl , update , true ) ; } #else