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
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:
75 TGDoubleSlider(const TGDoubleSlider&); // Not implemented
76 TGDoubleSlider& operator=(const TGDoubleSlider&); // Not implemented
77
78protected:
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
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 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
156protected:
157 Int_t fYp; // vertical slider y position in pixel coordinates
158
159 virtual void DoRedraw();
160
161public:
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);
174 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
175
176 ClassDef(TGDoubleVSlider,0) // Vertical double slider widget
177};
178
179
181
182protected:
183 Int_t fXp; // horizontal slider x position in pixel coordinates
184
185 virtual void DoRedraw();
186
187public:
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);
200 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
201
202 ClassDef(TGDoubleHSlider,0) // Horizontal double slider widget
203};
204
205#endif
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
const Bool_t kFALSE
Definition: RtypesCore.h:90
float Float_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
EDoubleSliderScale
@ kDoubleScaleBoth
@ kDoubleScaleDownRight
@ kDoubleScaleNo
EDoubleSliderSize
@ kDoubleSliderWidth
@ kDoubleSliderHeight
int type
Definition: TGX11.cxx:120
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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.
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
TGDoubleSlider & operator=(const TGDoubleSlider &)
virtual Float_t GetMaxPosition() const
virtual void PositionChanged()
static void FixBounds(Float_t &min, Float_t &max)
Avoid boundaries to be equal.
virtual void MapSubwindows()
map sub windows
virtual void GetPosition(Float_t *min, Float_t *max) const
virtual void GetPosition(Float_t &min, Float_t &max) const
virtual Bool_t HandleMotion(Event_t *event)=0
virtual Float_t GetMinPosition() const
TGDoubleSlider(const TGDoubleSlider &)
virtual void SetRange(Float_t min, Float_t max)
Bool_t fReversedScale
Float_t fPressSmax
virtual void Released()
virtual void Pressed()
virtual ~TGDoubleSlider()
virtual void SetScale(Int_t scale)
virtual Bool_t HandleButton(Event_t *event)=0
const TGPicture * fSliderPic
TString GetSString() const
Returns the slider type as a string - used in SavePrimitive()
Float_t fPressSmin
virtual void SetPosition(Float_t min, Float_t max)
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.
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
virtual void DoRedraw()
Redraw vertical slider widget.
UInt_t fHeight
Definition: TGFrame.h:113
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:667
UInt_t fWidth
Definition: TGFrame.h:112
TGClient * fClient
Definition: TGObject.h:37
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:158
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
Basic string class.
Definition: TString.h:131