Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGDoubleSlider.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: Reiner Rohlfs   30/09/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_TGDoubleSlider
0013 #define ROOT_TGDoubleSlider
0014 
0015 
0016 #include "TGFrame.h"
0017 #include "TGWidget.h"
0018 
0019 class TGPicture;
0020 
0021 enum EDoubleSliderSize {
0022    //--- sizes for vert. and horz. sliders
0023    kDoubleSliderWidth  = 24,
0024    kDoubleSliderHeight = kDoubleSliderWidth
0025 };
0026 
0027 
0028 enum EDoubleSliderScale {
0029    //--- type of slider scale
0030    kDoubleScaleNo        = BIT(0),
0031    kDoubleScaleDownRight = BIT(1),
0032    kDoubleScaleBoth      = BIT(2)
0033 };
0034 
0035 
0036 class TGDoubleSlider : public TGFrame, public TGWidget {
0037 
0038 private:
0039    TGDoubleSlider(const TGDoubleSlider&) = delete;
0040    TGDoubleSlider& operator=(const TGDoubleSlider&) = delete;
0041 
0042 protected:
0043    Double_t      fPos;           ///< logical position between fVmin and fVmax
0044    Double_t      fSmin;          ///< logical position of min value of Slider
0045    Double_t      fSmax;          ///< logical position of max value of Slider
0046    Int_t         fRelPos;        ///< slider position in pixel coordinates
0047    Double_t      fVmin;          ///< logical lower limit of slider
0048    Double_t      fVmax;          ///< logical upper limit of slider
0049    Int_t         fScale;         ///< tick mark scale
0050    Int_t         fScaleType;     ///< tick mark scale type (no, downright, both)
0051    Int_t         fPressPoint;    ///< mouse position at button press event
0052    Double_t      fPressSmin;     ///< logical min position at button press event
0053    Double_t      fPressSmax;     ///< logical max position at button press event
0054    Int_t         fMove;          ///< 1: move min value
0055                                  ///< 2: move max value
0056                                  ///< 3: move min and max value
0057                                  ///< 0: don't move any value
0058    Bool_t        fReversedScale; ///< reverse which end is min and max
0059    Bool_t        fMarkEnds;      ///< lines marking where stretch zones begin
0060    const TGPicture *fSliderPic;  ///< picture to draw slider ends
0061 
0062    TString       GetSString() const; ///< returns scaling type as string
0063 
0064    static void   FixBounds(Double_t &min, Double_t &max);
0065    void          ChangeCursor(Event_t *event);
0066 
0067 public:
0068    TGDoubleSlider(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
0069                   UInt_t options = kChildFrame,
0070                   Pixel_t back = GetDefaultFrameBackground(),
0071                   Bool_t reversed = kFALSE,
0072                   Bool_t mark_ends = kFALSE);
0073 
0074    ~TGDoubleSlider() override { }
0075 
0076    Bool_t HandleButton(Event_t *event) override = 0;
0077    Bool_t HandleMotion(Event_t *event) override = 0;
0078 
0079    virtual void  SetScale(Int_t scale) { fScale = scale; }
0080    virtual void  SetRange(Float_t min, Float_t max) {
0081       SetRange((Double_t) min, (Double_t) max);
0082    }
0083    virtual void  SetRange(Long64_t min, Long64_t max) {
0084       SetRange((Double_t) min, (Double_t) max);
0085    }
0086    virtual void  SetRange(Int_t min, Int_t max) {
0087       SetRange((Double_t) min, (Double_t) max);
0088    }
0089 
0090    virtual void SetPosition(Float_t min, Float_t max) {
0091       SetPosition((Double_t) min, (Double_t) max);
0092    }
0093    virtual void SetPosition(Long64_t min, Long64_t max) {
0094       SetPosition((Double_t) min, (Double_t) max);
0095    }
0096    virtual void SetPosition(Int_t min, Int_t max) {
0097       SetPosition((Double_t) min, (Double_t) max);
0098    }
0099 
0100    virtual Float_t GetMinPosition() const {
0101       return (Float_t) GetMinPositionD();
0102    }
0103    virtual Float_t GetMaxPosition() const {
0104       return (Float_t) GetMaxPositionD();
0105    }
0106    virtual Long64_t GetMinPositionL() const {
0107       return (Long64_t)GetMinPositionD();
0108    }
0109    virtual Long64_t GetMaxPositionL() const {
0110       return (Long64_t)GetMaxPositionD();
0111    }
0112 
0113    virtual void GetPosition(Float_t &min, Float_t &max) const {
0114       if (fReversedScale) { min = (Float_t)(fVmin+fVmax-fSmax); max = (Float_t)(fVmin+fVmax-fSmin); }
0115       else { min = (Float_t)fSmin; max = (Float_t)fSmax; }
0116    }
0117    virtual void GetPosition(Float_t *min, Float_t *max) const {
0118       if (fReversedScale) { *min = (Float_t)(fVmin+fVmax-fSmax); *max = (Float_t)(fVmin+fVmax-fSmin); }
0119       else { *min = (Float_t)fSmin; *max = (Float_t)fSmax; }
0120    }
0121    virtual void GetPosition(Long64_t &min, Long64_t &max) const {
0122       if (fReversedScale) { min = (Long64_t)(fVmin+fVmax-fSmax); max = (Long64_t)(fVmin+fVmax-fSmin); }
0123       else { min = (Long64_t)fSmin; max = (Long64_t)fSmax; }
0124    }
0125    virtual void GetPosition(Long64_t *min, Long64_t *max) const {
0126       if (fReversedScale) { *min = (Long64_t)(fVmin+fVmax-fSmax); *max = (Long64_t)(fVmin+fVmax-fSmin); }
0127       else { *min = (Long64_t)fSmin; *max = (Long64_t)fSmax; }
0128    }
0129 
0130    // double precision methods
0131 
0132    virtual void  SetRange(Double_t min, Double_t max) {
0133       fVmin = min; fVmax = max;
0134       FixBounds(fVmin, fVmax);
0135    }
0136 
0137    virtual void SetPosition(Double_t min, Double_t max) {
0138       if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
0139       else { fSmin = min; fSmax = max; }
0140       fClient->NeedRedraw(this);
0141    }
0142 
0143    virtual Double_t GetMinPositionD() const {
0144       if (fReversedScale) return fVmin+fVmax-fSmax;
0145       else return fSmin;
0146    }
0147    virtual Double_t GetMaxPositionD() const {
0148       if (fReversedScale) return fVmin+fVmax-fSmin;
0149       else return fSmax;
0150    }
0151    virtual void GetPosition(Double_t &min, Double_t &max) const {
0152       if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
0153       else { min = fSmin; max = fSmax; }
0154    }
0155    virtual void GetPosition(Double_t *min, Double_t *max) const {
0156       if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
0157       else { *min = fSmin; *max = fSmax; }
0158    }
0159 
0160    void  MapSubwindows() override { TGWindow::MapSubwindows(); }
0161 
0162    virtual void  PositionChanged() { Emit("PositionChanged()"); } //*SIGNAL*
0163    virtual void  Pressed() { Emit("Pressed()"); }                 //*SIGNAL*
0164    virtual void  Released() { Emit("Released()"); }               //*SIGNAL*
0165 
0166    ClassDefOverride(TGDoubleSlider,0)  // Double slider widget abstract base class
0167 };
0168 
0169 
0170 class TGDoubleVSlider : public TGDoubleSlider {
0171 
0172 protected:
0173    Int_t   fYp;      ///< vertical slider y position in pixel coordinates
0174 
0175    void DoRedraw() override;
0176 
0177 public:
0178    TGDoubleVSlider(const TGWindow *p = nullptr, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
0179                    UInt_t options = kVerticalFrame,
0180                    Pixel_t back = GetDefaultFrameBackground(),
0181                    Bool_t reversed = kFALSE,
0182                    Bool_t mark_ends = kFALSE);
0183 
0184    ~TGDoubleVSlider() override;
0185 
0186    Bool_t HandleButton(Event_t *event) override;
0187    Bool_t HandleMotion(Event_t *event) override;
0188    TGDimension GetDefaultSize() const override
0189                { return TGDimension(kDoubleSliderWidth, fHeight); }
0190    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0191 
0192    ClassDefOverride(TGDoubleVSlider,0)  // Vertical double slider widget
0193 };
0194 
0195 
0196 class TGDoubleHSlider : public TGDoubleSlider {
0197 
0198 protected:
0199    Int_t       fXp;     ///< horizontal slider x position in pixel coordinates
0200 
0201    void DoRedraw() override;
0202 
0203 public:
0204    TGDoubleHSlider(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
0205                    UInt_t options = kHorizontalFrame,
0206                    Pixel_t back = GetDefaultFrameBackground(),
0207                    Bool_t reversed = kFALSE,
0208                    Bool_t mark_ends = kFALSE);
0209 
0210    ~TGDoubleHSlider() override;
0211 
0212    Bool_t HandleButton(Event_t *event) override;
0213    Bool_t HandleMotion(Event_t *event) override;
0214    TGDimension GetDefaultSize() const override
0215                 { return TGDimension(fWidth, kDoubleSliderHeight); }
0216    void   SavePrimitive(std::ostream &out, Option_t *option = "") override;
0217 
0218    ClassDefOverride(TGDoubleHSlider,0)  // Horizontal double slider widget
0219 };
0220 
0221 #endif