From 2bed17c862db626a40bfb981cb8d2bfed17b2737 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 12 Sep 2008 19:38:27 +0000 Subject: [PATCH] implementing changes in toolbartool directly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/toolbar.cpp | 99 ++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/src/osx/carbon/toolbar.cpp b/src/osx/carbon/toolbar.cpp index d2e2b5cccb..f1ff79cd4c 100644 --- a/src/osx/carbon/toolbar.cpp +++ b/src/osx/carbon/toolbar.cpp @@ -159,19 +159,22 @@ public: return wxPoint( m_x, m_y ); } - bool DoEnable( bool enable ); + virtual bool Enable( bool enable ); void UpdateToggleImage( bool toggle ); -#if wxOSX_USE_NATIVE_TOOLBAR - void SetToolbarItemRef( HIToolbarItemRef ref ) + virtual bool Toggle(bool toggle) { - if ( m_controlHandle ) - HideControl( m_controlHandle ); - if ( m_toolbarItemRef ) - CFRelease( m_toolbarItemRef ); - - m_toolbarItemRef = ref; + if ( wxToolBarToolBase::Toggle( toggle ) == false ) + return false; + + UpdateToggleImage(toggle); + return true; + } + + void UpdateHelpStrings() + { +#if wxOSX_USE_NATIVE_TOOLBAR if ( m_toolbarItemRef ) { wxFontEncoding enc = GetToolBarFontEncoding(); @@ -181,27 +184,37 @@ public: wxCFStringRef( GetShortHelp(), enc ), wxCFStringRef( GetLongHelp(), enc ) ); } +#endif } - - HIToolbarItemRef GetToolbarItemRef() const + + virtual bool SetShortHelp(const wxString& help) { - return m_toolbarItemRef; + if ( wxToolBarToolBase::SetShortHelp( help ) == false ) + return false; + + UpdateHelpStrings(); + return true; } - - void SetIndex( CFIndex idx ) + + virtual bool SetLongHelp(const wxString& help) { - m_index = idx; + if ( wxToolBarToolBase::SetLongHelp( help ) == false ) + return false; + + UpdateHelpStrings(); + return true; } - CFIndex GetIndex() const + virtual void SetNormalBitmap(const wxBitmap& bmp) { - return m_index; + wxToolBarToolBase::SetNormalBitmap(bmp); + UpdateToggleImage(CanBeToggled() && IsToggled()); } - + virtual void SetLabel(const wxString& label) { wxToolBarToolBase::SetLabel(label); - +#if wxOSX_USE_NATIVE_TOOLBAR if ( m_toolbarItemRef ) { // strip mnemonics from the label for compatibility with the usual @@ -212,6 +225,34 @@ public: m_toolbarItemRef, wxCFStringRef(labelStr, GetToolBarFontEncoding()) ); } +#endif + } + +#if wxOSX_USE_NATIVE_TOOLBAR + void SetToolbarItemRef( HIToolbarItemRef ref ) + { + if ( m_controlHandle ) + HideControl( m_controlHandle ); + if ( m_toolbarItemRef ) + CFRelease( m_toolbarItemRef ); + + m_toolbarItemRef = ref; + UpdateHelpStrings(); + } + + HIToolbarItemRef GetToolbarItemRef() const + { + return m_toolbarItemRef; + } + + void SetIndex( CFIndex idx ) + { + m_index = idx; + } + + CFIndex GetIndex() const + { + return m_index; } #endif // wxOSX_USE_NATIVE_TOOLBAR @@ -384,8 +425,11 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarEventHandler ) #endif -bool wxToolBarTool::DoEnable( bool enable ) +bool wxToolBarTool::Enable( bool enable ) { + if ( wxToolBarToolBase::Enable( enable ) == false ) + return false; + if ( IsControl() ) { GetControl()->Enable( enable ); @@ -1190,10 +1234,6 @@ bool wxToolBar::Realize() { // since setting the help texts is non-virtual we have to update // the strings now - HIToolbarItemSetHelpText( hiItemRef, - wxCFStringRef( tool->GetShortHelp(), enc ), - wxCFStringRef( tool->GetLongHelp(), enc ) ); - if ( insertAll || (tool->GetIndex() != currentPosition) ) { OSStatus err = noErr; @@ -1461,17 +1501,14 @@ wxString wxToolBar::MacGetToolTipString( wxPoint &pt ) return wxEmptyString; } -void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) +void wxToolBar::DoEnableTool(wxToolBarToolBase *WXUNUSED(t), bool WXUNUSED(enable)) { - if ( t != NULL ) - ((wxToolBarTool*)t)->DoEnable( enable ); + // everything already done in the tool's implementation } void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) { - wxToolBarTool *tool = (wxToolBarTool *)t; - if ( ( tool != NULL ) && tool->IsButton() ) - tool->UpdateToggleImage( toggle ); + // everything already done in the tool's implementation } bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) @@ -1655,7 +1692,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) { - wxFAIL_MSG( wxT("not implemented") ); + // nothing to do } bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolbase) -- 2.45.2