void SetSize(const wxSize& size) ;
void SetPosition( const wxPoint& position ) ;
+
wxSize GetSize() const
{
if ( IsControl() )
{
return wxPoint(m_x, m_y);
}
+ bool DoEnable( bool enable ) ;
private :
void Init()
{
wxToolBarTool* tbartool = (wxToolBarTool*)data ;
if ( tbartool->CanBeToggled() )
{
- tbartool->Toggle( GetControl32BitValue( (ControlRef) tbartool->GetControlHandle() ) ) ;
+ ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), GetControl32BitValue((ControlRef)tbartool->GetControlHandle()));
}
((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ;
-
result = noErr;
}
break ;
// wxToolBarTool
// ----------------------------------------------------------------------------
+bool wxToolBarTool::DoEnable(bool enable)
+{
+ if ( IsControl() )
+ {
+ GetControl()->Enable( enable ) ;
+ }
+ else if ( IsButton() )
+ {
+#if TARGET_API_MAC_OSX
+ if ( enable )
+ EnableControl( m_controlHandle ) ;
+ else
+ DisableControl( m_controlHandle ) ;
+#else
+ if ( enable )
+ ActivateControl( m_controlHandle ) ;
+ else
+ DeactivateControl( m_controlHandle ) ;
+#endif
+ }
+ return true ;
+}
void wxToolBarTool::SetSize(const wxSize& size)
{
if ( IsControl() )
GetControlBounds( m_controlHandle , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
int former_mac_y = contrlRect.top ;
- wxSize sz = GetToolBar()->GetToolSize() ;
+ GetToolBar()->GetToolSize() ;
if ( mac_x != former_mac_x || mac_y != former_mac_y )
{
GetEventTypeCount(eventList), eventList, this,NULL);
UMAShowControl( m_controlHandle ) ;
- if ( !IsEnabled() )
- DisableControl( m_controlHandle ) ;
if ( CanBeToggled() && IsToggled() )
::SetControl32BitValue( m_controlHandle , 1 ) ;
node = node->GetNext();
}
+ bool lastWasRadio = FALSE;
node = m_tools.GetFirst();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
wxSize cursize = tool->GetSize() ;
+ bool isRadio = FALSE;
+
+ if ( tool->IsButton() && tool->GetKind() == wxITEM_RADIO )
+ {
+ if ( !lastWasRadio )
+ {
+ if (tool->Toggle(true))
+ {
+ DoToggleTool(tool, true);
+ }
+ }
+ isRadio = TRUE;
+ }
+ else
+ {
+ isRadio = FALSE;
+ }
+ lastWasRadio = isRadio;
+
// for the moment we just do a single row/column alignement
if ( x + cursize.x > maxWidth )
maxWidth = x + cursize.x ;
}
SetSize( maxWidth, maxHeight );
+ InvalidateBestSize();
return TRUE;
}
if (!IsShown())
return ;
- wxToolBarTool *tool = (wxToolBarTool *)t;
- if ( tool->IsControl() )
- {
- tool->GetControl()->Enable( enable ) ;
- }
- else if ( tool->IsButton() )
- {
- if ( enable )
- UMAActivateControl( (ControlRef) tool->GetControlHandle() ) ;
- else
- UMADeactivateControl( (ControlRef) tool->GetControlHandle() ) ;
- }
+ ((wxToolBarTool*)t)->DoEnable( enable ) ;
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{
// nothing special to do here - we relayout in Realize() later
tool->Attach(this);
+ InvalidateBestSize();
return TRUE;
}
tool2->SetPosition( pt ) ;
}
+ InvalidateBestSize();
return TRUE ;
}
if ( toolbarrect.top < 0 )
toolbarrect.top = 0 ;
*/
- UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() )
+ {
+ UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ }
+ else
+ {
+#if TARGET_API_MAC_OSX
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ if ( UMAGetSystemVersion() >= 0x1030 )
+ {
+ HIRect hiToolbarrect = CGRectMake( dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
+ dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) );
+ CGContextRef cgContext ;
+ Rect bounds ;
+ GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
+ QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
+ CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
+ CGContextScaleCTM( cgContext , 1 , -1 ) ;
+ {
+ HIThemeBackgroundDrawInfo drawInfo ;
+ drawInfo.version = 0 ;
+ drawInfo.state = kThemeStateActive ;
+ drawInfo.kind = kThemeBackgroundMetal ;
+ HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ;
+ }
+ QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
+ }
+ else
+#endif
+ {
+ UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ }
+#endif
+ }
event.Skip() ;
}