private void moveIntoVisibleArea() { if (calendarDlg != null) { int w = Window.getClientWidth() + Window.getScrollLeft(); int xd = calendarDlg.getAbsoluteLeft(); int wd = calendarGrid.getOffsetWidth() + 40; if ((xd + wd) > w) { xd = xd - ((xd + wd) - w); } int h = Window.getClientHeight() + Window.getScrollTop(); int yd = calendarDlg.getAbsoluteTop(); int hd = calendarDlg.getOffsetHeight() + 20; if ((yd + hd) > h) { yd = yd - ((yd + hd) - h); } calendarDlg.setPopupPosition(xd, yd); } }
/** Show the calendar container, and positione it in the provided coordinates. */ public void show(int left, int top) { if (needsRedraw) refresh(); if (calendarDlg == null) { assert outer.isAttached() : "Calendar has not been attached, even though it is not configured as a popup."; outer.setVisible(true); } else { if (top >= 0 && left >= 0) { calendarDlg.setPopupPosition(left, top); calendarDlg.show(); moveIntoVisibleArea(); DOM.scrollIntoView(calendarGrid.getElement()); } else { calendarDlg.center(); } } todayBtn.setFocus(true); }