Logo ROOT   master
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
TGScrollBarElement * fTail
Definition: TGScrollBar.h:98
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:152
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:588
Pixel_t fHighColor
Definition: TGScrollBar.h:106
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:133
TGScrollBarElement * fSlider
Definition: TGScrollBar.h:99
auto * m
Definition: textangle.C:8
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:612
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:135
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
virtual void Layout()
Layout and move horizontal scrollbar components.
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:138
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:145
TGScrollBarElement * fHead
Definition: TGScrollBar.h:97
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:129
virtual ~TGVScrollBar()
Definition: TGScrollBar.h:189
EScrollBarMode
Definition: TGScrollBar.h:40
TGScrollBarElement & operator=(const TGScrollBarElement &)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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.
const TGPicture * fTailPic
Definition: TGScrollBar.h:101
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 SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:73
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:166
virtual void DrawBorder()
Draw border around scollbar element.
Int_t fPsize
Definition: TGScrollBar.h:92
Bool_t fGrabPointer
Definition: TGScrollBar.h:90
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:326
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:666
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:150
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:120
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
const TGPicture * fHeadPic
Definition: TGScrollBar.h:100
Bool_t fDragging
Definition: TGScrollBar.h:89
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:132
TGScrollBar(const TGScrollBar &)
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:153
const TGPicture * fPicN
Definition: TGScrollBar.h:57
virtual void MapSubwindows()
map sub windows
Definition: TGScrollBar.h:143
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
UInt_t fHeight
Definition: TGDimension.h:30
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:109
virtual void SetRange(Int_t range, Int_t page_size)=0
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
UInt_t fWidth
Definition: TGDimension.h:29
virtual Bool_t HandleMotion(Event_t *event)=0
Int_t fRange
Definition: TGScrollBar.h:91
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:150
virtual Int_t GetRange() const
Definition: TGScrollBar.h:134
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:108
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:146
Int_t fSliderRange
Definition: TGScrollBar.h:95
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t fAccelerated
Definition: TGScrollBar.h:104
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:149
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TTimer * fRepeat
Definition: TGScrollBar.h:102
TGScrollBarElement(const TGScrollBarElement &)
const TGPicture * fPic
Definition: TGScrollBar.h:56
Int_t fPos
Definition: TGScrollBar.h:93
#define h(i)
Definition: RSha256.hxx:106
UInt_t fWidth
Definition: TGFrame.h:112
virtual void Layout()
Layout and move vertical scrollbar components.
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
virtual void SetAccelerated(Bool_t m=kTRUE)
Definition: TGScrollBar.h:140
Double_t y[n]
Definition: legend1.C:17
virtual void SetPosition(Int_t pos)=0
Int_t fSmallInc
Definition: TGScrollBar.h:96
UInt_t fHeight
Definition: TGFrame.h:113
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 ~TGScrollBarElement()
destructor
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion in a vertical scrollbar.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an vertical scrollbar as a C++ statement(s) on output stream out.
Handle_t Window_t
Definition: GuiTypes.h:28
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:170
Int_t fSliderSize
Definition: TGScrollBar.h:94
virtual Bool_t HandleButton(Event_t *event)=0
Handle_t Pixmap_t
Definition: GuiTypes.h:29
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:148
TGScrollBar & operator=(const TGScrollBar &)
virtual void ChangeBackground(Pixel_t back)
Change background color.
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:144
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
const TGPicture * fPicD
Definition: TGScrollBar.h:58
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:193
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void Layout()=0
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
virtual void DrawBorder()
Draw frame border.
Definition: TGScrollBar.h:122
Window_t fSubw
Definition: TGScrollBar.h:103
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:141
Pixel_t fBgndColor
Definition: TGScrollBar.h:105