Simple macro showing capabilities of triple slider.
HId3,
HCId1,
HCId2,
};
private:
public:
TTripleSliderDemo();
virtual ~TTripleSliderDemo();
void DoText(const char *text);
void DoSlider();
void HandleButtons();
};
{
char buf[32];
AddFrame(fCanvas, fLcan);
fCanvas->GetCanvas()->SetFillColor(33);
fCanvas->GetCanvas()->SetFrameFillColor(41);
fCanvas->GetCanvas()->SetBorderMode(0);
fCanvas->GetCanvas()->SetGrid();
fCanvas->GetCanvas()->SetLogy();
fCheck1->
SetToolTipText(
"Pointer position constrained to slider sides");
fCheck2->SetToolTipText("Pointer position relative to slider position");
fHframe0->Resize(200, 50);
GetDefaultFrameBackground(),
fHslider1->
Connect(
"PointerPositionChanged()",
"TTripleSliderDemo",
this, "DoSlider()");
fHslider1->
Connect(
"PositionChanged()",
"TTripleSliderDemo",
this, "DoSlider()");
fHframe1->Resize(200, 25);
fTeh3->SetToolTipText("Maximum (right) Value of Slider");
fTbh3->AddText(0, "0.0");
fTeh1->
Connect(
"TextChanged(char*)",
"TTripleSliderDemo",
this,
"DoText(char*)");
fTeh2->
Connect(
"TextChanged(char*)",
"TTripleSliderDemo",
this,
"DoText(char*)");
fTeh3->Connect("TextChanged(char*)", "TTripleSliderDemo", this,
"DoText(char*)");
fCheck1->
Connect(
"Clicked()",
"TTripleSliderDemo",
this,
"HandleButtons()");
fCheck2->Connect("Clicked()", "TTripleSliderDemo", this,
"HandleButtons()");
fHframe2->Resize(100, 25);
fHframe0->AddFrame(fCheck1, fBfly2);
fHframe0->AddFrame(fCheck2, fBfly2);
fHframe1->AddFrame(fHslider1, fBly);
fHframe2->AddFrame(fTeh1, fBfly2);
fHframe2->AddFrame(fTeh2, fBfly1);
fHframe2->AddFrame(fTeh3, fBfly3);
AddFrame(fHframe0, fBly);
AddFrame(fHframe1, fBly);
AddFrame(fHframe2, fBly);
SetWindowName("Triple Slider Demo");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
fFitFcn =
new TF1(
"fFitFcn",
"TMath::LogNormal(x, [0], [1], [2])", 0, 5);
fFitFcn->SetRange(0.0, 2.5);
fFitFcn->SetParameters(1.0, 0, 1);
fFitFcn->SetMinimum(1.0e-3);
fFitFcn->SetMaximum(10.0);
fFitFcn->SetLineColor(kRed);
fFitFcn->SetLineWidth(1);
fFitFcn->Draw();
fHslider1->SetPointerPosition(1.0);
sprintf(buf, "%.3f", fHslider1->GetPointerPosition());
fTbh3->Clear();
fTbh3->AddText(0, buf);
}
TTripleSliderDemo::~TTripleSliderDemo()
{
Cleanup();
}
void TTripleSliderDemo::CloseWindow()
{
delete this;
}
void TTripleSliderDemo::DoText(const char * )
{
switch (id) {
break;
fHslider1->SetPointerPosition(atof(fTbh2->
GetString()));
break;
case HId3:
break;
default:
break;
}
fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
fFitFcn->Draw();
fCanvas->GetCanvas()->Modified();
fCanvas->GetCanvas()->Update();
}
void TTripleSliderDemo::DoSlider()
{
char buf[32];
sprintf(buf, "%.3f", fHslider1->GetPointerPosition());
fTbh3->Clear();
fTbh3->AddText(0, buf);
fTeh3->SetCursorPosition(fTeh3->GetCursorPosition());
fTeh3->Deselect();
fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
fFitFcn->Draw();
fCanvas->GetCanvas()->Modified();
fCanvas->GetCanvas()->Update();
}
void TTripleSliderDemo::HandleButtons()
{
switch (id) {
case HCId1:
fHslider1->SetConstrained(fCheck1->
GetState());
break;
case HCId2:
fHslider1->SetRelative(fCheck2->GetState());
break;
default:
break;
}
}
void Slider3Demo()
{
new TTripleSliderDemo();
}