Пример #1
0
int ComboBox::findItemIndex(const std::string& text)
{
  int itemIndex = 0;

  ListItems::iterator it, end = m_items.end();
  for (it = m_items.begin(); it != end; ++it) {
    ListItem* item = *it;

    if ((m_casesensitive && item->getText() == text) ||
        (!m_casesensitive && item->getText() == text)) {
      return itemIndex;
    }

    itemIndex++;
  }

  return -1;
}
Пример #2
0
const std::string& ComboBox::getItemText(int itemIndex) const
{
  if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) {
    ListItem* item = m_items[itemIndex];
    return item->getText();
  }
  else {
    // Returns the text of the combo-box (it should be empty).
    ASSERT(getText().empty());
    return getText();
  }
}
Пример #3
0
void ComboBox::setSelectedItemIndex(int itemIndex)
{
  if (itemIndex >= 0 &&
      (size_t)itemIndex < m_items.size() &&
      m_selected != itemIndex) {
    m_selected = itemIndex;

    ListItems::iterator it = m_items.begin() + itemIndex;
    ListItem* item = *it;
    m_entry->setText(item->getText());

    onChange();
  }
}