View | Details | Raw Unified | Return to bug 296655
Collapse All | Expand All

(-)Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java (+20 lines)
Lines 2058-2063 Link Here
2058
		lock.unlock();
2058
		lock.unlock();
2059
	}
2059
	}
2060
}
2060
}
2061
/** @param time cast=(GTimeVal *) */
2062
public static final native void _g_get_current_time(int[] /*long*/ time);
2063
public static final void g_get_current_time (int[] /*long*/ time) {
2064
	lock.lock();
2065
	try {
2066
		_g_get_current_time(time);
2067
	} finally {
2068
		lock.unlock();
2069
	}
2070
}
2061
/** @method flags=dynamic */
2071
/** @method flags=dynamic */
2062
public static final native int /*long*/ _g_icon_to_string(int /*long*/ icon);
2072
public static final native int /*long*/ _g_icon_to_string(int /*long*/ icon);
2063
public static final int /*long*/ g_icon_to_string (int /*long*/ icon) {
2073
public static final int /*long*/ g_icon_to_string (int /*long*/ icon) {
Lines 14924-14927 Link Here
14924
		lock.unlock();
14934
		lock.unlock();
14925
	}
14935
	}
14926
}
14936
}
14937
/** @param time cast=(const time_t *) */
14938
public static final native int _localtime(int[] /*long*/ time);
14939
public static final int localtime(int[] /*long*/ time) {
14940
	lock.lock();
14941
	try {
14942
		return _localtime(time);
14943
	} finally {
14944
		lock.unlock();
14945
	}
14946
}
14927
}
14947
}
(-)Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java (-3 / +22 lines)
Lines 252-257 Link Here
252
		} else {
252
		} else {
253
			OS.gtk_calendar_display_options(handle, OS.GTK_CALENDAR_SHOW_HEADING | OS.GTK_CALENDAR_SHOW_DAY_NAMES);			
253
			OS.gtk_calendar_display_options(handle, OS.GTK_CALENDAR_SHOW_HEADING | OS.GTK_CALENDAR_SHOW_DAY_NAMES);			
254
		}
254
		}
255
		hours = minutes = seconds = -1;
255
	} else {
256
	} else {
256
		super.createHandle(index);
257
		super.createHandle(index);
257
	}
258
	}
Lines 382-388 Link Here
382
public int getHours () {
383
public int getHours () {
383
	checkWidget ();
384
	checkWidget ();
384
	if ((style & SWT.CALENDAR) != 0) {
385
	if ((style & SWT.CALENDAR) != 0) {
385
		return hours;
386
		if (hours != -1) return hours;
387
		int[] t_time = new int[2];
388
		OS.g_get_current_time (t_time);
389
		int /*long*/ time = OS.localtime (t_time);
390
		int[] dest = new int[9];
391
		OS.memmove(dest, time, 9 * 4);
392
		return dest[2];
386
	} else {
393
	} else {
387
		return calendar.get(Calendar.HOUR_OF_DAY);
394
		return calendar.get(Calendar.HOUR_OF_DAY);
388
	}
395
	}
Lines 404-410 Link Here
404
public int getMinutes () {
411
public int getMinutes () {
405
	checkWidget ();
412
	checkWidget ();
406
	if ((style & SWT.CALENDAR) != 0) {
413
	if ((style & SWT.CALENDAR) != 0) {
407
		return minutes;
414
		if (minutes != -1) return minutes;
415
		int[] t_time = new int[2];
416
		OS.g_get_current_time (t_time);
417
		int /*long*/ time = OS.localtime (t_time);
418
		int[] dest = new int[9];
419
		OS.memmove(dest, time, 9 * 4);
420
		return dest[1];
408
	} else {
421
	} else {
409
		return calendar.get(Calendar.MINUTE);
422
		return calendar.get(Calendar.MINUTE);
410
	}
423
	}
Lines 454-460 Link Here
454
public int getSeconds () {
467
public int getSeconds () {
455
	checkWidget ();
468
	checkWidget ();
456
	if ((style & SWT.CALENDAR) != 0) {
469
	if ((style & SWT.CALENDAR) != 0) {
457
		return seconds;
470
		if (seconds != -1) return seconds;
471
		int[] t_time = new int[2];
472
		OS.g_get_current_time (t_time);
473
		int /*long*/ time = OS.localtime (t_time);
474
		int[] dest = new int[9];
475
		OS.memmove(dest, time, 9 * 4);
476
		return dest[0];
458
	} else {
477
	} else {
459
		return calendar.get(Calendar.SECOND);
478
		return calendar.get(Calendar.SECOND);
460
	}
479
	}
(-)Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java (-9 / +7 lines)
Lines 186-191 Link Here
186
		TCHAR lpszFormat = new TCHAR (0, buffer, true);
186
		TCHAR lpszFormat = new TCHAR (0, buffer, true);
187
		OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat);
187
		OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat);
188
	}
188
	}
189
	if ((this.style & SWT.CALENDAR) != 0) time.wHour = time.wMinute = time.wSecond = -1;
189
}
190
}
190
191
191
/**
192
/**
Lines 568-577 Link Here
568
 */
569
 */
569
public int getHours () {
570
public int getHours () {
570
	checkWidget ();
571
	checkWidget ();
571
	if ((style & SWT.CALENDAR) != 0) return time.wHour;
572
	if ((style & SWT.CALENDAR) != 0 && time.wHour != -1) return time.wHour;
572
	SYSTEMTIME systime = new SYSTEMTIME ();
573
	SYSTEMTIME systime = new SYSTEMTIME ();
573
	int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
574
	OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime);
574
	OS.SendMessage (handle, msg, 0, systime);
575
	return systime.wHour;
575
	return systime.wHour;
576
}
576
}
577
577
Lines 590-599 Link Here
590
 */
590
 */
591
public int getMinutes () {
591
public int getMinutes () {
592
	checkWidget ();
592
	checkWidget ();
593
	if ((style & SWT.CALENDAR) != 0) return time.wMinute;
593
	if ((style & SWT.CALENDAR) != 0 && time.wMinute != -1) return time.wMinute;
594
	SYSTEMTIME systime = new SYSTEMTIME ();
594
	SYSTEMTIME systime = new SYSTEMTIME ();
595
	int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
595
	OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime);
596
	OS.SendMessage (handle, msg, 0, systime);
597
	return systime.wMinute;
596
	return systime.wMinute;
598
}
597
}
599
598
Lines 638-647 Link Here
638
 */
637
 */
639
public int getSeconds () {
638
public int getSeconds () {
640
	checkWidget ();
639
	checkWidget ();
641
	if ((style & SWT.CALENDAR) != 0) return time.wSecond;
640
	if ((style & SWT.CALENDAR) != 0 && time.wSecond != -1) return time.wSecond;
642
	SYSTEMTIME systime = new SYSTEMTIME ();
641
	SYSTEMTIME systime = new SYSTEMTIME ();
643
	int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
642
	OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime);
644
	OS.SendMessage (handle, msg, 0, systime);
645
	return systime.wSecond;
643
	return systime.wSecond;
646
}
644
}
647
645

Return to bug 296655