EntityChooser::EntityChooser() :
	gtkutil::DialogElement(), // create an Element without label
	_entityStore(Gtk::ListStore::create(_listColumns))
{
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 6));
	_widgets[WIDGET_TOPLEVEL] = vbox;

	// Initialise the base class
	DialogElement::setValueWidget(_widgets[WIDGET_TOPLEVEL]);

	Gtk::TreeView* treeView = Gtk::manage(new Gtk::TreeView(_entityStore));
	_widgets[WIDGET_TREEVIEW] = treeView;

	treeView->set_headers_visible(false);

	// Use the TreeModel's full string search function
	treeView->set_search_equal_func(sigc::ptr_fun(&gtkutil::TreeModel::equalFuncStringContains));

	// Head Name column
	treeView->append_column("", _listColumns.name);

	// Set the tree store to sort on this column
	_entityStore->set_sort_column_id(_listColumns.name, Gtk::SORT_ASCENDING);

	_selection = treeView->get_selection();
	_selection->signal_changed().connect(sigc::mem_fun(*this, &EntityChooser::onSelectionChanged));

	// Scrolled Frame
	vbox->pack_start(*Gtk::manage(new gtkutil::ScrolledFrame(*treeView)), true, true, 0);

	populateEntityList();
}
Esempio n. 2
0
EntityChooser::EntityChooser() :
	DialogBase(_("Select Entity")),
	_entityStore(new wxutil::TreeModel(_listColumns, true)),
	_entityView(NULL)
{
	SetSizer(new wxBoxSizer(wxVERTICAL));

	wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
	GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12);

	_entityView = wxutil::TreeView::Create(this, wxDV_NO_HEADER);

	vbox->Add(_entityView, 1, wxEXPAND | wxBOTTOM, 12);
	vbox->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_RIGHT);

	FitToScreen(0.3f, 0.6f);

	// Use the TreeModel's full string search function
	_entityView->AddSearchColumn(_listColumns.name);

	// Head Name column
	_entityView->AppendTextColumn("#", _listColumns.name.getColumnIndex(),
		wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE);

	populateEntityList();
}