# HG changeset patch # User Frank Benoit # Date 1201550739 -3600 # Node ID 39a9959ef14d535270046e8d431b420103006890 # Parent 2985239119a369b799ea83d9bb72b3dcbfbb6216 Display + ImageList diff -r 2985239119a3 -r 39a9959ef14d dwt/dwthelper/System.d --- a/dwt/dwthelper/System.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/dwthelper/System.d Mon Jan 28 21:05:39 2008 +0100 @@ -4,6 +4,7 @@ module dwt.dwthelper.System; import tango.core.Exception; +import tango.stdc.stdlib : exit; template SimpleType(T) { debug{ @@ -124,5 +125,9 @@ return 0; } + static void exit( int code ){ + .exit(code); + } + } diff -r 2985239119a3 -r 39a9959ef14d dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/dwthelper/utils.d Mon Jan 28 21:05:39 2008 +0100 @@ -22,6 +22,8 @@ abstract class ArrayWrapper{ } +abstract class ValueWrapper{ +} class ArrayWrapperT(T) : ArrayWrapper { public T[] array; @@ -30,6 +32,14 @@ } } +class ValueWrapperT(T) : ValueWrapper { + public T value; + public this( T data ){ + value = data; + } +} + +alias ValueWrapperT!(bool) ValueWrapperBool; alias ArrayWrapperT!(byte) ArrayWrapperByte; alias ArrayWrapperT!(int) ArrayWrapperInt; alias ArrayWrapperT!(Object) ArrayWrapperObject; diff -r 2985239119a3 -r 39a9959ef14d dwt/internal/ImageList.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ImageList.d Mon Jan 28 21:05:39 2008 +0100 @@ -0,0 +1,474 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.internal.ImageList; + + +import dwt.DWT; +import dwt.graphics.Color; +import dwt.graphics.Image; +import dwt.graphics.ImageData; +import dwt.graphics.PaletteData; +import dwt.graphics.Point; +import dwt.graphics.RGB; +import dwt.graphics.Rectangle; +import dwt.internal.win32.OS; + +import dwt.dwthelper.utils; +import dwt.dwthelper.System; + +public class ImageList { + HIMAGELIST handle; + int style, refCount; + Image [] images; + +public this (int style) { + this.style = style; + int flags = OS.ILC_MASK; + if (OS.IsWinCE) { + flags |= OS.ILC_COLOR; + } else { + if (OS.COMCTL32_MAJOR >= 6) { + flags |= OS.ILC_COLOR32; + } else { + auto hDC = OS.GetDC (null); + auto bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL); + auto planes = OS.GetDeviceCaps (hDC, OS.PLANES); + OS.ReleaseDC (null, hDC); + int depth = bits * planes; + switch (depth) { + case 4: flags |= OS.ILC_COLOR4; break; + case 8: flags |= OS.ILC_COLOR8; break; + case 16: flags |= OS.ILC_COLOR16; break; + case 24: flags |= OS.ILC_COLOR24; break; + case 32: flags |= OS.ILC_COLOR32; break; + default: flags |= OS.ILC_COLOR; break; + } + } + } + if ((style & DWT.RIGHT_TO_LEFT) !is 0) flags |= OS.ILC_MIRROR; + handle = OS.ImageList_Create (32, 32, flags, 16, 16); + images = new Image [4]; +} + +public int add (Image image) { + int count = OS.ImageList_GetImageCount (handle); + int index = 0; + while (index < count) { + if (images [index] !is null) { + if (images [index].isDisposed ()) images [index] = null; + } + if (images [index] is null) break; + index++; + } + if (count is 0) { + Rectangle rect = image.getBounds (); + OS.ImageList_SetIconSize (handle, rect.width, rect.height); + } + set (index, image, count); + if (index is images.length) { + Image [] newImages = new Image [images.length + 4]; + System.arraycopy (images, 0, newImages, 0, images.length); + images = newImages; + } + images [index] = image; + return index; +} + +public int addRef() { + return ++refCount; +} + +HBITMAP copyBitmap (HBITMAP hImage, int width, int height) { + BITMAP bm; + OS.GetObject (hImage, BITMAP.sizeof, &bm); + auto hDC = OS.GetDC (null); + auto hdc1 = OS.CreateCompatibleDC (hDC); + OS.SelectObject (hdc1, hImage); + auto hdc2 = OS.CreateCompatibleDC (hDC); + /* + * Feature in Windows. If a bitmap has a 32-bit depth and any + * pixel has an alpha value different than zero, common controls + * version 6.0 assumes that the bitmap should be alpha blended. + * AlphaBlend() composes the alpha channel of a destination 32-bit + * depth image with the alpha channel of the source image. This + * may cause opaque images to draw transparently. The fix is + * remove the alpha channel of opaque images by down sampling + * it to 24-bit depth. + */ + HBITMAP hBitmap; + if (bm.bmBitsPixel is 32 && OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { + BITMAPINFOHEADER bmiHeader; + bmiHeader.biSize = BITMAPINFOHEADER.sizeof; + bmiHeader.biWidth = width; + bmiHeader.biHeight = -height; + bmiHeader.biPlanes = 1; + bmiHeader.biBitCount = cast(short)24; + static if (OS.IsWinCE) bmiHeader.biCompression = OS.BI_BITFIELDS; + else bmiHeader.biCompression = OS.BI_RGB; + byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + (OS.IsWinCE ? 12 : 0)]; + *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader; + //OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof); + /* Set the rgb colors into the bitmap info */ + if (OS.IsWinCE) { + int redMask = 0xFF00; + int greenMask = 0xFF0000; + int blueMask = 0xFF000000; + /* big endian */ + int offset = BITMAPINFOHEADER.sizeof; + bmi[offset] = cast(byte)((redMask & 0xFF000000) >> 24); + bmi[offset + 1] = cast(byte)((redMask & 0xFF0000) >> 16); + bmi[offset + 2] = cast(byte)((redMask & 0xFF00) >> 8); + bmi[offset + 3] = cast(byte)((redMask & 0xFF) >> 0); + bmi[offset + 4] = cast(byte)((greenMask & 0xFF000000) >> 24); + bmi[offset + 5] = cast(byte)((greenMask & 0xFF0000) >> 16); + bmi[offset + 6] = cast(byte)((greenMask & 0xFF00) >> 8); + bmi[offset + 7] = cast(byte)((greenMask & 0xFF) >> 0); + bmi[offset + 8] = cast(byte)((blueMask & 0xFF000000) >> 24); + bmi[offset + 9] = cast(byte)((blueMask & 0xFF0000) >> 16); + bmi[offset + 10] = cast(byte)((blueMask & 0xFF00) >> 8); + bmi[offset + 11] = cast(byte)((blueMask & 0xFF) >> 0); + } + int[1] pBits; + hBitmap = OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0); + } else { + hBitmap = OS.CreateCompatibleBitmap (hDC, width, height); + } + OS.SelectObject (hdc2, hBitmap); + if (width !is bm.bmWidth || height !is bm.bmHeight) { + if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR); + OS.StretchBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, OS.SRCCOPY); + } else { + OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY); + } + OS.DeleteDC (hdc1); + OS.DeleteDC (hdc2); + OS.ReleaseDC (null, hDC); + return hBitmap; +} + +HBITMAP copyIcon (HBITMAP hImage, int width, int height) { + static if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); + auto hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, 0); + return hIcon !is null ? hIcon : hImage; +} + +HBITMAP copyWithAlpha (HBITMAP hBitmap, int background, byte[] alphaData, int destWidth, int destHeight) { + BITMAP bm; + OS.GetObject (hBitmap, BITMAP.sizeof, &bm); + int srcWidth = bm.bmWidth; + int srcHeight = bm.bmHeight; + + /* Create resources */ + auto hdc = OS.GetDC (null); + auto srcHdc = OS.CreateCompatibleDC (hdc); + auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap); + auto memHdc = OS.CreateCompatibleDC (hdc); + BITMAPINFOHEADER bmiHeader; + bmiHeader.biSize = BITMAPINFOHEADER.sizeof; + bmiHeader.biWidth = srcWidth; + bmiHeader.biHeight = -srcHeight; + bmiHeader.biPlanes = 1; + bmiHeader.biBitCount = 32; + bmiHeader.biCompression = OS.BI_RGB; + byte [] bmi = new byte[BITMAPINFOHEADER.sizeof]; + *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader; + //OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof); + int [1] pBits; + auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0); + if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES); + auto oldMemBitmap = OS.SelectObject (memHdc, memDib); + + BITMAP dibBM; + OS.GetObject (memDib, BITMAP.sizeof, &dibBM); + int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; + + /* Get the foreground pixels */ + OS.BitBlt (memHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY); + byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes].dup; + //OS.MoveMemory (srcData, dibBM.bmBits, sizeInBytes); + + /* Merge the alpha channel in place */ + if (alphaData !is null) { + int spinc = dibBM.bmWidthBytes - srcWidth * 4; + int ap = 0, sp = 3; + for (int y = 0; y < srcHeight; ++y) { + for (int x = 0; x < srcWidth; ++x) { + srcData [sp] = alphaData [ap++]; + sp += 4; + } + sp += spinc; + } + } else { + byte transRed = cast(byte)(background & 0xFF); + byte transGreen = cast(byte)((background >> 8) & 0xFF); + byte transBlue = cast(byte)((background >> 16) & 0xFF); + final int spinc = dibBM.bmWidthBytes - srcWidth * 4; + int sp = 3; + for (int y = 0; y < srcHeight; ++y) { + for (int x = 0; x < srcWidth; ++x) { + srcData [sp] = (srcData[sp-1] is transRed && srcData[sp-2] is transGreen && srcData[sp-3] is transBlue) ? 0 : cast(byte)255; + sp += 4; + } + sp += spinc; + } + } + (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes] = srcData; + //OS.MoveMemory (dibBM.bmBits, srcData, sizeInBytes); + + /* Stretch and free resources */ + if (srcWidth !is destWidth || srcHeight !is destHeight) { + BITMAPINFOHEADER bmiHeader2; + bmiHeader2.biSize = BITMAPINFOHEADER.sizeof; + bmiHeader2.biWidth = destWidth; + bmiHeader2.biHeight = -destHeight; + bmiHeader2.biPlanes = 1; + bmiHeader2.biBitCount = 32; + bmiHeader2.biCompression = OS.BI_RGB; + byte [] bmi2 = new byte[BITMAPINFOHEADER.sizeof]; + *cast(BITMAPINFOHEADER*)bmi2.ptr = bmiHeader2; + //OS.MoveMemory (bmi2, bmiHeader2, BITMAPINFOHEADER.sizeof); + int [1] pBits2; + auto memDib2 = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi2.ptr, OS.DIB_RGB_COLORS, pBits2.ptr, null, 0); + auto memHdc2 = OS.CreateCompatibleDC (hdc); + auto oldMemBitmap2 = OS.SelectObject (memHdc2, memDib2); + if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc2, OS.COLORONCOLOR); + OS.StretchBlt (memHdc2, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); + OS.SelectObject (memHdc2, oldMemBitmap2); + OS.DeleteDC (memHdc2); + OS.SelectObject (memHdc, oldMemBitmap); + OS.DeleteDC (memHdc); + OS.DeleteObject (memDib); + memDib = memDib2; + } else { + OS.SelectObject (memHdc, oldMemBitmap); + OS.DeleteDC (memHdc); + } + OS.SelectObject (srcHdc, oldSrcBitmap); + OS.DeleteDC (srcHdc); + OS.ReleaseDC (null, hdc); + return memDib; +} + +HBITMAP createMaskFromAlpha (ImageData data, int destWidth, int destHeight) { + int srcWidth = data.width; + int srcHeight = data.height; + ImageData mask = ImageData.internal_new (srcWidth, srcHeight, 1, + new PaletteData([new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)]), + 2, null, 1, null, null, -1, -1, -1, 0, 0, 0, 0); + int ap = 0; + for (int y = 0; y < mask.height; y++) { + for (int x = 0; x < mask.width; x++) { + mask.setPixel (x, y, (data.alphaData [ap++] & 0xff) <= 127 ? 1 : 0); + } + } + auto hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data.ptr); + if (srcWidth !is destWidth || srcHeight !is destHeight) { + auto hdc = OS.GetDC (null); + auto hdc1 = OS.CreateCompatibleDC (hdc); + OS.SelectObject (hdc1, hMask); + auto hdc2 = OS.CreateCompatibleDC (hdc); + auto hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null); + OS.SelectObject (hdc2, hMask2); + if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR); + OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); + OS.DeleteDC (hdc1); + OS.DeleteDC (hdc2); + OS.ReleaseDC (null, hdc); + OS.DeleteObject(hMask); + hMask = hMask2; + } + return hMask; +} + +HBITMAP createMask (HBITMAP hBitmap, int destWidth, int destHeight, int background, int transparentPixel) { + BITMAP bm; + OS.GetObject (hBitmap, BITMAP.sizeof, &bm); + int srcWidth = bm.bmWidth; + int srcHeight = bm.bmHeight; + auto hMask = OS.CreateBitmap (destWidth, destHeight, 1, 1, null); + auto hDC = OS.GetDC (null); + auto hdc1 = OS.CreateCompatibleDC (hDC); + if (background !is -1) { + OS.SelectObject (hdc1, hBitmap); + + /* + * If the image has a palette with multiple entries having + * the same color and one of those entries is the transparentPixel, + * only the first entry becomes transparent. To avoid this + * problem, temporarily change the image palette to a palette + * where the transparentPixel is white and everything else is + * black. + */ + bool isDib = bm.bmBits !is null; + byte[] originalColors = null; + if (!OS.IsWinCE && transparentPixel !is -1 && isDib && bm.bmBitsPixel <= 8) { + int maxColors = 1 << bm.bmBitsPixel; + byte[] oldColors = new byte[maxColors * 4]; + OS.GetDIBColorTable(hdc1, 0, maxColors, cast(RGBQUAD*)oldColors.ptr); + int offset = transparentPixel * 4; + byte[] newColors = new byte[oldColors.length]; + newColors[offset] = cast(byte)0xFF; + newColors[offset+1] = cast(byte)0xFF; + newColors[offset+2] = cast(byte)0xFF; + OS.SetDIBColorTable(hdc1, 0, maxColors, cast(RGBQUAD*)newColors.ptr); + originalColors = oldColors; + OS.SetBkColor (hdc1, 0xFFFFFF); + } else { + OS.SetBkColor (hdc1, background); + } + + auto hdc2 = OS.CreateCompatibleDC (hDC); + OS.SelectObject (hdc2, hMask); + if (destWidth !is srcWidth || destHeight !is srcHeight) { + if (!OS.IsWinCE) OS.SetStretchBltMode (hdc2, OS.COLORONCOLOR); + OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); + } else { + OS.BitBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, OS.SRCCOPY); + } + OS.DeleteDC (hdc2); + + /* Put back the original palette */ + if (originalColors !is null) OS.SetDIBColorTable(hdc1, 0, 1 << bm.bmBitsPixel, cast(RGBQUAD*)originalColors.ptr); + } else { + auto hOldBitmap = OS.SelectObject (hdc1, hMask); + OS.PatBlt (hdc1, 0, 0, destWidth, destHeight, OS.BLACKNESS); + OS.SelectObject (hdc1, hOldBitmap); + } + OS.ReleaseDC (null, hDC); + OS.DeleteDC (hdc1); + return hMask; +} + +public void dispose () { + if (handle !is null) OS.ImageList_Destroy (handle); + handle = null; + images = null; +} + +public Image get (int index) { + return images [index]; +} + +public int getStyle () { + return style; +} + +public HIMAGELIST getHandle () { + return handle; +} + +public Point getImageSize() { + int cx, cy; + OS.ImageList_GetIconSize (handle, &cx, &cy); + return new Point (cx, cy); +} + +public int indexOf (Image image) { + int count = OS.ImageList_GetImageCount (handle); + for (int i=0; i= 6) { + hBitmap = copyWithAlpha (hImage, -1, data.alphaData, cx, cy); + } else { + hBitmap = copyBitmap (hImage, cx, cy); + hMask = createMaskFromAlpha (data, cx, cy); + } + break; + case DWT.TRANSPARENCY_PIXEL: + int background = -1; + Color color = image.getBackground (); + if (color !is null) background = color.handle; + hBitmap = copyBitmap (hImage, cx, cy); + hMask = createMask (hImage, cx, cy, background, data.transparentPixel); + break; + case DWT.TRANSPARENCY_NONE: + default: + hBitmap = copyBitmap (hImage, cx, cy); + if (index !is count) hMask = createMask (hImage, cx, cy, -1, -1); + break; + } + if (index is count) { + OS.ImageList_Add (handle, hBitmap, hMask); + } else { + /* Note that the mask must always be replaced even for TRANSPARENCY_NONE */ + OS.ImageList_Replace (handle, index, hBitmap, hMask); + } + if (hMask !is null) OS.DeleteObject (hMask); + if (hBitmap !is hImage) OS.DeleteObject (hBitmap); + break; + } + case DWT.ICON: { + if (OS.IsWinCE) { + OS.ImageList_ReplaceIcon (handle, index is count ? -1 : index, hImage); + } else { + auto hIcon = copyIcon (hImage, cx, cy); + OS.ImageList_ReplaceIcon (handle, index is count ? -1 : index, hIcon); + OS.DestroyIcon (hIcon); + } + break; + } + } +} + +public int size () { + int result = 0; + int count = OS.ImageList_GetImageCount (handle); + for (int i=0; i sizeof = 28 int type; -// union { + union { MOUSEINPUT mi; -// KEYBOARDINPUT ki; + KEYBDINPUT ki; // HARDWAREINPUT hi; -// } + } }alias INPUT* PINPUT, LPINPUT; //struct ITEMIDLIST { @@ -2062,25 +2061,25 @@ } // WNDCLASSA is declared in phobos -struct WNDCLASSW { - UINT style; - WNDPROC_I lpfnWndProc; - int cbClsExtra; - int cbWndExtra; - HINSTANCE hInstance; - HICON hIcon; - HCURSOR hCursor; - HBRUSH hbrBackground; - LPCWSTR lpszMenuName; - LPCWSTR lpszClassName; -}alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW; - -// since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name -version(ANSI){ - alias WNDCLASSA WNDCLASS_T; -}else{ - alias WNDCLASSW WNDCLASS_T; -} +// struct WNDCLASSW { +// UINT style; +// WNDPROC_I lpfnWndProc; +// int cbClsExtra; +// int cbWndExtra; +// HINSTANCE hInstance; +// HICON hIcon; +// HCURSOR hCursor; +// HBRUSH hbrBackground; +// LPCWSTR lpszMenuName; +// LPCWSTR lpszClassName; +// }alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW; +// +// // since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name +// version(ANSI){ +// alias WNDCLASSA WNDCLASS_T; +// }else{ +// alias WNDCLASSW WNDCLASS_T; +// } } // end of extern(Windows) diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Composite.d Mon Jan 28 21:05:39 2008 +0100 @@ -14,9 +14,15 @@ import dwt.widgets.Scrollable; import dwt.widgets.Control; +import dwt.graphics.Font; class Composite : Scrollable { public Control [] getChildren () ; +void updateFont (Font oldFont, Font newFont) ; +public void layout () ; +public void layout (bool ) ; +public void layout (bool , bool ) ; +public void layout (Control[]) ; } /++ import dwt.DWT; diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Control.d --- a/dwt/widgets/Control.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Control.d Mon Jan 28 21:05:39 2008 +0100 @@ -14,6 +14,8 @@ import dwt.widgets.Widget; import dwt.widgets.Composite; +import dwt.widgets.Event; +import dwt.widgets.Shell; import dwt.graphics.Drawable; import dwt.graphics.Rectangle; import dwt.graphics.Point; @@ -21,6 +23,7 @@ import dwt.internal.win32.OS; class Control : Widget, Drawable { + public HANDLE handle; this(); this( Widget, int ); public HDC internal_new_GC (GCData data) ; @@ -35,6 +38,17 @@ void setBounds (int x, int y, int width, int height, int flags) ; void setBounds (int x, int y, int width, int height, int flags, bool defer) ; public void setBounds (Rectangle rect) ; +Shell getShell(); +bool checkHandle (HWND hwnd) ; +bool translateAccelerator (MSG* msg) ; +bool translateMnemonic (Event event, Control control) ; +bool translateMnemonic (MSG* msg) ; +bool translateTraversal (MSG* msg) ; +public void update () ; +void update (bool all) ; +void updateImages () ; +int windowProc (HWND hwnd, int msg, int wParam, int lParam) ; + } /++ import dwt.DWT; @@ -3281,7 +3295,7 @@ return handle; } -bool translateAccelerator (MSG msg) { +bool translateAccelerator (MSG* msg) { return menuShell ().translateAccelerator (msg); } @@ -3292,7 +3306,7 @@ return traverse (event); } -bool translateMnemonic (MSG msg) { +bool translateMnemonic (MSG* msg) { if (msg.wParam < 0x20) return false; int hwnd = msg.hwnd; if (OS.GetKeyState (OS.VK_MENU) >= 0) { @@ -3313,7 +3327,7 @@ return false; } -bool translateTraversal (MSG msg) { +bool translateTraversal (MSG* msg) { int hwnd = msg.hwnd; int key = msg.wParam; if (key is OS.VK_MENU) { diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Decorations.d --- a/dwt/widgets/Decorations.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Decorations.d Mon Jan 28 21:05:39 2008 +0100 @@ -14,6 +14,7 @@ import dwt.widgets.Canvas; class Decorations : Canvas { +void bringToTop () ; } /++ import dwt.DWT; diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Display.d --- a/dwt/widgets/Display.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Display.d Mon Jan 28 21:05:39 2008 +0100 @@ -12,14 +12,7 @@ *******************************************************************************/ module dwt.widgets.Display; -import dwt.graphics.Device; -import dwt.widgets.Control; -import dwt.widgets.Tray; -import dwt.widgets.Event; -import dwt.internal.win32.OS; - -import tango.core.Thread; - +/+ class Display : Device { RECT clickRect; int clickCount, lastTime, lastButton, lastClickHwnd; @@ -52,7 +45,7 @@ int controlKey (int key) ; HTHEME hEditTheme () ; } -/++ ++/ import dwt.DWT; import dwt.DWTError; import dwt.DWTException; @@ -70,29 +63,32 @@ import dwt.graphics.RGB; import dwt.graphics.Rectangle; import dwt.graphics.Resource; -import dwt.internal.Callback; import dwt.internal.ImageList; -import dwt.internal.win32.BITMAP; -import dwt.internal.win32.BITMAPINFOHEADER; -import dwt.internal.win32.HIGHCONTRAST; -import dwt.internal.win32.ICONINFO; -import dwt.internal.win32.INPUT; -import dwt.internal.win32.KEYBDINPUT; -import dwt.internal.win32.LOGFONT; -import dwt.internal.win32.LOGFONTA; -import dwt.internal.win32.LOGFONTW; -import dwt.internal.win32.MONITORINFO; -import dwt.internal.win32.MOUSEINPUT; -import dwt.internal.win32.MSG; -import dwt.internal.win32.NONCLIENTMETRICS; -import dwt.internal.win32.NONCLIENTMETRICSA; -import dwt.internal.win32.NONCLIENTMETRICSW; import dwt.internal.win32.OS; -import dwt.internal.win32.POINT; -import dwt.internal.win32.RECT; -import dwt.internal.win32.STARTUPINFO; -import dwt.internal.win32.TCHAR; -import dwt.internal.win32.WNDCLASS; + +import dwt.widgets.Control; +import dwt.widgets.Tray; +import dwt.widgets.Event; +import dwt.widgets.EventTable; +import dwt.widgets.Menu; +import dwt.widgets.MenuItem; +import dwt.widgets.Synchronizer; +import dwt.widgets.Monitor; +import dwt.widgets.Shell; +import dwt.widgets.Listener; +import dwt.widgets.Widget; +import dwt.widgets.TrayItem; + +import dwt.dwthelper.utils; +import dwt.dwthelper.Runnable; +import dwt.dwthelper.System; +import dwt.dwthelper.Integer; +import tango.core.Thread; +import tango.stdc.stringz; +import tango.util.Convert; +static import tango.text.convert.Utf; +static import tango.text.Text; +alias tango.text.Text.Text!(char) StringBuffer; /** * Instances of this class are responsible for managing the @@ -170,7 +166,7 @@ * @see Device#dispose */ -public class Display extends Device { +public class Display : Device { /** * the handle to the OS message queue @@ -182,29 +178,32 @@ * platforms and should never be accessed from application code. *

