#ifndef ROOT_TGDoubleSlider
#define ROOT_TGDoubleSlider
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGWidget
#include "TGWidget.h"
#endif
class TGPicture;
enum EDoubleSliderSize {
kDoubleSliderWidth = 24,
kDoubleSliderHeight = kDoubleSliderWidth
};
enum EDoubleSliderScale {
kDoubleScaleNo = BIT(0),
kDoubleScaleDownRight = BIT(1),
kDoubleScaleBoth = BIT(2)
};
class TGDoubleSlider : public TGFrame, public TGWidget {
private:
TGDoubleSlider(const TGDoubleSlider&);
TGDoubleSlider& operator=(const TGDoubleSlider&);
protected:
Float_t fPos;
Float_t fSmin;
Float_t fSmax;
Int_t fRelPos;
Float_t fVmin;
Float_t fVmax;
Int_t fScale;
Int_t fScaleType;
Int_t fPressPoint;
Float_t fPressSmin;
Float_t fPressSmax;
Int_t fMove;
Bool_t fReversedScale;
Bool_t fMarkEnds;
const TGPicture *fSliderPic;
TString GetSString() const;
static void FixBounds(Float_t &min, Float_t &max);
void ChangeCursor(Event_t *event);
public:
TGDoubleSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
UInt_t options = kChildFrame,
Pixel_t back = GetDefaultFrameBackground(),
Bool_t reversed = kFALSE,
Bool_t mark_ends = kFALSE);
virtual ~TGDoubleSlider() { }
virtual Bool_t HandleButton(Event_t *event) = 0;
virtual Bool_t HandleMotion(Event_t *event) = 0;
virtual void SetScale(Int_t scale) { fScale = scale; }
virtual void SetRange(Float_t min, Float_t max) {
fVmin = min; fVmax = max;
FixBounds(fVmin, fVmax);
}
virtual void SetPosition(Float_t min, Float_t max) {
if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
else { fSmin = min; fSmax = max; }
fClient->NeedRedraw(this);
}
virtual Float_t GetMinPosition() const {
if (fReversedScale) return fVmin+fVmax-fSmax;
else return fSmin;
}
virtual Float_t GetMaxPosition() const {
if (fReversedScale) return fVmin+fVmax-fSmin;
else return fSmax;
}
virtual void GetPosition(Float_t &min, Float_t &max) const {
if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
else { min = fSmin; max = fSmax; }
}
virtual void GetPosition(Float_t *min, Float_t *max) const {
if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
else { *min = fSmin; *max = fSmax; }
}
virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
virtual void PositionChanged() { Emit("PositionChanged()"); }
virtual void Pressed() { Emit("Pressed()"); }
virtual void Released() { Emit("Released()"); }
ClassDef(TGDoubleSlider,0)
};
class TGDoubleVSlider : public TGDoubleSlider {
protected:
Int_t fYp;
virtual void DoRedraw();
public:
TGDoubleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
UInt_t options = kVerticalFrame,
Pixel_t back = GetDefaultFrameBackground(),
Bool_t reversed = kFALSE,
Bool_t mark_ends = kFALSE);
virtual ~TGDoubleVSlider();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(kDoubleSliderWidth, fHeight); }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGDoubleVSlider,0)
};
class TGDoubleHSlider : public TGDoubleSlider {
protected:
Int_t fXp;
virtual void DoRedraw();
public:
TGDoubleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
UInt_t options = kHorizontalFrame,
Pixel_t back = GetDefaultFrameBackground(),
Bool_t reversed = kFALSE,
Bool_t mark_ends = kFALSE);
virtual ~TGDoubleHSlider();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fWidth, kDoubleSliderHeight); }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGDoubleHSlider,0)
};
#endif