From a2fe01c96d43777db58041ec470e8aaa27f1e3b2 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 23 Aug 2004 14:24:36 +0000 Subject: [PATCH] making tool enable consistent (was using mix of enable and activate controls before) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/toolbar.cpp | 39 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index b240fa221b..e445850c60 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -66,6 +66,7 @@ public: void SetSize(const wxSize& size) ; void SetPosition( const wxPoint& position ) ; + wxSize GetSize() const { if ( IsControl() ) @@ -88,6 +89,7 @@ public: { return wxPoint(m_x, m_y); } + bool DoEnable( bool enable ) ; private : void Init() { @@ -159,6 +161,28 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler ) // 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() ) @@ -240,8 +264,6 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar, GetEventTypeCount(eventList), eventList, this,NULL); UMAShowControl( m_controlHandle ) ; - if ( !IsEnabled() ) - DisableControl( m_controlHandle ) ; if ( CanBeToggled() && IsToggled() ) ::SetControl32BitValue( m_controlHandle , 1 ) ; @@ -443,18 +465,7 @@ void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) 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) -- 2.47.2