#ifndef ROOT_TGSlider
#define ROOT_TGSlider
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGWidget
#include "TGWidget.h"
#endif
enum ESliderSize {
kSliderWidth = 24,
kSliderHeight = kSliderWidth
};
enum ESliderType {
kSlider1 = BIT(0),
kSlider2 = BIT(1),
kScaleNo = BIT(2),
kScaleDownRight = BIT(3),
kScaleBoth = BIT(4)
};
class TGSlider : public TGFrame, public TGWidget {
protected:
Int_t fPos;
Int_t fRelPos;
Int_t fVmin;
Int_t fVmax;
Int_t fType;
Int_t fScale;
Bool_t fDragging;
const TGPicture *fSliderPic;
TString GetTypeString() const;
private:
TGSlider(const TGSlider&);
TGSlider& operator=(const TGSlider&);
public:
TGSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
UInt_t options = kChildFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGSlider() { }
virtual Bool_t HandleButton(Event_t *event) = 0;
virtual Bool_t HandleConfigureNotify(Event_t* event) = 0;
virtual Bool_t HandleMotion(Event_t *event) = 0;
virtual void SetScale(Int_t scale) { fScale = scale; }
virtual void SetRange(Int_t min, Int_t max) { fVmin = min; fVmax = max; }
virtual void SetPosition(Int_t pos) { fPos = pos; fClient->NeedRedraw(this); }
virtual Int_t GetPosition() const { return fPos; }
virtual Int_t GetMinPosition() const { return fVmin; }
virtual Int_t GetMaxPosition() const { return fVmax; }
virtual Int_t GetScale() const { return fScale; }
virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
virtual void ChangeSliderPic(const char *name) {
if (fSliderPic) fClient->FreePicture(fSliderPic);
fSliderPic = fClient->GetPicture(name);
}
virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); }
virtual void Pressed() { Emit("Pressed()"); }
virtual void Released() { Emit("Released()"); }
ClassDef(TGSlider,0)
};
class TGVSlider : public TGSlider {
protected:
Int_t fYp;
virtual void DoRedraw();
public:
TGVSlider(const TGWindow *p = 0, UInt_t h = 40,
UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
UInt_t options = kVerticalFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGVSlider();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleConfigureNotify(Event_t* event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(kSliderWidth, fHeight); }
virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w, h ? h+16 : fHeight + 16); }
virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGVSlider,0)
};
class TGHSlider : public TGSlider {
protected:
Int_t fXp;
virtual void DoRedraw();
public:
TGHSlider(const TGWindow *p = 0, UInt_t w = 40,
UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
UInt_t options = kHorizontalFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGHSlider();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleConfigureNotify(Event_t* event);
virtual Bool_t HandleMotion(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fWidth, kSliderHeight); }
virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w ? w+16 : fWidth + 16, h); }
virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGHSlider,0)
};
#endif