00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGSlider
00013 #define ROOT_TGSlider
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef ROOT_TGFrame
00043 #include "TGFrame.h"
00044 #endif
00045 #ifndef ROOT_TGWidget
00046 #include "TGWidget.h"
00047 #endif
00048
00049
00050
00051
00052 enum ESliderSize {
00053 kSliderWidth = 24,
00054 kSliderHeight = kSliderWidth
00055 };
00056
00057
00058 enum ESliderType {
00059
00060 kSlider1 = BIT(0),
00061 kSlider2 = BIT(1),
00062
00063
00064 kScaleNo = BIT(2),
00065 kScaleDownRight = BIT(3),
00066 kScaleBoth = BIT(4)
00067 };
00068
00069
00070 class TGSlider : public TGFrame, public TGWidget {
00071
00072 protected:
00073 Int_t fPos;
00074 Int_t fRelPos;
00075 Int_t fVmin;
00076 Int_t fVmax;
00077 Int_t fType;
00078 Int_t fScale;
00079 Bool_t fDragging;
00080 const TGPicture *fSliderPic;
00081 const TGPicture *fDisabledPic;
00082
00083 TString GetTypeString() const;
00084 virtual void CreateDisabledPicture();
00085
00086 private:
00087 TGSlider(const TGSlider&);
00088 TGSlider& operator=(const TGSlider&);
00089
00090 public:
00091 TGSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00092 UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
00093 UInt_t options = kChildFrame,
00094 Pixel_t back = GetDefaultFrameBackground());
00095
00096 virtual ~TGSlider() { }
00097
00098 virtual Bool_t HandleButton(Event_t *event) = 0;
00099 virtual Bool_t HandleConfigureNotify(Event_t* event) = 0;
00100 virtual Bool_t HandleMotion(Event_t *event) = 0;
00101
00102 virtual void SetEnabled(Bool_t flag = kTRUE) { SetState( flag ); }
00103 virtual void SetState(Bool_t state);
00104 virtual void SetScale(Int_t scale) { fScale = scale; }
00105 virtual void SetRange(Int_t min, Int_t max) { fVmin = min; fVmax = max; }
00106 virtual void SetPosition(Int_t pos) { fPos = pos; fClient->NeedRedraw(this); }
00107 virtual Int_t GetPosition() const { return fPos; }
00108 virtual Int_t GetMinPosition() const { return fVmin; }
00109 virtual Int_t GetMaxPosition() const { return fVmax; }
00110 virtual Int_t GetScale() const { return fScale; }
00111 virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
00112 virtual void ChangeSliderPic(const char *name) {
00113 if (fSliderPic) fClient->FreePicture(fSliderPic);
00114 fSliderPic = fClient->GetPicture(name);
00115 }
00116
00117 virtual void PositionChanged(Int_t pos) { Emit("PositionChanged(Int_t)", pos); }
00118 virtual void Pressed() { Emit("Pressed()"); }
00119 virtual void Released() { Emit("Released()"); }
00120
00121 ClassDef(TGSlider,0)
00122 };
00123
00124
00125 class TGVSlider : public TGSlider {
00126
00127 protected:
00128 Int_t fYp;
00129
00130 virtual void DoRedraw();
00131
00132 public:
00133 TGVSlider(const TGWindow *p = 0, UInt_t h = 40,
00134 UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
00135 UInt_t options = kVerticalFrame,
00136 Pixel_t back = GetDefaultFrameBackground());
00137 virtual ~TGVSlider();
00138
00139 virtual Bool_t HandleButton(Event_t *event);
00140 virtual Bool_t HandleConfigureNotify(Event_t* event);
00141 virtual Bool_t HandleMotion(Event_t *event);
00142 virtual TGDimension GetDefaultSize() const
00143 { return TGDimension(kSliderWidth, fHeight); }
00144 virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w, h ? h+16 : fHeight + 16); }
00145 virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
00146 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00147
00148 ClassDef(TGVSlider,0)
00149 };
00150
00151
00152 class TGHSlider : public TGSlider {
00153
00154 protected:
00155 Int_t fXp;
00156
00157 virtual void DoRedraw();
00158
00159 public:
00160 TGHSlider(const TGWindow *p = 0, UInt_t w = 40,
00161 UInt_t type = kSlider1 | kScaleBoth, Int_t id = -1,
00162 UInt_t options = kHorizontalFrame,
00163 Pixel_t back = GetDefaultFrameBackground());
00164 virtual ~TGHSlider();
00165
00166 virtual Bool_t HandleButton(Event_t *event);
00167 virtual Bool_t HandleConfigureNotify(Event_t* event);
00168 virtual Bool_t HandleMotion(Event_t *event);
00169 virtual TGDimension GetDefaultSize() const
00170 { return TGDimension(fWidth, kSliderHeight); }
00171 virtual void Resize(UInt_t w, UInt_t h) { TGFrame::Resize(w ? w+16 : fWidth + 16, h); }
00172 virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
00173 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00174
00175 ClassDef(TGHSlider,0)
00176 };
00177
00178 #endif