119 Int_t fFracDigits{0};
134 { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
166 return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
198 if (((
c ==
'.') || (
c ==
',')) &&
241 for (
Int_t i = strlen(
text) - 1; i >= 0; i--) {
256 if (
text[i] ==
'-') {
259 l = 10 *
l + (
text[i] -
'0');
271 while (digits > s.
Length()) {
277 strlcpy(
text, (
const char *) s, 250);
300 strlcpy(p,
"-", 256);
306 strlcpy(p,
".", 256-strlen(p));
312 strlcpy(p,
"e", 256-strlen(p));
314 StrInt(p, ri.fExpoNum, 0);
336 strlcpy(buf,
text,
sizeof(buf));
338 frac = strchr(s,
'.');
340 frac = strchr(s,
',');
342 expo = strchr(s,
'e');
343 minus = strchr(s,
'-');
345 expo = strchr(s,
'E');
347 if ((frac != 0) && (expo != 0) && (frac > expo)) {
350 if ((minus != 0) && ((expo == 0) || (minus < expo))) {
355 if ((frac == 0) && (expo == 0)) {
357 }
else if (frac == 0) {
359 }
else if (expo == 0) {
374 ri.fExpoNum =
IntStr(expo);
378 if (ri.fExpoNum > 999) {
381 if (ri.fExpoNum < -999) {
388 for (
UInt_t i = 0; i < strlen(frac); i++) {
389 if (isdigit(frac[i])) {
390 if (ri.fFracNum + 9 <
kMaxInt / 10) {
391 ri.fFracNum = 10 * ri.fFracNum + (frac[i] -
'0');
398 if ((ri.fFracDigits == 0) && (ri.fStyle ==
kRSFrac)) {
401 if ((ri.fFracDigits == 0) && (ri.fStyle ==
kRSFracExpo)) {
406 return ri.fSign * ri.fIntNum;
409 (ri.fIntNum + (
Double_t) ri.fFracNum / ri.fFracBase);
411 return ri.fSign * (ri.fIntNum *
TMath::Power(10, ri.fExpoNum));
413 return ri.fSign * (ri.fIntNum +
414 (
Double_t) ri.fFracNum / ri.fFracBase) *
425 for (
UInt_t i = 0; i < strlen(s); i++) {
426 if ((s[i] >=
'0') && (s[i] <=
'9')) {
427 w = 16 * w + (s[i] -
'0');
428 }
else if ((toupper(s[i]) >=
'A') && (toupper(s[i]) <=
'F')) {
429 w = 16 * w + (toupper(s[i]) -
'A' + 10);
439 const char *
const digits =
"0123456789ABCDEF";
445 *(--p) = digits[
l % 16];
487 strlcpy(
text, (
const char *) s, 256);
507 strlcpy(
text, (
const char *) s, 256);
528 if (!isdigit(*s) && !strchr(Delimiters, *s)) {
531 while ((*s != 0) && ((strchr(Delimiters, *s) == 0) || (maxd2 == 0))) {
532 if (isdigit(*s) && (
d < maxd1)) {
534 n1 = 10 * n1 + (*s -
'0');
540 if (strcspn(s, Delimiters) == strlen(s)) {
544 GetNumbers(s + 1, dummy, n2, maxd2, n3, maxd3,
n,
d, Delimiters);
563 p = strchr(
text,
'.');
565 p = strchr(
text,
',');
571 for (
UInt_t i = 0; i < strlen(p); i++) {
576 while (found < digits) {
578 strcpy(p + strlen(p),
"0");
603 if (Day >
kDays[Month])
605 if ((Month == 2) && (Day > 28) && !
IsLeapYear(Year))
607 return 10000 * Year + 100 * Month + Day;
630 strlcpy(buf,
text,
sizeof(buf));
632 GetNumbers(buf, sign, n1, 12, n2, 2, n3, 0,
".,");
638 strlcpy(buf,
text,
sizeof(buf));
640 GetNumbers(buf, sign, n1, 12, n2, 3, n3, 0,
".,");
646 strlcpy(buf,
text,
sizeof(buf));
648 GetNumbers(buf, sign, n1, 12, n2, 4, n3, 0,
".,");
712 strlcpy(
text, (
const char *) date, 256);
721 strlcpy(
text, (
const char *) date, 256);
738 return (
Double_t) ri.fSign * ri.fIntNum;
742 (
Double_t) ri.fFracNum / ri.fFracBase);
745 return (
Double_t) ri.fSign * ri.fIntNum *
774 lower =
Round(10.0 * min);
777 lower =
Round(100.0 * min);
780 lower =
Round(1000.0 * min);
783 lower =
Round(10000.0 * min);
808 upper =
Round(10.0 * max);
811 upper =
Round(100.0 * max);
814 upper =
Round(1000.0 * max);
817 upper =
Round(10000.0 * max);
857 x =
x + mag / ri.fFracBase;
881 for (
int j = 0; j < 10; j++) {
894 ri.fFracBase = 10000;
896 for (
int k = 0; k < 4; k++) {
897 if (rest % 10 != 0) {
904 if (ri.fFracDigits == 0) {
947 ri.fSign = (
x < 0) ? -1 : 1;
954 ri.fSign = (
x < 0) ? -1 : 1;
962 ri.fSign = (
x < 0) ? -1 : 1;
964 if (ri.fIntNum == 0) {
972 ri.fSign = (
x < 0) ? -1 : 1;
976 if ((ri.fIntNum == 0) && (ri.fFracNum == 0)) {
1024 if (day >
kDays[month])
1026 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1050 ((day >
kDays[month]) ||
1051 ((month == 2) && (day > 28) && !
IsLeapYear(year)))) {
1059 if ((sign < 0) && (day == 0)) {
1071 if (day >
kDays[month])
1073 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1076 l = 10000 * year + 100 * month + day;
1090 fNeedsVerification(
kFALSE), fNumStyle(kNESReal), fNumAttr(kNEAAnyNumber),
1091 fNumLimits(kNELNoLimits), fNumMin(0.0), fNumMax(1.0)
1108 fNumAttr(attr), fNumLimits(limits), fNumMin(min), fNumMax(max)
1240 strlcpy(buf,
text,
sizeof(buf));
1351 month = (
l % 10000) / 100;
1391 Int_t sign = stepsign;
1431 rmag = (!logstep) ? 1. : (odd ? 3. : 10. / 3.);
1437 rmag = (!logstep) ? 100. : (odd ? 30. : 100. / 3.);
1440 rmag = (!logstep) ? 1000. : 100.;
1444 rmag = logstep ? 1. / rmag : -rmag;
1453 sign = (sign > 0) ? 1 : -1;
1486 l += sign * 36 * mag;
1488 l += sign * 6 * mag;
1501 l += sign * 36 * mag;
1503 l += sign * 6 * mag;
1508 l = (24 * 3600) - ((-
l) % (24 * 3600));
1510 l =
l % (24 * 3600);
1516 l += sign * 6 * mag;
1529 l += sign * 6 * mag;
1534 l = (24 * 60) - ((-
l) % (24 * 60));
1550 ll += sign * 4096 * mag / 1000;
1552 ll += sign * 256 * mag / 100;
1554 ll += sign * 16 * mag / 10;
1625 gVirtualX->LookupString(event, tmp,
sizeof(tmp), keysym);
1681 else if (
n && (keysym < 127) && (keysym >= 32) &&
1734 if (instr != outstr) {
1780 UInt_t numw = (w >
h) ? w - upw : w;
1808class TGRepeatFireButton;
1812class TRepeatTimer :
public TTimer {
1814 TGRepeatFireButton *fButton;
1817 TRepeatTimer(TGRepeatFireButton * button,
Long_t ms)
1836 TRepeatTimer *fTimer;
1837 Int_t fIgnoreNextFire;
1842 Bool_t IsEditableParent();
1848 fStep(
TGNumberFormat::kNSSSmall), fStepLog(logstep), fDoLogStep(logstep)
1850 virtual ~TGRepeatFireButton() {
delete fTimer; }
1854 virtual void SetLogStep(
Bool_t on =
kTRUE) { fStepLog = on; }
1860Bool_t TGRepeatFireButton::IsEditableParent()
1864 while (parent && (parent != fClient->GetDefaultRoot())) {
1878 const Int_t t0 = 200;
1883 if (IsEditableParent()) {
1892 fDoLogStep = fStepLog;
1894 fDoLogStep = !fDoLogStep;
1906 fIgnoreNextFire = 0;
1908 fIgnoreNextFire = 2;
1911 fTimer =
new TRepeatTimer(
this, t0);
1919 fTimer->SetTime(t0);
1929void TGRepeatFireButton::FireButton()
1931 if (fIgnoreNextFire <= 0) {
1933 fWidgetId, (
Long_t) fStep + (fDoLogStep ? 100 : 0));
1942Bool_t TRepeatTimer::Notify()
1944 fButton->FireButton();
1946 if ((
Long64_t)fTime > 20) fTime -= 10;
1964 Error(
"TGNumberEntry",
"arrow_up.xpm not found");
1967 Error(
"TGNumberEntry",
"arrow_down.xpm not found");
1973 "ValueSet(Long_t=0)");
2068 (parm1 >= 1) && (parm1 <= 2)) {
2070 Int_t sign = (parm1 == 1) ? 1 : -1;
2072 Bool_t logstep = (parm2 >= 100);
2076 10000 * (parm1 - 1) + parm2);
2080 ValueSet(10000 * (parm1 - 1) + parm2);
2097 if (entry->
fLayoutManager->IsA() != TGNumberEntryLayout::Class()) {
2113 Emit(
"ValueChanged(Long_t)", val);
2125 Emit(
"ValueSet(Long_t)", val);
2148 Int_t digits = (30*w - 240 -20*
h)/(3*charw) + 3;
2151 Int_t hour, min, sec;
2158 out <<
" TGNumberEntry *";
2190 out << min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2194 out << hour*60 + min <<
"," << digits <<
"," <<
WidgetId()
2198 out << hour*3600 + min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2202 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2206 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2213 std::ios::fmtflags
f = out.flags();
2214 out <<
"0x" << std::hex <<
"U," << digits <<
"," <<
WidgetId()
2224 out <<
");" << std::endl;
2226 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2229 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2230 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2233 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2235 <<
"," <<
GetNumMin() <<
");" << std::endl;
2238 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2242 if (option && strstr(option,
"keep_names"))
2243 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2245 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2252 out <<
GetName() <<
"->GetNumberEntry()->SetToolTipText(" << quote
2253 << tiptext << quote <<
");" << std::endl;
2265 Int_t hour, min, sec;
2272 out <<
" TGNumberEntryField *";
2274 <<
", " <<
WidgetId() <<
", (Double_t) ";
2309 out << hour*60 + min
2313 out << hour*3600 + min*60 + sec
2317 out << yy << mm << dd
2321 out << yy << mm << dd
2328 std::ios::fmtflags
f = out.flags();
2329 out <<
"0x" << std::hex <<
"U"
2339 out <<
");" << std::endl;
2341 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2344 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2345 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2348 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2350 <<
"," <<
GetNumMin() <<
");" << std::endl;
2353 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2357 if (option && strstr(option,
"keep_names"))
2358 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2360 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2363 <<
"->GetDefaultHeight());" << std::endl;
2370 out <<
GetName() <<
"->SetToolTipText(" << quote
2371 << tiptext << quote <<
");" << std::endl;
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.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
static char * DIntToStr(char *text, Long_t l, Bool_t Sec, char Del)
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 char * RealToStr(char *text, const RealInfo_t &ri)
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 char * MIntToStr(char *text, Long_t l, Int_t digits)
static char * IntToHexStr(char *text, ULong_t l)
static char * TranslateToStr(char *text, Long_t l, TGNumberFormat::EStyle style, const RealInfo_t &ri)
Translate a number value to a string.
static char * EliminateGarbage(char *text, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
static Long_t Round(Double_t x)
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, 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, Int_t digits)
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 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 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.
R__EXTERN TSystem * gSystem
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
TGLayoutManager * fLayoutManager
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
virtual UInt_t GetDefaultHeight() const
TGDimension GetSize() const
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
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 InvalidInput(const char *instr)
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Set the value (text format).
virtual Double_t GetNumMin() const
Bool_t fNeedsVerification
virtual void SetFormat(EStyle style, EAttribute attr=kNEAAnyNumber)
Set the numerical format.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
virtual void SetTime(Int_t hour, Int_t min, Int_t sec)
Set the numeric value (time format).
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
virtual void ReturnPressed()
Return was pressed.
virtual Bool_t IsLogStep() const
virtual Bool_t HandleKey(Event_t *event)
Handle keys.
virtual EStyle GetNumStyle() const
virtual Double_t GetNumMax() const
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
Get the numeric value (date format).
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change.
virtual void IncreaseNumber(EStepSize step=kNSSSmall, Int_t sign=1, Bool_t logstep=kFALSE)
Increase the number value.
virtual void SetState(Bool_t state)
Set the active state.
virtual ULong_t GetHexNumber() const
Get the numeric value (hex format).
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 void TextChanged(const char *text=0)
Text has changed message.
virtual void SetLogStep(Bool_t on=kTRUE)
virtual void SetDate(Int_t year, Int_t month, Int_t day)
Set the numeric value (date format).
virtual EAttribute GetNumAttr() const
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 void SetIntNumber(Long_t val)
Set the numeric value (integer representation).
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
virtual Int_t GetCharWidth(const char *text="0") const
Get the text width in pixels.
virtual void Layout()
Layout.
virtual ELimit GetNumLimits() const
virtual void SetHexNumber(ULong_t val)
Set the numeric value (hex format).
virtual TGDimension GetDefaultSize() const
Return the default size of the numeric control box.
virtual void Layout()
Layout the internal GUI elements in use.
virtual Double_t GetNumMax() const
virtual EStyle GetNumStyle() const
virtual ULong_t GetHexNumber() const
virtual ~TGNumberEntry()
Destructs a numeric entry widget.
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
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
TGNumberEntry(const TGNumberEntry &)=delete
virtual ELimit GetNumLimits() const
virtual void SetLogStep(Bool_t on=kTRUE)
Set log steps.
const TGPicture * fPicDown
virtual void ValueChanged(Long_t val)
Emit ValueChanged(Long_t) signal.
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
TGButton * GetButtonDown() const
virtual Long_t GetIntNumber() const
virtual EAttribute GetNumAttr() const
virtual void Modified()
Emit Modified() signal.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process the up/down button messages.
virtual Double_t GetNumMin() const
TGNumberEntryField * fNumericEntry
virtual Double_t GetNumber() const
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
TGButton * GetButtonUp() const
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
const char * GetString() const
const char * GetString() const
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
TGTextBuffer * GetBuffer() const
const char * GetText() const
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text entry widget.
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.
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.
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.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
virtual Bool_t IsEditable() const
const TGWindow * GetParent() const
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Handles synchronous and a-synchronous timer events.
virtual Bool_t Notify()
Notify when timer times out.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
EGEventType fType
of event (see EGEventType)
UInt_t fState
key or button mask
UInt_t fCode
key or button code