Warning, file /include/root/TGScrollBar.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGScrollBar
0013 #define ROOT_TGScrollBar
0014
0015
0016 #include "TGButton.h"
0017
0018
0019
0020
0021 enum EScrollBarMode {
0022 kSBHorizontal,
0023 kSBVertical
0024 };
0025
0026 class TTimer;
0027
0028
0029 class TGScrollBarElement : public TGFrame {
0030
0031 private:
0032 TGScrollBarElement(const TGScrollBarElement&) = delete;
0033 TGScrollBarElement& operator=(const TGScrollBarElement&) = delete;
0034
0035 protected:
0036 Int_t fState;
0037 const TGPicture *fPic;
0038 const TGPicture *fPicN;
0039 const TGPicture *fPicD;
0040 Pixel_t fBgndColor;
0041 Pixel_t fHighColor;
0042 Int_t fStyle;
0043
0044 public:
0045 TGScrollBarElement(const TGWindow *p = nullptr, const TGPicture *pic = nullptr,
0046 UInt_t w = 1, UInt_t h = 1,
0047 UInt_t options = kRaisedFrame | kDoubleBorder,
0048 Pixel_t back = GetDefaultFrameBackground());
0049 ~TGScrollBarElement() override;
0050
0051 virtual void SetState(Int_t state);
0052 void DrawBorder() override;
0053 virtual void SetEnabled(Bool_t on = kTRUE);
0054 virtual Bool_t IsEnabled() const { return !(fState & kButtonDisabled); }
0055 Bool_t HandleCrossing(Event_t *event) override;
0056
0057 ClassDefOverride(TGScrollBarElement,0)
0058 };
0059
0060
0061 class TGScrollBar : public TGFrame, public TGWidget {
0062
0063 private:
0064 TGScrollBar(const TGScrollBar&) = delete;
0065 TGScrollBar& operator=(const TGScrollBar&) = delete;
0066
0067 protected:
0068 Int_t fX0, fY0;
0069 Int_t fXp, fYp;
0070 Bool_t fDragging;
0071 Bool_t fGrabPointer;
0072 Int_t fRange;
0073 Int_t fPsize;
0074 Int_t fPos;
0075 Int_t fSliderSize;
0076 Int_t fSliderRange;
0077 Int_t fSmallInc;
0078 TGScrollBarElement *fHead;
0079 TGScrollBarElement *fTail;
0080 TGScrollBarElement *fSlider;
0081 const TGPicture *fHeadPic;
0082 const TGPicture *fTailPic;
0083 TTimer *fRepeat;
0084 Window_t fSubw;
0085 Bool_t fAccelerated;
0086 Pixel_t fBgndColor;
0087 Pixel_t fHighColor;
0088
0089 static Pixmap_t fgBckgndPixmap;
0090 static Int_t fgScrollBarWidth;
0091
0092 public:
0093 static Pixmap_t GetBckgndPixmap();
0094 static Int_t GetScrollBarWidth();
0095
0096 TGScrollBar(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0097 UInt_t options = kChildFrame,
0098 Pixel_t back = GetDefaultFrameBackground());
0099 ~TGScrollBar() override;
0100
0101 void GrabPointer(Bool_t grab) { fGrabPointer = grab; }
0102
0103 void DrawBorder() override { }
0104 Bool_t HandleButton(Event_t *event) override = 0;
0105 Bool_t HandleCrossing(Event_t *event) override;
0106 Bool_t HandleMotion(Event_t *event) override = 0;
0107 Bool_t HandleTimer(TTimer *t) override;
0108 void Layout() override = 0;
0109
0110 virtual void SetDragging(Bool_t drag) { fDragging = drag; }
0111 virtual void SetRange(Int_t range, Int_t page_size) = 0;
0112 virtual void SetPosition(Int_t pos) = 0;
0113 virtual Int_t GetPosition() const { return fPos; }
0114 virtual Int_t GetPageSize() const { return fPsize; }
0115 virtual Int_t GetRange() const { return fRange; }
0116 void Resize(UInt_t w = 0, UInt_t h = 0) override
0117 { TGFrame::Resize(w, h); SetRange(fRange, fPsize); }
0118 void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0) override
0119 { TGFrame::MoveResize(x, y, w, h); SetRange(fRange, fPsize); }
0120 void Resize(TGDimension size) override { Resize(size.fWidth, size.fHeight); }
0121 void ChangeBackground(Pixel_t back) override;
0122 virtual void SetAccelerated(Bool_t m = kTRUE) { fAccelerated = m; }
0123 Bool_t IsAccelerated() const { return fAccelerated; }
0124
0125 void MapSubwindows() override { TGWindow::MapSubwindows(); }
0126 TGScrollBarElement *GetHead() const { return fHead; }
0127 TGScrollBarElement *GetTail() const { return fTail; }
0128 TGScrollBarElement *GetSlider() const { return fSlider; }
0129
0130 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); }
0131 virtual void RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); }
0132 virtual void PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); }
0133
0134 virtual Int_t GetSmallIncrement() { return fSmallInc; }
0135 virtual void SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
0136
0137 ClassDefOverride(TGScrollBar,0)
0138 };
0139
0140
0141
0142 class TGHScrollBar : public TGScrollBar {
0143
0144 public:
0145 TGHScrollBar(const TGWindow *p = nullptr, UInt_t w = 4, UInt_t h = 2,
0146 UInt_t options = kHorizontalFrame,
0147 Pixel_t back = GetDefaultFrameBackground());
0148 ~TGHScrollBar() override { }
0149
0150 Bool_t HandleButton(Event_t *event) override;
0151 Bool_t HandleMotion(Event_t *event) override;
0152 TGDimension GetDefaultSize() const override
0153 { return TGDimension(fWidth, GetScrollBarWidth()); }
0154 void Layout() override;
0155
0156 void SetRange(Int_t range, Int_t page_size) override;
0157 void SetPosition(Int_t pos) override;
0158 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0159
0160 ClassDefOverride(TGHScrollBar,0)
0161 };
0162
0163
0164
0165 class TGVScrollBar : public TGScrollBar {
0166
0167 public:
0168 TGVScrollBar(const TGWindow *p = nullptr, UInt_t w = 2, UInt_t h = 4,
0169 UInt_t options = kVerticalFrame,
0170 Pixel_t back = GetDefaultFrameBackground());
0171 ~TGVScrollBar() override { }
0172
0173 Bool_t HandleButton(Event_t *event) override;
0174 Bool_t HandleMotion(Event_t *event) override;
0175 TGDimension GetDefaultSize() const override
0176 { return TGDimension(GetScrollBarWidth(), fHeight); }
0177 void Layout() override;
0178
0179 void SetRange(Int_t range, Int_t page_size) override;
0180 void SetPosition(Int_t pos) override;
0181 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0182
0183 ClassDefOverride(TGVScrollBar,0)
0184 };
0185
0186 #endif