18 enum ETestCommandIdentifiers {
28 class TTripleSliderDemo :
public TGMainFrame {
31 TRootEmbeddedCanvas *fCanvas;
34 TGHorizontalFrame *fHframe0, *fHframe1, *fHframe2;
35 TGLayoutHints *fBly, *fBfly1, *fBfly2, *fBfly3;
36 TGTripleHSlider *fHslider1;
37 TGTextEntry *fTeh1, *fTeh2, *fTeh3;
38 TGTextBuffer *fTbh1, *fTbh2, *fTbh3;
39 TGCheckButton *fCheck1, *fCheck2;
43 virtual ~TTripleSliderDemo();
46 void DoText(
const char *text);
50 ClassDef(TTripleSliderDemo, 0)
54 TTripleSliderDemo::TTripleSliderDemo() : TGMainFrame(gClient->GetRoot(), 100, 100)
58 SetCleanup(kDeepCleanup);
61 fCanvas =
new TRootEmbeddedCanvas(
"Canvas",
this, 600, 400);
62 fLcan =
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 10, 10, 10);
63 AddFrame(fCanvas, fLcan);
64 fCanvas->GetCanvas()->SetFillColor(33);
65 fCanvas->GetCanvas()->SetFrameFillColor(41);
66 fCanvas->GetCanvas()->SetBorderMode(0);
67 fCanvas->GetCanvas()->SetGrid();
68 fCanvas->GetCanvas()->SetLogy();
70 fHframe0 =
new TGHorizontalFrame(
this, 0, 0, 0);
72 fCheck1 =
new TGCheckButton(fHframe0,
"&Constrained", HCId1);
73 fCheck2 =
new TGCheckButton(fHframe0,
"&Relative", HCId2);
74 fCheck1->SetState(kButtonUp);
75 fCheck2->SetState(kButtonUp);
76 fCheck1->SetToolTipText(
"Pointer position constrained to slider sides");
77 fCheck2->SetToolTipText(
"Pointer position relative to slider position");
79 fHframe0->Resize(200, 50);
81 fHframe1 =
new TGHorizontalFrame(
this, 0, 0, 0);
83 fHslider1 =
new TGTripleHSlider(fHframe1, 190, kDoubleScaleBoth, HSId1,
85 GetDefaultFrameBackground(),
86 kFALSE, kFALSE, kFALSE, kFALSE);
87 fHslider1->Connect(
"PointerPositionChanged()",
"TTripleSliderDemo",
89 fHslider1->Connect(
"PositionChanged()",
"TTripleSliderDemo",
91 fHslider1->SetRange(0.05,5.0);
93 fHframe1->Resize(200, 25);
95 fHframe2 =
new TGHorizontalFrame(
this, 0, 0, 0);
97 fTeh1 =
new TGTextEntry(fHframe2, fTbh1 =
new TGTextBuffer(5), HId1);
98 fTeh2 =
new TGTextEntry(fHframe2, fTbh2 =
new TGTextBuffer(5), HId2);
99 fTeh3 =
new TGTextEntry(fHframe2, fTbh3 =
new TGTextBuffer(5), HId3);
101 fTeh1->SetToolTipText(
"Minimum (left) Value of Slider");
102 fTeh2->SetToolTipText(
"Pointer Position Value");
103 fTeh3->SetToolTipText(
"Maximum (right) Value of Slider");
105 fTbh1->AddText(0,
"0.0");
106 fTbh2->AddText(0,
"0.0");
107 fTbh3->AddText(0,
"0.0");
109 fTeh1->Connect(
"TextChanged(char*)",
"TTripleSliderDemo",
this,
111 fTeh2->Connect(
"TextChanged(char*)",
"TTripleSliderDemo",
this,
113 fTeh3->Connect(
"TextChanged(char*)",
"TTripleSliderDemo",
this,
116 fCheck1->Connect(
"Clicked()",
"TTripleSliderDemo",
this,
118 fCheck2->Connect(
"Clicked()",
"TTripleSliderDemo",
this,
121 fHframe2->Resize(100, 25);
124 fBly =
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5);
127 fBfly1 =
new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 5, 5);
128 fBfly2 =
new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
129 fBfly3 =
new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
131 fHframe0->AddFrame(fCheck1, fBfly2);
132 fHframe0->AddFrame(fCheck2, fBfly2);
133 fHframe1->AddFrame(fHslider1, fBly);
134 fHframe2->AddFrame(fTeh1, fBfly2);
135 fHframe2->AddFrame(fTeh2, fBfly1);
136 fHframe2->AddFrame(fTeh3, fBfly3);
138 AddFrame(fHframe0, fBly);
139 AddFrame(fHframe1, fBly);
140 AddFrame(fHframe2, fBly);
144 SetWindowName(
"Triple Slider Demo");
146 Resize(GetDefaultSize());
149 fFitFcn =
new TF1(
"fFitFcn",
"TMath::LogNormal(x, [0], [1], [2])", 0, 5);
150 fFitFcn->SetRange(0.0, 2.5);
151 fFitFcn->SetParameters(1.0, 0, 1);
152 fFitFcn->SetMinimum(1.0e-3);
153 fFitFcn->SetMaximum(10.0);
154 fFitFcn->SetLineColor(kRed);
155 fFitFcn->SetLineWidth(1);
158 fHslider1->SetPosition(0.05,2.5);
159 fHslider1->SetPointerPosition(1.0);
161 sprintf(buf,
"%.3f", fHslider1->GetMinPosition());
163 fTbh1->AddText(0, buf);
164 sprintf(buf,
"%.3f", fHslider1->GetPointerPosition());
166 fTbh2->AddText(0, buf);
167 sprintf(buf,
"%.3f", fHslider1->GetMaxPosition());
169 fTbh3->AddText(0, buf);
173 TTripleSliderDemo::~TTripleSliderDemo()
181 void TTripleSliderDemo::CloseWindow()
189 void TTripleSliderDemo::DoText(
const char * )
193 TGTextEntry *te = (TGTextEntry *) gTQSender;
194 Int_t
id = te->WidgetId();
198 fHslider1->SetPosition(atof(fTbh1->GetString()),
199 fHslider1->GetMaxPosition());
202 fHslider1->SetPointerPosition(atof(fTbh2->GetString()));
205 fHslider1->SetPosition(fHslider1->GetMinPosition(),
206 atof(fTbh1->GetString()));
211 fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
212 fFitFcn->SetRange(fHslider1->GetMinPosition()-0.05,
213 fHslider1->GetMaxPosition());
215 fCanvas->GetCanvas()->Modified();
216 fCanvas->GetCanvas()->Update();
220 void TTripleSliderDemo::DoSlider()
226 sprintf(buf,
"%.3f", fHslider1->GetMinPosition());
228 fTbh1->AddText(0, buf);
229 fTeh1->SetCursorPosition(fTeh1->GetCursorPosition());
231 gClient->NeedRedraw(fTeh1);
233 sprintf(buf,
"%.3f", fHslider1->GetPointerPosition());
235 fTbh2->AddText(0, buf);
236 fTeh2->SetCursorPosition(fTeh2->GetCursorPosition());
238 gClient->NeedRedraw(fTeh2);
240 sprintf(buf,
"%.3f", fHslider1->GetMaxPosition());
242 fTbh3->AddText(0, buf);
243 fTeh3->SetCursorPosition(fTeh3->GetCursorPosition());
245 gClient->NeedRedraw(fTeh3);
247 fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
248 fFitFcn->SetRange(fHslider1->GetMinPosition()-0.05,
249 fHslider1->GetMaxPosition());
251 fCanvas->GetCanvas()->Modified();
252 fCanvas->GetCanvas()->Update();
256 void TTripleSliderDemo::HandleButtons()
260 TGButton *btn = (TGButton *) gTQSender;
261 Int_t
id = btn->WidgetId();
265 fHslider1->SetConstrained(fCheck1->GetState());
268 fHslider1->SetRelative(fCheck2->GetState());
278 new TTripleSliderDemo();