/************************************************************************* Remove all items from the list. *************************************************************************/ bool Listbox::resetList_impl(void) { // just return false if the list is already empty if (getItemCount() == 0) { return false; } // we have items to be removed and possible deleted else { // delete any items we are supposed to for (size_t i = 0; i < getItemCount(); ++i) { // if item is supposed to be deleted by us if (d_listItems[i]->isAutoDeleted()) { // clean up this item. delete d_listItems[i]; } } // clear out the list. d_listItems.clear(); d_lastSelected = 0; return true; } }
void CmdBox::updateList(QString txt){ QList<Cmd> *list = cmdManager->getCmdList(getItemCount(), txt); for(int i=0; i<getItemCount() && i<list->count(); ++i){ getItem(i)->setText(list->at(i)); getItem(i)->setIcon(getIconFromCmd(list->at(i).getCmd())); } }
void CmdBox::keyPressEvent(QKeyEvent *event){ bool arrowPressed = false; switch(event->key()){ case Qt::Key_Down: if(event->modifiers() & Qt::ALT){ }else{ changeSelectedItem(1); arrowPressed = true; } break; case Qt::Key_Up: changeSelectedItem(-1); arrowPressed = true; break; default: QDialog::keyPressEvent(event); break; } if(arrowPressed){ if(getSelectedItem() < 0){ setSelectedItem(getItemCount()); }else{ setSelectedItem(getSelectedItem() % (getItemCount()+1)); } getItem(getSelectedItem())->setSelected(true); } return QDialog::keyPressEvent(event); }
bool TransferItem::onTradeEvent(TradeEvents_t event, Player* owner, Player* seller) { switch(event) { case ON_TRADE_TRANSFER: { if(house) house->setOwnerEx(owner->getGUID(), true); g_game.internalRemoveItem(NULL, this, getItemCount()); seller->transferContainer.setParent(NULL); break; } case ON_TRADE_CANCEL: { owner->transferContainer.setParent(NULL); owner->transferContainer.__removeThing(this, getItemCount()); g_game.freeThing(this); break; } default: return false; } return true; }
void Menu::setSelectedIndex(int index) { selectedIndex = index; // Prevent selecting beyond the length of menu items if(selectedIndex >= getItemCount()) { selectedIndex = getItemCount() - 1; } selectMenuItem(selectedIndex); }
void MainMenu::recalculateSize_() { Rect parentRect = getParent()->getClientRect(); // client rect of parent //AbstractSkin* skin = getEnvironment()->getSkin(); Font font = Font::create( FONT_2_WHITE ); int height = std::max<int>( DEFAULT_MENU_HEIGHT, getHeight() ); setGeometry( Rect( parentRect.UpperLeftCorner.getX(), parentRect.UpperLeftCorner.getY(), parentRect.LowerRightCorner.getX(), parentRect.UpperLeftCorner.getY() + height ) ); Rect rect; rect.UpperLeftCorner = parentRect.UpperLeftCorner; height = std::max<int>( font.getSize("A").getHeight(), height ); //if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT )) // height = skin->getSize(EGDS_MENU_HEIGHT); int width = rect.UpperLeftCorner.getX(); int i; for( i=0; i<(int)getItemCount(); ++i) { ContextMenuItem* refItem = getItem( i ); if ( refItem->isSeparator() ) { refItem->setDim( Size( 16, getHeight() ) ); } else { Size itemSize = font.getSize( refItem->getText() ) + Size( 20, 0 ); itemSize.setHeight( getHeight() ); refItem->setDim( itemSize ); } refItem->setOffset( width ); width += refItem->getDim().getWidth(); } // recalculate submenus for (i=0; i<(int)getItemCount(); ++i) { ContextMenuItem* refItem = getItem( i ); Rect rectangle( refItem->getOffset(), 0, refItem->getOffset() + refItem->getDim().getWidth(), height ); refItem->setGeometry( rectangle ); if (refItem->getSubMenu()) { // move submenu Size itemSize = refItem->getSubMenu()->getAbsoluteRect().getSize(); refItem->getSubMenu()->setGeometry( Rect( refItem->getOffset(), height, refItem->getOffset() + itemSize.getWidth()-5, height+itemSize.getHeight() )); } } }
int Item::getWorth() const { switch(getID()){ case ITEM_COINS_GOLD: return getItemCount(); case ITEM_COINS_PLATINUM: return getItemCount() * 100; case ITEM_COINS_CRYSTAL: return getItemCount() * 10000; default: return 0; } }
uint16_t Item::getSubType() const { const ItemType& it = items[getID()]; if (it.isFluidContainer() || it.isSplash()) { return getFluidType(); } else if (it.stackable) { return getItemCount(); } else if (it.charges != 0) { return getCharges(); } return getItemCount(); }
void CmdBox::initList(){ getCmdList()->setIconSize(QSize(iconSize, iconSize)); for(int i=0; i<getItemCount(); ++i){ QListWidgetItem *item = new QListWidgetItem("", getCmdList()); item->setIcon(QIcon::fromTheme(WARNING_ICON)); item->setData(Qt::UserRole, i); } QListWidgetItem *item = new QListWidgetItem("", getCmdList()); item->setIcon(QIcon::fromTheme(RUN_ICON)); item->setData(Qt::UserRole, getItemCount()); getCmdList()->item(0)->setSelected(true); updateList(""); }
TArray<UItemBase*> UInventoryComponent::removeItems(FString& itemName, int32 ammount) { TArray<UItemBase*> item = lookForItems(itemName); if (ammount < 0) { for (int32 i = 0; i < item.Num(); i++) { removeItem(item[i]); } return item; } int32 maxAmm = getItemCount(itemName); if (ammount > maxAmm) { TArray<UItemBase*> returnItems; for (int32 i = 0; i < item.Num(); i++) { if (maxAmm > item[i]->ammount) { maxAmm -= item[i]->ammount; returnItems.Add(item[i]); } else { item[i]->ammount -= maxAmm; break; } } return returnItems; } else { return TArray<UItemBase*>(); } }
/************************************************************************* Return the ListboxItem under the given window local pixel co-ordinate. *************************************************************************/ ListboxItem* Listbox::getItemAtPoint(const Point& pt) const { Rect renderArea(getListRenderArea()); // point must be within the rendering area of the Listbox. if (renderArea.isPointInRect(pt)) { float y = renderArea.d_top - d_vertScrollbar->getScrollPosition(); // test if point is above first item if (pt.d_y >= y) { for (size_t i = 0; i < getItemCount(); ++i) { y += d_listItems[i]->getPixelSize().d_height; if (pt.d_y < y) { return d_listItems[i]; } } } } return NULL; }
void CListBox::paint() { liststart = (selected/listmaxshow)*listmaxshow; int lastnum = liststart + listmaxshow; if(lastnum<10) numwidth = g_Fonts->channellist_number->getRenderWidth("0"); else if(lastnum<100) numwidth = g_Fonts->channellist_number->getRenderWidth("00"); else if(lastnum<1000) numwidth = g_Fonts->channellist_number->getRenderWidth("000"); else if(lastnum<10000) numwidth = g_Fonts->channellist_number->getRenderWidth("0000"); else // if(lastnum<100000) numwidth = g_Fonts->channellist_number->getRenderWidth("00000"); for(unsigned int count=0; count<listmaxshow; count++) { paintItem(count); } int ypos = y+ theight; int sb = fheight* listmaxshow; frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT+ 1); int sbc= ((getItemCount()- 1)/ listmaxshow)+ 1; float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT+ 3); }
/************************************************************************* Set the select state of an attached ListboxItem. *************************************************************************/ void Listbox::setItemSelectState(size_t item_index, bool state) { if (item_index < getItemCount()) { // only do this if the setting is changing if (d_listItems[item_index]->isSelected() != state) { // conditions apply for single-select mode if (state && !d_multiselect) { clearAllSelections_impl(); } d_listItems[item_index]->setSelected(state); WindowEventArgs args(this); onSelectionChanged(args); } } else { CEGUI_THROW(InvalidRequestException("Listbox::setItemSelectState - the value passed in the 'item_index' parameter is out of range for this Listbox.")); } }
/** * Empties the listbox */ void CListBox::clear() { while(getItemCount() > 0) { SendMessage(hwnd, LB_DELETESTRING, 0, 0); } }
/************************************************************************* Return the ListboxItem under the given screen pixel co-ordinate. *************************************************************************/ ListboxItem* Listbox::getItemAtPoint(const Point& pt) const { const Point local_pos(CoordConverter::screenToWindow(*this, pt)); const Rect renderArea(getListRenderArea()); // point must be within the rendering area of the Listbox. if (renderArea.isPointInRect(local_pos)) { float y = renderArea.d_top - getVertScrollbar()->getScrollPosition(); // test if point is above first item if (local_pos.d_y >= y) { for (size_t i = 0; i < getItemCount(); ++i) { y += d_listItems[i]->getPixelSize().d_height; if (local_pos.d_y < y) { return d_listItems[i]; } } } } return 0; }
/** * Returns the selected item */ wstring CListBox::getSelectedItem() { if(getItemCount() == 0) { return L""; } return getItem(getSelectedIndex()); }
double Item::getWeight() const { if (isStackable()) { return items[id].weight * std::max<int32_t>(1, getItemCount()); } return items[id].weight; }
bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator) { Win32Window *pWindow = mCanvas ? dynamic_cast<Win32Window*>(mCanvas->getPlatformWindow()) : NULL; bool isAttached = isAttachedToMenuBar(); if(isAttached && pWindow == NULL) return false; // Are we out of range? if ( pos >= getItemCount() ) return false; MENUITEMINFOA mi; mi.cbSize = sizeof(mi); mi.fMask = MIIM_TYPE; if(title && *title) mi.fType = MFT_STRING; else mi.fType = MFT_SEPARATOR; char buf[1024]; if(accelerator && *accelerator) { dSprintf(buf, sizeof(buf), "%s\t%s", title, accelerator); if(isAttached) pWindow->removeAccelerators(mData->mAccelerators); // Build entry for accelerator table EventDescriptor accelDesc; if(ActionMap::createEventDescriptor(accelerator, &accelDesc)) mData->insertAccelerator(accelDesc, pos); else Con::errorf("PopupMenu::setItem - Could not create event descriptor for accelerator \"%s\"", accelerator); if(isAttached) pWindow->addAccelerators(mData->mAccelerators); } else dSprintf(buf, sizeof(buf), "%s", title); mi.dwTypeData = (LPSTR)buf; if(SetMenuItemInfoA(mData->mMenu, pos, TRUE, &mi)) { if(isAttached) { HWND hWindow = pWindow->getHWND(); DrawMenuBar(hWindow); } return true; } return false; }
void CBEChannelSelectWidget::paintItem(uint32_t itemNr, int paintNr, bool pselected) { int ypos = y+ theight + paintNr*iheight; fb_pixel_t color; fb_pixel_t bgcolor; if (pselected) { color = COL_MENUCONTENTSELECTED_TEXT; bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; if(itemNr < getItemCount()) { initItem2DetailsLine (paintNr, itemNr); paintDetails(itemNr); } frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, bgcolor, RADIUS_LARGE); } else { color = COL_MENUCONTENT_TEXT; bgcolor = COL_MENUCONTENT_PLUS_0; frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, bgcolor); } if(itemNr < getItemCount()) { if( isChannelInBouquet(itemNr)) { frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, x+10, ypos, iheight); } else { //frameBuffer->paintBoxRel(x+8, ypos+4, NEUTRINO_ICON_BUTTON_GREEN_WIDTH, fheight-4, bgcolor); frameBuffer->paintBoxRel(x+10, ypos, iconoffset, iheight, bgcolor); } //g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 8 + NEUTRINO_ICON_BUTTON_GREEN_WIDTH + 8, ypos+ fheight, width - (8 + NEUTRINO_ICON_BUTTON_GREEN_WIDTH + 8 + 8), Channels[itemNr]->getName(), color, 0, true); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 20 + iconoffset, ypos + iheight - (iheight-fheight)/2, width - 20 - iconoffset, Channels[itemNr]->getName(), color, 0, true); if(Channels[itemNr]->scrambled) frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x+width- 15 - 28, ypos, fheight); } }
void CTibiaItem::fillTypedItemIdArray(int ind) { refreshItemLists(); typedList.RemoveAll(); for (int loop = 0; loop < getItemCount(); loop++) { if (itemList.GetTypeAtIndex(loop) & ind) typedList.Add(itemList.GetValueAtIndex(loop), itemList.GetTextAtIndex(loop), itemList.GetExtraInfoAtIndex(loop), itemList.GetTypeAtIndex(loop)); } }
/** * Checks if the item s is in the list box */ bool CListBox::hasItem(std::wstring s) { for(int i=0;i<getItemCount(); i++) { if(getItem(i) == s) { return true; } } return false; }
/************************************************************************* Perform the actual rendering for this Window. *************************************************************************/ void Listbox::populateRenderCache() { // get the derived class to render general stuff before we handle the items cacheListboxBaseImagery(); // // Render list items // Vector3 itemPos; Size itemSize; Rect itemClipper, itemRect; float widest = getWidestItemWidth(); // calculate position of area we have to render into Rect itemsArea(getListRenderArea()); // set up some initial positional details for items itemPos.d_x = itemsArea.d_left - d_horzScrollbar->getScrollPosition(); itemPos.d_y = itemsArea.d_top - d_vertScrollbar->getScrollPosition(); itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ(); float alpha = getEffectiveAlpha(); // loop through the items size_t itemCount = getItemCount(); for (size_t i = 0; i < itemCount; ++i) { itemSize.d_height = d_listItems[i]->getPixelSize().d_height; // allow item to have full width of box if this is wider than items itemSize.d_width = ceguimax(itemsArea.getWidth(), widest); // calculate destination area for this item. itemRect.d_left = itemPos.d_x; itemRect.d_top = itemPos.d_y; itemRect.setSize(itemSize); itemClipper = itemRect.getIntersection(itemsArea); // skip this item if totally clipped if (itemClipper.getWidth() == 0) { itemPos.d_y += itemSize.d_height; continue; } // draw this item d_listItems[i]->draw(d_renderCache, itemRect, itemPos.d_z, alpha, &itemClipper); // update position ready for next item itemPos.d_y += itemSize.d_height; } }
//----------------------------------------------------------------------------// void ListWidget::setIndexSelectionState(size_t item_index, bool state) { if (item_index > getItemCount()) { CEGUI_THROW(InvalidRequestException( "the value passed in the 'item_index' parameter is out of range for this ListWidget.")); } ListView::setIndexSelectionState( d_itemModel.makeIndex(item_index, d_itemModel.getRootIndex()), state); }
ItemModel::ModelIndex ProxyItemModel::mapFromSource (ModelIndex index) { const ItemStack& itemToSearch = mSourceModel->getItem(index); for (size_t i=0; i<getItemCount(); ++i) { const ItemStack& item = getItem(i); if (item == itemToSearch) return i; } return -1; }
/************************************************************************* Return the sum of all item heights *************************************************************************/ float Listbox::getTotalItemsHeight(void) const { float height = 0; for (size_t i = 0; i < getItemCount(); ++i) { height += d_listItems[i]->getPixelSize().d_height; } return height; }
BOOL LLComboBox::handleScrollWheel(S32 x, S32 y, S32 clicks) { if (mList->getVisible()) return mList->handleScrollWheel(x, y, clicks); if (mAllowTextEntry) // We might be editable if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text return false; setCurrentByIndex(llclamp(getCurrentIndex() + clicks, 0, getItemCount() - 1)); prearrangeList(); onCommit(); return true; }
/** * Selects the given element */ void CListBox::select(std::wstring _elem) { for(int i=0; i<getItemCount(); i++) { wstring itI = getItem(i); if(itI == _elem) { select(i); return; } } }
//----------------------------------------------------------------------------// bool TreeItem::handleFontRenderSizeChange(const Font* const font) { if (getFont() == font) return true; for (size_t i = 0; i < getItemCount(); ++i) { if (d_listItems[i]->handleFontRenderSizeChange(font)) return true; } return false; }
int Menu::getPreviousIndex(int startingPoint) { int previousIndex = startingPoint - 1; if(enableSelectionWrap) { int itemCount = static_cast<int>(getItemCount()); if(itemCount == 0) { previousIndex = 0; } else { if(previousIndex < 0) { previousIndex = itemCount - 1; } else if(previousIndex >= itemCount) { previousIndex = 0; } } } else { previousIndex = std::min(previousIndex, static_cast<int>(getItemCount()) - 1); previousIndex = std::max(previousIndex, 0); } return previousIndex; }
bool CAndroidGUIComboBox::OnEvent(const SEvent& event) { bool result = CGUIComboBox::OnEvent(event); if (getItemCount() != 0 && isEnabled() && result && (event.GUIEvent.EventType == EGET_BUTTON_CLICKED || event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP )) { char* content; char** contents; char* label; int count = getItemCount(); contents = (char **)malloc(count * sizeof(char *)); for (int i = 0; i < count; i++) { content = (char *)malloc(256 * 4); BufferIO::EncodeUTF8(getItem(i), content); *(contents + i) = content; } android::showAndroidComboBoxCompat(ygo::mainGame->appMain, true, contents, count); for (int i = 0; i < count; i++) { free(*(contents + i)); } free(contents); } return result; }