130 { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
137 return (
Long_t) (x + 0.5);
139 return (
Long_t) (x - 0.5);
162 return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
194 if (((c ==
'.') || (c ==
',')) &&
237 for (
Int_t i = strlen(text) - 1; i >= 0; i--) {
239 memmove(text + i, text + i + 1, strlen(text) - i);
251 for (
UInt_t i = 0; i < strlen(text); i++) {
252 if (text[i] ==
'-') {
254 }
else if ((isdigit(text[i])) && (l <
kMaxLong)) {
255 l = 10 * l + (text[i] -
'0');
267 while (digits > s.
Length()) {
273 strlcpy(text, (
const char *) s, 250);
296 strlcpy(p,
"-", 256);
302 strlcpy(p,
".", 256-strlen(p));
308 strlcpy(p,
"e", 256-strlen(p));
310 StrInt(p, ri.fExpoNum, 0);
326 if ((text == 0) || (!text[0])) {
332 strlcpy(buf, text,
sizeof(buf));
334 frac = strchr(s,
'.');
336 frac = strchr(s,
',');
338 expo = strchr(s,
'e');
339 minus = strchr(s,
'-');
341 expo = strchr(s,
'E');
343 if ((frac != 0) && (expo != 0) && (frac > expo)) {
346 if ((minus != 0) && ((expo == 0) || (minus < expo))) {
351 if ((frac == 0) && (expo == 0)) {
353 }
else if (frac == 0) {
355 }
else if (expo == 0) {
370 ri.fExpoNum =
IntStr(expo);
374 if (ri.fExpoNum > 999) {
377 if (ri.fExpoNum < -999) {
384 for (
UInt_t i = 0; i < strlen(frac); i++) {
385 if (isdigit(frac[i])) {
386 if (ri.fFracNum + 9 <
kMaxInt / 10) {
387 ri.fFracNum = 10 * ri.fFracNum + (frac[i] -
'0');
394 if ((ri.fFracDigits == 0) && (ri.fStyle ==
kRSFrac)) {
397 if ((ri.fFracDigits == 0) && (ri.fStyle ==
kRSFracExpo)) {
402 return ri.fSign * ri.fIntNum;
405 (ri.fIntNum + (
Double_t) ri.fFracNum / ri.fFracBase);
407 return ri.fSign * (ri.fIntNum *
TMath::Power(10, ri.fExpoNum));
409 return ri.fSign * (ri.fIntNum +
410 (
Double_t) ri.fFracNum / ri.fFracBase) *
421 for (
UInt_t i = 0; i < strlen(s); i++) {
422 if ((s[i] >=
'0') && (s[i] <=
'9')) {
423 w = 16 * w + (s[i] -
'0');
424 }
else if ((toupper(s[i]) >=
'A') && (toupper(s[i]) <=
'F')) {
425 w = 16 * w + (toupper(s[i]) -
'A' + 10);
435 const char *
const digits =
"0123456789ABCDEF";
441 *(--p) = digits[l % 16];
483 strlcpy(text, (
const char *) s, 256);
503 strlcpy(text, (
const char *) s, 256);
524 if (!isdigit(*s) && !strchr(Delimiters, *s)) {
527 while ((*s != 0) && ((strchr(Delimiters, *s) == 0) || (maxd2 == 0))) {
528 if (isdigit(*s) && (d < maxd1)) {
530 n1 = 10 * n1 + (*s -
'0');
536 if (strcspn(s, Delimiters) == strlen(s)) {
540 GetNumbers(s + 1, dummy, n2, maxd2, n3, maxd3, n, d, Delimiters);
559 p = strchr(text,
'.');
561 p = strchr(text,
',');
567 for (
UInt_t i = 0; i < strlen(p); i++) {
572 while (found < digits) {
574 strcpy(p + strlen(p),
"0");
599 if (Day > kDays[Month])
601 if ((Month == 2) && (Day > 28) && !
IsLeapYear(Year))
603 return 10000 * Year + 100 * Month + Day;
618 GetNumbers(text, sign, n1, 12, n2, 0, n3, 0,
"");
621 GetNumbers(text, sign, n1, 12, n2, 1, n3, 0,
".,");
626 strlcpy(buf, text,
sizeof(buf));
628 GetNumbers(buf, sign, n1, 12, n2, 2, n3, 0,
".,");
634 strlcpy(buf, text,
sizeof(buf));
636 GetNumbers(buf, sign, n1, 12, n2, 3, n3, 0,
".,");
642 strlcpy(buf, text,
sizeof(buf));
644 GetNumbers(buf, sign, n1, 12, n2, 4, n3, 0,
".,");
650 GetNumbers(text, sign, n1, 12, n2, 2, n3, 2,
".,:");
654 GetNumbers(text, sign, n1, 12, n2, 2, n3, 2,
".,:");
658 GetNumbers(text, sign, n1, 12, n2, 2, n3, 0,
".,:");
661 GetNumbers(text, sign, n1, 12, n2, 2, n3, 0,
".,:");
664 GetNumbers(text, sign, n1, 2, n2, 2, n3, 4,
".,/");
667 GetNumbers(text, sign, n2, 2, n1, 2, n3, 4,
".,/");
683 return StrInt(text, l, 0);
708 strlcpy(text, (
const char *) date, 256);
717 strlcpy(text, (
const char *) date, 256);
734 return (
Double_t) ri.fSign * ri.fIntNum;
738 (
Double_t) ri.fFracNum / ri.fFracBase);
741 return (
Double_t) ri.fSign * ri.fIntNum *
770 lower =
Round(10.0 * min);
773 lower =
Round(100.0 * min);
776 lower =
Round(1000.0 * min);
779 lower =
Round(10000.0 * min);
804 upper =
Round(10.0 * max);
807 upper =
Round(100.0 * max);
810 upper =
Round(1000.0 * max);
813 upper =
Round(10000.0 * max);
853 x = x + mag / ri.fFracBase;
859 x = x + (mag / ri.fFracBase) * TMath::Power(10, ri.fExpoNum);
876 if ((x != 0) && logstep && (
TMath::Abs(mag) > kEpsilon)) {
877 for (
int j = 0; j < 10; j++) {
890 ri.fFracBase = 10000;
892 for (
int k = 0; k < 4; k++) {
893 if (rest % 10 != 0) {
900 if (ri.fFracDigits == 0) {
916 if ((
Truncate(y) == 0) && (y > 0.001)) {
943 ri.fSign = (x < 0) ? -1 : 1;
950 ri.fSign = (x < 0) ? -1 : 1;
958 ri.fSign = (x < 0) ? -1 : 1;
960 if (ri.fIntNum == 0) {
968 ri.fSign = (x < 0) ? -1 : 1;
972 if ((ri.fIntNum == 0) && (ri.fFracNum == 0)) {
987 snprintf(text, 255,
"%g", min);
996 snprintf(text, 255,
"%g", max);
1020 if (day > kDays[month])
1022 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1046 ((day > kDays[month]) ||
1047 ((month == 2) && (day > 28) && !
IsLeapYear(year)))) {
1055 if ((sign < 0) && (day == 0)) {
1067 if (day > kDays[month])
1069 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1072 l = 10000 * year + 100 * month + day;
1086 fNeedsVerification(
kFALSE), fNumStyle(kNESReal), fNumAttr(kNEAAnyNumber),
1087 fNumLimits(kNELNoLimits), fNumMin(0.0), fNumMax(1.0)
1100 EStyle style, EAttribute attr,
1104 fNumAttr(attr), fNumLimits(limits), fNumMin(min), fNumMax(max)
1137 snprintf(text, 255,
"%g", val);
1236 strlcpy(buf, text,
sizeof(buf));
1262 strlcpy(text,
GetText(),
sizeof(text));
1347 month = (l % 10000) / 100;
1427 rmag = (!logstep) ? 1. : (odd ? 3. : 10. / 3.);
1433 rmag = (!logstep) ? 100. : (odd ? 30. : 100. / 3.);
1436 rmag = (!logstep) ? 1000. : 100.;
1440 rmag = logstep ? 1. / rmag : -rmag;
1449 sign = (sign > 0) ? 1 : -1;
1459 l = logstep ?
Round(l * rmag) :
Round(l + rmag);
1482 l += sign * 36 * mag;
1484 l += sign * 6 * mag;
1497 l += sign * 36 * mag;
1499 l += sign * 6 * mag;
1504 l = (24 * 3600) - ((-l) % (24 * 3600));
1506 l = l % (24 * 3600);
1512 l += sign * 6 * mag;
1525 l += sign * 6 * mag;
1530 l = (24 * 60) - ((-l) % (24 * 60));
1546 ll += sign * 4096 * mag / 1000;
1548 ll += sign * 256 * mag / 100;
1550 ll += sign * 16 * mag / 10;
1621 gVirtualX->LookupString(event, tmp,
sizeof(tmp), keysym);
1677 else if (n && (keysym < 127) && (keysym >= 32) &&
1730 if (instr != outstr) {
1773 Int_t downy = h / 2;
1775 UInt_t downh = h - downy;
1776 UInt_t numw = (w >
h) ? w - upw : w;
1804 class TGRepeatFireButton;
1808 class TRepeatTimer :
public TTimer {
1810 TGRepeatFireButton *fButton;
1813 TRepeatTimer(TGRepeatFireButton * button,
Long_t ms)
1832 TRepeatTimer *fTimer;
1833 Int_t fIgnoreNextFire;
1838 Bool_t IsEditableParent();
1844 fStep(
TGNumberFormat::kNSSSmall), fStepLog(logstep), fDoLogStep(logstep)
1846 virtual ~TGRepeatFireButton() {
delete fTimer; }
1850 virtual void SetLogStep(
Bool_t on =
kTRUE) { fStepLog = on; }
1856 Bool_t TGRepeatFireButton::IsEditableParent()
1860 while (parent && (parent != fClient->GetDefaultRoot())) {
1874 const Int_t t0 = 200;
1879 if (IsEditableParent()) {
1888 fDoLogStep = fStepLog;
1890 fDoLogStep = !fDoLogStep;
1902 fIgnoreNextFire = 0;
1904 fIgnoreNextFire = 2;
1907 fTimer =
new TRepeatTimer(
this, t0);
1915 fTimer->SetTime(t0);
1925 void TGRepeatFireButton::FireButton()
1927 if (fIgnoreNextFire <= 0) {
1929 fWidgetId, (
Long_t) fStep + (fDoLogStep ? 100 : 0));
1940 fButton->FireButton();
1942 if ((
Long64_t)fTime > 20) fTime -= 10;
1957 fMsgWindow = parent;
1958 fPicUp = fClient->GetPicture(
"arrow_up.xpm");
1960 Error(
"TGNumberEntry",
"arrow_up.xpm not found");
1961 fPicDown = fClient->GetPicture(
"arrow_down.xpm");
1963 Error(
"TGNumberEntry",
"arrow_down.xpm not found");
1968 fNumericEntry->Connect(
"ReturnPressed()",
"TGNumberEntry",
this,
1969 "ValueSet(Long_t=0)");
1970 fNumericEntry->Associate(fMsgWindow);
1971 AddFrame(fNumericEntry, 0);
1972 fButtonUp =
new TGRepeatFireButton(
this, fPicUp, 1,
1973 fNumericEntry->IsLogStep());
1974 fButtonUp->Associate(
this);
1975 AddFrame(fButtonUp, 0);
1976 fButtonDown =
new TGRepeatFireButton(
this, fPicDown, 2,
1977 fNumericEntry->IsLogStep());
1978 fButtonDown->Associate(
this);
1979 AddFrame(fButtonDown, 0);
1982 Int_t h = fNumericEntry->GetDefaultHeight();
1983 Int_t charw = fNumericEntry->GetCharWidth(
"0123456789");
1988 fEditDisabled = kEditDisableLayout | kEditDisableHeight;
2062 (parm1 >= 1) && (parm1 <= 2)) {
2066 Bool_t logstep = (parm2 >= 100);
2070 10000 * (parm1 - 1) + parm2);
2074 ValueSet(10000 * (parm1 - 1) + parm2);
2106 Emit(
"ValueChanged(Long_t)", val);
2118 Emit(
"ValueSet(Long_t)", val);
2132 Int_t digits = (30*w - 240 -20*
h)/(3*charw) + 3;
2142 out <<
" TGNumberEntry *";
2174 out << min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2178 out << hour*60 + min <<
"," << digits <<
"," <<
WidgetId()
2182 out << hour*3600 + min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2186 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2190 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2197 std::ios::fmtflags
f = out.flags();
2208 out <<
");" << std::endl;
2210 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2213 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2214 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2217 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2219 <<
"," <<
GetNumMin() <<
");" << std::endl;
2222 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2226 if (option && strstr(option,
"keep_names"))
2227 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2229 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2236 out <<
GetName() <<
"->GetNumberEntry()->SetToolTipText(" << quote
2237 << tiptext << quote <<
");" << std::endl;
2256 out <<
" TGNumberEntryField *";
2258 <<
", " <<
WidgetId() <<
", (Double_t) ";
2293 out << hour*60 + min
2297 out << hour*3600 + min*60 + sec
2301 out << yy << mm << dd
2305 out << yy << mm << dd
2312 std::ios::fmtflags
f = out.flags();
2323 out <<
");" << std::endl;
2325 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2328 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2329 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2332 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2334 <<
"," <<
GetNumMin() <<
");" << std::endl;
2337 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2341 if (option && strstr(option,
"keep_names"))
2342 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2344 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2347 <<
"->GetDefaultHeight());" << std::endl;
2354 out <<
GetName() <<
"->SetToolTipText(" << quote
2355 << tiptext << quote <<
");" << std::endl;
const TGPicture * fPicDown
TGButton * GetButtonUp() const
TGLayoutManager * fLayoutManager
virtual ELimit GetNumLimits() const
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
virtual void SetTime(Int_t hour, Int_t min, Int_t sec)
Set the numeric value (time format).
virtual void SetDate(Int_t year, Int_t month, Int_t day)
Set the numeric value (date format).
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
static char * IntToHexStr(char *text, ULong_t l)
virtual void SetLogStep(Bool_t on=kTRUE)
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
virtual void InvalidInput(const char *instr)
virtual void ReturnPressed()
Return was pressed.
const TGWindow * GetParent() const
static void AppendFracZero(char *text, Int_t digits)
virtual EAttribute GetNumAttr() const
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
const char Int_t const char TProof Int_t const char const char * msd
virtual void TextChanged(const char *text=0)
Text has changed message.
const Mask_t kKeyShiftMask
TGNumberEntryLayout(const TGNumberEntryLayout &)
virtual void SetState(Bool_t state)
Set the active state.
const Mask_t kKeyMod1Mask
TString & ReplaceAll(const TString &s1, const TString &s2)
static char * RealToStr(char *text, const RealInfo_t &ri)
virtual EAttribute GetNumAttr() const
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
virtual void SetIntNumber(Long_t val)
Set the numeric value (integer representation).
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
Get the numeric value (time format).
static char * StrInt(char *text, Long_t i, Int_t digits)
virtual ELimit GetNumLimits() const
static char * DIntToStr(char *text, Long_t l, Bool_t Sec, char Del)
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
static Long_t MakeDateNumber(const char *, Long_t Day, Long_t Month, Long_t Year)
Create a number entry with year/month/day information.
static Bool_t IsGoodChar(char c, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
virtual void ValueSet(Long_t val)
Emit ValueSet(Long_t) signal.
static char * TranslateToStr(char *text, Long_t l, TGNumberFormat::EStyle style, const RealInfo_t &ri)
Translate a number value to a string.
virtual void IncreaseNumber(EStepSize step=kNSSSmall, Int_t sign=1, Bool_t logstep=kFALSE)
Increase the number value.
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
virtual TGToolTip * GetToolTip() const
virtual void SetFormat(EStyle style, EAttribute attr=kNEAAnyNumber)
Set the numerical format.
TGButton * GetButtonDown() const
virtual void SetButtonToNum(Bool_t state)
Send button messages to the number field (true) or parent widget (false).
TGNumberEntryField * GetNumberEntry() const
virtual void SetLogStep(Bool_t on=kTRUE)
Set log steps.
virtual Double_t GetNumMin() const
virtual void ReturnPressed()
This signal is emitted when the return or enter key is pressed.
TGNumberEntryField * fNumericEntry
const char * GetText() const
static Bool_t IsLeapYear(Int_t year)
virtual EStyle GetNumStyle() const
const char * GetString() const
virtual void Layout()
Layout.
virtual Bool_t IsLogStep() const
virtual Double_t GetNumMin() const
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
void End(Bool_t mark=kFALSE)
Moves the text cursor to the right end of the line.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
void Emit(const char *signal)
Acitvate signal without args.
virtual Bool_t Notify()
Notify when timer times out.
virtual void SetLimits(ELimit limits=kNELNoLimits, Double_t min=0, Double_t max=1)
Set the numerical limits.
static ULong_t HexStrToInt(const char *s)
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual Int_t GetCharWidth(const char *text="0") const
Get the text width in pixels.
static Double_t StrToReal(const char *text, RealInfo_t &ri)
static Long_t IntStr(const char *text)
R__EXTERN TSystem * gSystem
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
virtual void ValueChanged(Long_t val)
Emit ValueChanged(Long_t) signal.
static char * MIntToStr(char *text, Long_t l, Int_t digits)
virtual void SetHexNumber(ULong_t val)
Set the numeric value (hex format).
static void GetNumbers(const char *s, Int_t &Sign, Long_t &n1, Int_t maxd1, Long_t &n2, Int_t maxd2, Long_t &n3, Int_t maxd3, const char *Delimiters)
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change.
Handles synchronous and a-synchronous timer events.
virtual void TextChanged(const char *text=0)
This signal is emitted every time the text has changed.
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
virtual Bool_t IsEditable() const
virtual Double_t GetNumMax() const
void Reset(Detail::TBranchProxy *x)
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text entry widget.
virtual EStyle GetNumStyle() const
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process the up/down button messages.
static void CheckMinMax(Long_t &l, TGNumberFormat::EStyle style, TGNumberFormat::ELimit limits, Double_t min, Double_t max)
Check min/max limits for the set value.
TGNumberEntry(const TGNumberEntry &)
TGDimension GetSize() const
static RooMathCoreReg dummy
static Long_t TranslateToNum(const char *text, TGNumberFormat::EStyle style, RealInfo_t &ri)
Translate a string to a number value.
virtual ~TGNumberEntry()
Destructs a numeric entry widget.
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
Get the numeric value (date format).
ETextJustification GetAlignment() const
Bool_t fNeedsVerification
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual Bool_t HandleKey(Event_t *event)
Handle keys.
virtual ULong_t GetHexNumber() const
Get the numeric value (hex format).
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())
Constructs a number entry field.
virtual ULong_t GetHexNumber() const
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
static Long_t GetSignificant(Long_t l, Int_t Max)
static Long_t Truncate(Double_t x)
static Double_t RealToDouble(const RealInfo_t ri)
Convert to double format.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Short_t Max(Short_t a, Short_t b)
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
TGTextBuffer * GetBuffer() const
static TString StringInt(Long_t i, Int_t digits)
virtual Long_t GetIntNumber() const
virtual Double_t GetNumber() const
const char * GetString() const
const Mask_t kKeyControlMask
static void IncreaseReal(RealInfo_t &ri, Double_t mag, Bool_t logstep, TGNumberFormat::ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
Convert to double format.
void Home(Bool_t mark=kFALSE)
Moves the text cursor to the left end of the line.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
virtual TGDimension GetDefaultSize() const
Return the default size of the numeric control box.
static void IncreaseDate(Long_t &l, TGNumberFormat::EStepSize step, Int_t sign)
Change year/month/day format.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
double norm(double *x, double *p)
static Long_t Round(Double_t x)
virtual Double_t GetNumMax() const
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Set the value (text format).
static char * EliminateGarbage(char *text, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
virtual void Layout()
Layout the internal GUI elements in use.