00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TGNumberEntry
00014 #define ROOT_TGNumberEntry
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_TGFrame
00027 #include "TGFrame.h"
00028 #endif
00029 #ifndef ROOT_TGTextEntry
00030 #include "TGTextEntry.h"
00031 #endif
00032 #ifndef ROOT_TGButton
00033 #include "TGButton.h"
00034 #endif
00035
00036
00037 class TGNumberFormat {
00038 public:
00039 enum EStyle {
00040 kNESInteger = 0,
00041 kNESRealOne = 1,
00042 kNESRealTwo = 2,
00043 kNESRealThree = 3,
00044 kNESRealFour = 4,
00045 kNESReal = 5,
00046 kNESDegree = 6,
00047 kNESMinSec = 7,
00048 kNESHourMin = 8,
00049 kNESHourMinSec = 9,
00050 kNESDayMYear = 10,
00051 kNESMDayYear = 11,
00052 kNESHex = 12
00053 };
00054
00055 enum EAttribute {
00056 kNEAAnyNumber = 0,
00057 kNEANonNegative = 1,
00058 kNEAPositive = 2
00059 };
00060
00061 enum ELimit {
00062 kNELNoLimits = 0,
00063 kNELLimitMin = 1,
00064 kNELLimitMax = 2,
00065 kNELLimitMinMax = 3
00066 };
00067
00068 enum EStepSize {
00069 kNSSSmall = 0,
00070 kNSSMedium = 1,
00071 kNSSLarge = 2,
00072 kNSSHuge = 3
00073 };
00074
00075 virtual ~TGNumberFormat() { }
00076 ClassDef(TGNumberFormat,0)
00077 };
00078
00079
00080 class TGNumberEntryField : public TGTextEntry, public TGNumberFormat {
00081
00082 protected:
00083 Bool_t fNeedsVerification;
00084 EStyle fNumStyle;
00085 EAttribute fNumAttr;
00086 ELimit fNumLimits;
00087 Double_t fNumMin;
00088 Double_t fNumMax;
00089 Bool_t fStepLog;
00090
00091 public:
00092 TGNumberEntryField(const TGWindow *p, Int_t id,
00093 Double_t val, GContext_t norm,
00094 FontStruct_t font = GetDefaultFontStruct(),
00095 UInt_t option = kSunkenFrame | kDoubleBorder,
00096 Pixel_t back = GetWhitePixel());
00097 TGNumberEntryField(const TGWindow *parent = 0,
00098 Int_t id = -1, Double_t val = 0,
00099 EStyle style = kNESReal,
00100 EAttribute attr = kNEAAnyNumber,
00101 ELimit limits = kNELNoLimits,
00102 Double_t min = 0, Double_t max = 1);
00103
00104 virtual void SetNumber(Double_t val);
00105 virtual void SetIntNumber(Long_t val);
00106 virtual void SetTime(Int_t hour, Int_t min, Int_t sec);
00107 virtual void SetDate(Int_t year, Int_t month, Int_t day);
00108 virtual void SetHexNumber(ULong_t val);
00109 virtual void SetText(const char* text, Bool_t emit = kTRUE);
00110
00111 virtual Double_t GetNumber() const;
00112 virtual Long_t GetIntNumber() const;
00113 virtual void GetTime(Int_t& hour, Int_t& min, Int_t& sec) const;
00114 virtual void GetDate(Int_t& year, Int_t& month, Int_t& day) const;
00115 virtual ULong_t GetHexNumber() const;
00116
00117 virtual Int_t GetCharWidth(const char* text = "0") const;
00118 virtual void IncreaseNumber(EStepSize step = kNSSSmall,
00119 Int_t sign = 1, Bool_t logstep = kFALSE);
00120 virtual void SetFormat(EStyle style,
00121 EAttribute attr = kNEAAnyNumber);
00122 virtual void SetLimits(ELimit limits = kNELNoLimits,
00123 Double_t min = 0, Double_t max = 1);
00124 virtual void SetState(Bool_t state);
00125 virtual void SetLogStep(Bool_t on = kTRUE) {
00126
00127 fStepLog = on; }
00128
00129 virtual EStyle GetNumStyle() const {
00130
00131 return fNumStyle; }
00132 virtual EAttribute GetNumAttr() const {
00133
00134 return fNumAttr; }
00135 virtual ELimit GetNumLimits() const {
00136
00137 return fNumLimits; }
00138 virtual Double_t GetNumMin() const {
00139
00140 return fNumMin; }
00141 virtual Double_t GetNumMax() const {
00142
00143 return fNumMax; }
00144 virtual Bool_t IsLogStep() const {
00145
00146 return fStepLog; }
00147
00148 virtual Bool_t HandleKey(Event_t* event);
00149 virtual Bool_t HandleFocusChange (Event_t* event);
00150 virtual void TextChanged(const char *text = 0);
00151 virtual void ReturnPressed();
00152 virtual void Layout();
00153 virtual Bool_t IsEditable() const { return kFALSE; }
00154 virtual void InvalidInput(const char *instr) { Emit("InvalidInput(char*)", instr); }
00155 virtual void SavePrimitive(ostream &out, Option_t * = "");
00156
00157 ClassDef(TGNumberEntryField,0)
00158 };
00159
00160
00161
00162 class TGNumberEntry : public TGCompositeFrame, public TGWidget,
00163 public TGNumberFormat {
00164
00165
00166 EStyle fNumStyle;
00167 EAttribute fNumAttr;
00168 ELimit fNumLimits;
00169
00170 private:
00171 const TGPicture *fPicUp;
00172 const TGPicture *fPicDown;
00173
00174 TGNumberEntry(const TGNumberEntry&);
00175 TGNumberEntry& operator=(const TGNumberEntry&);
00176
00177 protected:
00178 TGNumberEntryField *fNumericEntry;
00179 TGButton *fButtonUp;
00180 TGButton *fButtonDown;
00181 Bool_t fButtonToNum;
00182
00183 public:
00184 TGNumberEntry(const TGWindow *parent = 0, Double_t val = 0,
00185 Int_t digitwidth = 5, Int_t id = -1,
00186 EStyle style = kNESReal,
00187 EAttribute attr = kNEAAnyNumber,
00188 ELimit limits = kNELNoLimits,
00189 Double_t min = 0, Double_t max = 1);
00190 virtual ~TGNumberEntry();
00191
00192 virtual void SetNumber(Double_t val) {
00193
00194 fNumericEntry->SetNumber(val); }
00195 virtual void SetIntNumber(Long_t val) {
00196
00197 fNumericEntry->SetIntNumber(val); }
00198 virtual void SetTime(Int_t hour, Int_t min, Int_t sec) {
00199
00200 fNumericEntry->SetTime(hour, min, sec); }
00201 virtual void SetDate(Int_t year, Int_t month, Int_t day) {
00202
00203 fNumericEntry->SetDate(year, month, day); }
00204 virtual void SetHexNumber(ULong_t val) {
00205
00206 fNumericEntry->SetHexNumber(val); }
00207 virtual void SetText(const char* text) {
00208
00209 fNumericEntry->SetText(text); }
00210 virtual void SetState(Bool_t enable = kTRUE);
00211
00212 virtual Double_t GetNumber() const {
00213
00214 return fNumericEntry->GetNumber(); }
00215 virtual Long_t GetIntNumber() const {
00216
00217 return fNumericEntry->GetIntNumber (); }
00218 virtual void GetTime(Int_t& hour, Int_t& min, Int_t& sec) const {
00219
00220 fNumericEntry->GetTime(hour, min, sec); }
00221 virtual void GetDate(Int_t& year, Int_t& month, Int_t& day) const {
00222
00223 fNumericEntry->GetDate(year, month, day); }
00224 virtual ULong_t GetHexNumber() const {
00225
00226 return fNumericEntry->GetHexNumber(); }
00227 virtual void IncreaseNumber(EStepSize step = kNSSSmall,
00228 Int_t sign = 1, Bool_t logstep = kFALSE) {
00229
00230 fNumericEntry->IncreaseNumber(step, sign, logstep); }
00231 virtual void SetFormat(EStyle style, EAttribute attr = TGNumberFormat::kNEAAnyNumber) {
00232
00233 fNumericEntry->SetFormat(style, attr); }
00234 virtual void SetLimits(ELimit limits = TGNumberFormat::kNELNoLimits,
00235 Double_t min = 0, Double_t max = 1) {
00236
00237 fNumericEntry->SetLimits(limits, min, max); }
00238
00239 virtual EStyle GetNumStyle() const {
00240
00241 return fNumericEntry->GetNumStyle(); }
00242 virtual EAttribute GetNumAttr() const {
00243
00244 return fNumericEntry->GetNumAttr(); }
00245 virtual ELimit GetNumLimits() const {
00246
00247 return fNumericEntry->GetNumLimits(); }
00248 virtual Double_t GetNumMin() const {
00249
00250 return fNumericEntry->GetNumMin(); }
00251 virtual Double_t GetNumMax() const {
00252
00253 return fNumericEntry->GetNumMax(); }
00254 virtual Bool_t IsLogStep() const {
00255
00256 return fNumericEntry->IsLogStep(); }
00257 virtual void SetButtonToNum(Bool_t state);
00258
00259 void SetNumStyle(EStyle style) {
00260 SetFormat(style, GetNumAttr()); }
00261 void SetNumAttr(EAttribute attr = kNEAAnyNumber) {
00262 SetFormat(GetNumStyle(), attr); }
00263 void SetNumLimits(ELimit limits = kNELNoLimits) {
00264 SetLimits(limits, GetNumMin(), GetNumMax()); }
00265 void SetLimitValues(Double_t min = 0, Double_t max = 1) {
00266 SetLimits(GetNumLimits(), min, max); }
00267 virtual void SetLogStep(Bool_t on = kTRUE);
00268
00269 virtual void Associate(const TGWindow *w);
00270 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00271 virtual void ValueChanged(Long_t val);
00272 virtual void ValueSet(Long_t val);
00273
00274 TGNumberEntryField *GetNumberEntry() const {
00275
00276 return fNumericEntry; }
00277 TGButton *GetButtonUp() const {
00278
00279 return fButtonUp; }
00280 TGButton *GetButtonDown() const {
00281
00282 return fButtonDown; }
00283
00284 virtual Bool_t IsEditable() const { return kFALSE; }
00285
00286 UInt_t GetDefaultHeight() const { return fNumericEntry->GetDefaultHeight(); }
00287 virtual void SavePrimitive(ostream &out, Option_t * = "");
00288 virtual TGLayoutManager *GetLayoutManager() const;
00289
00290 ClassDef(TGNumberEntry,0)
00291 };
00292
00293
00294 class TGNumberEntryLayout : public TGLayoutManager {
00295 protected:
00296 TGNumberEntry *fBox;
00297
00298 private:
00299 TGNumberEntryLayout(const TGNumberEntryLayout&);
00300 TGNumberEntryLayout& operator=(const TGNumberEntryLayout&);
00301
00302 public:
00303 TGNumberEntryLayout(TGNumberEntry *box): fBox(box) { }
00304 virtual void Layout();
00305 virtual TGDimension GetDefaultSize() const;
00306
00307 ClassDef(TGNumberEntryLayout,0)
00308 };
00309
00310
00311 #endif