void StartMenu::Impl::showLanguageOptions() { Widget* parent = game->gui()->rootWidget(); Size windowSize( 512, 384 ); Label* frame = new Label( parent, Rect( Point(), windowSize ), "", false, gui::Label::bgWhiteFrame ); ListBox* lbx = new ListBox( frame, Rect( 0, 0, 1, 1 ), -1, true, true ); PushButton* btn = new PushButton( frame, Rect( 0, 0, 1, 1), _("##apply##") ); WidgetEscapeCloser::insertTo( frame ); frame->setCenter( parent->center() ); lbx->setFocus(); lbx->setGeometry( RectF( 0.05, 0.05, 0.95, 0.85 ) ); btn->setGeometry( RectF( 0.1, 0.88, 0.9, 0.95 ) ); VariantMap languages = config::load( SETTINGS_RC_PATH( langModel ) ); std::string currentLang = SETTINGS_VALUE( language ).toString(); int currentIndex = -1; foreach( it, languages ) { lbx->addItem( it->first ); std::string ext = it->second.toMap().get( literals::ext ).toString(); if( ext == currentLang ) currentIndex = std::distance( languages.begin(), it ); }
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 ); }
int main(int argc, char *argv[]) { // initialize glut glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); // create the main window glutInitWindowPosition(30,30); glutInitWindowSize(800,600); glutCreateWindow("beGUI GLUT Example"); // set the display function glutDisplayFunc(renderScene); glutIdleFunc(renderScene); // resize function glutReshapeFunc(changeSize); // handle mouse events glutMouseFunc(processMouse); glutMotionFunc(processMouseActiveMotion); glutPassiveMotionFunc(processMousePassiveMotion); // initialize beGUI subsystems initBeGUI(); // create the beGUI window myWindow.create(20, 20, 200, 200, "test"); myBtn1.create(20, 20, "Show Modal Dialog", 101, makeFunctor((Functor1<int>*)0, &onButtonClick)); myWindow.addComponent(&myBtn1); myList1.create(20, 50, 160, 100, ListBox::SINGLE_SELECT); myList1.handleOnItemSelect(makeFunctor((Functor1<int>*)0, &onListSelect)); myList1.addItem("White"); myList1.addItem("Red"); myList1.addItem("Orange"); myList1.addItem("Green"); myList1.addItem("Yellow"); myList1.addItem("Blue"); myList1.addItem("Purple"); myList1.addItem("Grey"); myWindow.addComponent(&myList1); // create a container to hold all beGUI components mainContainer.setPos(0,0); mainContainer.setSize(800, 600); mainContainer.addComponent(&myWindow); // create a modal dialog myModalDlg.create(100, 100, 300, 300, "Modal Dialog"); myDlgBtn1.create(30, 30, "Close Dialog", 10001, makeFunctor((Functor1<int>*)0, &onCloseDlg)); myModalDlg.addComponent(&myDlgBtn1); // start the main loop glutMainLoop(); return 0; }