View | Details | Raw Unified | Return to bug 38436 | Differences between
and this patch

Collapse All | Expand All

(-)MenuItem.java (-35 / +21 lines)
Lines 303-344 Link Here
303
	if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0);
303
	if (OS.IsWinCE) return new Rectangle (0, 0, 0, 0);
304
	int index = parent.indexOf (this);
304
	int index = parent.indexOf (this);
305
	if (index == -1) return new Rectangle (0, 0, 0, 0);
305
	if (index == -1) return new Rectangle (0, 0, 0, 0);
306
	if ((parent.style & SWT.BAR) != 0) {
306
	RECT rect = new RECT();
307
		Decorations shell = parent.parent;
307
	boolean success = OS.GetMenuItemRect(((parent.getStyle()&SWT.BAR)==SWT.BAR)?parentControl.handle:0,
308
		if (shell.menuBar != parent) {
308
						parent.handle,
309
			return new Rectangle (0, 0, 0, 0);
309
						index,
310
		}
310
						rect);
311
		int hwndShell = shell.handle;
311
	if (!success) {
312
		MENUBARINFO info1 = new MENUBARINFO ();
312
		/* the OS API call couldn't get the MenuItem bounds, so return an empty rectangle */
313
		info1.cbSize = MENUBARINFO.sizeof;
313
		return new Rectangle(0, 0, 0, 0);		
314
		if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, info1)) {
314
	}
315
			return new Rectangle (0, 0, 0, 0);
315
	if ((parentControl.getStyle() & SWT.MIRRORED) == 0) {
316
		}
316
		/* coordinates are not mirrored */
317
		MENUBARINFO info2 = new MENUBARINFO ();
317
		Point p = parentControl.toControl(rect.left,rect.top);
318
		info2.cbSize = MENUBARINFO.sizeof;
318
		int width = rect.right - rect.left;
319
		if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, info2)) {
319
		int height = rect.bottom - rect.top;
320
			return new Rectangle (0, 0, 0, 0);
320
		return new Rectangle(p.x,p.y,width,height);   
321
		}
322
		int x = info2.left - info1.left;
323
		int y = info2.top - info1.top;
324
		int width = info1.right - info1.left;
325
		int height = info1.bottom - info1.top;
326
		return new Rectangle (x, y, width, height);
327
	} else {
321
	} else {
328
		int hMenu = parent.handle;
322
		/* coordinates are mirrored */
329
		RECT rect1 = new RECT ();
323
		/* TODO: this has not been tested */
330
		if (!OS.GetMenuItemRect (0, hMenu, 0, rect1)) {
324
		Point p = parentControl.toControl(rect.left,rect.top);
331
			return new Rectangle (0, 0, 0, 0);
325
		int width = rect.left - rect.right;
332
		}
326
		int height = rect.bottom - rect.top;
333
		RECT rect2 = new RECT ();
327
		return new Rectangle(p.x,p.y,width,height);   		
334
		if (!OS.GetMenuItemRect (0, hMenu, index, rect2)) {
335
			return new Rectangle (0, 0, 0, 0);
336
		}
337
		int x = rect2.left - rect1.left + 2;
338
		int y = rect2.top - rect1.top + 2;
339
		int width = rect2.right - rect2.left;
340
		int height = rect2.bottom - rect2.top;
341
		return new Rectangle (x, y, width, height);
342
	}
328
	}
343
}
329
}
344
330

Return to bug 38436