ChangeSalary::ChangeSalary(Widget* p, unsigned int salary)
  : Window( p, Rect(), "" ), __INIT_IMPL(ChangeSalaryWindow)
{
  setupUI( ":/gui/changesalary.gui");
  setCenter( parent()->center() );

  _dfunc()->newSalary = salary;

  ListBox* lbxTitles;
  GET_WIDGET_FROM_UI( lbxTitles )
  if( lbxTitles )
  {
    world::GovernorRanks ranks = world::EmpireHelper::ranks();
    for( auto rank : ranks )
    {
      std::string salaryStr = _( "##" + rank.rankName + "_salary##" );
      ListBoxItem& item = lbxTitles->addItem( salaryStr + "   " + utils::i2str( rank.salary ) );
      item.setTag( rank.salary );
      if( rank.salary == salary )
      {
        lbxTitles->setSelected( lbxTitles->itemsCount() - 1 );
      }
    }
  }

  INIT_WIDGET_FROM_UI( PushButton*, btnCancel  )
  INIT_WIDGET_FROM_UI( PushButton*, btnOk )

  CONNECT( btnCancel, onClicked(), this, ChangeSalary::deleteLater );
  CONNECT( btnOk, onClicked(), _dfunc().data(), Impl::setNewSalary );
  CONNECT( btnOk, onClicked(), this, ChangeSalary::deleteLater  );
  CONNECT( lbxTitles, onItemSelected(), _dfunc().data(), Impl::resolveSalaryChange );
}
Beispiel #2
0
void DeprecatedRenderSelect::updateSelection()
{
    const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
    int i;
    // if multi-select, we select only the new selected index
    ListBox *listBox = static_cast<ListBox*>(m_widget);
    int j = 0;
    for (i = 0; i < int(listItems.size()); i++) {
        listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
                            static_cast<HTMLOptionElement*>(listItems[i])->selected());
        if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
            ++j;
        
    }

    m_selectionChanged = false;
}