37 Int_t GetUnID(
void) {
return ++nID ; }
41 class SplitButtonTest :
public TGMainFrame {
44 TGSplitButton *fMButton;
45 TGPopupMenu *fPopMenu;
50 SplitButtonTest(
const TGWindow *p, UInt_t w, UInt_t h) ;
51 virtual ~SplitButtonTest() ;
54 void DoSplit(Bool_t split) ;
55 void DoEnable(Bool_t on) ;
56 void HandleMenu(Int_t
id) ;
58 ClassDef(SplitButtonTest, 0)
61 SplitButtonTest::SplitButtonTest(
const TGWindow *p, UInt_t w, UInt_t h)
62 : TGMainFrame(p, w, h)
64 SetCleanup(kDeepCleanup) ;
66 Connect(
"CloseWindow()",
"SplitButtonTest",
this,
"DoExit()") ;
69 TGVerticalFrame *fVL =
new TGVerticalFrame(
this, 100, 100) ;
70 TGHorizontalFrame *fHL =
new TGHorizontalFrame(fVL, 100, 40) ;
73 fPopMenu =
new TGPopupMenu(gClient->GetRoot());
74 fPopMenu->AddEntry(
"Button &1", ID_1);
75 fPopMenu->AddEntry(
"Button &2", ID_2);
76 fPopMenu->DisableEntry(ID_2);
77 fPopMenu->AddEntry(
"Button &3", ID_3);
78 fPopMenu->AddSeparator();
81 fMButton =
new TGSplitButton(fHL,
new TGHotString(
"Button &Options"),
82 fPopMenu, IDs.GetUnID());
85 fPopMenu->AddEntry(
"En&try with really really long name", ID_4);
86 fPopMenu->AddEntry(
"&Exit", ID_5);
90 fMButton->Connect(
"ItemClicked(Int_t)",
"SplitButtonTest",
this,
93 TGCheckButton *fCButton =
new TGCheckButton(fHL,
new TGHotString(
"Split"),
95 fCButton->SetState(kButtonDown);
96 fCButton->Connect(
"Toggled(Bool_t)",
"SplitButtonTest",
this,
"DoSplit(Bool_t)");
99 fHL->AddFrame(fCButton,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
101 TGCheckButton *fEButton =
new TGCheckButton(fHL,
new TGHotString(
"Enable"),
103 fEButton->SetState(kButtonDown);
104 fEButton->Connect(
"Toggled(Bool_t)",
"SplitButtonTest",
this,
"DoEnable(Bool_t)");
107 fHL->AddFrame(fEButton,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
109 fHL->AddFrame(fMButton,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
110 fVL->AddFrame(fHL,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY)) ;
111 AddFrame(fVL,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY)) ;
113 SetWindowName(
"SplitButton Test") ;
115 Resize(GetDefaultSize()) ;
120 SplitButtonTest::~SplitButtonTest()
126 void SplitButtonTest::DoExit()
134 gApplication->Terminate();
137 void SplitButtonTest::DoSplit(Bool_t split)
139 fMButton->SetSplit(split);
142 void SplitButtonTest::DoEnable(Bool_t on)
145 fMButton->SetState(kButtonUp);
147 fMButton->SetState(kButtonDisabled);
150 void SplitButtonTest::HandleMenu(Int_t
id)
158 std::cout <<
"Button 1 was activated" << std::endl;
161 std::cout <<
"Button 2 was activated" << std::endl;
164 std::cout <<
"Button 3 was activated" << std::endl;
167 std::cout <<
"Button with a really really long name was activated"
175 void splitbuttonTest()
177 new SplitButtonTest(gClient->GetRoot(),100,100);