void wxFileHistoryBase::RemoveFileFromHistory(size_t i) { size_t numFiles = m_fileHistory.size(); wxCHECK_RET( i < numFiles, wxT("invalid index in wxFileHistoryBase::RemoveFileFromHistory") ); // delete the element from the array m_fileHistory.RemoveAt(i); numFiles--; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst(); node; node = node->GetNext() ) { wxMenu * const menu = (wxMenu *) node->GetData(); // shift filenames up #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t j = i; j < numFiles; j++ ) { menu->SetLabel(m_idBase + j, GetMRUEntryLabel(j, m_fileHistory[j])); } // delete the last menu item which is unused now const wxWindowID lastItemId = m_idBase + numFiles; if ( menu->FindItem(lastItemId) ) menu->Delete(lastItemId); // delete the last separator too if no more files are left if ( m_fileHistory.empty() ) { const wxMenuItemList::compatibility_iterator nodeLast = menu->GetMenuItems().GetLast(); if ( nodeLast ) { wxMenuItem * const lastMenuItem = nodeLast->GetData(); if ( lastMenuItem->IsSeparator() ) menu->Delete(lastMenuItem); } //else: menu is empty somehow } } }
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) { if ( item->IsRadio() ) { // Check if we're removing the item starting the radio group if ( item->IsRadioGroupStart() ) { // Yes, we do, update the next radio group item, if any, to be the // start one now. const int endGroup = item->GetRadioGroupEnd(); wxMenuItemList::compatibility_iterator node = GetMenuItems().Item(endGroup); wxASSERT_MSG( node, wxS("Should have valid radio group end") ); while ( node->GetData() != item ) { const wxMenuItemList::compatibility_iterator prevNode = node->GetPrevious(); wxMenuItem* const prevItem = prevNode->GetData(); if ( prevItem == item ) { prevItem->SetAsRadioGroupStart(); prevItem->SetRadioGroupEnd(endGroup); break; } node = prevNode; } } } /* // we need to find the items position in the child list size_t pos; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for ( pos = 0; node; pos++ ) { if ( node->GetData() == item ) break; node = node->GetNext(); } // DoRemove() (unlike Remove) can only be called for existing item! wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") ); wxOSXMenuRemoveItem(m_hMenu , pos ); */ GetPeer()->Remove( item ); // and from internal data structures return wxMenuBase::DoRemove(item); }
void wxFileHistoryBase::RemoveExistingHistory() { size_t count = m_fileHistory.GetCount(); if ( !count ) return; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst(); node; node = node->GetNext() ) { wxMenu * const menu = static_cast<wxMenu *>(node->GetData()); // Notice that we remove count+1 items from the menu as we also remove // the separator preceding them. #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t n = 0; n <= count; n++ ) { const wxMenuItemList::compatibility_iterator nodeLast = menu->GetMenuItems().GetLast(); if ( nodeLast ) { wxMenuItem * const lastMenuItem = nodeLast->GetData(); menu->Delete(lastMenuItem); } } } }