X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19c7ac3d3bf1ac2113505a805a79c40ce3db1f5b..55410bb4f67febe1ca20654f078ea4fb9a6223ae:/src/osx/carbon/window.cpp?ds=sidebyside diff --git a/src/osx/carbon/window.cpp b/src/osx/carbon/window.cpp index 67227916f3..87c1eb5d89 100644 --- a/src/osx/carbon/window.cpp +++ b/src/osx/carbon/window.cpp @@ -131,24 +131,23 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { case kEventControlDraw : { - RgnHandle updateRgn = NULL ; - RgnHandle allocatedRgn = NULL ; + HIShapeRef updateRgn = NULL ; + HIMutableShapeRef allocatedRgn = NULL ; wxRegion visRegion = thisWindow->MacGetVisibleRegion() ; - if ( cEvent.GetParameter(kEventParamRgnHandle, &updateRgn) != noErr ) + // according to the docs: redraw entire control if param not present + if ( cEvent.GetParameter(kEventParamShape, &updateRgn) != noErr ) { - HIShapeGetAsQDRgn( visRegion.GetWXHRGN(), updateRgn ); + updateRgn = visRegion.GetWXHRGN(); } else { if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 ) { // as this update region is in native window locals we must adapt it to wx window local - allocatedRgn = NewRgn() ; - CopyRgn( updateRgn , allocatedRgn ) ; - + allocatedRgn = HIShapeCreateMutableCopy(updateRgn); + HIShapeOffset(allocatedRgn, thisWindow->MacGetLeftBorderSize() , thisWindow->MacGetTopBorderSize()); // hide the given region by the new region that must be shifted - OffsetRgn( allocatedRgn , thisWindow->MacGetLeftBorderSize() , thisWindow->MacGetTopBorderSize() ) ; updateRgn = allocatedRgn ; } } @@ -210,11 +209,23 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl CGContextClearRect( cgContext, bounds ); } - - - if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) - result = noErr ; - + if ( !HIShapeIsEmpty(updateRgn) ) + { + // refcount increase because wxRegion constructor takes ownership of the native region + CFRetain(updateRgn); + thisWindow->GetUpdateRegion() = wxRegion(updateRgn); + if ( !thisWindow->MacDoRedraw( cEvent.GetTicks() ) ) + { + // for native controls: call their native paint method + if ( !thisWindow->MacIsUserPane() || + ( thisWindow->IsTopLevel() && thisWindow->GetBackgroundStyle() == wxBG_STYLE_SYSTEM ) ) + { + if ( thisWindow->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT ) + CallNextEventHandler( handler ,event ) ; + } + } + thisWindow->MacPaintChildrenBorders(); + } thisWindow->MacSetCGContextRef( NULL ) ; } @@ -223,7 +234,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl } if ( allocatedRgn ) - DisposeRgn( allocatedRgn ) ; + CFRelease( allocatedRgn ) ; } break ; @@ -906,19 +917,24 @@ void wxMacControl::Lower() void wxMacControl::GetContentArea(int &left , int &top , int &width , int &height) const { - RgnHandle rgn = NewRgn() ; - Rect content ; - if ( GetControlRegion( m_controlRef, kControlContentMetaPart , rgn ) == noErr ) - GetRegionBounds( rgn , &content ) ; + HIShapeRef rgn = NULL; + Rect content ; + + if ( HIViewCopyShape(m_controlRef, kHIViewContentMetaPart, &rgn) == noErr) + { + CGRect cgrect; + HIShapeGetBounds(rgn, &cgrect); + content = (Rect){ cgrect.origin.y, cgrect.origin.x, cgrect.origin.y+cgrect.size.height, cgrect.origin.x+cgrect.size.width }; + CFRelease(rgn); + } else { - GetControlBounds( m_controlRef , &content ); + GetControlBounds(m_controlRef, &content); content.right -= content.left; content.left = 0; content.bottom -= content.top; content.top = 0; } - DisposeRgn( rgn ) ; left = content.left; top = content.top; @@ -1378,12 +1394,6 @@ void wxMacControl::GetFeatures( UInt32 * features ) GetControlFeatures( m_controlRef , features ); } -OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region ) -{ - OSStatus err = GetControlRegion( m_controlRef , partCode , region ); - return err; -} - void wxMacControl::PulseGauge() { }