129 { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
161 return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
194 if (((
c ==
'.') || (
c ==
',')) &&
249 std::size_t dstIdx = 0;
250 while (dstIdx < dstCap - 1 && *src) {
252 dst[dstIdx++] = *src;
266 if (
text[i] ==
'-') {
269 l = 10 *
l + (
text[i] -
'0');
303 const auto TextLen = [&p,
text, textCap] () -> std::size_t {
304 std::size_t curTextLen = p -
text;
305 if (curTextLen >= textCap)
307 return textCap - curTextLen;
310 strlcpy(p,
"", textCap);
312 strlcpy(p,
"-", textCap);
318 strlcpy(p,
".", TextLen());
324 strlcpy(p,
"e", TextLen());
348 strlcpy(buf,
text,
sizeof(buf));
350 frac = strchr(s,
'.');
352 frac = strchr(s,
',');
354 expo = strchr(s,
'e');
355 minus = strchr(s,
'-');
357 expo = strchr(s,
'E');
359 if ((frac != 0) && (expo != 0) && (frac > expo)) {
362 if ((minus != 0) && ((expo == 0) || (minus < expo))) {
367 if ((frac == 0) && (expo == 0)) {
369 }
else if (frac == 0) {
371 }
else if (expo == 0) {
400 for (
UInt_t i = 0; i < strlen(frac); i++) {
401 if (isdigit(frac[i])) {
437 for (
UInt_t i = 0; i < strlen(s); i++) {
438 if ((s[i] >=
'0') && (s[i] <=
'9')) {
439 w = 16 * w + (s[i] -
'0');
440 }
else if ((toupper(s[i]) >=
'A') && (toupper(s[i]) <=
'F')) {
441 w = 16 * w + (toupper(s[i]) -
'A' + 10);
484 strlcpy(
text, (
const char *) s, textCap);
504 strlcpy(
text, (
const char *) s, textCap);
520 strlcpy(
text, (
const char *) s, textCap);
541 if (!isdigit(*s) && !strchr(Delimiters, *s)) {
544 while ((*s != 0) && ((strchr(Delimiters, *s) == 0) || (maxd2 == 0))) {
545 if (isdigit(*s) && (
d < maxd1)) {
547 n1 = 10 * n1 + (*s -
'0');
553 if (strcspn(s, Delimiters) == strlen(s)) {
557 GetNumbers(s + 1, dummy, n2, maxd2, n3, maxd3,
n,
d, Delimiters);
577 char *p = strrchr(
text,
'.');
579 p = strrchr(
text,
',');
585 auto pLen = strlen(p);
586 for (
UInt_t i = 0; i < pLen; i++) {
589 found += !!isdigit(p[i]);
591 auto pOff = p -
text;
592 assert(textCap>= pOff + pLen);
593 auto remainingCap = textCap - pOff - pLen;
594 const auto trailingZeroes = std::min<std::size_t>(std::max(0, digits - found), remainingCap - 1);
595 if (trailingZeroes > 0) {
596 memset(p + pLen,
'0', trailingZeroes);
598 p[pLen + trailingZeroes] = 0;
622 if (Day >
kDays[Month])
624 if ((Month == 2) && (Day > 28) && !
IsLeapYear(Year))
626 return 10000 * Year + 100 * Month + Day;
649 strlcpy(buf,
text,
sizeof(buf));
651 GetNumbers(buf, sign, n1, 12, n2, 2, n3, 0,
".,");
657 strlcpy(buf,
text,
sizeof(buf));
659 GetNumbers(buf, sign, n1, 12, n2, 3, n3, 0,
".,");
665 strlcpy(buf,
text,
sizeof(buf));
667 GetNumbers(buf, sign, n1, 12, n2, 4, n3, 0,
".,");
738 strlcpy(
text, (
const char *) date, textCap);
747 strlcpy(
text, (
const char *) date, textCap);
800 lower =
Round(10.0 * min);
803 lower =
Round(100.0 * min);
806 lower =
Round(1000.0 * min);
809 lower =
Round(10000.0 * min);
834 upper =
Round(10.0 * max);
837 upper =
Round(100.0 * max);
840 upper =
Round(1000.0 * max);
843 upper =
Round(10000.0 * max);
907 for (
int j = 0; j < 10; j++) {
922 for (
int k = 0; k < 4; k++) {
923 if (rest % 10 != 0) {
973 ri.
fSign = (
x < 0) ? -1 : 1;
980 ri.
fSign = (
x < 0) ? -1 : 1;
988 ri.
fSign = (
x < 0) ? -1 : 1;
998 ri.
fSign = (
x < 0) ? -1 : 1;
1050 if (day >
kDays[month])
1052 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1076 ((day >
kDays[month]) ||
1077 ((month == 2) && (day > 28) && !
IsLeapYear(year)))) {
1085 if ((sign < 0) && (day == 0)) {
1097 if (day >
kDays[month])
1099 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1102 l = 10000 * year + 100 * month + day;
1391 month = (
l % 10000) / 100;
1431 Int_t sign = stepsign;
1471 rmag = (!logstep) ? 1. : (odd ? 3. : 10. / 3.);
1477 rmag = (!logstep) ? 100. : (odd ? 30. : 100. / 3.);
1480 rmag = (!logstep) ? 1000. : 100.;
1484 rmag = logstep ? 1. / rmag : -rmag;
1493 sign = (sign > 0) ? 1 : -1;
1526 l += sign * 36 * mag;
1528 l += sign * 6 * mag;
1541 l += sign * 36 * mag;
1543 l += sign * 6 * mag;
1548 l = (24 * 3600) - ((-
l) % (24 * 3600));
1550 l =
l % (24 * 3600);
1556 l += sign * 6 * mag;
1569 l += sign * 36 * mag;
1571 l += sign * 6 * mag;
1576 l = (60 * 6000) - ((-
l) % (60 * 6000));
1578 l =
l % (60 * 6000);
1584 l += sign * 6 * mag;
1589 l = (24 * 60) - ((-
l) % (24 * 60));
1605 ll += sign * 4096 * mag / 1000;
1607 ll += sign * 256 * mag / 100;
1609 ll += sign * 16 * mag / 10;
1680 gVirtualX->LookupString(event, tmp,
sizeof(tmp), keysym);
1736 else if (
n && (keysym < 127) && (keysym >= 32) &&
1789 if (instr != outstr) {
1835 UInt_t numw = (w >
h) ? w - upw : w;
1837 if (
fBox->GetNumberEntry())
1838 fBox->GetNumberEntry()->MoveResize(0, 0, numw, numh);
1839 if (
fBox->GetButtonUp())
1840 fBox->GetButtonUp()->MoveResize(upx, upy, upw, uph);
1841 if (
fBox->GetButtonDown())
1842 fBox->GetButtonDown()->MoveResize(downx, downy, downw, downh);
1850 return fBox->GetSize();
1919 while (parent && (parent !=
fClient->GetDefaultRoot())) {
1933 const Int_t t0 = 200;
2019 Error(
"TGNumberEntry",
"arrow_up.xpm not found");
2022 Error(
"TGNumberEntry",
"arrow_down.xpm not found");
2027 fNumericEntry->Connect(
"ReturnPressed()",
"TGNumberEntry",
this,
2028 "ValueSet(Long_t=0)");
2029 fNumericEntry->Connect(
"ReturnPressed()",
"TGNumberEntry",
this,
2123 (parm1 >= 1) && (parm1 <= 2)) {
2125 Int_t sign = (parm1 == 1) ? 1 : -1;
2127 Bool_t logstep = (parm2 >= 100);
2131 10000 * (parm1 - 1) + parm2);
2135 ValueSet(10000 * (parm1 - 1) + parm2);
2168 Emit(
"ValueChanged(Long_t)", val);
2180 Emit(
"ValueSet(Long_t)", val);
2201 Int_t digits = (30 * w - 240 - 20 *
h) / (3 * charw) + 3;
2204 Int_t hour, min, sec;
2211 out <<
" TGNumberEntry *" <<
GetName() <<
" = new TGNumberEntry(" <<
fParent->GetName() <<
", (Double_t) ";
2235 out << min * 60 + sec <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2239 out << min * 6000 + sec * 100 + hour <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) "
2243 out << hour * 60 + min <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2246 out << hour * 3600 + min * 60 + sec <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) "
2250 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2253 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId() <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2258 out <<
"0x" << hexstr <<
"U, " << digits <<
", " <<
WidgetId() <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2268 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");\n";
2271 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits()
2275 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits()
2279 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
","
2282 if (option && strstr(option,
"keep_names"))
2283 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");\n";
2285 out <<
" " <<
GetName() <<
"->SetState(kFALSE);\n";
2300 Int_t hour, min, sec;
2307 out <<
" TGNumberEntryField *" <<
GetName() <<
" = new TGNumberEntryField(" <<
fParent->GetName() <<
", " <<
WidgetId() <<
", (Double_t) ";
2319 out << min * 6000 + sec * 100 + hour <<
",(TGNumberFormat::EStyle) " <<
GetNumStyle();
2328 out <<
"0x" << hexstr <<
"U, (TGNumberFormat::EStyle) " <<
GetNumStyle();
2338 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");\n";
2341 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits()
2345 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits()
2349 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
","
2352 if (option && strstr(option,
"keep_names"))
2353 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");\n";
2355 out <<
" " <<
GetName() <<
"->SetState(kFALSE);\n";
const Mask_t kKeyMod1Mask
typically the Alt key
const Mask_t kKeyShiftMask
const Mask_t kKeyControlMask
Handle_t GContext_t
Graphics context handle.
Handle_t FontStruct_t
Pointer to font structure.
ULong_t Pixel_t
Pixel value.
constexpr Long_t kMaxLong
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
static char * MIntToStr(char *text, std::size_t textCap, Long_t l, Int_t digits)
static void IncreaseDate(Long_t &l, TGNumberFormat::EStepSize step, Int_t sign)
Change year/month/day format.
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.
static Long_t Truncate(Double_t x)
static Long_t TranslateToNum(const char *text, TGNumberFormat::EStyle style, RealInfo_t &ri)
Translate a string to a number value.
static Bool_t IsGoodChar(char c, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
static void CopyAndSkipGarbage(char *dst, std::size_t dstCap, const char *src, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
Copy the string stored in src into dst, skipping some chars depending on the format and style.
static Long_t Round(Double_t x)
static char * IntToHexStr(char *text, std::size_t textCap, ULong_t l)
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)
static char * StrInt(char *text, std::size_t textCap, Long_t i, Int_t digits)
static ULong_t HexStrToInt(const char *s)
static Long_t GetSignificant(Long_t l, Int_t Max)
static void AppendFracZero(char *text, std::size_t textCap, Int_t digits)
Given a numeric string "xxx.yyy" or "xxx,yyy", makes sure that the fractional part (if present) alway...
static char * DIntToStr(char *text, std::size_t textCap, Long_t l, Bool_t Sec, char Del)
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.
static char * TranslateToStr(char *text, std::size_t textCap, Long_t l, TGNumberFormat::EStyle style, const RealInfo_t &ri)
Translate a number value to a string.
static Long_t IntStr(const char *text)
static Double_t RealToDouble(const RealInfo_t ri)
Convert to double format.
static TString StringInt(Long_t i, Int_t digits)
static char * RealToStr(char *text, std::size_t textCap, const RealInfo_t &ri)
static Double_t StrToReal(const char *text, RealInfo_t &ri)
static Bool_t IsLeapYear(Int_t year)
static Long_t MakeDateNumber(const char *, Long_t Day, Long_t Month, Long_t Year)
Create a number entry with year/month/day information.
TGLayoutManager * fLayoutManager
layout manager
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
TGCompositeFrame(const TGCompositeFrame &)=delete
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
TClass * IsA() const override
virtual void SetHexNumber(ULong_t val, Bool_t emit=kTRUE)
Set the numeric value (hex format).
ELimit fNumLimits
Limit attributes.
virtual void InvalidInput(const char *instr)
virtual Double_t GetNumMin() const
Get the lower limit.
Bool_t fNeedsVerification
Needs verification of input.
virtual void SetFormat(EStyle style, EAttribute attr=kNEAAnyNumber)
Set the numerical format.
virtual void SetDate(Int_t year, Int_t month, Int_t day, Bool_t emit=kTRUE)
Set the numeric value (date format).
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
Set the numeric value (floating point representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
EStyle fNumStyle
Number style.
Bool_t HandleFocusChange(Event_t *event) override
Handle focus change.
void SetState(Bool_t state) override
Set the active state.
virtual EStyle GetNumStyle() const
Get the numerical style.
void ReturnPressed() override
Return was pressed.
virtual Double_t GetNumMax() const
Get the upper limit.
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
Get the numeric value (date format).
void TextChanged(const char *text=nullptr) override
Text has changed message.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a number entry widget as a C++ statement(s) on output stream out.
virtual void IncreaseNumber(EStepSize step=kNSSSmall, Int_t sign=1, Bool_t logstep=kFALSE)
Increase the number value.
virtual ULong_t GetHexNumber() const
Get the numeric value (hex format).
virtual void SetIntNumber(Long_t val, Bool_t emit=kTRUE)
Set the numeric value (integer representation).
Bool_t HandleKey(Event_t *event) override
Handle keys.
virtual void SetLimits(ELimit limits=kNELNoLimits, Double_t min=0, Double_t max=1)
Set the numerical limits.
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
Get the numeric value (time format).
virtual EAttribute GetNumAttr() const
Get the numerical attribute.
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.
void SetText(const char *text, Bool_t emit=kTRUE) override
Set the value (text format).
EAttribute fNumAttr
Number attribute.
Double_t fNumMin
Lower limit.
virtual Int_t GetCharWidth(const char *text="0") const
Get the text width in pixels.
virtual void SetTime(Int_t hour, Int_t min, Int_t sec, Bool_t emit=kTRUE)
Set the numeric value (time format).
Bool_t fStepLog
Logarithmic steps for increase?
Double_t fNumMax
Upper limit.
void Layout() override
Layout.
virtual ELimit GetNumLimits() const
Get the numerical limit attribute.
TGDimension GetDefaultSize() const override
Return the default size of the numeric control box.
void Layout() override
Layout the internal GUI elements in use.
TGButton * fButtonDown
Button for decreasing value.
virtual Double_t GetNumMax() const
virtual EStyle GetNumStyle() const
Bool_t fButtonToNum
Send button messages to parent rather than number entry field.
virtual ULong_t GetHexNumber() const
virtual void SetButtonToNum(Bool_t state)
Send button messages to the number field (true) or parent widget (false).
virtual void ValueSet(Long_t val)
Emit ValueSet(Long_t) signal.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
const TGPicture * fPicUp
Up arrow.
~TGNumberEntry() override
Destructs a numeric entry widget.
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
TGNumberEntry(const TGNumberEntry &)=delete
virtual ELimit GetNumLimits() const
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process the up/down button messages.
virtual void SetLogStep(Bool_t on=kTRUE)
Set log steps.
const TGPicture * fPicDown
Down arrow.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a number entry widget as a C++ statement(s) on output stream out.
virtual void ValueChanged(Long_t val)
Emit ValueChanged(Long_t) signal.
TGLayoutManager * GetLayoutManager() const override
Return layout manager.
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual Long_t GetIntNumber() const
virtual EAttribute GetNumAttr() const
virtual void Modified()
Emit Modified() signal.
virtual Double_t GetNumMin() const
TGNumberEntryField * fNumericEntry
Number text entry field.
virtual Double_t GetNumber() const
TGButton * fButtonUp
Button for increasing value.
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
TGClient * fClient
Connection to display server.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
const char * GetString() const
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
const char * GetString() const
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
TGTextBuffer * GetBuffer() const
const char * GetText() const
TGTextEntry(const TGTextEntry &)=delete
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
virtual TGToolTip * GetToolTip() const
ETextJustification GetAlignment() const
virtual void ReturnPressed()
This signal is emitted when the return or enter key is pressed.
Bool_t HandleFocusChange(Event_t *event) override
Handle focus change event in text entry widget.
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.
FontStruct_t fFontStruct
text font
void End(Bool_t mark=kFALSE)
Moves the text cursor to the right end of the line.
virtual void TextChanged(const char *text=nullptr)
This signal is emitted every time the text has changed.
void Home(Bool_t mark=kFALSE)
Moves the text cursor to the left end of the line.
ROOT GUI Window base class.
const TGWindow * fParent
Parent window.
@ kEditDisableHeight
window height cannot be edited
@ kEditDisableLayout
window layout cannot be edited
@ kEditDisableGrab
window grab cannot be edited
@ kEditDisable
disable edit of this window
virtual Bool_t IsEditable() const
const TGWindow * GetParent() const
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
UInt_t fEditDisabled
flags used for "guibuilding"
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
TRepeatTimer(TGRepeatFireButton *button, Long_t ms)
Bool_t Notify() override
Notify when timer times out and reset the timer.
TGRepeatFireButton * fButton
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
void Reset()
Reset the timer.
TTimer(const TTimer &)=delete
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
EGEventType fType
of event (see EGEventType)
UInt_t fState
key or button mask
UInt_t fCode
key or button code