summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
105fbe1)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45313
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#if wxMAC_USE_NATIVE_TOOLBAR
CFIndex currentPosition = 0;
bool insertAll = false;
#if wxMAC_USE_NATIVE_TOOLBAR
CFIndex currentPosition = 0;
bool insertAll = false;
+
+ HIToolbarRef refTB = (HIToolbarRef)m_macHIToolbarRef;
#endif
node = m_tools.GetFirst();
#endif
node = m_tools.GetFirst();
#if wxMAC_USE_NATIVE_TOOLBAR
// install in native HIToolbar
#if wxMAC_USE_NATIVE_TOOLBAR
// install in native HIToolbar
- if ( m_macHIToolbarRef != NULL )
- HIToolbarItemRef hiItemRef = tool->GetToolbarItemRef();
+ HIToolbarItemRef hiItemRef = tool->GetToolbarItemRef();
if ( hiItemRef != NULL )
{
if ( insertAll || (tool->GetIndex() != currentPosition) )
if ( hiItemRef != NULL )
{
if ( insertAll || (tool->GetIndex() != currentPosition) )
// 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
// 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
- // 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 :-(
- for ( CFIndex i = 100; i >= currentPosition; --i )
- {
- err = HIToolbarRemoveItemAtIndex( (HIToolbarRef) m_macHIToolbarRef, i );
- }
-
- if (err != noErr)
+ // all following tools will have to be reinserted (insertAll).
+ for ( wxToolBarToolsList::compatibility_iterator node2 = m_tools.GetLast();
+ node2 != node;
+ node2 = node2->GetPrevious() )
- wxString errMsg = wxString::Format( wxT("HIToolbarRemoveItemAtIndex failed [%ld]"), (long)err );
- wxFAIL_MSG( errMsg.c_str() );
+ wxToolBarTool *tool2 = (wxToolBarTool*) node2->GetData();
+
+ const long idx = tool2->GetIndex();
+ if ( idx != -1 )
+ {
+ err = HIToolbarRemoveItemAtIndex(refTB, idx);
+ if ( err != noErr )
+ {
+ wxLogDebug(wxT("HIToolbarRemoveItemAtIndex(%ld) failed [%ld]"),
+ idx, (long)err);
+ }
+
+ tool2->SetIndex(-1);
+ }
- err = HIToolbarInsertItemAtIndex( (HIToolbarRef) m_macHIToolbarRef, hiItemRef, currentPosition );
+ err = HIToolbarInsertItemAtIndex( refTB, hiItemRef, currentPosition );
- wxString errMsg = wxString::Format( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err );
- wxFAIL_MSG( errMsg.c_str() );
+ wxLogDebug( wxT("HIToolbarInsertItemAtIndex failed [%ld]"), (long)err );
}
tool->SetIndex( currentPosition );
}
tool->SetIndex( currentPosition );