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-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 
45 class TTimer;
46 
47 
48 class TGScrollBarElement : public TGFrame {
49 
50 private:
51  TGScrollBarElement(const TGScrollBarElement&); // Not implemented
52  TGScrollBarElement& operator=(const TGScrollBarElement&); // Not implemented
53 
54 protected:
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 
63 public:
64  TGScrollBarElement(const TGWindow *p = 0, const TGPicture *pic = 0,
65  UInt_t w = 1, UInt_t h = 1,
66  UInt_t options = kRaisedFrame | kDoubleBorder,
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 
80 class TGScrollBar : public TGFrame, public TGWidget {
81 
82 private:
83  TGScrollBar(const TGScrollBar&); // Not implemented
84  TGScrollBar& operator=(const TGScrollBar&); // Not implemented
85 
86 protected:
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 
111 public:
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; }
141  Bool_t IsAccelerated() const { return fAccelerated; }
142 
144  TGScrollBarElement *GetHead() const { return fHead; }
145  TGScrollBarElement *GetTail() const { return fTail; }
146  TGScrollBarElement *GetSlider() const { return fSlider; }
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 
160 class TGHScrollBar : public TGScrollBar {
161 
162 public:
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);
170  virtual TGDimension GetDefaultSize() const
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 
183 class TGVScrollBar : public TGScrollBar {
184 
185 public:
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);
193  virtual TGDimension GetDefaultSize() const
194  { return TGDimension(GetScrollBarWidth(), fHeight); }
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
TGScrollBar::DrawBorder
virtual void DrawBorder()
Draw frame border.
Definition: TGScrollBar.h:122
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:940
TGHScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
Definition: TGScrollBar.cxx:600
TGScrollBar::fSubw
Window_t fSubw
Definition: TGScrollBar.h:103
m
auto * m
Definition: textangle.C:8
TGScrollBar::IsAccelerated
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:141
TGVScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
Definition: TGScrollBar.cxx:884
TGScrollBar::fBgndColor
Pixel_t fBgndColor
Definition: TGScrollBar.h:105
TGWindow
Definition: TGWindow.h:31
TGScrollBarElement::SetEnabled
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
Definition: TGScrollBar.cxx:141
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
Pixmap_t
Handle_t Pixmap_t
Definition: GuiTypes.h:29
TGVScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion in a vertical scrollbar.
Definition: TGScrollBar.cxx:860
TGScrollBar::fTail
TGScrollBarElement * fTail
Definition: TGScrollBar.h:98
TGVScrollBar
Definition: TGScrollBar.h:183
TGScrollBar::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGScrollBar.cxx:336
TGPicture
Definition: TGPicture.h:36
TGScrollBar
Definition: TGScrollBar.h:80
TGDimension
Definition: TGDimension.h:27
TGScrollBar::GetPageSize
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:133
TGScrollBar::fSlider
TGScrollBarElement * fSlider
Definition: TGScrollBar.h:99
TGScrollBar::GetScrollBarWidth
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
Definition: TGScrollBar.cxx:402
TGScrollBar::fHead
TGScrollBarElement * fHead
Definition: TGScrollBar.h:97
TGScrollBarElement::fPicN
const TGPicture * fPicN
Definition: TGScrollBar.h:57
TGScrollBar::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:135
TGScrollBar::SetDragging
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:129
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGScrollBarElement::fPic
const TGPicture * fPic
Definition: TGScrollBar.h:56
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:136
TGScrollBarElement
Definition: TGScrollBar.h:48
TGScrollBar::Resize
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:138
TGScrollBar::GetTail
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:145
Int_t
int Int_t
Definition: RtypesCore.h:45
TGScrollBar::fPsize
Int_t fPsize
Definition: TGScrollBar.h:92
TGWidget
Definition: TGWidget.h:55
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:967
TGVScrollBar::SetPosition
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
Definition: TGScrollBar.cxx:919
TGScrollBar::fGrabPointer
Bool_t fGrabPointer
Definition: TGScrollBar.h:90
x
Double_t x[n]
Definition: legend1.C:17
TGVScrollBar::Layout
virtual void Layout()
Layout and move vertical scrollbar components.
Definition: TGScrollBar.cxx:718
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGScrollBar::fTailPic
const TGPicture * fTailPic
Definition: TGScrollBar.h:101
TGScrollBarElement::fStyle
Int_t fStyle
Definition: TGScrollBar.h:61
TGScrollBar::fHeadPic
const TGPicture * fHeadPic
Definition: TGScrollBar.h:100
TGFrame
Definition: TGFrame.h:105
TGScrollBar::fDragging
Bool_t fDragging
Definition: TGScrollBar.h:89
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
TGScrollBar::TGScrollBar
TGScrollBar(const TGScrollBar &)
TGScrollBarElement::operator=
TGScrollBarElement & operator=(const TGScrollBarElement &)
bool
TGScrollBar::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGScrollBar.h:143
kSBVertical
@ kSBVertical
Definition: TGScrollBar.h:48
TGScrollBar::GrabPointer
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:120
TGHScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
Definition: TGScrollBar.cxx:624
TGScrollBarElement::fPicD
const TGPicture * fPicD
Definition: TGScrollBar.h:58
TGVScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
Definition: TGScrollBar.cxx:736
TGScrollBar::GetBckgndPixmap
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
Definition: TGScrollBar.cxx:389
TGScrollBar::GetPosition
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:132
TTimer
Definition: TTimer.h:51
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGScrollBarElement::TGScrollBarElement
TGScrollBarElement(const TGScrollBarElement &)
TGScrollBar::SetSmallIncrement
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:153
TGScrollBarElement::fState
Int_t fState
Definition: TGScrollBar.h:55
TGScrollBar::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)=0
TGHScrollBar::Layout
virtual void Layout()
Layout and move horizontal scrollbar components.
Definition: TGScrollBar.cxx:461
TGScrollBar::PageSizeChanged
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:150
TGDimension::fHeight
UInt_t fHeight
Definition: TGDimension.h:36
TGScrollBar::GetRange
virtual Int_t GetRange() const
Definition: TGScrollBar.h:134
h
#define h(i)
Definition: RSha256.hxx:124
TGScrollBar::HandleTimer
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
Definition: TGScrollBar.cxx:361
TGScrollBar::~TGScrollBar
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
Definition: TGScrollBar.cxx:323
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGHScrollBar
Definition: TGScrollBar.h:160
TGHScrollBar::SetPosition
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
Definition: TGScrollBar.cxx:657
TGScrollBar::fgScrollBarWidth
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:109
TGVScrollBar::~TGVScrollBar
virtual ~TGVScrollBar()
Definition: TGScrollBar.h:189
TGScrollBar::SetRange
virtual void SetRange(Int_t range, Int_t page_size)=0
TGScrollBar::fAccelerated
Bool_t fAccelerated
Definition: TGScrollBar.h:104
TGScrollBar::fRepeat
TTimer * fRepeat
Definition: TGScrollBar.h:102
TGScrollBarElement::fBgndColor
Pixel_t fBgndColor
Definition: TGScrollBar.h:59
TGScrollBar::fYp
Int_t fYp
Definition: TGScrollBar.h:88
TGVScrollBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:193
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:35
TGScrollBar::fRange
Int_t fRange
Definition: TGScrollBar.h:91
TGScrollBar::fPos
Int_t fPos
Definition: TGScrollBar.h:93
TGScrollBarElement::~TGScrollBarElement
virtual ~TGScrollBarElement()
destructor
Definition: TGScrollBar.cxx:109
TGScrollBarElement::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGScrollBar.cxx:262
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
TGScrollBar::fgBckgndPixmap
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:108
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:149
y
Double_t y[n]
Definition: legend1.C:17
TGScrollBar::GetSlider
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:146
TGScrollBar::fSliderRange
Int_t fSliderRange
Definition: TGScrollBar.h:95
TGHScrollBar::~TGHScrollBar
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:166
kSBHorizontal
@ kSBHorizontal
Definition: TGScrollBar.h:47
TGScrollBar::RangeChanged
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:149
kRaisedFrame
@ kRaisedFrame
Definition: GuiTypes.h:384
TGVScrollBar::TGVScrollBar
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.
Definition: TGScrollBar.cxx:678
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:119
TGScrollBar::SetAccelerated
virtual void SetAccelerated(Bool_t m=kTRUE)
Definition: TGScrollBar.h:140
TGScrollBar::SetPosition
virtual void SetPosition(Int_t pos)=0
TGScrollBarElement::fHighColor
Pixel_t fHighColor
Definition: TGScrollBar.h:60
TGHScrollBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:170
EScrollBarMode
EScrollBarMode
Definition: TGScrollBar.h:40
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:614
TGScrollBarElement::DrawBorder
virtual void DrawBorder()
Draw border around scollbar element.
Definition: TGScrollBar.cxx:184
TGHScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
Definition: TGScrollBar.cxx:479
TGHScrollBar::TGHScrollBar
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.
Definition: TGScrollBar.cxx:421
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGScrollBar::fSmallInc
Int_t fSmallInc
Definition: TGScrollBar.h:96
TGButton.h
Event_t
Definition: GuiTypes.h:173
TGScrollBar::ChangeBackground
virtual void ChangeBackground(Pixel_t back)
Change background color.
Definition: TGScrollBar.cxx:410
TGScrollBarElement::IsEnabled
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:73
TGScrollBar::fX0
Int_t fX0
Definition: TGScrollBar.h:87
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
TGScrollBar::fSliderSize
Int_t fSliderSize
Definition: TGScrollBar.h:94
TGScrollBar::PositionChanged
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:148
TGScrollBar::Layout
virtual void Layout()=0
TGScrollBar::HandleButton
virtual Bool_t HandleButton(Event_t *event)=0
TGScrollBar::operator=
TGScrollBar & operator=(const TGScrollBar &)
TGScrollBar::fY0
Int_t fY0
Definition: TGScrollBar.h:87
TGScrollBar::GetHead
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:144
TGScrollBar::fXp
Int_t fXp
Definition: TGScrollBar.h:88
kButtonDisabled
@ kButtonDisabled
Definition: TGButton.h:62
TGScrollBar::GetSmallIncrement
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:152
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGScrollBar::fHighColor
Pixel_t fHighColor
Definition: TGScrollBar.h:106