//! Insert the item at the given index //! Return the index on success or -1 on failure. int ListBox::insertItem(unsigned int index, std::string text) { ListBoxItem i; i.setText( text ); _d->items.insert( _d->items.begin() + index, i ); _recalculateItemHeight( _d->font, height() ); return index; }
void ListBox::AddItem(Object* item) { ListBoxItem* listboxitem = dynamic_cast<ListBoxItem*>(item); if (listboxitem == NULL) { listboxitem = new ListBoxItem; listboxitem->set_Content(item); } // m_owner->m_itemContainerGenerator->m_containers.push_back(listboxitem); m_itemsPresenter->m_panel->AddChild(listboxitem); }
void KeyValueListBox::_updateItemText(gfx::Engine& painter, ListBoxItem& item, const Rect& textRect, Font font, const Rect& frameRect ) { ListBox::_updateItemText( painter, item, textRect, font, frameRect ); Font f = Font::create( "FONT_1" ); std::string str = item.data( "key" ).toString(); Rect finalRect = f.getTextRect( str, Rect( 0, 0, frameRect.width() / 2, frameRect.height() ), align::center, align::center ); item.draw( str, f, finalRect.lefttop() - Point( 10, 0) ); str = item.data( "value" ).toString(); finalRect = f.getTextRect( str, Rect( frameRect.width()/2, 0, frameRect.width(), frameRect.height() ), align::upperLeft, align::center ); item.draw( str, f, finalRect.lefttop() - Point( 10, 0) ); }
ListBoxItem& ListBox::addItem( const std::string& text, Font font, const int color ) { ListBoxItem i; i.setText( text ); i.setState( stNormal ); i.setTextOffset( _d->itemTextOffset ); i.OverrideColors[ ListBoxItem::simple ].font = font.isValid() ? font : _d->font; i.OverrideColors[ ListBoxItem::simple ].color = color; i.setTextAlignment( horizontalTextAlign(), verticalTextAlign() ); _d->needItemsRepackTextures = true; _d->items.push_back(i); _recalculateItemHeight( _d->font, height() ); return _d->items.back(); }
void FileListBox::_updateItemText(gfx::Engine& painter, ListBoxItem& item, const Rect& textRect, Font font, const Rect& frameRect ) { ListBox::_updateItemText( painter, item, textRect, font, frameRect ); if( !isFlag( showExtension ) ) { item.clear(); std::string text = vfs::Path( item.text() ).baseName( false ).toString(); Rect finalRect = font.getTextRect( text, Rect( Point(), frameRect.size() ), align::upperLeft, align::center ); item.draw( text, font, finalRect.lefttop() + Point( 10, 0) ); } if( isFlag( showTime ) ) { Font f = Font::create( FONT_1 ); std::string timeStr = item.data( "time" ).toString(); Rect finalRect = f.getTextRect( timeStr, Rect( Point(), frameRect.size() ), align::lowerRight, align::center ); item.draw( timeStr, f, finalRect.lefttop() - Point( 10, 0) ); } }
void LoadFileDialog::Impl::resolveItemSelected(const ListBoxItem& item) { saveItemText = item.text(); if( btnLoad ) btnLoad->setEnabled( !saveItemText.empty() ); if( btnDelete ) btnDelete->setEnabled( !saveItemText.empty() ); }
void ChangeSalary::Impl::resolveSalaryChange(const ListBoxItem& item ) { newSalary = item.tag(); }
void ListBox::_updateItemText(Engine& painter, ListBoxItem& item, const Rect& textRect, Font font, const Rect& frameRect) { item.updateText( textRect.UpperLeftCorner, font, frameRect.size() ); }
void ListBox::_drawItemText( Engine& painter, ListBoxItem& item, const Point& pos, Rect* clipRect ) { painter.draw( item.picture(), pos + item.textOffset(), clipRect ); }
void ListBox::_drawItemIcon( Engine& painter, ListBoxItem& item, const Point& pos, Rect* clipRect) { painter.draw( item.icon(), pos + item.iconOffset(), clipRect ); }