00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGScrollBar
00013 #define ROOT_TGScrollBar
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef ROOT_TGButton
00036 #include "TGButton.h"
00037 #endif
00038
00039
00040
00041
00042 enum EScrollBarMode {
00043 kSBHorizontal,
00044 kSBVertical
00045 };
00046
00047 class TTimer;
00048
00049
00050 class TGScrollBarElement : public TGFrame {
00051
00052 private:
00053 TGScrollBarElement(const TGScrollBarElement&);
00054 TGScrollBarElement& operator=(const TGScrollBarElement&);
00055
00056 protected:
00057 Int_t fState;
00058 const TGPicture *fPic;
00059 const TGPicture *fPicN;
00060 const TGPicture *fPicD;
00061
00062 public:
00063 TGScrollBarElement(const TGWindow *p = 0, const TGPicture *pic = 0,
00064 UInt_t w = 1, UInt_t h = 1,
00065 UInt_t options = kRaisedFrame | kDoubleBorder,
00066 Pixel_t back = GetDefaultFrameBackground());
00067 virtual ~TGScrollBarElement();
00068
00069 virtual void SetState(Int_t state);
00070 virtual void DrawBorder();
00071 virtual void SetEnabled(Bool_t on = kTRUE);
00072 virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
00073
00074 ClassDef(TGScrollBarElement,0)
00075 };
00076
00077
00078 class TGScrollBar : public TGFrame, public TGWidget {
00079
00080 private:
00081 TGScrollBar(const TGScrollBar&);
00082 TGScrollBar& operator=(const TGScrollBar&);
00083
00084 protected:
00085 Int_t fX0, fY0;
00086 Int_t fXp, fYp;
00087 Bool_t fDragging;
00088 Bool_t fGrabPointer;
00089 Int_t fRange;
00090 Int_t fPsize;
00091 Int_t fPos;
00092 Int_t fSliderSize;
00093 Int_t fSliderRange;
00094 Int_t fSmallInc;
00095 TGScrollBarElement *fHead;
00096 TGScrollBarElement *fTail;
00097 TGScrollBarElement *fSlider;
00098 const TGPicture *fHeadPic;
00099 const TGPicture *fTailPic;
00100 TTimer *fRepeat;
00101 Window_t fSubw;
00102 Bool_t fAccelerated;
00103
00104 static Pixmap_t fgBckgndPixmap;
00105 static Int_t fgScrollBarWidth;
00106
00107 public:
00108 static Pixmap_t GetBckgndPixmap();
00109 static Int_t GetScrollBarWidth();
00110
00111 TGScrollBar(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00112 UInt_t options = kChildFrame,
00113 Pixel_t back = GetDefaultFrameBackground());
00114 virtual ~TGScrollBar();
00115
00116 void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
00117
00118 virtual void DrawBorder() { }
00119 virtual Bool_t HandleButton(Event_t *event) = 0;
00120 virtual Bool_t HandleMotion(Event_t *event) = 0;
00121 virtual Bool_t HandleTimer(TTimer *t);
00122 virtual void Layout() = 0;
00123
00124 virtual void SetRange(Int_t range, Int_t page_size) = 0;
00125 virtual void SetPosition(Int_t pos) = 0;
00126 virtual Int_t GetPosition() const { return fPos; }
00127 virtual Int_t GetPageSize() const { return fPsize; }
00128 virtual Int_t GetRange() const { return fRange; }
00129 virtual void Resize(UInt_t w = 0, UInt_t h = 0) { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
00130 virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0)
00131 { TGFrame::MoveResize(x, y, w, h); SetRange(fRange, fPsize); }
00132 virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
00133 virtual void ChangeBackground(Pixel_t back);
00134 virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
00135 Bool_t IsAccelerated() const { return fAccelerated; }
00136
00137 virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
00138 TGScrollBarElement *GetHead() const { return fHead; }
00139 TGScrollBarElement *GetTail() const { return fTail; }
00140 TGScrollBarElement *GetSlider() const { return fSlider; }
00141
00142 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); }
00143 virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); }
00144 virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); }
00145
00146 virtual Int_t GetSmallIncrement() { return fSmallInc; }
00147 virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
00148
00149 ClassDef(TGScrollBar,0)
00150 };
00151
00152
00153
00154 class TGHScrollBar : public TGScrollBar {
00155
00156 public:
00157 TGHScrollBar(const TGWindow *p = 0, UInt_t w = 4, UInt_t h = 2,
00158 UInt_t options = kHorizontalFrame,
00159 Pixel_t back = GetDefaultFrameBackground());
00160 virtual ~TGHScrollBar() { }
00161
00162 virtual Bool_t HandleButton(Event_t *event);
00163 virtual Bool_t HandleMotion(Event_t *event);
00164 virtual TGDimension GetDefaultSize() const
00165 { return TGDimension(fWidth, GetScrollBarWidth()); }
00166 virtual void Layout();
00167
00168 virtual void SetRange(Int_t range, Int_t page_size);
00169 virtual void SetPosition(Int_t pos);
00170 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00171
00172 ClassDef(TGHScrollBar,0)
00173 };
00174
00175
00176
00177 class TGVScrollBar : public TGScrollBar {
00178
00179 public:
00180 TGVScrollBar(const TGWindow *p = 0, UInt_t w = 2, UInt_t h = 4,
00181 UInt_t options = kVerticalFrame,
00182 Pixel_t back = GetDefaultFrameBackground());
00183 virtual ~TGVScrollBar() { }
00184
00185 virtual Bool_t HandleButton(Event_t *event);
00186 virtual Bool_t HandleMotion(Event_t *event);
00187 virtual TGDimension GetDefaultSize() const
00188 { return TGDimension(GetScrollBarWidth(), fHeight); }
00189 virtual void Layout();
00190
00191 virtual void SetRange(Int_t range, Int_t page_size);
00192 virtual void SetPosition(Int_t pos);
00193 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00194
00195 ClassDef(TGVScrollBar,0)
00196 };
00197
00198 #endif