Mercurial > projects > dwt-mac
comparison dwt/widgets/DateTime.d @ 123:63a09873578e
Fixed compile errors
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 15 Jan 2009 23:08:54 +0100 |
parents | c7f7f4d7091a |
children |
comparison
equal
deleted
inserted
replaced
122:2e671fa40eec | 123:63a09873578e |
---|---|
30 import dwt.internal.cocoa.SWTDatePicker; | 30 import dwt.internal.cocoa.SWTDatePicker; |
31 | 31 |
32 import tango.text.convert.Format; | 32 import tango.text.convert.Format; |
33 | 33 |
34 import Carbon = dwt.internal.c.Carbon; | 34 import Carbon = dwt.internal.c.Carbon; |
35 import dwt.internal.objc.cocoa.Cocoa; | |
35 import dwt.widgets.Composite; | 36 import dwt.widgets.Composite; |
36 import dwt.widgets.TypedListener; | 37 import dwt.widgets.TypedListener; |
37 | 38 |
38 /** | 39 /** |
39 * Instances of this class are selectable user interface | 40 * Instances of this class are selectable user interface |
61 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | 62 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
62 * | 63 * |
63 * @since 3.3 | 64 * @since 3.3 |
64 */ | 65 */ |
65 public class DateTime : Composite { | 66 public class DateTime : Composite { |
66 | 67 |
67 /** | 68 /** |
68 * Constructs a new instance of this class given its parent | 69 * Constructs a new instance of this class given its parent |
69 * and a style value describing its behavior and appearance. | 70 * and a style value describing its behavior and appearance. |
70 * <p> | 71 * <p> |
71 * The style value is either one of the style constants defined in | 72 * The style value is either one of the style constants defined in |
98 super (parent, checkStyle (style)); | 99 super (parent, checkStyle (style)); |
99 } | 100 } |
100 | 101 |
101 static int checkStyle (int style) { | 102 static int checkStyle (int style) { |
102 /* | 103 /* |
103 * Even though it is legal to create this widget | 104 * Even though it is legal to create this widget |
104 * with scroll bars, they serve no useful purpose | 105 * with scroll bars, they serve no useful purpose |
105 * because they do not automatically scroll the | 106 * because they do not automatically scroll the |
106 * widget's client area. The fix is to clear | 107 * widget's client area. The fix is to clear |
107 * the DWT style. | 108 * the DWT style. |
108 */ | 109 */ |
109 style &= ~(DWT.H_SCROLL | DWT.V_SCROLL); | 110 style &= ~(DWT.H_SCROLL | DWT.V_SCROLL); |
110 style = checkBits (style, DWT.MEDIUM, DWT.SHORT, DWT.LONG, 0, 0, 0); | 111 style = checkBits (style, DWT.MEDIUM, DWT.SHORT, DWT.LONG, 0, 0, 0); |
111 return checkBits (style, DWT.DATE, DWT.TIME, DWT.CALENDAR, 0, 0, 0); | 112 return checkBits (style, DWT.DATE, DWT.TIME, DWT.CALENDAR, 0, 0, 0); |
112 } | 113 } |
113 | 114 |
269 return cast(int)/*64*/getCalendarDate().monthOfYear() - 1; | 270 return cast(int)/*64*/getCalendarDate().monthOfYear() - 1; |
270 } | 271 } |
271 | 272 |
272 String getNameText() { | 273 String getNameText() { |
273 return (style & DWT.TIME) !is 0 ? Format("{}{}{}{}{}", getHours() , ":" , getMinutes() , ":" , getSeconds()) | 274 return (style & DWT.TIME) !is 0 ? Format("{}{}{}{}{}", getHours() , ":" , getMinutes() , ":" , getSeconds()) |
274 : Format("{}{}{}{}{}", (getMonth() + 1) , "/" , getDay() , "/" , getYear()); | 275 : Format("{}{}{}{}{}", (getMonth() + 1) , "/" , getDay() , "/" , getYear()); |
275 } | 276 } |
276 | 277 |
277 /** | 278 /** |
278 * Returns the receiver's seconds. | 279 * Returns the receiver's seconds. |
279 * <p> | 280 * <p> |
369 */ | 370 */ |
370 public void setDate (int year, int month, int day) { | 371 public void setDate (int year, int month, int day) { |
371 checkWidget (); | 372 checkWidget (); |
372 NSCalendarDate date = getCalendarDate(); | 373 NSCalendarDate date = getCalendarDate(); |
373 NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, month + 1, day, | 374 NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, month + 1, day, |
374 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); | 375 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); |
375 if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is day) { | 376 if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is day) { |
376 (cast(NSDatePicker)view).setDateValue(newDate); | 377 (cast(NSDatePicker)view).setDateValue(newDate); |
377 } | 378 } |
378 } | 379 } |
379 | 380 |
392 */ | 393 */ |
393 public void setDay (int day) { | 394 public void setDay (int day) { |
394 checkWidget (); | 395 checkWidget (); |
395 NSCalendarDate date = getCalendarDate(); | 396 NSCalendarDate date = getCalendarDate(); |
396 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), day, | 397 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), day, |
397 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); | 398 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); |
398 if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is day) { | 399 if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is day) { |
399 (cast(NSDatePicker)view).setDateValue(newDate); | 400 (cast(NSDatePicker)view).setDateValue(newDate); |
400 } | 401 } |
401 } | 402 } |
402 | 403 |
426 public void setHours (int hours) { | 427 public void setHours (int hours) { |
427 checkWidget (); | 428 checkWidget (); |
428 if (hours < 0 || hours > 23) return; | 429 if (hours < 0 || hours > 23) return; |
429 NSCalendarDate date = getCalendarDate(); | 430 NSCalendarDate date = getCalendarDate(); |
430 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), | 431 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), |
431 hours, date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); | 432 hours, date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); |
432 (cast(NSDatePicker)view).setDateValue(newDate); | 433 (cast(NSDatePicker)view).setDateValue(newDate); |
433 } | 434 } |
434 | 435 |
435 /** | 436 /** |
436 * Sets the receiver's minutes. | 437 * Sets the receiver's minutes. |
448 public void setMinutes (int minutes) { | 449 public void setMinutes (int minutes) { |
449 checkWidget (); | 450 checkWidget (); |
450 if (minutes < 0 || minutes > 59) return; | 451 if (minutes < 0 || minutes > 59) return; |
451 NSCalendarDate date = getCalendarDate(); | 452 NSCalendarDate date = getCalendarDate(); |
452 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), | 453 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), |
453 date.hourOfDay(), minutes, date.secondOfMinute(), date.timeZone()); | 454 date.hourOfDay(), minutes, date.secondOfMinute(), date.timeZone()); |
454 (cast(NSDatePicker)view).setDateValue(newDate); | 455 (cast(NSDatePicker)view).setDateValue(newDate); |
455 } | 456 } |
456 | 457 |
457 /** | 458 /** |
458 * Sets the receiver's month. | 459 * Sets the receiver's month. |
469 */ | 470 */ |
470 public void setMonth (int month) { | 471 public void setMonth (int month) { |
471 checkWidget (); | 472 checkWidget (); |
472 NSCalendarDate date = getCalendarDate(); | 473 NSCalendarDate date = getCalendarDate(); |
473 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), month + 1, date.dayOfMonth(), | 474 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), month + 1, date.dayOfMonth(), |
474 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); | 475 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); |
475 if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is date.dayOfMonth()) { | 476 if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is date.dayOfMonth()) { |
476 (cast(NSDatePicker)view).setDateValue(newDate); | 477 (cast(NSDatePicker)view).setDateValue(newDate); |
477 } | 478 } |
478 } | 479 } |
479 | 480 |
493 public void setSeconds (int seconds) { | 494 public void setSeconds (int seconds) { |
494 checkWidget (); | 495 checkWidget (); |
495 if (seconds < 0 || seconds > 59) return; | 496 if (seconds < 0 || seconds > 59) return; |
496 NSCalendarDate date = getCalendarDate(); | 497 NSCalendarDate date = getCalendarDate(); |
497 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), | 498 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), |
498 date.hourOfDay(), date.minuteOfHour(), seconds, date.timeZone()); | 499 date.hourOfDay(), date.minuteOfHour(), seconds, date.timeZone()); |
499 (cast(NSDatePicker)view).setDateValue(newDate); | 500 (cast(NSDatePicker)view).setDateValue(newDate); |
500 } | 501 } |
501 | 502 |
502 /** | 503 /** |
503 * Sets the receiver's hours, minutes, and seconds in a single operation. | 504 * Sets the receiver's hours, minutes, and seconds in a single operation. |
516 public void setTime (int hours, int minutes, int seconds) { | 517 public void setTime (int hours, int minutes, int seconds) { |
517 checkWidget (); | 518 checkWidget (); |
518 if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) return; | 519 if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) return; |
519 NSCalendarDate date = getCalendarDate(); | 520 NSCalendarDate date = getCalendarDate(); |
520 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), | 521 NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(), |
521 hours, minutes, seconds, date.timeZone()); | 522 hours, minutes, seconds, date.timeZone()); |
522 (cast(NSDatePicker)view).setDateValue(newDate); | 523 (cast(NSDatePicker)view).setDateValue(newDate); |
523 } | 524 } |
524 | 525 |
525 /** | 526 /** |
526 * Sets the receiver's year. | 527 * Sets the receiver's year. |
537 */ | 538 */ |
538 public void setYear (int year) { | 539 public void setYear (int year) { |
539 checkWidget (); | 540 checkWidget (); |
540 NSCalendarDate date = getCalendarDate(); | 541 NSCalendarDate date = getCalendarDate(); |
541 NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, date.monthOfYear(), date.dayOfMonth(), | 542 NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, date.monthOfYear(), date.dayOfMonth(), |
542 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); | 543 date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone()); |
543 if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is date.dayOfMonth()) { | 544 if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is date.dayOfMonth()) { |
544 (cast(NSDatePicker)view).setDateValue(newDate); | 545 (cast(NSDatePicker)view).setDateValue(newDate); |
545 } | 546 } |
546 } | 547 } |
547 } | 548 } |