Index: MenuItem.java =================================================================== RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java,v retrieving revision 1.73 diff -u -r1.73 MenuItem.java --- MenuItem.java 25 Apr 2005 14:09:12 -0000 1.73 +++ MenuItem.java 12 May 2005 23:40:37 -0000 @@ -303,42 +303,28 @@ if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0); int index = parent.indexOf (this); if (index == -1) return new Rectangle (0, 0, 0, 0); - if ((parent.style & SWT.BAR) != 0) { - Decorations shell = parent.parent; - if (shell.menuBar != parent) { - return new Rectangle (0, 0, 0, 0); - } - int hwndShell = shell.handle; - MENUBARINFO info1 = new MENUBARINFO (); - info1.cbSize = MENUBARINFO.sizeof; - if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, info1)) { - return new Rectangle (0, 0, 0, 0); - } - MENUBARINFO info2 = new MENUBARINFO (); - info2.cbSize = MENUBARINFO.sizeof; - if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, info2)) { - return new Rectangle (0, 0, 0, 0); - } - int x = info2.left - info1.left; - int y = info2.top - info1.top; - int width = info1.right - info1.left; - int height = info1.bottom - info1.top; - return new Rectangle (x, y, width, height); + RECT rect = new RECT(); + boolean success = OS.GetMenuItemRect(((parent.getStyle()&SWT.BAR)==SWT.BAR)?parentControl.handle:0, + parent.handle, + index, + rect); + if (!success) { + /* the OS API call couldn't get the MenuItem bounds, so return an empty rectangle */ + return new Rectangle(0, 0, 0, 0); + } + if ((parentControl.getStyle() & SWT.MIRRORED) == 0) { + /* coordinates are not mirrored */ + Point p = parentControl.toControl(rect.left,rect.top); + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + return new Rectangle(p.x,p.y,width,height); } else { - int hMenu = parent.handle; - RECT rect1 = new RECT (); - if (!OS.GetMenuItemRect (0, hMenu, 0, rect1)) { - return new Rectangle (0, 0, 0, 0); - } - RECT rect2 = new RECT (); - if (!OS.GetMenuItemRect (0, hMenu, index, rect2)) { - return new Rectangle (0, 0, 0, 0); - } - int x = rect2.left - rect1.left + 2; - int y = rect2.top - rect1.top + 2; - int width = rect2.right - rect2.left; - int height = rect2.bottom - rect2.top; - return new Rectangle (x, y, width, height); + /* coordinates are mirrored */ + /* TODO: this has not been tested */ + Point p = parentControl.toControl(rect.left,rect.top); + int width = rect.left - rect.right; + int height = rect.bottom - rect.top; + return new Rectangle(p.x,p.y,width,height); } }