Logo ROOT  
Reference Guide
TGSlider.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 14/01/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_TGSlider
13 #define ROOT_TGSlider
14 
15 
16 #include "TGFrame.h"
17 #include "TGWidget.h"
18 
19 
20 //--- sizes for vert. and horz. sliders
21 
25 };
26 
27 
29  //--- slider types (type of slider picture)
30  kSlider1 = BIT(0),
31  kSlider2 = BIT(1),
32 
33  //--- scaling of slider
34  kScaleNo = BIT(2),
36  kScaleBoth = BIT(4)
37 };
38 
39 
40 class TGSlider : public TGFrame, public TGWidget {
41 
42 protected:
43  Int_t fPos; ///< logical position between fVmin and fVmax
44  Int_t fRelPos; ///< slider position in pixel coordinates
45  Int_t fVmin; ///< logical lower limit of slider
46  Int_t fVmax; ///< logical upper limit of slider
47  Int_t fType; ///< slider type bits
48  Int_t fScale; ///< tick mark scale
49  Bool_t fDragging; ///< true if in dragging mode
50  const TGPicture *fSliderPic; ///< picture to draw slider
51  const TGPicture *fDisabledPic; ///< picture to draw disabled slider
52 
53  TString GetTypeString() const; ///< used in SavePrimitive
54  virtual void CreateDisabledPicture();
55 
56 private:
57  TGSlider(const TGSlider&) = delete;
58  TGSlider& operator=(const TGSlider&) = delete;
59 
60 public:
61  TGSlider(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
62  UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
63  UInt_t options = kChildFrame,
65 
66  virtual ~TGSlider() { }
67 
71 
72  virtual void SetEnabled(Bool_t flag = kTRUE) { SetState( flag ); } //*TOGGLE* *GETTER=IsEnabled
73  virtual void SetState(Bool_t state);
74  virtual void SetScale(Int_t scale) { fScale = scale; } //*MENU*
75  virtual void SetRange(Int_t min, Int_t max) {
76  if (max > min) { fVmin = min; fVmax = max; }
77  else Warning("SetRange", "Incorrect range boundaries [%d,%d]", min, max);
78  } //*MENU*
79  virtual void SetPosition(Int_t pos) {
80  if ((pos >= fVmin) && (pos <= fVmax)) { fPos = pos; fClient->NeedRedraw(this); }
81  else Warning("SetPosition", "The position (%d) is out of range [%d,%d]", pos, fVmin, fVmax);
82  } //*MENU*
83  virtual Int_t GetPosition() const { return fPos; }
84  virtual Int_t GetMinPosition() const { return fVmin; }
85  virtual Int_t GetMaxPosition() const { return fVmax; }
86  virtual Int_t GetScale() const { return fScale; }
87  virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
88  virtual void ChangeSliderPic(const char *name) {
91  }
92 
93  virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } // *SIGNAL*
94  virtual void Pressed() { Emit("Pressed()"); } // *SIGNAL*
95  virtual void Released() { Emit("Released()"); } // *SIGNAL*
96 
97  ClassDef(TGSlider,0) // Slider widget abstract base class
98 };
99 
100 
101 class TGVSlider : public TGSlider {
102 
103 protected:
104  Int_t fYp; ///< vertical slider y position in pixel coordinates
105 
106  virtual void DoRedraw();
107 
108 public:
109  TGVSlider(const TGWindow *p = nullptr, UInt_t h = 40,
110  UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
111  UInt_t options = kVerticalFrame,
113  virtual ~TGVSlider();
114 
115  virtual Bool_t HandleButton(Event_t *event);
117  virtual Bool_t HandleMotion(Event_t *event);
118  virtual TGDimension GetDefaultSize() const
119  { return TGDimension(kSliderWidth, fHeight); }
120  virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w, h ? h+16 : fHeight + 16); }
121  virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
122  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
123 
124  ClassDef(TGVSlider,0) // Vertical slider widget
125 };
126 
127 
128 class TGHSlider : public TGSlider {
129 
130 protected:
131  Int_t fXp; ///< horizontal slider x position in pixel coordinates
132 
133  virtual void DoRedraw();
134 
135 public:
136  TGHSlider(const TGWindow *p = 0, UInt_t w = 40,
137  UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
138  UInt_t options = kHorizontalFrame,
140  virtual ~TGHSlider();
141 
142  virtual Bool_t HandleButton(Event_t *event);
144  virtual Bool_t HandleMotion(Event_t *event);
145  virtual TGDimension GetDefaultSize() const
146  { return TGDimension(fWidth, kSliderHeight); }
147  virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w ? w+16 : fWidth + 16, h); }
148  virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
149  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
150 
151  ClassDef(TGHSlider,0) // Horizontal slider widget
152 };
153 
154 #endif
TGVSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition: TGSlider.cxx:225
TGVSlider::DoRedraw
virtual void DoRedraw()
Redraw vertical slider widget.
Definition: TGSlider.cxx:182
TGVSlider::fYp
Int_t fYp
vertical slider y position in pixel coordinates
Definition: TGSlider.h:104
TGSlider::fType
Int_t fType
slider type bits
Definition: TGSlider.h:47
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TGSlider::SetState
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Definition: TGSlider.cxx:129
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGSlider::fVmin
Int_t fVmin
logical lower limit of slider
Definition: TGSlider.h:45
TGHSlider::fXp
Int_t fXp
horizontal slider x position in pixel coordinates
Definition: TGSlider.h:131
TGVSlider::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition: TGSlider.cxx:327
TGSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)=0
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGDimension
Definition: TGDimension.h:18
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGSlider::GetPosition
virtual Int_t GetPosition() const
Definition: TGSlider.h:83
TGSlider::GetMaxPosition
virtual Int_t GetMaxPosition() const
Definition: TGSlider.h:85
TGSlider::CreateDisabledPicture
virtual void CreateDisabledPicture()
Creates disabled picture.
Definition: TGSlider.cxx:100
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGSlider::fSliderPic
const TGPicture * fSliderPic
picture to draw slider
Definition: TGSlider.h:50
TGSlider::PositionChanged
virtual void PositionChanged(Int_t pos)
Definition: TGSlider.h:93
TGFrame::fWidth
UInt_t fWidth
frame width
Definition: TGFrame.h:87
kScaleDownRight
@ kScaleDownRight
Definition: TGSlider.h:35
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGSlider::~TGSlider
virtual ~TGSlider()
Definition: TGSlider.h:66
TGVSlider::Resize
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGSlider.h:121
TGSlider::ChangeSliderPic
virtual void ChangeSliderPic(const char *name)
Definition: TGSlider.h:88
kSliderHeight
@ kSliderHeight
Definition: TGSlider.h:24
TGSlider::SetRange
virtual void SetRange(Int_t min, Int_t max)
Definition: TGSlider.h:75
TGHSlider
Concrete class for horizontal slider.
Definition: TGSlider.h:128
TGSlider::GetMinPosition
virtual Int_t GetMinPosition() const
Definition: TGSlider.h:84
TGSlider::fPos
Int_t fPos
logical position between fVmin and fVmax
Definition: TGSlider.h:43
TGHSlider::TGHSlider
TGHSlider(const TGWindow *p=0, UInt_t w=40, UInt_t type=kSlider1|kScaleBoth, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground())
Create horizontal slider widget.
Definition: TGSlider.cxx:337
TGWidget
The widget base class.
Definition: TGWidget.h:43
TGSlider::Pressed
virtual void Pressed()
Definition: TGSlider.h:94
TGVSlider::~TGVSlider
virtual ~TGVSlider()
Delete vertical slider widget.
Definition: TGSlider.cxx:173
kSlider2
@ kSlider2
Definition: TGSlider.h:31
event
Definition: triangle.c:553
TGVSlider
Concrete class for vertical slider.
Definition: TGSlider.h:101
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGClient::FreePicture
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:310
TGVSlider::TGVSlider
TGVSlider(const TGWindow *p=nullptr, UInt_t h=40, UInt_t type=kSlider1|kScaleBoth, Int_t id=-1, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a vertical slider widget.
Definition: TGSlider.cxx:142
TGSlider::Released
virtual void Released()
Definition: TGSlider.h:95
TGSlider::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGSlider.h:87
TString
Basic string class.
Definition: TString.h:136
TGFrame
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGSlider::SetPosition
virtual void SetPosition(Int_t pos)
Definition: TGSlider.h:79
TGHSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
Definition: TGSlider.cxx:419
bool
TGSlider::SetScale
virtual void SetScale(Int_t scale)
Definition: TGSlider.h:74
TGHSlider::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition: TGSlider.cxx:517
ESliderSize
ESliderSize
Definition: TGSlider.h:22
TGHSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition: TGSlider.cxx:493
ESliderType
ESliderType
Definition: TGSlider.h:28
kScaleNo
@ kScaleNo
Definition: TGSlider.h:34
TGSlider::fVmax
Int_t fVmax
logical upper limit of slider
Definition: TGSlider.h:46
TGSlider::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *event)=0
This event is generated when the frame is resized.
TGVSlider::Resize
virtual void Resize(UInt_t w, UInt_t h)
Resize the frame.
Definition: TGSlider.h:120
h
#define h(i)
Definition: RSha256.hxx:106
TGSlider::fScale
Int_t fScale
tick mark scale
Definition: TGSlider.h:48
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TGSlider::TGSlider
TGSlider(const TGSlider &)=delete
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
TGFrame.h
TGVSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGSlider.cxx:596
TGSlider::GetScale
virtual Int_t GetScale() const
Definition: TGSlider.h:86
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:291
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGSlider::GetTypeString
TString GetTypeString() const
used in SavePrimitive
Definition: TGSlider.cxx:527
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:168
TGSlider
Slider widgets allow easy selection of a range.
Definition: TGSlider.h:40
TGVSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition: TGSlider.cxx:303
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:879
TGWidget.h
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGHSlider::DoRedraw
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition: TGSlider.cxx:377
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
kSliderWidth
@ kSliderWidth
Definition: TGSlider.h:23
TGVSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGSlider.h:118
TGObject::fClient
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
Event_t
Event structure.
Definition: GuiTypes.h:174
TGHSlider::~TGHSlider
virtual ~TGHSlider()
Delete a horizontal slider widget.
Definition: TGSlider.cxx:368
name
char name[80]
Definition: TGX11.cxx:110
TGSlider::fRelPos
Int_t fRelPos
slider position in pixel coordinates
Definition: TGSlider.h:44
TGHSlider::Resize
virtual void Resize(UInt_t w, UInt_t h)
Resize the frame.
Definition: TGSlider.h:147
kSlider1
@ kSlider1
Definition: TGSlider.h:30
TGHSlider::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGSlider.h:145
TGHSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGSlider.cxx:559
TGHSlider::Resize
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGSlider.h:148
TGFrame::fHeight
UInt_t fHeight
frame height
Definition: TGFrame.h:88
type
int type
Definition: TGX11.cxx:121
TGSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)=0
kScaleBoth
@ kScaleBoth
Definition: TGSlider.h:36
TGSlider::operator=
TGSlider & operator=(const TGSlider &)=delete
TGSlider::fDisabledPic
const TGPicture * fDisabledPic
picture to draw disabled slider
Definition: TGSlider.h:51
TGSlider::SetEnabled
virtual void SetEnabled(Bool_t flag=kTRUE)
Definition: TGSlider.h:72
TGSlider::fDragging
Bool_t fDragging
true if in dragging mode
Definition: TGSlider.h:49
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int