// position the opened menuList...
// Must set absolute coordinates in order to read the coordinates of
// element accurately IE6 bug
final Element menuListElement = menuList.getElement();
final InlineStyle menuListInlineStyle = InlineStyle.getInlineStyle(menuListElement );
final ComputedStyle menuListComputedStyle = ComputedStyle.getComputedStyle(menuListElement );
menuListInlineStyle.setString(Css.POSITION, "absolute");
menuListInlineStyle.setInteger(Css.LEFT, 0, CssUnit.PX);
menuListInlineStyle.setInteger(Css.TOP, 0, CssUnit.PX);
int x = Dom.getContainerLeftOffset(menuListElement);
int y = Dom.getContainerTopOffset(menuListElement);
while (true) {
final MenuListOpenDirection openDirection = menuList.getOpenDirection();
if (MenuListOpenDirection.LEFT == openDirection) {
x = x - menuListComputedStyle.getInteger(Css.WIDTH, CssUnit.PX, 0);
x = x + menuListComputedStyle.getInteger(Css.BORDER_RIGHT_WIDTH, CssUnit.PX, 0);
x++;
y = y - menuListComputedStyle.getInteger(Css.BORDER_TOP_WIDTH, CssUnit.PX, 0);
break;
}
if (MenuListOpenDirection.UP == openDirection) {
x = x - menuListComputedStyle.getInteger(Css.BORDER_LEFT_WIDTH, CssUnit.PX, 0);
y = y - menuListComputedStyle.getInteger(Css.HEIGHT, CssUnit.PX, 0);
y = y + menuListComputedStyle.getInteger(Css.BORDER_BOTTOM_WIDTH, CssUnit.PX, 0);
y--;
break;
}
if (MenuListOpenDirection.RIGHT == openDirection) {
x = x + menuListComputedStyle.getInteger(Css.WIDTH, CssUnit.PX, 0);
x = x - menuListComputedStyle.getInteger(Css.BORDER_LEFT_WIDTH, CssUnit.PX, 0);
x--;
y = y - menuListComputedStyle.getInteger(Css.BORDER_TOP_WIDTH, CssUnit.PX, 0);
break;
}
Checker.same("openDirection", MenuListOpenDirection.DOWN, openDirection);
x = x - menuListComputedStyle.getInteger(Css.BORDER_LEFT_WIDTH, CssUnit.PX, 0);
y = y + menuListComputedStyle.getInteger(Css.HEIGHT, CssUnit.PX, 0); // parentMenuList
y = y - menuListComputedStyle.getInteger(Css.BORDER_TOP_WIDTH, CssUnit.PX, 0);
y--;
break;
}
menuListInlineStyle.setString(Css.POSITION, "absolute");
menuListInlineStyle.setInteger(Css.LEFT, x, CssUnit.PX);
menuListInlineStyle.setInteger(Css.TOP, y, CssUnit.PX);
menuListInlineStyle.setInteger(Css.Z_INDEX, 1, CssUnit.NONE);
// notify listeners
menuList.getMenu().fireMenuOpened(event, this);
}