int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, void **clientData, wxClientDataType type) { MSWAllocStorage(items, LB_INITSTORAGE); const bool append = pos == GetCount(); const unsigned msg = append ? LB_ADDSTRING : LB_INSERTSTRING; if ( append ) pos = 0; int n = wxNOT_FOUND; const unsigned int numItems = items.GetCount(); for ( unsigned int i = 0; i < numItems; ++i ) { n = MSWInsertOrAppendItem(pos, items[i], msg); if ( !append ) pos++; AssignNewItemClientData(n, clientData, i, type); } return n; }
int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, unsigned int pos, void **clientData, wxClientDataType type) { MSWAllocStorage(items, LB_INITSTORAGE); const bool append = pos == GetCount(); // we must use CB_ADDSTRING when appending as only it works correctly for // the sorted controls const unsigned msg = append ? LB_ADDSTRING : LB_INSERTSTRING; if ( append ) pos = 0; int n = wxNOT_FOUND; const unsigned int numItems = items.GetCount(); for ( unsigned int i = 0; i < numItems; i++ ) { n = MSWInsertOrAppendItem(pos, items[i], msg); if ( n == wxNOT_FOUND ) return n; if ( !append ) pos++; ++m_noItems; #if wxUSE_OWNER_DRAWN if ( HasFlag(wxLB_OWNERDRAW) ) { wxOwnerDrawn *pNewItem = CreateLboxItem(n); pNewItem->SetName(items[i]); pNewItem->SetFont(GetFont()); m_aItems.Insert(pNewItem, n); } #endif // wxUSE_OWNER_DRAWN AssignNewItemClientData(n, clientData, i, type); } m_updateHorizontalExtent = true; UpdateOldSelections(); return n; }
int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, void **clientData, wxClientDataType type) { MSWAllocStorage(items, CB_INITSTORAGE); const bool append = pos == GetCount(); // use CB_ADDSTRING when appending at the end to make sure the control is // resorted if it has wxCB_SORT style const unsigned msg = append ? CB_ADDSTRING : CB_INSERTSTRING; if ( append ) pos = 0; int n = wxNOT_FOUND; const unsigned numItems = items.GetCount(); for ( unsigned i = 0; i < numItems; ++i ) { n = MSWInsertOrAppendItem(pos, items[i], msg); if ( n == wxNOT_FOUND ) return n; if ( !append ) pos++; AssignNewItemClientData(n, clientData, i, type); } // we need to refresh our size in order to have enough space for the // newly added items if ( !IsFrozen() ) MSWUpdateDropDownHeight(); InvalidateBestSize(); return n; }