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
19class TGPicture;
20
22 //--- sizes for vert. and horz. sliders
25};
26
27
29 //--- type of slider scale
33};
34
35
36class TGDoubleSlider : public TGFrame, public TGWidget {
37
38private:
41
42protected:
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);
66
67public:
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
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
172protected:
173 Int_t fYp; ///< vertical slider y position in pixel coordinates
174
175 virtual void DoRedraw();
176
177public:
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
190 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
191
192 ClassDef(TGDoubleVSlider,0) // Vertical double slider widget
193};
194
195
197
198protected:
199 Int_t fXp; ///< horizontal slider x position in pixel coordinates
200
201 virtual void DoRedraw();
202
203public:
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
216 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
217
218 ClassDef(TGDoubleHSlider,0) // Horizontal double slider widget
219};
220
221#endif
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:80
float Float_t
Definition: RtypesCore.h:57
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define BIT(n)
Definition: Rtypes.h:85
EDoubleSliderScale
@ kDoubleScaleBoth
@ kDoubleScaleDownRight
@ kDoubleScaleNo
EDoubleSliderSize
@ kDoubleSliderWidth
@ kDoubleSliderHeight
int type
Definition: TGX11.cxx:121
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
Dragging the slider will generate the event:
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Int_t fXp
horizontal slider x position in pixel coordinates
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.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
virtual ~TGDoubleHSlider()
Delete a horizontal slider widget.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
virtual void DoRedraw()
Redraw horizontal slider widget.
DoubleSlider widgets allow easy selection of a min and a max value out of a range.
TGDoubleSlider & operator=(const TGDoubleSlider &)=delete
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
virtual void SetRange(Double_t min, Double_t max)
virtual Float_t GetMaxPosition() const
Double_t fSmin
logical position of min value of Slider
virtual void GetPosition(Long64_t *min, Long64_t *max) const
Int_t fScaleType
tick mark scale type (no, downright, both)
virtual void SetPosition(Int_t min, Int_t max)
Double_t fPressSmax
logical max position at button press event
virtual void PositionChanged()
TGDoubleSlider(const TGDoubleSlider &)=delete
virtual void MapSubwindows()
map sub windows
virtual void GetPosition(Float_t *min, Float_t *max) const
Double_t fSmax
logical position of max value of Slider
static void FixBounds(Double_t &min, Double_t &max)
Avoid boundaries to be equal.
virtual void GetPosition(Double_t *min, Double_t *max) const
virtual Double_t GetMaxPositionD() const
Double_t fVmax
logical upper limit of slider
Int_t fScale
tick mark scale
Double_t fVmin
logical lower limit of slider
Int_t fMove
1: move min value 2: move max value 3: move min and max value 0: don't move any value
Int_t fRelPos
slider position in pixel coordinates
virtual void GetPosition(Float_t &min, Float_t &max) const
Double_t fPos
logical position between fVmin and fVmax
virtual Long64_t GetMinPositionL() const
virtual Bool_t HandleMotion(Event_t *event)=0
virtual void SetPosition(Double_t min, Double_t max)
virtual Float_t GetMinPosition() const
virtual void GetPosition(Long64_t &min, Long64_t &max) const
virtual Double_t GetMinPositionD() const
virtual void SetRange(Float_t min, Float_t max)
virtual void SetRange(Int_t min, Int_t max)
Bool_t fReversedScale
reverse which end is min and max
Double_t fPressSmin
logical min position at button press event
virtual void Released()
Bool_t fMarkEnds
lines marking where stretch zones begin
virtual void Pressed()
virtual ~TGDoubleSlider()
virtual void SetScale(Int_t scale)
Int_t fPressPoint
mouse position at button press event
virtual void SetPosition(Long64_t min, Long64_t max)
virtual Long64_t GetMaxPositionL() const
virtual Bool_t HandleButton(Event_t *event)=0
virtual void GetPosition(Double_t &min, Double_t &max) const
const TGPicture * fSliderPic
picture to draw slider ends
virtual void SetRange(Long64_t min, Long64_t max)
TString GetSString() const
returns scaling type as string
virtual void SetPosition(Float_t min, Float_t max)
Dragging the slider will generate the event:
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Int_t fYp
vertical slider y position in pixel coordinates
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
virtual void DoRedraw()
Redraw vertical slider widget.
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
UInt_t fHeight
frame height
Definition: TGFrame.h:88
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
UInt_t fWidth
frame width
Definition: TGFrame.h:87
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
The widget base class.
Definition: TGWidget.h:43
ROOT GUI Window base class.
Definition: TGWindow.h:23
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:168
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
Basic string class.
Definition: TString.h:136
Event structure.
Definition: GuiTypes.h:174