# HG changeset patch # User davelzg@gmail.com # Date 1203612193 -28800 # Node ID cd28aa5221a35e72ab434986fabdf9cfcf7032df # Parent 07ed83d51a195ceee10ea61a6c9be6e85091d233 Added DateTime widget port. by Zhiguang Liang but we need to pay attention to the java code. Mostly is the call of following: size = OS.GetDateFormat if it fails, MSDN says size would be 0, reasons : 1.ERROR_INSUFFICIENT_BUFFER 2.ERROR_INVALID_FLAGS 3.ERROR_INVALID_PARAMETER since the second time calling , the java code uses the exactly same args. So I assume the javacode is trying to retry for the 1st case. But it shouldn't allocate an empty array for this? weird... diff -r 07ed83d51a19 -r cd28aa5221a3 dwt/widgets/DateTime.d --- a/dwt/widgets/DateTime.d Fri Feb 22 00:40:30 2008 +0800 +++ b/dwt/widgets/DateTime.d Fri Feb 22 00:43:13 2008 +0800 @@ -14,22 +14,18 @@ import dwt.widgets.Composite; -class DateTime : Composite { -} -/++ import dwt.DWT; import dwt.DWTException; import dwt.events.SelectionEvent; import dwt.events.SelectionListener; import dwt.graphics.Point; -import dwt.internal.win32.INITCOMMONCONTROLSEX; -import dwt.internal.win32.LRESULT; -import dwt.internal.win32.NMHDR; import dwt.internal.win32.OS; -import dwt.internal.win32.RECT; -import dwt.internal.win32.SYSTEMTIME; -import dwt.internal.win32.TCHAR; -import dwt.internal.win32.WNDCLASS; + +import dwt.widgets.TypedListener; + +import dwt.dwthelper.utils; + +import Integer = tango.text.convert.Integer; //TODO - features not yet implemented: read-only, drop-down calendar for date //TODO - font, colors, background image not yet implemented (works on some platforms) @@ -58,44 +54,56 @@ * @since 3.3 */ -public class DateTime extends Composite { +public class DateTime : Composite { alias Composite.computeSize computeSize; alias Composite.windowProc windowProc; - static final int DateTimeProc; - static final TCHAR DateTimeClass = new TCHAR (0, OS.DATETIMEPICK_CLASS, true); - static final int CalendarProc; - static final TCHAR CalendarClass = new TCHAR (0, OS.MONTHCAL_CLASS, true); - static { - INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX (); - icex.dwSize = INITCOMMONCONTROLSEX.sizeof; - icex.dwICC = OS.ICC_DATE_CLASSES; - OS.InitCommonControlsEx (icex); - WNDCLASS lpWndClass = new WNDCLASS (); - OS.GetClassInfo (0, DateTimeClass, lpWndClass); - DateTimeProc = lpWndClass.lpfnWndProc; - OS.GetClassInfo (0, CalendarClass, lpWndClass); - CalendarProc = lpWndClass.lpfnWndProc; + static /+const+/ WNDPROC DateTimeProc; + static const TCHAR* DateTimeClass = OS.DATETIMEPICK_CLASS.ptr; + static /+const+/ WNDPROC CalendarProc; + static const TCHAR* CalendarClass = OS.MONTHCAL_CLASS.ptr; + + private static bool static_this_completed = false; + private static void static_this() { + if( static_this_completed ){ + return; + } + synchronized { + if( static_this_completed ){ + return; + } + INITCOMMONCONTROLSEX icex; + icex.dwSize = INITCOMMONCONTROLSEX.sizeof; + icex.dwICC = OS.ICC_DATE_CLASSES; + OS.InitCommonControlsEx (&icex); + WNDCLASS lpWndClass; + OS.GetClassInfo (null, DateTimeClass, &lpWndClass); + DateTimeProc = lpWndClass.lpfnWndProc; + OS.GetClassInfo (null, CalendarClass, &lpWndClass); + CalendarProc = lpWndClass.lpfnWndProc; + static_this_completed = true; + } } - static final int MARGIN = 4; - static final int MAX_DIGIT = 9; - static final int MAX_DAY = 31; - static final int MAX_12HOUR = 12; - static final int MAX_24HOUR = 24; - static final int MAX_MINUTE = 60; - static final int MONTH_DAY_YEAR = 0; - static final int DAY_MONTH_YEAR = 1; - static final int YEAR_MONTH_DAY = 2; - static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text - static final char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day - static final char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month - static final char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year - static final char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours - static final char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes - static final char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds - static final char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm - 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}; + + static const int MARGIN = 4; + static const int MAX_DIGIT = 9; + static const int MAX_DAY = 31; + static const int MAX_12HOUR = 12; + static const int MAX_24HOUR = 24; + static const int MAX_MINUTE = 60; + static const int MONTH_DAY_YEAR = 0; + static const int DAY_MONTH_YEAR = 1; + static const int YEAR_MONTH_DAY = 2; + static const char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text + static const char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day + static const char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month + static const char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year + static const char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours + static const char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes + static const char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds + static const char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm + 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]; /** @@ -128,12 +136,13 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public DateTime (Composite parent, int style) { +public this (Composite parent, int style) { + static_this(); super (parent, checkStyle (style)); if ((this.style & DWT.SHORT) !is 0) { - String buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); - TCHAR lpszFormat = new TCHAR (0, buffer, true); - OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat); + char[] buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); + TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true); + OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr); } } @@ -169,9 +178,9 @@ addListener (DWT.DefaultSelection, typedListener); } -override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { - if (handle is 0) return 0; - return OS.CallWindowProc (windowProc (), hwnd, msg, wParam, lParam); +override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { + if (handle is null) return 0; + return OS.CallWindowProc ( cast(WNDPROC)windowProc(), hwnd, msg, wParam, lParam); } static int checkStyle (int style) { @@ -196,33 +205,33 @@ int width = 0, height = 0; if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { if ((style & DWT.CALENDAR) !is 0) { - RECT rect = new RECT (); - OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, rect); + RECT rect; + OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, &rect); width = rect.right; height = rect.bottom; } else { - TCHAR buffer = new TCHAR (getCodePage (), 128); - int newFont, oldFont = 0; - int hDC = OS.GetDC (handle); - newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); - if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); - RECT rect = new RECT (); + TCHAR[] buffer = new TCHAR[128]; + void* newFont = cast(void*)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0), oldFont = null; + auto hDC = OS.GetDC (handle); +// newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); + if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); + RECT rect; int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX; - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; if ((style & DWT.DATE) !is 0) { /* Determine the widest/tallest year string. */ systime.wMonth = 1; systime.wDay = 1; int widest = 0, secondWidest = 0, thirdWidest = 0; for (int i = 0; i <= MAX_DIGIT; i++) { - systime.wYear = (short) (2000 + i); // year 2000 + i is guaranteed to exist - int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ()); + systime.wYear = cast(short) (2000 + i); // year 2000 + i is guaranteed to exist + int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); if (rect.right - rect.left >= width) { width = rect.right - rect.left; thirdWidest = secondWidest; @@ -234,39 +243,39 @@ if (widest > 1) widest = widest * 1000 + widest * 100 + widest * 10 + widest; else if (secondWidest > 1) widest = secondWidest * 1000 + widest * 100 + widest * 10 + widest; else widest = thirdWidest * 1000 + widest * 100 + widest * 10 + widest; - systime.wYear = (short) widest; + systime.wYear = cast(short) widest; /* Determine the widest/tallest month name string. */ width = widest = 0; for (short i = 0; i < MONTH_NAMES.length; i++) { int name = MONTH_NAMES [i]; - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ()); + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); if (rect.right - rect.left > width) { width = rect.right - rect.left; widest = i; } height = Math.max(height, rect.bottom - rect.top); } - systime.wMonth = (short) (widest + 1); + systime.wMonth = cast(short) (widest + 1); /* Determine the widest/tallest date string in the widest month of the widest year. */ int dwFlags = ((style & DWT.MEDIUM) !is 0) ? OS.DATE_SHORTDATE : ((style & DWT.SHORT) !is 0) ? OS.DATE_YEARMONTH : OS.DATE_LONGDATE; width = 0; for (short i = 1; i <= MAX_DAY; i++) { systime.wDay = i; - int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); width = Math.max(width, rect.right - rect.left); height = Math.max(height, rect.bottom - rect.top); if ((style & DWT.SHORT) !is 0) break; @@ -278,13 +287,13 @@ int max = is24HourTime () ? MAX_24HOUR : MAX_12HOUR; for (short i = 0; i < max; i++) { systime.wHour = i; - int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); if (rect.right - rect.left > width) { width = rect.right - rect.left; widest = i; @@ -297,13 +306,13 @@ width = widest = 0; for (short i = 0; i < MAX_MINUTE; i++) { systime.wMinute = i; - int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); if (rect.right - rect.left > width) { width = rect.right - rect.left; widest = i; @@ -314,17 +323,17 @@ systime.wSecond = widest; /* Determine the widest/tallest time string for the widest hour, widest minute, and if applicable, widest second. */ - int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); if (size is 0) { - buffer = new TCHAR (getCodePage (), size); - OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); + buffer = new TCHAR[size]; + OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); } rect.left = rect.top = rect.right = rect.bottom = 0; - OS.DrawText (hDC, buffer, size, rect, flags); + OS.DrawText (hDC, buffer.ptr, size, &rect, flags); width = rect.right - rect.left; height = Math.max(height, rect.bottom - rect.top); } - if (newFont !is 0) OS.SelectObject (hDC, oldFont); + if (newFont !is null) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL); width += upDownWidth + MARGIN; @@ -353,7 +362,7 @@ return OS.GetSysColor (OS.COLOR_WINDOW); } -String getComputeSizeString () { +char[] getComputeSizeString () { // TODO: Not currently used but might need for WinCE if ((style & DWT.DATE) !is 0) { if ((style & DWT.SHORT) !is 0) return getCustomShortDateFormat (); @@ -367,16 +376,16 @@ return ""; } -String getCustomShortDateFormat () { +char[] getCustomShortDateFormat () { if (true) { - TCHAR tchar = new TCHAR (getCodePage (), 80); - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar, 80); - return size !is 0 ? tchar.toString (0, size - 1) : "M/yyyy"; //$NON-NLS-1$ + TCHAR[] tchar = new TCHAR[80]; + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar.ptr, 80); + return size !is 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/yyyy"; //$NON-NLS-1$ } //TODO: Not currently used, but may need for WinCE (or if numeric short date is required) - StringBuffer buffer = new StringBuffer (getShortDateFormat ()); - int length = buffer.length (); + char[] buffer = getShortDateFormat (); + int length = buffer.length; bool inQuotes = false; int start = 0, end = 0; while (start < length) { @@ -405,13 +414,13 @@ } start++; } - if (start < end) buffer.delete (start, end); - return buffer.toString (); + if (start < end) buffer.length = start - 1; + return buffer; } -String getCustomShortTimeFormat () { - StringBuffer buffer = new StringBuffer (getTimeFormat ()); - int length = buffer.length (); +char[] getCustomShortTimeFormat () { + char[] buffer = getTimeFormat (); + int length = buffer.length; bool inQuotes = false; int start = 0, end = 0; while (start < length) { @@ -427,48 +436,48 @@ } start++; } - if (start < end) buffer.delete (start, end); - return buffer.toString (); + if (start < end) buffer.length = start - 1; + return buffer; } -String getLongDateFormat () { +char[] getLongDateFormat () { //TODO: Not currently used, but may need for WinCE - TCHAR tchar = new TCHAR (getCodePage (), 80); - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar, 80); - return size > 0 ? tchar.toString (0, size - 1) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ + TCHAR tchar[80]; + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar.ptr, 80); + return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ } -String getShortDateFormat () { +char[] getShortDateFormat () { //TODO: Not currently used, but may need for WinCE - TCHAR tchar = new TCHAR (getCodePage (), 80); + TCHAR tchar[80]; //TODO: May need to OR with LOCALE_ICENTURY - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar, 80); - return size > 0 ? tchar.toString (0, size - 1) : "M/d/yyyy"; //$NON-NLS-1$ + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar.ptr, 80); + return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/d/yyyy"; //$NON-NLS-1$ } int getShortDateFormatOrdering () { //TODO: Not currently used, but may need for WinCE - TCHAR tchar = new TCHAR (getCodePage (), 4); - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar, 4); + TCHAR tchar[80]; + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4); if (size > 0) { - String number = tchar.toString (0, size - 1); - return Integer.parseInt (number); + char[] number = TCHARsToStr(tchar[0..size - 1]); + return Integer.parse (number); } return 0; } -String getTimeFormat () { - TCHAR tchar = new TCHAR (getCodePage (), 80); - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar, 80); - return size > 0 ? tchar.toString (0, size - 1) : "h:mm:ss tt"; //$NON-NLS-1$ +char[] getTimeFormat () { + TCHAR tchar[80]; + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar.ptr, 80); + return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "h:mm:ss tt"; //$NON-NLS-1$ } bool is24HourTime () { - TCHAR tchar = new TCHAR (getCodePage (), 4); - int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar, 4); + TCHAR tchar[4]; + int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4); if (size > 0) { - String number = tchar.toString (0, size - 1); - return Integer.parseInt (number) !is 0; + char[] number = TCHARsToStr(tchar[0..size - 1]); + return Integer.parse (number) !is 0; } return true; } @@ -488,9 +497,9 @@ */ public int getDay () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wDay; } @@ -509,9 +518,9 @@ */ public int getHours () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wHour; } @@ -530,9 +539,9 @@ */ public int getMinutes () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wMinute; } @@ -551,13 +560,13 @@ */ public int getMonth () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wMonth - 1; } -override String getNameText () { +override char[] getNameText () { return "DateTime"; } @@ -576,9 +585,9 @@ */ public int getSeconds () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wSecond; } @@ -597,9 +606,9 @@ */ public int getYear () { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); return systime.wYear; } @@ -643,12 +652,12 @@ */ public void setDay (int day) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wDay = (short)day; - OS.SendMessage (handle, msg, 0, systime); + systime.wDay = cast(short)day; + OS.SendMessage (handle, msg, 0, &systime); } /** @@ -666,12 +675,12 @@ */ public void setHours (int hours) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wHour = (short)hours; - OS.SendMessage (handle, msg, 0, systime); + systime.wHour = cast(short)hours; + OS.SendMessage (handle, msg, 0, &systime); } /** @@ -689,12 +698,12 @@ */ public void setMinutes (int minutes) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wMinute = (short)minutes; - OS.SendMessage (handle, msg, 0, systime); + systime.wMinute = cast(short)minutes; + OS.SendMessage (handle, msg, 0, &systime); } /** @@ -712,12 +721,12 @@ */ public void setMonth (int month) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wMonth = (short)(month + 1); - OS.SendMessage (handle, msg, 0, systime); + systime.wMonth = cast(short)(month + 1); + OS.SendMessage (handle, msg, 0, &systime); } /** @@ -735,12 +744,12 @@ */ public void setSeconds (int seconds) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wSecond = (short)seconds; - OS.SendMessage (handle, msg, 0, systime); + systime.wSecond = cast(short)seconds; + OS.SendMessage (handle, msg, 0, &systime); } /** @@ -758,12 +767,12 @@ */ public void setYear (int year) { checkWidget (); - SYSTEMTIME systime = new SYSTEMTIME (); + SYSTEMTIME systime; int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, msg, 0, &systime); msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; - systime.wYear = (short)year; - OS.SendMessage (handle, msg, 0, systime); + systime.wYear = cast(short)year; + OS.SendMessage (handle, msg, 0, &systime); } override int widgetStyle () { @@ -780,15 +789,15 @@ return bits; } -override TCHAR windowClass () { - return (style & DWT.CALENDAR) !is 0 ? CalendarClass : DateTimeClass; +override char[] windowClass () { + return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass); } override int windowProc () { - return (style & DWT.CALENDAR) !is 0 ? CalendarProc : DateTimeProc; + return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc; } -override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) { +override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { switch (hdr.code) { case OS.MCN_SELCHANGE: //SENT WHEN YOU SET IT? case OS.DTN_DATETIMECHANGE: @@ -799,4 +808,4 @@ return super.wmNotifyChild (hdr, wParam, lParam); } } -++/ +