00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGDoubleSlider
00013 #define ROOT_TGDoubleSlider
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
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef ROOT_TGFrame
00053 #include "TGFrame.h"
00054 #endif
00055 #ifndef ROOT_TGWidget
00056 #include "TGWidget.h"
00057 #endif
00058
00059 class TGPicture;
00060
00061 enum EDoubleSliderSize {
00062
00063 kDoubleSliderWidth = 24,
00064 kDoubleSliderHeight = kDoubleSliderWidth
00065 };
00066
00067
00068 enum EDoubleSliderScale {
00069
00070 kDoubleScaleNo = BIT(0),
00071 kDoubleScaleDownRight = BIT(1),
00072 kDoubleScaleBoth = BIT(2)
00073 };
00074
00075
00076 class TGDoubleSlider : public TGFrame, public TGWidget {
00077
00078 private:
00079 TGDoubleSlider(const TGDoubleSlider&);
00080 TGDoubleSlider& operator=(const TGDoubleSlider&);
00081
00082 protected:
00083 Float_t fPos;
00084 Float_t fSmin;
00085 Float_t fSmax;
00086 Int_t fRelPos;
00087 Float_t fVmin;
00088 Float_t fVmax;
00089 Int_t fScale;
00090 Int_t fScaleType;
00091 Int_t fPressPoint;
00092 Float_t fPressSmin;
00093 Float_t fPressSmax;
00094 Int_t fMove;
00095
00096
00097
00098 Bool_t fReversedScale;
00099 Bool_t fMarkEnds;
00100 const TGPicture *fSliderPic;
00101
00102 TString GetSString() const;
00103
00104 static void FixBounds(Float_t &min, Float_t &max);
00105 void ChangeCursor(Event_t *event);
00106
00107 public:
00108 TGDoubleSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
00109 UInt_t options = kChildFrame,
00110 Pixel_t back = GetDefaultFrameBackground(),
00111 Bool_t reversed = kFALSE,
00112 Bool_t mark_ends = kFALSE);
00113
00114 virtual ~TGDoubleSlider() { }
00115
00116 virtual Bool_t HandleButton(Event_t *event) = 0;
00117 virtual Bool_t HandleMotion(Event_t *event) = 0;
00118
00119 virtual void SetScale(Int_t scale) { fScale = scale; }
00120 virtual void SetRange(Float_t min, Float_t max) {
00121 fVmin = min; fVmax = max;
00122 FixBounds(fVmin, fVmax);
00123 }
00124
00125 virtual void SetPosition(Float_t min, Float_t max) {
00126 if (fReversedScale) { fSmin = fVmin+fVmax-max; fSmax = fVmin+fVmax-min; }
00127 else { fSmin = min; fSmax = max; }
00128 fClient->NeedRedraw(this);
00129 }
00130
00131 virtual Float_t GetMinPosition() const {
00132 if (fReversedScale) return fVmin+fVmax-fSmax;
00133 else return fSmin;
00134 }
00135 virtual Float_t GetMaxPosition() const {
00136 if (fReversedScale) return fVmin+fVmax-fSmin;
00137 else return fSmax;
00138 }
00139 virtual void GetPosition(Float_t &min, Float_t &max) const {
00140 if (fReversedScale) { min = fVmin+fVmax-fSmax; max = fVmin+fVmax-fSmin; }
00141 else { min = fSmin; max = fSmax; }
00142 }
00143 virtual void GetPosition(Float_t *min, Float_t *max) const {
00144 if (fReversedScale) { *min = fVmin+fVmax-fSmax; *max = fVmin+fVmax-fSmin; }
00145 else { *min = fSmin; *max = fSmax; }
00146 }
00147
00148 virtual void MapSubwindows() { TGWindow::MapSubwindows(); }
00149
00150 virtual void PositionChanged() { Emit("PositionChanged()"); }
00151 virtual void Pressed() { Emit("Pressed()"); }
00152 virtual void Released() { Emit("Released()"); }
00153
00154 ClassDef(TGDoubleSlider,0)
00155 };
00156
00157
00158 class TGDoubleVSlider : public TGDoubleSlider {
00159
00160 protected:
00161 Int_t fYp;
00162
00163 virtual void DoRedraw();
00164
00165 public:
00166 TGDoubleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
00167 UInt_t options = kVerticalFrame,
00168 Pixel_t back = GetDefaultFrameBackground(),
00169 Bool_t reversed = kFALSE,
00170 Bool_t mark_ends = kFALSE);
00171
00172 virtual ~TGDoubleVSlider();
00173
00174 virtual Bool_t HandleButton(Event_t *event);
00175 virtual Bool_t HandleMotion(Event_t *event);
00176 virtual TGDimension GetDefaultSize() const
00177 { return TGDimension(kDoubleSliderWidth, fHeight); }
00178 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00179
00180 ClassDef(TGDoubleVSlider,0)
00181 };
00182
00183
00184 class TGDoubleHSlider : public TGDoubleSlider {
00185
00186 protected:
00187 Int_t fXp;
00188
00189 virtual void DoRedraw();
00190
00191 public:
00192 TGDoubleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
00193 UInt_t options = kHorizontalFrame,
00194 Pixel_t back = GetDefaultFrameBackground(),
00195 Bool_t reversed = kFALSE,
00196 Bool_t mark_ends = kFALSE);
00197
00198 virtual ~TGDoubleHSlider();
00199
00200 virtual Bool_t HandleButton(Event_t *event);
00201 virtual Bool_t HandleMotion(Event_t *event);
00202 virtual TGDimension GetDefaultSize() const
00203 { return TGDimension(fWidth, kDoubleSliderHeight); }
00204 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00205
00206 ClassDef(TGDoubleHSlider,0)
00207 };
00208
00209 #endif