This macro gives an example of how to create a list box and how to set and use its multiple selection feature.
To run it do either:
.x listBox.C
.x listBox.C++
private:
public:
virtual ~MyMainFrame();
void DoExit();
void DoSelect();
void HandleButtons();
void PrintSelected();
};
void MyMainFrame::DoSelect()
{
}
void MyMainFrame::DoExit()
{
}
{
char tmp[20];
for (int i = 0; i < 20; ++i) {
sprintf(tmp, "Entry %i", i+1);
}
5, 5, 5, 5));
fCheckMulti =
new TGCheckButton(
this,
"&Mutliple selection", 10);
5, 5, 5, 5));
fCheckMulti->
Connect(
"Clicked()",
"MyMainFrame",
this,
"HandleButtons()");
show->
Connect(
"Pressed()",
"MyMainFrame",
this,
"PrintSelected()");
exit->
Connect(
"Pressed()",
"MyMainFrame",
this,
"DoExit()");
SetWindowName("List Box");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
if (fSelected) {
fSelected->Delete();
delete fSelected;
}
}
void MyMainFrame::HandleButtons()
{
printf("HandleButton: id = %d\n", id);
if (id == 10)
}
void MyMainFrame::PrintSelected()
{
fSelected->Clear();
Printf(
"Selected entries are:\n");
fSelected->ls();
} else {
}
}
void listBox()
{
new MyMainFrame(
gClient->GetRoot(), 200, 200);
}
- Author
- Ilka Antcheva 1/12/2006
Definition in file listBox.C.