# HG changeset patch # User Frank Benoit # Date 1205959711 -3600 # Node ID 3afcd4ddcf9014dd184203fbe59faceaf72aaefe # Parent d0bbd290530f48757b3e61e01662798d9ff01491 Update to SWT 3.3.2 diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/custom/CCombo.d --- a/dwt/custom/CCombo.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/custom/CCombo.d Wed Mar 19 21:48:31 2008 +0100 @@ -1087,7 +1087,21 @@ dropDown (false); break; case DWT.Deactivate: - dropDown (false); + /* + * Bug in GTK. When the arrow button is pressed the popup control receives a + * deactivate event and then the arrow button receives a selection event. If + * we hide the popup in the deactivate event, the selection event will show + * it again. To prevent the popup from showing again, we will let the selection + * event of the arrow button hide the popup. + */ + if ("gtk".equals(DWT.getPlatform())) { + Point point = arrow.toControl(getDisplay().getCursorLocation()); + Point size = arrow.getSize(); + Rectangle rect = new Rectangle(0, 0, size.x, size.y); + if (!rect.contains(point)) dropDown (false); + } else { + dropDown(false); + } break; default: } diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/dnd/DragSource.d --- a/dwt/dnd/DragSource.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/dnd/DragSource.d Wed Mar 19 21:48:31 2008 +0100 @@ -131,6 +131,7 @@ Transfer[] transferAgents; DragSourceEffect dragEffect; Composite topControl; + HWND hwndDrag; // ole interfaces _IDropSourceImpl iDropSource; @@ -143,6 +144,7 @@ static const char[] DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ static const char[] DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ static const int CFSTR_PERFORMEDDROPEFFECT; + static final TCHAR[] WindowClass = "#32770\0"; static this(){ CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$ } @@ -298,17 +300,43 @@ uint[1] pdwEffect; int operations = opToOs(getStyle()); Display display = control.getDisplay(); - char[] key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ + char[] key = "dwt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ Object oldValue = display.getData(key); display.setData(key, new ValueWrapperBool(true)); ImageList imagelist = null; Image image = event.image; + hwndDrag = null; + topControl = null; if (image !is null) { imagelist = new ImageList(DWT.NONE); imagelist.add(image); topControl = control.getShell(); - OS.ImageList_BeginDrag(imagelist.getHandle(), 0, 0, 0); - Point location = topControl.getLocation(); + /* + * Bug in Windows. The image is inverted if the shell is RIGHT_TO_LEFT. + * The fix is to create a transparent window that covers the shell client + * area and use it during the drag to prevent the image from being inverted. + * On XP if the shell is RTL, the image is not displayed. + */ + int offset = 0; + hwndDrag = topControl.handle; + if ((topControl.getStyle() & DWT.RIGHT_TO_LEFT) !is 0) { + offset = image.getBounds().width; + RECT rect; + OS.GetClientRect (topControl.handle, &rect); + hwndDrag = OS.CreateWindowEx ( + OS.WS_EX_TRANSPARENT | OS.WS_EX_NOINHERITLAYOUT, + WindowClass.ptr, + null, + OS.WS_CHILD | OS.WS_CLIPSIBLINGS, + 0, 0, + rect.right - rect.left, rect.bottom - rect.top, + topControl.handle, + null, + OS.GetModuleHandle (null), + null); + OS.ShowWindow (hwndDrag, OS.SW_SHOW); + } + OS.ImageList_BeginDrag(imagelist.getHandle(), 0, offset, 0); /* * Feature in Windows. When ImageList_DragEnter() is called, * it takes a snapshot of the screen If a drag is started @@ -323,16 +351,29 @@ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; OS.RedrawWindow (topControl.handle, null, null, flags); } - OS.ImageList_DragEnter(topControl.handle, dragEvent.x - location.x, dragEvent.y - location.y); + POINT pt; + pt.x = dragEvent.x; + pt.y = dragEvent.y; + OS.MapWindowPoints (control.handle, null, &pt, 1); + RECT rect; + OS.GetWindowRect (hwndDrag, &rect); + OS.ImageList_DragEnter(hwndDrag, pt.x - rect.left, pt.y - rect.top); } - int result = COM.DoDragDrop(iDataObject, iDropSource, operations, pdwEffect.ptr); - if (imagelist !is null) { - OS.ImageList_DragLeave(topControl.handle); - OS.ImageList_EndDrag(); - imagelist.dispose(); - topControl = null; + int result = COM.DRAGDROP_S_CANCEL; + try { + result = COM.DoDragDrop(iDataObject, iDropSource, operations, pdwEffect.ptr); + } finally { + // ensure that we don't leave transparent window around + if (hwndDrag !is null) { + OS.ImageList_DragLeave(hwndDrag); + OS.ImageList_EndDrag(); + imagelist.dispose(); + if (hwndDrag !is topControl.handle) OS.DestroyWindow(hwndDrag); + hwndDrag = null; + topControl = null; + } + display.setData(key, oldValue); } - display.setData(key, oldValue); int operation = osToOp(pdwEffect[0]); if (dataEffect is DND.DROP_MOVE) { operation = (operation is DND.DROP_NONE || operation is DND.DROP_COPY) ? DND.DROP_TARGET_MOVE : DND.DROP_MOVE; @@ -459,8 +500,9 @@ } package .LRESULT QueryContinueDrag(int fEscapePressed, DWORD grfKeyState) { + if (topControl !is null && topControl.isDisposed()) return COM.DRAGDROP_S_CANCEL; if (fEscapePressed !is 0){ - if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); + if (hwndDrag !is null) OS.ImageList_DragLeave(hwndDrag); return COM.DRAGDROP_S_CANCEL; } /* @@ -472,15 +514,16 @@ int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON; // if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2; if ((grfKeyState & mask) is 0) { - if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); + if (hwndDrag !is null) OS.ImageList_DragLeave(hwndDrag); return COM.DRAGDROP_S_DROP; } - if (topControl !is null) { - Display display = getDisplay(); - Point pt = display.getCursorLocation(); - Point location = topControl.getLocation(); - OS.ImageList_DragMove(pt.x - location.x, pt.y - location.y); + if (hwndDrag !is null) { + POINT pt; + OS.GetCursorPos (&pt); + RECT rect; + OS.GetWindowRect (hwndDrag, &rect); + OS.ImageList_DragMove (pt.x - rect.left, pt.y - rect.top); } return COM.S_OK; } diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/dnd/TableDragSourceEffect.d --- a/dwt/dnd/TableDragSourceEffect.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/dnd/TableDragSourceEffect.d Wed Mar 19 21:48:31 2008 +0100 @@ -99,6 +99,11 @@ } auto hDC = OS.GetDC(null); auto hDC1 = OS.CreateCompatibleDC(hDC); + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { + if ((table.getStyle() & DWT.RIGHT_TO_LEFT) !is 0) { + OS.SetLayout(hDC1, OS.LAYOUT_RTL | OS.LAYOUT_BITMAPORIENTATIONPRESERVED); + } + } auto bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); auto hOldBitmap = OS.SelectObject(hDC1, bitmap); RECT rect; diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/dnd/TreeDragSourceEffect.d --- a/dwt/dnd/TreeDragSourceEffect.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/dnd/TreeDragSourceEffect.d Wed Mar 19 21:48:31 2008 +0100 @@ -96,7 +96,7 @@ for (int i = 1; i < count; i++) { bounds = bounds.makeUnion(selection[i].getBounds(0)); } - auto hDC = OS.GetDC(null); + auto hDC = OS.GetDC(tree.handle); auto hDC1 = OS.CreateCompatibleDC(hDC); auto bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); auto hOldBitmap = OS.SelectObject(hDC1, bitmap); @@ -114,7 +114,7 @@ } OS.SelectObject(hDC1, hOldBitmap); OS.DeleteDC (hDC1); - OS.ReleaseDC (null, hDC); + OS.ReleaseDC (tree.handle, hDC); Display display = tree.getDisplay(); dragSourceImage = Image.win32_new(display, DWT.BITMAP, bitmap); return dragSourceImage; diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/dwthelper/utils.d Wed Mar 19 21:48:31 2008 +0100 @@ -10,7 +10,7 @@ import tango.io.Stdout; import tango.stdc.stringz; -import tango.text.Util; +static import tango.text.Util; import tango.text.Unicode; import tango.text.convert.Utf; import tango.core.Exception; diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/graphics/GC.d --- a/dwt/graphics/GC.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/graphics/GC.d Wed Mar 19 21:48:31 2008 +0100 @@ -3714,10 +3714,10 @@ } data.state &= ~(NULL_BRUSH | NULL_PEN); auto hFont = data.hFont; - if (hFont !is null) { + if (hFont !is null && hFont !is cast(HFONT)-1 ) { data.state &= ~FONT; } else { - hFont = OS.GetCurrentObject(hDC, OS.OBJ_FONT); + data.hFont = OS.GetCurrentObject(hDC, OS.OBJ_FONT); } auto hPalette = data.device.hPalette; if (hPalette !is null) { diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/internal/Library.d --- a/dwt/internal/Library.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/internal/Library.d Wed Mar 19 21:48:31 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * 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 @@ -33,7 +33,7 @@ /** * DWT Minor version number (must be in the range 0..999) */ - static const int MINOR_VERSION = 346; + static const int MINOR_VERSION = 349; /** * DWT revision number (must be >= 0) diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/internal/win32/OS.d --- a/dwt/internal/win32/OS.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/internal/win32/OS.d Wed Mar 19 21:48:31 2008 +0100 @@ -1040,6 +1040,7 @@ public static const int LANG_NEUTRAL = 0x0; public static const int LANG_USER_DEFAULT = 1 << 10; public static const int LAYOUT_RTL = 0x1; + public static const int LAYOUT_BITMAPORIENTATIONPRESERVED = 0x8; public static const int LBN_DBLCLK = 0x2; public static const int LBN_SELCHANGE = 0x1; public static const int LBS_EXTENDEDSEL = 0x800; diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/widgets/Decorations.d --- a/dwt/widgets/Decorations.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/widgets/Decorations.d Wed Mar 19 21:48:31 2008 +0100 @@ -445,22 +445,6 @@ setParent (); setSystemMenu (); } - /* - * Set the default icon for the shell to IDI_APPLICATION. - * This is not necessary for native applications but later - * versions of Java set the icon in javaw.exe instead of - * leaving the default. - * - * NOTE: The icon is not leaked. It is shared within - * the process by all threads and is released when the - * process exits. - */ - if ((state & FOREIGN_HANDLE) is 0) { - static if (!OS.IsWinCE) { - auto hIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); - OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hIcon); - } - } } override void createWidget () { @@ -1028,20 +1012,6 @@ break; default: } - } else { - /* - * Set the default icon for the shell to IDI_APPLICATION. - * This is not necessary for native applications but later - * versions of Java set the icon in javaw.exe instead of - * leaving the default. - * - * NOTE: The icon is not leaked. It is shared within - * the process by all threads and is released when the - * process exits. - */ - if ((state & FOREIGN_HANDLE) is 0) { - hSmallIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); - } } OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hSmallIcon); if (largeIcon !is null) { diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/widgets/Synchronizer.d --- a/dwt/widgets/Synchronizer.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/widgets/Synchronizer.d Wed Mar 19 21:48:31 2008 +0100 @@ -46,6 +46,9 @@ Object messageLock; Thread syncThread; + //TEMPORARY CODE + static final bool IS_CARBON = false;//"carbon".equals (DWT.getPlatform ()); + /** * Constructs a new instance of this class. * @@ -84,8 +87,11 @@ */ public void asyncExec (Runnable runnable) { if (runnable is null) { - display.wake (); - return; + //TEMPORARY CODE + if (!IS_CARBON) { + display.wake (); + return; + } } addLast (new RunnableLock (runnable)); } diff -r d0bbd290530f -r 3afcd4ddcf90 dwt/widgets/TableColumn.d --- a/dwt/widgets/TableColumn.d Mon Mar 17 21:47:05 2008 +0100 +++ b/dwt/widgets/TableColumn.d Wed Mar 19 21:48:31 2008 +0100 @@ -561,7 +561,7 @@ style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER); auto hwnd = parent.handle; LVCOLUMN lvColumn; - lvColumn.mask = OS.LVCF_FMT | OS.LVCF_IMAGE; + lvColumn.mask = OS.LVCF_FMT; OS.SendMessage (hwnd, OS.LVM_GETCOLUMN, index, &lvColumn); lvColumn.fmt &= ~OS.LVCFMT_JUSTIFYMASK; int fmt = 0;