本文整理汇总了C++中ListBox::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ListBox::addItem方法的具体用法?C++ ListBox::addItem怎么用?C++ ListBox::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox::addItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: windowSize
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 );
}
示例2: Window
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 );
}
示例3: main
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;
}