Logo ROOT   6.16/01
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-2000, 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:
51 TGScrollBarElement(const TGScrollBarElement&); // Not implemented
52 TGScrollBarElement& operator=(const TGScrollBarElement&); // Not implemented
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 = 0, const TGPicture *pic = 0,
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&); // Not implemented
84 TGScrollBar& operator=(const TGScrollBar&); // Not implemented
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 = 0, 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 = 0, 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 = 0, 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
Definition: GuiTypes.h:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
Handle_t Window_t
Definition: GuiTypes.h:28
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
@ kButtonDisabled
Definition: TGButton.h:56
@ kChildFrame
Definition: TGFrame.h:57
@ kRaisedFrame
Definition: TGFrame.h:62
@ kVerticalFrame
Definition: TGFrame.h:59
@ kDoubleBorder
Definition: TGFrame.h:63
@ kHorizontalFrame
Definition: TGFrame.h:60
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:135
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
UInt_t fWidth
Definition: TGFrame.h:134
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:611
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.
TGHScrollBar(const TGWindow *p=0, UInt_t w=4, UInt_t h=2, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a horizontal scrollbar widget.
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:166
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;
Definition: TGScrollBar.h:170
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.
TGScrollBarElement & operator=(const TGScrollBarElement &)
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).
const TGPicture * fPicN
Definition: TGScrollBar.h:57
TGScrollBarElement(const TGScrollBarElement &)
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:149
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:108
TGScrollBar(const TGScrollBar &)
TTimer * fRepeat
Definition: TGScrollBar.h:102
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:145
Int_t fPsize
Definition: TGScrollBar.h:92
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:141
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
virtual Bool_t HandleButton(Event_t *event)=0
Bool_t fAccelerated
Definition: TGScrollBar.h:104
Int_t fSliderSize
Definition: TGScrollBar.h:94
virtual void SetRange(Int_t range, Int_t page_size)=0
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:109
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:152
Bool_t fDragging
Definition: TGScrollBar.h:89
virtual Int_t GetRange() const
Definition: TGScrollBar.h:134
virtual Bool_t HandleMotion(Event_t *event)=0
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fTailPic
Definition: TGScrollBar.h:101
virtual void SetPosition(Int_t pos)=0
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:146
TGScrollBar & operator=(const TGScrollBar &)
TGScrollBarElement * fSlider
Definition: TGScrollBar.h:99
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:144
virtual void SetAccelerated(Bool_t m=kTRUE)
Definition: TGScrollBar.h:140
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:150
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
virtual void DrawBorder()
Draw frame border.
Definition: TGScrollBar.h:122
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:133
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:132
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:120
Window_t fSubw
Definition: TGScrollBar.h:103
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:129
virtual void MapSubwindows()
Definition: TGScrollBar.h:143
Int_t fSmallInc
Definition: TGScrollBar.h:96
Bool_t fGrabPointer
Definition: TGScrollBar.h:90
Int_t fPos
Definition: TGScrollBar.h:93
Pixel_t fBgndColor
Definition: TGScrollBar.h:105
TGScrollBarElement * fHead
Definition: TGScrollBar.h:97
Pixel_t fHighColor
Definition: TGScrollBar.h:106
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:136
virtual void Layout()=0
TGScrollBarElement * fTail
Definition: TGScrollBar.h:98
Int_t fRange
Definition: TGScrollBar.h:91
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:135
Int_t fSliderRange
Definition: TGScrollBar.h:95
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:148
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:153
const TGPicture * fHeadPic
Definition: TGScrollBar.h:100
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:138
TGVScrollBar(const TGWindow *p=0, 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:193
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:189
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()
Definition: TGWindow.h:89
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
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
auto * m
Definition: textangle.C:8