Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSliderBox.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Rene Brun 23/11/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TSlider.h"
14#include "TSliderBox.h"
15#include "TMath.h"
16
17#include <cstring>
18
19
20
21/** \class TSliderBox
22\ingroup gpad
23
24The moving box in a TSlider
25*/
26
27////////////////////////////////////////////////////////////////////////////////
28/// SliderBox default constructor.
29
31{
32 fSlider = nullptr;
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// SliderBox normal constructor.
37
43
44////////////////////////////////////////////////////////////////////////////////
45/// SliderBox default destructor.
46
50
51
52////////////////////////////////////////////////////////////////////////////////
53/// Interaction with a slider.
54
56{
58
59 TWbox::ExecuteEvent((vertical ? 20000 : 10000) + event, px, py);
60
61 if (!fSlider)
62 return;
63
67 Double_t v1, v2, d;
68
69 // Give control to object using the slider
70 if (vertical) {
71 v1 = GetY1();
72 v2 = GetY2();
73 d = TMath::Min(0.3, dy);
74 } else {
75 v1 = GetX1();
76 v2 = GetX2();
77 d = TMath::Min(0.3, dx);
78 }
79 fSlider->SetMinimum(TMath::Max(0., (v1 - d) / (1 - 2*d)));
80 fSlider->SetMaximum(TMath::Min(1., (v2 - d) / (1 - 2*d)));
81
82 if (event == kButton1Up) {
83 if (vertical) {
84 SetX1(dx); SetX2(1 - dx);
85 } else {
86 SetY1(dy); SetY2(1 - dy);
87 }
88 }
89
90 //A user method to execute?
91 if (event == kButton1Up && (strlen(fSlider->GetMethod()) > 0)) {
92 gPad->SetCursor(kWatch);
93 gROOT->ProcessLine(fSlider->GetMethod());
94 return;
95 }
96
97 //An object connected to this slider?
98 TObject *obj = fSlider->GetObject();
99 if (obj)
100 obj->ExecuteEvent(event, 0, 0);
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// Save primitive as a C++ statement(s) on output stream out
105
106void TSliderBox::SavePrimitive(std::ostream &, Option_t * /*= ""*/)
107{
108}
@ kButton1Up
Definition Buttons.h:19
@ kWatch
Definition GuiTypes.h:376
#define d(i)
Definition RSha256.hxx:102
short Color_t
Color number (short)
Definition RtypesCore.h:100
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:417
#define gPad
Double_t GetX1() const
Definition TBox.h:51
virtual void SetY2(Double_t y2)
Definition TBox.h:65
Double_t GetX2() const
Definition TBox.h:52
Double_t GetY1() const
Definition TBox.h:53
virtual void SetX1(Double_t x1)
Definition TBox.h:62
Double_t GetY2() const
Definition TBox.h:54
virtual void SetX2(Double_t x2)
Definition TBox.h:63
virtual void SetY1(Double_t y1)
Definition TBox.h:64
Mother of all ROOT objects.
Definition TObject.h:42
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition TObject.cxx:414
Double_t PixeltoY(Double_t py) override
Convert pixel to Y coordinate.
Definition TPad.cxx:7380
Short_t GetBorderSize() const override
Definition TPad.h:200
Double_t GetAbsWNDC() const override
Definition TPad.h:224
Double_t GetAbsHNDC() const override
Definition TPad.h:225
Double_t PixeltoX(Double_t px) override
Convert pixel to X coordinate.
Definition TPad.cxx:7371
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TSlider * fSlider
Pointer to slider.
Definition TSliderBox.h:22
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Interaction with a slider.
TSliderBox()
SliderBox default constructor.
~TSliderBox() override
SliderBox default destructor.
virtual const char * GetMethod() const
Definition TSlider.h:36
virtual void SetMaximum(Double_t max=1)
Definition TSlider.h:41
TObject * GetObject() const
Definition TSlider.h:33
virtual void SetMinimum(Double_t min=0)
Definition TSlider.h:40
A TBox with a bordersize and a bordermode.
Definition TWbox.h:20
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TWbox.cxx:106
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197