Back to home page

EIC code displayed by LXR

 
 

    


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 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   10/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGScrollBar
0013 #define ROOT_TGScrollBar
0014 
0015 
0016 #include "TGButton.h"
0017 
0018 
0019 //--- scrollbar types
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;      ///< state of scrollbar element (button up or down)
0037    const TGPicture *fPic;        ///< picture in scrollbar element
0038    const TGPicture *fPicN;       ///< picture for normal state of scrollbar element
0039    const TGPicture *fPicD;       ///< picture for disabled state of scrollbar element
0040    Pixel_t          fBgndColor;  ///< background color
0041    Pixel_t          fHighColor;  ///< highlight color
0042    Int_t            fStyle;      ///< modern or classic style
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)  // Scrollbar element (head, tail, slider)
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;      ///< current slider position in pixels
0069    Int_t                fXp, fYp;      ///< previous slider position in pixels
0070    Bool_t               fDragging;     ///< in dragging mode?
0071    Bool_t               fGrabPointer;  ///< grab pointer when dragging
0072    Int_t                fRange;        ///< logical upper range of scrollbar
0073    Int_t                fPsize;        ///< logical page size of scrollbar
0074    Int_t                fPos;          ///< logical current position
0075    Int_t                fSliderSize;   ///< logical slider size
0076    Int_t                fSliderRange;  ///< logical slider range
0077    Int_t                fSmallInc;     ///< Small Increment in the sliding algorithm
0078    TGScrollBarElement  *fHead;         ///< head button of scrollbar
0079    TGScrollBarElement  *fTail;         ///< tail button of scrollbar
0080    TGScrollBarElement  *fSlider;       ///< slider
0081    const TGPicture     *fHeadPic;      ///< picture in head (up or left arrow)
0082    const TGPicture     *fTailPic;      ///< picture in tail (down or right arrow)
0083    TTimer              *fRepeat;       ///< repeat rate timer (when mouse stays pressed)
0084    Window_t             fSubw;         ///< sub window in which mouse is pressed
0085    Bool_t               fAccelerated;  ///< kFALSE - normal, kTRUE - accelerated
0086    Pixel_t              fBgndColor;    ///< background color
0087    Pixel_t              fHighColor;    ///< highlight color
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); } //*SIGNAL*
0131    virtual void  RangeChanged(Int_t range) { Emit("RangeChanged(Int_t)", range); } //*SIGNAL*
0132    virtual void  PageSizeChanged(Int_t range) { Emit("PageSizeChanged(Int_t)", range); } //*SIGNAL*
0133 
0134    virtual Int_t GetSmallIncrement() { return fSmallInc; }
0135    virtual void  SetSmallIncrement(Int_t increment) { fSmallInc = increment; }
0136 
0137    ClassDefOverride(TGScrollBar,0)  // Scrollbar widget
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;  //*MENU*
0157    void SetPosition(Int_t pos) override;                  //*MENU* *GETTER=GetPosition
0158    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0159 
0160    ClassDefOverride(TGHScrollBar,0)  // Horizontal scrollbar widget
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;  //*MENU*
0180    void SetPosition(Int_t pos) override;                  //*MENU*  *GETTER=GetPosition
0181    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0182 
0183    ClassDefOverride(TGVScrollBar,0)  // Vertical scrollbar widget
0184 };
0185 
0186 #endif