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-2000, 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 
55 class TGPicture;
56 
58  //--- sizes for vert. and horz. sliders
61 };
62 
63 
65  //--- type of slider scale
69 };
70 
71 
72 class TGDoubleSlider : public TGFrame, public TGWidget {
73 
74 private:
75  TGDoubleSlider(const TGDoubleSlider&); // Not implemented
76  TGDoubleSlider& operator=(const TGDoubleSlider&); // Not implemented
77 
78 protected:
79  Float_t fPos; // logical position between fVmin and fVmax
80  Float_t fSmin; // logical position of min value of Slider
81  Float_t fSmax; // logical position of max value of Slider
82  Int_t fRelPos; // slider position in pixel coordinates
83  Float_t fVmin; // logical lower limit of slider
84  Float_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  Float_t fPressSmin; // logical min position at button press event
89  Float_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(Float_t &min, Float_t &max);
101  void ChangeCursor(Event_t *event);
102 
103 public:
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  fVmin = min; fVmax = max;
119  }
120 
121  virtual void SetPosition(Float_t min, Float_t max) {
122  if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
123  else { fSmin = min; fSmax = max; }
124  fClient->NeedRedraw(this);
125  }
126 
127  virtual Float_t GetMinPosition() const {
128  if (fReversedScale) return fVmin+fVmax-fSmax;
129  else return fSmin;
130  }
131  virtual Float_t GetMaxPosition() const {
132  if (fReversedScale) return fVmin+fVmax-fSmin;
133  else return fSmax;
134  }
135  virtual void GetPosition(Float_t &min, Float_t &max) const {
136  if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
137  else { min = fSmin; max = fSmax; }
138  }
139  virtual void GetPosition(Float_t *min, Float_t *max) const {
140  if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
141  else { *min = fSmin; *max = fSmax; }
142  }
143 
145 
146  virtual void PositionChanged() { Emit("PositionChanged()"); } //*SIGNAL*
147  virtual void Pressed() { Emit("Pressed()"); } //*SIGNAL*
148  virtual void Released() { Emit("Released()"); } //*SIGNAL*
149 
150  ClassDef(TGDoubleSlider,0) // Double slider widget abstract base class
151 };
152 
153 
155 
156 protected:
157  Int_t fYp; // vertical slider y position in pixel coordinates
158 
159  virtual void DoRedraw();
160 
161 public:
162  TGDoubleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
163  UInt_t options = kVerticalFrame,
165  Bool_t reversed = kFALSE,
166  Bool_t mark_ends = kFALSE);
167 
168  virtual ~TGDoubleVSlider();
169 
170  virtual Bool_t HandleButton(Event_t *event);
171  virtual Bool_t HandleMotion(Event_t *event);
172  virtual TGDimension GetDefaultSize() const
174  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
175 
176  ClassDef(TGDoubleVSlider,0) // Vertical double slider widget
177 };
178 
179 
181 
182 protected:
183  Int_t fXp; // horizontal slider x position in pixel coordinates
184 
185  virtual void DoRedraw();
186 
187 public:
188  TGDoubleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
189  UInt_t options = kHorizontalFrame,
191  Bool_t reversed = kFALSE,
192  Bool_t mark_ends = kFALSE);
193 
194  virtual ~TGDoubleHSlider();
195 
196  virtual Bool_t HandleButton(Event_t *event);
197  virtual Bool_t HandleMotion(Event_t *event);
198  virtual TGDimension GetDefaultSize() const
200  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
201 
202  ClassDef(TGDoubleHSlider,0) // Horizontal double slider widget
203 };
204 
205 #endif
TGDoubleSlider::GetSString
TString GetSString() const
Returns the slider type as a string - used in SavePrimitive()
Definition: TGDoubleSlider.cxx:128
TGWindow
Definition: TGWindow.h:31
TGDoubleHSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition: TGDoubleSlider.cxx:552
TGDoubleSlider::PositionChanged
virtual void PositionChanged()
Definition: TGDoubleSlider.h:146
TGPicture
Definition: TGPicture.h:36
TGDimension
Definition: TGDimension.h:27
TGDoubleSlider::SetRange
virtual void SetRange(Float_t min, Float_t max)
Definition: TGDoubleSlider.h:116
TGDoubleVSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition: TGDoubleSlider.cxx:314
TGDoubleSlider::operator=
TGDoubleSlider & operator=(const TGDoubleSlider &)
TGDoubleSlider::fVmax
Float_t fVmax
Definition: TGDoubleSlider.h:84
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:220
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGDoubleSlider::GetPosition
virtual void GetPosition(Float_t *min, Float_t *max) const
Definition: TGDoubleSlider.h:139
TGDoubleHSlider::DoRedraw
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition: TGDoubleSlider.cxx:442
Float_t
float Float_t
Definition: RtypesCore.h:57
TGWidget
Definition: TGWidget.h:55
TGDoubleSlider::fRelPos
Int_t fRelPos
Definition: TGDoubleSlider.h:82
TGDoubleSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)=0
kDoubleScaleDownRight
@ kDoubleScaleDownRight
Definition: TGDoubleSlider.h:67
TGDoubleVSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition: TGDoubleSlider.cxx:361
TGDoubleSlider::fPressSmax
Float_t fPressSmax
Definition: TGDoubleSlider.h:89
TGDoubleSlider::fPressSmin
Float_t fPressSmin
Definition: TGDoubleSlider.h:88
TGDoubleSlider::GetPosition
virtual void GetPosition(Float_t &min, Float_t &max) const
Definition: TGDoubleSlider.h:135
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGDoubleSlider::~TGDoubleSlider
virtual ~TGDoubleSlider()
Definition: TGDoubleSlider.h:110
TGDoubleSlider::fPos
Float_t fPos
Definition: TGDoubleSlider.h:79
TGDoubleSlider
Definition: TGDoubleSlider.h:72
TString
Definition: TString.h:136
TGDoubleSlider::fMove
Int_t fMove
Definition: TGDoubleSlider.h:90
TGFrame
Definition: TGFrame.h:105
TGDoubleVSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGDoubleSlider.h:172
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGDoubleSlider::Pressed
virtual void Pressed()
Definition: TGDoubleSlider.h:147
bool
TGDoubleHSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGDoubleSlider.h:198
TGDoubleSlider::TGDoubleSlider
TGDoubleSlider(const TGDoubleSlider &)
EDoubleSliderScale
EDoubleSliderScale
Definition: TGDoubleSlider.h:64
TGDoubleHSlider
Definition: TGDoubleSlider.h:180
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGDoubleVSlider::fYp
Int_t fYp
Definition: TGDoubleSlider.h:157
TGDoubleSlider::fSliderPic
const TGPicture * fSliderPic
Definition: TGDoubleSlider.h:96
kDoubleSliderHeight
@ kDoubleSliderHeight
Definition: TGDoubleSlider.h:60
h
#define h(i)
Definition: RSha256.hxx:124
TGDoubleSlider::fMarkEnds
Bool_t fMarkEnds
Definition: TGDoubleSlider.h:95
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGDoubleHSlider::~TGDoubleHSlider
virtual ~TGDoubleHSlider()
Delete a horizontal slider widget.
Definition: TGDoubleSlider.cxx:434
TGFrame.h
kDoubleScaleNo
@ kDoubleScaleNo
Definition: TGDoubleSlider.h:66
TGDoubleHSlider::fXp
Int_t fXp
Definition: TGDoubleSlider.h:183
EDoubleSliderSize
EDoubleSliderSize
Definition: TGDoubleSlider.h:57
TGDoubleSlider::fVmin
Float_t fVmin
Definition: TGDoubleSlider.h:83
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGDoubleVSlider::~TGDoubleVSlider
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
Definition: TGDoubleSlider.cxx:240
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:149
TGDoubleSlider::Released
virtual void Released()
Definition: TGDoubleSlider.h:148
TGDoubleSlider::fSmin
Float_t fSmin
Definition: TGDoubleSlider.h:80
TGWidget.h
unsigned int
TGDoubleSlider::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGDoubleSlider.h:144
TGDoubleSlider::fPressPoint
Int_t fPressPoint
Definition: TGDoubleSlider.h:87
TGDoubleVSlider
Definition: TGDoubleSlider.h:154
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGDoubleVSlider::DoRedraw
virtual void DoRedraw()
Redraw vertical slider widget.
Definition: TGDoubleSlider.cxx:248
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:643
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGDoubleSlider::ChangeCursor
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
Definition: TGDoubleSlider.cxx:158
TGDoubleSlider::SetScale
virtual void SetScale(Int_t scale)
Definition: TGDoubleSlider.h:115
TGDoubleSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)=0
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGDoubleSlider::FixBounds
static void FixBounds(Float_t &min, Float_t &max)
Avoid boundaries to be equal.
Definition: TGDoubleSlider.cxx:108
Event_t
Definition: GuiTypes.h:173
kDoubleSliderWidth
@ kDoubleSliderWidth
Definition: TGDoubleSlider.h:59
TGDoubleSlider::fReversedScale
Bool_t fReversedScale
Definition: TGDoubleSlider.h:94
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:414
TGDoubleSlider::GetMinPosition
virtual Float_t GetMinPosition() const
Definition: TGDoubleSlider.h:127
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
kDoubleScaleBoth
@ kDoubleScaleBoth
Definition: TGDoubleSlider.h:68
TGDoubleSlider::fSmax
Float_t fSmax
Definition: TGDoubleSlider.h:81
TGDoubleSlider::fScale
Int_t fScale
Definition: TGDoubleSlider.h:85
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:505
TGDoubleSlider::fScaleType
Int_t fScaleType
Definition: TGDoubleSlider.h:86
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:605
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:121
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGDoubleSlider::GetMaxPosition
virtual Float_t GetMaxPosition() const
Definition: TGDoubleSlider.h:131