当前位置: 首页>>代码示例>>C++>>正文


C++ ListBox类代码示例

本文整理汇总了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 );
}
开发者ID:binakot,项目名称:caesaria-game,代码行数:33,代码来源:change_salary_window.cpp

示例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);
}
开发者ID:szlinjia,项目名称:HuntingButterfly,代码行数:26,代码来源:win_support.cpp

示例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);
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:36,代码来源:menu.cpp

示例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;
}
开发者ID:JamesLinus,项目名称:Medusa,代码行数:7,代码来源:NodeFactory.cpp

示例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 );
  }
开发者ID:Ecordonnier,项目名称:caesaria-game,代码行数:25,代码来源:menu.cpp

示例6: ListBox

ListBox* DeprecatedRenderSelect::createListBox()
{
    ListBox *lb = new ListBox();
    lb->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
    m_ignoreSelectEvents = false;
    return lb;
}
开发者ID:oroisec,项目名称:ios,代码行数:7,代码来源:DeprecatedRenderSelect.cpp

示例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);
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:8,代码来源:filedialog.cpp

示例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
    }
  }
开发者ID:whizzter,项目名称:aseprite,代码行数:33,代码来源:font_popup.cpp

示例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);
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:34,代码来源:filedialog.cpp

示例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);
}
开发者ID:aidanfarrow,项目名称:GC_tidy,代码行数:30,代码来源:VSLBuiltin.C

示例11: ListBox

bool MyApp::OnInit()
{
	ListBox *listBox = new ListBox(wxT("ListBox测试"));
	listBox->Show(true);

	return true;
}
开发者ID:xuweirong,项目名称:wxWidgets,代码行数:7,代码来源:main.cpp

示例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;
}
开发者ID:Stabledog,项目名称:dddbash,代码行数:29,代码来源:ListBox.C

示例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);
  }
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:9,代码来源:menu.cpp

示例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;
}
开发者ID:EEmmanuel7,项目名称:begui,代码行数:57,代码来源:main.cpp

示例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;
}
开发者ID:codekiddy2,项目名称:freeorion,代码行数:9,代码来源:StyleFactory.cpp


注:本文中的ListBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。