Changeset 166:cd28aa5221a3
- Timestamp:
- 02/21/08 11:43:13 (8 months ago)
- Files:
-
- dwt/widgets/DateTime.d (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/widgets/DateTime.d
r82 r166 15 15 import dwt.widgets.Composite; 16 16 17 class DateTime : Composite {18 }19 /++20 17 import dwt.DWT; 21 18 import dwt.DWTException; … … 23 20 import dwt.events.SelectionListener; 24 21 import dwt.graphics.Point; 25 import dwt.internal.win32.INITCOMMONCONTROLSEX;26 import dwt.internal.win32.LRESULT;27 import dwt.internal.win32.NMHDR;28 22 import dwt.internal.win32.OS; 29 import dwt.internal.win32.RECT; 30 import dwt.internal.win32.SYSTEMTIME; 31 import dwt.internal.win32.TCHAR; 32 import dwt.internal.win32.WNDCLASS; 23 24 import dwt.widgets.TypedListener; 25 26 import dwt.dwthelper.utils; 27 28 import Integer = tango.text.convert.Integer; 33 29 34 30 //TODO - features not yet implemented: read-only, drop-down calendar for date … … 59 55 */ 60 56 61 public class DateTime extendsComposite {57 public class DateTime : Composite { 62 58 63 59 alias Composite.computeSize computeSize; 64 60 alias Composite.windowProc windowProc; 65 61 66 static final int DateTimeProc; 67 static final TCHAR DateTimeClass = new TCHAR (0, OS.DATETIMEPICK_CLASS, true); 68 static final int CalendarProc; 69 static final TCHAR CalendarClass = new TCHAR (0, OS.MONTHCAL_CLASS, true); 70 static { 71 INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX (); 72 icex.dwSize = INITCOMMONCONTROLSEX.sizeof; 73 icex.dwICC = OS.ICC_DATE_CLASSES; 74 OS.InitCommonControlsEx (icex); 75 WNDCLASS lpWndClass = new WNDCLASS (); 76 OS.GetClassInfo (0, DateTimeClass, lpWndClass); 77 DateTimeProc = lpWndClass.lpfnWndProc; 78 OS.GetClassInfo (0, CalendarClass, lpWndClass); 79 CalendarProc = lpWndClass.lpfnWndProc; 80 } 81 static final int MARGIN = 4; 82 static final int MAX_DIGIT = 9; 83 static final int MAX_DAY = 31; 84 static final int MAX_12HOUR = 12; 85 static final int MAX_24HOUR = 24; 86 static final int MAX_MINUTE = 60; 87 static final int MONTH_DAY_YEAR = 0; 88 static final int DAY_MONTH_YEAR = 1; 89 static final int YEAR_MONTH_DAY = 2; 90 static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text 91 static final char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day 92 static final char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month 93 static final char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year 94 static final char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours 95 static final char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes 96 static final char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds 97 static final char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm 98 static final int[] MONTH_NAMES = new int[] {OS.LOCALE_SMONTHNAME1, OS.LOCALE_SMONTHNAME2, OS.LOCALE_SMONTHNAME3, OS.LOCALE_SMONTHNAME4, OS.LOCALE_SMONTHNAME5, OS.LOCALE_SMONTHNAME6, OS.LOCALE_SMONTHNAME7, OS.LOCALE_SMONTHNAME8, OS.LOCALE_SMONTHNAME9, OS.LOCALE_SMONTHNAME10, OS.LOCALE_SMONTHNAME11, OS.LOCALE_SMONTHNAME12}; 62 static /+const+/ WNDPROC DateTimeProc; 63 static const TCHAR* DateTimeClass = OS.DATETIMEPICK_CLASS.ptr; 64 static /+const+/ WNDPROC CalendarProc; 65 static const TCHAR* CalendarClass = OS.MONTHCAL_CLASS.ptr; 66 67 private static bool static_this_completed = false; 68 private static void static_this() { 69 if( static_this_completed ){ 70 return; 71 } 72 synchronized { 73 if( static_this_completed ){ 74 return; 75 } 76 INITCOMMONCONTROLSEX icex; 77 icex.dwSize = INITCOMMONCONTROLSEX.sizeof; 78 icex.dwICC = OS.ICC_DATE_CLASSES; 79 OS.InitCommonControlsEx (&icex); 80 WNDCLASS lpWndClass; 81 OS.GetClassInfo (null, DateTimeClass, &lpWndClass); 82 DateTimeProc = lpWndClass.lpfnWndProc; 83 OS.GetClassInfo (null, CalendarClass, &lpWndClass); 84 CalendarProc = lpWndClass.lpfnWndProc; 85 static_this_completed = true; 86 } 87 } 88 89 static const int MARGIN = 4; 90 static const int MAX_DIGIT = 9; 91 static const int MAX_DAY = 31; 92 static const int MAX_12HOUR = 12; 93 static const int MAX_24HOUR = 24; 94 static const int MAX_MINUTE = 60; 95 static const int MONTH_DAY_YEAR = 0; 96 static const int DAY_MONTH_YEAR = 1; 97 static const int YEAR_MONTH_DAY = 2; 98 static const char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text 99 static const char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day 100 static const char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month 101 static const char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year 102 static const char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours 103 static const char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes 104 static const char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds 105 static const char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm 106 static const int[] MONTH_NAMES = [OS.LOCALE_SMONTHNAME1, OS.LOCALE_SMONTHNAME2, OS.LOCALE_SMONTHNAME3, OS.LOCALE_SMONTHNAME4, OS.LOCALE_SMONTHNAME5, OS.LOCALE_SMONTHNAME6, OS.LOCALE_SMONTHNAME7, OS.LOCALE_SMONTHNAME8, OS.LOCALE_SMONTHNAME9, OS.LOCALE_SMONTHNAME10, OS.LOCALE_SMONTHNAME11, OS.LOCALE_SMONTHNAME12]; 99 107 100 108 … … 129 137 * @see Widget#getStyle 130 138 */ 131 public DateTime (Composite parent, int style) { 139 public this (Composite parent, int style) { 140 static_this(); 132 141 super (parent, checkStyle (style)); 133 142 if ((this.style & DWT.SHORT) !is 0) { 134 Stringbuffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat();135 TCHAR lpszFormat = new TCHAR(0, buffer, true);136 OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat );143 char[] buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); 144 TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true); 145 OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr); 137 146 } 138 147 } … … 170 179 } 171 180 172 override int callWindowProc ( inthwnd, int msg, int wParam, int lParam) {173 if (handle is 0) return 0;174 return OS.CallWindowProc ( windowProc(), hwnd, msg, wParam, lParam);181 override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 182 if (handle is null) return 0; 183 return OS.CallWindowProc ( cast(WNDPROC)windowProc(), hwnd, msg, wParam, lParam); 175 184 } 176 185 … … 197 206 if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { 198 207 if ((style & DWT.CALENDAR) !is 0) { 199 RECT rect = new RECT ();200 OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, rect);208 RECT rect; 209 OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, &rect); 201 210 width = rect.right; 202 211 height = rect.bottom; 203 212 } else { 204 TCHAR buffer = new TCHAR (getCodePage (), 128);205 int newFont, oldFont = 0;206 inthDC = OS.GetDC (handle);207 newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);208 if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont);209 RECT rect = new RECT ();213 TCHAR[] buffer = new TCHAR[128]; 214 void* newFont = cast(void*)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0), oldFont = null; 215 auto hDC = OS.GetDC (handle); 216 // newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 217 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 218 RECT rect; 210 219 int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX; 211 SYSTEMTIME systime = new SYSTEMTIME ();220 SYSTEMTIME systime; 212 221 if ((style & DWT.DATE) !is 0) { 213 222 /* Determine the widest/tallest year string. */ … … 216 225 int widest = 0, secondWidest = 0, thirdWidest = 0; 217 226 for (int i = 0; i <= MAX_DIGIT; i++) { 218 systime.wYear = (short) (2000 + i); // year 2000 + i is guaranteed to exist219 int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ());227 systime.wYear = cast(short) (2000 + i); // year 2000 + i is guaranteed to exist 228 int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); 220 229 if (size is 0) { 221 buffer = new TCHAR (getCodePage (), size);222 OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ());230 buffer = new TCHAR[size]; 231 OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); 223 232 } 224 233 rect.left = rect.top = rect.right = rect.bottom = 0; 225 OS.DrawText (hDC, buffer , size,rect, flags);234 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 226 235 if (rect.right - rect.left >= width) { 227 236 width = rect.right - rect.left; … … 235 244 else if (secondWidest > 1) widest = secondWidest * 1000 + widest * 100 + widest * 10 + widest; 236 245 else widest = thirdWidest * 1000 + widest * 100 + widest * 10 + widest; 237 systime.wYear = (short) widest;246 systime.wYear = cast(short) widest; 238 247 239 248 /* Determine the widest/tallest month name string. */ … … 241 250 for (short i = 0; i < MONTH_NAMES.length; i++) { 242 251 int name = MONTH_NAMES [i]; 243 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer , buffer.length ());252 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); 244 253 if (size is 0) { 245 buffer = new TCHAR (getCodePage (), size);246 OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer , buffer.length ());254 buffer = new TCHAR[size]; 255 OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); 247 256 } 248 257 rect.left = rect.top = rect.right = rect.bottom = 0; 249 OS.DrawText (hDC, buffer , size,rect, flags);258 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 250 259 if (rect.right - rect.left > width) { 251 260 width = rect.right - rect.left; … … 254 263 height = Math.max(height, rect.bottom - rect.top); 255 264 } 256 systime.wMonth = (short) (widest + 1);265 systime.wMonth = cast(short) (widest + 1); 257 266 258 267 /* Determine the widest/tallest date string in the widest month of the widest year. */ … … 261 270 for (short i = 1; i <= MAX_DAY; i++) { 262 271 systime.wDay = i; 263 int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());272 int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 264 273 if (size is 0) { 265 buffer = new TCHAR (getCodePage (), size);266 OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());274 buffer = new TCHAR[size]; 275 OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 267 276 } 268 277 rect.left = rect.top = rect.right = rect.bottom = 0; 269 OS.DrawText (hDC, buffer , size,rect, flags);278 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 270 279 width = Math.max(width, rect.right - rect.left); 271 280 height = Math.max(height, rect.bottom - rect.top); … … 279 288 for (short i = 0; i < max; i++) { 280 289 systime.wHour = i; 281 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());290 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 282 291 if (size is 0) { 283 buffer = new TCHAR (getCodePage (), size);284 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());292 buffer = new TCHAR[size]; 293 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 285 294 } 286 295 rect.left = rect.top = rect.right = rect.bottom = 0; 287 OS.DrawText (hDC, buffer , size,rect, flags);296 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 288 297 if (rect.right - rect.left > width) { 289 298 width = rect.right - rect.left; … … 298 307 for (short i = 0; i < MAX_MINUTE; i++) { 299 308 systime.wMinute = i; 300 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());309 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 301 310 if (size is 0) { 302 buffer = new TCHAR (getCodePage (), size);303 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());311 buffer = new TCHAR[size]; 312 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 304 313 } 305 314 rect.left = rect.top = rect.right = rect.bottom = 0; 306 OS.DrawText (hDC, buffer , size,rect, flags);315 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 307 316 if (rect.right - rect.left > width) { 308 317 width = rect.right - rect.left; … … 315 324 316 325 /* Determine the widest/tallest time string for the widest hour, widest minute, and if applicable, widest second. */ 317 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());326 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 318 327 if (size is 0) { 319 buffer = new TCHAR (getCodePage (), size);320 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());328 buffer = new TCHAR[size]; 329 OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 321 330 } 322 331 rect.left = rect.top = rect.right = rect.bottom = 0; 323 OS.DrawText (hDC, buffer , size,rect, flags);332 OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 324 333 width = rect.right - rect.left; 325 334 height = Math.max(height, rect.bottom - rect.top); 326 335 } 327 if (newFont !is 0) OS.SelectObject (hDC, oldFont);336 if (newFont !is null) OS.SelectObject (hDC, oldFont); 328 337 OS.ReleaseDC (handle, hDC); 329 338 int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL); … … 354 363 } 355 364 356 StringgetComputeSizeString () {365 char[] getComputeSizeString () { 357 366 // TODO: Not currently used but might need for WinCE 358 367 if ((style & DWT.DATE) !is 0) { … … 368 377 } 369 378 370 StringgetCustomShortDateFormat () {379 char[] getCustomShortDateFormat () { 371 380 if (true) { 372 TCHAR tchar = new TCHAR (getCodePage (), 80);373 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar , 80);374 return size !is 0 ? tchar.toString (0, size - 1): "M/yyyy"; //$NON-NLS-1$381 TCHAR[] tchar = new TCHAR[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$ 375 384 } 376 385 377 386 //TODO: Not currently used, but may need for WinCE (or if numeric short date is required) 378 StringBuffer buffer = new StringBuffer (getShortDateFormat ());379 int length = buffer.length ();387 char[] buffer = getShortDateFormat (); 388 int length = buffer.length; 380 389 bool inQuotes = false; 381 390 int start = 0, end = 0; … … 406 415 start++; 407 416 } 408 if (start < end) buffer. delete (start, end);409 return buffer .toString ();410 } 411 412 StringgetCustomShortTimeFormat () {413 StringBuffer buffer = new StringBuffer (getTimeFormat ());414 int length = buffer.length ();417 if (start < end) buffer.length = start - 1; 418 return buffer; 419 } 420 421 char[] getCustomShortTimeFormat () { 422 char[] buffer = getTimeFormat (); 423 int length = buffer.length; 415 424 bool inQuotes = false; 416 425 int start = 0, end = 0; … … 428 437 start++; 429 438 } 430 if (start < end) buffer. delete (start, end);431 return buffer .toString ();432 } 433 434 StringgetLongDateFormat () {439 if (start < end) buffer.length = start - 1; 440 return buffer; 441 } 442 443 char[] getLongDateFormat () { 435 444 //TODO: Not currently used, but may need for WinCE 436 TCHAR tchar = new TCHAR (getCodePage (), 80);437 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar , 80);438 return size > 0 ? tchar.toString (0, size - 1) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$439 } 440 441 StringgetShortDateFormat () {445 TCHAR tchar[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$ 448 } 449 450 char[] getShortDateFormat () { 442 451 //TODO: Not currently used, but may need for WinCE 443 TCHAR tchar = new TCHAR (getCodePage (), 80);452 TCHAR tchar[80]; 444 453 //TODO: May need to OR with LOCALE_ICENTURY 445 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar , 80);446 return size > 0 ? tchar.toString (0, size - 1) : "M/d/yyyy"; //$NON-NLS-1$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$ 447 456 } 448 457 449 458 int getShortDateFormatOrdering () { 450 459 //TODO: Not currently used, but may need for WinCE 451 TCHAR tchar = new TCHAR (getCodePage (), 4);452 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar , 4);460 TCHAR tchar[80]; 461 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4); 453 462 if (size > 0) { 454 String number = tchar.toString (0, size - 1);455 return Integer.parse Int(number);463 char[] number = TCHARsToStr(tchar[0..size - 1]); 464 return Integer.parse (number); 456 465 } 457 466 return 0; 458 467 } 459 468 460 StringgetTimeFormat () {461 TCHAR tchar = new TCHAR (getCodePage (), 80);462 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar , 80);463 return size > 0 ? tchar.toString (0, size - 1) : "h:mm:ss tt"; //$NON-NLS-1$469 char[] getTimeFormat () { 470 TCHAR tchar[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$ 464 473 } 465 474 466 475 bool is24HourTime () { 467 TCHAR tchar = new TCHAR (getCodePage (), 4);468 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar , 4);476 TCHAR tchar[4]; 477 int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4); 469 478 if (size > 0) { 470 String number = tchar.toString (0, size - 1);471 return Integer.parse Int(number) !is 0;479 char[] number = TCHARsToStr(tchar[0..size - 1]); 480 return Integer.parse (number) !is 0; 472 481 } 473 482 return true; … … 489 498 public int getDay () { 490 499 checkWidget (); 491 SYSTEMTIME systime = new SYSTEMTIME ();492 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 493 OS.SendMessage (handle, msg, 0, systime);500 SYSTEMTIME systime; 501 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 502 OS.SendMessage (handle, msg, 0, &systime); 494 503 return systime.wDay; 495 504 } … … 510 519 public int getHours () { 511 520 checkWidget (); 512 SYSTEMTIME systime = new SYSTEMTIME ();513 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 514 OS.SendMessage (handle, msg, 0, systime);521 SYSTEMTIME systime; 522 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 523 OS.SendMessage (handle, msg, 0, &systime); 515 524 return systime.wHour; 516 525 } … … 531 540 public int getMinutes () { 532 541 checkWidget (); 533 SYSTEMTIME systime = new SYSTEMTIME ();534 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 535 OS.SendMessage (handle, msg, 0, systime);542 SYSTEMTIME systime; 543 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 544 OS.SendMessage (handle, msg, 0, &systime); 536 545 return systime.wMinute; 537 546 } … … 552 561 public int getMonth () { 553 562 checkWidget (); 554 SYSTEMTIME systime = new SYSTEMTIME ();555 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 556 OS.SendMessage (handle, msg, 0, systime);563 SYSTEMTIME systime; 564 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 565 OS.SendMessage (handle, msg, 0, &systime); 557 566 return systime.wMonth - 1; 558 567 } 559 568 560 override StringgetNameText () {569 override char[] getNameText () { 561 570 return "DateTime"; 562 571 } … … 577 586 public int getSeconds () { 578 587 checkWidget (); 579 SYSTEMTIME systime = new SYSTEMTIME ();580 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 581 OS.SendMessage (handle, msg, 0, systime);588 SYSTEMTIME systime; 589 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 590 OS.SendMessage (handle, msg, 0, &systime); 582 591 return systime.wSecond; 583 592 } … … 598 607 public int getYear () { 599 608 checkWidget (); 600 SYSTEMTIME systime = new SYSTEMTIME ();601 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 602 OS.SendMessage (handle, msg, 0, systime);609 SYSTEMTIME systime; 610 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 611 OS.SendMessage (handle, msg, 0, &systime); 603 612 return systime.wYear; 604 613 } … … 644 653 public void setDay (int day) { 645 654 checkWidget (); 646 SYSTEMTIME systime = new SYSTEMTIME ();647 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 648 OS.SendMessage (handle, msg, 0, systime);655 SYSTEMTIME systime; 656 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 657 OS.SendMessage (handle, msg, 0, &systime); 649 658 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 650 systime.wDay = (short)day;651 OS.SendMessage (handle, msg, 0, systime);659 systime.wDay = cast(short)day; 660 OS.SendMessage (handle, msg, 0, &systime); 652 661 } 653 662 … … 667 676 public void setHours (int hours) { 668 677 checkWidget (); 669 SYSTEMTIME systime = new SYSTEMTIME ();670 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 671 OS.SendMessage (handle, msg, 0, systime);678 SYSTEMTIME systime; 679 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 680 OS.SendMessage (handle, msg, 0, &systime); 672 681 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 673 systime.wHour = (short)hours;674 OS.SendMessage (handle, msg, 0, systime);682 systime.wHour = cast(short)hours; 683 OS.SendMessage (handle, msg, 0, &systime); 675 684 } 676 685 … … 690 699 public void setMinutes (int minutes) { 691 700 checkWidget (); 692 SYSTEMTIME systime = new SYSTEMTIME ();693 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 694 OS.SendMessage (handle, msg, 0, systime);701 SYSTEMTIME systime; 702 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 703 OS.SendMessage (handle, msg, 0, &systime); 695 704 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 696 systime.wMinute = (short)minutes;697 OS.SendMessage (handle, msg, 0, systime);705 systime.wMinute = cast(short)minutes; 706 OS.SendMessage (handle, msg, 0, &systime); 698 707 } 699 708 … … 713 722 public void setMonth (int month) { 714 723 checkWidget (); 715 SYSTEMTIME systime = new SYSTEMTIME ();716 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 717 OS.SendMessage (handle, msg, 0, systime);724 SYSTEMTIME systime; 725 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 726 OS.SendMessage (handle, msg, 0, &systime); 718 727 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 719 systime.wMonth = (short)(month + 1);720 OS.SendMessage (handle, msg, 0, systime);728 systime.wMonth = cast(short)(month + 1); 729 OS.SendMessage (handle, msg, 0, &systime); 721 730 } 722 731 … … 736 745 public void setSeconds (int seconds) { 737 746 checkWidget (); 738 SYSTEMTIME systime = new SYSTEMTIME ();739 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 740 OS.SendMessage (handle, msg, 0, systime);747 SYSTEMTIME systime; 748 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 749 OS.SendMessage (handle, msg, 0, &systime); 741 750 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 742 systime.wSecond = (short)seconds;743 OS.SendMessage (handle, msg, 0, systime);751 systime.wSecond = cast(short)seconds; 752 OS.SendMessage (handle, msg, 0, &systime); 744 753 } 745 754 … … 759 768 public void setYear (int year) { 760 769 checkWidget (); 761 SYSTEMTIME systime = new SYSTEMTIME ();762 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 763 OS.SendMessage (handle, msg, 0, systime);770 SYSTEMTIME systime; 771 int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 772 OS.SendMessage (handle, msg, 0, &systime); 764 773 msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 765 systime.wYear = (short)year;766 OS.SendMessage (handle, msg, 0, systime);774 systime.wYear = cast(short)year; 775 OS.SendMessage (handle, msg, 0, &systime); 767 776 } 768 777 … … 781 790 } 782 791 783 override TCHARwindowClass () {784 return (style & DWT.CALENDAR) !is 0 ? CalendarClass : DateTimeClass;792 override char[] windowClass () { 793 return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass); 785 794 } 786 795 787 796 override int windowProc () { 788 return (style & DWT.CALENDAR) !is 0 ? CalendarProc :DateTimeProc;789 } 790 791 override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) {797 return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc; 798 } 799 800 override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { 792 801 switch (hdr.code) { 793 802 case OS.MCN_SELCHANGE: //SENT WHEN YOU SET IT? … … 800 809 } 801 810 } 802 ++/ 811
