/************************************************************************* Removes the given item from the list box. *************************************************************************/ void Listbox::removeItem(const ListboxItem* item) { if (item) { LBItemList::iterator pos = std::find(d_listItems.begin(), d_listItems.end(), item); // if item is in the list if (pos != d_listItems.end()) { // disown item (*pos)->setOwnerWindow(0); // remove item d_listItems.erase(pos); // if item was the last selected item, reset that to NULL if (item == d_lastSelected) { d_lastSelected = 0; } // if item is supposed to be deleted by us if (item->isAutoDeleted()) { // clean up this item. delete item; } WindowEventArgs args(this); onListContentsChanged(args); } } }
bool Combobox::listbox_ListContentsChangedHandler(const EventArgs& e) { WindowEventArgs args(this); onListContentsChanged(args); return true; }
/************************************************************************* Remove all items from the list. *************************************************************************/ void Tree::resetList(void) { if (resetList_impl()) { WindowEventArgs args(this); onListContentsChanged(args); } }
/************************************************************************* Causes the list box to update it's internal state after changes have been made to one or more attached ItemEntry objects. *************************************************************************/ void ItemListBase::handleUpdatedItemData(bool resort) { if (!d_destructionStarted) { d_resort |= resort; WindowEventArgs args(this); onListContentsChanged(args); } }
bool Combobox::listbox_ListContentsChangedHandler(const EventArgs&) { if (isDropDownListVisible()) updateAutoSizedDropList(); WindowEventArgs args(this); onListContentsChanged(args); return true; }
/************************************************************************* Insert an item into the list box after a specified item already in the list. *************************************************************************/ void Listbox::insertItem(ListboxItem* item, const ListboxItem* position) { // if the list is sorted, it's the same as a normal add operation if (isSortEnabled()) { addItem(item); } else if (item) { // establish ownership item->setOwnerWindow(this); // if position is NULL begin insert at begining, else insert after item 'position' LBItemList::iterator ins_pos; if (!position) { ins_pos = d_listItems.begin(); } else { ins_pos = std::find(d_listItems.begin(), d_listItems.end(), position); // throw if item 'position' is not in the list if (ins_pos == d_listItems.end()) { CEGUI_THROW(InvalidRequestException( "the specified ListboxItem for parameter 'position' is not attached to this Listbox.")); } } d_listItems.insert(ins_pos, item); WindowEventArgs args(this); onListContentsChanged(args); } }
/************************************************************************* Add the given TreeItem to the list. *************************************************************************/ void Tree::addItem(TreeItem* item) { if (item != 0) { // establish ownership item->setOwnerWindow(this); // if sorting is enabled, re-sort the list if (isSortEnabled()) { d_listItems.insert(std::upper_bound(d_listItems.begin(), d_listItems.end(), item, &lbi_less), item); } // not sorted, just stick it on the end. else { d_listItems.push_back(item); } WindowEventArgs args(this); onListContentsChanged(args); } }