Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 ~TGScrollBarElement() override;
50
51 virtual void SetState(Int_t state);
52 void DrawBorder() override;
53 virtual void SetEnabled(Bool_t on = kTRUE);
54 virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
56
57 ClassDefOverride(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 ~TGScrollBar() override;
100
102
103 void DrawBorder() override { }
107 Bool_t HandleTimer(TTimer *t) override;
108 void Layout() override = 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 void Resize(UInt_t w = 0, UInt_t h = 0) override
118 void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0) override
120 void Resize(TGDimension size) override { Resize(size.fWidth, size.fHeight); }
121 void ChangeBackground(Pixel_t back) override;
122 virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
124
126 TGScrollBarElement *GetHead() const { return fHead; }
127 TGScrollBarElement *GetTail() const { return fTail; }
129
130 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } //*SIGNAL*
131 virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); } //*SIGNAL*
132 virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); } //*SIGNAL*
133
134 virtual Int_t GetSmallIncrement() { return fSmallInc; }
135 virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
136
137 ClassDefOverride(TGScrollBar,0) // Scrollbar widget
138};
139
140
141
142class TGHScrollBar : public TGScrollBar {
143
144public:
145 TGHScrollBar(const TGWindow *p = nullptr, UInt_t w = 4, UInt_t h = 2,
146 UInt_t options = kHorizontalFrame,
148 ~TGHScrollBar() override { }
149
150 Bool_t HandleButton(Event_t *event) override;
151 Bool_t HandleMotion(Event_t *event) override;
153 { return TGDimension(fWidth, GetScrollBarWidth()); }
154 void Layout() override;
155
156 void SetRange(Int_t range, Int_t page_size) override; //*MENU*
157 void SetPosition(Int_t pos) override; //*MENU* *GETTER=GetPosition
158 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
159
160 ClassDefOverride(TGHScrollBar,0) // Horizontal scrollbar widget
161};
162
163
164
165class TGVScrollBar : public TGScrollBar {
166
167public:
168 TGVScrollBar(const TGWindow *p = nullptr, UInt_t w = 2, UInt_t h = 4,
169 UInt_t options = kVerticalFrame,
171 ~TGVScrollBar() override { }
172
173 Bool_t HandleButton(Event_t *event) override;
174 Bool_t HandleMotion(Event_t *event) override;
177 void Layout() override;
178
179 void SetRange(Int_t range, Int_t page_size) override; //*MENU*
180 void SetPosition(Int_t pos) override; //*MENU* *GETTER=GetPosition
181 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
182
183 ClassDefOverride(TGVScrollBar,0) // Vertical scrollbar widget
184};
185
186#endif
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
@ 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
#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 ClassDefOverride(name, id)
Definition Rtypes.h:341
@ kButtonDisabled
Definition TGButton.h:56
EScrollBarMode
Definition TGScrollBar.h:21
@ kSBHorizontal
Definition TGScrollBar.h:22
@ kSBVertical
Definition TGScrollBar.h:23
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 on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t grab
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:629
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
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in a horizontal scrollbar.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
void Layout() override
Layout and move horizontal scrollbar components.
Bool_t HandleButton(Event_t *event) override
Handle a mouse button event in a horizontal scrolbar.
void SetRange(Int_t range, Int_t page_size) override
Set range of horizontal scrollbar.
~TGHScrollBar() override
void SetPosition(Int_t pos) override
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
~TGScrollBarElement() override
destructor
const TGPicture * fPic
picture in scrollbar element
Definition TGScrollBar.h:37
Pixel_t fBgndColor
background color
Definition TGScrollBar.h:40
void DrawBorder() override
Draw border around scollbar element.
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).
TGScrollBarElement & operator=(const TGScrollBarElement &)=delete
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
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
TGScrollBarElement(const TGScrollBarElement &)=delete
The classes in this file implement scrollbars.
Definition TGScrollBar.h:61
virtual void RangeChanged(Int_t range)
static Pixmap_t fgBckgndPixmap
Definition TGScrollBar.h:89
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
TTimer * fRepeat
repeat rate timer (when mouse stays pressed)
Definition TGScrollBar.h:83
TGScrollBarElement * GetTail() const
Int_t fPsize
logical page size of scrollbar
Definition TGScrollBar.h:73
Bool_t IsAccelerated() const
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
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()
void DrawBorder() override
Draw frame border.
Bool_t fDragging
in dragging mode?
Definition TGScrollBar.h:70
virtual Int_t GetRange() const
const TGPicture * fTailPic
picture in tail (down or right arrow)
Definition TGScrollBar.h:82
virtual void SetPosition(Int_t pos)=0
Bool_t HandleButton(Event_t *event) override=0
TGScrollBarElement * GetSlider() const
TGScrollBarElement * fSlider
slider
Definition TGScrollBar.h:80
TGScrollBarElement * GetHead() const
Bool_t HandleMotion(Event_t *event) override=0
virtual void SetAccelerated(Bool_t m=kTRUE)
virtual void PageSizeChanged(Int_t range)
Int_t fY0
current slider position in pixels
Definition TGScrollBar.h:68
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
virtual Int_t GetPageSize() const
virtual Int_t GetPosition() const
void GrabPointer(Bool_t grab)
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)
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
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
void ChangeBackground(Pixel_t back) override
Change background color.
Pixel_t fHighColor
highlight color
Definition TGScrollBar.h:87
void Resize(TGDimension size) override
Resize the frame.
Bool_t HandleTimer(TTimer *t) override
Handle repeat timer for horizontal or vertical scrollbar.
TGScrollBar(const TGScrollBar &)=delete
TGScrollBarElement * fTail
tail button of scrollbar
Definition TGScrollBar.h:79
void MapSubwindows() override
map sub windows
Int_t fRange
logical upper range of scrollbar
Definition TGScrollBar.h:72
Int_t fSliderRange
logical slider range
Definition TGScrollBar.h:76
virtual void PositionChanged(Int_t pos)
virtual void SetSmallIncrement(Int_t increment)
~TGScrollBar() override
Delete a scrollbar (either horizontal or vertical).
void Layout() override=0
const TGPicture * fHeadPic
picture in head (up or left arrow)
Definition TGScrollBar.h:81
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
~TGVScrollBar() override
void SetRange(Int_t range, Int_t page_size) override
Set range of vertical scrollbar.
void SetPosition(Int_t pos) override
Set logical slider position of vertical scrollbar.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in vertical scrollbar.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion in a vertical scrollbar.
void Layout() override
Layout and move vertical scrollbar components.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an vertical scrollbar as a C++ statement(s) on output stream out.
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
TMarker m
Definition textangle.C:8