133 { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
165 return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
198 if (((
c ==
'.') || (
c ==
',')) &&
243 for (
Int_t i = strlen(
text) - 1; i >= 0; i--) {
258 if (
text[i] ==
'-') {
261 l = 10 *
l + (
text[i] -
'0');
273 while (digits > s.
Length()) {
279 strlcpy(
text, (
const char *) s, 250);
302 strlcpy(
p,
"-", 256);
308 strlcpy(
p,
".", 256-strlen(
p));
314 strlcpy(
p,
"e", 256-strlen(
p));
338 strlcpy(buf,
text,
sizeof(buf));
340 frac = strchr(s,
'.');
342 frac = strchr(s,
',');
344 expo = strchr(s,
'e');
345 minus = strchr(s,
'-');
347 expo = strchr(s,
'E');
349 if ((frac != 0) && (expo != 0) && (frac > expo)) {
352 if ((minus != 0) && ((expo == 0) || (minus < expo))) {
357 if ((frac == 0) && (expo == 0)) {
359 }
else if (frac == 0) {
361 }
else if (expo == 0) {
390 for (
UInt_t i = 0; i < strlen(frac); i++) {
391 if (isdigit(frac[i])) {
427 for (
UInt_t i = 0; i < strlen(s); i++) {
428 if ((s[i] >=
'0') && (s[i] <=
'9')) {
429 w = 16 *
w + (s[i] -
'0');
430 }
else if ((toupper(s[i]) >=
'A') && (toupper(s[i]) <=
'F')) {
431 w = 16 *
w + (toupper(s[i]) -
'A' + 10);
441 const char *
const digits =
"0123456789ABCDEF";
447 *(--
p) = digits[
l % 16];
489 strlcpy(
text, (
const char *) s, 256);
509 strlcpy(
text, (
const char *) s, 256);
525 strlcpy(
text, (
const char *) s, 256);
546 if (!isdigit(*s) && !strchr(Delimiters, *s)) {
549 while ((*s != 0) && ((strchr(Delimiters, *s) == 0) || (maxd2 == 0))) {
550 if (isdigit(*s) && (
d < maxd1)) {
552 n1 = 10 * n1 + (*s -
'0');
558 if (strcspn(s, Delimiters) == strlen(s)) {
562 GetNumbers(s + 1, dummy, n2, maxd2, n3, maxd3,
n,
d, Delimiters);
581 p = strchr(
text,
'.');
583 p = strchr(
text,
',');
589 for (
UInt_t i = 0; i < strlen(
p); i++) {
594 while (found < digits) {
596 strcpy(
p + strlen(
p),
"0");
621 if (Day >
kDays[Month])
623 if ((Month == 2) && (Day > 28) && !
IsLeapYear(Year))
625 return 10000 * Year + 100 * Month + Day;
648 strlcpy(buf,
text,
sizeof(buf));
650 GetNumbers(buf, sign, n1, 12, n2, 2, n3, 0,
".,");
656 strlcpy(buf,
text,
sizeof(buf));
658 GetNumbers(buf, sign, n1, 12, n2, 3, n3, 0,
".,");
664 strlcpy(buf,
text,
sizeof(buf));
666 GetNumbers(buf, sign, n1, 12, n2, 4, n3, 0,
".,");
736 strlcpy(
text, (
const char *) date, 256);
745 strlcpy(
text, (
const char *) date, 256);
798 lower =
Round(10.0 * min);
801 lower =
Round(100.0 * min);
804 lower =
Round(1000.0 * min);
807 lower =
Round(10000.0 * min);
832 upper =
Round(10.0 * max);
835 upper =
Round(100.0 * max);
838 upper =
Round(1000.0 * max);
841 upper =
Round(10000.0 * max);
905 for (
int j = 0; j < 10; j++) {
920 for (
int k = 0; k < 4; k++) {
921 if (rest % 10 != 0) {
971 ri.
fSign = (
x < 0) ? -1 : 1;
978 ri.
fSign = (
x < 0) ? -1 : 1;
986 ri.
fSign = (
x < 0) ? -1 : 1;
996 ri.
fSign = (
x < 0) ? -1 : 1;
1048 if (day >
kDays[month])
1050 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1074 ((day >
kDays[month]) ||
1075 ((month == 2) && (day > 28) && !
IsLeapYear(year)))) {
1083 if ((sign < 0) && (day == 0)) {
1095 if (day >
kDays[month])
1097 if ((month == 2) && (day > 28) && !
IsLeapYear(year)) {
1100 l = 10000 * year + 100 * month + day;
1114 fNeedsVerification(
kFALSE), fNumStyle(kNESReal), fNumAttr(kNEAAnyNumber),
1115 fNumLimits(kNELNoLimits), fNumMin(0.0), fNumMax(1.0)
1132 fNumAttr(
attr), fNumLimits(limits), fNumMin(min), fNumMax(max)
1268 strlcpy(buf,
text,
sizeof(buf));
1390 month = (
l % 10000) / 100;
1430 Int_t sign = stepsign;
1470 rmag = (!logstep) ? 1. : (odd ? 3. : 10. / 3.);
1476 rmag = (!logstep) ? 100. : (odd ? 30. : 100. / 3.);
1479 rmag = (!logstep) ? 1000. : 100.;
1483 rmag = logstep ? 1. / rmag : -rmag;
1492 sign = (sign > 0) ? 1 : -1;
1525 l += sign * 36 * mag;
1527 l += sign * 6 * mag;
1540 l += sign * 36 * mag;
1542 l += sign * 6 * mag;
1547 l = (24 * 3600) - ((-
l) % (24 * 3600));
1549 l =
l % (24 * 3600);
1555 l += sign * 6 * mag;
1568 l += sign * 36 * mag;
1570 l += sign * 6 * mag;
1575 l = (60 * 6000) - ((-
l) % (60 * 6000));
1577 l =
l % (60 * 6000);
1583 l += sign * 6 * mag;
1588 l = (24 * 60) - ((-
l) % (24 * 60));
1604 ll += sign * 4096 * mag / 1000;
1606 ll += sign * 256 * mag / 100;
1608 ll += sign * 16 * mag / 10;
1679 gVirtualX->LookupString(event, tmp,
sizeof(tmp), keysym);
1735 else if (
n && (keysym < 127) && (keysym >= 32) &&
1788 if (instr != outstr) {
1932 const Int_t t0 = 200;
2018 Error(
"TGNumberEntry",
"arrow_up.xpm not found");
2021 Error(
"TGNumberEntry",
"arrow_down.xpm not found");
2027 "ValueSet(Long_t=0)");
2122 (parm1 >= 1) && (parm1 <= 2)) {
2124 Int_t sign = (parm1 == 1) ? 1 : -1;
2126 Bool_t logstep = (parm2 >= 100);
2130 10000 * (parm1 - 1) + parm2);
2134 ValueSet(10000 * (parm1 - 1) + parm2);
2167 Emit(
"ValueChanged(Long_t)", val);
2179 Emit(
"ValueSet(Long_t)", val);
2202 Int_t digits = (30*
w - 240 -20*
h)/(3*charw) + 3;
2205 Int_t hour, min, sec;
2212 out <<
" TGNumberEntry *";
2244 out << min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2249 out << min*6000 + sec*100 + hour <<
"," << digits <<
"," <<
WidgetId()
2253 out << hour*60 + min <<
"," << digits <<
"," <<
WidgetId()
2257 out << hour*3600 + min*60 + sec <<
"," << digits <<
"," <<
WidgetId()
2261 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2265 out << yy << mm << dd <<
"," << digits <<
"," <<
WidgetId()
2272 std::ios::fmtflags
f = out.flags();
2273 out <<
"0x" << std::hex <<
"U," << digits <<
"," <<
WidgetId()
2283 out <<
");" << std::endl;
2285 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2288 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2289 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2292 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2294 <<
"," <<
GetNumMin() <<
");" << std::endl;
2297 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2302 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2304 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2311 out <<
GetName() <<
"->GetNumberEntry()->SetToolTipText(" << quote
2312 << tiptext << quote <<
");" << std::endl;
2324 Int_t hour, min, sec;
2331 out <<
" TGNumberEntryField *";
2333 <<
", " <<
WidgetId() <<
", (Double_t) ";
2369 out << min*6000 + sec*100 + hour
2373 out << hour*60 + min
2377 out << hour*3600 + min*60 + sec
2381 out << yy << mm << dd
2385 out << yy << mm << dd
2392 std::ios::fmtflags
f = out.flags();
2393 out <<
"0x" << std::hex <<
"U"
2403 out <<
");" << std::endl;
2405 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr() <<
");" << std::endl;
2408 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2409 <<
",(TGNumberFormat::ELimit) " <<
GetNumLimits() <<
");" << std::endl;
2412 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2414 <<
"," <<
GetNumMin() <<
");" << std::endl;
2417 out <<
",(TGNumberFormat::EAttribute) " <<
GetNumAttr()
2422 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2424 out <<
" " <<
GetName() <<
"->SetState(kFALSE);" << std::endl;
2427 <<
"->GetDefaultHeight());" << std::endl;
2434 out <<
GetName() <<
"->SetToolTipText(" << quote
2435 << tiptext << quote <<
");" << std::endl;
const Mask_t kKeyMod1Mask
typically the Alt key
Handle_t GContext_t
Graphics context handle.
const Mask_t kKeyShiftMask
const Mask_t kKeyControlMask
ULong_t Pixel_t
Pixel value.
Handle_t FontStruct_t
Pointer to font structure.
constexpr Long_t kMaxLong
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.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char text
R__EXTERN TSystem * gSystem
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
The base class for composite widgets (menu bars, list boxes, etc.).
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.
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
virtual UInt_t GetDefaultHeight() const
TGDimension GetSize() const
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.
virtual Bool_t IsLogStep() const
Is log step enabled?
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 void SetLogStep(Bool_t on=kTRUE)
Set logarithmic steps.
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.
TGNumberEntry is a number entry input widget with up/down buttons.
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.
TGButton * GetButtonDown() const
Get the down button.
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.
TGButton * GetButtonUp() const
Get the up button.
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
A TGTextEntry is a one line text input widget.
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
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.
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.
TRepeatTimer(TGRepeatFireButton *button, Long_t ms)
Bool_t Notify() override
Notify when timer times out and reset the timer.
TGRepeatFireButton * fButton
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.
void Reset()
Reset the timer.
void SetTime(Long_t milliSec)
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