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#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);
65 void ChangeCursor(Event_t *event);
66
67public:
68 TGDoubleSlider(const TGWindow *p = nullptr, 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 ~TGDoubleSlider() override { }
75
76 Bool_t HandleButton(Event_t *event) override = 0;
77 Bool_t HandleMotion(Event_t *event) override = 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 ClassDefOverride(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 void DoRedraw() override;
176
177public:
178 TGDoubleVSlider(const TGWindow *p = nullptr, 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 ~TGDoubleVSlider() override;
185
186 Bool_t HandleButton(Event_t *event) override;
187 Bool_t HandleMotion(Event_t *event) override;
190 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
191
192 ClassDefOverride(TGDoubleVSlider,0) // Vertical double slider widget
193};
194
195
197
198protected:
199 Int_t fXp; ///< horizontal slider x position in pixel coordinates
200
201 void DoRedraw() override;
202
203public:
204 TGDoubleHSlider(const TGWindow *p = nullptr, 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 ~TGDoubleHSlider() override;
211
212 Bool_t HandleButton(Event_t *event) override;
213 Bool_t HandleMotion(Event_t *event) override;
216 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
217
218 ClassDefOverride(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
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
EDoubleSliderScale
@ kDoubleScaleBoth
@ kDoubleScaleDownRight
@ kDoubleScaleNo
EDoubleSliderSize
@ kDoubleSliderWidth
@ kDoubleSliderHeight
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
Dragging the slider will generate the event:
void DoRedraw() override
Redraw horizontal slider widget.
Int_t fXp
horizontal slider x position in pixel coordinates
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in horizontal slide widget.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal slider as a C++ statement(s) on output stream out.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
~TGDoubleHSlider() override
Delete a horizontal slider widget.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in 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
Bool_t HandleMotion(Event_t *event) override=0
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 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
~TGDoubleSlider() override
virtual void Released()
Bool_t fMarkEnds
lines marking where stretch zones begin
virtual void Pressed()
void MapSubwindows() override
map sub windows
Bool_t HandleButton(Event_t *event) override=0
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 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:
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in vertical slider.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal slider as a C++ statement(s) on output stream out.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in vertical slider.
~TGDoubleVSlider() override
Delete vertical slider widget.
Int_t fYp
vertical slider y position in pixel coordinates
void DoRedraw() override
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:25
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:139
Event structure.
Definition GuiTypes.h:174