예제 #1
0
//! 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;
}
예제 #2
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();
}