Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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//////////////////////////////////////////////////////////////////////////
17// //
18// TGDoubleSlider, TGDoubleVSlider and TGDoubleHSlider //
19// //
20// DoubleSlider widgets allow easy selection of a min and a max value //
21// out of a range. //
22// DoubleSliders can be either horizontal or vertical oriented and //
23// there is a choice of three different types of tick marks. //
24// //
25// To change the min value press the mouse near to the left / bottom //
26// edge of the slider. //
27// To change the max value press the mouse near to the right / top //
28// edge of the slider. //
29// To change both values simultaneously press the mouse near to the //
30// center of the slider. //
31// //
32// TGDoubleSlider is an abstract base class. Use the concrete //
33// TGDoubleVSlider and TGDoubleHSlider. //
34// //
35// Dragging the slider will generate the event: //
36// kC_VSLIDER, kSL_POS, slider id, 0 (for vertical slider) //
37// kC_HSLIDER, kSL_POS, slider id, 0 (for horizontal slider) //
38// //
39// Pressing the mouse will generate the event: //
40// kC_VSLIDER, kSL_PRESS, slider id, 0 (for vertical slider) //
41// kC_HSLIDER, kSL_PRESS, slider id, 0 (for horizontal slider) //
42// //
43// Releasing the mouse will generate the event: //
44// kC_VSLIDER, kSL_RELEASE, slider id, 0 (for vertical slider) //
45// kC_HSLIDER, kSL_RELEASE, slider id, 0 (for horizontal slider) //
46// //
47// Use the functions GetMinPosition(), GetMaxPosition() and //
48// GetPosition() to retrieve the position of the slider. //
49// //
50//////////////////////////////////////////////////////////////////////////
51
52#include "TGFrame.h"
53#include "TGWidget.h"
54
55class TGPicture;
56
58 //--- sizes for vert. and horz. sliders
61};
62
63
65 //--- type of slider scale
69};
70
71
72class TGDoubleSlider : public TGFrame, public TGWidget {
73
74private:
77
78protected:
79 Double_t fPos; // logical position between fVmin and fVmax
80 Double_t fSmin; // logical position of min value of Slider
81 Double_t fSmax; // logical position of max value of Slider
82 Int_t fRelPos; // slider position in pixel coordinates
83 Double_t fVmin; // logical lower limit of slider
84 Double_t fVmax; // logical upper limit of slider
85 Int_t fScale; // tick mark scale
86 Int_t fScaleType; // tick mark scale type (no, downright, both)
87 Int_t fPressPoint; // mouse position at button press event
88 Double_t fPressSmin; // logical min position at button press event
89 Double_t fPressSmax; // logical max position at button press event
90 Int_t fMove; // 1: move min value
91 // 2: move max value
92 // 3: move min and max value
93 // 0: don't move any value
94 Bool_t fReversedScale; // reverse which end is min and max
95 Bool_t fMarkEnds; // lines marking where stretch zones begin
96 const TGPicture *fSliderPic; // picture to draw slider ends
97
98 TString GetSString() const; // returns scaling type as string
99
100 static void FixBounds(Double_t &min, Double_t &max);
101 void ChangeCursor(Event_t *event);
102
103public:
104 TGDoubleSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
105 UInt_t options = kChildFrame,
107 Bool_t reversed = kFALSE,
108 Bool_t mark_ends = kFALSE);
109
110 virtual ~TGDoubleSlider() { }
111
112 virtual Bool_t HandleButton(Event_t *event) = 0;
113 virtual Bool_t HandleMotion(Event_t *event) = 0;
114
115 virtual void SetScale(Int_t scale) { fScale = scale; }
116 virtual void SetRange(Float_t min, Float_t max) {
117 SetRange((Double_t) min, (Double_t) max);
118 }
119 virtual void SetRange(Long64_t min, Long64_t max) {
120 SetRange((Double_t) min, (Double_t) max);
121 }
122 virtual void SetRange(Int_t min, Int_t max) {
123 SetRange((Double_t) min, (Double_t) max);
124 }
125
126 virtual void SetPosition(Float_t min, Float_t max) {
127 SetPosition((Double_t) min, (Double_t) max);
128 }
129 virtual void SetPosition(Long64_t min, Long64_t max) {
130 SetPosition((Double_t) min, (Double_t) max);
131 }
132 virtual void SetPosition(Int_t min, Int_t max) {
133 SetPosition((Double_t) min, (Double_t) max);
134 }
135
136 virtual Float_t GetMinPosition() const {
137 return (Float_t) GetMinPositionD();
138 }
139 virtual Float_t GetMaxPosition() const {
140 return (Float_t) GetMaxPositionD();
141 }
142 virtual Long64_t GetMinPositionL() const {
143 return (Long64_t)GetMinPositionD();
144 }
145 virtual Long64_t GetMaxPositionL() const {
146 return (Long64_t)GetMaxPositionD();
147 }
148
149 virtual void GetPosition(Float_t &min, Float_t &max) const {
150 if (fReversedScale) { min = (Float_t)(fVmin+fVmax-fSmax); max = (Float_t)(fVmin+fVmax-fSmin); }
151 else { min = (Float_t)fSmin; max = (Float_t)fSmax; }
152 }
153 virtual void GetPosition(Float_t *min, Float_t *max) const {
154 if (fReversedScale) { *min = (Float_t)(fVmin+fVmax-fSmax); *max = (Float_t)(fVmin+fVmax-fSmin); }
155 else { *min = (Float_t)fSmin; *max = (Float_t)fSmax; }
156 }
157 virtual void GetPosition(Long64_t &min, Long64_t &max) const {
158 if (fReversedScale) { min = (Long64_t)(fVmin+fVmax-fSmax); max = (Long64_t)(fVmin+fVmax-fSmin); }
159 else { min = (Long64_t)fSmin; max = (Long64_t)fSmax; }
160 }
161 virtual void GetPosition(Long64_t *min, Long64_t *max) const {
162 if (fReversedScale) { *min = (Long64_t)(fVmin+fVmax-fSmax); *max = (Long64_t)(fVmin+fVmax-fSmin); }
163 else { *min = (Long64_t)fSmin; *max = (Long64_t)fSmax; }
164 }
165
166 // double precision methods
167
168 virtual void SetRange(Double_t min, Double_t max) {
169 fVmin = min; fVmax = max;
171 }
172
173 virtual void SetPosition(Double_t min, Double_t max) {
174 if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
175 else { fSmin = min; fSmax = max; }
176 fClient->NeedRedraw(this);
177 }
178
179 virtual Double_t GetMinPositionD() const {
180 if (fReversedScale) return fVmin+fVmax-fSmax;
181 else return fSmin;
182 }
183 virtual Double_t GetMaxPositionD() const {
184 if (fReversedScale) return fVmin+fVmax-fSmin;
185 else return fSmax;
186 }
187 virtual void GetPosition(Double_t &min, Double_t &max) const {
188 if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
189 else { min = fSmin; max = fSmax; }
190 }
191 virtual void GetPosition(Double_t *min, Double_t *max) const {
192 if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
193 else { *min = fSmin; *max = fSmax; }
194 }
195
197
198 virtual void PositionChanged() { Emit("PositionChanged()"); } //*SIGNAL*
199 virtual void Pressed() { Emit("Pressed()"); } //*SIGNAL*
200 virtual void Released() { Emit("Released()"); } //*SIGNAL*
201
202 ClassDef(TGDoubleSlider,0) // Double slider widget abstract base class
203};
204
205
207
208protected:
209 Int_t fYp; // vertical slider y position in pixel coordinates
210
211 virtual void DoRedraw();
212
213public:
214 TGDoubleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
215 UInt_t options = kVerticalFrame,
217 Bool_t reversed = kFALSE,
218 Bool_t mark_ends = kFALSE);
219
220 virtual ~TGDoubleVSlider();
221
222 virtual Bool_t HandleButton(Event_t *event);
223 virtual Bool_t HandleMotion(Event_t *event);
226 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
227
228 ClassDef(TGDoubleVSlider,0) // Vertical double slider widget
229};
230
231
233
234protected:
235 Int_t fXp; // horizontal slider x position in pixel coordinates
236
237 virtual void DoRedraw();
238
239public:
240 TGDoubleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
241 UInt_t options = kHorizontalFrame,
243 Bool_t reversed = kFALSE,
244 Bool_t mark_ends = kFALSE);
245
246 virtual ~TGDoubleHSlider();
247
248 virtual Bool_t HandleButton(Event_t *event);
249 virtual Bool_t HandleMotion(Event_t *event);
252 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
253
254 ClassDef(TGDoubleHSlider,0) // Horizontal double slider widget
255};
256
257#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
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:73
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:371
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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.
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
virtual void GetPosition(Long64_t *min, Long64_t *max) const
virtual void SetPosition(Int_t min, Int_t max)
Double_t fPressSmax
virtual void PositionChanged()
TGDoubleSlider(const TGDoubleSlider &)=delete
virtual void MapSubwindows()
map sub windows
virtual void GetPosition(Float_t *min, Float_t *max) const
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
virtual void GetPosition(Float_t &min, Float_t &max) const
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)
Double_t fPressSmin
virtual void Released()
virtual void Pressed()
virtual ~TGDoubleSlider()
virtual void SetScale(Int_t scale)
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
virtual void SetRange(Long64_t min, Long64_t max)
TString GetSString() const
Returns the slider type as a string - used in SavePrimitive()
virtual void SetPosition(Float_t min, Float_t max)
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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.
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
virtual void DoRedraw()
Redraw vertical slider widget.
UInt_t fHeight
Definition TGFrame.h:112
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
UInt_t fWidth
Definition TGFrame.h:111
TGClient * fClient
Definition TGObject.h:37
virtual void MapSubwindows()
map sub windows
Definition TGWindow.cxx:167
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