Mercurial > projects > dwt-win
comparison dwt/widgets/DateTime.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 219551956439 |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
138 */ | 138 */ |
139 public this (Composite parent, int style) { | 139 public this (Composite parent, int style) { |
140 static_this(); | 140 static_this(); |
141 super (parent, checkStyle (style)); | 141 super (parent, checkStyle (style)); |
142 if ((this.style & DWT.SHORT) !is 0) { | 142 if ((this.style & DWT.SHORT) !is 0) { |
143 char[] buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); | 143 String buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); |
144 TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true); | 144 TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true); |
145 OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr); | 145 OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
360 | 360 |
361 override int defaultBackground () { | 361 override int defaultBackground () { |
362 return OS.GetSysColor (OS.COLOR_WINDOW); | 362 return OS.GetSysColor (OS.COLOR_WINDOW); |
363 } | 363 } |
364 | 364 |
365 char[] getComputeSizeString () { | 365 String getComputeSizeString () { |
366 // TODO: Not currently used but might need for WinCE | 366 // TODO: Not currently used but might need for WinCE |
367 if ((style & DWT.DATE) !is 0) { | 367 if ((style & DWT.DATE) !is 0) { |
368 if ((style & DWT.SHORT) !is 0) return getCustomShortDateFormat (); | 368 if ((style & DWT.SHORT) !is 0) return getCustomShortDateFormat (); |
369 if ((style & DWT.MEDIUM) !is 0) return getShortDateFormat (); | 369 if ((style & DWT.MEDIUM) !is 0) return getShortDateFormat (); |
370 if ((style & DWT.LONG) !is 0) return getLongDateFormat (); | 370 if ((style & DWT.LONG) !is 0) return getLongDateFormat (); |
374 return getTimeFormat (); | 374 return getTimeFormat (); |
375 } | 375 } |
376 return ""; | 376 return ""; |
377 } | 377 } |
378 | 378 |
379 char[] getCustomShortDateFormat () { | 379 String getCustomShortDateFormat () { |
380 if (true) { | 380 if (true) { |
381 TCHAR[] tchar = new TCHAR[80]; | 381 TCHAR[] tchar = new TCHAR[80]; |
382 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar.ptr, 80); | 382 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar.ptr, 80); |
383 return size !is 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/yyyy"; //$NON-NLS-1$ | 383 return size !is 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/yyyy"; //$NON-NLS-1$ |
384 } | 384 } |
385 | 385 |
386 //TODO: Not currently used, but may need for WinCE (or if numeric short date is required) | 386 //TODO: Not currently used, but may need for WinCE (or if numeric short date is required) |
387 char[] buffer = getShortDateFormat (); | 387 String buffer = getShortDateFormat (); |
388 int length = buffer.length; | 388 int length = buffer.length; |
389 bool inQuotes = false; | 389 bool inQuotes = false; |
390 int start = 0, end = 0; | 390 int start = 0, end = 0; |
391 while (start < length) { | 391 while (start < length) { |
392 char ch = buffer.charAt (start); | 392 char ch = buffer.charAt (start); |
416 } | 416 } |
417 if (start < end) buffer.length = start - 1; | 417 if (start < end) buffer.length = start - 1; |
418 return buffer; | 418 return buffer; |
419 } | 419 } |
420 | 420 |
421 char[] getCustomShortTimeFormat () { | 421 String getCustomShortTimeFormat () { |
422 char[] buffer = getTimeFormat (); | 422 String buffer = getTimeFormat (); |
423 int length = buffer.length; | 423 int length = buffer.length; |
424 bool inQuotes = false; | 424 bool inQuotes = false; |
425 int start = 0, end = 0; | 425 int start = 0, end = 0; |
426 while (start < length) { | 426 while (start < length) { |
427 char ch = buffer.charAt (start); | 427 char ch = buffer.charAt (start); |
438 } | 438 } |
439 if (start < end) buffer.length = start - 1; | 439 if (start < end) buffer.length = start - 1; |
440 return buffer; | 440 return buffer; |
441 } | 441 } |
442 | 442 |
443 char[] getLongDateFormat () { | 443 String getLongDateFormat () { |
444 //TODO: Not currently used, but may need for WinCE | 444 //TODO: Not currently used, but may need for WinCE |
445 TCHAR tchar[80]; | 445 TCHAR tchar[80]; |
446 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar.ptr, 80); | 446 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar.ptr, 80); |
447 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ | 447 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ |
448 } | 448 } |
449 | 449 |
450 char[] getShortDateFormat () { | 450 String getShortDateFormat () { |
451 //TODO: Not currently used, but may need for WinCE | 451 //TODO: Not currently used, but may need for WinCE |
452 TCHAR tchar[80]; | 452 TCHAR tchar[80]; |
453 //TODO: May need to OR with LOCALE_ICENTURY | 453 //TODO: May need to OR with LOCALE_ICENTURY |
454 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar.ptr, 80); | 454 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar.ptr, 80); |
455 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/d/yyyy"; //$NON-NLS-1$ | 455 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/d/yyyy"; //$NON-NLS-1$ |
458 int getShortDateFormatOrdering () { | 458 int getShortDateFormatOrdering () { |
459 //TODO: Not currently used, but may need for WinCE | 459 //TODO: Not currently used, but may need for WinCE |
460 TCHAR tchar[80]; | 460 TCHAR tchar[80]; |
461 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4); | 461 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4); |
462 if (size > 0) { | 462 if (size > 0) { |
463 char[] number = TCHARsToStr(tchar[0..size - 1]); | 463 String number = TCHARsToStr(tchar[0..size - 1]); |
464 return Integer.parse (number); | 464 return Integer.parse (number); |
465 } | 465 } |
466 return 0; | 466 return 0; |
467 } | 467 } |
468 | 468 |
469 char[] getTimeFormat () { | 469 String getTimeFormat () { |
470 TCHAR tchar[80]; | 470 TCHAR tchar[80]; |
471 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar.ptr, 80); | 471 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar.ptr, 80); |
472 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "h:mm:ss tt"; //$NON-NLS-1$ | 472 return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "h:mm:ss tt"; //$NON-NLS-1$ |
473 } | 473 } |
474 | 474 |
475 bool is24HourTime () { | 475 bool is24HourTime () { |
476 TCHAR tchar[4]; | 476 TCHAR tchar[4]; |
477 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4); | 477 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4); |
478 if (size > 0) { | 478 if (size > 0) { |
479 char[] number = TCHARsToStr(tchar[0..size - 1]); | 479 String number = TCHARsToStr(tchar[0..size - 1]); |
480 return Integer.parse (number) !is 0; | 480 return Integer.parse (number) !is 0; |
481 } | 481 } |
482 return true; | 482 return true; |
483 } | 483 } |
484 | 484 |
564 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; | 564 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; |
565 OS.SendMessage (handle, msg, 0, &systime); | 565 OS.SendMessage (handle, msg, 0, &systime); |
566 return systime.wMonth - 1; | 566 return systime.wMonth - 1; |
567 } | 567 } |
568 | 568 |
569 override char[] getNameText () { | 569 override String getNameText () { |
570 return "DateTime"; | 570 return "DateTime"; |
571 } | 571 } |
572 | 572 |
573 /** | 573 /** |
574 * Returns the receiver's seconds. | 574 * Returns the receiver's seconds. |
787 if ((style & DWT.TIME) !is 0) bits |= OS.DTS_TIMEFORMAT; | 787 if ((style & DWT.TIME) !is 0) bits |= OS.DTS_TIMEFORMAT; |
788 if ((style & DWT.DATE) !is 0) bits |= ((style & DWT.MEDIUM) !is 0 ? OS.DTS_SHORTDATECENTURYFORMAT : OS.DTS_LONGDATEFORMAT) | OS.DTS_UPDOWN; | 788 if ((style & DWT.DATE) !is 0) bits |= ((style & DWT.MEDIUM) !is 0 ? OS.DTS_SHORTDATECENTURYFORMAT : OS.DTS_LONGDATEFORMAT) | OS.DTS_UPDOWN; |
789 return bits; | 789 return bits; |
790 } | 790 } |
791 | 791 |
792 override char[] windowClass () { | 792 override String windowClass () { |
793 return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass); | 793 return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass); |
794 } | 794 } |
795 | 795 |
796 override int windowProc () { | 796 override int windowProc () { |
797 return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc; | 797 return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc; |