void ComboBox::setOpen(bool b) { m_open = b; if (m_open) { int newHeight = m_height; for(unsigned int i = 0; i < m_items.size(); i++) { ComboBoxItem* item = m_items.at(i); item->setSize(m_width, ARK2D::getRenderer()->getFont()->getLineHeight()); item->m_parent = m_parent; newHeight += item->getHeight(); } m_height = newHeight; } else { m_height = m_originalHeight; } }
void ComboBox::setOpen(bool b) { m_open = b; if (m_open) { int newHeight = m_height; for(unsigned int i = 0; i < m_items.size(); i++) { ComboBoxItem* item = m_items.at(i); item->setSize(m_width, ARK2D::getRenderer()->getFont()->getLineHeight()); item->m_parent = m_parent; newHeight += item->getHeight(); } m_height = newHeight; } else { m_height = m_originalHeight; // state state to off for all children for(unsigned int i = 0; i < m_items.size(); i++) { m_items[i]->m_state = Button::STATE_OFF; } } }
void UITestGameState::init(GameContainer* container, StateBasedGame* game) { Panel* root = new Panel(); root->setSize(container->getWidth(), container->getHeight()); root->setShowBorder(false); rightPanel = new ScrollPanel(); rightPanel->setLocation(50, 50); rightPanel->setWidth(container->getWidth()/2); rightPanel->setHeight(container->getHeight()-100); rightPanel->m_layout = ScrollPanel::LAYOUT_FLOW; Label* label2 = new Label("A Text Label #2"); label2->setMargin(10); rightPanel->add(label2); TextField* textField2 = new TextField(); textField2->setMargin(10); textField2->setSize(200, 30); textField2->setText("A Text Field #2"); rightPanel->add(textField2); Label* label3 = new Label("A Text Label #2"); label3->setMargin(10); rightPanel->add(label3); ComboBox* comboBox = new ComboBox(); comboBox->setMargin(10); comboBox->setSize(200, 30); comboBox->setItemChangedEvent((void*) &itemChangedEvent); ComboBoxItem* comboItemOne = new ComboBoxItem(); comboItemOne->setText("Item One"); comboBox->addItem(comboItemOne); ComboBoxItem* comboItemTwo = new ComboBoxItem(); comboItemTwo->setText("Item Two"); comboBox->addItem(comboItemTwo); rightPanel->add(comboBox); Label* label4 = new Label("A Text Label #3"); label4->setMargin(10); rightPanel->add(label4); CheckBox* checkBox = new CheckBox(); checkBox->setMargin(10); checkBox->setChecked(false); checkBox->setStateChangedEvent((void*) &stateChangedEvent); rightPanel->add(checkBox); CheckBox* checkBox2 = new CheckBox(); checkBox2->setMargin(10); checkBox2->setChecked(true); rightPanel->add(checkBox2); Label* label5 = new Label("A Text Label four is big"); label5->setMargin(10); rightPanel->add(label5); Button* button = new Button(); button->setText("Click me!"); button->setSize(50, 50); button->setEvent((void*) &buttonClickEvent); button->setMargin(10); rightPanel->add(button); root->add(rightPanel); m_rootUIComponent = root; }