# HG changeset patch # User Frank Benoit # Date 1201884336 -3600 # Node ID f5e70f9aeeda59a9dfdf8d8a7577a4e797f40063 # Parent 4d6511d2441fe4913e215421f0a2e9c2ad83af4e Decorations diff -r 4d6511d2441f -r f5e70f9aeeda dwt/internal/win32/OS.d --- a/dwt/internal/win32/OS.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/internal/win32/OS.d Fri Feb 01 17:45:36 2008 +0100 @@ -72,8 +72,11 @@ } public static const BOOL IsPPC_; - public static const BOOL IsHPC; - public static const BOOL IsSP_; + public static const BOOL IsHPC = false; + + // PORTING_FIXME, is it Windows WFSP? + public static const BOOL IsSP_ = false; + public static const BOOL IsDBLocale; version(ANSI) { @@ -115,9 +118,9 @@ IsWin32s = (info.dwPlatformId is VER_PLATFORM_WIN32s); IsWin95 = (info.dwPlatformId is VER_PLATFORM_WIN32_WINDOWS); IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT); - IsSP_ = false; + //IsSP_ = false; IsPPC_ = false; - IsHPC = false; + //IsHPC = false; IsDBLocale = false; WIN32_MAJOR = info.dwMajorVersion; WIN32_MINOR = info.dwMinorVersion; @@ -3876,6 +3879,7 @@ alias WINAPI.GetCharWidthA GetCharWidth; alias WINAPI.GetCharacterPlacementA GetCharacterPlacement; alias WINAPI.GetClassInfoA GetClassInfo; + alias STDWIN.GetClassNameA GetClassName; alias WINAPI.GetClipboardFormatNameA GetClipboardFormatName; alias WINAPI.GetKeyNameTextA GetKeyNameText; alias WINAPI.GetLocaleInfoA GetLocaleInfo; @@ -3973,6 +3977,7 @@ alias WINAPI.GetCharWidthW GetCharWidth; alias WINAPI.GetCharacterPlacementW GetCharacterPlacement; alias WINAPI.GetClassInfoW GetClassInfo; + alias STDWIN.GetClassNameW GetClassName; alias WINAPI.GetClipboardFormatNameW GetClipboardFormatName; alias WINAPI.GetKeyNameTextW GetKeyNameText; alias WINAPI.GetLocaleInfoW GetLocaleInfo; diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/Button.d --- a/dwt/widgets/Button.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/Button.d Fri Feb 01 17:45:36 2008 +0100 @@ -15,6 +15,8 @@ import dwt.widgets.Control; class Button : Control{ +void setDefault (bool value) ; +void click () ; } /++ diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/Decorations.d --- a/dwt/widgets/Decorations.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/Decorations.d Fri Feb 01 17:45:36 2008 +0100 @@ -12,37 +12,26 @@ *******************************************************************************/ module dwt.widgets.Decorations; -import dwt.widgets.Canvas; -import dwt.widgets.Menu; -import dwt.widgets.Control; -import dwt.internal.win32.OS; -class Decorations : Canvas { -Menu findMenu (HMENU hMenu) ; -void bringToTop () ; -void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) ; -void setSavedFocus (Control control) ; -public Menu getMenuBar () ; -void saveFocus () ; -} -/++ import dwt.DWT; import dwt.DWTException; import dwt.graphics.Image; import dwt.graphics.ImageData; import dwt.graphics.Point; import dwt.graphics.Rectangle; -import dwt.internal.win32.ACCEL; -import dwt.internal.win32.CREATESTRUCT; -import dwt.internal.win32.LRESULT; -import dwt.internal.win32.MENUITEMINFO; -import dwt.internal.win32.MSG; import dwt.internal.win32.OS; -import dwt.internal.win32.RECT; -import dwt.internal.win32.STARTUPINFO; -import dwt.internal.win32.TCHAR; -import dwt.internal.win32.WINDOWPLACEMENT; -import dwt.internal.win32.WINDOWPOS; + +import dwt.widgets.Canvas; +import dwt.widgets.Menu; +import dwt.widgets.Control; +import dwt.widgets.Button; +import dwt.widgets.Composite; +import dwt.widgets.Event; +import dwt.widgets.Shell; +import dwt.widgets.MenuItem; +import dwt.widgets.Display; + +import dwt.dwthelper.utils; /** * Instances of this class provide the appearance and @@ -122,14 +111,16 @@ * @see DWT */ -public class Decorations extends Canvas { +public class Decorations : Canvas { Image image, smallImage, largeImage; Image [] images; Menu menuBar; Menu [] menus; Control savedFocus; Button defaultButton, saveDefault; - int swFlags, hAccel, nAccel; + int swFlags; + HACCEL hAccel; + int nAccel; bool moved, resized, opened; int oldX = OS.CW_USEDEFAULT, oldY = OS.CW_USEDEFAULT; int oldWidth = OS.CW_USEDEFAULT, oldHeight = OS.CW_USEDEFAULT; @@ -137,7 +128,7 @@ /** * Prevents uninitialized instances from being created outside the package. */ -Decorations () { +this () { } /** @@ -178,7 +169,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public Decorations (Composite parent, int style) { +public this (Composite parent, int style) { super (parent, checkStyle (style)); } @@ -190,20 +181,20 @@ * workaround is to resize the window to fit the parent client area. */ if (maximized) { - RECT rect = new RECT (); - OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0); + RECT rect; + OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); int width = rect.right - rect.left, height = rect.bottom - rect.top; - if (OS.IsPPC) { + if (OS.IsPPC_) { /* Leave space for the menu bar */ if (menuBar !is null) { - int hwndCB = menuBar.hwndCB; - RECT rectCB = new RECT (); - OS.GetWindowRect (hwndCB, rectCB); + auto hwndCB = menuBar.hwndCB; + RECT rectCB; + OS.GetWindowRect (hwndCB, &rectCB); height -= rectCB.bottom - rectCB.top; } } int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; - SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags); + SetWindowPos (handle, null, rect.left, rect.top, width, height, flags); } } else { if (!OS.IsWindowVisible (handle)) return; @@ -320,9 +311,9 @@ if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS); } -int callWindowProc (int hwnd, int msg, int wParam, int lParam) { - if (handle is 0) return 0; - return OS.DefMDIChildProc (hwnd, msg, wParam, lParam); +override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { + if (handle is null) return LRESULT.ZERO; + return cast(LRESULT) OS.DefMDIChildProc (hwnd, msg, wParam, lParam); } void closeWidget () { @@ -365,12 +356,12 @@ checkWidget (); /* Get the size of the trimmings */ - RECT rect = new RECT (); - OS.SetRect (rect, x, y, x + width, y + height); + RECT rect; + OS.SetRect (&rect, x, y, x + width, y + height); int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); - bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is 0; - OS.AdjustWindowRectEx (rect, bits1, hasMenu, bits2); + bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is null; + OS.AdjustWindowRectEx (&rect, bits1, hasMenu, bits2); /* Get the size of the scroll bars */ if (horizontalBar !is null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL); @@ -378,30 +369,31 @@ /* Compute the height of the menu bar */ if (hasMenu) { - RECT testRect = new RECT (); - OS.SetRect (testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); - OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect); + RECT testRect; + OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); + OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); while ((testRect.bottom - testRect.top) < height) { if (testRect.bottom - testRect.top is 0) break; rect.top -= OS.GetSystemMetrics (OS.SM_CYMENU) - OS.GetSystemMetrics (OS.SM_CYBORDER); - OS.SetRect (testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); - OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect); + OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); + OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); } } return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } void createAccelerators () { - hAccel = nAccel = 0; + hAccel = null; + nAccel = 0; int maxAccel = 0; MenuItem [] items = display.items; if (menuBar is null || items is null) { - if (!OS.IsPPC) return; + if (!OS.IsPPC_) return; maxAccel = 1; } else { - maxAccel = OS.IsPPC ? items.length + 1 : items.length; + maxAccel = OS.IsPPC_ ? items.length + 1 : items.length; } - ACCEL accel = new ACCEL (); + ACCEL accel; byte [] buffer1 = new byte [ACCEL.sizeof]; byte [] buffer2 = new byte [maxAccel * ACCEL.sizeof]; if (menuBar !is null && items !is null) { @@ -414,8 +406,9 @@ menu = menu.getParentMenu (); } if (menu is menuBar) { - item.fillAccel (accel); - OS.MoveMemory (buffer1, accel, ACCEL.sizeof); + item.fillAccel (&accel); + *cast(ACCEL*)buffer1.ptr = accel; + //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); nAccel++; } @@ -423,19 +416,20 @@ } } } - if (OS.IsPPC) { + if (OS.IsPPC_) { /* * Note on WinCE PPC. Close the shell when user taps CTRL-Q. * IDOK represents the "Done Button" which also closes the shell. */ - accel.fVirt = (byte) (OS.FVIRTKEY | OS.FCONTROL); - accel.key = (short) 'Q'; - accel.cmd = (short) OS.IDOK; - OS.MoveMemory (buffer1, accel, ACCEL.sizeof); + accel.fVirt = cast(byte) (OS.FVIRTKEY | OS.FCONTROL); + accel.key = cast(short) 'Q'; + accel.cmd = cast(short) OS.IDOK; + *cast(ACCEL*)buffer1.ptr = accel; + //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); nAccel++; } - if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable (buffer2, nAccel); + if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable ( cast(ACCEL*)buffer2.ptr, nAccel); } void createHandle () { @@ -456,7 +450,7 @@ */ if ((state & FOREIGN_HANDLE) is 0) { if (!OS.IsWinCE) { - int hIcon = OS.LoadIcon (0, OS.IDI_APPLICATION); + auto hIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hIcon); } } @@ -465,18 +459,18 @@ void createWidget () { super.createWidget (); swFlags = OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : OS.SW_SHOWNOACTIVATE; - hAccel = -1; + hAccel = cast(HACCEL)-1; } void destroyAccelerators () { - if (hAccel !is 0 && hAccel !is -1) OS.DestroyAcceleratorTable (hAccel); - hAccel = -1; + if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); + hAccel = cast(HACCEL)-1; } public void dispose () { if (isDisposed()) return; if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); - if (!(this instanceof Shell)) { + if (!(cast(Shell)this)) { if (!traverseDecorations (true)) { Shell shell = getShell (); shell.setFocus (); @@ -486,7 +480,7 @@ super.dispose (); } -Menu findMenu (int hMenu) { +Menu findMenu (HMENU hMenu) { if (menus is null) return null; for (int i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * */ -public String getText () { +public char[] getText () { checkWidget (); int length = OS.GetWindowTextLength (handle); if (length is 0) return ""; /* Use the character encoding for the default locale */ - TCHAR buffer = new TCHAR (0, length + 1); - OS.GetWindowText (handle, buffer, length + 1); - return buffer.toString (0, length); + TCHAR[] buffer; + buffer.length = length + 1; + OS.GetWindowText (handle, buffer.ptr, length + 1); + return TCHARsToStr( buffer ); } public bool isReparentable () { @@ -828,8 +823,8 @@ images = null; savedFocus = null; defaultButton = saveDefault = null; - if (hAccel !is 0 && hAccel !is -1) OS.DestroyAcceleratorTable (hAccel); - hAccel = -1; + if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); + hAccel = cast(HACCEL)-1; } void removeMenu (Menu menu) { @@ -874,8 +869,8 @@ } } forceResize (); - RECT rect = new RECT (); - OS.GetWindowRect (handle, rect); + RECT rect; + OS.GetWindowRect (handle, &rect); bool sameOrigin = true; if ((OS.SWP_NOMOVE & flags) is 0) { sameOrigin = rect.left is x && rect.top is y; @@ -886,7 +881,7 @@ sameExtent = rect.right - rect.left is width && rect.bottom - rect.top is height; if (!sameExtent) resized = true; } - if (!OS.IsWinCE) { + static if (!OS.IsWinCE) { if (OS.IsZoomed (handle)) { if (sameOrigin && sameExtent) return; setPlacement (x, y, width, height, flags); @@ -990,7 +985,7 @@ if (smallImage !is null) smallImage.dispose (); if (largeImage !is null) largeImage.dispose (); smallImage = largeImage = null; - int hSmallIcon = 0, hLargeIcon = 0; + HICON hSmallIcon, hLargeIcon; Image smallIcon = null, largeIcon = null; if (image !is null) { smallIcon = largeIcon = image; @@ -1037,7 +1032,7 @@ * process exits. */ if ((state & FOREIGN_HANDLE) is 0) { - hSmallIcon = OS.LoadIcon (0, OS.IDI_APPLICATION); + hSmallIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); } } OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hSmallIcon); @@ -1062,9 +1057,9 @@ * The fix is to force a redraw. */ if (!OS.IsWinCE) { - if (hSmallIcon is 0 && hLargeIcon is 0 && (style & DWT.BORDER) !is 0) { + if (hSmallIcon is null && hLargeIcon is null && (style & DWT.BORDER) !is 0) { int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE; - OS.RedrawWindow (handle, null, 0, flags); + OS.RedrawWindow (handle, null, null, flags); } } } @@ -1155,7 +1150,7 @@ if ((menu.style & DWT.BAR) is 0) error (DWT.ERROR_MENU_NOT_BAR); if (menu.parent !is this) error (DWT.ERROR_INVALID_PARENT); } - if (OS.IsWinCE) { + static if (OS.IsWinCE) { if (OS.IsHPC) { bool resize = menuBar !is menu; if (menuBar !is null) OS.CommandBar_Show (menuBar.hwndCB, false); @@ -1170,7 +1165,7 @@ } } } else { - if (OS.IsPPC) { + if (OS.IsPPC_) { /* * Note in WinCE PPC. The menu bar is a separate popup window. * If the shell is full screen, resize its window to leave @@ -1191,7 +1186,7 @@ } else { if (menu !is null) display.removeBar (menu); menuBar = menu; - int hMenu = menuBar !is null ? menuBar.handle: 0; + auto hMenu = menuBar !is null ? menuBar.handle: null; OS.SetMenu (handle, hMenu); } destroyAccelerators (); @@ -1235,7 +1230,7 @@ * undocumented and possibly dangerous Windows * feature. */ - int hwndParent = parent.handle; + auto hwndParent = parent.handle; display.lockActiveWindow = true; OS.SetParent (handle, hwndParent); if (!OS.IsWindowVisible (hwndParent)) { @@ -1246,14 +1241,14 @@ OS.SetWindowLong (handle, OS.GWL_STYLE, bits | OS.WS_POPUP); OS.SetWindowLong (handle, OS.GWL_ID, 0); int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; - SetWindowPos (handle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags); + SetWindowPos (handle, cast(HWND)OS.HWND_BOTTOM, 0, 0, 0, 0, flags); display.lockActiveWindow = false; } void setPlacement (int x, int y, int width, int height, int flags) { - WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT (); + WINDOWPLACEMENT lpwndpl; lpwndpl.length = WINDOWPLACEMENT.sizeof; - OS.GetWindowPlacement (handle, lpwndpl); + OS.GetWindowPlacement (handle, &lpwndpl); lpwndpl.showCmd = OS.SW_SHOWNA; if (OS.IsIconic (handle)) { lpwndpl.showCmd = OS.SW_SHOWMINNOACTIVE; @@ -1264,19 +1259,19 @@ } bool sameOrigin = true; if ((flags & OS.SWP_NOMOVE) is 0) { - sameOrigin = lpwndpl.left !is x || lpwndpl.top !is y; - lpwndpl.right = x + (lpwndpl.right - lpwndpl.left); - lpwndpl.bottom = y + (lpwndpl.bottom - lpwndpl.top); - lpwndpl.left = x; - lpwndpl.top = y; + sameOrigin = lpwndpl.rcNormalPosition.left !is x || lpwndpl.rcNormalPosition.top !is y; + lpwndpl.rcNormalPosition.right = x + (lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left); + lpwndpl.rcNormalPosition.bottom = y + (lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top); + lpwndpl.rcNormalPosition.left = x; + lpwndpl.rcNormalPosition.top = y; } bool sameExtent = true; if ((flags & OS.SWP_NOSIZE) is 0) { - sameExtent = lpwndpl.right - lpwndpl.left !is width || lpwndpl.bottom - lpwndpl.top !is height; - lpwndpl.right = lpwndpl.left + width; - lpwndpl.bottom = lpwndpl.top + height; + sameExtent = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left !is width || lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top !is height; + lpwndpl.rcNormalPosition.right = lpwndpl.rcNormalPosition.left + width; + lpwndpl.rcNormalPosition.bottom = lpwndpl.rcNormalPosition.top + height; } - OS.SetWindowPlacement (handle, lpwndpl); + OS.SetWindowPlacement (handle, &lpwndpl); if (OS.IsIconic (handle)) { if (sameOrigin) { moved = true; @@ -1293,7 +1288,7 @@ oldHeight = rect.height; sendEvent (DWT.Resize); if (isDisposed ()) return; - if (layout !is null) { + if (layout_ !is null) { markLayout (false, false); updateLayout (true, false); } @@ -1306,9 +1301,9 @@ } void setSystemMenu () { - if (OS.IsWinCE) return; - int hMenu = OS.GetSystemMenu (handle, false); - if (hMenu is 0) return; + static if (OS.IsWinCE) return; + auto hMenu = OS.GetSystemMenu (handle, false); + if (hMenu is null) return; int oldCount = OS.GetMenuItemCount (hMenu); if ((style & DWT.RESIZE) is 0) { OS.DeleteMenu (hMenu, OS.SC_SIZE, OS.MF_BYCOMMAND); @@ -1325,12 +1320,12 @@ int newCount = OS.GetMenuItemCount (hMenu); if ((style & DWT.CLOSE) is 0 || newCount !is oldCount) { OS.DeleteMenu (hMenu, OS.SC_TASKLIST, OS.MF_BYCOMMAND); - MENUITEMINFO info = new MENUITEMINFO (); + MENUITEMINFO info; info.cbSize = MENUITEMINFO.sizeof; info.fMask = OS.MIIM_ID; int index = 0; while (index < newCount) { - if (OS.GetMenuItemInfo (hMenu, index, true, info)) { + if (OS.GetMenuItemInfo (hMenu, index, true, &info)) { if (info.wID is OS.SC_CLOSE) break; } index++; @@ -1359,12 +1354,11 @@ *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • * */ -public void setText (String string) { +public void setText (char[] string) { checkWidget (); if (string is null) error (DWT.ERROR_NULL_ARGUMENT); /* Use the character encoding for the default locale */ - TCHAR buffer = new TCHAR (0, string, true); - OS.SetWindowText (handle, buffer); + OS.SetWindowText (handle, StrToTCHARz(string)); } public void setVisible (bool visible) { @@ -1382,23 +1376,23 @@ */ sendEvent (DWT.Show); if (isDisposed ()) return; - if (OS.IsHPC) { + static if (OS.IsHPC) { if (menuBar !is null) { - int hwndCB = menuBar.hwndCB; + auto hwndCB = menuBar.hwndCB; OS.CommandBar_DrawMenuBar (hwndCB, 0); } } if (drawCount !is 0) { state &= ~HIDDEN; } else { - if (OS.IsWinCE) { + static if (OS.IsWinCE) { OS.ShowWindow (handle, OS.SW_SHOW); } else { if (menuBar !is null) { display.removeBar (menuBar); OS.DrawMenuBar (handle); } - STARTUPINFO lpStartUpInfo = Display.lpStartupInfo; + STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo; if (lpStartUpInfo !is null && (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) !is 0) { OS.ShowWindow (handle, lpStartUpInfo.wShowWindow); } else { @@ -1422,7 +1416,7 @@ OS.UpdateWindow (handle); } } else { - if (!OS.IsWinCE) { + static if (!OS.IsWinCE) { if (OS.IsIconic (handle)) { swFlags = OS.SW_SHOWMINNOACTIVE; } else { @@ -1467,7 +1461,7 @@ } } -bool translateAccelerator (MSG msg) { +bool translateAccelerator (MSG* msg) { if (!isEnabled () || !isActive ()) return false; if (menuBar !is null && !menuBar.isEnabled ()) return false; if (translateMDIAccelerator (msg) || translateMenuAccelerator (msg)) return true; @@ -1475,16 +1469,16 @@ return decorations.translateAccelerator (msg); } -bool translateMenuAccelerator (MSG msg) { - if (hAccel is -1) createAccelerators (); - return hAccel !is 0 && OS.TranslateAccelerator (handle, hAccel, msg) !is 0; +bool translateMenuAccelerator (MSG* msg) { + if (hAccel is cast(HACCEL)-1) createAccelerators (); + return hAccel !is null && OS.TranslateAccelerator (handle, hAccel, msg) !is 0; } -bool translateMDIAccelerator (MSG msg) { - if (!(this instanceof Shell)) { +bool translateMDIAccelerator (MSG* msg) { + if (!(cast(Shell)this)) { Shell shell = getShell (); - int hwndMDIClient = shell.hwndMDIClient; - if (hwndMDIClient !is 0 && OS.TranslateMDISysAccel (hwndMDIClient, msg)) { + auto hwndMDIClient = shell.hwndMDIClient_; + if (hwndMDIClient !is null && OS.TranslateMDISysAccel (hwndMDIClient, msg)) { return true; } if (msg.message is OS.WM_KEYDOWN) { @@ -1527,7 +1521,7 @@ int start = index, offset = (next) ? 1 : -1; while ((index = (index + offset + length) % length) !is start) { Control child = children [index]; - if (!child.isDisposed () && child instanceof Decorations) { + if (!child.isDisposed () && ( null !is cast(Decorations)child)) { if (child.setFocus ()) return true; } } @@ -1545,7 +1539,7 @@ return true; } -CREATESTRUCT widgetCreateStruct () { +CREATESTRUCT* widgetCreateStruct () { return new CREATESTRUCT (); } @@ -1553,7 +1547,7 @@ int bits = super.widgetExtStyle () | OS.WS_EX_MDICHILD; bits &= ~OS.WS_EX_CLIENTEDGE; if ((style & DWT.NO_TRIM) !is 0) return bits; - if (OS.IsPPC) { + if (OS.IsPPC_) { if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_EX_CAPTIONOKBTN; } if ((style & DWT.RESIZE) !is 0) return bits; @@ -1561,7 +1555,7 @@ return bits; } -int widgetParent () { +HWND widgetParent () { Shell shell = getShell (); return shell.hwndMDIClient (); } @@ -1590,32 +1584,32 @@ * the Shell according to the state of the IME. * It does not set the WS_THICKFRAME style. */ - if (!OS.IsPPC) bits |= OS.WS_THICKFRAME; + if (!OS.IsPPC_) bits |= OS.WS_THICKFRAME; } else { if ((style & DWT.BORDER) is 0) bits |= OS.WS_BORDER; } /* Set the system menu and close box bits */ - if (!OS.IsPPC && !OS.IsSP) { + if (!OS.IsPPC_ && !OS.IsSP_) { if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_SYSMENU; } return bits; } -int windowProc (int hwnd, int msg, int wParam, int lParam) { +override int windowProc (HWND hwnd, int msg, int wParam, int lParam) { switch (msg) { case Display.SWT_GETACCEL: case Display.SWT_GETACCELCOUNT: - if (hAccel is -1) createAccelerators (); - return msg is Display.SWT_GETACCELCOUNT ? nAccel : hAccel; + if (hAccel is cast(HACCEL)-1) createAccelerators (); + return msg is Display.SWT_GETACCELCOUNT ? nAccel : cast(int)hAccel; } return super.windowProc (hwnd, msg, wParam, lParam); } LRESULT WM_ACTIVATE (int wParam, int lParam) { LRESULT result = super.WM_ACTIVATE (wParam, lParam); - if (result !is null) return result; + if (result !is LRESULT.NULL) return result; /* * Feature in AWT. When an AWT Window is activated, * for some reason, it seems to forward the WM_ACTIVATE @@ -1628,11 +1622,11 @@ * focus from the AWT Window. The fix is to ignore * WM_ACTIVATE messages that come from AWT Windows. */ - if (OS.GetParent (lParam) is handle) { - TCHAR buffer = new TCHAR (0, 128); - OS.GetClassName (lParam, buffer, buffer.length ()); - String className = buffer.toString (0, buffer.strlen ()); - if (className.equals (Display.AWT_WINDOW_CLASS)) { + if (OS.GetParent ( cast(HWND)lParam) is handle) { + TCHAR[128] buffer = 0; + OS.GetClassName (cast(HWND)lParam, buffer.ptr, buffer.length ); + char[] className = TCHARzToStr( buffer.ptr ); + if (className == Display.AWT_WINDOW_CLASS) { return LRESULT.ZERO; } } @@ -1644,9 +1638,9 @@ * events or restore the focus. */ if ((wParam >> 16) !is 0) return result; - Control control = display.findControl (lParam); - if (control is null || control instanceof Shell) { - if (this instanceof Shell) { + Control control = display.findControl (cast(HWND)lParam); + if (control is null || (null !is cast(Shell)control)) { + if (cast(Shell)this) { sendEvent (DWT.Activate); if (isDisposed ()) return LRESULT.ZERO; } @@ -1656,9 +1650,9 @@ Display display = this.display; bool lockWindow = display.isXMouseActive (); if (lockWindow) display.lockActiveWindow = true; - Control control = display.findControl (lParam); - if (control is null || control instanceof Shell) { - if (this instanceof Shell) { + Control control = display.findControl (cast(HWND)lParam); + if (control is null || (null !is cast(Shell)control)) { + if (cast(Shell)this) { sendEvent (DWT.Deactivate); if (!isDisposed ()) { Shell shell = getShell (); @@ -1676,32 +1670,34 @@ LRESULT WM_CLOSE (int wParam, int lParam) { LRESULT result = super.WM_CLOSE (wParam, lParam); - if (result !is null) return result; + if (result !is LRESULT.NULL) return result; if (isEnabled () && isActive ()) closeWidget (); return LRESULT.ZERO; } LRESULT WM_HOTKEY (int wParam, int lParam) { LRESULT result = super.WM_HOTKEY (wParam, lParam); - if (result !is null) return result; - if (OS.IsSP) { - /* - * Feature on WinCE SP. The Back key is either used to close - * the foreground Dialog or used as a regular Back key in an EDIT - * control. The article 'Back Key' in MSDN for Smartphone - * describes how an application should handle it. The - * workaround is to override the Back key when creating - * the menubar and handle it based on the style of the Shell. - * If the Shell has the DWT.CLOSE style, close the Shell. - * Otherwise, send the Back key to the window with focus. - */ - if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { - if ((style & DWT.CLOSE) !is 0) { - OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); - } else { - OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); + if (result !is LRESULT.NULL) return result; + static if( OS.IsWinCE ){ + if (OS.IsSP_) { + /* + * Feature on WinCE SP. The Back key is either used to close + * the foreground Dialog or used as a regular Back key in an EDIT + * control. The article 'Back Key' in MSDN for Smartphone + * describes how an application should handle it. The + * workaround is to override the Back key when creating + * the menubar and handle it based on the style of the Shell. + * If the Shell has the DWT.CLOSE style, close the Shell. + * Otherwise, send the Back key to the window with focus. + */ + if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { + if ((style & DWT.CLOSE) !is 0) { + OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); + } else { + OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); + } + return LRESULT.ZERO; } - return LRESULT.ZERO; } } return result; @@ -1717,7 +1713,7 @@ if (moved) { Point location = getLocation (); if (location.x is oldX && location.y is oldY) { - return null; + return LRESULT.NULL; } oldX = location.x; oldY = location.y; @@ -1727,15 +1723,15 @@ LRESULT WM_NCACTIVATE (int wParam, int lParam) { LRESULT result = super.WM_NCACTIVATE (wParam, lParam); - if (result !is null) return result; + if (result !is LRESULT.NULL) return result; if (wParam is 0) { if (display.lockActiveWindow) return LRESULT.ZERO; - Control control = display.findControl (lParam); + Control control = display.findControl (cast(HANDLE)lParam); if (control !is null) { Shell shell = getShell (); Decorations decorations = control.menuShell (); if (decorations.getShell () is shell) { - if (this instanceof Shell) return LRESULT.ONE; + if (cast(Shell)this) return LRESULT.ONE; if (display.ignoreRestoreFocus) { if (display.lastHittest !is OS.HTCLIENT) { result = LRESULT.ONE; @@ -1744,8 +1740,8 @@ } } } - if (!(this instanceof Shell)) { - int hwndShell = getShell().handle; + if (!(cast(Shell)this)) { + auto hwndShell = getShell().handle; OS.SendMessage (hwndShell, OS.WM_NCACTIVATE, wParam, lParam); } return result; @@ -1753,7 +1749,7 @@ LRESULT WM_QUERYOPEN (int wParam, int lParam) { LRESULT result = super.WM_QUERYOPEN (wParam, lParam); - if (result !is null) return result; + if (result !is LRESULT.NULL) return result; sendEvent (DWT.Deiconify); // widget could be disposed at this point return result; @@ -1766,7 +1762,7 @@ } LRESULT WM_SIZE (int wParam, int lParam) { - LRESULT result = null; + LRESULT result = LRESULT.NULL; bool changed = true; if (resized) { int newWidth = 0, newHeight = 0; @@ -1801,8 +1797,8 @@ LRESULT WM_SYSCOMMAND (int wParam, int lParam) { LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); - if (result !is null) return result; - if (!(this instanceof Shell)) { + if (result !is LRESULT.NULL) return result; + if (!(cast(Shell)this)) { int cmd = wParam & 0xFFF0; switch (cmd) { case OS.SC_CLOSE: { @@ -1820,15 +1816,14 @@ LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam); - if (result !is null) return result; + if (result !is LRESULT.NULL) return result; if (display.lockActiveWindow) { - WINDOWPOS lpwp = new WINDOWPOS (); - OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); + WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam; + //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); lpwp.flags |= OS.SWP_NOZORDER; - OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof); + //OS.MoveMemory (lParam, &lpwp, WINDOWPOS.sizeof); } return result; } } -++/ \ No newline at end of file diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/Display.d --- a/dwt/widgets/Display.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/Display.d Fri Feb 01 17:45:36 2008 +0100 @@ -210,12 +210,12 @@ } /* Startup info */ - static STARTUPINFO lpStartupInfo; + static STARTUPINFO* lpStartupInfo; static this() { static if (!OS.IsWinCE) { - //lpStartupInfo = new STARTUPINFO (); + lpStartupInfo = new STARTUPINFO (); lpStartupInfo.cb = STARTUPINFO.sizeof; - OS.GetStartupInfo (&lpStartupInfo); + OS.GetStartupInfo (lpStartupInfo); } } @@ -3387,7 +3387,7 @@ */ public bool readAndDispatch () { checkDevice (); - //lpStartupInfo = null; + lpStartupInfo = null; drawMenuBars (); runPopups (); if (OS.PeekMessage (&msg, null, 0, 0, OS.PM_REMOVE)) { diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/Menu.d --- a/dwt/widgets/Menu.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/Menu.d Fri Feb 01 17:45:36 2008 +0100 @@ -15,10 +15,16 @@ import dwt.widgets.Widget; import dwt.widgets.Decorations; import dwt.widgets.MenuItem; +import dwt.internal.win32.OS; class Menu : Widget { + int x, y; + HBRUSH hBrush; + HWND hwndCB; + int id0, id1; MenuItem cascade; Decorations parent; + HMENU handle; this( Widget, int ); public void setLocation (int x, int y) ; public void setVisible (bool visible) ; @@ -26,6 +32,8 @@ void _setVisible (bool visible) ; public Menu getParentMenu () ; public MenuItem [] getItems () ; +void fixMenus (Decorations newParent) ; +public bool isEnabled () ; } /++ import dwt.DWT; diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/MenuItem.d --- a/dwt/widgets/MenuItem.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/MenuItem.d Fri Feb 01 17:45:36 2008 +0100 @@ -15,9 +15,12 @@ import dwt.widgets.Item; import dwt.widgets.Widget; import dwt.widgets.Menu; +import dwt.internal.win32.OS; class MenuItem : Item { Menu parent, menu; + HBITMAP hBitmap; + int accelerator; int id; public this (Widget parent, int style) { super (parent, style); @@ -27,6 +30,7 @@ LRESULT wmCommandChild (int wParam, int lParam) ; LRESULT wmDrawChild (int wParam, int lParam) ; LRESULT wmMeasureChild (int wParam, int lParam) ; +void fillAccel (ACCEL* accel) ; } /++ import dwt.DWT; @@ -269,7 +273,7 @@ releaseHandle (); } -void fillAccel (ACCEL accel) { +void fillAccel (ACCEL* accel) { accel.fVirt = 0; accel.cmd = accel.key = 0; if (accelerator is 0 || !getEnabled ()) return; diff -r 4d6511d2441f -r f5e70f9aeeda dwt/widgets/Shell.d --- a/dwt/widgets/Shell.d Fri Feb 01 16:16:51 2008 +0100 +++ b/dwt/widgets/Shell.d Fri Feb 01 17:45:36 2008 +0100 @@ -17,6 +17,9 @@ import dwt.internal.win32.OS; class Shell : Decorations { + HIMC hIMC; + HWND hwndMDIClient_; + //, lpstrTip, toolTipHandle, balloonTipHandle; Menu activeMenu; void checkWidget (); void updateModal () ; @@ -29,6 +32,7 @@ void fixToolTip () ; ToolTip findToolTip (int id) ; void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) ; +HWND hwndMDIClient () ; } /++ import dwt.DWT;