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
0
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
0
//! 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
0
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
0
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
0
ListBox* DeprecatedRenderSelect::createListBox()
{
    ListBox *lb = new ListBox();
    lb->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
    m_ignoreSelectEvents = false;
    return lb;
}
//! 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
0
  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
    }
  }
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
0
// 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
0
bool MyApp::OnInit()
{
	ListBox *listBox = new ListBox(wxT("ListBox测试"));
	listBox->Show(true);

	return true;
}
示例#12
0
// 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
0
//! 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
0
文件: main.cpp 项目: EEmmanuel7/begui
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
0
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;
}
void FillTypeArray(
		ListBox& ListMajor, 
		ListBox& ListMinor,
		GUID *atypes, 
		int nIndex, 
		DWORD *pdwPairs
	)
{
    UINT nMajorSel = 0, nMinorSel = 0; 
		
	BOOL result = ListMajor.GetCurrentSelection(&nMajorSel);
    // If no selection ("don't care"), just exit without modifying the array
	if (!result || nMajorSel == 0)
	{
        return;
	}

    // Get GUID for major type
    const GUID *p1 = (const GUID *)ListMajor.GetItem(nMajorSel);

    // Since the FilterMapper interface requires GUIDs (instead of GUID *),
    // copy the specified GUID data into its array slot.
    if (p1)
	{
        memcpy(&atypes[nIndex], p1, sizeof(GUID));
	}
    else
	{
        memset(&atypes[nIndex], 0, sizeof(GUID));
	}

    // Increment number of type/subtype pairs
    (*pdwPairs)++;

	result = ListMinor.GetCurrentSelection(&nMinorSel);

    // If no selection ("don't care"), or uninitialized (returning -1),
    // just exit without modifying the array
    if (!result || nMinorSel == 0)
	{
        return;
	}
    
    // Get GUID for subtype
    const GUID *p2 = (const GUID *)ListMinor.GetItem(nMinorSel);

    if (p2)
	{
        memcpy(&atypes[nIndex+1], p2, sizeof(GUID));
	}
    else
	{
        memset(&atypes[nIndex+1], 0, sizeof(GUID));
	}
}
示例#17
0
文件: main.cpp 项目: vanjs83/v02
int MainWindow::OnCreate(CREATESTRUCT* pcs)
{
	Edit edit; edit.Create(* this,WS_CHILD | WS_VISIBLE | WS_BORDER,"",IDC_EDIT,120,10,100,24 );
	Button button_add; button_add.Create(* this,WS_CHILD | WS_VISIBLE,"add",IDC_ADD,120,40,100,24);
	Button button_remove; button_remove.Create(* this,WS_CHILD | WS_VISIBLE,"remove",IDC_REMOVE,120,70,100,24);
	ListBox listbox; listbox.Create(* this,WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL,"listbox",IDC_LB,10,10,100,100);
	EnableWindow(GetDlgItem(*this,IDC_REMOVE),false);
	// TODO: create all child windows
	// TODO: disable "Remove" button
	return 0;
}
示例#18
0
// True iff all args have some size
static bool checkSize(ListBox *args)
{
    for (ListBox *b = args; !b->isEmpty(); b = b->tail())
    {
	Box *box = b->head();
	if (!box->size().isValid())
	    return false;
    }

    return true;
}
示例#19
0
void ListBoxItem::onClick(ClickEventArgs& event) {
	ListBox* parent = dynamic_cast<ListBox*>(getParent());
	if(parent != NULL) {
		parent->setSelectedItem(this);
	}
	
	// Set that the event has been handled to prevent it to
	// bubble up to the parent control.
	event.handled = true;
	SingleControlContainer::onClick(event);
}
示例#20
0
	void Combobox::AddItem(const std::string& name)
	{
		if(m_list)
		{
			ListBox* lb = static_cast<ListBox*>(m_list.get());
			if(lb)
			{
				lb->AddItem(name);
			}
		}
	}
