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//////////////////////////////////////////////////////////////////////////
17// //
18// TGScrollBar and TGScrollBarElement //
19// //
20// The classes in this file implement scrollbars. Scrollbars can be //
21// either placed horizontal or vertical. A scrollbar contains three //
22// TGScrollBarElements: The "head", "tail" and "slider". The head and //
23// tail are fixed at either end and have the typical arrows in them. //
24// //
25// The TGHScrollBar will generate the following event messages: //
26// kC_HSCROLL, kSB_SLIDERPOS, position, 0 //
27// kC_HSCROLL, kSB_SLIDERTRACK, position, 0 //
28// //
29// The TGVScrollBar will generate the following event messages: //
30// kC_VSCROLL, kSB_SLIDERPOS, position, 0 //
31// kC_VSCROLL, kSB_SLIDERTRACK, position, 0 //
32// //
33//////////////////////////////////////////////////////////////////////////
34
35#include "TGButton.h"
36
37
38//--- scrollbar types
39
43};
44
45class TTimer;
46
47
49
50private:
53
54protected:
55 Int_t fState; // state of scrollbar element (button up or down)
56 const TGPicture *fPic; // picture in scrollbar element
57 const TGPicture *fPicN; // picture for normal state of scrollbar element
58 const TGPicture *fPicD; // picture for disabled state of scrollbar element
59 Pixel_t fBgndColor; // background color
60 Pixel_t fHighColor; // highlight color
61 Int_t fStyle; // modern or classic style
62
63public:
64 TGScrollBarElement(const TGWindow *p = nullptr, const TGPicture *pic = nullptr,
65 UInt_t w = 1, UInt_t h = 1,
68 virtual ~TGScrollBarElement();
69
70 virtual void SetState(Int_t state);
71 virtual void DrawBorder();
72 virtual void SetEnabled(Bool_t on = kTRUE);
73 virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
74 virtual Bool_t HandleCrossing(Event_t *event);
75
76 ClassDef(TGScrollBarElement,0) // Scrollbar element (head, tail, slider)
77};
78
79
80class TGScrollBar : public TGFrame, public TGWidget {
81
82private:
83 TGScrollBar(const TGScrollBar&) = delete;
85
86protected:
87 Int_t fX0, fY0; // current slider position in pixels
88 Int_t fXp, fYp; // previous slider position in pixels
89 Bool_t fDragging; // in dragging mode?
90 Bool_t fGrabPointer; // grab pointer when dragging
91 Int_t fRange; // logical upper range of scrollbar
92 Int_t fPsize; // logical page size of scrollbar
93 Int_t fPos; // logical current position
94 Int_t fSliderSize; // logical slider size
95 Int_t fSliderRange; // logical slider range
96 Int_t fSmallInc; // Small Increment in the sliding algorithm
97 TGScrollBarElement *fHead; // head button of scrollbar
98 TGScrollBarElement *fTail; // tail button of scrollbar
100 const TGPicture *fHeadPic; // picture in head (up or left arrow)
101 const TGPicture *fTailPic; // picture in tail (down or right arrow)
102 TTimer *fRepeat; // repeat rate timer (when mouse stays pressed)
103 Window_t fSubw; // sub window in which mouse is pressed
104 Bool_t fAccelerated; // kFALSE - normal, kTRUE - accelerated
105 Pixel_t fBgndColor; // background color
106 Pixel_t fHighColor; // highlight color
107
110
111public:
112 static Pixmap_t GetBckgndPixmap();
113 static Int_t GetScrollBarWidth();
114
115 TGScrollBar(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
116 UInt_t options = kChildFrame,
118 virtual ~TGScrollBar();
119
120 void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
121
122 virtual void DrawBorder() { }
123 virtual Bool_t HandleButton(Event_t *event) = 0;
124 virtual Bool_t HandleCrossing(Event_t *event);
125 virtual Bool_t HandleMotion(Event_t *event) = 0;
126 virtual Bool_t HandleTimer(TTimer *t);
127 virtual void Layout() = 0;
128
129 virtual void SetDragging(Bool_t drag) { fDragging = drag; }
130 virtual void SetRange(Int_t range, Int_t page_size) = 0;
131 virtual void SetPosition(Int_t pos) = 0;
132 virtual Int_t GetPosition() const { return fPos; }
133 virtual Int_t GetPageSize() const { return fPsize; }
134 virtual Int_t GetRange() const { return fRange; }
135 virtual void Resize(UInt_t w = 0, UInt_t h = 0) { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
136 virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0)
138 virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
139 virtual void ChangeBackground(Pixel_t back);
140 virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
142
144 TGScrollBarElement *GetHead() const { return fHead; }
145 TGScrollBarElement *GetTail() const { return fTail; }
147
148 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } //*SIGNAL*
149 virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); } //*SIGNAL*
150 virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); } //*SIGNAL*
151
152 virtual Int_t GetSmallIncrement() { return fSmallInc; }
153 virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
154
155 ClassDef(TGScrollBar,0) // Scrollbar widget
156};
157
158
159
160class TGHScrollBar : public TGScrollBar {
161
162public:
163 TGHScrollBar(const TGWindow *p = nullptr, UInt_t w = 4, UInt_t h = 2,
164 UInt_t options = kHorizontalFrame,
166 virtual ~TGHScrollBar() { }
167
168 virtual Bool_t HandleButton(Event_t *event);
169 virtual Bool_t HandleMotion(Event_t *event);
171 { return TGDimension(fWidth, GetScrollBarWidth()); }
172 virtual void Layout();
173
174 virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
175 virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
176 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
177
178 ClassDef(TGHScrollBar,0) // Horizontal scrollbar widget
179};
180
181
182
183class TGVScrollBar : public TGScrollBar {
184
185public:
186 TGVScrollBar(const TGWindow *p = nullptr, UInt_t w = 2, UInt_t h = 4,
187 UInt_t options = kVerticalFrame,
189 virtual ~TGVScrollBar() { }
190
191 virtual Bool_t HandleButton(Event_t *event);
192 virtual Bool_t HandleMotion(Event_t *event);
195 virtual void Layout();
196
197 virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
198 virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
199 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
200
201 ClassDef(TGVScrollBar,0) // Vertical scrollbar widget
202};
203
204#endif
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
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
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:40
@ kSBHorizontal
Definition TGScrollBar.h:41
@ kSBVertical
Definition TGScrollBar.h:42
UInt_t fHeight
Definition TGDimension.h:30
UInt_t fWidth
Definition TGDimension.h:29
UInt_t fHeight
Definition TGFrame.h:112
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
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:614
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()
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.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
virtual Bool_t IsEnabled() const
Definition TGScrollBar.h:73
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
Definition TGScrollBar.h:56
const TGPicture * fPicD
Definition TGScrollBar.h:58
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
const TGPicture * fPicN
Definition TGScrollBar.h:57
TGScrollBarElement(const TGScrollBarElement &)=delete
virtual void RangeChanged(Int_t range)
static Pixmap_t fgBckgndPixmap
TTimer * fRepeat
TGScrollBarElement * GetTail() const
Bool_t IsAccelerated() const
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
virtual Bool_t HandleButton(Event_t *event)=0
Bool_t fAccelerated
Int_t fSliderSize
Definition TGScrollBar.h:94
virtual void SetRange(Int_t range, Int_t page_size)=0
static Int_t fgScrollBarWidth
TGScrollBar & operator=(const TGScrollBar &)=delete
virtual Int_t GetSmallIncrement()
Bool_t fDragging
Definition TGScrollBar.h:89
virtual Int_t GetRange() const
virtual Bool_t HandleMotion(Event_t *event)=0
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fTailPic
virtual void SetPosition(Int_t pos)=0
TGScrollBarElement * GetSlider() const
TGScrollBarElement * fSlider
Definition TGScrollBar.h:99
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
TGScrollBarElement * GetHead() const
virtual void SetAccelerated(Bool_t m=kTRUE)
virtual void PageSizeChanged(Int_t range)
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
virtual void DrawBorder()
Draw frame border.
virtual Int_t GetPageSize() const
virtual Int_t GetPosition() const
void GrabPointer(Bool_t grab)
Window_t fSubw
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
virtual void SetDragging(Bool_t drag)
virtual void MapSubwindows()
map sub windows
Int_t fSmallInc
Definition TGScrollBar.h:96
Bool_t fGrabPointer
Definition TGScrollBar.h:90
Pixel_t fBgndColor
TGScrollBarElement * fHead
Definition TGScrollBar.h:97
Pixel_t fHighColor
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.
TGScrollBar(const TGScrollBar &)=delete
virtual void Layout()=0
TGScrollBarElement * fTail
Definition TGScrollBar.h:98
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Int_t fSliderRange
Definition TGScrollBar.h:95
virtual void PositionChanged(Int_t pos)
virtual void SetSmallIncrement(Int_t increment)
const TGPicture * fHeadPic
virtual void Resize(TGDimension size)
Resize the frame.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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()
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.
virtual void MapSubwindows()
map sub windows
Definition TGWindow.cxx:167
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