*/ - public MSG msg = new MSG (); + public MSG msg; /* Windows and Events */ Event [] eventQueue; - Callback windowCallback; - int windowProc, threadId; - TCHAR windowClass, windowShadowClass; + //Callback windowCallback; + //int windowProc_; + int threadId; + TCHAR* windowClass, windowShadowClass; static int WindowClassCount; - static final String WindowName = "SWT_Window"; //$NON-NLS-1$ - static final String WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$ + static const char[] WindowName = "SWT_Window"; //$NON-NLS-1$ + static const char[] WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$ EventTable eventTable, filterTable; /* Widget Table */ int [] indexTable; Control lastControl, lastGetControl; - int freeSlot, lastHwnd, lastGetHwnd; + int freeSlot; + HANDLE lastHwnd; + HWND lastGetHwnd; Control [] controlTable; - static final int GROW_SIZE = 1024; - static final int SWT_OBJECT_INDEX; - static final bool USE_PROPERTY = !OS.IsWinCE; - static { - if (USE_PROPERTY) { - SWT_OBJECT_INDEX = OS.GlobalAddAtom (new TCHAR (0, "SWT_OBJECT_INDEX", true)); //$NON-NLS-1$ + static const int GROW_SIZE = 1024; + static const int SWT_OBJECT_INDEX; + static const bool USE_PROPERTY = !OS.IsWinCE; + static this() { + static if (USE_PROPERTY) { + SWT_OBJECT_INDEX = OS.GlobalAddAtom (StrToTCHARz( "SWT_OBJECT_INDEX")); //$NON-NLS-1$ } else { SWT_OBJECT_INDEX = 0; } @@ -212,24 +211,24 @@ /* Startup info */ static STARTUPINFO lpStartupInfo; - static { - if (!OS.IsWinCE) { - lpStartupInfo = new STARTUPINFO (); + static this() { + static if (!OS.IsWinCE) { + //lpStartupInfo = new STARTUPINFO (); lpStartupInfo.cb = STARTUPINFO.sizeof; - OS.GetStartupInfo (lpStartupInfo); + OS.GetStartupInfo (&lpStartupInfo); } } /* XP Themes */ - int hButtonTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme; - static final char [] BUTTON = new char [] {'B', 'U', 'T', 'T', 'O', 'N', 0}; - static final char [] EDIT = new char [] {'E', 'D', 'I', 'T', 0}; - static final char [] EXPLORER = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 0}; - static final char [] EXPLORERBAR = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 'B', 'A', 'R', 0}; - static final char [] SCROLLBAR = new char [] {'S', 'C', 'R', 'O', 'L', 'L', 'B', 'A', 'R', 0}; - static final char [] LISTVIEW = new char [] {'L', 'I', 'S', 'T', 'V', 'I', 'E', 'W', 0}; - static final char [] TAB = new char [] {'T', 'A', 'B', 0}; - static final char [] TREEVIEW = new char [] {'T', 'R', 'E', 'E', 'V', 'I', 'E', 'W', 0}; + HTHEME hButtonTheme_, hEditTheme_, hExplorerBarTheme_, hScrollBarTheme_, hTabTheme_; + static const wchar [] BUTTON = "BUTTON\0"w; + static const wchar [] EDIT = "EDIT\0"w; + static const wchar [] EXPLORER = "EXPLORER\0"w; + static const wchar [] EXPLORERBAR = "EXPLORERBAR\0"w; + static const wchar [] SCROLLBAR = "SCROLLBAR\0"w; + static const wchar [] LISTVIEW = "LISTVIEW\0"w; + static const wchar [] TAB = "TAB\0"w; + static const wchar [] TREEVIEW = "TREEVIEW\0"w; /* Focus */ int focusEvent; @@ -246,29 +245,34 @@ * The SmartPhone DWT resource file reserves * the values 101..107. */ - static final int ID_START = 108; + static const int ID_START = 108; /* Filter Hook */ - Callback msgFilterCallback; - int msgFilterProc, filterHook; - MSG hookMsg = new MSG (); + //Callback msgFilterCallback; + //int msgFilterProc_, + HHOOK filterHook; + MSG hookMsg; bool runDragDrop = true; /* Idle Hook */ - Callback foregroundIdleCallback; - int foregroundIdleProc, idleHook; + //Callback foregroundIdleCallback; + //int foregroundIdleProc_; + HHOOK idleHook; /* Message Hook and Embedding */ bool ignoreNextKey; - Callback getMsgCallback, embeddedCallback; - int getMsgProc, msgHook, embeddedHwnd, embeddedProc; - static final String AWT_WINDOW_CLASS = "SunAwtWindow"; - static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'}; + //Callback getMsgCallback, embeddedCallback; + int getMsgProc_; + HHOOK msgHook; + HWND embeddedHwnd; + int embeddedProc_; + static const char[] AWT_WINDOW_CLASS = "SunAwtWindow"; + static const short [] ACCENTS = [ cast(short) '~', '`', '\'', '^', '"']; /* Sync/Async Widget Communication */ - Synchronizer synchronizer = new Synchronizer (this); + Synchronizer synchronizer; bool runMessages = true, runMessagesInIdle = false; - static final String RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ + static const char[] RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ Thread thread; /* Display Shutdown */ @@ -282,15 +286,16 @@ int [] timerIds; Runnable [] timerList; int nextTimerId = SETTINGS_ID + 1; - static final int SETTINGS_ID = 100; - static final int SETTINGS_DELAY = 2000; + static const int SETTINGS_ID = 100; + static const int SETTINGS_DELAY = 2000; /* Keyboard and Mouse */ RECT clickRect; - int clickCount, lastTime, lastButton, lastClickHwnd; + int clickCount, lastTime, lastButton; + HWND lastClickHwnd; int lastKey, lastAscii, lastMouse; bool lastVirtual, lastNull, lastDead; - byte [] keyboard = new byte [256]; + ubyte [256] keyboard; bool accelKeyHit, mnemonicKeyHit; bool lockActiveWindow, captureChanged, xMouse; @@ -303,22 +308,23 @@ int lastHittest; /* Message Only Window */ - Callback messageCallback; - int hwndMessage, messageProc; + //Callback messageCallback; + HWND hwndMessage; + int messageProc_; /* System Resources */ - LOGFONT lfSystemFont; + LOGFONT* lfSystemFont; Font systemFont; Image errorImage, infoImage, questionImage, warningIcon; - Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1]; + Cursor [] cursors; Resource [] resources; - static final int RESOURCE_SIZE = 1 + 4 + DWT.CURSOR_HAND + 1; + static const int RESOURCE_SIZE = 1 + 4 + DWT.CURSOR_HAND + 1; /* ImageList Cache */ ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList; /* Custom Colors for ChooseColor */ - int lpCustColors; + COLORREF* lpCustColors; /* Sort Indicators */ Image upArrow, downArrow; @@ -328,95 +334,95 @@ /* Display Data */ Object data; - String [] keys; + char[] [] keys; Object [] values; /* Key Mappings */ - static final int [] [] KeyTable = { + static const int [] [] KeyTable = [ /* Keyboard and Mouse Masks */ - {OS.VK_MENU, DWT.ALT}, - {OS.VK_SHIFT, DWT.SHIFT}, - {OS.VK_CONTROL, DWT.CONTROL}, -// {OS.VK_????, DWT.COMMAND}, + [OS.VK_MENU, DWT.ALT], + [OS.VK_SHIFT, DWT.SHIFT], + [OS.VK_CONTROL, DWT.CONTROL], +// [OS.VK_????, DWT.COMMAND], /* NOT CURRENTLY USED */ -// {OS.VK_LBUTTON, DWT.BUTTON1}, -// {OS.VK_MBUTTON, DWT.BUTTON3}, -// {OS.VK_RBUTTON, DWT.BUTTON2}, +// [OS.VK_LBUTTON, DWT.BUTTON1], +// [OS.VK_MBUTTON, DWT.BUTTON3], +// [OS.VK_RBUTTON, DWT.BUTTON2], /* Non-Numeric Keypad Keys */ - {OS.VK_UP, DWT.ARROW_UP}, - {OS.VK_DOWN, DWT.ARROW_DOWN}, - {OS.VK_LEFT, DWT.ARROW_LEFT}, - {OS.VK_RIGHT, DWT.ARROW_RIGHT}, - {OS.VK_PRIOR, DWT.PAGE_UP}, - {OS.VK_NEXT, DWT.PAGE_DOWN}, - {OS.VK_HOME, DWT.HOME}, - {OS.VK_END, DWT.END}, - {OS.VK_INSERT, DWT.INSERT}, + [OS.VK_UP, DWT.ARROW_UP], + [OS.VK_DOWN, DWT.ARROW_DOWN], + [OS.VK_LEFT, DWT.ARROW_LEFT], + [OS.VK_RIGHT, DWT.ARROW_RIGHT], + [OS.VK_PRIOR, DWT.PAGE_UP], + [OS.VK_NEXT, DWT.PAGE_DOWN], + [OS.VK_HOME, DWT.HOME], + [OS.VK_END, DWT.END], + [OS.VK_INSERT, DWT.INSERT], /* Virtual and Ascii Keys */ - {OS.VK_BACK, DWT.BS}, - {OS.VK_RETURN, DWT.CR}, - {OS.VK_DELETE, DWT.DEL}, - {OS.VK_ESCAPE, DWT.ESC}, - {OS.VK_RETURN, DWT.LF}, - {OS.VK_TAB, DWT.TAB}, + [OS.VK_BACK, DWT.BS], + [OS.VK_RETURN, DWT.CR], + [OS.VK_DELETE, DWT.DEL], + [OS.VK_ESCAPE, DWT.ESC], + [OS.VK_RETURN, DWT.LF], + [OS.VK_TAB, DWT.TAB], /* Functions Keys */ - {OS.VK_F1, DWT.F1}, - {OS.VK_F2, DWT.F2}, - {OS.VK_F3, DWT.F3}, - {OS.VK_F4, DWT.F4}, - {OS.VK_F5, DWT.F5}, - {OS.VK_F6, DWT.F6}, - {OS.VK_F7, DWT.F7}, - {OS.VK_F8, DWT.F8}, - {OS.VK_F9, DWT.F9}, - {OS.VK_F10, DWT.F10}, - {OS.VK_F11, DWT.F11}, - {OS.VK_F12, DWT.F12}, - {OS.VK_F13, DWT.F13}, - {OS.VK_F14, DWT.F14}, - {OS.VK_F15, DWT.F15}, + [OS.VK_F1, DWT.F1], + [OS.VK_F2, DWT.F2], + [OS.VK_F3, DWT.F3], + [OS.VK_F4, DWT.F4], + [OS.VK_F5, DWT.F5], + [OS.VK_F6, DWT.F6], + [OS.VK_F7, DWT.F7], + [OS.VK_F8, DWT.F8], + [OS.VK_F9, DWT.F9], + [OS.VK_F10, DWT.F10], + [OS.VK_F11, DWT.F11], + [OS.VK_F12, DWT.F12], + [OS.VK_F13, DWT.F13], + [OS.VK_F14, DWT.F14], + [OS.VK_F15, DWT.F15], /* Numeric Keypad Keys */ - {OS.VK_MULTIPLY, DWT.KEYPAD_MULTIPLY}, - {OS.VK_ADD, DWT.KEYPAD_ADD}, - {OS.VK_RETURN, DWT.KEYPAD_CR}, - {OS.VK_SUBTRACT, DWT.KEYPAD_SUBTRACT}, - {OS.VK_DECIMAL, DWT.KEYPAD_DECIMAL}, - {OS.VK_DIVIDE, DWT.KEYPAD_DIVIDE}, - {OS.VK_NUMPAD0, DWT.KEYPAD_0}, - {OS.VK_NUMPAD1, DWT.KEYPAD_1}, - {OS.VK_NUMPAD2, DWT.KEYPAD_2}, - {OS.VK_NUMPAD3, DWT.KEYPAD_3}, - {OS.VK_NUMPAD4, DWT.KEYPAD_4}, - {OS.VK_NUMPAD5, DWT.KEYPAD_5}, - {OS.VK_NUMPAD6, DWT.KEYPAD_6}, - {OS.VK_NUMPAD7, DWT.KEYPAD_7}, - {OS.VK_NUMPAD8, DWT.KEYPAD_8}, - {OS.VK_NUMPAD9, DWT.KEYPAD_9}, -// {OS.VK_????, DWT.KEYPAD_EQUAL}, + [OS.VK_MULTIPLY, DWT.KEYPAD_MULTIPLY], + [OS.VK_ADD, DWT.KEYPAD_ADD], + [OS.VK_RETURN, DWT.KEYPAD_CR], + [OS.VK_SUBTRACT, DWT.KEYPAD_SUBTRACT], + [OS.VK_DECIMAL, DWT.KEYPAD_DECIMAL], + [OS.VK_DIVIDE, DWT.KEYPAD_DIVIDE], + [OS.VK_NUMPAD0, DWT.KEYPAD_0], + [OS.VK_NUMPAD1, DWT.KEYPAD_1], + [OS.VK_NUMPAD2, DWT.KEYPAD_2], + [OS.VK_NUMPAD3, DWT.KEYPAD_3], + [OS.VK_NUMPAD4, DWT.KEYPAD_4], + [OS.VK_NUMPAD5, DWT.KEYPAD_5], + [OS.VK_NUMPAD6, DWT.KEYPAD_6], + [OS.VK_NUMPAD7, DWT.KEYPAD_7], + [OS.VK_NUMPAD8, DWT.KEYPAD_8], + [OS.VK_NUMPAD9, DWT.KEYPAD_9], +// [OS.VK_????, DWT.KEYPAD_EQUAL], /* Other keys */ - {OS.VK_CAPITAL, DWT.CAPS_LOCK}, - {OS.VK_NUMLOCK, DWT.NUM_LOCK}, - {OS.VK_SCROLL, DWT.SCROLL_LOCK}, - {OS.VK_PAUSE, DWT.PAUSE}, - {OS.VK_CANCEL, DWT.BREAK}, - {OS.VK_SNAPSHOT, DWT.PRINT_SCREEN}, -// {OS.VK_????, DWT.HELP}, - - }; + [OS.VK_CAPITAL, DWT.CAPS_LOCK], + [OS.VK_NUMLOCK, DWT.NUM_LOCK], + [OS.VK_SCROLL, DWT.SCROLL_LOCK], + [OS.VK_PAUSE, DWT.PAUSE], + [OS.VK_CANCEL, DWT.BREAK], + [OS.VK_SNAPSHOT, DWT.PRINT_SCREEN], +// [OS.VK_????, DWT.HELP], + + ]; /* Multiple Displays */ static Display Default; - static Display [] Displays = new Display [4]; + static Display [] Displays; /* Multiple Monitors */ - Monitor[] monitors = null; + dwt.widgets.Monitor.Monitor[] monitors = null; int monitorCount = 0; /* Modality */ @@ -425,13 +431,13 @@ static bool TrimEnabled = false; /* Private DWT Window Messages */ - static final int SWT_GETACCELCOUNT = OS.WM_APP; - static final int SWT_GETACCEL = OS.WM_APP + 1; - static final int SWT_KEYMSG = OS.WM_APP + 2; - static final int SWT_DESTROY = OS.WM_APP + 3; - static final int SWT_TRAYICONMSG = OS.WM_APP + 4; - static final int SWT_NULL = OS.WM_APP + 5; - static final int SWT_RUNASYNC = OS.WM_APP + 6; + static const int SWT_GETACCELCOUNT = OS.WM_APP; + static const int SWT_GETACCEL = OS.WM_APP + 1; + static const int SWT_KEYMSG = OS.WM_APP + 2; + static const int SWT_DESTROY = OS.WM_APP + 3; + static const int SWT_TRAYICONMSG = OS.WM_APP + 4; + static const int SWT_NULL = OS.WM_APP + 5; + static const int SWT_RUNASYNC = OS.WM_APP + 6; static int SWT_TASKBARCREATED; static int SWT_RESTORECARET; @@ -439,7 +445,7 @@ int hitCount; /* Package Name */ - static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$ + static const char[] PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$ /* * This code is intentionally commented. In order * to support CLDC, .class cannot be used because @@ -447,7 +453,7 @@ * they are targeted for CLDC. */ // static { -// String name = Display.class.getName (); +// char[] name = Display.class.getName (); // int index = name.lastIndexOf ('.'); // PACKAGE_PREFIX = name.substring (0, index + 1); // } @@ -457,8 +463,8 @@ * gets the current display. This code will * be removed in the future. */ - static { - DeviceFinder = new Runnable () { + static this () { + DeviceFinder = new class() Runnable { public void run () { Device device = getCurrent (); if (device is null) { @@ -495,7 +501,7 @@ * @see Widget#checkSubclass * @see Shell */ -public Display () { +public this () { this (null); } @@ -504,8 +510,10 @@ * * @param data the device data */ -public Display (DeviceData data) { +public this (DeviceData data) { super (data); + synchronizer = new Synchronizer (this); + cursors = new Cursor [DWT.CURSOR_HAND + 1]; } Control _getFocusControl () { @@ -514,38 +522,38 @@ void addBar (Menu menu) { if (bars is null) bars = new Menu [4]; - int length = bars.length; - for (int i=0; i> 2); - red = (byte)((transparentPixel & 0x7C00) >> 7); + blue = cast(byte)((transparentPixel & 0x1F) << 3); + green = cast(byte)((transparentPixel & 0x3E0) >> 2); + red = cast(byte)((transparentPixel & 0x7C00) >> 7); break; case 24: - blue = (byte)((transparentPixel & 0xFF0000) >> 16); - green = (byte)((transparentPixel & 0xFF00) >> 8); - red = (byte)(transparentPixel & 0xFF); + blue = cast(byte)((transparentPixel & 0xFF0000) >> 16); + green = cast(byte)((transparentPixel & 0xFF00) >> 8); + red = cast(byte)(transparentPixel & 0xFF); break; case 32: - blue = (byte)((transparentPixel & 0xFF000000) >>> 24); - green = (byte)((transparentPixel & 0xFF0000) >> 16); - red = (byte)((transparentPixel & 0xFF00) >> 8); + blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24); + green = cast(byte)((transparentPixel & 0xFF0000) >> 16); + red = cast(byte)((transparentPixel & 0xFF00) >> 8); break; } } } - byte [] srcData = new byte [sizeInBytes]; - OS.MoveMemory (srcData, pBits [0], sizeInBytes); - if (hMask !is 0) { + byte [] srcData = (cast(byte*)pBits [0])[ 0 .. sizeInBytes].dup; + if (hMask !is null) { OS.SelectObject(srcHdc, hMask); for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (OS.GetPixel(srcHdc, x, y) !is 0) { - srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData[dp + 3] = (byte)0; + srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData[dp + 3] = cast(byte)0; } else { - srcData[dp + 3] = (byte)0xFF; + srcData[dp + 3] = cast(byte)0xFF; } dp += 4; } @@ -907,7 +916,7 @@ } else if (alpha !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { - srcData [dp + 3] = (byte)alpha; + srcData [dp + 3] = cast(byte)alpha; if (srcData [dp + 3] is 0) srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = 0; dp += 4; } @@ -924,9 +933,9 @@ for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) { - srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData [dp + 3] = (byte)0; + srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData [dp + 3] = cast(byte)0; } else { - srcData [dp + 3] = (byte)0xFF; + srcData [dp + 3] = cast(byte)0xFF; } dp += 4; } @@ -934,72 +943,71 @@ } else { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { - srcData [dp + 3] = (byte)0xFF; + srcData [dp + 3] = cast(byte)0xFF; dp += 4; } } } - OS.MoveMemory (pBits [0], srcData, sizeInBytes); + (cast(byte*)pBits [0])[ 0 .. sizeInBytes] = srcData[]; OS.SelectObject (srcHdc, oldSrcBitmap); OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteObject (srcHdc); OS.DeleteObject (memHdc); - OS.ReleaseDC (0, hDC); - if (hBitmap !is image.handle && hBitmap !is 0) OS.DeleteObject (hBitmap); - if (hMask !is 0) OS.DeleteObject (hMask); + OS.ReleaseDC (null, hDC); + if (hBitmap !is image.handle && hBitmap !is null) OS.DeleteObject (hBitmap); + if (hMask !is null) OS.DeleteObject (hMask); return memDib; } -static int create32bitDIB (int hBitmap, int alpha, byte [] alphaData, int transparentPixel) { - BITMAP bm = new BITMAP (); - OS.GetObject (hBitmap, BITMAP.sizeof, bm); +static HBITMAP create32bitDIB (HBITMAP hBitmap, int alpha, byte [] alphaData, int transparentPixel) { + BITMAP bm; + OS.GetObject (hBitmap, BITMAP.sizeof, &bm); int imgWidth = bm.bmWidth; int imgHeight = bm.bmHeight; - int hDC = OS.GetDC (0); - int srcHdc = OS.CreateCompatibleDC (hDC); - int oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap); - int memHdc = OS.CreateCompatibleDC (hDC); - BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER (); + auto hDC = OS.GetDC (null); + auto srcHdc = OS.CreateCompatibleDC (hDC); + auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap); + auto memHdc = OS.CreateCompatibleDC (hDC); + BITMAPINFOHEADER bmiHeader; bmiHeader.biSize = BITMAPINFOHEADER.sizeof; bmiHeader.biWidth = imgWidth; bmiHeader.biHeight = -imgHeight; bmiHeader.biPlanes = 1; - bmiHeader.biBitCount = (short)32; + bmiHeader.biBitCount = cast(short)32; bmiHeader.biCompression = OS.BI_RGB; - byte [] bmi = new byte [BITMAPINFOHEADER.sizeof]; - OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof); - int [] pBits = new int [1]; - int memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0); - if (memDib is 0) DWT.error (DWT.ERROR_NO_HANDLES); - int oldMemBitmap = OS.SelectObject (memHdc, memDib); - BITMAP dibBM = new BITMAP (); - OS.GetObject (memDib, BITMAP.sizeof, dibBM); + byte [] bmi = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof]; + int [1] pBits; + auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0); + if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES); + auto oldMemBitmap = OS.SelectObject (memHdc, memDib); + BITMAP dibBM; + OS.GetObject (memDib, BITMAP.sizeof, &dibBM); int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY); byte red = 0, green = 0, blue = 0; if (transparentPixel !is -1) { if (bm.bmBitsPixel <= 8) { - byte [] color = new byte [4]; - OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color); + byte [4] color; + OS.GetDIBColorTable (srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr); blue = color [0]; green = color [1]; red = color [2]; } else { switch (bm.bmBitsPixel) { case 16: - blue = (byte)((transparentPixel & 0x1F) << 3); - green = (byte)((transparentPixel & 0x3E0) >> 2); - red = (byte)((transparentPixel & 0x7C00) >> 7); + blue = cast(byte)((transparentPixel & 0x1F) << 3); + green = cast(byte)((transparentPixel & 0x3E0) >> 2); + red = cast(byte)((transparentPixel & 0x7C00) >> 7); break; case 24: - blue = (byte)((transparentPixel & 0xFF0000) >> 16); - green = (byte)((transparentPixel & 0xFF00) >> 8); - red = (byte)(transparentPixel & 0xFF); + blue = cast(byte)((transparentPixel & 0xFF0000) >> 16); + green = cast(byte)((transparentPixel & 0xFF00) >> 8); + red = cast(byte)(transparentPixel & 0xFF); break; case 32: - blue = (byte)((transparentPixel & 0xFF000000) >>> 24); - green = (byte)((transparentPixel & 0xFF0000) >> 16); - red = (byte)((transparentPixel & 0xFF00) >> 8); + blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24); + green = cast(byte)((transparentPixel & 0xFF0000) >> 16); + red = cast(byte)((transparentPixel & 0xFF00) >> 8); break; } } @@ -1008,13 +1016,12 @@ OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteObject (srcHdc); OS.DeleteObject (memHdc); - OS.ReleaseDC (0, hDC); - byte [] srcData = new byte [sizeInBytes]; - OS.MoveMemory (srcData, pBits [0], sizeInBytes); + OS.ReleaseDC (null, hDC); + byte [] srcData = (cast(byte*)pBits[0])[ 0 .. sizeInBytes ].dup; if (alpha !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { - srcData [dp + 3] = (byte)alpha; + srcData [dp + 3] = cast(byte)alpha; dp += 4; } } @@ -1029,15 +1036,15 @@ for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) { - srcData [dp + 3] = (byte)0; + srcData [dp + 3] = cast(byte)0; } else { - srcData [dp + 3] = (byte)0xFF; + srcData [dp + 3] = cast(byte)0xFF; } dp += 4; } } } - OS.MoveMemory (pBits [0], srcData, sizeInBytes); + (cast(byte*)pBits[0])[ 0 .. sizeInBytes ] = srcData[]; return memDib; } @@ -1049,9 +1056,10 @@ return new Image (device, data, mask); } int width = data.width, height = data.height; - int hMask, hBitmap; - int hDC = device.internal_new_GC (null); - int dstHdc = OS.CreateCompatibleDC (hDC), oldDstBitmap; + HBITMAP hMask, hBitmap; + auto hDC = device.internal_new_GC (null); + auto dstHdc = OS.CreateCompatibleDC (hDC); + HBITMAP oldDstBitmap; if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { hBitmap = Display.create32bitDIB (image.handle, data.alpha, data.alphaData, data.transparentPixel); hMask = OS.CreateBitmap (width, height, 1, 1, null); @@ -1062,8 +1070,8 @@ /* Icons need black pixels where the mask is transparent */ hBitmap = OS.CreateCompatibleBitmap (hDC, width, height); oldDstBitmap = OS.SelectObject (dstHdc, hBitmap); - int srcHdc = OS.CreateCompatibleDC (hDC); - int oldSrcBitmap = OS.SelectObject (srcHdc, image.handle); + auto srcHdc = OS.CreateCompatibleDC (hDC); + auto oldSrcBitmap = OS.SelectObject (srcHdc, image.handle); OS.PatBlt (dstHdc, 0, 0, width, height, OS.BLACKNESS); OS.BitBlt (dstHdc, 0, 0, width, height, srcHdc, 0, 0, OS.SRCINVERT); OS.SelectObject (srcHdc, hMask); @@ -1076,22 +1084,22 @@ OS.SelectObject (dstHdc, oldDstBitmap); OS.DeleteDC (dstHdc); device.internal_dispose_GC (hDC, null); - ICONINFO info = new ICONINFO (); + ICONINFO info; info.fIcon = true; info.hbmColor = hBitmap; info.hbmMask = hMask; - int hIcon = OS.CreateIconIndirect (info); - if (hIcon is 0) DWT.error(DWT.ERROR_NO_HANDLES); + auto hIcon = OS.CreateIconIndirect (&info); + if (hIcon is null) DWT.error(DWT.ERROR_NO_HANDLES); OS.DeleteObject (hBitmap); OS.DeleteObject (hMask); return Image.win32_new (device, DWT.ICON, hIcon); } -static int createMaskFromAlpha (ImageData data, int destWidth, int destHeight) { +static HBITMAP createMaskFromAlpha (ImageData data, int destWidth, int destHeight) { int srcWidth = data.width; int srcHeight = data.height; ImageData mask = ImageData.internal_new (srcWidth, srcHeight, 1, - new PaletteData(new RGB [] {new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)}), + new PaletteData([new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)]), 2, null, 1, null, null, -1, -1, -1, 0, 0, 0, 0); int ap = 0; for (int y = 0; y < mask.height; y++) { @@ -1099,19 +1107,19 @@ mask.setPixel (x, y, (data.alphaData [ap++] & 0xff) <= 127 ? 1 : 0); } } - int hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data); + auto hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data.ptr); if (srcWidth !is destWidth || srcHeight !is destHeight) { - int hdc = OS.GetDC (0); - int hdc1 = OS.CreateCompatibleDC (hdc); + auto hdc = OS.GetDC (null); + auto hdc1 = OS.CreateCompatibleDC (hdc); OS.SelectObject (hdc1, hMask); - int hdc2 = OS.CreateCompatibleDC (hdc); - int hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null); + auto hdc2 = OS.CreateCompatibleDC (hdc); + auto hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null); OS.SelectObject (hdc2, hMask2); if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR); OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); OS.DeleteDC (hdc1); OS.DeleteDC (hdc2); - OS.ReleaseDC (0, hdc); + OS.ReleaseDC (null, hdc); OS.DeleteObject(hMask); hMask = hMask2; } @@ -1166,7 +1174,7 @@ } } Runnable [] newDisposeList = new Runnable [disposeList.length + 4]; - System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length); + SimpleType!(Runnable).arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length); newDisposeList [disposeList.length] = runnable; disposeList = newDisposeList; } @@ -1180,23 +1188,22 @@ bars = null; } -int embeddedProc (int hwnd, int msg, int wParam, int lParam) { +private static extern(Windows) int embeddedFunc (HWND hwnd, int msg, int wParam, int lParam) { switch (msg) { case SWT_KEYMSG: { - MSG keyMsg = new MSG (); - OS.MoveMemory (keyMsg, lParam, MSG.sizeof); + MSG* keyMsg = cast(MSG*)lParam; OS.TranslateMessage (keyMsg); OS.DispatchMessage (keyMsg); - int hHeap = OS.GetProcessHeap (); - OS.HeapFree (hHeap, 0, lParam); + auto hHeap = OS.GetProcessHeap (); + OS.HeapFree (hHeap, 0, cast(void*)lParam); break; } case SWT_DESTROY: { OS.DestroyWindow (hwnd); - if (embeddedCallback !is null) embeddedCallback.dispose (); - if (getMsgCallback !is null) getMsgCallback.dispose (); - embeddedCallback = getMsgCallback = null; - embeddedProc = getMsgProc = 0; + //if (embeddedCallback !is null) embeddedCallback.dispose (); + //if (getMsgCallback !is null) getMsgCallback.dispose (); + //embeddedCallback = getMsgCallback = null; + //embeddedProc_ = getMsgProc_ = 0; break; } } @@ -1225,7 +1232,7 @@ return filterTable.hooks (eventType); } -bool filterMessage (MSG msg) { +bool filterMessage (MSG* msg) { int message = msg.message; if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) { Control control = findControl (msg.hwnd); @@ -1240,15 +1247,15 @@ return false; } -Control findControl (int handle) { - if (handle is 0) return null; - int hwndOwner = 0; +Control findControl (HANDLE handle) { + if (handle is null) return null; + HWND hwndOwner = null; do { Control control = getControl (handle); if (control !is null) return control; hwndOwner = OS.GetWindow (handle, OS.GW_OWNER); handle = OS.GetParent (handle); - } while (handle !is 0 && handle !is hwndOwner); + } while (handle !is null && handle !is hwndOwner); return null; } @@ -1270,7 +1277,7 @@ *
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
  • * */ -public Widget findWidget (int handle) { +public Widget findWidget (HANDLE handle) { checkDevice (); return getControl (handle); } @@ -1297,7 +1304,7 @@ * * @since 3.1 */ -public Widget findWidget (int handle, int id) { +public Widget findWidget (HANDLE handle, int id) { checkDevice (); Control control = getControl (handle); return control !is null ? control.findItem (id) : null; @@ -1322,12 +1329,17 @@ */ public Widget findWidget (Widget widget, int id) { checkDevice (); - if (widget instanceof Control) { - return findWidget (((Control) widget).handle, id); + if (cast(Control)widget) { + return findWidget ((cast(Control) widget).handle, id); } return null; } +private static extern(Windows) int foregroundIdleProcFunc (int code, int wParam, int lParam) { + auto d = Display.getCurrent(); + return d.foregroundIdleProc( code, wParam, lParam ); +} + int foregroundIdleProc (int code, int wParam, int lParam) { if (runMessages) { if (code >= 0) { @@ -1412,19 +1424,19 @@ * @return the current display */ public static synchronized Display getCurrent () { - return findDisplay (Thread.currentThread ()); + return findDisplay (Thread.getThis ()); } -int getClickCount (int type, int button, int hwnd, int lParam) { +int getClickCount (int type, int button, HWND hwnd, int lParam) { switch (type) { case DWT.MouseDown: int doubleClick = OS.GetDoubleClickTime (); - if (clickRect is null) clickRect = new RECT (); + //if (clickRect is null) clickRect = new RECT (); int deltaTime = Math.abs (lastTime - getLastEventTime ()); - POINT pt = new POINT (); - pt.x = (short) (lParam & 0xFFFF); - pt.y = (short) (lParam >> 16); - if (lastClickHwnd is hwnd && lastButton is button && (deltaTime <= doubleClick) && OS.PtInRect (clickRect, pt)) { + POINT pt; + pt.x = cast(short) (lParam & 0xFFFF); + pt.y = cast(short) (lParam >> 16); + if (lastClickHwnd is hwnd && lastButton is button && (deltaTime <= doubleClick) && OS.PtInRect (&clickRect, pt)) { clickCount++; } else { clickCount = 1; @@ -1436,8 +1448,8 @@ lastTime = getLastEventTime (); int xInset = OS.GetSystemMetrics (OS.SM_CXDOUBLECLK) / 2; int yInset = OS.GetSystemMetrics (OS.SM_CYDOUBLECLK) / 2; - int x = (short) (lParam & 0xFFFF), y = (short) (lParam >> 16); - OS.SetRect (clickRect, x - xInset, y - yInset, x + xInset, y + yInset); + int x = cast(short) (lParam & 0xFFFF), y = cast(short) (lParam >> 16); + OS.SetRect (&clickRect, x - xInset, y - yInset, x + xInset, y + yInset); //FALL THROUGH case DWT.MouseUp: return clickCount; @@ -1461,8 +1473,8 @@ public Rectangle getClientArea () { checkDevice (); if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) { - 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; int height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); @@ -1474,8 +1486,8 @@ return new Rectangle (x, y, width, height); } -Control getControl (int handle) { - if (handle is 0) return null; +Control getControl (HANDLE handle) { + if (handle is null) return null; if (lastControl !is null && lastHwnd is handle) { return lastControl; } @@ -1483,8 +1495,8 @@ return lastGetControl; } int index; - if (USE_PROPERTY) { - index = OS.GetProp (handle, SWT_OBJECT_INDEX) - 1; + static if (USE_PROPERTY) { + index = cast(int) OS.GetProp (handle, cast(wchar*)SWT_OBJECT_INDEX) - 1; } else { index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1; } @@ -1521,8 +1533,8 @@ */ public Control getCursorControl () { checkDevice (); - POINT pt = new POINT (); - if (!OS.GetCursorPos (pt)) return null; + POINT pt; + if (!OS.GetCursorPos (&pt)) return null; return findControl (OS.WindowFromPoint (pt)); } @@ -1539,8 +1551,8 @@ */ public Point getCursorLocation () { checkDevice (); - POINT pt = new POINT (); - OS.GetCursorPos (pt); + POINT pt; + OS.GetCursorPos (&pt); return new Point (pt.x, pt.y); } @@ -1558,8 +1570,8 @@ */ public Point [] getCursorSizes () { checkDevice (); - return new Point [] { - new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))}; + return [ + new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))]; } /** @@ -1574,11 +1586,12 @@ return Default; } -static bool isValidClass (Class clazz) { - String name = clazz.getName (); +//PORTING_TODO +/+static bool isValidClass (Class clazz) { + char[] name = clazz.getName (); int index = name.lastIndexOf ('.'); return name.substring (0, index + 1).equals (PACKAGE_PREFIX); -} +}+/ /** * Returns the application defined property of the receiver @@ -1605,15 +1618,15 @@ * @see #setData(String, Object) * @see #disposeExec(Runnable) */ -public Object getData (String key) { +public Object getData (char[] key) { checkDevice (); if (key is null) error (DWT.ERROR_NULL_ARGUMENT); - if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) { - return new bool (runMessagesInIdle); + if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { + return new ValueWrapperBool(runMessagesInIdle); } - if (keys is null) return null; + if (keys.length is 0) return null; for (int i=0; i= 0 && wParam !is OS.PM_NOREMOVE) { - MSG msg = new MSG (); - OS.MoveMemory (msg, lParam, MSG.sizeof); + MSG* msg = cast(MSG*)lParam; switch (msg.message) { case OS.WM_KEYDOWN: case OS.WM_KEYUP: @@ -2019,12 +2027,12 @@ case OS.WM_SYSKEYUP: { Control control = findControl (msg.hwnd); if (control !is null) { - int hHeap = OS.GetProcessHeap (); - int keyMsg = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof); - OS.MoveMemory (keyMsg, msg, MSG.sizeof); - OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, keyMsg); + auto hHeap = OS.GetProcessHeap (); + MSG* keyMsg = cast(MSG*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof); + *keyMsg = *msg; + OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, cast(int)keyMsg); msg.message = OS.WM_NULL; - OS.MoveMemory (lParam, msg, MSG.sizeof); + //OS.MoveMemory (lParam, msg, MSG.sizeof); } } } @@ -2039,34 +2047,30 @@ * * @since 3.0 */ -public Monitor getPrimaryMonitor () { +public dwt.widgets.Monitor.Monitor getPrimaryMonitor () { checkDevice (); if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { - Monitor monitor = new Monitor(); + dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor(); int width = OS.GetSystemMetrics (OS.SM_CXSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYSCREEN); monitor.width = width; monitor.height = height; - RECT rect = new RECT (); - OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0); + RECT rect; + OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); monitor.clientX = rect.left; monitor.clientY = rect.top; monitor.clientWidth = rect.right - rect.left; monitor.clientHeight = rect.bottom - rect.top; return monitor; } - monitors = new Monitor [4]; - Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$ - int lpfnEnum = callback.getAddress (); - if (lpfnEnum is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); - callback.dispose (); - Monitor result = null; - MONITORINFO lpmi = new MONITORINFO (); + monitors = new dwt.widgets.Monitor.Monitor [4]; + OS.EnumDisplayMonitors (null, null, &monitorEnumFunc, cast(int)cast(void*)this); + dwt.widgets.Monitor.Monitor result = null; + MONITORINFO lpmi; lpmi.cbSize = MONITORINFO.sizeof; for (int i = 0; i < monitorCount; i++) { - Monitor monitor = monitors [i]; - OS.GetMonitorInfo (monitors [i].handle, lpmi); + dwt.widgets.Monitor.Monitor monitor = monitors [i]; + OS.GetMonitorInfo (monitors [i].handle, &lpmi); if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) !is 0) { result = monitor; break; @@ -2094,7 +2098,7 @@ Shell [] result = new Shell [16]; for (int i = 0; i < controlTable.length; i++) { Control control = controlTable [i]; - if (control !is null && control instanceof Shell) { + if (control !is null && (cast(Shell)control)) { int j = 0; while (j < index) { if (result [j] is control) break; @@ -2106,7 +2110,7 @@ System.arraycopy (result, 0, newResult, 0, index); result = newResult; } - result [index++] = (Shell) control; + result [index++] = cast(Shell) control; } } } @@ -2123,7 +2127,7 @@ Color c1 = getSystemColor (DWT.COLOR_WIDGET_NORMAL_SHADOW); Color c2 = getSystemColor (DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); Color c3 = getSystemColor (DWT.COLOR_WIDGET_BACKGROUND); - PaletteData palette = new PaletteData(new RGB [] {c1.getRGB (), c2.getRGB (), c3.getRGB ()}); + PaletteData palette = new PaletteData([c1.getRGB (), c2.getRGB (), c3.getRGB ()]); ImageData imageData = new ImageData (8, 8, 4, palette); imageData.transparentPixel = 2; upArrow = new Image (this, imageData); @@ -2131,10 +2135,10 @@ gc.setBackground (c3); gc.fillRectangle (0, 0, 8, 8); gc.setForeground (c1); - int [] line1 = new int [] {0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1}; + int [] line1 = [0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1]; gc.drawPolyline (line1); gc.setForeground (c2); - int [] line2 = new int [] {0,7, 7,7, 7,6, 6,6, 6,4, 5,4, 5,2, 4,2, 4,1}; + int [] line2 = [0,7, 7,7, 7,6, 6,6, 6,4, 5,4, 5,2, 4,2, 4,1]; gc.drawPolyline (line2); gc.dispose (); return upArrow; @@ -2144,7 +2148,7 @@ Color c1 = getSystemColor (DWT.COLOR_WIDGET_NORMAL_SHADOW); Color c2 = getSystemColor (DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); Color c3 = getSystemColor (DWT.COLOR_WIDGET_BACKGROUND); - PaletteData palette = new PaletteData (new RGB [] {c1.getRGB (), c2.getRGB (), c3.getRGB ()}); + PaletteData palette = new PaletteData ([c1.getRGB (), c2.getRGB (), c3.getRGB ()]); ImageData imageData = new ImageData (8, 8, 4, palette); imageData.transparentPixel = 2; downArrow = new Image (this, imageData); @@ -2152,10 +2156,10 @@ gc.setBackground (c3); gc.fillRectangle (0, 0, 8, 8); gc.setForeground (c1); - int [] line1 = new int [] {7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6}; + int [] line1 = [7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6]; gc.drawPolyline (line1); gc.setForeground (c2); - int [] line2 = new int [] {4,6, 4,5, 5,5, 5,3, 6,3, 6,1, 7,1}; + int [] line2 = [4,6, 4,5, 5,5, 5,3, 6,3, 6,1, 7,1]; gc.drawPolyline (line2); gc.dispose (); return downArrow; @@ -2313,18 +2317,18 @@ public Font getSystemFont () { checkDevice (); if (systemFont !is null) return systemFont; - int hFont = 0; + HFONT hFont; if (!OS.IsWinCE) { - NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA (); + NONCLIENTMETRICS info; info.cbSize = NONCLIENTMETRICS.sizeof; - if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { - LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont; - hFont = OS.CreateFontIndirect (logFont); - lfSystemFont = hFont !is 0 ? logFont : null; + if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) { + LOGFONT logFont = info.lfMessageFont; + hFont = OS.CreateFontIndirect (&logFont); + lfSystemFont = hFont !is null ? &logFont : null; } } - if (hFont is 0) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT); - if (hFont is 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT); + if (hFont is null) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT); + if (hFont is null) hFont = OS.GetStockObject (OS.SYSTEM_FONT); return systemFont = Font.win32_new (this, hFont); } @@ -2359,23 +2363,23 @@ switch (id) { case DWT.ICON_ERROR: { if (errorImage !is null) return errorImage; - int hIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); + auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return errorImage = Image.win32_new (this, DWT.ICON, hIcon); } case DWT.ICON_WORKING: case DWT.ICON_INFORMATION: { if (infoImage !is null) return infoImage; - int hIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); + auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return infoImage = Image.win32_new (this, DWT.ICON, hIcon); } case DWT.ICON_QUESTION: { if (questionImage !is null) return questionImage; - int hIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); + auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return questionImage = Image.win32_new (this, DWT.ICON, hIcon); } case DWT.ICON_WARNING: { if (warningIcon !is null) return warningIcon; - int hIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); + auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return warningIcon = Image.win32_new (this, DWT.ICON, hIcon); } } @@ -2415,29 +2419,29 @@ return thread; } -int hButtonTheme () { - if (hButtonTheme !is 0) return hButtonTheme; - return hButtonTheme = OS.OpenThemeData (hwndMessage, BUTTON); +HTHEME hButtonTheme () { + if (hButtonTheme_ !is null) return hButtonTheme_; + return hButtonTheme_ = OS.OpenThemeData (hwndMessage, BUTTON.ptr); } -int hEditTheme () { - if (hEditTheme !is 0) return hEditTheme; - return hEditTheme = OS.OpenThemeData (hwndMessage, EDIT); +HTHEME hEditTheme () { + if (hEditTheme_ !is null) return hEditTheme_; + return hEditTheme_ = OS.OpenThemeData (hwndMessage, EDIT.ptr); } -int hExplorerBarTheme () { - if (hExplorerBarTheme !is 0) return hExplorerBarTheme; - return hExplorerBarTheme = OS.OpenThemeData (hwndMessage, EXPLORERBAR); +HTHEME hExplorerBarTheme () { + if (hExplorerBarTheme_ !is null) return hExplorerBarTheme_; + return hExplorerBarTheme_ = OS.OpenThemeData (hwndMessage, EXPLORERBAR.ptr); } -int hScrollBarTheme () { - if (hScrollBarTheme !is 0) return hScrollBarTheme; - return hScrollBarTheme = OS.OpenThemeData (hwndMessage, SCROLLBAR); +HTHEME hScrollBarTheme () { + if (hScrollBarTheme_ !is null) return hScrollBarTheme_; + return hScrollBarTheme_ = OS.OpenThemeData (hwndMessage, SCROLLBAR.ptr); } -int hTabTheme () { - if (hTabTheme !is 0) return hTabTheme; - return hTabTheme = OS.OpenThemeData (hwndMessage, TAB); +HTHEME hTabTheme () { + if (hTabTheme_ !is null) return hTabTheme_; + return hTabTheme_ = OS.OpenThemeData (hwndMessage, TAB.ptr); } /** @@ -2460,10 +2464,10 @@ *
  • ERROR_NO_HANDLES if a handle could not be obtained for gc creation
  • * */ -public int internal_new_GC (GCData data) { +public HDC internal_new_GC (GCData data) { if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED); - int hDC = OS.GetDC (0); - if (hDC is 0) DWT.error (DWT.ERROR_NO_HANDLES); + auto hDC = OS.GetDC (null); + if (hDC is null) DWT.error (DWT.ERROR_NO_HANDLES); if (data !is null) { int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; if ((data.style & mask) !is 0) { @@ -2490,38 +2494,40 @@ super.init (); /* Create the callbacks */ - windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$ - windowProc = windowCallback.getAddress (); - if (windowProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); + //windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$ + //windowProc_ = windowCallback.getAddress (); + //if (windowProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); /* Remember the current thread id */ threadId = OS.GetCurrentThreadId (); /* Use the character encoding for the default locale */ - windowClass = new TCHAR (0, WindowName + WindowClassCount, true); - windowShadowClass = new TCHAR (0, WindowShadowName + WindowClassCount, true); + windowClass = StrToTCHARz ( WindowName ~ to!(char[])(WindowClassCount)); + windowShadowClass = StrToTCHARz ( WindowShadowName ~ to!(char[])(WindowClassCount)); WindowClassCount++; /* Register the DWT window class */ - int hHeap = OS.GetProcessHeap (); - int hInstance = OS.GetModuleHandle (null); - WNDCLASS lpWndClass = new WNDCLASS (); + auto hHeap = OS.GetProcessHeap (); + auto hInstance = OS.GetModuleHandle (null); + WNDCLASS lpWndClass; lpWndClass.hInstance = hInstance; - lpWndClass.lpfnWndProc = windowProc; + lpWndClass.lpfnWndProc = &windowProcFunc; lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS; - lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW); - int byteCount = windowClass.length () * TCHAR.sizeof; - lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); - OS.MoveMemory (lpWndClass.lpszClassName, windowClass, byteCount); - OS.RegisterClass (lpWndClass); + lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW); + int len = strlenz( windowClass ); + int byteCount = len * TCHAR.sizeof; + lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + lpWndClass.lpszClassName[ 0 .. len ] = windowClass[ 0 .. len ]; + OS.RegisterClass (&lpWndClass); OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName); /* Register the DWT drop shadow window class */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) lpWndClass.style |= OS.CS_DROPSHADOW; - byteCount = windowShadowClass.length () * TCHAR.sizeof; - lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); - OS.MoveMemory (lpWndClass.lpszClassName, windowShadowClass, byteCount); - OS.RegisterClass (lpWndClass); + len = strlenz( windowShadowClass ); + byteCount = len * TCHAR.sizeof; + lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + lpWndClass.lpszClassName[ 0 .. len ] = windowShadowClass[ 0 .. len ]; + OS.RegisterClass (&lpWndClass); OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName); /* Create the message only HWND */ @@ -2530,37 +2536,37 @@ null, OS.WS_OVERLAPPED, 0, 0, 0, 0, - 0, - 0, + null, + null, hInstance, null); - messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$ - messageProc = messageCallback.getAddress (); - if (messageProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); - OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, messageProc); + //messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$ + //messageProc_ = messageCallback.getAddress (); + //if (messageProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); + OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, cast(int) &messageProcFunc); /* Create the filter hook */ - if (!OS.IsWinCE) { - msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$ - msgFilterProc = msgFilterCallback.getAddress (); - if (msgFilterProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); - filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId); + static if (!OS.IsWinCE) { + //msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$ + //msgFilterProc_ = msgFilterCallback.getAddress (); + //if (msgFilterProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); + filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, &msgFilterProcFunc, null, threadId); } /* Create the idle hook */ - if (!OS.IsWinCE) { - foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$ - foregroundIdleProc = foregroundIdleCallback.getAddress (); - if (foregroundIdleProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); - idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, foregroundIdleProc, 0, threadId); + static if (!OS.IsWinCE) { + //foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$ + //foregroundIdleProc_ = foregroundIdleCallback.getAddress (); + //if (foregroundIdleProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); + idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, &foregroundIdleProcFunc, null, threadId); } /* Register custom messages message */ - SWT_TASKBARCREATED = OS.RegisterWindowMessage (new TCHAR (0, "TaskbarCreated", true)); - SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true)); + SWT_TASKBARCREATED = OS.RegisterWindowMessage (StrToTCHARz ( "TaskbarCreated" )); + SWT_RESTORECARET = OS.RegisterWindowMessage (StrToTCHARz ( "SWT_RESTORECARET")); /* Initialize OLE */ - if (!OS.IsWinCE) OS.OleInitialize (0); + static if (!OS.IsWinCE) OS.OleInitialize (null); /* Initialize buffered painting */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)){ @@ -2587,8 +2593,8 @@ * @param hDC the platform specific GC handle * @param data the platform specific GC data */ -public void internal_dispose_GC (int hDC, GCData data) { - OS.ReleaseDC (0, hDC); +public void internal_dispose_GC (HDC hDC, GCData data) { + OS.ReleaseDC (null, hDC); } bool isXMouseActive () { @@ -2596,21 +2602,22 @@ * NOTE: X-Mouse is active when bit 1 of the UserPreferencesMask is set. */ bool xMouseActive = false; - TCHAR key = new TCHAR (0, "Control Panel\\Desktop", true); //$NON-NLS-1$ - int [] phKey = new int [1]; - int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, phKey); + TCHAR* key = StrToTCHARz( "Control Panel\\Desktop" ); //$NON-NLS-1$ + void* phKey; + int result = OS.RegOpenKeyEx (cast(void*)OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, &phKey); if (result is 0) { - TCHAR lpValueName = new TCHAR (0, "UserPreferencesMask", true); //$NON-NLS-1$ - int [] lpcbData = new int [] {4}, lpData = new int [1]; - result = OS.RegQueryValueEx (phKey [0], lpValueName, 0, null, lpData, lpcbData); - if (result is 0) xMouseActive = (lpData [0] & 0x01) !is 0; - OS.RegCloseKey (phKey [0]); + TCHAR* lpValueName = StrToTCHARz ( "UserPreferencesMask" ); //$NON-NLS-1$ + uint[4] lpcbData; + uint lpData; + result = OS.RegQueryValueEx (phKey, lpValueName, null, null, cast(ubyte*)&lpData, lpcbData.ptr); + if (result is 0) xMouseActive = (lpData & 0x01) !is 0; + OS.RegCloseKey (phKey); } return xMouseActive; } bool isValidThread () { - return thread is Thread.currentThread (); + return thread is Thread.getThis (); } /** @@ -2696,12 +2703,12 @@ if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); if (from is to) return new Point (x, y); - int hwndFrom = from !is null ? from.handle : 0; - int hwndTo = to !is null ? to.handle : 0; - POINT point = new POINT (); + auto hwndFrom = from !is null ? from.handle : null; + auto hwndTo = to !is null ? to.handle : null; + POINT point; point.x = x; point.y = y; - OS.MapWindowPoints (hwndFrom, hwndTo, point, 1); + OS.MapWindowPoints (hwndFrom, hwndTo, &point, 1); return new Point (point.x, point.y); } @@ -2790,14 +2797,14 @@ if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); if (from is to) return new Rectangle (x, y, width, height); - int hwndFrom = from !is null ? from.handle : 0; - int hwndTo = to !is null ? to.handle : 0; - RECT rect = new RECT (); + auto hwndFrom = from !is null ? from.handle : null; + auto hwndTo = to !is null ? to.handle : null; + RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; - OS.MapWindowPoints (hwndFrom, hwndTo, rect, 2); + OS.MapWindowPoints (hwndFrom, hwndTo, cast(POINT*)&rect, 2); return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } @@ -2822,27 +2829,32 @@ * @param codePage the code page used to convert the character * @return the WCS character */ -static char mbcsToWcs (int ch, int codePage) { - if (OS.IsUnicode) return (char) ch; +static wchar mbcsToWcs (int ch, int codePage) { + if (OS.IsUnicode) return cast(wchar) ch; int key = ch & 0xFFFF; - if (key <= 0x7F) return (char) ch; - byte [] buffer; + if (key <= 0x7F) return cast(wchar) ch; + char [] buffer; if (key <= 0xFF) { - buffer = new byte [1]; - buffer [0] = (byte) key; + buffer = new char [1]; + buffer [0] = cast(char) key; } else { - buffer = new byte [2]; - buffer [0] = (byte) ((key >> 8) & 0xFF); - buffer [1] = (byte) (key & 0xFF); + buffer = new char [2]; + buffer [0] = cast(char) ((key >> 8) & 0xFF); + buffer [1] = cast(char) (key & 0xFF); } - char [] unicode = new char [1]; + wchar [] unicode = new wchar [1]; int cp = codePage !is 0 ? codePage : OS.CP_ACP; - int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, buffer.length, unicode, 1); + int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer.ptr, buffer.length, unicode.ptr, 1); if (count is 0) return 0; return unicode [0]; } -int messageProc (int hwnd, int msg, int wParam, int lParam) { +private static extern(Windows) int messageProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) { + Display d = Display.getCurrent(); + return d.messageProc( hwnd, msg, wParam, lParam ); +} + +int messageProc (HWND hwnd, uint msg, uint wParam, int lParam) { switch (msg) { case SWT_RUNASYNC: { if (runMessagesInIdle) runAsyncMessages (false); @@ -2850,8 +2862,7 @@ } case SWT_KEYMSG: { bool consumed = false; - MSG keyMsg = new MSG (); - OS.MoveMemory (keyMsg, lParam, MSG.sizeof); + MSG* keyMsg = cast(MSG*) lParam; Control control = findControl (keyMsg.hwnd); if (control !is null) { /* @@ -2937,8 +2948,8 @@ } } if (consumed) { - int hHeap = OS.GetProcessHeap (); - OS.HeapFree (hHeap, 0, lParam); + auto hHeap = OS.GetProcessHeap (); + OS.HeapFree (hHeap, 0, cast(void*)lParam); } else { OS.PostMessage (embeddedHwnd, SWT_KEYMSG, wParam, lParam); } @@ -2981,13 +2992,13 @@ if (modalDialogShell !is null && modalDialogShell.isDisposed ()) modalDialogShell = null; Shell modal = modalDialogShell !is null ? modalDialogShell : getModalShell (); if (modal !is null) { - int hwndModal = modal.handle; + auto hwndModal = modal.handle; if (OS.IsWindowEnabled (hwndModal)) { modal.bringToTop (); if (modal.isDisposed ()) break; } - int hwndPopup = OS.GetLastActivePopup (hwndModal); - if (hwndPopup !is 0 && hwndPopup !is modal.handle) { + auto hwndPopup = OS.GetLastActivePopup (hwndModal); + if (hwndPopup !is null && hwndPopup !is modal.handle) { if (getControl (hwndPopup) is null) { if (OS.IsWindowEnabled (hwndPopup)) { OS.SetActiveWindow (hwndPopup); @@ -3022,18 +3033,18 @@ case 0: case 1: case OS.SPI_SETHIGHCONTRAST: - OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, 0); + OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null); } break; } case OS.WM_THEMECHANGED: { if (OS.COMCTL32_MAJOR >= 6) { - if (hButtonTheme !is 0) OS.CloseThemeData (hButtonTheme); - if (hEditTheme !is 0) OS.CloseThemeData (hEditTheme); - if (hExplorerBarTheme !is 0) OS.CloseThemeData (hExplorerBarTheme); - if (hScrollBarTheme !is 0) OS.CloseThemeData (hScrollBarTheme); - if (hTabTheme !is 0) OS.CloseThemeData (hTabTheme); - hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0; + if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_); + if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_); + if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_); + if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_); + if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_); + hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null; } break; } @@ -3061,34 +3072,43 @@ return OS.DefWindowProc (hwnd, msg, wParam, lParam); } -int monitorEnumProc (int hmonitor, int hdc, int lprcMonitor, int dwData) { +private static extern(Windows) int monitorEnumFunc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor, int dwData) { + auto d = cast(Display)cast(void*)dwData; + return d.monitorEnumProc( hmonitor, hdc, lprcMonitor ); +} +int monitorEnumProc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor) { if (monitorCount >= monitors.length) { - Monitor[] newMonitors = new Monitor [monitors.length + 4]; + dwt.widgets.Monitor.Monitor[] newMonitors = new dwt.widgets.Monitor.Monitor [monitors.length + 4]; System.arraycopy (monitors, 0, newMonitors, 0, monitors.length); monitors = newMonitors; } - MONITORINFO lpmi = new MONITORINFO (); + MONITORINFO lpmi; lpmi.cbSize = MONITORINFO.sizeof; - OS.GetMonitorInfo (hmonitor, lpmi); - Monitor monitor = new Monitor (); + OS.GetMonitorInfo (hmonitor, &lpmi); + dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor (); monitor.handle = hmonitor; - monitor.x = lpmi.rcMonitor_left; - monitor.y = lpmi.rcMonitor_top; - monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left; - monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top; - monitor.clientX = lpmi.rcWork_left; - monitor.clientY = lpmi.rcWork_top; - monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left; - monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top; + monitor.x = lpmi.rcMonitor.left; + monitor.y = lpmi.rcMonitor.top; + monitor.width = lpmi.rcMonitor.right - lpmi.rcMonitor.left; + monitor.height = lpmi.rcMonitor.bottom - lpmi.rcMonitor.top; + monitor.clientX = lpmi.rcWork.left; + monitor.clientY = lpmi.rcWork.top; + monitor.clientWidth = lpmi.rcWork.right - lpmi.rcWork.left; + monitor.clientHeight = lpmi.rcWork.bottom - lpmi.rcWork.top; monitors [monitorCount++] = monitor; return 1; } +private static extern(Windows) int msgFilterProcFunc (int code, int wParam, int lParam) { + Display pThis = Display.getCurrent(); + return pThis.msgFilterProc( code, wParam, lParam ); +} + int msgFilterProc (int code, int wParam, int lParam) { switch (code) { case OS.MSGF_COMMCTRL_BEGINDRAG: { if (!runDragDrop) { - OS.MoveMemory (hookMsg, lParam, MSG.sizeof); + hookMsg = *cast(MSG*)lParam; if (hookMsg.message is OS.WM_MOUSEMOVE) { OS.SendMessage (hookMsg.hwnd, OS.WM_CANCELMODE, 0, 0); } @@ -3111,11 +3131,11 @@ case OS.MSGF_SCROLLBAR: case OS.MSGF_SIZE: { if (runMessages) { - OS.MoveMemory (hookMsg, lParam, MSG.sizeof); + hookMsg = *cast(MSG*)lParam; if (hookMsg.message is OS.WM_NULL) { - MSG msg = new MSG (); + MSG msg; int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE; - if (!OS.PeekMessage (msg, 0, 0, 0, flags)) { + if (!OS.PeekMessage (&msg, null, 0, 0, flags)) { if (runAsyncMessages (false)) wakeThread (); } } @@ -3208,27 +3228,27 @@ switch (type){ case DWT.KeyDown: case DWT.KeyUp: { - KEYBDINPUT inputs = new KEYBDINPUT (); - inputs.wVk = (short) untranslateKey (event.keyCode); + KEYBDINPUT inputs; + inputs.wVk = cast(short) untranslateKey (event.keyCode); if (inputs.wVk is 0) { char key = event.character; switch (key) { - case DWT.BS: inputs.wVk = (short) OS.VK_BACK; break; - case DWT.CR: inputs.wVk = (short) OS.VK_RETURN; break; - case DWT.DEL: inputs.wVk = (short) OS.VK_DELETE; break; - case DWT.ESC: inputs.wVk = (short) OS.VK_ESCAPE; break; - case DWT.TAB: inputs.wVk = (short) OS.VK_TAB; break; + case DWT.BS: inputs.wVk = cast(short) OS.VK_BACK; break; + case DWT.CR: inputs.wVk = cast(short) OS.VK_RETURN; break; + case DWT.DEL: inputs.wVk = cast(short) OS.VK_DELETE; break; + case DWT.ESC: inputs.wVk = cast(short) OS.VK_ESCAPE; break; + case DWT.TAB: inputs.wVk = cast(short) OS.VK_TAB; break; /* * Since there is no LF key on the keyboard, do not attempt * to map LF to CR or attempt to post an LF key. */ -// case DWT.LF: inputs.wVk = (short) OS.VK_RETURN; break; +// case DWT.LF: inputs.wVk = cast(short) OS.VK_RETURN; break; case DWT.LF: return false; default: { if (OS.IsWinCE) { - inputs.wVk = OS.CharUpper ((short) key); + inputs.wVk = cast(int)OS.CharUpper (cast(wchar*) key); } else { - inputs.wVk = OS.VkKeyScan ((short) wcsToMbcs (key, 0)); + inputs.wVk = OS.VkKeyScan (cast(short) wcsToMbcs (key, 0)); if (inputs.wVk is -1) return false; inputs.wVk &= 0xFF; } @@ -3236,10 +3256,11 @@ } } inputs.dwFlags = type is DWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0; - int hHeap = OS.GetProcessHeap (); - int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); - OS.MoveMemory(pInputs, new int[] {OS.INPUT_KEYBOARD}, 4); - OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof); + auto hHeap = OS.GetProcessHeap (); + auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); + pInputs.type = OS.INPUT_KEYBOARD; + pInputs.ki = inputs; + //OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof); bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0; OS.HeapFree (hHeap, 0, pInputs); return result; @@ -3248,7 +3269,7 @@ case DWT.MouseMove: case DWT.MouseUp: case DWT.MouseWheel: { - MOUSEINPUT inputs = new MOUSEINPUT (); + MOUSEINPUT inputs; if (type is DWT.MouseMove){ inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE; int x= 0, y = 0, width = 0, height = 0; @@ -3273,9 +3294,9 @@ inputs.mouseData = event.count * OS.WHEEL_DELTA; break; case DWT.SCROLL_LINE: - int [] value = new int [1]; - OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0); - inputs.mouseData = event.count * OS.WHEEL_DELTA / value [0]; + int value; + OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0); + inputs.mouseData = event.count * OS.WHEEL_DELTA / value; break; default: return false; } @@ -3300,10 +3321,12 @@ } } } - int hHeap = OS.GetProcessHeap (); - int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); - OS.MoveMemory(pInputs, new int[] {OS.INPUT_MOUSE}, 4); - OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof); + auto hHeap = OS.GetProcessHeap (); + auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); + pInputs.type = OS.INPUT_MOUSE; + //OS.MoveMemory(pInputs, [OS.INPUT_MOUSE], 4); + pInputs.mi = inputs; + //OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof); bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0; OS.HeapFree (hHeap, 0, pInputs); return result; @@ -3321,14 +3344,14 @@ */ if (eventQueue is null) eventQueue = new Event [4]; int index = 0; - int length = eventQueue.length; - while (index < length) { + int length_ = eventQueue.length; + while (index < length_) { if (eventQueue [index] is null) break; index++; } - if (index is length) { - Event [] newQueue = new Event [length + 4]; - System.arraycopy (eventQueue, 0, newQueue, 0, length); + if (index is length_) { + Event [] newQueue = new Event [length_ + 4]; + System.arraycopy (eventQueue, 0, newQueue, 0, length_); eventQueue = newQueue; } eventQueue [index] = event; @@ -3360,13 +3383,13 @@ */ public bool readAndDispatch () { checkDevice (); - lpStartupInfo = null; + //lpStartupInfo = null; drawMenuBars (); runPopups (); - if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) { - if (!filterMessage (msg)) { - OS.TranslateMessage (msg); - OS.DispatchMessage (msg); + if (OS.PeekMessage (&msg, null, 0, 0, OS.PM_REMOVE)) { + if (!filterMessage (&msg)) { + OS.TranslateMessage (&msg); + OS.DispatchMessage (&msg); } runDeferredEvents (); return true; @@ -3434,62 +3457,62 @@ } void releaseDisplay () { - if (embeddedHwnd !is 0) { + if (embeddedHwnd !is null) { OS.PostMessage (embeddedHwnd, SWT_DESTROY, 0, 0); } /* Release XP Themes */ if (OS.COMCTL32_MAJOR >= 6) { - if (hButtonTheme !is 0) OS.CloseThemeData (hButtonTheme); - if (hEditTheme !is 0) OS.CloseThemeData (hEditTheme); - if (hExplorerBarTheme !is 0) OS.CloseThemeData (hExplorerBarTheme); - if (hScrollBarTheme !is 0) OS.CloseThemeData (hScrollBarTheme); - if (hTabTheme !is 0) OS.CloseThemeData (hTabTheme); - hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0; + if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_); + if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_); + if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_); + if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_); + if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_); + hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null; } /* Unhook the message hook */ - if (!OS.IsWinCE) { - if (msgHook !is 0) OS.UnhookWindowsHookEx (msgHook); - msgHook = 0; + static if (!OS.IsWinCE) { + if (msgHook !is null) OS.UnhookWindowsHookEx (msgHook); + msgHook = null; } /* Unhook the filter hook */ - if (!OS.IsWinCE) { - if (filterHook !is 0) OS.UnhookWindowsHookEx (filterHook); - filterHook = 0; - msgFilterCallback.dispose (); - msgFilterCallback = null; - msgFilterProc = 0; + static if (!OS.IsWinCE) { + if (filterHook !is null) OS.UnhookWindowsHookEx (filterHook); + filterHook = null; + //msgFilterCallback.dispose (); + //msgFilterCallback = null; + //msgFilterProc_ = 0; } /* Unhook the idle hook */ if (!OS.IsWinCE) { - if (idleHook !is 0) OS.UnhookWindowsHookEx (idleHook); - idleHook = 0; - foregroundIdleCallback.dispose (); - foregroundIdleCallback = null; - foregroundIdleProc = 0; + if (idleHook !is null) OS.UnhookWindowsHookEx (idleHook); + idleHook = null; + //foregroundIdleCallback.dispose (); + //foregroundIdleCallback = null; + //foregroundIdleProc_ = 0; } /* Destroy the message only HWND */ - if (hwndMessage !is 0) OS.DestroyWindow (hwndMessage); - hwndMessage = 0; - messageCallback.dispose (); - messageCallback = null; - messageProc = 0; + if (hwndMessage !is null) OS.DestroyWindow (hwndMessage); + hwndMessage = null; + //messageCallback.dispose (); + //messageCallback = null; + //messageProc_ = 0; /* Unregister the DWT window class */ - int hHeap = OS.GetProcessHeap (); - int hInstance = OS.GetModuleHandle (null); + auto hHeap = OS.GetProcessHeap (); + auto hInstance = OS.GetModuleHandle (null); OS.UnregisterClass (windowClass, hInstance); /* Unregister the DWT drop shadow window class */ OS.UnregisterClass (windowShadowClass, hInstance); windowClass = windowShadowClass = null; - windowCallback.dispose (); - windowCallback = null; - windowProc = 0; + //windowCallback.dispose (); + //windowCallback = null; + //windowProc_ = 0; /* Release the System fonts */ if (systemFont !is null) systemFont.dispose (); @@ -3523,11 +3546,11 @@ } /* Release Custom Colors for ChooseColor */ - if (lpCustColors !is 0) OS.HeapFree (hHeap, 0, lpCustColors); - lpCustColors = 0; + if (lpCustColors !is null) OS.HeapFree (hHeap, 0, lpCustColors); + lpCustColors = null; /* Uninitialize OLE */ - if (!OS.IsWinCE) OS.OleUninitialize (); + static if (!OS.IsWinCE) OS.OleUninitialize (); /* Uninitialize buffered painting */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { @@ -3536,8 +3559,8 @@ /* Release references */ thread = null; - msg = null; - keyboard = null; + //msg = null; + //keyboard = null; modalDialogShell = null; modalShells = null; data = null; @@ -3552,14 +3575,14 @@ void releaseImageList (ImageList list) { int i = 0; - int length = imageList.length; - while (i < length) { + int length_ = imageList.length; + while (i < length_) { if (imageList [i] is list) { if (list.removeRef () > 0) return; list.dispose (); - System.arraycopy (imageList, i + 1, imageList, i, --length - i); - imageList [length] = null; - for (int j=0; j 0) return; list.dispose (); - System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i); - toolImageList [length] = null; - for (int j=0; j 0) return; list.dispose (); - System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i); - toolHotImageList [length] = null; - for (int j=0; j 0) return; list.dispose (); - System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i); - toolDisabledImageList [length] = null; - for (int j=0; jnull */ -public static void setAppName (String name) { +public static void setAppName (char[] name) { /* Do nothing */ } @@ -4066,15 +4091,15 @@ void setModalShell (Shell shell) { if (modalShells is null) modalShells = new Shell [4]; - int index = 0, length = modalShells.length; - while (index < length) { + int index = 0, length_ = modalShells.length; + while (index < length_) { if (modalShells [index] is shell) return; if (modalShells [index] is null) break; index++; } - if (index is length) { - Shell [] newModalShells = new Shell [length + 4]; - System.arraycopy (modalShells, 0, newModalShells, 0, length); + if (index is length_) { + Shell [] newModalShells = new Shell [length_ + 4]; + System.arraycopy (modalShells, 0, newModalShells, 0, length_); modalShells = newModalShells; } modalShells [index] = shell; @@ -4114,12 +4139,12 @@ keyboard [OS.VK_SHIFT] |= 0x80; /* Translate the key to ASCII or UNICODE using the virtual keyboard */ - if (OS.IsUnicode) { - char [] result = new char [1]; - if (OS.ToUnicode (key, key, keyboard, result, 1, 0) is 1) return result [0]; + static if (OS.IsUnicode) { + wchar result; + if (OS.ToUnicode (key, key, keyboard.ptr, &result, 1, 0) is 1) return result; } else { - short [] result = new short [1]; - if (OS.ToAscii (key, key, keyboard, result, 0) is 1) return result [0]; + wchar result; + if (OS.ToAscii (key, key, keyboard.ptr, &result, 0) is 1) return result; } return 0; } @@ -4141,11 +4166,11 @@ public bool sleep () { checkDevice (); if (runMessages && getMessageCount () !is 0) return true; - if (OS.IsWinCE) { - OS.MsgWaitForMultipleObjectsEx (0, 0, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE); + static if (OS.IsWinCE) { + OS.MsgWaitForMultipleObjectsEx (0, null, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE); return true; } - return OS.WaitMessage (); + return cast(bool) OS.WaitMessage (); } /** @@ -4203,6 +4228,7 @@ public void timerExec (int milliseconds, Runnable runnable) { checkDevice (); if (runnable is null) error (DWT.ERROR_NULL_ARGUMENT); + assert( runnable ); if (timerList is null) timerList = new Runnable [4]; if (timerIds is null) timerIds = new int [4]; int index = 0; @@ -4229,21 +4255,21 @@ timerId = nextTimerId++; if (index is timerList.length) { Runnable [] newTimerList = new Runnable [timerList.length + 4]; - System.arraycopy (timerList, 0, newTimerList, 0, timerList.length); + SimpleType!(Runnable).arraycopy (timerList, 0, newTimerList, 0, timerList.length); timerList = newTimerList; int [] newTimerIds = new int [timerIds.length + 4]; System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length); timerIds = newTimerIds; } } - int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0); + int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, null); if (newTimerID !is 0) { timerList [index] = runnable; timerIds [index] = newTimerID; } } -bool translateAccelerator (MSG msg, Control control) { +bool translateAccelerator (MSG* msg, Control control) { accelKeyHit = true; bool result = control.translateAccelerator (msg); accelKeyHit = false; @@ -4257,16 +4283,17 @@ return 0; } -bool translateMnemonic (MSG msg, Control control) { +bool translateMnemonic (MSG* msg, Control control) { switch (msg.message) { case OS.WM_CHAR: case OS.WM_SYSCHAR: return control.translateMnemonic (msg); + default: } return false; } -bool translateTraversal (MSG msg, Control control) { +bool translateTraversal (MSG* msg, Control control) { switch (msg.message) { case OS.WM_KEYDOWN: switch (msg.wParam) { @@ -4280,12 +4307,14 @@ case OS.VK_PRIOR: case OS.VK_NEXT: return control.translateTraversal (msg); + default: } break; case OS.WM_SYSKEYDOWN: switch (msg.wParam) { case OS.VK_MENU: return control.translateTraversal (msg); + default: } break; } @@ -4327,9 +4356,9 @@ */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { if (OS.IsHungAppWindow (hwndMessage)) { - MSG msg = new MSG (); + MSG msg; int flags = OS.PM_REMOVE | OS.PM_NOYIELD; - OS.PeekMessage (msg, hwndMessage, SWT_NULL, SWT_NULL, flags); + OS.PeekMessage (&msg, hwndMessage, SWT_NULL, SWT_NULL, flags); } } Shell[] shells = getShells (); @@ -4362,7 +4391,7 @@ */ public void wake () { if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED); - if (thread is Thread.currentThread ()) return; + if (thread is Thread.getThis ()) return; wakeThread (); } @@ -4384,11 +4413,13 @@ * @param codePage the code page used to convert the character * @return the MBCS character */ -static int wcsToMbcs (char ch, int codePage) { +static int wcsToMbcs (wchar ch, int codePage) { if (OS.IsUnicode) return ch; if (ch <= 0x7F) return ch; - TCHAR buffer = new TCHAR (codePage, ch, false); - return buffer.tcharAt (0); + wchar[1] wc; + wc[0] = ch; + auto r = StrToMBCSs( tango.text.convert.Utf.toString(wc), codePage ); + return r[0]; } /* @@ -4404,7 +4435,12 @@ return wcsToMbcs (ch, 0); } -int windowProc (int hwnd, int msg, int wParam, int lParam) { +private static extern(Windows) int windowProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) { + auto d = Display.getCurrent(); + return d.windowProc( hwnd, msg, wParam, lParam ); +} + +int windowProc (HWND hwnd, uint msg, uint wParam, int lParam) { /* * Bug in Adobe Reader 7.0. For some reason, when Adobe * Reader 7.0 is deactivated from within Internet Explorer, @@ -4420,7 +4456,7 @@ */ if (msg is OS.WM_NCHITTEST) { if (hitCount++ >= 1024) { - try {Thread.sleep (1);} catch (Throwable t) {} + try {Thread.sleep (0.001);} catch (Exception t) {} } } else { hitCount = 0; @@ -4429,8 +4465,8 @@ return lastControl.windowProc (hwnd, msg, wParam, lParam); } int index; - if (USE_PROPERTY) { - index = OS.GetProp (hwnd, SWT_OBJECT_INDEX) - 1; + static if (USE_PROPERTY) { + index = cast(int)OS.GetProp (hwnd, cast(wchar*)SWT_OBJECT_INDEX) - 1; } else { index = OS.GetWindowLong (hwnd, OS.GWL_USERDATA) - 1; } @@ -4445,11 +4481,11 @@ return OS.DefWindowProc (hwnd, msg, wParam, lParam); } -static String withCrLf (String string) { +static char[] withCrLf (char[] string) { /* If the string is empty, return the string. */ - int length = string.length (); - if (length is 0) return string; + int length_ = string.length; + if (length_ is 0) return string; /* * Check for an LF or CR/LF and assume the rest of @@ -4469,20 +4505,20 @@ */ i++; int count = 1; - while (i < length) { + while (i < length_) { if ((i = string.indexOf ('\n', i)) is -1) break; count++; i++; } - count += length; + count += length_; /* Create a new string with the CR/LF line terminator. */ i = 0; StringBuffer result = new StringBuffer (count); - while (i < length) { + while (i < length_) { int j = string.indexOf ('\n', i); - if (j is -1) j = length; + if (j is -1) j = length_; result.append (string.substring (i, j)); - if ((i = j) < length) { + if ((i = j) < length_) { result.append ("\r\n"); //$NON-NLS-1$ i++; } @@ -4491,4 +4527,3 @@ } } -++/ \ No newline at end of file diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Menu.d --- a/dwt/widgets/Menu.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Menu.d Mon Jan 28 21:05:39 2008 +0100 @@ -17,6 +17,8 @@ this( Widget, int ); public void setLocation (int x, int y) ; public void setVisible (bool visible) ; +void update (); +void _setVisible (bool visible) ; } /++ import dwt.DWT; diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/MenuItem.d --- a/dwt/widgets/MenuItem.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/MenuItem.d Mon Jan 28 21:05:39 2008 +0100 @@ -16,6 +16,7 @@ import dwt.widgets.Widget; class MenuItem : Item { + int id; public this (Widget parent, int style) { super (parent, style); } diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Monitor.d --- a/dwt/widgets/Monitor.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Monitor.d Mon Jan 28 21:05:39 2008 +0100 @@ -13,6 +13,7 @@ module dwt.widgets.Monitor; import dwt.graphics.Rectangle; +import dwt.internal.win32.WINTYPES; /** * Instances of this class are descriptions of monitors. @@ -22,7 +23,7 @@ * @since 3.0 */ public final class Monitor { - int handle; + HMONITOR handle; int x, y, width, height; int clientX, clientY, clientWidth, clientHeight; diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/Shell.d --- a/dwt/widgets/Shell.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/Shell.d Mon Jan 28 21:05:39 2008 +0100 @@ -13,6 +13,7 @@ import dwt.widgets.Decorations; class Shell : Decorations { void checkWidget (); +void updateModal () ; } /++ import dwt.DWT; diff -r 2985239119a3 -r 39a9959ef14d dwt/widgets/TrayItem.d --- a/dwt/widgets/TrayItem.d Mon Jan 28 14:13:08 2008 +0100 +++ b/dwt/widgets/TrayItem.d Mon Jan 28 21:05:39 2008 +0100 @@ -12,11 +12,15 @@ import dwt.widgets.Item; import dwt.widgets.Widget; +import dwt.internal.win32.OS; class TrayItem : Item { + int id; public this (Widget parent, int style) { super (parent, style); } +int messageProc (HWND hwnd, int msg, int wParam, int lParam) ; +void recreate () ; } /++ @@ -239,7 +243,7 @@ return visible; } -int messageProc (int hwnd, int msg, int wParam, int lParam) { +int messageProc (HWND hwnd, int msg, int wParam, int lParam) { /* * Feature in Windows. When the user clicks on the tray * icon, another application may be the foreground window. diff -r 2985239119a3 -r 39a9959ef14d tango_sys_win32/Types.di --- a/tango_sys_win32/Types.di Mon Jan 28 14:13:08 2008 +0100 +++ b/tango_sys_win32/Types.di Mon Jan 28 21:05:39 2008 +0100 @@ -12999,8 +12999,7 @@ alias WINDOWPLACEMENT TWINDOWPLACEMENT; alias WINDOWPLACEMENT* PWINDOWPLACEMENT; -struct WNDCLASS -{ +struct WNDCLASSA { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; @@ -13013,11 +13012,34 @@ LPCTSTR lpszClassName; } +alias WNDCLASSA* PWNDCLASSA, LPWNDCLASSA; + +struct WNDCLASSW { + UINT style; + WNDPROC lpfnWndProc; + int cbClsExtra; + int cbWndExtra; + HINSTANCE hInstance; + HICON hIcon; + HCURSOR hCursor; + HBRUSH hbrBackground; + LPCWSTR lpszMenuName; + LPCWSTR lpszClassName; +}; + +alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW; + +// since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name +version(ANSI){ + alias WNDCLASSA WNDCLASS; +}else{ + alias WNDCLASSW WNDCLASS; +} + alias WNDCLASS* LPWNDCLASS; alias WNDCLASS _WNDCLASS; alias WNDCLASS TWNDCLASS; -alias WNDCLASS TWNDCLASSA; -alias WNDCLASS* PWNDCLASS; +alias WNDCLASS WNDCLASS_T; struct WNDCLASSEX {