Mercurial > projects > dwt-win
diff dwt/widgets/Menu.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | fd9c62a2998e |
line wrap: on
line diff
--- a/dwt/widgets/Menu.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Menu.d Sat May 17 17:34:28 2008 +0200 @@ -89,6 +89,11 @@ * Constructs a new instance of this class given its parent, * and sets the style for the instance so that the instance * will be a popup menu on the given parent's shell. + * <p> + * After constructing a menu, it can be set into its parent + * using <code>parent.setMenu(menu)</code>. In this case, the parent may + * be any control in the same widget tree as the parent. + * </p> * * @param parent a control which will be the parent of the new instance (cannot be null) * @@ -120,6 +125,9 @@ * of those <code>DWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. + * </p><p> + * After constructing a menu or menuBar, it can be set into its parent + * using <code>parent.setMenu(menu)</code> or <code>parent.setMenuBar(menuBar)</code>. * </p> * * @param parent a decorations control which will be the parent of the new instance (cannot be null) @@ -148,6 +156,10 @@ * (which must be a <code>Menu</code>) and sets the style * for the instance so that the instance will be a drop-down * menu on the given parent's parent. + * <p> + * After constructing a drop-down menu, it can be set into its parentMenu + * using <code>parentMenu.setMenu(menu)</code>. + * </p> * * @param parentMenu a menu which will be the parent of the new instance (cannot be null) * @@ -172,6 +184,10 @@ * (which must be a <code>MenuItem</code>) and sets the style * for the instance so that the instance will be a drop-down * menu on the given parent's parent menu. + * <p> + * After constructing a drop-down menu, it can be set into its parentItem + * using <code>parentItem.setMenu(menu)</code>. + * </p> * * @param parentItem a menu item which will be the parent of the new instance (cannot be null) * @@ -227,8 +243,8 @@ int nX = x, nY = y; if (!hasLocation) { int pos = OS.GetMessagePos (); - nX = cast(short) (pos & 0xFFFF); - nY = cast(short) (pos >> 16); + nX = OS.GET_X_LPARAM (pos); + nY = OS.GET_Y_LPARAM (pos); } /* * Feature in Windows. It is legal use TrackPopupMenu() @@ -238,14 +254,14 @@ * that the menu has been closed. This is not strictly a * bug but leads to unwanted behavior when application code * assumes that every WM_INITPOPUPMENU will eventually result - * in a WM_MENUSELECT, wParam=0xFFFF0000, lParam=0 to indicate - * that the menu has been closed. The fix is to detect the - * case when TrackPopupMenu() fails and the number of items in + * in a WM_MENUSELECT, wParam=MAKEWPARAM (0, 0xFFFF), lParam=0 to + * indicate that the menu has been closed. The fix is to detect + * the case when TrackPopupMenu() fails and the number of items in * the menu is zero and issue a fake WM_MENUSELECT. */ bool success = cast(bool) OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null); if (!success && GetMenuItemCount (handle) is 0) { - OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0); + OS.SendMessage (hwndParent, OS.WM_MENUSELECT, OS.MAKEWPARAM (0, 0xFFFF), 0); } } else { OS.SendMessage (hwndParent, OS.WM_CANCELMODE, 0, 0); @@ -385,7 +401,7 @@ /* Set first item */ if (nToolBarId is ID_SPMM || nToolBarId is ID_SPMB) { - int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY0); + int /*long*/ hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY0); /* Remove the item from the resource file */ OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION); Menu menu = new Menu (parent, DWT.DROP_DOWN, hMenu); @@ -398,7 +414,7 @@ /* Set second item */ if (nToolBarId is ID_SPMM || nToolBarId is ID_SPBM) { - int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY1); + int /*long*/ hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY1); OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION); Menu menu = new Menu (parent, DWT.DROP_DOWN, hMenu); item = new MenuItem (this, menu, DWT.CASCADE, 1); @@ -414,7 +430,7 @@ * a result, Shell on WinCE SP must use the class Dialog. */ int dwMask = OS.SHMBOF_NODEFAULT | OS.SHMBOF_NOTIFY; - int lParam = dwMask << 16 | dwMask; + int /*long*/ lParam = OS.MAKELPARAM (dwMask, dwMask); OS.SendMessage (hwndCB, OS.SHCMBM_OVERRIDEKEY, OS.VK_ESCAPE, lParam); return; } @@ -493,7 +509,8 @@ MENUITEMINFO info; info.cbSize = MENUITEMINFO.sizeof; info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; - info.wID = info.dwItemData = item.id; + info.wID = item.id; + info.dwItemData = item.id; info.fType = item.widgetStyle (); info.dwTypeData = pszText; success = cast(bool) OS.InsertMenuItem (handle, index, true, &info); @@ -583,6 +600,7 @@ } override void destroyWidget () { + MenuItem cascade = this.cascade; HMENU hMenu = handle; HWND hCB = hwndCB; releaseHandle (); @@ -591,7 +609,11 @@ OS.CommandBar_Destroy (hCB); } } else { - if (hMenu !is null) OS.DestroyMenu (hMenu); + if (cascade !is null) { + if (!OS.IsSP) cascade.setMenu (null, true); + } else { + if (hMenu !is null) OS.DestroyMenu (hMenu); + } } } @@ -1116,7 +1138,7 @@ override void releaseHandle () { super.releaseHandle (); handle = null; - hwndCB = null; + cascade = null; } override void releaseChildren (bool destroy) { @@ -1136,7 +1158,6 @@ override void releaseParent () { super.releaseParent (); - if (cascade !is null) cascade.releaseMenu (); if ((style & DWT.BAR) !is 0) { display.removeBar (this); if (this is parent.menuBar) { @@ -1163,7 +1184,6 @@ } if (parent !is null) parent.removeMenu (this); parent = null; - cascade = null; } /**