21 class MyMainFrame :
public TGMainFrame {
25 TGCheckButton *fCheckMulti;
29 MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h);
30 virtual ~MyMainFrame();
36 ClassDef(MyMainFrame, 0)
39 void MyMainFrame::DoSelect()
41 Printf(
"Slot DoSelect()");
44 void MyMainFrame::DoExit()
46 Printf(
"Slot DoExit()");
47 gApplication->Terminate(0);
50 MyMainFrame::MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h) :
55 fListBox =
new TGListBox(
this, 89);
56 fSelected =
new TList;
58 for (
int i = 0; i < 20; ++i) {
59 sprintf(tmp,
"Entry %i", i+1);
60 fListBox->AddEntry(tmp, i+1);
62 fListBox->Resize(100,150);
63 AddFrame(fListBox,
new TGLayoutHints(kLHintsTop | kLHintsLeft |
64 kLHintsExpandX | kLHintsExpandY,
67 fCheckMulti =
new TGCheckButton(
this,
"&Mutliple selection", 10);
68 AddFrame(fCheckMulti,
new TGLayoutHints(kLHintsTop | kLHintsLeft,
70 fCheckMulti->Connect(
"Clicked()",
"MyMainFrame",
this,
"HandleButtons()");
72 TGHorizontalFrame *hframe =
new TGHorizontalFrame(
this, 150, 20, kFixedWidth);
73 TGTextButton *show =
new TGTextButton(hframe,
"&Show");
74 show->SetToolTipText(
"Click here to print the selection you made");
75 show->Connect(
"Pressed()",
"MyMainFrame",
this,
"PrintSelected()");
76 hframe->AddFrame(show,
new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
77 TGTextButton *exit =
new TGTextButton(hframe,
"&Exit ");
78 exit->Connect(
"Pressed()",
"MyMainFrame",
this,
"DoExit()");
79 hframe->AddFrame(exit,
new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
80 AddFrame(hframe,
new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
83 SetWindowName(
"List Box");
87 Resize(GetDefaultSize());
94 MyMainFrame::~MyMainFrame()
104 void MyMainFrame::HandleButtons()
108 TGButton *btn = (TGButton *) gTQSender;
109 id = btn->WidgetId();
111 printf(
"HandleButton: id = %d\n",
id);
114 fListBox->SetMultipleSelections(fCheckMulti->GetState());
118 void MyMainFrame::PrintSelected()
124 if (fListBox->GetMultipleSelections()) {
125 Printf(
"Selected entries are:\n");
126 fListBox->GetSelectedEntries(fSelected);
129 Printf(
"Selected entries is: %d\n", fListBox->GetSelected());
136 new MyMainFrame(gClient->GetRoot(), 200, 200);