本文整理汇总了C++中ListBox类的典型用法代码示例。如果您正苦于以下问题:C++ ListBox类的具体用法?C++ ListBox怎么用?C++ ListBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: win_ListBox_Select
int win_ListBox_Select (
char *title,
char **lines, // array of string descriptions
int num_lines ) // # in array
{
int i, selection;
// If only 1 line available, return index to this line
if (num_lines == 1)
selection = 0;
else {
// Allow user to select from a MFC dialog box
CArray <CString, CString> list;
for (i=0; i<num_lines; i++)
list.Add (lines[i]);
ListBox dialog (NULL, title);
dialog.SetContents (&list);
//ShowCursor (TRUE);
if (dialog.DoModal () != IDOK)
selection = -1;
else
selection = dialog.GetSelection ();
}
return (selection);
}
示例3: Dialog
//! the assign texture button
void Menu::assignTexture(Gui::GuiElement* elem){
//Dialog
Dialog* dia = new Dialog();
//Textures
ListBox* lb = new ListBox();
lb->setPosition(Vector2D(50, 100));
lb->setSpan(Vector2D(400,600));
vector<Texture*> textures = Graphic::instance()->getScene().getTextures();
for (unsigned i = 0; i < textures.size(); i++){
lb->addEntry(textures[i]->getName());
}
dia->addElement(lb);
//Texture stages
DropDownButton* stages = new DropDownButton();
stages->setPosition(Vector2D(500, 680));
dia->addUnscaledElement(stages);
stages->calcDDPos(1);
stages->setText("Stage 0");
stages->addEntry("Stage 0");
stages->addEntry("Stage 1");
stages->addEntry("Stage 2");
stages->addEntry("Stage 3");
stages->addEntry("Stage 4");
stages->addEntry("Stage 5");
stages->addEntry("Stage 6");
stages->addEntry("Stage 7");
//OK button
PDButton* ok = new PDButton();
ok->setPosition(Vector2D(575, 50));
ok->setSpan(Vector2D(75,18));
ok->setText(" OK");
ok->setCbFunc(assignTextureDialog);
dia->addUnscaledElement(ok);
CGE::Engine::instance()->addGuiListener(dia);
}
示例4: ListBox
ListBox* NodeFactory::CreateStringListBox(const List<WHeapString>& strItems, bool isSingleLine/*=true*/)
{
ListBox* listBox = new ListBox();
listBox->SetDataSource(new StringListDataSource(strItems, isSingleLine));
listBox->Initialize();
return listBox;
}
示例5: 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 );
}
示例6: ListBox
ListBox* DeprecatedRenderSelect::createListBox()
{
ListBox *lb = new ListBox();
lb->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
m_ignoreSelectEvents = false;
return lb;
}
示例7: writeFilename
//! The write filename callback
void FileDialog::writeFilename(GuiElement* elem){
FileDialog* dia = dynamic_cast<FileDialog*>(elem->getParent());
InputField* inp = dynamic_cast<InputField*>(dia->getElement(2));
ListBox* files = dynamic_cast<ListBox*>(dia->getElement(1));
string file = files->selectedItem();
inp->setText(file);
}
示例8: onSelect
void onSelect() override {
if (m_image)
return;
ListBox* listbox = static_cast<ListBox*>(getParent());
if (!listbox)
return;
app::skin::SkinTheme* theme = app::skin::SkinTheme::instance();
gfx::Color color = theme->colors.text();
try {
m_image.reset(
render_text(
m_filename, 16,
"ABCDEabcde", // TODO custom text
doc::rgba(gfx::getr(color),
gfx::getg(color),
gfx::getb(color),
gfx::geta(color)),
true)); // antialias
View* view = View::getView(listbox);
view->updateView();
listbox->makeChildVisible(this);
// Save the thumbnail for future FontPopups
g_thumbnails[m_filename] = m_image;
}
catch (const std::exception&) {
// Ignore errors
}
}
示例9: ListBox
void FileDialog::init(){
//Directories
ListBox* dir = new ListBox();
dir->setPosition(Vector2D(50, 100));
dir->setSpan(Vector2D(400, 600));
dir->addEntries(Filesystem::getDirectories(cwd_+SEPARATOR+path_));
dir->setCbFunc(&changeDir);
addElement(dir);
//Files
ListBox* file = new ListBox();
file->setPosition(Vector2D(564, 100));
file->setSpan(Vector2D(400, 600));
file->addEntries(Filesystem::getFiles(cwd_+SEPARATOR+path_));
file->setCbFunc(&writeFilename);
addElement(file);
//Input field
InputField* inp = new InputField();
inp->setOpacity(0.8f);
inp->setPosition(Vector2D(50, 50));
inp->setSpan(Vector2D(300,18));
addUnscaledElement(inp);
//OK button
PDButton* ok = new PDButton();
ok->setPosition(Vector2D(575, 50));
ok->setSpan(Vector2D(75,18));
ok->setText(" OK");
addUnscaledElement(ok);
//Abort button
PDButton* abort = new PDButton();
abort->setPosition(Vector2D(700, 50));
abort->setSpan(Vector2D(75,18));
abort->setText(" Abort");
addUnscaledElement(abort);
}
示例10: CHECK_ATOMS
// Stacked alignment
static Box *op_ualign(ListBox *args)
{
CHECK_ATOMS(args);
UAlignBox *ret = 0;
for (ListBox *b = args; !b->isEmpty(); b = b->tail())
{
Box *box = b->head();
if (ret == 0)
ret = new UAlignBox;
*ret ^= box;
}
// No child? Return null box.
if (ret == 0)
return new NullBox;
// One child? Return it.
if (ret->nchildren() == 1)
{
Box *child = (*ret)[0]->link();
ret->unlink();
return child;
}
// Return normalized alignment
return normalize(ret);
}
示例11: ListBox
bool MyApp::OnInit()
{
ListBox *listBox = new ListBox(wxT("ListBox测试"));
listBox->Show(true);
return true;
}
示例12: assert
// Append list
ListBox *ListBox::cons(ListBox *b)
{
assert(!isEmpty());
if (!b->isEmpty())
{
// Replace final ListBox by B
const ListBox *t = this;
ListBox *attach = 0;
while (!t->isEmpty())
{
attach = (ListBox *)t;
t = t->tail();
}
assert (attach != 0);
assert (attach->tail()->isEmpty());
attach->tail()->unlink();
attach->_tail() = b->link();
attach->_last = b->_last;
return attach;
}
return 0;
}
示例13: setModel
//! The set model callback
void Menu::setModel(Gui::GuiElement* elem){
Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
ListBox* lb = dynamic_cast<ListBox*>(dia->getElement(0));
int sel = lb->selected();
if (sel >= 0){
Graphic::instance()->addModel(sel);
}
}
示例14: 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;
}
示例15: NewListBox
ListBox* StyleFactory::NewDropDownListListBox(Clr color, Clr interior/* = CLR_ZERO*/) const
{
ListBox* lb = NewListBox(color, interior);
// Because the rows of DropDownLists must be the same size, there's
// no need to worry that the bottom entry will get cut off if the
// scrollbar ends exactly at the list's end.
lb->AddPaddingAtEnd(false);
return lb;
}