From: Tom R. <tl...@us...> - 2005-04-29 23:30:26
|
Update of /cvsroot/abbot/abbot.swt/src/abbot/swt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20013/src/abbot/swt Modified Files: SWTWorkarounds.java Log Message: clearer commenting: JavaProjectTester still works. Index: SWTWorkarounds.java =================================================================== RCS file: /cvsroot/abbot/abbot.swt/src/abbot/swt/SWTWorkarounds.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SWTWorkarounds.java 29 Apr 2005 20:22:37 -0000 1.2 --- SWTWorkarounds.java 29 Apr 2005 23:30:15 -0000 1.3 *************** *** 44,100 **** */ public static Rectangle getBounds (MenuItem menuItem) { ! /*// menuItem.getParent() calls checkWidget() on itself. ! //checkWidget (); ! Menu parent = menuItem.getParent(); ! if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0); ! int index = parent.indexOf (menuItem); ! if (index == -1) return new Rectangle (0, 0, 0, 0); ! if ((parent.getStyle() & SWT.BAR) != 0) { ! Decorations shell = parent.getParent(); ! if (shell.getMenuBar() != 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; ! //y *= 0.01; // trying to fix menu problem ! int width = info1.right - info1.left; ! int height = info1.bottom - info1.top; ! //height *= 0.2; // trying to fix menu problem ! return new Rectangle (x, 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); ! } ! */ ! //checkWidget(); Menu parent = menuItem.getParent(); Decorations parentControl = parent.getParent(); int index = parent.indexOf (menuItem); if (index == -1) return new Rectangle (0, 0, 0, 0); RECT rect = new RECT(); ! boolean success = OS.GetMenuItemRect( ((parent.getStyle()&SWT.BAR)==SWT.BAR)?parentControl.handle:0, parent.handle, index, --- 44,99 ---- */ public static Rectangle getBounds (MenuItem menuItem) { ! // start code from (Northover via?) GJ: fails with JavaProjectTester ! // // menuItem.getParent() calls checkWidget() on itself. ! // //checkWidget (); Menu parent = menuItem.getParent(); + // if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0); + // int index = parent.indexOf (menuItem); + // if (index == -1) return new Rectangle (0, 0, 0, 0); + // if ((parent.getStyle() & SWT.BAR) != 0) { + // Decorations shell = parent.getParent(); + // if (shell.getMenuBar() != 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); + // } 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); + // } + // end code from (Northover via?) GJ: fails with JavaProjectTester + // start code adapted from o.e.swt.patched.MenuItem.getBounds(): works for JavaProjectTester Decorations parentControl = parent.getParent(); + if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0); int index = parent.indexOf (menuItem); if (index == -1) return new Rectangle (0, 0, 0, 0); RECT rect = new RECT(); ! boolean success = OS.GetMenuItemRect(((parent.getStyle()&SWT.BAR)==SWT.BAR)?parentControl.handle:0, parent.handle, index, *************** *** 119,123 **** } } - /** --- 118,121 ---- |