cleanup - reformatting; simplified OnPaint
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37460 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -884,31 +884,41 @@ bool wxToolBar::Realize()
|
|||||||
{
|
{
|
||||||
if ( insertAll || (tool->GetIndex() != currentPosition) )
|
if ( insertAll || (tool->GetIndex() != currentPosition) )
|
||||||
{
|
{
|
||||||
OSStatus err = noErr ;
|
OSStatus err = noErr;
|
||||||
if ( !insertAll )
|
if ( !insertAll )
|
||||||
{
|
{
|
||||||
|
insertAll = true;
|
||||||
|
|
||||||
// if this is the first tool that gets newly inserted or repositioned
|
// if this is the first tool that gets newly inserted or repositioned
|
||||||
// first remove all 'old' tools from here to the right, because of this
|
// first remove all 'old' tools from here to the right, because of this
|
||||||
// all following tools will have to be reinserted (insertAll). i = 100 because there's
|
// all following tools will have to be reinserted (insertAll). i = 100 because there's
|
||||||
// no way to determine how many there are in a toolbar, so just a high number :-(
|
// no way to determine how many there are in a toolbar, so just a high number :-(
|
||||||
for ( CFIndex i = 100 ; i >= currentPosition ; --i )
|
for ( CFIndex i = 100 ; i >= currentPosition ; --i )
|
||||||
{
|
{
|
||||||
err = HIToolbarRemoveItemAtIndex( (HIToolbarRef) m_macHIToolbarRef , i ) ;
|
err = HIToolbarRemoveItemAtIndex( (HIToolbarRef) m_macHIToolbarRef, i );
|
||||||
}
|
|
||||||
wxASSERT_MSG( err == noErr, _T("HIToolbarRemoveItemAtIndex failed") );
|
|
||||||
insertAll = true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = HIToolbarInsertItemAtIndex( (HIToolbarRef) m_macHIToolbarRef, hiItemRef , currentPosition ) ;
|
if (err != noErr)
|
||||||
wxASSERT_MSG( err == noErr, _T("HIToolbarInsertItemAtIndex failed") );
|
{
|
||||||
|
wxString errMsg = wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err );
|
||||||
tool->SetIndex( currentPosition ) ;
|
wxASSERT_MSG( 0, errMsg.c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPosition++ ;
|
err = HIToolbarInsertItemAtIndex( (HIToolbarRef) m_macHIToolbarRef, hiItemRef, currentPosition );
|
||||||
|
if (err != noErr)
|
||||||
|
{
|
||||||
|
wxString errMsg = wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err );
|
||||||
|
wxASSERT_MSG( 0, errMsg.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
tool->SetIndex( currentPosition );
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxMAC_USE_NATIVE_TOOLBAR
|
#endif
|
||||||
|
|
||||||
// update radio button (and group) state
|
// update radio button (and group) state
|
||||||
lastIsRadio = curIsRadio;
|
lastIsRadio = curIsRadio;
|
||||||
@@ -925,7 +935,7 @@ bool wxToolBar::Realize()
|
|||||||
{
|
{
|
||||||
if ( !lastIsRadio )
|
if ( !lastIsRadio )
|
||||||
{
|
{
|
||||||
if ( tool->Toggle(true) )
|
if ( tool->Toggle( true ) )
|
||||||
{
|
{
|
||||||
DoToggleTool( tool, true );
|
DoToggleTool( tool, true );
|
||||||
setChoiceInGroup = true;
|
setChoiceInGroup = true;
|
||||||
@@ -943,7 +953,7 @@ bool wxToolBar::Realize()
|
|||||||
if ( (toggleTool == NULL) || !toggleTool->IsButton() || (toggleTool->GetKind() != wxITEM_RADIO) )
|
if ( (toggleTool == NULL) || !toggleTool->IsButton() || (toggleTool->GetKind() != wxITEM_RADIO) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( toggleTool->Toggle(false) )
|
if ( toggleTool->Toggle( false ) )
|
||||||
DoToggleTool( toggleTool, false );
|
DoToggleTool( toggleTool, false );
|
||||||
|
|
||||||
nodePrev = nodePrev->GetPrevious();
|
nodePrev = nodePrev->GetPrevious();
|
||||||
@@ -1337,8 +1347,8 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
|||||||
#if wxMAC_USE_NATIVE_TOOLBAR
|
#if wxMAC_USE_NATIVE_TOOLBAR
|
||||||
if ( m_macUsesNativeToolbar )
|
if ( m_macUsesNativeToolbar )
|
||||||
{
|
{
|
||||||
event.Skip(true) ;
|
event.Skip(true);
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1347,20 +1357,20 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
|||||||
int w, h ;
|
int w, h ;
|
||||||
GetSize( &w , &h ) ;
|
GetSize( &w , &h ) ;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
bool drawMetalTheme = MacGetTopLevelWindow()->MacGetMetalAppearance();
|
||||||
if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() )
|
bool minimumUmaAvailable = (UMAGetSystemVersion() >= 0x1030);
|
||||||
{
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
|
||||||
{
|
|
||||||
HIThemePlacardDrawInfo info ;
|
|
||||||
memset( &info, 0, sizeof(info) ) ;
|
|
||||||
info.version = 0 ;
|
|
||||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
|
||||||
|
|
||||||
CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ;
|
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||||
HIRect rect = CGRectMake( 0 , 0 , w , h ) ;
|
if ( !drawMetalTheme && minimumUmaAvailable )
|
||||||
HIThemeDrawPlacard( &rect , & info , cgContext, kHIThemeOrientationNormal) ;
|
{
|
||||||
}
|
HIThemePlacardDrawInfo info;
|
||||||
|
memset( &info, 0, sizeof(info) );
|
||||||
|
info.version = 0;
|
||||||
|
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive;
|
||||||
|
|
||||||
|
CGContextRef cgContext = (CGContextRef) MacGetCGContextRef();
|
||||||
|
HIRect rect = CGRectMake( 0, 0, w, h );
|
||||||
|
HIThemeDrawPlacard( &rect, &info, cgContext, kHIThemeOrientationNormal );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1368,57 +1378,55 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
const bool drawBorder = true;
|
||||||
|
|
||||||
|
if (drawBorder)
|
||||||
|
{
|
||||||
wxMacPortSetter helper(&dc) ;
|
wxMacPortSetter helper(&dc) ;
|
||||||
|
|
||||||
|
if ( !drawMetalTheme || !minimumUmaAvailable )
|
||||||
|
{
|
||||||
Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
||||||
dc.YLOG2DEVMAC(h) , dc.XLOG2DEVMAC(w) } ;
|
dc.YLOG2DEVMAC(h) , dc.XLOG2DEVMAC(w) } ;
|
||||||
/*
|
|
||||||
|
#if 0
|
||||||
if ( toolbarrect.left < 0 )
|
if ( toolbarrect.left < 0 )
|
||||||
toolbarrect.left = 0 ;
|
toolbarrect.left = 0 ;
|
||||||
if ( toolbarrect.top < 0 )
|
if ( toolbarrect.top < 0 )
|
||||||
toolbarrect.top = 0 ;
|
toolbarrect.top = 0 ;
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() )
|
UMADrawThemePlacard( &toolbarrect, IsEnabled() ? kThemeStateActive : kThemeStateInactive );
|
||||||
{
|
|
||||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
|
||||||
{
|
|
||||||
HIRect hiToolbarrect = CGRectMake(
|
HIRect hiToolbarrect = CGRectMake(
|
||||||
dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
|
||||||
dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
|
dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
|
||||||
CGContextRef cgContext ;
|
CGContextRef cgContext ;
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
|
|
||||||
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
||||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||||
|
|
||||||
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
||||||
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
||||||
|
|
||||||
{
|
|
||||||
HIThemeBackgroundDrawInfo drawInfo ;
|
HIThemeBackgroundDrawInfo drawInfo ;
|
||||||
drawInfo.version = 0 ;
|
drawInfo.version = 0 ;
|
||||||
drawInfo.state = kThemeStateActive ;
|
drawInfo.state = kThemeStateActive ;
|
||||||
drawInfo.kind = kThemeBackgroundMetal ;
|
drawInfo.kind = kThemeBackgroundMetal ;
|
||||||
HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext, kHIThemeOrientationNormal) ;
|
HIThemeApplyBackground( &hiToolbarrect, &drawInfo, cgContext, kHIThemeOrientationNormal );
|
||||||
}
|
|
||||||
|
|
||||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
event.Skip() ;
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
Reference in New Issue
Block a user