This macro gives an example of how to create a list box and how to set and use its multiple selection feature.
private:
public:
~MyMainFrame() override;
void DoExit();
void DoSelect();
void HandleButtons();
void PrintSelected();
};
void MyMainFrame::DoSelect()
{
}
void MyMainFrame::DoExit()
{
}
{
for (int i = 0; i < 20; ++i) {
sprintf(tmp, "Entry %i", i+1);
fListBox->AddEntry(tmp, i+1);
}
fListBox->Resize(100,150);
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");
Resize(GetDefaultSize());
MapWindow();
fListBox->Select(1);
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
if (fSelected) {
fSelected->Delete();
delete fSelected;
}
}
void MyMainFrame::HandleButtons()
{
printf("HandleButton: id = %d\n", id);
if (id == 10)
fListBox->SetMultipleSelections(fCheckMulti->GetState());
}
void MyMainFrame::PrintSelected()
{
fSelected->Clear();
if (fListBox->GetMultipleSelections()) {
Printf(
"Selected entries are:\n");
fListBox->GetSelectedEntries(fSelected);
fSelected->ls();
} else {
Printf(
"Selected entries is: %d\n", fListBox->GetSelected());
}
}
void listBox()
{
new MyMainFrame(
gClient->GetRoot(), 200, 200);
}
#define ClassDefOverride(name, id)
R__EXTERN TApplication * gApplication
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
R__EXTERN void * gTQSender
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
A composite frame that layout their children in horizontal way.
This class describes layout hints used by the layout classes.
A listbox is a box, possibly with scrollbar, containing entries.
Defines top level windows that interact with the system Window Manager.
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.