void MultiListBox::removeItemAt(size_t _index) { MYGUI_ASSERT(!mVectorColumnInfo.empty(), "MultiListBox::removeItemAt"); MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::removeItemAt"); size_t index = BiIndexBase::removeItemAt(_index); for (VectorColumnInfo::iterator iter = mVectorColumnInfo.begin(); iter != mVectorColumnInfo.end(); ++iter) { (*iter).list->removeItemAt(index); } // если надо, то меняем выделенный элемент size_t count = mVectorColumnInfo.begin()->list->getItemCount(); if (count == 0) mItemSelected = ITEM_NONE; else if (mItemSelected != ITEM_NONE) { if (_index < mItemSelected) mItemSelected --; else if ((_index == mItemSelected) && (mItemSelected == count)) mItemSelected --; } updateBackSelected(BiIndexBase::convertToBack(mItemSelected)); }
void MultiListBox::flipList() { if (ITEM_NONE == mSortColumnIndex) return; size_t last = mVectorColumnInfo.front().list->getItemCount(); if (0 == last) return; last --; size_t first = 0; while (first < last) { BiIndexBase::swapItemsBackAt(first, last); for (VectorColumnInfo::iterator iter = mVectorColumnInfo.begin(); iter != mVectorColumnInfo.end(); ++iter) { (*iter).list->swapItemsAt(first, last); } first++; last--; } updateBackSelected(BiIndexBase::convertToBack(mItemSelected)); }
void MultiListBox::setIndexSelected(size_t _index) { if (_index == mItemSelected) return; MYGUI_ASSERT(!mVectorColumnInfo.empty(), "MultiListBox::setIndexSelected"); MYGUI_ASSERT_RANGE_AND_NONE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::setIndexSelected"); mItemSelected = _index; updateBackSelected(BiIndexBase::convertToBack(mItemSelected)); }
void MultiListBox::notifyListChangePosition(ListBox* _sender, size_t _position) { for (VectorColumnInfo::iterator iter = mVectorColumnInfo.begin(); iter != mVectorColumnInfo.end(); ++iter) { if (_sender != (*iter).list) (*iter).list->setIndexSelected(_position); } updateBackSelected(_position); mItemSelected = BiIndexBase::convertToFace(_position); // наш евент eventListChangePosition(this, mItemSelected); }
void MultiList2::sortList() { return; if (ITEM_NONE == mSortColumnIndex) return; ListBox* list = mVectorColumnInfo[mSortColumnIndex].list; size_t count = list->getItemCount(); if (0 == count) return; // shell sort int first; size_t last; for (size_t step = count >> 1; step > 0 ; step >>= 1) { for (size_t i = 0; i < (count - step); ++i) { first = (int)i; while (first >= 0) { last = first + step; if (compare(list, first, last)) { BiIndexBase::swapItemsBackAt(first, last); for (VectorColumnInfo::iterator iter = mVectorColumnInfo.begin(); iter != mVectorColumnInfo.end(); ++iter) { (*iter).list->swapItemsAt(first, last); } } first--; } } } frameAdvise(false); updateBackSelected(BiIndexBase::convertToBack(mItemSelected)); }