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); //*MENU*
76 virtual void SetPosition(Int_t pos); //*MENU*
77 virtual Int_t GetPosition() const { return fPos; }
78 virtual Int_t GetMinPosition() const { return fVmin; }
79 virtual Int_t GetMaxPosition() const { return fVmax; }
80 virtual Int_t GetScale() const { return fScale; }
82 virtual void ChangeSliderPic(const char *name);
83
84 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } // *SIGNAL*
85 virtual void Pressed() { Emit("Pressed()"); } // *SIGNAL*
86 virtual void Released() { Emit("Released()"); } // *SIGNAL*
87
88 ClassDefOverride(TGSlider,0) // Slider widget abstract base class
89};
90
91
92class TGVSlider : public TGSlider {
93
94protected:
95 Int_t fYp; ///< vertical slider y position in pixel coordinates
96
97 void DoRedraw() override;
98
99public:
100 TGVSlider(const TGWindow *p = nullptr, UInt_t h = 40,
101 UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
102 UInt_t options = kVerticalFrame,
104 virtual ~TGVSlider();
105
106 Bool_t HandleButton(Event_t *event) override;
108 Bool_t HandleMotion(Event_t *event) override;
110 { return TGDimension(kSliderWidth, fHeight); }
111 void Resize(UInt_t w, UInt_t h) override { TGFrame::Resize(w, h ? h+16 : fHeight + 16); }
112 void Resize(TGDimension size) override { Resize(size.fWidth, size.fHeight); }
113 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
114
115 ClassDefOverride(TGVSlider,0) // Vertical slider widget
116};
117
118
119class TGHSlider : public TGSlider {
120
121protected:
122 Int_t fXp; ///< horizontal slider x position in pixel coordinates
123
124 void DoRedraw() override;
125
126public:
127 TGHSlider(const TGWindow *p = nullptr, UInt_t w = 40,
128 UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
129 UInt_t options = kHorizontalFrame,
131 virtual ~TGHSlider();
132
133 Bool_t HandleButton(Event_t *event) override;
135 Bool_t HandleMotion(Event_t *event) override;
137 { return TGDimension(fWidth, kSliderHeight); }
138 void Resize(UInt_t w, UInt_t h) override { TGFrame::Resize(w ? w+16 : fWidth + 16, h); }
139 void Resize(TGDimension size) override { Resize(size.fWidth, size.fHeight); }
140 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
141
142 ClassDefOverride(TGHSlider,0) // Horizontal slider widget
143};
144
145#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
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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
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
char name[80]
Definition TGX11.cxx:110
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
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
Concrete class for horizontal slider.
Definition TGSlider.h:119
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in horizontal slide widget.
Definition TGSlider.cxx:524
Bool_t HandleConfigureNotify(Event_t *event) override
Handles resize events for this widget.
Definition TGSlider.cxx:548
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in horizontal slider widget.
Definition TGSlider.cxx:450
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition TGSlider.cxx:590
virtual ~TGHSlider()
Delete a horizontal slider widget.
Definition TGSlider.cxx:399
void DoRedraw() override
Redraw horizontal slider widget.
Definition TGSlider.cxx:408
void Resize(TGDimension size) override
Resize the frame.
Definition TGSlider.h:139
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGSlider.h:136
Int_t fXp
horizontal slider x position in pixel coordinates
Definition TGSlider.h:122
void Resize(UInt_t w, UInt_t h) override
Resize the frame.
Definition TGSlider.h:138
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:79
virtual void CreateDisabledPicture()
Creates disabled picture.
Definition TGSlider.cxx:131
virtual void Released()
Definition TGSlider.h:86
virtual void Pressed()
Definition TGSlider.h:85
virtual Int_t GetPosition() const
Definition TGSlider.h:77
virtual void SetPosition(Int_t pos)
Set slider position.
Definition TGSlider.cxx:110
Bool_t HandleMotion(Event_t *event) override=0
const TGPicture * fSliderPic
picture to draw slider
Definition TGSlider.h:50
virtual Int_t GetMinPosition() const
Definition TGSlider.h:78
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:99
Int_t fVmin
logical lower limit of slider
Definition TGSlider.h:45
Bool_t HandleConfigureNotify(Event_t *event) override=0
This event is generated when the frame is resized.
Int_t fType
slider type bits
Definition TGSlider.h:47
TString GetTypeString() const
used in SavePrimitive
Definition TGSlider.cxx:558
TGSlider(const TGSlider &)=delete
virtual ~TGSlider()
Definition TGSlider.h:66
virtual Int_t GetScale() const
Definition TGSlider.h:80
Bool_t fDragging
true if in dragging mode
Definition TGSlider.h:49
Bool_t HandleButton(Event_t *event) override=0
Int_t fScale
tick mark scale
Definition TGSlider.h:48
void MapSubwindows() override
map sub windows
Definition TGSlider.h:81
TGSlider & operator=(const TGSlider &)=delete
virtual void ChangeSliderPic(const char *name)
Change slider picture.
Definition TGSlider.cxx:121
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:84
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:160
virtual void SetScale(Int_t scale)
Definition TGSlider.h:74
Concrete class for vertical slider.
Definition TGSlider.h:92
void Resize(TGDimension size) override
Resize the frame.
Definition TGSlider.h:112
virtual ~TGVSlider()
Delete vertical slider widget.
Definition TGSlider.cxx:204
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in vertical slider.
Definition TGSlider.cxx:334
void DoRedraw() override
Redraw vertical slider widget.
Definition TGSlider.cxx:213
Bool_t HandleConfigureNotify(Event_t *event) override
Handles resize events for this widget.
Definition TGSlider.cxx:358
void Resize(UInt_t w, UInt_t h) override
Resize the frame.
Definition TGSlider.h:111
Int_t fYp
vertical slider y position in pixel coordinates
Definition TGSlider.h:95
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition TGSlider.cxx:627
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in vertical slider.
Definition TGSlider.cxx:256
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGSlider.h:109
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