#ifndef ROOT_TGNumberEntry
#define ROOT_TGNumberEntry
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGTextEntry
#include "TGTextEntry.h"
#endif
#ifndef ROOT_TGButton
#include "TGButton.h"
#endif
class TGNumberFormat {
public:
enum EStyle {
kNESInteger = 0,
kNESRealOne = 1,
kNESRealTwo = 2,
kNESRealThree = 3,
kNESRealFour = 4,
kNESReal = 5,
kNESDegree = 6,
kNESMinSec = 7,
kNESHourMin = 8,
kNESHourMinSec = 9,
kNESDayMYear = 10,
kNESMDayYear = 11,
kNESHex = 12
};
enum EAttribute {
kNEAAnyNumber = 0,
kNEANonNegative = 1,
kNEAPositive = 2
};
enum ELimit {
kNELNoLimits = 0,
kNELLimitMin = 1,
kNELLimitMax = 2,
kNELLimitMinMax = 3
};
enum EStepSize {
kNSSSmall = 0,
kNSSMedium = 1,
kNSSLarge = 2,
kNSSHuge = 3
};
virtual ~TGNumberFormat() { }
ClassDef(TGNumberFormat,0)
};
class TGNumberEntryField : public TGTextEntry, public TGNumberFormat {
protected:
Bool_t fNeedsVerification;
EStyle fNumStyle;
EAttribute fNumAttr;
ELimit fNumLimits;
Double_t fNumMin;
Double_t fNumMax;
Bool_t fStepLog;
public:
TGNumberEntryField(const TGWindow *p, Int_t id,
Double_t val, GContext_t norm,
FontStruct_t font = GetDefaultFontStruct(),
UInt_t option = kSunkenFrame | kDoubleBorder,
Pixel_t back = GetWhitePixel());
TGNumberEntryField(const TGWindow *parent = 0,
Int_t id = -1, Double_t val = 0,
EStyle style = kNESReal,
EAttribute attr = kNEAAnyNumber,
ELimit limits = kNELNoLimits,
Double_t min = 0, Double_t max = 1);
virtual void SetNumber(Double_t val);
virtual void SetIntNumber(Long_t val);
virtual void SetTime(Int_t hour, Int_t min, Int_t sec);
virtual void SetDate(Int_t year, Int_t month, Int_t day);
virtual void SetHexNumber(ULong_t val);
virtual void SetText(const char* text, Bool_t emit = kTRUE);
virtual Double_t GetNumber() const;
virtual Long_t GetIntNumber() const;
virtual void GetTime(Int_t& hour, Int_t& min, Int_t& sec) const;
virtual void GetDate(Int_t& year, Int_t& month, Int_t& day) const;
virtual ULong_t GetHexNumber() const;
virtual Int_t GetCharWidth(const char* text = "0") const;
virtual void IncreaseNumber(EStepSize step = kNSSSmall,
Int_t sign = 1, Bool_t logstep = kFALSE);
virtual void SetFormat(EStyle style,
EAttribute attr = kNEAAnyNumber);
virtual void SetLimits(ELimit limits = kNELNoLimits,
Double_t min = 0, Double_t max = 1);
virtual void SetState(Bool_t state);
virtual void SetLogStep(Bool_t on = kTRUE) {
fStepLog = on; }
virtual EStyle GetNumStyle() const {
return fNumStyle; }
virtual EAttribute GetNumAttr() const {
return fNumAttr; }
virtual ELimit GetNumLimits() const {
return fNumLimits; }
virtual Double_t GetNumMin() const {
return fNumMin; }
virtual Double_t GetNumMax() const {
return fNumMax; }
virtual Bool_t IsLogStep() const {
return fStepLog; }
virtual Bool_t HandleKey(Event_t* event);
virtual Bool_t HandleFocusChange (Event_t* event);
virtual void TextChanged(const char *text = 0);
virtual void ReturnPressed();
virtual void Layout();
virtual Bool_t IsEditable() const { return kFALSE; }
virtual void InvalidInput(const char *instr) { Emit("InvalidInput(char*)", instr); }
virtual void SavePrimitive(ostream &out, Option_t * = "");
ClassDef(TGNumberEntryField,0)
};
class TGNumberEntry : public TGCompositeFrame, public TGWidget,
public TGNumberFormat {
EStyle fNumStyle;
EAttribute fNumAttr;
ELimit fNumLimits;
private:
const TGPicture *fPicUp;
const TGPicture *fPicDown;
TGNumberEntry(const TGNumberEntry&);
TGNumberEntry& operator=(const TGNumberEntry&);
protected:
TGNumberEntryField *fNumericEntry;
TGButton *fButtonUp;
TGButton *fButtonDown;
Bool_t fButtonToNum;
public:
TGNumberEntry(const TGWindow *parent = 0, Double_t val = 0,
Int_t digitwidth = 5, Int_t id = -1,
EStyle style = kNESReal,
EAttribute attr = kNEAAnyNumber,
ELimit limits = kNELNoLimits,
Double_t min = 0, Double_t max = 1);
virtual ~TGNumberEntry();
virtual void SetNumber(Double_t val) {
fNumericEntry->SetNumber(val); }
virtual void SetIntNumber(Long_t val) {
fNumericEntry->SetIntNumber(val); }
virtual void SetTime(Int_t hour, Int_t min, Int_t sec) {
fNumericEntry->SetTime(hour, min, sec); }
virtual void SetDate(Int_t year, Int_t month, Int_t day) {
fNumericEntry->SetDate(year, month, day); }
virtual void SetHexNumber(ULong_t val) {
fNumericEntry->SetHexNumber(val); }
virtual void SetText(const char* text) {
fNumericEntry->SetText(text); }
virtual void SetState(Bool_t enable = kTRUE);
virtual Double_t GetNumber() const {
return fNumericEntry->GetNumber(); }
virtual Long_t GetIntNumber() const {
return fNumericEntry->GetIntNumber (); }
virtual void GetTime(Int_t& hour, Int_t& min, Int_t& sec) const {
fNumericEntry->GetTime(hour, min, sec); }
virtual void GetDate(Int_t& year, Int_t& month, Int_t& day) const {
fNumericEntry->GetDate(year, month, day); }
virtual ULong_t GetHexNumber() const {
return fNumericEntry->GetHexNumber(); }
virtual void IncreaseNumber(EStepSize step = kNSSSmall,
Int_t sign = 1, Bool_t logstep = kFALSE) {
fNumericEntry->IncreaseNumber(step, sign, logstep); }
virtual void SetFormat(EStyle style, EAttribute attr = TGNumberFormat::kNEAAnyNumber) {
fNumericEntry->SetFormat(style, attr); }
virtual void SetLimits(ELimit limits = TGNumberFormat::kNELNoLimits,
Double_t min = 0, Double_t max = 1) {
fNumericEntry->SetLimits(limits, min, max); }
virtual EStyle GetNumStyle() const {
return fNumericEntry->GetNumStyle(); }
virtual EAttribute GetNumAttr() const {
return fNumericEntry->GetNumAttr(); }
virtual ELimit GetNumLimits() const {
return fNumericEntry->GetNumLimits(); }
virtual Double_t GetNumMin() const {
return fNumericEntry->GetNumMin(); }
virtual Double_t GetNumMax() const {
return fNumericEntry->GetNumMax(); }
virtual Bool_t IsLogStep() const {
return fNumericEntry->IsLogStep(); }
virtual void SetButtonToNum(Bool_t state);
void SetNumStyle(EStyle style) {
SetFormat(style, GetNumAttr()); }
void SetNumAttr(EAttribute attr = kNEAAnyNumber) {
SetFormat(GetNumStyle(), attr); }
void SetNumLimits(ELimit limits = kNELNoLimits) {
SetLimits(limits, GetNumMin(), GetNumMax()); }
void SetLimitValues(Double_t min = 0, Double_t max = 1) {
SetLimits(GetNumLimits(), min, max); }
virtual void SetLogStep(Bool_t on = kTRUE);
virtual void Associate(const TGWindow *w);
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
virtual void ValueChanged(Long_t val);
virtual void ValueSet(Long_t val);
TGNumberEntryField *GetNumberEntry() const {
return fNumericEntry; }
TGButton *GetButtonUp() const {
return fButtonUp; }
TGButton *GetButtonDown() const {
return fButtonDown; }
virtual Bool_t IsEditable() const { return kFALSE; }
UInt_t GetDefaultHeight() const { return fNumericEntry->GetDefaultHeight(); }
virtual void SavePrimitive(ostream &out, Option_t * = "");
virtual TGLayoutManager *GetLayoutManager() const;
ClassDef(TGNumberEntry,0)
};
class TGNumberEntryLayout : public TGLayoutManager {
protected:
TGNumberEntry *fBox;
private:
TGNumberEntryLayout(const TGNumberEntryLayout&);
TGNumberEntryLayout& operator=(const TGNumberEntryLayout&);
public:
TGNumberEntryLayout(TGNumberEntry *box): fBox(box) { }
virtual void Layout();
virtual TGDimension GetDefaultSize() const;
ClassDef(TGNumberEntryLayout,0)
};
#endif