Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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)
32
33 //--- scaling of slider
36 kScaleBoth = BIT(4)
37};
38
39
40class TGSlider : public TGFrame, public TGWidget {
41
42protected:
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
56private:
57 TGSlider(const TGSlider&) = delete;
58 TGSlider& operator=(const TGSlider&) = delete;
59
60public:
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; }
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
101class TGVSlider : public TGSlider {
102
103protected:
104 Int_t fYp; ///< vertical slider y position in pixel coordinates
105
106 virtual void DoRedraw();
107
108public:
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
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
128class TGHSlider : public TGSlider {
129
130protected:
131 Int_t fXp; ///< horizontal slider x position in pixel coordinates
132
133 virtual void DoRedraw();
134
135public:
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
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
@ 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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
#define BIT(n)
Definition Rtypes.h:85
ESliderSize
Definition TGSlider.h:22
@ kSliderWidth
Definition TGSlider.h:23
@ kSliderHeight
Definition TGSlider.h:24
ESliderType
Definition TGSlider.h:28
@ kScaleNo
Definition TGSlider.h:34
@ kScaleBoth
Definition TGSlider.h:36
@ kSlider2
Definition TGSlider.h:31
@ kSlider1
Definition TGSlider.h:30
@ kScaleDownRight
Definition TGSlider.h:35
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:308
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
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
UInt_t fWidth
frame width
Definition TGFrame.h:87
Concrete class for horizontal slider.
Definition TGSlider.h:128
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGSlider.h:145
virtual void Resize(TGDimension size)
Resize the frame.
Definition TGSlider.h:148
virtual void Resize(UInt_t w, UInt_t h)
Resize the frame.
Definition TGSlider.h:147
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition TGSlider.cxx:377
virtual ~TGHSlider()
Delete a horizontal slider widget.
Definition TGSlider.cxx:368
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
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition TGSlider.cxx:493
Int_t fXp
horizontal slider x position in pixel coordinates
Definition TGSlider.h:131
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
Definition TGSlider.cxx:419
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition TGSlider.cxx:517
TGClient * fClient
Connection to display server.
Definition TGObject.h:27
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Slider widgets allow easy selection of a range.
Definition TGSlider.h:40
Int_t fPos
logical position between fVmin and fVmax
Definition TGSlider.h:43
Int_t fRelPos
slider position in pixel coordinates
Definition TGSlider.h:44
virtual Int_t GetMaxPosition() const
Definition TGSlider.h:85
virtual void CreateDisabledPicture()
Creates disabled picture.
Definition TGSlider.cxx:100
virtual void Released()
Definition TGSlider.h:95
virtual void Pressed()
Definition TGSlider.h:94
virtual void ChangeSliderPic(const char *name)
Definition TGSlider.h:88
virtual Int_t GetPosition() const
Definition TGSlider.h:83
const TGPicture * fSliderPic
picture to draw slider
Definition TGSlider.h:50
virtual void MapSubwindows()
map sub windows
Definition TGSlider.h:87
virtual Int_t GetMinPosition() const
Definition TGSlider.h:84
virtual Bool_t HandleButton(Event_t *event)=0
virtual void SetPosition(Int_t pos)
Definition TGSlider.h:79
Int_t fVmin
logical lower limit of slider
Definition TGSlider.h:45
Int_t fType
slider type bits
Definition TGSlider.h:47
TString GetTypeString() const
used in SavePrimitive
Definition TGSlider.cxx:527
TGSlider(const TGSlider &)=delete
virtual ~TGSlider()
Definition TGSlider.h:66
virtual Int_t GetScale() const
Definition TGSlider.h:86
Bool_t fDragging
true if in dragging mode
Definition TGSlider.h:49
virtual Bool_t HandleMotion(Event_t *event)=0
virtual void SetRange(Int_t min, Int_t max)
Definition TGSlider.h:75
Int_t fScale
tick mark scale
Definition TGSlider.h:48
TGSlider & operator=(const TGSlider &)=delete
virtual void SetEnabled(Bool_t flag=kTRUE)
Definition TGSlider.h:72
const TGPicture * fDisabledPic
picture to draw disabled slider
Definition TGSlider.h:51
virtual void PositionChanged(Int_t pos)
Definition TGSlider.h:93
virtual Bool_t HandleConfigureNotify(Event_t *event)=0
This event is generated when the frame is resized.
Int_t fVmax
logical upper limit of slider
Definition TGSlider.h:46
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Definition TGSlider.cxx:129
virtual void SetScale(Int_t scale)
Definition TGSlider.h:74
Concrete class for vertical slider.
Definition TGSlider.h:101
virtual void Resize(UInt_t w, UInt_t h)
Resize the frame.
Definition TGSlider.h:120
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition TGSlider.cxx:327
virtual ~TGVSlider()
Delete vertical slider widget.
Definition TGSlider.cxx:173
virtual void DoRedraw()
Redraw vertical slider widget.
Definition TGSlider.cxx:182
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
Int_t fYp
vertical slider y position in pixel coordinates
Definition TGSlider.h:104
virtual void Resize(TGDimension size)
Resize the frame.
Definition TGSlider.h:121
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition TGSlider.cxx:303
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition TGSlider.cxx:225
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGSlider.h:118
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
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:949
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