#ifndef ROOT_TGScrollBar
#define ROOT_TGScrollBar
#ifndef ROOT_TGButton
#include "TGButton.h"
#endif
enum EScrollBarMode {
kSBHorizontal,
kSBVertical
};
class TTimer;
class TGScrollBarElement : public TGFrame {
private:
TGScrollBarElement(const TGScrollBarElement&);
TGScrollBarElement& operator=(const TGScrollBarElement&);
protected:
Int_t fState;
const TGPicture *fPic;
const TGPicture *fPicN;
const TGPicture *fPicD;
public:
TGScrollBarElement(const TGWindow *p = 0, const TGPicture *pic = 0,
UInt_t w = 1, UInt_t h = 1,
UInt_t options = kRaisedFrame | kDoubleBorder,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGScrollBarElement();
virtual void SetState(Int_t state);
virtual void DrawBorder();
virtual void SetEnabled(Bool_t on = kTRUE);
virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
ClassDef(TGScrollBarElement,0)
};
class TGScrollBar : public TGFrame, public TGWidget {
private:
TGScrollBar(const TGScrollBar&);
TGScrollBar& operator=(const TGScrollBar&);
protected:
Int_t fX0, fY0;
Int_t fXp, fYp;
Bool_t fDragging;
Bool_t fGrabPointer;
Int_t fRange;
Int_t fPsize;
Int_t fPos;
Int_t fSliderSize;
Int_t fSliderRange;
Int_t fSmallInc;
TGScrollBarElement *fHead;
TGScrollBarElement *fTail;
TGScrollBarElement *fSlider;
const TGPicture *fHeadPic;
const TGPicture *fTailPic;
TTimer *fRepeat;
Window_t fSubw;
Bool_t fAccelerated;
static Pixmap_t fgBckgndPixmap;
static Int_t fgScrollBarWidth;
public:
static Pixmap_t GetBckgndPixmap();
static Int_t GetScrollBarWidth();
TGScrollBar(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
UInt_t options = kChildFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGScrollBar();
void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
virtual void DrawBorder() { }
virtual Bool_t HandleButton(Event_t *event) = 0;
virtual Bool_t HandleMotion(Event_t *event) = 0;
virtual Bool_t HandleTimer(TTimer *t);
virtual void Layout() = 0;
virtual void SetRange(Int_t range, Int_t page_size) = 0;
virtual void SetPosition(Int_t pos) = 0;
virtual Int_t GetPosition() const { return fPos; }
virtual Int_t GetPageSize() const { return fPsize; }
virtual Int_t GetRange() const { return fRange; }
virtual void Resize(UInt_t w = 0, UInt_t h = 0) { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0)
{ TGFrame::MoveResize(x, y, w, h); SetRange(fRange, fPsize); }
virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
virtual void ChangeBackground(Pixel_t back);
virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
Bool_t IsAccelerated() const { return fAccelerated; }
virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
TGScrollBarElement *GetHead() const { return fHead; }
TGScrollBarElement *GetTail() const { return fTail; }
TGScrollBarElement *GetSlider() const { return fSlider; }
virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); }
virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); }
virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); }
virtual Int_t GetSmallIncrement() { return fSmallInc; }
virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
ClassDef(TGScrollBar,0)
};
class TGHScrollBar : public TGScrollBar {
public:
TGHScrollBar(const TGWindow *p = 0, UInt_t w = 4, UInt_t h = 2,
UInt_t options = kHorizontalFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGHScrollBar() { }
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fWidth, GetScrollBarWidth()); }
virtual void Layout();
virtual void SetRange(Int_t range, Int_t page_size);
virtual void SetPosition(Int_t pos);
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGHScrollBar,0)
};
class TGVScrollBar : public TGScrollBar {
public:
TGVScrollBar(const TGWindow *p = 0, UInt_t w = 2, UInt_t h = 4,
UInt_t options = kVerticalFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGVScrollBar() { }
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(GetScrollBarWidth(), fHeight); }
virtual void Layout();
virtual void SetRange(Int_t range, Int_t page_size);
virtual void SetPosition(Int_t pos);
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGVScrollBar,0)
};
#endif