void wxSTEPrependArrayString(const wxString &str, wxArrayString &strArray, int count) { const int idx = strArray.Index(str); if (idx == 0) return; if (idx != wxNOT_FOUND) strArray.RemoveAt(idx); strArray.Insert(str, 0); if ((count > 0) && ((int)strArray.GetCount() > count)) strArray.RemoveAt(count, strArray.GetCount()-count); }
void AddTypeToAssociated( wxListBox *WxListBoxAssociated, wxListBox *WxListBoxPredefined, const wxArrayString &as ) { int idx = 0; const int count = int( as.Count() ); wxString type; while( idx < count ) { type = as[idx]; int n = WxListBoxPredefined->FindString( type ); if( n != wxNOT_FOUND ) { WxListBoxPredefined->Delete( n ); } n = WxListBoxAssociated->FindString( type ); if( n == wxNOT_FOUND ) { WxListBoxAssociated->Append( type ); } n = as_remove.Index( type ); if( n != wxNOT_FOUND ) { as_remove.RemoveAt( n ); } ++idx; } }
bool wxArrayStringUpdatePos(wxArrayString& arr, size_t pos, int num, bool no_error) { if (num == 0) return false; else if (num > 0) { // if no_error check if <= GetCount, else let array error out if (!no_error || (pos <= arr.GetCount())) arr.Insert( wxEmptyString, pos, num ); } else // if (num < 0) { const int count = arr.GetCount(); if (no_error && (int(pos) - num > count)) { num = -(count - int(pos)); if ((num >= 0) || (count == 0)) return false; } else { wxCHECK_MSG( int(pos) - num <= count, false, wxString::Format(wxT("Called wxArrayStringUpdatePos(pos=%d, N=%d)\nPos value is invalid for present array with %d elements"), int(pos), num, count) ); } if ((pos == 0u) && (num == count)) arr.Clear(); else arr.RemoveAt( pos, -num ); } return true; }
void DebuggerTreeListCtrlBase::DoRefreshItemRecursively(IDebugger *dbgr, const wxTreeItemId &item, wxArrayString &itemsToRefresh) { if(itemsToRefresh.IsEmpty()) return; wxTreeItemIdValue cookieOne; wxTreeItemId exprItem = m_listTable->GetFirstChild(item, cookieOne); while( exprItem.IsOk() ) { DbgTreeItemData* data = static_cast<DbgTreeItemData*>(m_listTable->GetItemData(exprItem)); if(data) { int where = itemsToRefresh.Index(data->_gdbId); if(where != wxNOT_FOUND) { dbgr->EvaluateVariableObject(data->_gdbId, m_DBG_USERR); m_gdbIdToTreeId[data->_gdbId] = exprItem; itemsToRefresh.RemoveAt((size_t)where); } } if(m_listTable->HasChildren(exprItem)) { DoRefreshItemRecursively(dbgr, exprItem, itemsToRefresh); } exprItem = m_listTable->GetNextChild(item, cookieOne); } }
/** * Function OnRemovePlugin * Remove a plugin from the list */ void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event ) { int ii = m_lbPlugins->GetSelection(); if( ii < 0 ) return; m_lbPlugins->Delete( ii ); m_plugins.RemoveAt( 2*ii, 2 ); // Remove title and command line // Select the next item, if exists if( (int)m_lbPlugins->GetCount() >= ii ) ii = m_lbPlugins->GetCount() - 1; if( ii >= 0 ) m_lbPlugins->SetSelection( ii ); pluginInit(); }
//============================================================================= // Function: BuildRemoteList // Purpose: Append Network Neighborhood items to the list. // Notes: - Mounted gets transalated into Connected. FilteredAdd is told // to ignore the Mounted flag since we need to handle it in a weird // way manually. // - The resulting list is sorted alphabetically. //============================================================================= static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc, unsigned flagsSet, unsigned flagsUnset) { // NN query depends on dynamically loaded library. if (!s_pWNetOpenEnum || !s_pWNetEnumResource || !s_pWNetCloseEnum) { wxLogError(_("Failed to load mpr.dll.")); return false; } // Don't waste time doing the work if the flags conflict. if (flagsSet & wxFS_VOL_MOUNTED && flagsUnset & wxFS_VOL_MOUNTED) return false; //---------------------------------------------- // Generate the list according to the flags set. //---------------------------------------------- BuildListFromNN(list, pResSrc, flagsSet, flagsUnset); list.Sort(CompareFcn); //------------------------------------------------------------------------- // If mounted only is requested, then we only need one simple pass. // Otherwise, we need to build a list of all NN volumes and then apply the // list of mounted drives to it. //------------------------------------------------------------------------- if (!(flagsSet & wxFS_VOL_MOUNTED)) { // generate. wxArrayString mounted; BuildListFromNN(mounted, pResSrc, flagsSet | wxFS_VOL_MOUNTED, flagsUnset & ~wxFS_VOL_MOUNTED); mounted.Sort(CompareFcn); // apply list from bottom to top to preserve indexes if removing items. ssize_t iList = list.GetCount()-1; for (ssize_t iMounted = mounted.GetCount()-1; iMounted >= 0 && iList >= 0; iMounted--) { int compare; wxString all(list[iList]); wxString mount(mounted[iMounted]); while (compare = wxStricmp(list[iList].c_str(), mounted[iMounted].c_str()), compare > 0 && iList >= 0) { iList--; all = list[iList]; } if (compare == 0) { // Found the element. Remove it or mark it mounted. if (flagsUnset & wxFS_VOL_MOUNTED) list.RemoveAt(iList); else s_fileInfo[list[iList]].m_flags |= wxFS_VOL_MOUNTED; } iList--; } } return true; } // BuildRemoteList
void FindReplaceData::TruncateArray(wxArrayString& arr, size_t maxSize) { while(arr.GetCount() > maxSize && arr.GetCount() > 0) { arr.RemoveAt(arr.GetCount() - 1); } }