Logo ROOT  
Reference Guide
TGScrollBar.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 10/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_TGScrollBar
13#define ROOT_TGScrollBar
14
15
16#include "TGButton.h"
17
18
19//--- scrollbar types
20
24};
25
26class TTimer;
27
28
30
31private:
34
35protected:
36 Int_t fState; ///< state of scrollbar element (button up or down)
37 const TGPicture *fPic; ///< picture in scrollbar element
38 const TGPicture *fPicN; ///< picture for normal state of scrollbar element
39 const TGPicture *fPicD; ///< picture for disabled state of scrollbar element
40 Pixel_t fBgndColor; ///< background color
41 Pixel_t fHighColor; ///< highlight color
42 Int_t fStyle; ///< modern or classic style
43
44public:
45 TGScrollBarElement(const TGWindow *p = nullptr, const TGPicture *pic = nullptr,
46 UInt_t w = 1, UInt_t h = 1,
49 virtual ~TGScrollBarElement();
50
51 virtual void SetState(Int_t state);
52 virtual void DrawBorder();
53 virtual void SetEnabled(Bool_t on = kTRUE);
54 virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
56
57 ClassDef(TGScrollBarElement,0) // Scrollbar element (head, tail, slider)
58};
59
60
61class TGScrollBar : public TGFrame, public TGWidget {
62
63private:
64 TGScrollBar(const TGScrollBar&) = delete;
66
67protected:
68 Int_t fX0, fY0; ///< current slider position in pixels
69 Int_t fXp, fYp; ///< previous slider position in pixels
70 Bool_t fDragging; ///< in dragging mode?
71 Bool_t fGrabPointer; ///< grab pointer when dragging
72 Int_t fRange; ///< logical upper range of scrollbar
73 Int_t fPsize; ///< logical page size of scrollbar
74 Int_t fPos; ///< logical current position
75 Int_t fSliderSize; ///< logical slider size
76 Int_t fSliderRange; ///< logical slider range
77 Int_t fSmallInc; ///< Small Increment in the sliding algorithm
78 TGScrollBarElement *fHead; ///< head button of scrollbar
79 TGScrollBarElement *fTail; ///< tail button of scrollbar
81 const TGPicture *fHeadPic; ///< picture in head (up or left arrow)
82 const TGPicture *fTailPic; ///< picture in tail (down or right arrow)
83 TTimer *fRepeat; ///< repeat rate timer (when mouse stays pressed)
84 Window_t fSubw; ///< sub window in which mouse is pressed
85 Bool_t fAccelerated; ///< kFALSE - normal, kTRUE - accelerated
86 Pixel_t fBgndColor; ///< background color
87 Pixel_t fHighColor; ///< highlight color
88
91
92public:
94 static Int_t GetScrollBarWidth();
95
96 TGScrollBar(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
97 UInt_t options = kChildFrame,
99 virtual ~TGScrollBar();
100
101 void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
102
103 virtual void DrawBorder() { }
107 virtual Bool_t HandleTimer(TTimer *t);
108 virtual void Layout() = 0;
109
110 virtual void SetDragging(Bool_t drag) { fDragging = drag; }
111 virtual void SetRange(Int_t range, Int_t page_size) = 0;
112 virtual void SetPosition(Int_t pos) = 0;
113 virtual Int_t GetPosition() const { return fPos; }
114 virtual Int_t GetPageSize() const { return fPsize; }
115 virtual Int_t GetRange() const { return fRange; }
116 virtual void Resize(UInt_t w = 0, UInt_t h = 0) { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
117 virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0)
119 virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
120 virtual void ChangeBackground(Pixel_t back);
121 virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
123
125 TGScrollBarElement *GetHead() const { return fHead; }
126 TGScrollBarElement *GetTail() const { return fTail; }
128
129 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } //*SIGNAL*
130 virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); } //*SIGNAL*
131 virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); } //*SIGNAL*
132
133 virtual Int_t GetSmallIncrement() { return fSmallInc; }
134 virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
135
136 ClassDef(TGScrollBar,0) // Scrollbar widget
137};
138
139
140
141class TGHScrollBar : public TGScrollBar {
142
143public:
144 TGHScrollBar(const TGWindow *p = nullptr, UInt_t w = 4, UInt_t h = 2,
145 UInt_t options = kHorizontalFrame,
147 virtual ~TGHScrollBar() { }
148
152 { return TGDimension(fWidth, GetScrollBarWidth()); }
153 virtual void Layout();
154
155 virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
156 virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
157 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
158
159 ClassDef(TGHScrollBar,0) // Horizontal scrollbar widget
160};
161
162
163
164class TGVScrollBar : public TGScrollBar {
165
166public:
167 TGVScrollBar(const TGWindow *p = nullptr, UInt_t w = 2, UInt_t h = 4,
168 UInt_t options = kVerticalFrame,
170 virtual ~TGVScrollBar() { }
171
176 virtual void Layout();
177
178 virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
179 virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
180 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
181
182 ClassDef(TGVScrollBar,0) // Vertical scrollbar widget
183};
184
185#endif
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
@ kChildFrame
Definition: GuiTypes.h:379
@ kRaisedFrame
Definition: GuiTypes.h:384
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kDoubleBorder
Definition: GuiTypes.h:385
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
Handle_t Window_t
Window handle.
Definition: GuiTypes.h:29
#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
@ kButtonDisabled
Definition: TGButton.h:56
EScrollBarMode
Definition: TGScrollBar.h:21
@ kSBHorizontal
Definition: TGScrollBar.h:22
@ kSBVertical
Definition: TGScrollBar.h:23
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
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:629
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:141
virtual void Layout()
Layout and move horizontal scrollbar components.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:147
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
TGHScrollBar(const TGWindow *p=nullptr, UInt_t w=4, UInt_t h=2, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a horizontal scrollbar widget.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:151
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:54
virtual void DrawBorder()
Draw border around scollbar element.
virtual ~TGScrollBarElement()
destructor
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fPic
picture in scrollbar element
Definition: TGScrollBar.h:37
Pixel_t fBgndColor
background color
Definition: TGScrollBar.h:40
TGScrollBarElement & operator=(const TGScrollBarElement &)=delete
const TGPicture * fPicD
picture for disabled state of scrollbar element
Definition: TGScrollBar.h:39
Int_t fStyle
modern or classic style
Definition: TGScrollBar.h:42
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
Pixel_t fHighColor
highlight color
Definition: TGScrollBar.h:41
const TGPicture * fPicN
picture for normal state of scrollbar element
Definition: TGScrollBar.h:38
Int_t fState
state of scrollbar element (button up or down)
Definition: TGScrollBar.h:36
TGScrollBarElement(const TGScrollBarElement &)=delete
The classes in this file implement scrollbars.
Definition: TGScrollBar.h:61
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:130
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:89
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:127
TTimer * fRepeat
repeat rate timer (when mouse stays pressed)
Definition: TGScrollBar.h:83
Int_t fPsize
logical page size of scrollbar
Definition: TGScrollBar.h:73
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:122
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:126
virtual Bool_t HandleButton(Event_t *event)=0
Bool_t fAccelerated
kFALSE - normal, kTRUE - accelerated
Definition: TGScrollBar.h:85
Int_t fSliderSize
logical slider size
Definition: TGScrollBar.h:75
virtual void SetRange(Int_t range, Int_t page_size)=0
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:90
TGScrollBar & operator=(const TGScrollBar &)=delete
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:133
Bool_t fDragging
in dragging mode?
Definition: TGScrollBar.h:70
virtual Int_t GetRange() const
Definition: TGScrollBar.h:115
virtual Bool_t HandleMotion(Event_t *event)=0
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fTailPic
picture in tail (down or right arrow)
Definition: TGScrollBar.h:82
virtual void SetPosition(Int_t pos)=0
TGScrollBarElement * fSlider
slider
Definition: TGScrollBar.h:80
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
virtual void SetAccelerated(Bool_t m=kTRUE)
Definition: TGScrollBar.h:121
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:131
Int_t fY0
current slider position in pixels
Definition: TGScrollBar.h:68
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
virtual void DrawBorder()
Draw frame border.
Definition: TGScrollBar.h:103
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:125
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:114
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:113
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:101
Window_t fSubw
sub window in which mouse is pressed
Definition: TGScrollBar.h:84
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:110
virtual void MapSubwindows()
map sub windows
Definition: TGScrollBar.h:124
Int_t fSmallInc
Small Increment in the sliding algorithm.
Definition: TGScrollBar.h:77
Bool_t fGrabPointer
grab pointer when dragging
Definition: TGScrollBar.h:71
Int_t fPos
logical current position
Definition: TGScrollBar.h:74
Pixel_t fBgndColor
background color
Definition: TGScrollBar.h:86
TGScrollBarElement * fHead
head button of scrollbar
Definition: TGScrollBar.h:78
Int_t fYp
previous slider position in pixels
Definition: TGScrollBar.h:69
Pixel_t fHighColor
highlight color
Definition: TGScrollBar.h:87
virtual void ChangeBackground(Pixel_t back)
Change background color.
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGScrollBar.h:117
TGScrollBar(const TGScrollBar &)=delete
virtual void Layout()=0
TGScrollBarElement * fTail
tail button of scrollbar
Definition: TGScrollBar.h:79
Int_t fRange
logical upper range of scrollbar
Definition: TGScrollBar.h:72
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:116
Int_t fSliderRange
logical slider range
Definition: TGScrollBar.h:76
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:129
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:134
const TGPicture * fHeadPic
picture in head (up or left arrow)
Definition: TGScrollBar.h:81
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:119
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:164
TGVScrollBar(const TGWindow *p=nullptr, UInt_t w=2, UInt_t h=4, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a vertical scrollbar.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:174
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion in a vertical scrollbar.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
virtual ~TGVScrollBar()
Definition: TGScrollBar.h:170
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
virtual void Layout()
Layout and move vertical scrollbar components.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an vertical scrollbar as a C++ statement(s) on output stream out.
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
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
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
Event structure.
Definition: GuiTypes.h:174
auto * m
Definition: textangle.C:8