ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TGButton
36 #include "TGButton.h"
37 #endif
38 
39 
40 //--- scrollbar types
41 
45 };
46 
47 class TTimer;
48 
49 
50 class TGScrollBarElement : public TGFrame {
51 
52 private:
53  TGScrollBarElement(const TGScrollBarElement&); // Not implemented
54  TGScrollBarElement& operator=(const TGScrollBarElement&); // Not implemented
55 
56 protected:
57  Int_t fState; // state of scrollbar element (button up or down)
58  const TGPicture *fPic; // picture in scrollbar element
59  const TGPicture *fPicN; // picture for normal state of scrollbar element
60  const TGPicture *fPicD; // picture for disabled state of scrollbar element
61  Pixel_t fBgndColor; // background color
62  Pixel_t fHighColor; // highlight color
63  Int_t fStyle; // modern or classic style
64 
65 public:
66  TGScrollBarElement(const TGWindow *p = 0, const TGPicture *pic = 0,
67  UInt_t w = 1, UInt_t h = 1,
68  UInt_t options = kRaisedFrame | kDoubleBorder,
70  virtual ~TGScrollBarElement();
71 
72  virtual void SetState(Int_t state);
73  virtual void DrawBorder();
74  virtual void SetEnabled(Bool_t on = kTRUE);
75  virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
76  virtual Bool_t HandleCrossing(Event_t *event);
77 
78  ClassDef(TGScrollBarElement,0) // Scrollbar element (head, tail, slider)
79 };
80 
81 
82 class TGScrollBar : public TGFrame, public TGWidget {
83 
84 private:
85  TGScrollBar(const TGScrollBar&); // Not implemented
86  TGScrollBar& operator=(const TGScrollBar&); // Not implemented
87 
88 protected:
89  Int_t fX0, fY0; // current slider position in pixels
90  Int_t fXp, fYp; // previous slider position in pixels
91  Bool_t fDragging; // in dragging mode?
92  Bool_t fGrabPointer; // grab pointer when dragging
93  Int_t fRange; // logical upper range of scrollbar
94  Int_t fPsize; // logical page size of scrollbar
95  Int_t fPos; // logical current position
96  Int_t fSliderSize; // logical slider size
97  Int_t fSliderRange; // logical slider range
98  Int_t fSmallInc; // Small Increment in the sliding algorithm
99  TGScrollBarElement *fHead; // head button of scrollbar
100  TGScrollBarElement *fTail; // tail button of scrollbar
102  const TGPicture *fHeadPic; // picture in head (up or left arrow)
103  const TGPicture *fTailPic; // picture in tail (down or right arrow)
104  TTimer *fRepeat; // repeat rate timer (when mouse stays pressed)
105  Window_t fSubw; // sub window in which mouse is pressed
106  Bool_t fAccelerated; // kFALSE - normal, kTRUE - accelerated
107  Pixel_t fBgndColor; // background color
108  Pixel_t fHighColor; // highlight color
109 
112 
113 public:
114  static Pixmap_t GetBckgndPixmap();
115  static Int_t GetScrollBarWidth();
116 
117  TGScrollBar(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
118  UInt_t options = kChildFrame,
120  virtual ~TGScrollBar();
121 
122  void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
123 
124  virtual void DrawBorder() { }
125  virtual Bool_t HandleButton(Event_t *event) = 0;
126  virtual Bool_t HandleCrossing(Event_t *event);
127  virtual Bool_t HandleMotion(Event_t *event) = 0;
128  virtual Bool_t HandleTimer(TTimer *t);
129  virtual void Layout() = 0;
130 
131  virtual void SetDragging(Bool_t drag) { fDragging = drag; }
132  virtual void SetRange(Int_t range, Int_t page_size) = 0;
133  virtual void SetPosition(Int_t pos) = 0;
134  virtual Int_t GetPosition() const { return fPos; }
135  virtual Int_t GetPageSize() const { return fPsize; }
136  virtual Int_t GetRange() const { return fRange; }
137  virtual void Resize(UInt_t w = 0, UInt_t h = 0) { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
138  virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0)
139  { TGFrame::MoveResize(x, y, w, h); SetRange(fRange, fPsize); }
140  virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
141  virtual void ChangeBackground(Pixel_t back);
142  virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
143  Bool_t IsAccelerated() const { return fAccelerated; }
144 
146  TGScrollBarElement *GetHead() const { return fHead; }
147  TGScrollBarElement *GetTail() const { return fTail; }
148  TGScrollBarElement *GetSlider() const { return fSlider; }
149 
150  virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); } //*SIGNAL*
151  virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); } //*SIGNAL*
152  virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); } //*SIGNAL*
153 
154  virtual Int_t GetSmallIncrement() { return fSmallInc; }
156 
157  ClassDef(TGScrollBar,0) // Scrollbar widget
158 };
159 
160 
161 
162 class TGHScrollBar : public TGScrollBar {
163 
164 public:
165  TGHScrollBar(const TGWindow *p = 0, UInt_t w = 4, UInt_t h = 2,
166  UInt_t options = kHorizontalFrame,
168  virtual ~TGHScrollBar() { }
169 
170  virtual Bool_t HandleButton(Event_t *event);
171  virtual Bool_t HandleMotion(Event_t *event);
172  virtual TGDimension GetDefaultSize() const
173  { return TGDimension(fWidth, GetScrollBarWidth()); }
174  virtual void Layout();
175 
176  virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
177  virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
178  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
179 
180  ClassDef(TGHScrollBar,0) // Horizontal scrollbar widget
181 };
182 
183 
184 
185 class TGVScrollBar : public TGScrollBar {
186 
187 public:
188  TGVScrollBar(const TGWindow *p = 0, UInt_t w = 2, UInt_t h = 4,
189  UInt_t options = kVerticalFrame,
191  virtual ~TGVScrollBar() { }
192 
193  virtual Bool_t HandleButton(Event_t *event);
194  virtual Bool_t HandleMotion(Event_t *event);
195  virtual TGDimension GetDefaultSize() const
196  { return TGDimension(GetScrollBarWidth(), fHeight); }
197  virtual void Layout();
198 
199  virtual void SetRange(Int_t range, Int_t page_size); //*MENU*
200  virtual void SetPosition(Int_t pos); //*MENU* *GETTER=GetPosition
201  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
202 
203  ClassDef(TGVScrollBar,0) // Vertical scrollbar widget
204 };
205 
206 #endif
TGScrollBarElement * fTail
Definition: TGScrollBar.h:100
virtual Int_t GetSmallIncrement()
Definition: TGScrollBar.h:154
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
Pixel_t fHighColor
Definition: TGScrollBar.h:108
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
TGScrollBarElement * fSlider
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: TGFrame.cxx:611
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGScrollBar.h:137
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:135
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:75
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 Int_t GetPosition() const
Definition: TGScrollBar.h:134
TH1 * h
Definition: legend2.C:5
virtual void Resize(TGDimension size)
Resize the frame.
Definition: TGScrollBar.h:140
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
TGScrollBarElement * fHead
Definition: TGScrollBar.h:99
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:131
virtual ~TGVScrollBar()
Definition: TGScrollBar.h:191
virtual void MapSubwindows()
Definition: TGWindow.h:91
EScrollBarMode
Definition: TGScrollBar.h:42
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:103
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:138
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.
TGScrollBarElement * GetTail() const
Definition: TGScrollBar.h:147
virtual ~TGHScrollBar()
Definition: TGScrollBar.h:168
virtual void DrawBorder()
Draw border around scollbar element.
Int_t fPsize
Definition: TGScrollBar.h:94
Bool_t fGrabPointer
Definition: TGScrollBar.h:92
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:122
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
const TGPicture * fHeadPic
Definition: TGScrollBar.h:102
TGScrollBarElement * GetSlider() const
Definition: TGScrollBar.h:148
Bool_t fDragging
Definition: TGScrollBar.h:91
TGScrollBar(const TGScrollBar &)
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:155
const TGPicture * fPicN
Definition: TGScrollBar.h:59
virtual void MapSubwindows()
Definition: TGScrollBar.h:145
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
UInt_t fHeight
Definition: TGDimension.h:32
char * out
Definition: TBase64.cxx:29
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
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:111
virtual void SetRange(Int_t range, Int_t page_size)=0
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
TThread * t[5]
Definition: threadsh1.C:13
UInt_t fWidth
Definition: TGDimension.h:31
virtual Bool_t HandleMotion(Event_t *event)=0
Int_t fRange
Definition: TGScrollBar.h:93
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:195
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:152
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:110
Int_t fSliderRange
Definition: TGScrollBar.h:97
unsigned int UInt_t
Definition: RtypesCore.h:42
TMarker * m
Definition: textangle.C:8
Bool_t fAccelerated
Definition: TGScrollBar.h:106
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:151
tuple w
Definition: qtexample.py:51
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
TTimer * fRepeat
Definition: TGScrollBar.h:104
TGScrollBarElement(const TGScrollBarElement &)
const TGPicture * fPic
Definition: TGScrollBar.h:58
Int_t fPos
Definition: TGScrollBar.h:95
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:143
UInt_t fWidth
Definition: TGFrame.h:150
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:142
Double_t y[n]
Definition: legend1.C:17
virtual void SetPosition(Int_t pos)=0
Int_t fSmallInc
Definition: TGScrollBar.h:98
TGScrollBarElement * GetHead() const
Definition: TGScrollBar.h:146
UInt_t fHeight
Definition: TGFrame.h:151
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGScrollBar.h:172
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:30
const int increment
Int_t fSliderSize
Definition: TGScrollBar.h:96
virtual Bool_t HandleButton(Event_t *event)=0
Handle_t Pixmap_t
Definition: GuiTypes.h:31
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:150
TGScrollBar & operator=(const TGScrollBar &)
virtual void ChangeBackground(Pixel_t back)
Change background color.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
const TGPicture * fPicD
Definition: TGScrollBar.h:60
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Int_t GetRange() const
Definition: TGScrollBar.h:136
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
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:124
Window_t fSubw
Definition: TGScrollBar.h:105
Pixel_t fBgndColor
Definition: TGScrollBar.h:107