implementing changes in toolbartool directly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2008-09-12 19:38:27 +00:00
parent 01548e7c02
commit 2bed17c862

View File

@@ -159,10 +159,75 @@ public:
return wxPoint( m_x, m_y ); return wxPoint( m_x, m_y );
} }
bool DoEnable( bool enable ); virtual bool Enable( bool enable );
void UpdateToggleImage( bool toggle ); void UpdateToggleImage( bool toggle );
virtual bool Toggle(bool toggle)
{
if ( wxToolBarToolBase::Toggle( toggle ) == false )
return false;
UpdateToggleImage(toggle);
return true;
}
void UpdateHelpStrings()
{
#if wxOSX_USE_NATIVE_TOOLBAR
if ( m_toolbarItemRef )
{
wxFontEncoding enc = GetToolBarFontEncoding();
HIToolbarItemSetHelpText(
m_toolbarItemRef,
wxCFStringRef( GetShortHelp(), enc ),
wxCFStringRef( GetLongHelp(), enc ) );
}
#endif
}
virtual bool SetShortHelp(const wxString& help)
{
if ( wxToolBarToolBase::SetShortHelp( help ) == false )
return false;
UpdateHelpStrings();
return true;
}
virtual bool SetLongHelp(const wxString& help)
{
if ( wxToolBarToolBase::SetLongHelp( help ) == false )
return false;
UpdateHelpStrings();
return true;
}
virtual void SetNormalBitmap(const wxBitmap& bmp)
{
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
// labels in wxStaticText sense
wxString labelStr = wxStripMenuCodes(label);
HIToolbarItemSetLabel(
m_toolbarItemRef,
wxCFStringRef(labelStr, GetToolBarFontEncoding()) );
}
#endif
}
#if wxOSX_USE_NATIVE_TOOLBAR #if wxOSX_USE_NATIVE_TOOLBAR
void SetToolbarItemRef( HIToolbarItemRef ref ) void SetToolbarItemRef( HIToolbarItemRef ref )
{ {
@@ -172,15 +237,7 @@ public:
CFRelease( m_toolbarItemRef ); CFRelease( m_toolbarItemRef );
m_toolbarItemRef = ref; m_toolbarItemRef = ref;
if ( m_toolbarItemRef ) UpdateHelpStrings();
{
wxFontEncoding enc = GetToolBarFontEncoding();
HIToolbarItemSetHelpText(
m_toolbarItemRef,
wxCFStringRef( GetShortHelp(), enc ),
wxCFStringRef( GetLongHelp(), enc ) );
}
} }
HIToolbarItemRef GetToolbarItemRef() const HIToolbarItemRef GetToolbarItemRef() const
@@ -197,22 +254,6 @@ public:
{ {
return m_index; return m_index;
} }
virtual void SetLabel(const wxString& label)
{
wxToolBarToolBase::SetLabel(label);
if ( m_toolbarItemRef )
{
// strip mnemonics from the label for compatibility with the usual
// labels in wxStaticText sense
wxString labelStr = wxStripMenuCodes(label);
HIToolbarItemSetLabel(
m_toolbarItemRef,
wxCFStringRef(labelStr, GetToolBarFontEncoding()) );
}
}
#endif // wxOSX_USE_NATIVE_TOOLBAR #endif // wxOSX_USE_NATIVE_TOOLBAR
private: private:
@@ -384,8 +425,11 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarEventHandler )
#endif #endif
bool wxToolBarTool::DoEnable( bool enable ) bool wxToolBarTool::Enable( bool enable )
{ {
if ( wxToolBarToolBase::Enable( enable ) == false )
return false;
if ( IsControl() ) if ( IsControl() )
{ {
GetControl()->Enable( enable ); GetControl()->Enable( enable );
@@ -1190,10 +1234,6 @@ bool wxToolBar::Realize()
{ {
// since setting the help texts is non-virtual we have to update // since setting the help texts is non-virtual we have to update
// the strings now // the strings now
HIToolbarItemSetHelpText( hiItemRef,
wxCFStringRef( tool->GetShortHelp(), enc ),
wxCFStringRef( tool->GetLongHelp(), enc ) );
if ( insertAll || (tool->GetIndex() != currentPosition) ) if ( insertAll || (tool->GetIndex() != currentPosition) )
{ {
OSStatus err = noErr; OSStatus err = noErr;
@@ -1461,17 +1501,14 @@ wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
return wxEmptyString; return wxEmptyString;
} }
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) void wxToolBar::DoEnableTool(wxToolBarToolBase *WXUNUSED(t), bool WXUNUSED(enable))
{ {
if ( t != NULL ) // everything already done in the tool's implementation
((wxToolBarTool*)t)->DoEnable( enable );
} }
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{ {
wxToolBarTool *tool = (wxToolBarTool *)t; // everything already done in the tool's implementation
if ( ( tool != NULL ) && tool->IsButton() )
tool->UpdateToggleImage( toggle );
} }
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) 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)) 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) bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolbase)