/* (non-Javadoc) * @see com.google.gwt.user.client.ui.UIObject#addStyleDependentName(java.lang.String) */ @Override public void addStyleDependentName(String s) { if (calendarDlg != null) calendarDlg.addStyleDependentName(s); else outer.addStyleDependentName(s); addStyleToMonthMenu(getStylePrimaryName() + "-" + s); }
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); } }
/* (non-Javadoc) * @see com.google.gwt.user.client.ui.UIObject#addStyleName(java.lang.String) */ @Override public void addStyleName(String s) { if (calendarDlg != null) { calendarDlg.addStyleName(s); } else { outer.addStyleName(s); } addStyleToMonthMenu(s); }
/** 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); }
/* (non-Javadoc) * @see com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String) */ @Override public void setStyleName(String s) { if (calendarDlg != null) calendarDlg.setStyleName(s); else outer.setStyleName(s); monthSelectorHeader.setStyleName(s + "-MenuBar"); monthMenu.setStyleName(s + "-MenuBar"); monthSelectorHeader.addStyleName(s + "-MenuBar-horizontal"); monthMenu.addStyleName(s + "-MenuBar-vertical"); for (int i = 0; i < monthHeaders.size(); i++) { monthHeaders.get(i).setStyleName(StyleMonthLabel); monthHeaders.get(i).addStyleName(s + "-MenuBar"); monthSelectorHeader.addStyleName(s + "-MenuBar-horizontal"); } if (!s.equals(styleName)) { addStyleName(styleName); } }
/** Hide the calendar container. */ public void hide() { if (calendarDlg != null) { calendarDlg.hide(); } else outer.setVisible(false); }
/** * Set the zIndex value. * * @param z */ public void setZIndex(int z) { if (calendarDlg != null) { DOM.setStyleAttribute(calendarDlg.getElement(), "zIndex", String.valueOf(z)); helpDlg.setZIndex(z + 1); } }
/* (non-Javadoc) * @see com.google.gwt.user.client.ui.UIObject#getElement() */ @Override public Element getElement() { return calendarDlg != null ? calendarDlg.getElement() : outer.getElement(); }
/* (non-Javadoc) * @see com.google.gwt.user.client.ui.UIObject#getStylePrimaryName() */ @Override public String getStylePrimaryName() { return calendarDlg != null ? calendarDlg.getStylePrimaryName() : outer.getStylePrimaryName(); }
/** * Set the text for the caption of the dialog box. It is only available if the calendar is shown * as a dialog. * * @param t the message to display */ public void setCaptionText(String t) { if (calendarDlg != null) calendarDlg.setText(t); }
/** * Creates the calendar instance based in the configuration provided. * * <p>Options can be passed joining these using the or bit wise operator * * <ul> * <li>CONFIG_DIALOG show as modal dialog * <li>CONFIG_ROUNDED_BOX wrap with a rounded-corner box * <li>CONFIG_NO_AUTOHIDE don't autohide dialog when the user click out of the picker * <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden * <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden * <li>CONFIG_BACKGROUND show a semitransparent background covering all the document * <li>CONFIG_FLAT_BUTTONS use native Buttons instead of GWTCButton also add the dependent class * 'flat' * <li>CONFIG_STANDARD_BUTTONS use native browser Buttons instead of GWTCButton * </ul> */ public void initialize(int config) { int buttonsType = config & CONFIG_FLAT_BUTTONS | config & CONFIG_STANDARD_BUTTONS; helpBtn = createButton(buttonsType, "?", this); closeBtn = createButton(buttonsType, "x", this); todayBtn = createButton(buttonsType, "-", this); prevMBtn = createButton(buttonsType, "\u003c", this); prevYBtn = createButton(buttonsType, "\u00AB", this); nextMBtn = createButton(buttonsType, "\u003e", this); nextYBtn = createButton(buttonsType, "\u00BB", this); if ((config & CONFIG_DIALOG) == CONFIG_DIALOG) { int opt = 0; if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) { opt |= GWTCModalBox.OPTION_ROUNDED_FLAT; } if ((config & CONFIG_BACKGROUND) != CONFIG_BACKGROUND) { opt |= GWTCModalBox.OPTION_DISABLE_BACKGROUND; if ((config & CONFIG_NO_AUTOHIDE) == CONFIG_NO_AUTOHIDE) { opt |= GWTCModalBox.OPTION_DISABLE_AUTOHIDE; } } calendarDlg = new GWTCModalBox(opt); calendarDlg.setAnimationEnabled((config & CONFIG_NO_ANIMATION) != CONFIG_NO_ANIMATION); outer = calendarDlg; initWidget(new DockPanel()); setStyleName(styleName); addStyleDependentName(StyleDialog); setZIndex(999); } else { if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) { outer = new GWTCBox(GWTCBox.STYLE_FLAT); } else { outer = new VerticalPanel(); } String s = outer.getStyleName(); initWidget(outer); setStyleName(styleName); addStyleDependentName(StyleEmbeded); if (s != null && s.length() > 0) addStyleName(s); } helpDlg.addStyleName(StyleHelp); navButtonsTop.setStyleName(StyleCButtonsTop); navButtonsBottom.setStyleName(StyleCButtonsBottom); calendarGrid.setStyleName(StyleMonthGrid); navButtonsTop.setWidth("100%"); calendarGrid.setWidth("100%"); navButtonsBottom.setWidth("100%"); if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) addStyleDependentName(StyleBox); else addStyleDependentName(StyleNoBox); if ((config & CONFIG_DIALOG) != CONFIG_DIALOG) closeBtn.setVisible(false); monthSelectorHeader.setAnimationEnabled(true); outer.add(navButtonsTop); outer.add(calendarGrid); outer.add(navButtonsBottom); drawDatePickerWidget(); refresh(); DOM.sinkEvents(outer.getElement(), Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONCLICK); DOM.setStyleAttribute(outer.getElement(), "cursor", "default"); DOM.setElementAttribute(monthMenu.getElement(), "align", "center"); }