removing non-compositing code, adding individual transparency
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40567 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -203,31 +203,11 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
|
wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
|
||||||
Rect controlBounds ;
|
Rect controlBounds ;
|
||||||
|
|
||||||
if ( ! thisWindow->GetPeer()->IsCompositing() )
|
|
||||||
{
|
|
||||||
if ( thisWindow->GetPeer()->IsRootControl() )
|
|
||||||
thisWindow->GetPeer()->GetRect( &controlBounds ) ;
|
|
||||||
else
|
|
||||||
GetControlBounds( thisWindow->GetPeer()->GetControlRef() , &controlBounds ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
|
if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
|
||||||
{
|
{
|
||||||
updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
|
updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if ( ! thisWindow->GetPeer()->IsCompositing() )
|
|
||||||
{
|
|
||||||
allocatedRgn = NewRgn() ;
|
|
||||||
CopyRgn( updateRgn , allocatedRgn ) ;
|
|
||||||
OffsetRgn( allocatedRgn , -controlBounds.left , -controlBounds.top ) ;
|
|
||||||
|
|
||||||
// hide the given region by the new region that must be shifted
|
|
||||||
wxMacNativeToWindow( thisWindow , allocatedRgn ) ;
|
|
||||||
updateRgn = allocatedRgn ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 )
|
if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 )
|
||||||
{
|
{
|
||||||
@@ -240,7 +220,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
updateRgn = allocatedRgn ;
|
updateRgn = allocatedRgn ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Rect rgnBounds ;
|
Rect rgnBounds ;
|
||||||
GetRegionBounds( updateRgn , &rgnBounds ) ;
|
GetRegionBounds( updateRgn , &rgnBounds ) ;
|
||||||
@@ -272,43 +251,25 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
bool created = false ;
|
bool created = false ;
|
||||||
CGContextRef cgContext = NULL ;
|
CGContextRef cgContext = NULL ;
|
||||||
if ( cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) != noErr )
|
OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
|
||||||
{
|
wxASSERT_MSG( err == noErr , wxT("Unable to retrieve CGContextRef") ) ;
|
||||||
wxASSERT( thisWindow->GetPeer()->IsCompositing() == false ) ;
|
|
||||||
|
|
||||||
// this parameter is not provided on non-composited windows
|
|
||||||
created = true ;
|
|
||||||
|
|
||||||
// rest of the code expects this to be already transformed and clipped for local
|
|
||||||
CGrafPtr port = GetWindowPort( (WindowRef) thisWindow->MacGetTopLevelWindowRef() ) ;
|
|
||||||
Rect bounds ;
|
|
||||||
GetPortBounds( port , &bounds ) ;
|
|
||||||
CreateCGContextForPort( port , &cgContext ) ;
|
|
||||||
|
|
||||||
wxMacWindowToNative( thisWindow , updateRgn ) ;
|
|
||||||
OffsetRgn( updateRgn , controlBounds.left , controlBounds.top ) ;
|
|
||||||
ClipCGContextToRegion( cgContext , &bounds , updateRgn ) ;
|
|
||||||
wxMacNativeToWindow( thisWindow , updateRgn ) ;
|
|
||||||
OffsetRgn( updateRgn , -controlBounds.left , -controlBounds.top ) ;
|
|
||||||
|
|
||||||
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
|
||||||
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
|
||||||
|
|
||||||
CGContextTranslateCTM( cgContext , controlBounds.left , controlBounds.top ) ;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
CGContextSetRGBFillColor( cgContext , 1.0 , 1.0 , 1.0 , 1.0 ) ;
|
|
||||||
CGContextFillRect( cgContext ,
|
|
||||||
CGRectMake( 0 , 0 ,
|
|
||||||
controlBounds.right - controlBounds.left ,
|
|
||||||
controlBounds.bottom - controlBounds.top ) );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
thisWindow->MacSetCGContextRef( cgContext ) ;
|
thisWindow->MacSetCGContextRef( cgContext ) ;
|
||||||
|
|
||||||
{
|
{
|
||||||
wxMacCGContextStateSaver sg( cgContext ) ;
|
wxMacCGContextStateSaver sg( cgContext ) ;
|
||||||
|
float alpha = 1.0 ;
|
||||||
|
{
|
||||||
|
wxWindow* iter = thisWindow ;
|
||||||
|
while ( iter )
|
||||||
|
{
|
||||||
|
alpha *= (float) iter->GetTransparent()/255.0 ;
|
||||||
|
if ( iter->IsTopLevel() )
|
||||||
|
iter = NULL ;
|
||||||
|
else
|
||||||
|
iter = iter->GetParent() ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CGContextSetAlpha( cgContext , alpha ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
@@ -941,6 +902,7 @@ void wxWindowMac::Init()
|
|||||||
{
|
{
|
||||||
m_peer = NULL ;
|
m_peer = NULL ;
|
||||||
m_frozenness = 0 ;
|
m_frozenness = 0 ;
|
||||||
|
m_macAlpha = 255 ;
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_4
|
#if WXWIN_COMPATIBILITY_2_4
|
||||||
m_backgroundTransparent = false;
|
m_backgroundTransparent = false;
|
||||||
@@ -1396,10 +1358,6 @@ bool wxWindowMac::MacGetBoundsForControl(
|
|||||||
w = wxMax(size.x, 0) ; // WidthDefault( size.x );
|
w = wxMax(size.x, 0) ; // WidthDefault( size.x );
|
||||||
h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
|
h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
|
||||||
|
|
||||||
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
|
|
||||||
if ( !isCompositing )
|
|
||||||
GetParent()->MacWindowToRootWindow( &x , &y ) ;
|
|
||||||
|
|
||||||
x += MacGetLeftBorderSize() ;
|
x += MacGetLeftBorderSize() ;
|
||||||
y += MacGetTopBorderSize() ;
|
y += MacGetTopBorderSize() ;
|
||||||
w -= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
w -= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||||
@@ -2357,7 +2315,7 @@ void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( MacGetTopLevelWindow()->MacUsesCompositing() && (!m_macBackgroundBrush.Ok() || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT ) )
|
if ( !m_macBackgroundBrush.Ok() || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT )
|
||||||
{
|
{
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
}
|
}
|
||||||
@@ -2595,7 +2553,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
GetClientSize( &width , &height ) ;
|
GetClientSize( &width , &height ) ;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( true /* m_peer->IsCompositing() */ )
|
if ( true )
|
||||||
{
|
{
|
||||||
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
||||||
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
||||||
@@ -2615,7 +2573,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
// this would be the preferred version for fast drawing controls
|
// this would be the preferred version for fast drawing controls
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 && m_peer->IsCompositing() )
|
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||||
HIViewRender(m_peer->GetControlRef()) ;
|
HIViewRender(m_peer->GetControlRef()) ;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -2636,7 +2594,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
// this would be the preferred version for fast drawing controls
|
// this would be the preferred version for fast drawing controls
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 && m_peer->IsCompositing() )
|
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||||
HIViewRender(m_peer->GetControlRef()) ;
|
HIViewRender(m_peer->GetControlRef()) ;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -3450,3 +3408,32 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWindowMac::SetTransparent(wxByte alpha)
|
||||||
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
if ( alpha != m_macAlpha )
|
||||||
|
{
|
||||||
|
m_macAlpha = alpha ;
|
||||||
|
Refresh() ;
|
||||||
|
}
|
||||||
|
return true ;
|
||||||
|
#else
|
||||||
|
return false ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool wxWindowMac::CanSetTransparent()
|
||||||
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
return true ;
|
||||||
|
#else
|
||||||
|
return false ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
wxByte wxWindowMac::GetTransparent() const
|
||||||
|
{
|
||||||
|
return m_macAlpha ;
|
||||||
|
}
|
Reference in New Issue
Block a user