Logo ROOT  
Reference Guide
TGNumberEntry.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Daniel Sigg 03/09/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGNumberEntry, TGNumberEntryField and TGNumberFormat //
15 // //
16 // TGNumberEntry is a number entry input widget with up/down buttons. //
17 // TGNumberEntryField is a number entry input widget. //
18 // TGNumberFormat contains enum types to specify the numeric format. //
19 // //
20 // The number entry widget is based on TGTextEntry but allows only //
21 // numerical input. The widget support numerous formats including //
22 // integers, hex numbers, real numbers, fixed fraction reals and //
23 // time/date formats. The widget also allows to restrict input values //
24 // to non-negative or positive numbers and to specify explicit limits. //
25 // //
26 // The following styles are supported: //
27 // kNESInteger: integer number //
28 // kNESRealOne: real number with one digit (no exponent) //
29 // kNESRealTwo: real number with two digits (no exponent) //
30 // kNESRealThree: real number with three digits (no exponent) //
31 // kNESRealFour: real number with four digits (no exponent) //
32 // kNESReal: arbitrary real number //
33 // kNESDegree: angle in degree:minutes:seconds format //
34 // kNESMinSec: time in minutes:seconds format //
35 // kNESHourMin: time in hour:minutes format //
36 // kNESHourMinSec: time in hour:minutes:seconds format //
37 // kNESDayMYear: date in day/month/year format //
38 // kNESMDayYear: date in month/day/year format //
39 // kNESHex: hex number //
40 // //
41 // The following attributes can be specified: //
42 // kNEAAnyNumber: any number is allowed //
43 // kNEANonNegative: only non-negative numbers are allowed //
44 // kNEAPositive: only positive numbers are allowed //
45 // //
46 // Explicit limits can be specified individually: //
47 // kNELNoLimits: no limits //
48 // kNELLimitMin: lower limit only //
49 // kNELLimitMax upper limit only //
50 // kNELLimitMinMax both lower and upper limits //
51 // //
52 // TGNumberEntryField is a plain vanilla entry field, whereas //
53 // TGNumberEntry adds two small buttons to increase and decrease the //
54 // numerical value in the field. The number entry widgets also support //
55 // using the up and down cursor keys to change the numerical values. //
56 // The step size can be selected with control and shift keys: //
57 // -- small step (1 unit/factor of 3) //
58 // shift medium step (10 units/factor of 10) //
59 // control large step (100 units/factor of 30) //
60 // shift-control huge step (1000 units/factor of 100) //
61 // //
62 // The steps are either linear or logarithmic. The default behaviour //
63 // is set when the entry field is created, but it can be changed by //
64 // pressing the alt key at the same time. //
65 // //
66 // Changing the number in the widget will generate the event: //
67 // kC_TEXTENTRY, kTE_TEXTCHANGED, widget id, 0. //
68 // Hitting the enter key will generate: //
69 // kC_TEXTENTRY, kTE_ENTER, widget id, 0. //
70 // Hitting the tab key will generate: //
71 // kC_TEXTENTRY, kTE_TAB, widget id, 0. //
72 // //
73 //Begin_Html
74 /*
75 <img src="numberentry.jpg">
76 */
77 //End_Html
78 //
79 
80 #include "TGNumberEntry.h"
81 #include "KeySymbols.h"
82 #include "TTimer.h"
83 #include "TSystem.h"
84 #include "TGToolTip.h"
85 #include "TMath.h"
86 #include "TVirtualX.h"
87 #include "strlcpy.h"
88 #include "snprintf.h"
89 
90 #include <cctype>
91 #include <iostream>
92 
93 
98 
99 
100 
101 //////////////////////////////////////////////////////////////////////////
102 // //
103 // Miscellanous routines for handling numeric values <-> strings //
104 // //
105 //////////////////////////////////////////////////////////////////////////
106 
107 //______________________________________________________________________________
108 enum ERealStyle { // Style of real
109  kRSInt = 0, // Integer
110  kRSFrac = 1, // Fraction only
111  kRSExpo = 2, // Exponent only
112  kRSFracExpo = 3 // Fraction and Exponent
113 };
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 
117 struct RealInfo_t {
118  ERealStyle fStyle; // Style of real
119  Int_t fFracDigits; // Number of fractional digits
120  Int_t fFracBase; // Base of fractional digits
121  Int_t fIntNum; // Integer number
122  Int_t fFracNum; // Fraction
123  Int_t fExpoNum; // Exponent
124  Int_t fSign; // Sign
125 };
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 
129 const Double_t kEpsilon = 1E-12;
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 
133 const Int_t kDays[13] =
134  { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
135 
136 ////////////////////////////////////////////////////////////////////////////////
137 
139 {
140  if (x > 0) {
141  return (Long_t) (x + 0.5);
142  } else if (x < 0) {
143  return (Long_t) (x - 0.5);
144  } else {
145  return 0;
146  }
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 
152 {
153  if (x > 0) {
154  return (Long_t) (x + kEpsilon);
155  } else if (x < 0) {
156  return (Long_t) (x - kEpsilon);
157  } else {
158  return 0;
159  }
160 }
161 
162 ////////////////////////////////////////////////////////////////////////////////
163 
164 static Bool_t IsLeapYear(Int_t year)
165 {
166  return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 
173 {
174  if (isdigit(c)) {
175  return kTRUE;
176  }
177  if (isxdigit(c) && (style == TGNumberFormat::kNESHex)) {
178  return kTRUE;
179  }
180  if ((c == '-') && (style == TGNumberFormat::kNESInteger) &&
181  (attr == TGNumberFormat::kNEAAnyNumber)) {
182  return kTRUE;
183  }
184  if ((c == '-') &&
192  (attr == TGNumberFormat::kNEAAnyNumber)) {
193  return kTRUE;
194  }
195  if ((c == '-') && (style == TGNumberFormat::kNESReal)) {
196  return kTRUE;
197  }
198  if (((c == '.') || (c == ',')) &&
210  return kTRUE;
211  }
212  if ((c == ':') &&
219  return kTRUE;
220  }
221  if ((c == '/') &&
224  return kTRUE;
225  }
226  if (((c == 'e') || (c == 'E')) && (style == TGNumberFormat::kNESReal)) {
227  return kTRUE;
228  }
229  return kFALSE;
230 }
231 
232 ////////////////////////////////////////////////////////////////////////////////
233 
234 static char *EliminateGarbage(char *text,
237 {
238  if (text == 0) {
239  return 0;
240  }
241  for (Int_t i = strlen(text) - 1; i >= 0; i--) {
242  if (!IsGoodChar(text[i], style, attr)) {
243  memmove(text + i, text + i + 1, strlen(text) - i);
244  }
245  }
246  return text;
247 }
248 
249 ////////////////////////////////////////////////////////////////////////////////
250 
251 static Long_t IntStr(const char *text)
252 {
253  Long_t l = 0;
254  Int_t sign = 1;
255  for (UInt_t i = 0; i < strlen(text); i++) {
256  if (text[i] == '-') {
257  sign = -1;
258  } else if ((isdigit(text[i])) && (l < kMaxLong)) {
259  l = 10 * l + (text[i] - '0');
260  }
261  }
262  return sign * l;
263 }
264 
265 ////////////////////////////////////////////////////////////////////////////////
266 
267 static char *StrInt(char *text, Long_t i, Int_t digits)
268 {
269  snprintf(text, 250, "%li", TMath::Abs(i));
270  TString s = text;
271  while (digits > s.Length()) {
272  s = "0" + s;
273  }
274  if (i < 0) {
275  s = "-" + s;
276  }
277  strlcpy(text, (const char *) s, 250);
278  return text;
279 }
280 
281 ////////////////////////////////////////////////////////////////////////////////
282 
283 static TString StringInt(Long_t i, Int_t digits)
284 {
285  char text[256];
286  StrInt(text, i, digits);
287  return TString(text);
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 
292 static char *RealToStr(char *text, const RealInfo_t & ri)
293 {
294  char *p = text;
295  if (text == 0) {
296  return 0;
297  }
298  strlcpy(p, "", 256);
299  if (ri.fSign < 0) {
300  strlcpy(p, "-", 256);
301  p++;
302  }
303  StrInt(p, TMath::Abs(ri.fIntNum), 0);
304  p += strlen(p);
305  if ((ri.fStyle == kRSFrac) || (ri.fStyle == kRSFracExpo)) {
306  strlcpy(p, ".", 256-strlen(p));
307  p++;
308  StrInt(p, TMath::Abs(ri.fFracNum), ri.fFracDigits);
309  p += strlen(p);
310  }
311  if ((ri.fStyle == kRSExpo) || (ri.fStyle == kRSFracExpo)) {
312  strlcpy(p, "e", 256-strlen(p));
313  p++;
314  StrInt(p, ri.fExpoNum, 0);
315  p += strlen(p);
316  }
317  return text;
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 
322 static Double_t StrToReal(const char *text, RealInfo_t & ri)
323 {
324  char *s;
325  char *frac;
326  char *expo;
327  char *minus;
328  char buf[256];
329 
330  if ((text == 0) || (!text[0])) {
331  ri.fStyle = kRSInt;
332  ri.fIntNum = 0;
333  ri.fSign = 1;
334  return 0.0;
335  }
336  strlcpy(buf, text, sizeof(buf));
337  s = buf;
338  frac = strchr(s, '.');
339  if (frac == 0) {
340  frac = strchr(s, ',');
341  }
342  expo = strchr(s, 'e');
343  minus = strchr(s, '-');
344  if (expo == 0) {
345  expo = strchr(s, 'E');
346  }
347  if ((frac != 0) && (expo != 0) && (frac > expo)) {
348  frac = 0;
349  }
350  if ((minus != 0) && ((expo == 0) || (minus < expo))) {
351  ri.fSign = -1;
352  } else {
353  ri.fSign = 1;
354  }
355  if ((frac == 0) && (expo == 0)) {
356  ri.fStyle = kRSInt;
357  } else if (frac == 0) {
358  ri.fStyle = kRSExpo;
359  } else if (expo == 0) {
360  ri.fStyle = kRSFrac;
361  } else {
362  ri.fStyle = kRSFracExpo;
363  }
364  if (frac != 0) {
365  *frac = 0;
366  frac++;
367  }
368  if (expo != 0) {
369  *expo = 0;
370  expo++;
371  }
372  ri.fIntNum = TMath::Abs(IntStr(s));
373  if (expo != 0) {
374  ri.fExpoNum = IntStr(expo);
375  } else {
376  ri.fExpoNum = 0;
377  }
378  if (ri.fExpoNum > 999) {
379  ri.fExpoNum = 999;
380  }
381  if (ri.fExpoNum < -999) {
382  ri.fExpoNum = -999;
383  }
384  ri.fFracDigits = 0;
385  ri.fFracBase = 1;
386  ri.fFracNum = 0;
387  if (frac != 0) {
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');
392  ri.fFracDigits++;
393  ri.fFracBase *= 10;
394  }
395  }
396  }
397  }
398  if ((ri.fFracDigits == 0) && (ri.fStyle == kRSFrac)) {
399  ri.fStyle = kRSInt;
400  }
401  if ((ri.fFracDigits == 0) && (ri.fStyle == kRSFracExpo)) {
402  ri.fStyle = kRSExpo;
403  }
404  switch (ri.fStyle) {
405  case kRSInt:
406  return ri.fSign * ri.fIntNum;
407  case kRSFrac:
408  return ri.fSign *
409  (ri.fIntNum + (Double_t) ri.fFracNum / ri.fFracBase);
410  case kRSExpo:
411  return ri.fSign * (ri.fIntNum * TMath::Power(10, ri.fExpoNum));
412  case kRSFracExpo:
413  return ri.fSign * (ri.fIntNum +
414  (Double_t) ri.fFracNum / ri.fFracBase) *
415  TMath::Power(10, ri.fExpoNum);
416  }
417  return 0;
418 }
419 
420 ////////////////////////////////////////////////////////////////////////////////
421 
422 static ULong_t HexStrToInt(const char *s)
423 {
424  ULong_t w = 0;
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);
430  }
431  }
432  return w;
433 }
434 
435 ////////////////////////////////////////////////////////////////////////////////
436 
437 static char *IntToHexStr(char *text, ULong_t l)
438 {
439  const char *const digits = "0123456789ABCDEF";
440  char buf[64];
441  char *p = buf + 62;
442  // coverity[secure_coding]
443  strcpy(p, "");
444  while (l > 0) {
445  *(--p) = digits[l % 16];
446  l /= 16;
447  }
448  if (!p[0]) {
449  // coverity[secure_coding]
450  strcpy(text, "0");
451  } else {
452  // coverity[secure_coding]
453  strcpy(text, p);
454  }
455  return text;
456 }
457 
458 ////////////////////////////////////////////////////////////////////////////////
459 
460 static char *MIntToStr(char *text, Long_t l, Int_t digits)
461 {
462  TString s;
463  Int_t base;
464  switch (digits) {
465  case 0:
466  base = 1;
467  break;
468  case 1:
469  base = 10;
470  break;
471  case 2:
472  base = 100;
473  break;
474  case 3:
475  base = 1000;
476  break;
477  default:
478  case 4:
479  base = 10000;
480  break;
481  }
482  s = StringInt(TMath::Abs(l) / base, 0) + "." +
483  StringInt(TMath::Abs(l) % base, digits);
484  if (l < 0) {
485  s = "-" + s;
486  }
487  strlcpy(text, (const char *) s, 256);
488  return text;
489 }
490 
491 ////////////////////////////////////////////////////////////////////////////////
492 
493 static char *DIntToStr(char *text, Long_t l, Bool_t Sec, char Del)
494 {
495  TString s;
496  if (Sec) {
497  s = StringInt(TMath::Abs(l) / 3600, 0) + Del +
498  StringInt((TMath::Abs(l) % 3600) / 60, 2) + Del +
499  StringInt(TMath::Abs(l) % 60, 2);
500  } else {
501  s = StringInt(TMath::Abs(l) / 60, 0) + Del +
502  StringInt(TMath::Abs(l) % 60, 2);
503  }
504  if (l < 0) {
505  s = "-" + s;
506  }
507  strlcpy(text, (const char *) s, 256);
508  return text;
509 }
510 
511 ////////////////////////////////////////////////////////////////////////////////
512 
513 static void GetNumbers(const char *s, Int_t & Sign,
514  Long_t & n1, Int_t maxd1,
515  Long_t & n2, Int_t maxd2,
516  Long_t & n3, Int_t maxd3, const char *Delimiters)
517 {
518  Long_t n;
519  Long_t d = 0;
520  Sign = +1;
521  n1 = 0;
522  n2 = 0;
523  n3 = 0;
524  if (*s == '-') {
525  Sign = -1;
526  s++;
527  }
528  if (!isdigit(*s) && !strchr(Delimiters, *s)) {
529  return;
530  }
531  while ((*s != 0) && ((strchr(Delimiters, *s) == 0) || (maxd2 == 0))) {
532  if (isdigit(*s) && (d < maxd1)) {
533  if (n1 < kMaxLong) {
534  n1 = 10 * n1 + (*s - '0');
535  }
536  d++;
537  }
538  s++;
539  }
540  if (strcspn(s, Delimiters) == strlen(s)) {
541  return;
542  }
543  Int_t dummy = 0;
544  GetNumbers(s + 1, dummy, n2, maxd2, n3, maxd3, n, d, Delimiters);
545 }
546 
547 ////////////////////////////////////////////////////////////////////////////////
548 
550 {
551  while (TMath::Abs(l) >= Max) {
552  l /= 10;
553  }
554  return l;
555 }
556 
557 ////////////////////////////////////////////////////////////////////////////////
558 
559 static void AppendFracZero(char *text, Int_t digits)
560 {
561  char *p;
562  Int_t found = 0;
563  p = strchr(text, '.');
564  if (p == 0) {
565  p = strchr(text, ',');
566  }
567  if (p == 0) {
568  return;
569  }
570  p++;
571  for (UInt_t i = 0; i < strlen(p); i++) {
572  if (isdigit(*p)) {
573  found++;
574  }
575  }
576  while (found < digits) {
577  // coverity[secure_coding]
578  strcpy(p + strlen(p), "0");
579  found++;
580  }
581 }
582 
583 ////////////////////////////////////////////////////////////////////////////////
584 /// Create a number entry with year/month/day information.
585 
586 static Long_t MakeDateNumber(const char * /*text*/, Long_t Day,
587  Long_t Month, Long_t Year)
588 {
589  Day = TMath::Abs(Day);
590  Month = TMath::Abs(Month);
591  Year = TMath::Abs(Year);
592  if (Year < 100) {
593  Year += 2000;
594  }
595  Month = GetSignificant(Month, 100);
596  if (Month > 12)
597  Month = 12;
598  if (Month == 0)
599  Month = 1;
600  Day = GetSignificant(Day, 100);
601  if (Day == 0)
602  Day = 1;
603  if (Day > kDays[Month])
604  Day = kDays[Month];
605  if ((Month == 2) && (Day > 28) && !IsLeapYear(Year))
606  Day = 28;
607  return 10000 * Year + 100 * Month + Day;
608 }
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 /// Translate a string to a number value.
612 
613 static Long_t TranslateToNum(const char *text,
614  TGNumberFormat::EStyle style, RealInfo_t & ri)
615 {
616  Long_t n1;
617  Long_t n2;
618  Long_t n3;
619  Int_t sign;
620  switch (style) {
622  GetNumbers(text, sign, n1, 12, n2, 0, n3, 0, "");
623  return sign * n1;
625  GetNumbers(text, sign, n1, 12, n2, 1, n3, 0, ".,");
626  return sign * (10 * n1 + GetSignificant(n2, 10));
628  {
629  char buf[256];
630  strlcpy(buf, text, sizeof(buf));
631  AppendFracZero(buf, 2);
632  GetNumbers(buf, sign, n1, 12, n2, 2, n3, 0, ".,");
633  return sign * (100 * n1 + GetSignificant(n2, 100));
634  }
636  {
637  char buf[256];
638  strlcpy(buf, text, sizeof(buf));
639  AppendFracZero(buf, 3);
640  GetNumbers(buf, sign, n1, 12, n2, 3, n3, 0, ".,");
641  return sign * (1000 * n1 + GetSignificant(n2, 1000));
642  }
644  {
645  char buf[256];
646  strlcpy(buf, text, sizeof(buf));
647  AppendFracZero(buf, 4);
648  GetNumbers(buf, sign, n1, 12, n2, 4, n3, 0, ".,");
649  return sign * (10000 * n1 + GetSignificant(n2, 10000));
650  }
652  return (Long_t) StrToReal(text, ri);
654  GetNumbers(text, sign, n1, 12, n2, 2, n3, 2, ".,:");
655  return sign * (3600 * n1 + 60 * GetSignificant(n2, 60) +
656  GetSignificant(n3, 60));
658  GetNumbers(text, sign, n1, 12, n2, 2, n3, 2, ".,:");
659  return 3600 * n1 + 60 * GetSignificant(n2, 60) +
660  GetSignificant(n3, 60);
662  GetNumbers(text, sign, n1, 12, n2, 2, n3, 0, ".,:");
663  return sign * (60 * n1 + GetSignificant(n2, 60));
665  GetNumbers(text, sign, n1, 12, n2, 2, n3, 0, ".,:");
666  return 60 * n1 + GetSignificant(n2, 60);
668  GetNumbers(text, sign, n1, 2, n2, 2, n3, 4, ".,/");
669  return MakeDateNumber(text, n1, n2, n3);
671  GetNumbers(text, sign, n2, 2, n1, 2, n3, 4, ".,/");
672  return MakeDateNumber(text, n1, n2, n3);
674  return HexStrToInt(text);
675  }
676  return 0;
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Translate a number value to a string.
681 
682 static char *TranslateToStr(char *text, Long_t l,
683  TGNumberFormat::EStyle style, const RealInfo_t & ri)
684 {
685  switch (style) {
687  return StrInt(text, l, 0);
689  return MIntToStr(text, l, 1);
691  return MIntToStr(text, l, 2);
693  return MIntToStr(text, l, 3);
695  return MIntToStr(text, l, 4);
697  return RealToStr(text, ri);
699  return DIntToStr(text, l, kTRUE, '.');
701  return DIntToStr(text, l % (24 * 3600), kTRUE, ':');
703  return DIntToStr(text, l, kFALSE, ':');
705  return DIntToStr(text, l % (24 * 60), kFALSE, ':');
707  {
708  TString date =
709  StringInt(TMath::Abs(l) % 100, 0) + "/" +
710  StringInt((TMath::Abs(l) / 100) % 100, 0) + "/" +
711  StringInt(TMath::Abs(l) / 10000, 0);
712  strlcpy(text, (const char *) date, 256);
713  return text;
714  }
716  {
717  TString date =
718  StringInt((TMath::Abs(l) / 100) % 100, 0) + "/" +
719  StringInt(TMath::Abs(l) % 100, 0) + "/" +
720  StringInt(TMath::Abs(l) / 10000, 0);
721  strlcpy(text, (const char *) date, 256);
722  return text;
723  }
725  return IntToHexStr(text, (ULong_t) l);
726  }
727  return 0;
728 }
729 
730 ////////////////////////////////////////////////////////////////////////////////
731 /// Convert to double format.
732 
733 static Double_t RealToDouble(const RealInfo_t ri)
734 {
735  switch (ri.fStyle) {
736  // Integer type real
737  case kRSInt:
738  return (Double_t) ri.fSign * ri.fIntNum;
739  // Fraction type real
740  case kRSFrac:
741  return (Double_t) ri.fSign * ((Double_t) TMath::Abs(ri.fIntNum) +
742  (Double_t) ri.fFracNum / ri.fFracBase);
743  // Exponent only
744  case kRSExpo:
745  return (Double_t) ri.fSign * ri.fIntNum *
746  TMath::Power(10, ri.fExpoNum);
747  // Fraction and exponent
748  case kRSFracExpo:
749  return (Double_t) ri.fSign * ((Double_t) TMath::Abs(ri.fIntNum) +
750  (Double_t) ri.fFracNum /
751  ri.fFracBase) * TMath::Power(10,
752  ri.fExpoNum);
753  }
754  return 0;
755 }
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 /// Check min/max limits for the set value.
759 
761  TGNumberFormat::ELimit limits,
762  Double_t min, Double_t max)
763 {
764  if ((limits == TGNumberFormat::kNELNoLimits) ||
766  return;
767  }
768  // check min
769  if ((limits == TGNumberFormat::kNELLimitMin) ||
770  (limits == TGNumberFormat::kNELLimitMinMax)) {
771  Long_t lower;
772  switch (style) {
774  lower = Round(10.0 * min);
775  break;
777  lower = Round(100.0 * min);
778  break;
780  lower = Round(1000.0 * min);
781  break;
783  lower = Round(10000.0 * min);
784  break;
786  lower = (ULong_t) Round(min);
787  break;
788  default:
789  lower = Round(min);
790  break;
791  }
793  if (l < lower)
794  l = lower;
795  } else {
796  if (lower < 0)
797  lower = 0;
798  if ((ULong_t) l < (ULong_t) lower)
799  l = lower;
800  }
801  }
802  // check max
803  if ((limits == TGNumberFormat::kNELLimitMax) ||
804  (limits == TGNumberFormat::kNELLimitMinMax)) {
805  Long_t upper;
806  switch (style) {
808  upper = Round(10.0 * max);
809  break;
811  upper = Round(100.0 * max);
812  break;
814  upper = Round(1000.0 * max);
815  break;
817  upper = Round(10000.0 * max);
818  break;
820  upper = (ULong_t) Round(max);
821  break;
822  default:
823  upper = Round(max);
824  break;
825  }
827  if (l > upper)
828  l = upper;
829  } else {
830  if (upper < 0)
831  upper = 0;
832  if ((ULong_t) l > (ULong_t) upper)
833  l = upper;
834  }
835  }
836 }
837 
838 ////////////////////////////////////////////////////////////////////////////////
839 /// Convert to double format.
840 
841 static void IncreaseReal(RealInfo_t & ri, Double_t mag, Bool_t logstep,
842  TGNumberFormat::ELimit limits =
844  Double_t max = 1)
845 {
846  Double_t x = RealToDouble(ri);
847 
848  // apply step
849  if (logstep) {
850  x *= mag;
851  } else {
852  switch (ri.fStyle) {
853  case kRSInt:
854  x = x + mag;
855  break;
856  case kRSFrac:
857  x = x + mag / ri.fFracBase;
858  break;
859  case kRSExpo:
860  x = x + mag * TMath::Power(10, ri.fExpoNum);
861  break;
862  case kRSFracExpo:
863  x = x + (mag / ri.fFracBase) * TMath::Power(10, ri.fExpoNum);
864  break;
865  }
866  }
867  // check min
868  if ((limits == TGNumberFormat::kNELLimitMin) ||
869  (limits == TGNumberFormat::kNELLimitMinMax)) {
870  if (x < min)
871  x = min;
872  }
873  // check max
874  if ((limits == TGNumberFormat::kNELLimitMax) ||
875  (limits == TGNumberFormat::kNELLimitMinMax)) {
876  if (x > max)
877  x = max;
878  }
879  // check format after log step
880  if ((x != 0) && logstep && (TMath::Abs(mag) > kEpsilon)) {
881  for (int j = 0; j < 10; j++) {
882  // Integer: special case
883  if ((ri.fStyle == kRSInt) && (TMath::Abs(x) < 1) &&
884  (TMath::Abs(x) > kEpsilon)) {
885  ri.fStyle = kRSFrac;
886  ri.fFracDigits = 1;
887  ri.fFracBase = 10;
888  continue;
889  }
890  if ((ri.fStyle == kRSInt) && (TMath::Abs(x) > 10000)) {
891  ri.fStyle = kRSFracExpo;
892  ri.fExpoNum = 4;
893  ri.fFracDigits = 4;
894  ri.fFracBase = 10000;
895  Long_t rest = Round(TMath::Abs(x)) % 10000;
896  for (int k = 0; k < 4; k++) {
897  if (rest % 10 != 0) {
898  break;
899  }
900  ri.fFracDigits--;
901  ri.fFracBase /= 10;
902  rest /= 10;
903  }
904  if (ri.fFracDigits == 0) {
905  ri.fStyle = kRSExpo;
906  }
907  continue;
908  }
909  if (ri.fStyle == kRSInt)
910  break;
911 
912  // caluclate first digit
913  Double_t y;
914  if ((ri.fStyle == kRSExpo) || (ri.fStyle == kRSFracExpo)) {
915  y = TMath::Abs(x) * TMath::Power(10, -ri.fExpoNum);
916  } else {
917  y = TMath::Abs(x);
918  }
919  // adjust exponent if num < 1
920  if ((Truncate(y) == 0) && (y > 0.001)) {
921  if ((ri.fStyle == kRSExpo) || (ri.fStyle == kRSFracExpo)) {
922  ri.fExpoNum--;
923  } else {
924  ri.fStyle = kRSFracExpo;
925  ri.fExpoNum = -1;
926  }
927  continue;
928  }
929  // adjust exponent if num > 10
930  if (Truncate(y) >= 10) {
931  if ((ri.fStyle == kRSExpo) || (ri.fStyle == kRSFracExpo)) {
932  ri.fExpoNum++;
933  } else {
934  ri.fStyle = kRSFracExpo;
935  ri.fExpoNum = 1;
936  }
937  continue;
938  }
939  break;
940  }
941  }
942  // convert back to RealInfo_t
943  switch (ri.fStyle) {
944  // Integer type real
945  case kRSInt:
946  {
947  ri.fSign = (x < 0) ? -1 : 1;
948  ri.fIntNum = Round(TMath::Abs(x));
949  break;
950  }
951  // Fraction type real
952  case kRSFrac:
953  {
954  ri.fSign = (x < 0) ? -1 : 1;
955  ri.fIntNum = Truncate(TMath::Abs(x));
956  ri.fFracNum = Round((TMath::Abs(x) - TMath::Abs(ri.fIntNum)) * ri.fFracBase);
957  break;
958  }
959  // Exponent only
960  case kRSExpo:
961  {
962  ri.fSign = (x < 0) ? -1 : 1;
963  ri.fIntNum = Round(TMath::Abs(x) * TMath::Power(10, -ri.fExpoNum));
964  if (ri.fIntNum == 0) {
965  ri.fStyle = kRSInt;
966  }
967  break;
968  }
969  // Fraction and exponent
970  case kRSFracExpo:
971  {
972  ri.fSign = (x < 0) ? -1 : 1;
973  Double_t y = TMath::Abs(x) * TMath::Power(10, -ri.fExpoNum);
974  ri.fIntNum = Truncate(y);
975  ri.fFracNum = Round((y - TMath::Abs(ri.fIntNum)) * ri.fFracBase);
976  if ((ri.fIntNum == 0) && (ri.fFracNum == 0)) {
977  ri.fStyle = kRSFrac;
978  }
979  break;
980  }
981  }
982 
983  // check if the back conversion violated limits
984  if (limits != TGNumberFormat::kNELNoLimits) {
985  x = RealToDouble(ri);
986  // check min
987  if ((limits == TGNumberFormat::kNELLimitMin) ||
988  (limits == TGNumberFormat::kNELLimitMinMax)) {
989  if (x < min) {
990  char text[256];
991  snprintf(text, 255, "%g", min);
992  StrToReal(text, ri);
993  }
994  }
995  // check max
996  if ((limits == TGNumberFormat::kNELLimitMax) ||
997  (limits == TGNumberFormat::kNELLimitMinMax)) {
998  if (x > max) {
999  char text[256];
1000  snprintf(text, 255, "%g", max);
1001  StrToReal(text, ri);
1002  }
1003  }
1004  }
1005 }
1006 
1007 ////////////////////////////////////////////////////////////////////////////////
1008 /// Change year/month/day format.
1009 
1011 {
1012  Long_t year;
1013  Long_t month;
1014  Long_t day;
1015 
1016  // get year/month/day format
1017  year = l / 10000;
1018  month = (TMath::Abs(l) / 100) % 100;
1019  if (month > 12)
1020  month = 12;
1021  if (month == 0)
1022  month = 1;
1023  day = TMath::Abs(l) % 100;
1024  if (day > kDays[month])
1025  day = kDays[month];
1026  if ((month == 2) && (day > 28) && !IsLeapYear(year)) {
1027  day = 28;
1028  }
1029  if (day == 0)
1030  day = 0;
1031 
1032  // apply step
1033  if (step == TGNumberFormat::kNSSHuge) {
1034  year += sign * 10;
1035  } else if (step == TGNumberFormat::kNSSLarge) {
1036  year += sign;
1037  } else if (step == TGNumberFormat::kNSSMedium) {
1038  month += sign;
1039  if (month > 12) {
1040  month = 1;
1041  year++;
1042  }
1043  if (month < 1) {
1044  month = 12;
1045  year--;
1046  }
1047  } else if (step == TGNumberFormat::kNSSSmall) {
1048  day += sign;
1049  if ((sign > 0) &&
1050  ((day > kDays[month]) ||
1051  ((month == 2) && (day > 28) && !IsLeapYear(year)))) {
1052  day = 1;
1053  month++;
1054  if (month > 12) {
1055  month = 1;
1056  year++;
1057  }
1058  }
1059  if ((sign < 0) && (day == 0)) {
1060  month--;
1061  if (month < 1) {
1062  month = 12;
1063  year--;
1064  }
1065  day = kDays[month];
1066  }
1067  }
1068  // check again for valid date
1069  if (year < 0)
1070  year = 0;
1071  if (day > kDays[month])
1072  day = kDays[month];
1073  if ((month == 2) && (day > 28) && !IsLeapYear(year)) {
1074  day = 28;
1075  }
1076  l = 10000 * year + 100 * month + day;
1077 }
1078 
1079 
1080 
1081 
1082 ////////////////////////////////////////////////////////////////////////////////
1083 /// Constructs a number entry field.
1084 
1086  Double_t val, GContext_t norm,
1087  FontStruct_t font, UInt_t option,
1088  ULong_t back)
1089  : TGTextEntry(p, new TGTextBuffer(), id, norm, font, option, back),
1090  fNeedsVerification(kFALSE), fNumStyle(kNESReal), fNumAttr(kNEAAnyNumber),
1091  fNumLimits(kNELNoLimits), fNumMin(0.0), fNumMax(1.0)
1092 {
1093  fStepLog = kFALSE;
1095  SetNumber(val);
1097 }
1098 
1099 ////////////////////////////////////////////////////////////////////////////////
1100 /// Constructs a number entry field.
1101 
1103  Int_t id, Double_t val,
1104  EStyle style, EAttribute attr,
1105  ELimit limits, Double_t min,
1106  Double_t max)
1107  : TGTextEntry(parent, "", id), fNeedsVerification(kFALSE), fNumStyle(style),
1108  fNumAttr(attr), fNumLimits(limits), fNumMin(min), fNumMax(max)
1109 {
1110  fStepLog = kFALSE;
1112  SetNumber(val);
1114 }
1115 
1116 ////////////////////////////////////////////////////////////////////////////////
1117 /// Set the numeric value (floating point representation).
1118 
1120 {
1121  switch (fNumStyle) {
1122  case kNESInteger:
1123  SetIntNumber(Round(val));
1124  break;
1125  case kNESRealOne:
1126  SetIntNumber(Round(10.0 * val));
1127  break;
1128  case kNESRealTwo:
1129  SetIntNumber(Round(100.0 * val));
1130  break;
1131  case kNESRealThree:
1132  SetIntNumber(Round(1000.0 * val));
1133  break;
1134  case kNESRealFour:
1135  SetIntNumber(Round(10000.0 * val));
1136 
1137  break;
1138  case kNESReal:
1139  {
1140  char text[256];
1141  snprintf(text, 255, "%g", val);
1142  SetText(text);
1143  break;
1144  }
1145  case kNESDegree:
1146  SetIntNumber(Round(val));
1147  break;
1148  case kNESHourMinSec:
1149  SetIntNumber(Round(val));
1150  break;
1151  case kNESMinSec:
1152  SetIntNumber(Round(val));
1153  break;
1154  case kNESHourMin:
1155  SetIntNumber(Round(val));
1156  break;
1157  case kNESDayMYear:
1158  SetIntNumber(Round(val));
1159  break;
1160  case kNESMDayYear:
1161  SetIntNumber(Round(val));
1162  break;
1163  case kNESHex:
1164  SetIntNumber((UInt_t) (TMath::Abs(val) + 0.5));
1165  break;
1166  }
1167 }
1168 
1169 ////////////////////////////////////////////////////////////////////////////////
1170 /// Set the numeric value (integer representation).
1171 
1173 {
1174  char text[256];
1175  RealInfo_t ri;
1176  if (fNumStyle == kNESReal) {
1177  TranslateToStr(text, val, kNESInteger, ri);
1178  } else {
1179  TranslateToStr(text, val, fNumStyle, ri);
1180  }
1181  SetText(text);
1182 }
1183 
1184 ////////////////////////////////////////////////////////////////////////////////
1185 /// Set the numeric value (time format).
1186 
1188 {
1189  switch (fNumStyle) {
1190  case kNESHourMinSec:
1191  SetIntNumber(3600 * TMath::Abs(hour) + 60 * TMath::Abs(min) +
1192  TMath::Abs(sec));
1193  break;
1194  case kNESMinSec:
1195  {
1196  SetIntNumber(60 * min + sec);
1197  break;
1198  }
1199  case kNESHourMin:
1200  SetIntNumber(60 * TMath::Abs(hour) + TMath::Abs(min));
1201  break;
1202  default:
1203  break;
1204  }
1205 }
1206 
1207 ////////////////////////////////////////////////////////////////////////////////
1208 /// Set the numeric value (date format).
1209 
1211 {
1212  switch (fNumStyle) {
1213  case kNESDayMYear:
1214  case kNESMDayYear:
1215  {
1216  SetIntNumber(10000 * TMath::Abs(year) + 100 * TMath::Abs(month) +
1217  TMath::Abs(day));
1218  }
1219  default:
1220  {
1221  break;
1222  }
1223  }
1224 }
1225 
1226 ////////////////////////////////////////////////////////////////////////////////
1227 /// Set the numeric value (hex format).
1228 
1230 {
1231  SetIntNumber((Long_t) val);
1232 }
1233 
1234 ////////////////////////////////////////////////////////////////////////////////
1235 /// Set the value (text format).
1236 
1237 void TGNumberEntryField::SetText(const char *text, Bool_t emit)
1238 {
1239  char buf[256];
1240  strlcpy(buf, text, sizeof(buf));
1242  TGTextEntry::SetText(buf, emit);
1244 }
1245 
1246 ////////////////////////////////////////////////////////////////////////////////
1247 /// Get the numeric value (floating point representation).
1248 
1250 {
1251  switch (fNumStyle) {
1252  case kNESInteger:
1253  return (Double_t) GetIntNumber();
1254  case kNESRealOne:
1255  return (Double_t) GetIntNumber() / 10.0;
1256  case kNESRealTwo:
1257  return (Double_t) GetIntNumber() / 100.0;
1258  case kNESRealThree:
1259  return (Double_t) GetIntNumber() / 1000.0;
1260  case kNESRealFour:
1261  return (Double_t) GetIntNumber() / 10000.0;
1262  case kNESReal:
1263  {
1264  char text[256];
1265  RealInfo_t ri;
1266  strlcpy(text, GetText(), sizeof(text));
1267  return StrToReal(text, ri);
1268  }
1269  case kNESDegree:
1270  return (Double_t) GetIntNumber();
1271  case kNESHourMinSec:
1272  return (Double_t) GetIntNumber();
1273  case kNESMinSec:
1274  return (Double_t) GetIntNumber();
1275  case kNESHourMin:
1276  return (Double_t) GetIntNumber();
1277  case kNESDayMYear:
1278  return (Double_t) GetIntNumber();
1279  case kNESMDayYear:
1280  return (Double_t) GetIntNumber();
1281  case kNESHex:
1282  return (Double_t) (ULong_t) GetIntNumber();
1283  }
1284  return 0;
1285 }
1286 
1287 ////////////////////////////////////////////////////////////////////////////////
1288 /// Get the numeric value (integer representation).
1289 
1291 {
1292  RealInfo_t ri;
1293  return TranslateToNum(GetText(), fNumStyle, ri);
1294 }
1295 
1296 ////////////////////////////////////////////////////////////////////////////////
1297 /// Get the numeric value (time format).
1298 
1299 void TGNumberEntryField::GetTime(Int_t & hour, Int_t & min, Int_t & sec) const
1300 {
1301  switch (fNumStyle) {
1302  case kNESHourMinSec:
1303  {
1304  Long_t l = GetIntNumber();
1305  hour = TMath::Abs(l) / 3600;
1306  min = (TMath::Abs(l) % 3600) / 60;
1307  sec = TMath::Abs(l) % 60;
1308  break;
1309  }
1310  case kNESMinSec:
1311  {
1312  Long_t l = GetIntNumber();
1313  hour = 0;
1314  min = TMath::Abs(l) / 60;
1315  sec = TMath::Abs(l) % 60;
1316  if (l < 0) {
1317  min *= -1;
1318  sec *= -1;
1319  }
1320  break;
1321  }
1322  case kNESHourMin:
1323  {
1324  Long_t l = GetIntNumber();
1325  hour = TMath::Abs(l) / 60;
1326  min = TMath::Abs(l) % 60;
1327  sec = 0;
1328  break;
1329  }
1330  default:
1331  {
1332  hour = 0;
1333  min = 0;
1334  sec = 0;
1335  break;
1336  }
1337  }
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Get the numeric value (date format).
1342 
1343 void TGNumberEntryField::GetDate(Int_t & year, Int_t & month, Int_t & day) const
1344 {
1345  switch (fNumStyle) {
1346  case kNESDayMYear:
1347  case kNESMDayYear:
1348  {
1349  Long_t l = GetIntNumber();
1350  year = l / 10000;
1351  month = (l % 10000) / 100;
1352  day = l % 100;
1353  break;
1354  }
1355  default:
1356  {
1357  year = 0;
1358  month = 0;
1359  day = 0;
1360  break;
1361  }
1362  }
1363 }
1364 
1365 ////////////////////////////////////////////////////////////////////////////////
1366 /// Get the numeric value (hex format).
1367 
1369 {
1370  return (ULong_t) GetIntNumber();
1371 }
1372 
1373 ////////////////////////////////////////////////////////////////////////////////
1374 /// Get the text width in pixels.
1375 
1377 {
1378  return gVirtualX->TextWidth(fFontStruct, text, strlen(text));
1379 }
1380 
1381 ////////////////////////////////////////////////////////////////////////////////
1382 /// Increase the number value.
1383 
1385  Int_t stepsign, Bool_t logstep)
1386 {
1387  Long_t l = 0;
1388  RealInfo_t ri;
1389  Long_t mag = 0;
1390  Double_t rmag = 0.0;
1391  Int_t sign = stepsign;
1392 
1393  // svae old text field
1394  TString oldtext = GetText();
1395  // Get number
1396  if (fNumStyle != kNESReal) {
1397  l = GetIntNumber();
1398  } else {
1399  StrToReal(oldtext, ri);
1400  }
1401 
1402  // magnitude of step
1403  if ((fNumStyle == kNESDegree) || (fNumStyle == kNESHourMinSec) ||
1404  (fNumStyle == kNESMinSec) || (fNumStyle == kNESHourMin) ||
1406  (fNumStyle == kNESHex)) {
1407  logstep = kFALSE;
1408  switch (step) {
1409  case kNSSSmall:
1410  mag = 1;
1411  break;
1412  case kNSSMedium:
1413  mag = 10;
1414  break;
1415  case kNSSLarge:
1416  mag = 100;
1417  break;
1418  case kNSSHuge:
1419  mag = 1000;
1420  break;
1421  }
1422  } else {
1423  Int_t msd = TMath::Abs((fNumStyle == kNESReal) ? ri.fIntNum : l);
1424  while (msd >= 10)
1425  msd /= 10;
1426  Bool_t odd = (msd < 3);
1427  if (sign < 0)
1428  odd = !odd;
1429  switch (step) {
1430  case kNSSSmall:
1431  rmag = (!logstep) ? 1. : (odd ? 3. : 10. / 3.);
1432  break;
1433  case kNSSMedium:
1434  rmag = 10.;
1435  break;
1436  case kNSSLarge:
1437  rmag = (!logstep) ? 100. : (odd ? 30. : 100. / 3.);
1438  break;
1439  case kNSSHuge:
1440  rmag = (!logstep) ? 1000. : 100.;
1441  break;
1442  }
1443  if (sign < 0)
1444  rmag = logstep ? 1. / rmag : -rmag;
1445  }
1446 
1447  // sign of step
1448  if (sign == 0) {
1449  logstep = kFALSE;
1450  rmag = 0;
1451  mag = 0;
1452  } else {
1453  sign = (sign > 0) ? 1 : -1;
1454  }
1455  // add/multiply step
1456  switch (fNumStyle) {
1457  case kNESInteger:
1458  case kNESRealOne:
1459  case kNESRealTwo:
1460  case kNESRealThree:
1461  case kNESRealFour:
1462  {
1463  l = logstep ? Round(l * rmag) : Round(l + rmag);
1465  if ((l < 0) && (fNumAttr == kNEANonNegative))
1466  l = 0;
1467  if ((l <= 0) && (fNumAttr == kNEAPositive))
1468  l = 1;
1469  break;
1470  }
1471  case kNESReal:
1472  {
1473  IncreaseReal(ri, rmag, logstep, fNumLimits, fNumMin, fNumMax);
1474  if (((fNumAttr == kNEANonNegative) ||
1475  (fNumAttr == kNEAPositive)) && (ri.fSign < 0)) {
1476  ri.fIntNum = 0;
1477  ri.fFracNum = 0;
1478  ri.fExpoNum = 0;
1479  ri.fSign = 1;
1480  }
1481  break;
1482  }
1483  case kNESDegree:
1484  {
1485  if (mag > 60)
1486  l += sign * 36 * mag;
1487  else if (mag > 6)
1488  l += sign * 6 * mag;
1489  else
1490  l += sign * mag;
1492  if ((l < 0) && (fNumAttr == kNEANonNegative))
1493  l = 0;
1494  if ((l <= 0) && (fNumAttr == kNEAPositive))
1495  l = 1;
1496  break;
1497  }
1498  case kNESHourMinSec:
1499  {
1500  if (mag > 60)
1501  l += sign * 36 * mag;
1502  else if (mag > 6)
1503  l += sign * 6 * mag;
1504  else
1505  l += sign * mag;
1507  if (l < 0)
1508  l = (24 * 3600) - ((-l) % (24 * 3600));
1509  if (l > 0)
1510  l = l % (24 * 3600);
1511  break;
1512  }
1513  case kNESMinSec:
1514  {
1515  if (mag > 6)
1516  l += sign * 6 * mag;
1517  else
1518  l += sign * mag;
1520  if ((l < 0) && (fNumAttr == kNEANonNegative))
1521  l = 0;
1522  if ((l <= 0) && (fNumAttr == kNEAPositive))
1523  l = 1;
1524  break;
1525  }
1526  case kNESHourMin:
1527  {
1528  if (mag > 6)
1529  l += sign * 6 * mag;
1530  else
1531  l += sign * mag;
1533  if (l < 0)
1534  l = (24 * 60) - ((-l) % (24 * 60));
1535  if (l > 0)
1536  l = l % (24 * 60);
1537  break;
1538  }
1539  case kNESDayMYear:
1540  case kNESMDayYear:
1541  {
1542  IncreaseDate(l, step, sign);
1544  break;
1545  }
1546  case kNESHex:
1547  {
1548  ULong_t ll = (ULong_t) l;
1549  if (mag > 500)
1550  ll += sign * 4096 * mag / 1000;
1551  else if (mag > 50)
1552  ll += sign * 256 * mag / 100;
1553  else if (mag > 5)
1554  ll += sign * 16 * mag / 10;
1555  else
1556  ll += sign * mag;
1557  l = (Long_t) ll;
1559  break;
1560  }
1561  }
1562  if (fNumStyle != kNESReal) {
1563  SetIntNumber(l);
1564  } else {
1565  char buf[256];
1566  RealToStr(buf, ri);
1567  SetText(buf);
1568  }
1569 }
1570 
1571 ////////////////////////////////////////////////////////////////////////////////
1572 /// Set the numerical format.
1573 
1575 {
1576  Double_t val = GetNumber();
1577  fNumStyle = style;
1578  fNumAttr = attr;
1579  if ((fNumAttr != kNEAAnyNumber) && (val < 0))
1580  val = 0;
1581  SetNumber(val);
1582  // make sure we have a valid number by increasaing it by 0
1584 }
1585 
1586 ////////////////////////////////////////////////////////////////////////////////
1587 /// Set the numerical limits.
1588 
1590  Double_t min, Double_t max)
1591 {
1592  Double_t val = GetNumber();
1593  fNumLimits = limits;
1594  fNumMin = min;
1595  fNumMax = max;
1596  SetNumber(val);
1597  // make sure we have a valid number by increasaing it by 0
1599 }
1600 
1601 ////////////////////////////////////////////////////////////////////////////////
1602 /// Set the active state.
1603 
1605 {
1606  if (!state && fNeedsVerification) {
1607  // make sure we have a valid number by increasaing it by 0
1609  }
1610  TGTextEntry::SetState(state);
1611 }
1612 
1613 ////////////////////////////////////////////////////////////////////////////////
1614 /// Handle keys.
1615 
1617 {
1618  if (!IsEnabled()) {
1619  return TGTextEntry::HandleKey(event);
1620  }
1621 
1622  Int_t n;
1623  char tmp[10];
1624  UInt_t keysym;
1625  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
1626  n = strlen(tmp);
1627 
1628  // intercept up key
1629  if ((EKeySym) keysym == kKey_Up) {
1630  // Get log step / alt key
1631  Bool_t logstep = fStepLog;
1632  if (event->fState & kKeyMod1Mask)
1633  logstep = !logstep;
1634  // shift-cntrl-up
1635  if ((event->fState & kKeyShiftMask) &&
1636  (event->fState & kKeyControlMask)) {
1637  IncreaseNumber(kNSSHuge, 1, logstep);
1638  }
1639  // cntrl-up
1640  else if (event->fState & kKeyControlMask) {
1641  IncreaseNumber(kNSSLarge, 1, logstep);
1642 
1643  }
1644  // shift-up
1645  else if (event->fState & kKeyShiftMask) {
1646  IncreaseNumber(kNSSMedium, 1, logstep);
1647  }
1648 
1649  // up
1650  else {
1651  IncreaseNumber(kNSSSmall, 1, logstep);
1652  }
1653  return kTRUE;
1654  }
1655  // intercept down key
1656  else if ((EKeySym) keysym == kKey_Down) {
1657  // Get log step / alt key
1658  Bool_t logstep = fStepLog;
1659  if (event->fState & kKeyMod1Mask)
1660  logstep = !logstep;
1661  // shift-cntrl-down
1662  if ((event->fState & kKeyShiftMask) &&
1663  (event->fState & kKeyControlMask)) {
1664  IncreaseNumber(kNSSHuge, -1, logstep);
1665  }
1666  // cntrl-down
1667  else if (event->fState & kKeyControlMask) {
1668  IncreaseNumber(kNSSLarge, -1, logstep);
1669  }
1670  // shift-down
1671  else if (event->fState & kKeyShiftMask) {
1672  IncreaseNumber(kNSSMedium, -1, logstep);
1673  }
1674  // down
1675  else {
1676  IncreaseNumber(kNSSSmall, -1, logstep);
1677  }
1678  return kTRUE;
1679  }
1680  // intercept printable characters
1681  else if (n && (keysym < 127) && (keysym >= 32) &&
1682  ((EKeySym) keysym != kKey_Delete) &&
1683  ((EKeySym) keysym != kKey_Backspace) &&
1684  ((event->fState & kKeyControlMask) == 0)) {
1685  if (IsGoodChar(tmp[0], fNumStyle, fNumAttr)) {
1686  return TGTextEntry::HandleKey(event);
1687  } else {
1688  return kTRUE;
1689  }
1690  }
1691  // otherwise use default behaviour
1692  else {
1693  return TGTextEntry::HandleKey(event);
1694  }
1695 }
1696 
1697 ////////////////////////////////////////////////////////////////////////////////
1698 /// Handle focus change.
1699 
1701 {
1702  if (IsEnabled() && fNeedsVerification &&
1703  (event->fCode == kNotifyNormal) &&
1704  (event->fState != kNotifyPointer) && (event->fType == kFocusOut)) {
1705  // make sure we have a valid number by increasing it by 0
1707  }
1708 
1709  return TGTextEntry::HandleFocusChange(event);
1710 }
1711 
1712 ////////////////////////////////////////////////////////////////////////////////
1713 /// Text has changed message.
1714 
1716 {
1719 }
1720 
1721 ////////////////////////////////////////////////////////////////////////////////
1722 /// Return was pressed.
1723 
1725 {
1726  TString instr, outstr;
1727  instr = TGTextEntry::GetBuffer()->GetString();
1728 
1729  if (fNeedsVerification) {
1730  // make sure we have a valid number by increasing it by 0
1732  }
1733  outstr = TGTextEntry::GetBuffer()->GetString();
1734  if (instr != outstr) {
1735  InvalidInput(instr);
1736  gVirtualX->Bell(0);
1737  }
1739 }
1740 
1741 ////////////////////////////////////////////////////////////////////////////////
1742 /// Layout.
1743 
1745 {
1746  if (GetAlignment() == kTextRight) {
1747  End(kFALSE);
1748  } else {
1749  Home(kFALSE);
1750  }
1751 }
1752 
1753 //////////////////////////////////////////////////////////////////////////
1754 // //
1755 // TGNumberEntryLayout //
1756 // //
1757 // Layout manager for number entry widget //
1758 // //
1759 //////////////////////////////////////////////////////////////////////////
1760 
1761 
1762 ////////////////////////////////////////////////////////////////////////////////
1763 /// Layout the internal GUI elements in use.
1764 
1766 {
1767  if (fBox == 0) {
1768  return;
1769  }
1770  UInt_t w = fBox->GetWidth();
1771  UInt_t h = fBox->GetHeight();
1772  UInt_t upw = 2 * h / 3;
1773  UInt_t uph = h / 2;
1774  Int_t upx = (w > h) ? (Int_t) w - (Int_t) upw : -1000;
1775  Int_t upy = 0;
1776  Int_t downx = (w > h) ? (Int_t) w - (Int_t) upw : -1000;
1777  Int_t downy = h / 2;
1778  UInt_t downw = upw;
1779  UInt_t downh = h - downy;
1780  UInt_t numw = (w > h) ? w - upw : w;
1781  UInt_t numh = h;
1782  if (fBox->GetNumberEntry())
1783  fBox->GetNumberEntry()->MoveResize(0, 0, numw, numh);
1784  if (fBox->GetButtonUp())
1785  fBox->GetButtonUp()->MoveResize(upx, upy, upw, uph);
1786  if (fBox->GetButtonDown())
1787  fBox->GetButtonDown()->MoveResize(downx, downy, downw, downh);
1788 }
1789 
1790 ////////////////////////////////////////////////////////////////////////////////
1791 /// Return the default size of the numeric control box.
1792 
1794 {
1795  return fBox->GetSize();
1796 }
1797 
1798 
1799 
1800 //////////////////////////////////////////////////////////////////////////
1801 // //
1802 // TRepeatTimer //
1803 // //
1804 // Timer for numeric control box buttons. //
1805 // //
1806 //////////////////////////////////////////////////////////////////////////
1807 
1808 class TGRepeatFireButton;
1809 
1810 ////////////////////////////////////////////////////////////////////////////////
1811 
1812 class TRepeatTimer : public TTimer {
1813 private:
1814  TGRepeatFireButton *fButton; // Fire button
1815 
1816 public:
1817  TRepeatTimer(TGRepeatFireButton * button, Long_t ms)
1818  : TTimer(ms, kTRUE), fButton(button) { }
1819  virtual Bool_t Notify();
1820 };
1821 
1822 
1823 
1824 //////////////////////////////////////////////////////////////////////////
1825 // //
1826 // TRepeatFireButton //
1827 // //
1828 // Picture button which fires repeatly as long as the button is pressed //
1829 // //
1830 //////////////////////////////////////////////////////////////////////////
1831 
1832 ////////////////////////////////////////////////////////////////////////////////
1833 
1834 class TGRepeatFireButton : public TGPictureButton {
1835 protected:
1836  TRepeatTimer *fTimer; // the timer
1837  Int_t fIgnoreNextFire; // flag for skipping next
1838  TGNumberFormat::EStepSize fStep; // increment/decrement step
1839  Bool_t fStepLog; // logarithmic step flag
1840  Bool_t fDoLogStep; // flag for using logarithmic step
1841 
1842  Bool_t IsEditableParent();
1843 
1844 public:
1845  TGRepeatFireButton(const TGWindow *p, const TGPicture *pic,
1846  Int_t id, Bool_t logstep)
1847  : TGPictureButton(p, pic, id), fTimer(0), fIgnoreNextFire(0),
1848  fStep(TGNumberFormat::kNSSSmall), fStepLog(logstep), fDoLogStep(logstep)
1850  virtual ~TGRepeatFireButton() { delete fTimer; }
1851 
1852  virtual Bool_t HandleButton(Event_t *event);
1853  void FireButton();
1854  virtual void SetLogStep(Bool_t on = kTRUE) { fStepLog = on; }
1855 };
1856 
1857 ////////////////////////////////////////////////////////////////////////////////
1858 /// Return kTRUE if one of the parents is in edit mode.
1859 
1860 Bool_t TGRepeatFireButton::IsEditableParent()
1861 {
1862  TGWindow *parent = (TGWindow*)GetParent();
1863 
1864  while (parent && (parent != fClient->GetDefaultRoot())) {
1865  if (parent->IsEditable()) {
1866  return kTRUE;
1867  }
1868  parent = (TGWindow*)parent->GetParent();
1869  }
1870  return kFALSE;
1871 }
1872 
1873 ////////////////////////////////////////////////////////////////////////////////
1874 /// Handle messages for number entry widget according to the user input.
1875 
1876 Bool_t TGRepeatFireButton::HandleButton(Event_t * event)
1877 {
1878  const Int_t t0 = 200;
1879  if (fTip)
1880  fTip->Hide();
1881 
1882  // disable button handling while guibuilding
1883  if (IsEditableParent()) {
1884  return kTRUE;
1885  }
1886 
1887  if (fState == kButtonDisabled)
1888  return kTRUE;
1889 
1890  if (event->fType == kButtonPress) {
1891  // Get log step / alt key
1892  fDoLogStep = fStepLog;
1893  if (event->fState & kKeyMod1Mask)
1894  fDoLogStep = !fDoLogStep;
1895  if ((event->fState & kKeyShiftMask) &&
1896  (event->fState & kKeyControlMask)) {
1897  fStep = TGNumberFormat::kNSSHuge;
1898  } else if (event->fState & kKeyControlMask) {
1899  fStep = TGNumberFormat::kNSSLarge;
1900  } else if (event->fState & kKeyShiftMask) {
1902  } else {
1903  fStep = TGNumberFormat::kNSSSmall;
1904  }
1905  SetState(kButtonDown);
1906  fIgnoreNextFire = 0;
1907  FireButton();
1908  fIgnoreNextFire = 2;
1909 
1910  if (fTimer == 0) {
1911  fTimer = new TRepeatTimer(this, t0);
1912  }
1913  fTimer->Reset();
1914  gSystem->AddTimer(fTimer);
1915  } else {
1916  SetState(kButtonUp);
1917  if (fTimer != 0) {
1918  fTimer->Remove();
1919  fTimer->SetTime(t0);
1920  }
1921  }
1922 
1923  return kTRUE;
1924 }
1925 
1926 ////////////////////////////////////////////////////////////////////////////////
1927 /// Process messages for fire button.
1928 
1929 void TGRepeatFireButton::FireButton()
1930 {
1931  if (fIgnoreNextFire <= 0) {
1932  SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_BUTTON),
1933  fWidgetId, (Long_t) fStep + (fDoLogStep ? 100 : 0));
1934  } else {
1935  fIgnoreNextFire--;
1936  }
1937 }
1938 
1939 ////////////////////////////////////////////////////////////////////////////////
1940 /// Notify when timer times out and reset the timer.
1941 
1942 Bool_t TRepeatTimer::Notify()
1943 {
1944  fButton->FireButton();
1945  Reset();
1946  if ((Long64_t)fTime > 20) fTime -= 10;
1947  return kFALSE;
1948 }
1949 
1950 ////////////////////////////////////////////////////////////////////////////////
1951 /// Constructs a numeric entry widget.
1952 
1954  Double_t val, Int_t wdigits, Int_t id,
1955  EStyle style,
1956  EAttribute attr,
1957  ELimit limits, Double_t min, Double_t max)
1958  : TGCompositeFrame(parent, 10 * wdigits, 25), fButtonToNum(kTRUE)
1959 {
1960  fWidgetId = id;
1961  fMsgWindow = parent;
1962  fPicUp = fClient->GetPicture("arrow_up.xpm");
1963  if (!fPicUp)
1964  Error("TGNumberEntry", "arrow_up.xpm not found");
1965  fPicDown = fClient->GetPicture("arrow_down.xpm");
1966  if (!fPicDown)
1967  Error("TGNumberEntry", "arrow_down.xpm not found");
1968 
1969  // create gui elements
1970  fNumericEntry = new TGNumberEntryField(this, id, val, style, attr,
1971  limits, min, max);
1972  fNumericEntry->Connect("ReturnPressed()", "TGNumberEntry", this,
1973  "ValueSet(Long_t=0)");
1975  AddFrame(fNumericEntry, 0);
1976  fButtonUp = new TGRepeatFireButton(this, fPicUp, 1,
1978  fButtonUp->Associate(this);
1979  AddFrame(fButtonUp, 0);
1980  fButtonDown = new TGRepeatFireButton(this, fPicDown, 2,
1982  fButtonDown->Associate(this);
1983  AddFrame(fButtonDown, 0);
1984 
1985  // resize
1987  Int_t charw = fNumericEntry->GetCharWidth("0123456789");
1988  Int_t w = charw * TMath::Abs(wdigits) / 10 + 8 + 2 * h / 3;
1990  MapSubwindows();
1991  Resize(w, h);
1993 }
1994 
1995 ////////////////////////////////////////////////////////////////////////////////
1996 /// Destructs a numeric entry widget.
1997 
1999 {
2000  gClient->FreePicture(fPicUp);
2001  gClient->FreePicture(fPicDown);
2002 
2003  Cleanup();
2004 }
2005 
2006 ////////////////////////////////////////////////////////////////////////////////
2007 /// Make w the window that will receive the generated messages.
2008 
2010 {
2013 }
2014 
2015 ////////////////////////////////////////////////////////////////////////////////
2016 /// Set log steps.
2017 
2019 {
2021  ((TGRepeatFireButton *) fButtonUp)->SetLogStep(fNumericEntry->IsLogStep());
2022  ((TGRepeatFireButton *) fButtonDown)->SetLogStep(fNumericEntry->IsLogStep());
2023 }
2024 
2025 ////////////////////////////////////////////////////////////////////////////////
2026 /// Set the active state.
2027 
2029 {
2030  if (enable) {
2034  } else {
2038  }
2039 }
2040 
2041 ////////////////////////////////////////////////////////////////////////////////
2042 /// Send button messages to the number field (true) or parent widget (false).
2043 /// When the message is sent to the parent widget, it is responsible to change
2044 /// the numerical value accordingly. This can be useful to implement cursors
2045 /// which move from data point to data point. For the message being sent
2046 /// see ProcessMessage().
2047 
2049 {
2050  fButtonToNum = state;
2051 }
2052 
2053 ////////////////////////////////////////////////////////////////////////////////
2054 /// Process the up/down button messages. If fButtonToNum is false the
2055 /// following message is sent: kC_COMMAND, kCM_BUTTON, widget id, param
2056 /// param % 100 is the step size
2057 /// param % 10000 / 100 != 0 indicates log step
2058 /// param / 10000 != 0 indicates button down
2059 
2061 {
2062  switch (GET_MSG(msg)) {
2063  case kC_COMMAND:
2064  {
2065  if ((GET_SUBMSG(msg) == kCM_BUTTON) &&
2066  (parm1 >= 1) && (parm1 <= 2)) {
2067  if (fButtonToNum) {
2068  Int_t sign = (parm1 == 1) ? 1 : -1;
2069  EStepSize step = (EStepSize) (parm2 % 100);
2070  Bool_t logstep = (parm2 >= 100);
2071  fNumericEntry->IncreaseNumber(step, sign, logstep);
2072  } else {
2074  10000 * (parm1 - 1) + parm2);
2075  ValueChanged(10000 * (parm1 - 1) + parm2);
2076  }
2077  // Emit a signal needed by pad editor
2078  ValueSet(10000 * (parm1 - 1) + parm2);
2079  }
2080  break;
2081  }
2082  }
2083  return kTRUE;
2084 }
2085 
2086 
2087 ////////////////////////////////////////////////////////////////////////////////
2088 /// Return layout manager.
2089 
2091 {
2092  TGNumberEntry *entry = (TGNumberEntry*)this;
2093 
2094  if (entry->fLayoutManager->IsA() != TGNumberEntryLayout::Class()) {
2095  entry->SetLayoutManager(new TGNumberEntryLayout(entry));
2096  }
2097 
2098  return entry->fLayoutManager;
2099 }
2100 
2101 ////////////////////////////////////////////////////////////////////////////////
2102 /// Emit ValueChanged(Long_t) signal. This signal is emitted when
2103 /// fButtonToNum is false. The val has the following meaning:
2104 /// val % 100 is the step size
2105 /// val % 10000 / 100 != 0 indicates log step
2106 /// val / 10000 != 0 indicates button down
2107 
2109 {
2110  Emit("ValueChanged(Long_t)", val);
2111 }
2112 
2113 ////////////////////////////////////////////////////////////////////////////////
2114 /// Emit ValueSet(Long_t) signal. This signal is emitted when the
2115 /// number entry value is changed. The val has the following meaning:
2116 /// val % 100 is the step size
2117 /// val % 10000 / 100 != 0 indicates log step
2118 /// val / 10000 != 0 indicates button down
2119 
2121 {
2122  Emit("ValueSet(Long_t)", val);
2123 }
2124 
2125 ////////////////////////////////////////////////////////////////////////////////
2126 /// Save a number entry widget as a C++ statement(s) on output stream out.
2127 
2128 void TGNumberEntry::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2129 {
2130  char quote = '"';
2131 
2132  // to calculate the digits parameter
2133  Int_t w = fNumericEntry->GetWidth();
2135  Int_t charw = fNumericEntry->GetCharWidth("0123456789");
2136  Int_t digits = (30*w - 240 -20*h)/(3*charw) + 3;
2137 
2138  // for time format
2139  Int_t hour, min, sec;
2140  GetTime(hour, min, sec);
2141 
2142  // for date format
2143  Int_t yy, mm, dd;
2144  GetDate(yy, mm, dd);
2145 
2146  out << " TGNumberEntry *";
2147  out << GetName() << " = new TGNumberEntry(" << fParent->GetName() << ", (Double_t) ";
2148  switch (GetNumStyle()){
2149  case kNESInteger:
2150  out << GetIntNumber() << "," << digits << "," << WidgetId()
2151  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2152  break;
2153  case kNESRealOne:
2154  out << GetNumber() << "," << digits << "," << WidgetId()
2155  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2156  break;
2157  case kNESRealTwo:
2158  out << GetNumber() << "," << digits << "," << WidgetId()
2159  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2160  break;
2161  case kNESRealThree:
2162  out << GetNumber() << "," << digits << "," << WidgetId()
2163  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2164  break;
2165  case kNESRealFour:
2166  out << GetNumber() << "," << digits << "," << WidgetId()
2167  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2168  break;
2169  case kNESReal:
2170  out << GetNumber() << "," << digits << "," << WidgetId()
2171  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2172  break;
2173  case kNESDegree:
2174  out << GetIntNumber() << "," << digits << "," << WidgetId()
2175  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2176  break;
2177  case kNESMinSec:
2178  out << min*60 + sec << "," << digits << "," << WidgetId()
2179  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2180  break;
2181  case kNESHourMin:
2182  out << hour*60 + min << "," << digits << "," << WidgetId()
2183  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2184  break;
2185  case kNESHourMinSec:
2186  out << hour*3600 + min*60 + sec << "," << digits << "," << WidgetId()
2187  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2188  break;
2189  case kNESDayMYear:
2190  out << yy << mm << dd << "," << digits << "," << WidgetId()
2191  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2192  break;
2193  case kNESMDayYear:
2194  out << yy << mm << dd << "," << digits << "," << WidgetId()
2195  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2196  break;
2197  case kNESHex:
2198  { char hex[256];
2199  ULong_t l = GetHexNumber();
2200  IntToHexStr(hex, l);
2201  std::ios::fmtflags f = out.flags(); // store flags
2202  out << "0x" << std::hex << "U," << digits << "," << WidgetId()
2203  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2204  out.flags( f ); // restore flags (reset std::hex)
2205  break;
2206  }
2207  }
2208  if (GetNumMax() ==1) {
2209  if (GetNumMin() == 0) {
2210  if (GetNumLimits() == kNELNoLimits) {
2211  if (GetNumAttr() == kNEAAnyNumber) {
2212  out << ");" << std::endl;
2213  } else {
2214  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr() << ");" << std::endl;
2215  }
2216  } else {
2217  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2218  << ",(TGNumberFormat::ELimit) " << GetNumLimits() << ");" << std::endl;
2219  }
2220  } else {
2221  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2222  << ",(TGNumberFormat::ELimit) " << GetNumLimits()
2223  << "," << GetNumMin() << ");" << std::endl;
2224  }
2225  } else {
2226  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2227  << ",(TGNumberFormat::ELimit) " << GetNumLimits()
2228  << "," << GetNumMin() << "," << GetNumMax() << ");" << std::endl;
2229  }
2230  if (option && strstr(option, "keep_names"))
2231  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
2233  out << " " << GetName() << "->SetState(kFALSE);" << std::endl;
2234 
2235  TGToolTip *tip = GetNumberEntry()->GetToolTip();
2236  if (tip) {
2237  TString tiptext = tip->GetText()->GetString();
2238  tiptext.ReplaceAll("\n", "\\n");
2239  out << " ";
2240  out << GetName() << "->GetNumberEntry()->SetToolTipText(" << quote
2241  << tiptext << quote << ");" << std::endl;
2242  }
2243 }
2244 
2245 ////////////////////////////////////////////////////////////////////////////////
2246 /// Save a number entry widget as a C++ statement(s) on output stream out.
2247 
2248 void TGNumberEntryField::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2249 {
2250  char quote = '"';
2251 
2252  // for time format
2253  Int_t hour, min, sec;
2254  GetTime(hour, min, sec);
2255 
2256  // for date format
2257  Int_t yy, mm, dd;
2258  GetDate(yy, mm, dd);
2259 
2260  out << " TGNumberEntryField *";
2261  out << GetName() << " = new TGNumberEntryField(" << fParent->GetName()
2262  << ", " << WidgetId() << ", (Double_t) ";
2263  switch (GetNumStyle()){
2264  case kNESInteger:
2265  out << GetIntNumber()
2266  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2267  break;
2268  case kNESRealOne:
2269  out << GetNumber()
2270  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2271  break;
2272  case kNESRealTwo:
2273  out << GetNumber()
2274  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2275  break;
2276  case kNESRealThree:
2277  out << GetNumber()
2278  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2279  break;
2280  case kNESRealFour:
2281  out << GetNumber()
2282  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2283  break;
2284  case kNESReal:
2285  out << GetNumber()
2286  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2287  break;
2288  case kNESDegree:
2289  out << GetIntNumber()
2290  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2291  break;
2292  case kNESMinSec:
2293  out << min*60 + sec
2294  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2295  break;
2296  case kNESHourMin:
2297  out << hour*60 + min
2298  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2299  break;
2300  case kNESHourMinSec:
2301  out << hour*3600 + min*60 + sec
2302  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2303  break;
2304  case kNESDayMYear:
2305  out << yy << mm << dd
2306  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2307  break;
2308  case kNESMDayYear:
2309  out << yy << mm << dd
2310  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2311  break;
2312  case kNESHex:
2313  { char hex[256];
2314  ULong_t l = GetHexNumber();
2315  IntToHexStr(hex, l);
2316  std::ios::fmtflags f = out.flags(); // store flags
2317  out << "0x" << std::hex << "U"
2318  << ",(TGNumberFormat::EStyle) " << GetNumStyle();
2319  out.flags( f ); // restore flags (reset std::hex)
2320  break;
2321  }
2322  }
2323  if (GetNumMax() ==1) {
2324  if (GetNumMin() == 0) {
2325  if (GetNumLimits() == kNELNoLimits) {
2326  if (GetNumAttr() == kNEAAnyNumber) {
2327  out << ");" << std::endl;
2328  } else {
2329  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr() << ");" << std::endl;
2330  }
2331  } else {
2332  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2333  << ",(TGNumberFormat::ELimit) " << GetNumLimits() << ");" << std::endl;
2334  }
2335  } else {
2336  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2337  << ",(TGNumberFormat::ELimit) " << GetNumLimits()
2338  << "," << GetNumMin() << ");" << std::endl;
2339  }
2340  } else {
2341  out << ",(TGNumberFormat::EAttribute) " << GetNumAttr()
2342  << ",(TGNumberFormat::ELimit) " << GetNumLimits()
2343  << "," << GetNumMin() << "," << GetNumMax() << ");" << std::endl;
2344  }
2345  if (option && strstr(option, "keep_names"))
2346  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
2347  if (!IsEnabled())
2348  out << " " << GetName() << "->SetState(kFALSE);" << std::endl;
2349 
2350  out << " " << GetName() << "->Resize("<< GetWidth() << "," << GetName()
2351  << "->GetDefaultHeight());" << std::endl;
2352 
2353  TGToolTip *tip = GetToolTip();
2354  if (tip) {
2355  TString tiptext = tip->GetText()->GetString();
2356  tiptext.ReplaceAll("\n", "\\n");
2357  out << " ";
2358  out << GetName() << "->SetToolTipText(" << quote
2359  << tiptext << quote << ");" << std::endl;
2360  }
2361 }
kKey_Down
@ kKey_Down
Definition: KeySymbols.h:49
TGNumberFormat::ELimit
ELimit
Definition: TGNumberEntry.h:61
c
#define c(i)
Definition: RSha256.hxx:119
l
auto * l
Definition: textangle.C:4
Event_t::fType
EGEventType fType
Definition: GuiTypes.h:174
TGNumberFormat::kNELLimitMax
@ kNELLimitMax
Definition: TGNumberEntry.h:64
TGNumberFormat::kNESMinSec
@ kNESMinSec
Definition: TGNumberEntry.h:53
TGNumberEntryField::SetHexNumber
virtual void SetHexNumber(ULong_t val)
Set the numeric value (hex format).
Definition: TGNumberEntry.cxx:1229
n
const Int_t n
Definition: legend1.C:16
IntStr
static Long_t IntStr(const char *text)
Definition: TGNumberEntry.cxx:251
CheckMinMax
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.
Definition: TGNumberEntry.cxx:760
Event_t::fState
UInt_t fState
Definition: GuiTypes.h:180
GET_MSG
Int_t GET_MSG(Long_t val)
Definition: WidgetMessageTypes.h:112
StrToReal
static Double_t StrToReal(const char *text, RealInfo_t &ri)
Definition: TGNumberEntry.cxx:322
TGNumberEntry::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process the up/down button messages.
Definition: TGNumberEntry.cxx:2060
TGNumberEntry::GetLayoutManager
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
Definition: TGNumberEntry.cxx:2090
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:250
IncreaseDate
static void IncreaseDate(Long_t &l, TGNumberFormat::EStepSize step, Int_t sign)
Change year/month/day format.
Definition: TGNumberEntry.cxx:1010
TranslateToNum
static Long_t TranslateToNum(const char *text, TGNumberFormat::EStyle style, RealInfo_t &ri)
Translate a string to a number value.
Definition: TGNumberEntry.cxx:613
TGNumberEntryLayout
Definition: TGNumberEntry.h:288
kKey_Delete
@ kKey_Delete
Definition: KeySymbols.h:39
TGWindow
Definition: TGWindow.h:31
TGNumberEntryField::GetDate
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
Get the numeric value (date format).
Definition: TGNumberEntry.cxx:1343
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGNumberEntry::fPicUp
const TGPicture * fPicUp
Definition: TGNumberEntry.h:165
StrInt
static char * StrInt(char *text, Long_t i, Int_t digits)
Definition: TGNumberEntry.cxx:267
TGTextEntry::SetText
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.
Definition: TGTextEntry.cxx:623
kRSInt
@ kRSInt
Definition: TGNumberEntry.cxx:115
TGNumberFormat::kNELLimitMinMax
@ kNELLimitMinMax
Definition: TGNumberEntry.h:65
snprintf
#define snprintf
Definition: civetweb.c:1540
TGNumberFormat::kNESDegree
@ kNESDegree
Definition: TGNumberEntry.h:52
TGNumberEntry::~TGNumberEntry
virtual ~TGNumberEntry()
Destructs a numeric entry widget.
Definition: TGNumberEntry.cxx:1998
kEpsilon
const Double_t kEpsilon
Definition: TGNumberEntry.cxx:129
TGPicture
Definition: TGPicture.h:36
f
#define f(i)
Definition: RSha256.hxx:122
TGNumberEntry::ValueChanged
virtual void ValueChanged(Long_t val)
Emit ValueChanged(Long_t) signal.
Definition: TGNumberEntry.cxx:2108
MIntToStr
static char * MIntToStr(char *text, Long_t l, Int_t digits)
Definition: TGNumberEntry.cxx:460
TGDimension
Definition: TGDimension.h:27
TGNumberEntryLayout::Layout
virtual void Layout()
Layout the internal GUI elements in use.
Definition: TGNumberEntry.cxx:1765
TGNumberFormat::kNSSMedium
@ kNSSMedium
Definition: TGNumberEntry.h:70
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TGNumberEntryLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return the default size of the numeric control box.
Definition: TGNumberEntry.cxx:1793
TGNumberFormat::kNSSHuge
@ kNSSHuge
Definition: TGNumberEntry.h:72
TGNumberFormat::kNSSSmall
@ kNSSSmall
Definition: TGNumberEntry.h:69
TGNumberEntryField::IncreaseNumber
virtual void IncreaseNumber(EStepSize step=kNSSSmall, Int_t sign=1, Bool_t logstep=kFALSE)
Increase the number value.
Definition: TGNumberEntry.cxx:1384
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
GetSignificant
static Long_t GetSignificant(Long_t l, Int_t Max)
Definition: TGNumberEntry.cxx:549
Truncate
static Long_t Truncate(Double_t x)
Definition: TGNumberEntry.cxx:151
kButtonDown
@ kButtonDown
Definition: TGButton.h:60
kKey_Up
@ kKey_Up
Definition: KeySymbols.h:47
TGTextEntry::SetAlignment
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
Definition: TGTextEntry.cxx:578
TGFrame::GetSize
TGDimension GetSize() const
Definition: TGFrame.h:255
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
kNotifyNormal
@ kNotifyNormal
Definition: GuiTypes.h:218
EKeySym
EKeySym
Definition: KeySymbols.h:25
TGNumberEntry::fButtonToNum
Bool_t fButtonToNum
Definition: TGNumberEntry.h:175
TGTextEntry::SetState
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Definition: TGTextEntry.cxx:510
TGNumberFormat::kNESHourMin
@ kNESHourMin
Definition: TGNumberEntry.h:54
IntToHexStr
static char * IntToHexStr(char *text, ULong_t l)
Definition: TGNumberEntry.cxx:437
HexStrToInt
static ULong_t HexStrToInt(const char *s)
Definition: TGNumberEntry.cxx:422
FontStruct_t
Handle_t FontStruct_t
Definition: GuiTypes.h:38
TGNumberFormat::kNESRealThree
@ kNESRealThree
Definition: TGNumberEntry.h:49
TGNumberFormat::kNEAAnyNumber
@ kNEAAnyNumber
Definition: TGNumberEntry.h:56
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TGToolTip::GetText
const TGString * GetText() const
Get the tool tip text.
Definition: TGToolTip.cxx:427
TGNumberEntryField::fNumStyle
EStyle fNumStyle
Definition: TGNumberEntry.h:78
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TGWindow::kEditDisableLayout
@ kEditDisableLayout
Definition: TGWindow.h:61
TGNumberEntryField::Layout
virtual void Layout()
Layout.
Definition: TGNumberEntry.cxx:1744
TGCompositeFrame::Cleanup
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:952
TGFrame::GetDefaultHeight
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:216
TGNumberFormat::kNEAPositive
@ kNEAPositive
Definition: TGNumberEntry.h:58
kButtonUp
@ kButtonUp
Definition: TGButton.h:59
TGWindow::kEditDisable
@ kEditDisable
Definition: TGWindow.h:58
TGTextEntry::fFontStruct
FontStruct_t fFontStruct
Definition: TGTextEntry.h:56
TGNumberFormat::kNEANonNegative
@ kNEANonNegative
Definition: TGNumberEntry.h:57
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TGNumberEntryField::TGNumberEntryField
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.
Definition: TGNumberEntry.cxx:1085
Int_t
int Int_t
Definition: RtypesCore.h:45
TGNumberEntryField::InvalidInput
virtual void InvalidInput(const char *instr)
Definition: TGNumberEntry.h:148
TGNumberEntryField::GetCharWidth
virtual Int_t GetCharWidth(const char *text="0") const
Get the text width in pixels.
Definition: TGNumberEntry.cxx:1376
TGNumberEntryField::fNumAttr
EAttribute fNumAttr
Definition: TGNumberEntry.h:79
TGNumberFormat::kNESReal
@ kNESReal
Definition: TGNumberEntry.h:51
TGNumberEntryField::SetDate
virtual void SetDate(Int_t year, Int_t month, Int_t day)
Set the numeric value (date format).
Definition: TGNumberEntry.cxx:1210
x
Double_t x[n]
Definition: legend1.C:17
TGWindow::kEditDisableHeight
@ kEditDisableHeight
Definition: TGWindow.h:63
TGToolTip
Definition: TGToolTip.h:35
kKeyMod1Mask
const Mask_t kKeyMod1Mask
Definition: GuiTypes.h:197
TGNumberFormat::kNESRealTwo
@ kNESRealTwo
Definition: TGNumberEntry.h:48
TVirtualX.h
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TGNumberEntryField::SetNumber
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
Definition: TGNumberEntry.cxx:1119
TGTextEntry::GetBuffer
TGTextBuffer * GetBuffer() const
Definition: TGTextEntry.h:127
TGNumberEntryField::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
Definition: TGNumberEntry.cxx:2248
TGNumberEntry::GetNumberEntry
TGNumberEntryField * GetNumberEntry() const
Definition: TGNumberEntry.h:268
TTimer.h
kFocusOut
@ kFocusOut
Definition: GuiTypes.h:60
RealToDouble
static Double_t RealToDouble(const RealInfo_t ri)
Convert to double format.
Definition: TGNumberEntry.cxx:733
kNotifyPointer
@ kNotifyPointer
Definition: GuiTypes.h:219
TString
Definition: TString.h:136
ERealStyle
ERealStyle
Definition: TGNumberEntry.cxx:108
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGNumberEntryField::fNumMax
Double_t fNumMax
Definition: TGNumberEntry.h:82
TGNumberFormat::kNESRealFour
@ kNESRealFour
Definition: TGNumberEntry.h:50
TGNumberEntryLayout::fBox
TGNumberEntry * fBox
Definition: TGNumberEntry.h:290
text
TText * text
Definition: entrylist_figure1.C:10
TSystem::AddTimer
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition: TSystem.cxx:472
bool
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
StringInt
static TString StringInt(Long_t i, Int_t digits)
Definition: TGNumberEntry.cxx:283
TGTextBuffer
Definition: TGTextBuffer.h:30
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
id
XFontStruct * id
Definition: TGX11.cxx:109
TGNumberEntryField::HandleFocusChange
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change.
Definition: TGNumberEntry.cxx:1700
TGLayoutManager
Definition: TGLayout.h:142
IncreaseReal
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.
Definition: TGNumberEntry.cxx:841
TGNumberFormat::EStepSize
EStepSize
Definition: TGNumberEntry.h:68
GContext_t
Handle_t GContext_t
Definition: GuiTypes.h:37
gClient
#define gClient
Definition: TGClient.h:166
TGNumberEntryField::IsLogStep
virtual Bool_t IsLogStep() const
Definition: TGNumberEntry.h:138
style
TCanvas * style()
Definition: style.C:1
TGNumberFormat::kNESRealOne
@ kNESRealOne
Definition: TGNumberEntry.h:47
TGNumberEntryField::SetText
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Set the value (text format).
Definition: TGNumberEntry.cxx:1237
TTimer
Definition: TTimer.h:51
kDays
const Int_t kDays[13]
Definition: TGNumberEntry.cxx:133
kRSFrac
@ kRSFrac
Definition: TGNumberEntry.cxx:116
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGNumberEntry::fButtonUp
TGButton * fButtonUp
Definition: TGNumberEntry.h:173
TGTextEntry::GetAlignment
ETextJustification GetAlignment() const
Definition: TGTextEntry.h:126
EliminateGarbage
static char * EliminateGarbage(char *text, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
Definition: TGNumberEntry.cxx:234
TGWindow::kEditDisableGrab
@ kEditDisableGrab
Definition: TGWindow.h:60
TGNumberEntry::fNumericEntry
TGNumberEntryField * fNumericEntry
Definition: TGNumberEntry.h:172
TGNumberEntryField::SetLogStep
virtual void SetLogStep(Bool_t on=kTRUE)
Definition: TGNumberEntry.h:119
TGNumberFormat::kNESMDayYear
@ kNESMDayYear
Definition: TGNumberEntry.h:57
TGNumberFormat::kNESDayMYear
@ kNESDayMYear
Definition: TGNumberEntry.h:56
TSystem.h
TGNumberEntry::GetHexNumber
virtual ULong_t GetHexNumber() const
Definition: TGNumberEntry.h:218
TGTextEntry::ReturnPressed
virtual void ReturnPressed()
This signal is emitted when the return or enter key is pressed.
Definition: TGTextEntry.cxx:405
h
#define h(i)
Definition: RSha256.hxx:124
TGNumberFormat
Definition: TGNumberEntry.h:31
TGWidget::WidgetId
Int_t WidgetId() const
Definition: TGWidget.h:80
TGWidget::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
TGTextEntry::GetToolTip
virtual TGToolTip * GetToolTip() const
Definition: TGTextEntry.h:135
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:317
DIntToStr
static char * DIntToStr(char *text, Long_t l, Bool_t Sec, char Del)
Definition: TGNumberEntry.cxx:493
TGCompositeFrame::MapSubwindows
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1149
TGButton::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:283
TGWidget::Associate
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
kMaxLong
const Long_t kMaxLong
Definition: RtypesCore.h:107
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGNumberEntryField::SetTime
virtual void SetTime(Int_t hour, Int_t min, Int_t sec)
Set the numeric value (time format).
Definition: TGNumberEntry.cxx:1187
TGNumberEntry::fPicDown
const TGPicture * fPicDown
Definition: TGNumberEntry.h:166
TGTextEntry
Definition: TGTextEntry.h:39
Event_t::fCode
UInt_t fCode
Definition: GuiTypes.h:179
TGFrame::SendMessage
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:630
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TMath::Sign
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:165
TGNumberFormat::kNESHex
@ kNESHex
Definition: TGNumberEntry.h:58
TGTextEntry::TextChanged
virtual void TextChanged(const char *text=0)
This signal is emitted every time the text has changed.
Definition: TGTextEntry.cxx:435
kButtonPress
@ kButtonPress
Definition: GuiTypes.h:59
kCM_BUTTON
@ kCM_BUTTON
Definition: WidgetMessageTypes.h:42
TGNumberEntryField::GetNumber
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
Definition: TGNumberEntry.cxx:1249
Long_t
long Long_t
Definition: RtypesCore.h:54
IsGoodChar
static Bool_t IsGoodChar(char c, TGNumberFormat::EStyle style, TGNumberFormat::EAttribute attr)
Definition: TGNumberEntry.cxx:171
TGWidget::IsEnabled
Bool_t IsEnabled() const
Definition: TGWidget.h:81
TMath::Power
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:724
TGNumberEntryField::HandleKey
virtual Bool_t HandleKey(Event_t *event)
Handle keys.
Definition: TGNumberEntry.cxx:1616
TGTextEntry::End
void End(Bool_t mark=kFALSE)
Moves the text cursor to the right end of the line.
Definition: TGTextEntry.cxx:1015
TGNumberEntry::GetNumLimits
virtual ELimit GetNumLimits() const
Definition: TGNumberEntry.h:239
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:290
kRSFracExpo
@ kRSFracExpo
Definition: TGNumberEntry.cxx:118
TGNumberEntry::fButtonDown
TGButton * fButtonDown
Definition: TGNumberEntry.h:174
TGNumberEntryField::SetState
virtual void SetState(Bool_t state)
Set the active state.
Definition: TGNumberEntry.cxx:1604
TGTextEntry::HandleKey
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
Definition: TGTextEntry.cxx:1228
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGNumberEntry::GetNumAttr
virtual EAttribute GetNumAttr() const
Definition: TGNumberEntry.h:236
y
Double_t y[n]
Definition: legend1.C:17
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGNumberEntryField::TextChanged
virtual void TextChanged(const char *text=0)
Text has changed message.
Definition: TGNumberEntry.cxx:1715
KeySymbols.h
TGNumberEntryField
Definition: TGNumberEntry.h:74
RealToStr
static char * RealToStr(char *text, const RealInfo_t &ri)
Definition: TGNumberEntry.cxx:292
TGCompositeFrame::SetLayoutManager
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition: TGFrame.cxx:985
TGeant4Unit::mm
static constexpr double mm
Definition: TGeant4SystemOfUnits.h:114
TGNumberEntry::GetTime
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
Definition: TGNumberEntry.h:212
unsigned int
TGNumberEntry::SetLogStep
virtual void SetLogStep(Bool_t on=kTRUE)
Set log steps.
Definition: TGNumberEntry.cxx:2018
TGButton::SetState
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:188
TGTextEntry::HandleFocusChange
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text entry widget.
Definition: TGTextEntry.cxx:1466
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
kKeyControlMask
const Mask_t kKeyControlMask
Definition: GuiTypes.h:196
IsLeapYear
static Bool_t IsLeapYear(Int_t year)
Definition: TGNumberEntry.cxx:164
TGNumberEntry::GetButtonUp
TGButton * GetButtonUp() const
Definition: TGNumberEntry.h:271
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:84
TGWidget::fWidgetId
Int_t fWidgetId
Definition: TGWidget.h:58
TGNumberEntry::GetDate
virtual void GetDate(Int_t &year, Int_t &month, Int_t &day) const
Definition: TGNumberEntry.h:215
Double_t
double Double_t
Definition: RtypesCore.h:59
TQObject::Connect
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.
Definition: TQObject.cxx:864
TGNumberEntryField::GetNumStyle
virtual EStyle GetNumStyle() const
Definition: TGNumberEntry.h:123
TGTextEntry::Home
void Home(Bool_t mark=kFALSE)
Moves the text cursor to the left end of the line.
Definition: TGTextEntry.cxx:995
TGPictureButton
Definition: TGButton.h:228
MakeDateNumber
static Long_t MakeDateNumber(const char *, Long_t Day, Long_t Month, Long_t Year)
Create a number entry with year/month/day information.
Definition: TGNumberEntry.cxx:586
dummy
static RooMathCoreReg dummy
Definition: RooMathCoreReg.cxx:27
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGFrame::MoveResize
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:614
TGNumberEntryField::GetHexNumber
virtual ULong_t GetHexNumber() const
Get the numeric value (hex format).
Definition: TGNumberEntry.cxx:1368
TGNumberEntryField::GetIntNumber
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
Definition: TGNumberEntry.cxx:1290
TranslateToStr
static char * TranslateToStr(char *text, Long_t l, TGNumberFormat::EStyle style, const RealInfo_t &ri)
Translate a number value to a string.
Definition: TGNumberEntry.cxx:682
kC_COMMAND
@ kC_COMMAND
Definition: WidgetMessageTypes.h:39
AppendFracZero
static void AppendFracZero(char *text, Int_t digits)
Definition: TGNumberEntry.cxx:559
TGNumberEntryField::GetNumAttr
virtual EAttribute GetNumAttr() const
Definition: TGNumberEntry.h:126
TGCompositeFrame::fLayoutManager
TGLayoutManager * fLayoutManager
Definition: TGFrame.h:328
kRSExpo
@ kRSExpo
Definition: TGNumberEntry.cxx:117
kKey_Backspace
@ kKey_Backspace
Definition: KeySymbols.h:35
TGButton::GetState
virtual EButtonState GetState() const
Definition: TGButton.h:112
TGToolTip.h
TGNumberEntry::TGNumberEntry
TGNumberEntry(const TGNumberEntry &)
TGNumberEntry::GetNumStyle
virtual EStyle GetNumStyle() const
Definition: TGNumberEntry.h:233
TGNumberEntryField::GetNumMax
virtual Double_t GetNumMax() const
Definition: TGNumberEntry.h:135
TGNumberEntryField::SetFormat
virtual void SetFormat(EStyle style, EAttribute attr=kNEAAnyNumber)
Set the numerical format.
Definition: TGNumberEntry.cxx:1574
Event_t
Definition: GuiTypes.h:173
GET_SUBMSG
Int_t GET_SUBMSG(Long_t val)
Definition: WidgetMessageTypes.h:113
TGNumberEntry::Associate
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
Definition: TGNumberEntry.cxx:2009
TTimer::Notify
virtual Bool_t Notify()
Notify when timer times out.
Definition: TTimer.cxx:143
TGNumberFormat::kNELNoLimits
@ kNELNoLimits
Definition: TGNumberEntry.h:62
TGNumberEntryField::GetNumMin
virtual Double_t GetNumMin() const
Definition: TGNumberEntry.h:132
TGNumberEntry::SetButtonToNum
virtual void SetButtonToNum(Bool_t state)
Send button messages to the number field (true) or parent widget (false).
Definition: TGNumberEntry.cxx:2048
d
#define d(i)
Definition: RSha256.hxx:120
Round
static Long_t Round(Double_t x)
Definition: TGNumberEntry.cxx:138
TGTextEntry::GetText
const char * GetText() const
Definition: TGTextEntry.h:134
TGNumberFormat::kNELLimitMin
@ kNELLimitMin
Definition: TGNumberEntry.h:63
kMaxInt
const Int_t kMaxInt
Definition: RtypesCore.h:103
TGString::GetString
const char * GetString() const
Definition: TGString.h:46
TGNumberEntry::GetIntNumber
virtual Long_t GetIntNumber() const
Definition: TGNumberEntry.h:209
TGNumberEntryField::GetNumLimits
virtual ELimit GetNumLimits() const
Definition: TGNumberEntry.h:129
TGNumberEntry.h
TGNumberEntry::GetNumber
virtual Double_t GetNumber() const
Definition: TGNumberEntry.h:206
TGNumberEntryField::GetTime
virtual void GetTime(Int_t &hour, Int_t &min, Int_t &sec) const
Get the numeric value (time format).
Definition: TGNumberEntry.cxx:1299
TGeant4Unit::ms
static constexpr double ms
Definition: TGeant4SystemOfUnits.h:169
kTextRight
@ kTextRight
Definition: TGWidget.h:41
TGNumberEntryField::fNumLimits
ELimit fNumLimits
Definition: TGNumberEntry.h:80
TGNumberEntry
Definition: TGNumberEntry.h:156
TGNumberEntryField::ReturnPressed
virtual void ReturnPressed()
Return was pressed.
Definition: TGNumberEntry.cxx:1724
GetNumbers
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)
Definition: TGNumberEntry.cxx:513
TGNumberEntryField::fStepLog
Bool_t fStepLog
Definition: TGNumberEntry.h:83
TGWindow::fEditDisabled
UInt_t fEditDisabled
Definition: TGWindow.h:40
TGNumberFormat::kNESHourMinSec
@ kNESHourMinSec
Definition: TGNumberEntry.h:55
TGNumberFormat::EAttribute
EAttribute
Definition: TGNumberEntry.h:55
Class
void Class()
Definition: Class.C:29
TGNumberEntryField::SetLimits
virtual void SetLimits(ELimit limits=kNELNoLimits, Double_t min=0, Double_t max=1)
Set the numerical limits.
Definition: TGNumberEntry.cxx:1589
TGWindow::IsEditable
virtual Bool_t IsEditable() const
Definition: TGWindow.h:112
TGCompositeFrame
Definition: TGFrame.h:324
TGNumberFormat::kNSSLarge
@ kNSSLarge
Definition: TGNumberEntry.h:71
TGNumberEntry::SetState
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
Definition: TGNumberEntry.cxx:2028
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TMath::E
constexpr Double_t E()
Base of natural log:
Definition: TMath.h:102
TGNumberEntry::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a number entry widget as a C++ statement(s) on output stream out.
Definition: TGNumberEntry.cxx:2128
TGNumberFormat::EStyle
EStyle
Definition: TGNumberEntry.h:39
TGNumberEntry::GetNumMax
virtual Double_t GetNumMax() const
Definition: TGNumberEntry.h:245
TGNumberEntry::ValueSet
virtual void ValueSet(Long_t val)
Emit ValueSet(Long_t) signal.
Definition: TGNumberEntry.cxx:2120
MK_MSG
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Definition: WidgetMessageTypes.h:110
TGNumberEntryField::SetIntNumber
virtual void SetIntNumber(Long_t val)
Set the numeric value (integer representation).
Definition: TGNumberEntry.cxx:1172
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:36
TGNumberEntryField::fNumMin
Double_t fNumMin
Definition: TGNumberEntry.h:81
TGNumberEntry::GetButtonDown
TGButton * GetButtonDown() const
Definition: TGNumberEntry.h:274
kKeyShiftMask
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:194
kButtonDisabled
@ kButtonDisabled
Definition: TGButton.h:62
TGNumberFormat::kNESInteger
@ kNESInteger
Definition: TGNumberEntry.h:46
TGNumberEntry::GetNumMin
virtual Double_t GetNumMin() const
Definition: TGNumberEntry.h:242
TGTextBuffer::GetString
const char * GetString() const
Definition: TGTextBuffer.h:53
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TMath.h
int
TGNumberEntryField::fNeedsVerification
Bool_t fNeedsVerification
Definition: TGNumberEntry.h:77