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 
26 class TTimer;
27 
28 
29 class TGScrollBarElement : public TGFrame {
30 
31 private:
34 
35 protected:
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 
44 public:
45  TGScrollBarElement(const TGWindow *p = nullptr, const TGPicture *pic = nullptr,
46  UInt_t w = 1, UInt_t h = 1,
47  UInt_t options = kRaisedFrame | kDoubleBorder,
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 
61 class TGScrollBar : public TGFrame, public TGWidget {
62 
63 private:
64  TGScrollBar(const TGScrollBar&) = delete;
65  TGScrollBar& operator=(const TGScrollBar&) = delete;
66 
67 protected:
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 
92 public:
93  static Pixmap_t GetBckgndPixmap();
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; }
122  Bool_t IsAccelerated() const { return fAccelerated; }
123 
125  TGScrollBarElement *GetHead() const { return fHead; }
126  TGScrollBarElement *GetTail() const { return fTail; }
127  TGScrollBarElement *GetSlider() const { return fSlider; }
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 
141 class TGHScrollBar : public TGScrollBar {
142 
143 public:
144  TGHScrollBar(const TGWindow *p = nullptr, UInt_t w = 4, UInt_t h = 2,
145  UInt_t options = kHorizontalFrame,
147  virtual ~TGHScrollBar() { }
148 
149  virtual Bool_t HandleButton(Event_t *event);
150  virtual Bool_t HandleMotion(Event_t *event);
151  virtual TGDimension GetDefaultSize() const
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 
164 class TGVScrollBar : public TGScrollBar {
165 
166 public:
167  TGVScrollBar(const TGWindow *p = nullptr, UInt_t w = 2, UInt_t h = 4,
168  UInt_t options = kVerticalFrame,
170  virtual ~TGVScrollBar() { }
171 
172  virtual Bool_t HandleButton(Event_t *event);
173  virtual Bool_t HandleMotion(Event_t *event);
174  virtual TGDimension GetDefaultSize() const
175  { return TGDimension(GetScrollBarWidth(), fHeight); }
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
TGScrollBar::DrawBorder
virtual void DrawBorder()
Draw frame border.
Definition: TGScrollBar.h:103
TGHScrollBar::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
Definition: TGScrollBar.cxx:948
TGHScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
Definition: TGScrollBar.cxx:608
TGScrollBar::fSubw
Window_t fSubw
sub window in which mouse is pressed
Definition: TGScrollBar.h:84
m
auto * m
Definition: textangle.C:8
TGScrollBar::IsAccelerated
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:122
TGVScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
Definition: TGScrollBar.cxx:892
TGScrollBar::fBgndColor
Pixel_t fBgndColor
background color
Definition: TGScrollBar.h:86
TGScrollBar::operator=
TGScrollBar & operator=(const TGScrollBar &)=delete
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TGScrollBarElement::SetEnabled
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
Definition: TGScrollBar.cxx:149
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
Pixmap_t
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
TGVScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion in a vertical scrollbar.
Definition: TGScrollBar.cxx:868
TGScrollBar::fTail
TGScrollBarElement * fTail
tail button of scrollbar
Definition: TGScrollBar.h:79
TGVScrollBar
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:164
TGScrollBar::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGScrollBar.cxx:344
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGScrollBar
The classes in this file implement scrollbars.
Definition: TGScrollBar.h:61
TGDimension
Definition: TGDimension.h:18
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGScrollBar::GetPageSize
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:114
TGScrollBar::fSlider
TGScrollBarElement * fSlider
slider
Definition: TGScrollBar.h:80
TGScrollBar::GetScrollBarWidth
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
Definition: TGScrollBar.cxx:410
TGScrollBar::fHead
TGScrollBarElement * fHead
head button of scrollbar
Definition: TGScrollBar.h:78
TGScrollBarElement::fPicN
const TGPicture * fPicN
picture for normal state of scrollbar element
Definition: TGScrollBar.h:38
TGScrollBar::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:116
TGScrollBar::SetDragging
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:110
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGFrame::fWidth
UInt_t fWidth
frame width
Definition: TGFrame.h:87
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGScrollBarElement::fPic
const TGPicture * fPic
picture in scrollbar element
Definition: TGScrollBar.h:37
TGScrollBar::MoveResize
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
TGScrollBarElement
Definition: TGScrollBar.h:29
TGScrollBar::Resize
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:119
TGHScrollBar::TGHScrollBar
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.
Definition: TGScrollBar.cxx:429
TGScrollBar::GetTail
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:126
Int_t
int Int_t
Definition: RtypesCore.h:45
TGScrollBar::fPsize
Int_t fPsize
logical page size of scrollbar
Definition: TGScrollBar.h:73
TGWidget
The widget base class.
Definition: TGWidget.h:43
TGVScrollBar::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an vertical scrollbar as a C++ statement(s) on output stream out.
Definition: TGScrollBar.cxx:975
TGVScrollBar::SetPosition
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
Definition: TGScrollBar.cxx:927
TGScrollBar::fGrabPointer
Bool_t fGrabPointer
grab pointer when dragging
Definition: TGScrollBar.h:71
event
Definition: triangle.c:553
x
Double_t x[n]
Definition: legend1.C:17
TGVScrollBar::Layout
virtual void Layout()
Layout and move vertical scrollbar components.
Definition: TGScrollBar.cxx:726
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGScrollBar::fTailPic
const TGPicture * fTailPic
picture in tail (down or right arrow)
Definition: TGScrollBar.h:82
TGScrollBarElement::fStyle
Int_t fStyle
modern or classic style
Definition: TGScrollBar.h:42
TGScrollBar::fHeadPic
const TGPicture * fHeadPic
picture in head (up or left arrow)
Definition: TGScrollBar.h:81
TGFrame
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
TGScrollBar::fDragging
Bool_t fDragging
in dragging mode?
Definition: TGScrollBar.h:70
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
bool
TGScrollBar::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGScrollBar.h:124
kSBVertical
@ kSBVertical
Definition: TGScrollBar.h:23
TGScrollBar::GrabPointer
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:101
TGHScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
Definition: TGScrollBar.cxx:632
TGScrollBarElement::fPicD
const TGPicture * fPicD
picture for disabled state of scrollbar element
Definition: TGScrollBar.h:39
TGVScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
Definition: TGScrollBar.cxx:744
TGScrollBar::GetBckgndPixmap
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
Definition: TGScrollBar.cxx:397
TGScrollBar::GetPosition
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:113
TTimer
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TGScrollBar::SetSmallIncrement
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:134
TGScrollBarElement::fState
Int_t fState
state of scrollbar element (button up or down)
Definition: TGScrollBar.h:36
TGScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)=0
TGHScrollBar::Layout
virtual void Layout()
Layout and move horizontal scrollbar components.
Definition: TGScrollBar.cxx:469
TGScrollBar::PageSizeChanged
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:131
TGScrollBar::GetRange
virtual Int_t GetRange() const
Definition: TGScrollBar.h:115
h
#define h(i)
Definition: RSha256.hxx:106
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TGScrollBar::HandleTimer
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
Definition: TGScrollBar.cxx:369
TGScrollBar::~TGScrollBar
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
Definition: TGScrollBar.cxx:331
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
TGHScrollBar
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
Definition: TGScrollBar.h:141
TGHScrollBar::SetPosition
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
Definition: TGScrollBar.cxx:665
TGScrollBar::fgScrollBarWidth
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:90
TGVScrollBar::~TGVScrollBar
virtual ~TGVScrollBar()
Definition: TGScrollBar.h:170
TGScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)=0
TGScrollBar::fAccelerated
Bool_t fAccelerated
kFALSE - normal, kTRUE - accelerated
Definition: TGScrollBar.h:85
TGScrollBar::fRepeat
TTimer * fRepeat
repeat rate timer (when mouse stays pressed)
Definition: TGScrollBar.h:83
TGScrollBarElement::fBgndColor
Pixel_t fBgndColor
background color
Definition: TGScrollBar.h:40
TGScrollBar::fYp
Int_t fYp
previous slider position in pixels
Definition: TGScrollBar.h:69
TGVScrollBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:174
TGScrollBar::fRange
Int_t fRange
logical upper range of scrollbar
Definition: TGScrollBar.h:72
TGScrollBar::fPos
Int_t fPos
logical current position
Definition: TGScrollBar.h:74
TGScrollBarElement::~TGScrollBarElement
virtual ~TGScrollBarElement()
destructor
Definition: TGScrollBar.cxx:117
TGScrollBarElement::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGScrollBar.cxx:270
TGScrollBarElement::TGScrollBarElement
TGScrollBarElement(const TGScrollBarElement &)=delete
Window_t
Handle_t Window_t
Window handle.
Definition: GuiTypes.h:29
TGScrollBar::fgBckgndPixmap
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:89
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:168
y
Double_t y[n]
Definition: legend1.C:17
TGScrollBar::GetSlider
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:127
TGScrollBar::fSliderRange
Int_t fSliderRange
logical slider range
Definition: TGScrollBar.h:76
TGHScrollBar::~TGHScrollBar
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:147
kSBHorizontal
@ kSBHorizontal
Definition: TGScrollBar.h:22
TGScrollBar::RangeChanged
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:130
kRaisedFrame
@ kRaisedFrame
Definition: GuiTypes.h:384
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGScrollBarElement::SetState
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
Definition: TGScrollBar.cxx:127
TGScrollBar::SetAccelerated
virtual void SetAccelerated(Bool_t m=kTRUE)
Definition: TGScrollBar.h:121
TGScrollBar::SetPosition
virtual void SetPosition(Int_t pos)=0
TGScrollBarElement::fHighColor
Pixel_t fHighColor
highlight color
Definition: TGScrollBar.h:41
TGHScrollBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:151
EScrollBarMode
EScrollBarMode
Definition: TGScrollBar.h:21
TGFrame::MoveResize
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
TGScrollBarElement::DrawBorder
virtual void DrawBorder()
Draw border around scollbar element.
Definition: TGScrollBar.cxx:192
TGHScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
Definition: TGScrollBar.cxx:487
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGScrollBar::fSmallInc
Int_t fSmallInc
Small Increment in the sliding algorithm.
Definition: TGScrollBar.h:77
TGButton.h
Event_t
Event structure.
Definition: GuiTypes.h:174
TGScrollBar::ChangeBackground
virtual void ChangeBackground(Pixel_t back)
Change background color.
Definition: TGScrollBar.cxx:418
TGScrollBarElement::IsEnabled
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:54
TGScrollBar::TGScrollBar
TGScrollBar(const TGScrollBar &)=delete
TGScrollBar::fX0
Int_t fX0
Definition: TGScrollBar.h:68
TGFrame::fHeight
UInt_t fHeight
frame height
Definition: TGFrame.h:88
TGScrollBar::fSliderSize
Int_t fSliderSize
logical slider size
Definition: TGScrollBar.h:75
TGScrollBar::PositionChanged
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:129
TGScrollBar::Layout
virtual void Layout()=0
TGScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)=0
TGScrollBar::fY0
Int_t fY0
current slider position in pixels
Definition: TGScrollBar.h:68
TGScrollBar::GetHead
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:125
TGVScrollBar::TGVScrollBar
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.
Definition: TGScrollBar.cxx:686
TGScrollBar::fXp
Int_t fXp
Definition: TGScrollBar.h:69
kButtonDisabled
@ kButtonDisabled
Definition: TGButton.h:56
TGScrollBar::GetSmallIncrement
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:133
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TGScrollBarElement::operator=
TGScrollBarElement & operator=(const TGScrollBarElement &)=delete
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGScrollBar::fHighColor
Pixel_t fHighColor
highlight color
Definition: TGScrollBar.h:87