void FillMajorTypes(ListBox& listbox)
{
    listbox.ClearItems();

    // Fill the specified list box with major type name/GUID
    for (int i=0; i < NUM_MAJOR_TYPES; i++)
    {
        listbox.AddItem(majortypes[i].szName, (void *) majortypes[i].pGUID);
    }

    listbox.Select(0);
}
示例#22
0
void HandleMenu(HWND hWnd, DWORD opt) {
    switch(opt) {
        case ID_SCALE_CONNECT:
            cEditBox.SetText("Trying to communicate with the scale...");
            mScale.EditItem(ID_SCALE_CONNECT, "&Connecting...", MF_DISABLED);
            _beginthread(ScaleConnect, 0, (void*) hWnd);
        break;

        case ID_FILE_NEW:
            if (!bSaved && vMealItems.size() > 0) {
                switch(MessageBox(hWnd, "You haven't saved the current meal, would you like to?","Hold Up!", MB_YESNOCANCEL | MB_ICONINFORMATION)) {
                    case IDYES:
                        if (CheckAndSave()==-1) break;
                    case IDNO:
                        cListBox.Clear();
                        vMealItems.clear();
                        strcpy(cSaveName, "");
                        cWindow.SetTitle("MealTrack - Untitled");
                        cButton.SetText("Start Meal");
                    break;

                    case IDCANCEL:
                    default:
                    break;
                }
            } else {
                cListBox.Clear();
                vMealItems.clear();
                strcpy(cSaveName, "");
                cWindow.SetTitle("MealTrack - Untitled");
                cButton.SetText("Start Meal");
            }
        break;

        case ID_FILE_SAVE:
            GetSaveFile(hWnd);
            if (vMealItems.size() >= 1) CheckAndSave();

            char tmp[313];
            sprintf(tmp, "MealTrack - %s", strrchr(cSaveName,'\\') + 1);
            cWindow.SetTitle(tmp);
        break;

        case ID_FILE_EXIT:
            PostMessage(hWnd, WM_CLOSE, 0, 0);
        break;

        case ID_SCALE_ZERO:
            if (scale != NULL) scale->Zero();
        break;
    }
}
示例#23
0
// Addition
static Box *op_plus(ListBox *args)
{
    CHECK_ATOMS(args);
    CHECK_SIZE(args);

    BoxSize sum(0,0);
    for (ListBox *b = args; !b->isEmpty(); b = b->tail())
    {
	Box *box = b->head();
	sum += box->size();
    }

    return new SpaceBox(sum);
}
示例#24
0
// Multiplication
static Box *op_mult(ListBox *args)
{
    CHECK_ATOMS(args);
    CHECK_SIZE(args);

    BoxSize product(1,1);
    for (ListBox *b = args; !b->isEmpty(); b = b->tail())
    {
	Box *box = b->head();
	product *= box->size();
    }

    return new SpaceBox(product);
}
示例#25
0
// True iff all args are atoms
static bool checkAtoms(ListBox *args)
{
    for (ListBox *b = args; !b->isEmpty(); b = b->tail())
    {
	Box *box = b->head();
	if (box->isListBox() && !box->isDummyBox())
	{
	    VSLLib::eval_error("invalid argument -- argument is list");
	    return false;
	}
    }

    return true;
}
示例#26
0
文件: GUI.cpp 项目: SinYocto/Zee
int GUI::GUIListBox(std::vector<LPWSTR> _texts, Rect _rect, int _ix, char* _id, ListBoxStyle* listBox_style)
{
	ListBox* listBox = New ListBox(_texts, _rect, _ix, _id, listBox_style);
	AddListBox(listBox);

	if(listBoxState.count(_id))
		listBox->isSelecting = listBoxState[_id];
	else
		listBox->isSelecting = false;

	listBox->GetState();
	listBoxState[_id] = listBox->isSelecting;
	
	return listBox->selectedIx;
}
示例#27
0
文件: main.cpp 项目: fihorvat/v02
int MainWindow::OnCreate(CREATESTRUCT* pcs)
{
	// TODO: create all child windows
	ListBox listbox; listbox.Create(*this, WS_CHILD | WS_VISIBLE | WS_BORDER , "", IDC_LB, 10, 10, 180, 150);
	Edit edit; edit.Create(*this, WS_CHILD | WS_VISIBLE | WS_BORDER, "", IDC_EDIT, 202, 10, 150, 40);
	Button button_add; button_add.Create(*this, WS_CHILD | WS_VISIBLE | WS_BORDER ,"Add", IDC_ADD, 202, 60, 150, 40);
	Button button_remove; button_remove.Create(*this, WS_CHILD | WS_VISIBLE | WS_BORDER, "Remove", IDC_REMOVE, 202, 110, 150, 40);

	// TODO: disable "Remove" button
	EnableWindow(GetDlgItem(*this, IDC_REMOVE), false);

	//disable "Add" button until something is written in edit 
	EnableWindow(GetDlgItem(*this, IDC_ADD), false);


	return 0;
}
void FillSubType(ListBox& listboxMajor, ListBox& listboxMinor)
{
    const GUIDINFO *pSubtype;
    UINT nSelection = 0;
	
	listboxMajor.GetCurrentSelection(&nSelection);
    int nMajorType;

    // First clear the subtype list
    listboxMinor.ClearItems();

    // If the "don't care" item was selected, clear and exit
    if (nSelection == 0)
    {
        listboxMinor.AddString(L"<No subtypes>\0");
        listboxMinor.Select(0);
        return;
    }
    else
	{
        nMajorType = nSelection - 1;
	}

    // Determine how to fill the minor type list, based on the
    // currently selected major type.
    pSubtype = pSubTypes[nMajorType];

    // If there's no associated subtype, just add a default
    if (!pSubtype)
    {
        listboxMinor.AddString(L"<No subtypes>\0");
        listboxMinor.Select(0);
        return;
    }
    else
    {
        // Set a default item for "don't care"
        listboxMinor.AddString(L"<Don't care>\0");

        int i=0;

        // Fill the subtype list box.  Enter N item data to the N+1 list slot.
        while (pSubtype[i].pGUID != NULL)
        {
            listboxMinor.AddItem(pSubtype[i].szName, (void *) pSubtype[i].pGUID);
            i++;
        }

        listboxMinor.Select(0);
    }
}
示例#29
0
void DeprecatedRenderSelect::updateSelection()
{
    const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
    int i;
    // if multi-select, we select only the new selected index
    ListBox *listBox = static_cast<ListBox*>(m_widget);
    int j = 0;
    for (i = 0; i < int(listItems.size()); i++) {
        listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
                            static_cast<HTMLOptionElement*>(listItems[i])->selected());
        if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
            ++j;
        
    }

    m_selectionChanged = false;
}
示例#30
0
int ListBoxItem::operator == (const ListBoxItem& item) const
{
    if (listbox && listbox == item.listbox) {
        int sort_column   = listbox->GetSortColumn() - 1;
        int sort_criteria = listbox->GetSortCriteria();
        
        if (sort_column == -1) {
            switch (sort_criteria) {
            case ListBox::LIST_SORT_NUMERIC_DESCENDING:
                return data == item.data;

            case ListBox::LIST_SORT_ALPHA_DESCENDING:
                return text == item.text;

            case ListBox::LIST_SORT_ALPHA_ASCENDING:
                return text == item.text;

            case ListBox::LIST_SORT_NUMERIC_ASCENDING:
                return data == item.data;
            }
        }

        else if (sort_column >= 0 &&
                sort_column <= subitems.size() &&
                sort_column <= item.subitems.size()) {

            switch (sort_criteria) {
            case ListBox::LIST_SORT_NUMERIC_DESCENDING:
                return subitems[sort_column]->data == item.subitems[sort_column]->data;

            case ListBox::LIST_SORT_ALPHA_DESCENDING:
                return subitems[sort_column]->text == item.subitems[sort_column]->text;

            case ListBox::LIST_SORT_ALPHA_ASCENDING:
                return subitems[sort_column]->text == item.subitems[sort_column]->text;

            case ListBox::LIST_SORT_NUMERIC_ASCENDING:
                return subitems[sort_column]->data == item.subitems[sort_column]->data;
            }
        }
    }

    return 0;
}