Esempio n. 1
0
	void ShowAll() {
		DeleteAllChildren();
		PackEnd(new Gui::Label(m_title));
		m_tentry = new Gui::TextEntry();
		PackEnd(m_tentry);

		std::list<std::string> files;
		GetDirectoryContents(GetFullSavefileDirPath().c_str(), files);

		Gui::HBox *hbox = new Gui::HBox();
		PackEnd(hbox);

		Gui::HBox *buttonBox = new Gui::HBox();
		buttonBox->SetSpacing(5.0f);
		Gui::Button *b = new Gui::LabelButton(new Gui::Label(m_type == SAVE ? Lang::SAVE : Lang::LOAD));
		b->onClick.connect(sigc::mem_fun(this, &FileDialog::OnClickAction));
		buttonBox->PackEnd(b);
		b = new Gui::LabelButton(new Gui::Label(Lang::CANCEL));
		b->onClick.connect(sigc::mem_fun(this, &FileDialog::OnClickCancel));
		buttonBox->PackEnd(b);
		PackEnd(buttonBox);


		Gui::VScrollBar *scroll = new Gui::VScrollBar();
		Gui::VScrollPortal *portal = new Gui::VScrollPortal(390);
		portal->SetTransparency(false);
		scroll->SetAdjustment(&portal->vscrollAdjust);
		hbox->PackEnd(portal);
		hbox->PackEnd(scroll);

		Gui::Box *vbox = new Gui::VBox();
		for (std::list<std::string>::iterator i = files.begin(); i!=files.end(); ++i) {
			b = new SimpleLabelButton(new Gui::Label(*i));
			b->onClick.connect(sigc::bind(sigc::mem_fun(this, &FileDialog::OnClickFile), *i));
			vbox->PackEnd(b);
		}
		portal->Add(vbox);
		
		Gui::VBox::ShowAll();
	}
Esempio n. 2
0
void FileSelectorWidget::ShowAll()
{
	DeleteAllChildren();
	PackEnd(new Gui::Label(m_title));
	m_tentry = new Gui::TextEntry();
	PackEnd(m_tentry);

	Gui::HBox *hbox = new Gui::HBox();
	PackEnd(hbox);

	Gui::HBox *buttonBox = new Gui::HBox();
	buttonBox->SetSpacing(5.0f);
	Gui::Button *b = new Gui::LabelButton(new Gui::Label(m_type == SAVE ? Lang::SAVE : Lang::LOAD));
	b->onClick.connect(sigc::mem_fun(this, &FileSelectorWidget::OnClickAction));
	buttonBox->PackEnd(b);
	b = new Gui::LabelButton(new Gui::Label(Lang::CANCEL));
	b->onClick.connect(sigc::mem_fun(this, &FileSelectorWidget::OnClickCancel));
	buttonBox->PackEnd(b);
	PackEnd(buttonBox);

	Gui::VScrollBar *scroll = new Gui::VScrollBar();
	Gui::VScrollPortal *portal = new Gui::VScrollPortal(390);
	portal->SetTransparency(false);
	scroll->SetAdjustment(&portal->vscrollAdjust);
	hbox->PackEnd(portal);
	hbox->PackEnd(scroll);

	Gui::Box *vbox = new Gui::VBox();
	for (FileSystem::FileEnumerator files(FileSystem::rawFileSystem, Pi::GetSaveDir()); !files.Finished(); files.Next())
	{
		std::string name = files.Current().GetName();
		b = new SimpleLabelButton(new Gui::Label(name));
		b->onClick.connect(sigc::bind(sigc::mem_fun(this, &FileSelectorWidget::OnClickFile), name));
		vbox->PackEnd(b);
	}
	portal->Add(vbox);

	Gui::VBox::ShowAll();
}