Logo ROOT  
Reference Guide
TGDoubleSlider.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Reiner Rohlfs 30/09/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2021, 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 #ifndef ROOT_TGDoubleSlider
13 #define ROOT_TGDoubleSlider
14 
15 
16 #include "TGFrame.h"
17 #include "TGWidget.h"
18 
19 class TGPicture;
20 
22  //--- sizes for vert. and horz. sliders
25 };
26 
27 
29  //--- type of slider scale
33 };
34 
35 
36 class TGDoubleSlider : public TGFrame, public TGWidget {
37 
38 private:
39  TGDoubleSlider(const TGDoubleSlider&) = delete;
41 
42 protected:
43  Double_t fPos; // logical position between fVmin and fVmax
44  Double_t fSmin; // logical position of min value of Slider
45  Double_t fSmax; // logical position of max value of Slider
46  Int_t fRelPos; // slider position in pixel coordinates
47  Double_t fVmin; // logical lower limit of slider
48  Double_t fVmax; // logical upper limit of slider
49  Int_t fScale; // tick mark scale
50  Int_t fScaleType; // tick mark scale type (no, downright, both)
51  Int_t fPressPoint; // mouse position at button press event
52  Double_t fPressSmin; // logical min position at button press event
53  Double_t fPressSmax; // logical max position at button press event
54  Int_t fMove; // 1: move min value
55  // 2: move max value
56  // 3: move min and max value
57  // 0: don't move any value
58  Bool_t fReversedScale; // reverse which end is min and max
59  Bool_t fMarkEnds; // lines marking where stretch zones begin
60  const TGPicture *fSliderPic; // picture to draw slider ends
61 
62  TString GetSString() const; // returns scaling type as string
63 
64  static void FixBounds(Double_t &min, Double_t &max);
65  void ChangeCursor(Event_t *event);
66 
67 public:
68  TGDoubleSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
69  UInt_t options = kChildFrame,
71  Bool_t reversed = kFALSE,
72  Bool_t mark_ends = kFALSE);
73 
74  virtual ~TGDoubleSlider() { }
75 
76  virtual Bool_t HandleButton(Event_t *event) = 0;
77  virtual Bool_t HandleMotion(Event_t *event) = 0;
78 
79  virtual void SetScale(Int_t scale) { fScale = scale; }
80  virtual void SetRange(Float_t min, Float_t max) {
81  SetRange((Double_t) min, (Double_t) max);
82  }
83  virtual void SetRange(Long64_t min, Long64_t max) {
84  SetRange((Double_t) min, (Double_t) max);
85  }
86  virtual void SetRange(Int_t min, Int_t max) {
87  SetRange((Double_t) min, (Double_t) max);
88  }
89 
90  virtual void SetPosition(Float_t min, Float_t max) {
91  SetPosition((Double_t) min, (Double_t) max);
92  }
93  virtual void SetPosition(Long64_t min, Long64_t max) {
94  SetPosition((Double_t) min, (Double_t) max);
95  }
96  virtual void SetPosition(Int_t min, Int_t max) {
97  SetPosition((Double_t) min, (Double_t) max);
98  }
99 
100  virtual Float_t GetMinPosition() const {
101  return (Float_t) GetMinPositionD();
102  }
103  virtual Float_t GetMaxPosition() const {
104  return (Float_t) GetMaxPositionD();
105  }
106  virtual Long64_t GetMinPositionL() const {
107  return (Long64_t)GetMinPositionD();
108  }
109  virtual Long64_t GetMaxPositionL() const {
110  return (Long64_t)GetMaxPositionD();
111  }
112 
113  virtual void GetPosition(Float_t &min, Float_t &max) const {
114  if (fReversedScale) { min = (Float_t)(fVmin+fVmax-fSmax); max = (Float_t)(fVmin+fVmax-fSmin); }
115  else { min = (Float_t)fSmin; max = (Float_t)fSmax; }
116  }
117  virtual void GetPosition(Float_t *min, Float_t *max) const {
118  if (fReversedScale) { *min = (Float_t)(fVmin+fVmax-fSmax); *max = (Float_t)(fVmin+fVmax-fSmin); }
119  else { *min = (Float_t)fSmin; *max = (Float_t)fSmax; }
120  }
121  virtual void GetPosition(Long64_t &min, Long64_t &max) const {
122  if (fReversedScale) { min = (Long64_t)(fVmin+fVmax-fSmax); max = (Long64_t)(fVmin+fVmax-fSmin); }
123  else { min = (Long64_t)fSmin; max = (Long64_t)fSmax; }
124  }
125  virtual void GetPosition(Long64_t *min, Long64_t *max) const {
126  if (fReversedScale) { *min = (Long64_t)(fVmin+fVmax-fSmax); *max = (Long64_t)(fVmin+fVmax-fSmin); }
127  else { *min = (Long64_t)fSmin; *max = (Long64_t)fSmax; }
128  }
129 
130  // double precision methods
131 
132  virtual void SetRange(Double_t min, Double_t max) {
133  fVmin = min; fVmax = max;
135  }
136 
137  virtual void SetPosition(Double_t min, Double_t max) {
138  if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
139  else { fSmin = min; fSmax = max; }
140  fClient->NeedRedraw(this);
141  }
142 
143  virtual Double_t GetMinPositionD() const {
144  if (fReversedScale) return fVmin+fVmax-fSmax;
145  else return fSmin;
146  }
147  virtual Double_t GetMaxPositionD() const {
148  if (fReversedScale) return fVmin+fVmax-fSmin;
149  else return fSmax;
150  }
151  virtual void GetPosition(Double_t &min, Double_t &max) const {
152  if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
153  else { min = fSmin; max = fSmax; }
154  }
155  virtual void GetPosition(Double_t *min, Double_t *max) const {
156  if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
157  else { *min = fSmin; *max = fSmax; }
158  }
159 
161 
162  virtual void PositionChanged() { Emit("PositionChanged()"); } //*SIGNAL*
163  virtual void Pressed() { Emit("Pressed()"); } //*SIGNAL*
164  virtual void Released() { Emit("Released()"); } //*SIGNAL*
165 
166  ClassDef(TGDoubleSlider,0) // Double slider widget abstract base class
167 };
168 
169 
171 
172 protected:
173  Int_t fYp; // vertical slider y position in pixel coordinates
174 
175  virtual void DoRedraw();
176 
177 public:
178  TGDoubleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
179  UInt_t options = kVerticalFrame,
181  Bool_t reversed = kFALSE,
182  Bool_t mark_ends = kFALSE);
183 
184  virtual ~TGDoubleVSlider();
185 
186  virtual Bool_t HandleButton(Event_t *event);
187  virtual Bool_t HandleMotion(Event_t *event);
188  virtual TGDimension GetDefaultSize() const
190  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
191 
192  ClassDef(TGDoubleVSlider,0) // Vertical double slider widget
193 };
194 
195 
197 
198 protected:
199  Int_t fXp; // horizontal slider x position in pixel coordinates
200 
201  virtual void DoRedraw();
202 
203 public:
204  TGDoubleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
205  UInt_t options = kHorizontalFrame,
207  Bool_t reversed = kFALSE,
208  Bool_t mark_ends = kFALSE);
209 
210  virtual ~TGDoubleHSlider();
211 
212  virtual Bool_t HandleButton(Event_t *event);
213  virtual Bool_t HandleMotion(Event_t *event);
214  virtual TGDimension GetDefaultSize() const
216  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
217 
218  ClassDef(TGDoubleHSlider,0) // Horizontal double slider widget
219 };
220 
221 #endif
TGDoubleSlider::SetRange
virtual void SetRange(Int_t min, Int_t max)
Definition: TGDoubleSlider.h:86
TGDoubleSlider::GetSString
TString GetSString() const
Returns the slider type as a string - used in SavePrimitive()
Definition: TGDoubleSlider.cxx:146
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TGDoubleHSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition: TGDoubleSlider.cxx:570
TGDoubleSlider::PositionChanged
virtual void PositionChanged()
Definition: TGDoubleSlider.h:162
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGDimension
Definition: TGDimension.h:18
TGDoubleSlider::SetRange
virtual void SetRange(Float_t min, Float_t max)
Definition: TGDoubleSlider.h:80
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGDoubleVSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition: TGDoubleSlider.cxx:332
TGDoubleSlider::SetRange
virtual void SetRange(Double_t min, Double_t max)
Definition: TGDoubleSlider.h:132
TGDoubleVSlider::TGDoubleVSlider
TGDoubleVSlider(const TGWindow *p=0, UInt_t h=1, UInt_t type=1, Int_t id=-1, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground(), Bool_t reversed=kFALSE, Bool_t mark_ends=kFALSE)
Create a vertical slider widget.
Definition: TGDoubleSlider.cxx:238
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:87
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGDoubleSlider::GetPosition
virtual void GetPosition(Float_t *min, Float_t *max) const
Definition: TGDoubleSlider.h:117
TGDoubleHSlider::DoRedraw
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition: TGDoubleSlider.cxx:460
Long64_t
long long Long64_t
Definition: RtypesCore.h:75
TGDoubleSlider::fVmin
Double_t fVmin
Definition: TGDoubleSlider.h:47
Float_t
float Float_t
Definition: RtypesCore.h:57
TGDoubleSlider::operator=
TGDoubleSlider & operator=(const TGDoubleSlider &)=delete
TGWidget
The widget base class.
Definition: TGWidget.h:43
TGDoubleSlider::fRelPos
Int_t fRelPos
Definition: TGDoubleSlider.h:46
TGDoubleSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)=0
kDoubleScaleDownRight
@ kDoubleScaleDownRight
Definition: TGDoubleSlider.h:31
TGDoubleVSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition: TGDoubleSlider.cxx:379
TGDoubleSlider::GetPosition
virtual void GetPosition(Long64_t *min, Long64_t *max) const
Definition: TGDoubleSlider.h:125
TGDoubleSlider::GetPosition
virtual void GetPosition(Float_t &min, Float_t &max) const
Definition: TGDoubleSlider.h:113
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGDoubleSlider::~TGDoubleSlider
virtual ~TGDoubleSlider()
Definition: TGDoubleSlider.h:74
TGDoubleSlider::fSmax
Double_t fSmax
Definition: TGDoubleSlider.h:45
TGDoubleSlider
DoubleSlider widgets allow easy selection of a min and a max value out of a range.
Definition: TGDoubleSlider.h:36
TString
Basic string class.
Definition: TString.h:136
TGDoubleSlider::fMove
Int_t fMove
Definition: TGDoubleSlider.h:54
TGFrame
Definition: TGFrame.h:80
TGDoubleVSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGDoubleSlider.h:188
TGDoubleSlider::Pressed
virtual void Pressed()
Definition: TGDoubleSlider.h:163
bool
TGDoubleHSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGDoubleSlider.h:214
TGDoubleSlider::fVmax
Double_t fVmax
Definition: TGDoubleSlider.h:48
TGDoubleSlider::GetPosition
virtual void GetPosition(Double_t &min, Double_t &max) const
Definition: TGDoubleSlider.h:151
EDoubleSliderScale
EDoubleSliderScale
Definition: TGDoubleSlider.h:28
TGDoubleHSlider
Dragging the slider will generate the event:
Definition: TGDoubleSlider.h:196
TGDoubleSlider::GetMinPositionD
virtual Double_t GetMinPositionD() const
Definition: TGDoubleSlider.h:143
TGDoubleVSlider::fYp
Int_t fYp
Definition: TGDoubleSlider.h:173
TGDoubleSlider::fSliderPic
const TGPicture * fSliderPic
Definition: TGDoubleSlider.h:60
kDoubleSliderHeight
@ kDoubleSliderHeight
Definition: TGDoubleSlider.h:24
h
#define h(i)
Definition: RSha256.hxx:106
TGDoubleSlider::fMarkEnds
Bool_t fMarkEnds
Definition: TGDoubleSlider.h:59
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:96
TGDoubleSlider::SetPosition
virtual void SetPosition(Int_t min, Int_t max)
Definition: TGDoubleSlider.h:96
TGDoubleHSlider::~TGDoubleHSlider
virtual ~TGDoubleHSlider()
Delete a horizontal slider widget.
Definition: TGDoubleSlider.cxx:452
TGDoubleSlider::fPressSmax
Double_t fPressSmax
Definition: TGDoubleSlider.h:53
TGFrame.h
TGDoubleSlider::SetPosition
virtual void SetPosition(Long64_t min, Long64_t max)
Definition: TGDoubleSlider.h:93
kDoubleScaleNo
@ kDoubleScaleNo
Definition: TGDoubleSlider.h:30
TGDoubleHSlider::fXp
Int_t fXp
Definition: TGDoubleSlider.h:199
EDoubleSliderSize
EDoubleSliderSize
Definition: TGDoubleSlider.h:21
TGDoubleSlider::GetPosition
virtual void GetPosition(Long64_t &min, Long64_t &max) const
Definition: TGDoubleSlider.h:121
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGDoubleSlider::SetPosition
virtual void SetPosition(Double_t min, Double_t max)
Definition: TGDoubleSlider.h:137
TGDoubleVSlider::~TGDoubleVSlider
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
Definition: TGDoubleSlider.cxx:258
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:168
TGDoubleSlider::GetMaxPositionD
virtual Double_t GetMaxPositionD() const
Definition: TGDoubleSlider.h:147
TGDoubleSlider::Released
virtual void Released()
Definition: TGDoubleSlider.h:164
TGWidget.h
unsigned int
TGDoubleSlider::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGDoubleSlider.h:160
TGDoubleSlider::fPressPoint
Int_t fPressPoint
Definition: TGDoubleSlider.h:51
TGDoubleVSlider
Dragging the slider will generate the event:
Definition: TGDoubleSlider.h:170
TGDoubleSlider::fPos
Double_t fPos
Definition: TGDoubleSlider.h:43
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGDoubleSlider::GetMaxPositionL
virtual Long64_t GetMaxPositionL() const
Definition: TGDoubleSlider.h:109
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
Double_t
double Double_t
Definition: RtypesCore.h:59
TGDoubleVSlider::DoRedraw
virtual void DoRedraw()
Redraw vertical slider widget.
Definition: TGDoubleSlider.cxx:266
TGDoubleVSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGDoubleSlider.cxx:661
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:27
TGDoubleSlider::FixBounds
static void FixBounds(Double_t &min, Double_t &max)
Avoid boundaries to be equal.
Definition: TGDoubleSlider.cxx:126
TGDoubleSlider::ChangeCursor
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
Definition: TGDoubleSlider.cxx:176
TGDoubleSlider::SetScale
virtual void SetScale(Int_t scale)
Definition: TGDoubleSlider.h:79
TGDoubleSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)=0
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGDoubleSlider::GetMinPositionL
virtual Long64_t GetMinPositionL() const
Definition: TGDoubleSlider.h:106
Event_t
Event structure.
Definition: GuiTypes.h:174
kDoubleSliderWidth
@ kDoubleSliderWidth
Definition: TGDoubleSlider.h:23
TGDoubleSlider::fReversedScale
Bool_t fReversedScale
Definition: TGDoubleSlider.h:58
TGDoubleSlider::SetRange
virtual void SetRange(Long64_t min, Long64_t max)
Definition: TGDoubleSlider.h:83
TGDoubleHSlider::TGDoubleHSlider
TGDoubleHSlider(const TGWindow *p=0, UInt_t w=1, UInt_t type=1, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground(), Bool_t reversed=kFALSE, Bool_t mark_ends=kFALSE)
Create horizontal slider widget.
Definition: TGDoubleSlider.cxx:432
TGDoubleSlider::GetMinPosition
virtual Float_t GetMinPosition() const
Definition: TGDoubleSlider.h:100
TGDoubleSlider::fPressSmin
Double_t fPressSmin
Definition: TGDoubleSlider.h:52
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:88
kDoubleScaleBoth
@ kDoubleScaleBoth
Definition: TGDoubleSlider.h:32
TGDoubleSlider::fScale
Int_t fScale
Definition: TGDoubleSlider.h:49
type
int type
Definition: TGX11.cxx:121
TGDoubleHSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
Definition: TGDoubleSlider.cxx:523
TGDoubleSlider::fScaleType
Int_t fScaleType
Definition: TGDoubleSlider.h:50
TGDoubleSlider::TGDoubleSlider
TGDoubleSlider(const TGDoubleSlider &)=delete
TGDoubleSlider::fSmin
Double_t fSmin
Definition: TGDoubleSlider.h:44
TGDoubleSlider::GetPosition
virtual void GetPosition(Double_t *min, Double_t *max) const
Definition: TGDoubleSlider.h:155
TGDoubleHSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGDoubleSlider.cxx:623
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TGDoubleSlider::SetPosition
virtual void SetPosition(Float_t min, Float_t max)
Definition: TGDoubleSlider.h:90
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGDoubleSlider::GetMaxPosition
virtual Float_t GetMaxPosition() const
Definition: TGDoubleSlider.h:103