List of usage examples for com.google.gwt.user.client Window getScrollLeft
public static int getScrollLeft()
From source file:com.google.mobile.trippy.web.client.widget.DefaultToast.java
License:Apache License
public void showLoading(String message) { loadingLabel.setText(message);/*from ww w. j a v a 2 s .c om*/ loadingPanel.setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { int left = (Window.getClientWidth() - loadingPanel.getOffsetWidth()) >> 1; int top = 2; loadingPanel.setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Window.getScrollTop() + top); } }); }
From source file:com.googlesource.gerrit.plugins.cookbook.client.PopDownButton.java
License:Apache License
private void show() { if (popup != null) { getElement().getStyle().clearFontWeight(); popup.hide();//from w w w. j av a2s. co m return; } final Widget relativeTo = getParent(); final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; Style popupStyle = p.getElement().getStyle(); popupStyle.setBorderWidth(0, Unit.PX); popupStyle.setBackgroundColor("#EEEEEE"); p.addAutoHidePartner(getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { getElement().getStyle().clearFontWeight(); popup = null; } } }); p.add(widget); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); getElement().getStyle().setFontWeight(FontWeight.BOLD); popup = p; }
From source file:com.gwtplatform.mvp.client.view.CenterPopupPositioner.java
License:Apache License
/** * By default this method centers the popup horizontally. * You can override this method to change the horizontal position of the popup. * @param popupWidth/*from w ww .java2s . com*/ * @return the left position of the popup */ protected int getLeft(int popupWidth) { return ((Window.getClientWidth() - popupWidth) / 2) + Window.getScrollLeft(); }
From source file:com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner.java
License:Apache License
private boolean canFitOnLeftEdge(int popupWidth) { int windowRight = Window.getClientWidth() + Window.getScrollLeft(); return windowRight - popupWidth > widget.getAbsoluteLeft(); }
From source file:com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner.java
License:Apache License
private boolean canFitOnRightEdge(int popupWidth) { return getRightEdge(popupWidth) >= Window.getScrollLeft(); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.tree.CubaTreeWidget.java
License:Apache License
@Override protected void handleBodyContextMenu(ContextMenuEvent event) { if (customContextMenu == null) { super.handleBodyContextMenu(event); } else if (!selectedIds.isEmpty()) { int left = event.getNativeEvent().getClientX(); int top = event.getNativeEvent().getClientY(); top += Window.getScrollTop(); left += Window.getScrollLeft(); showContextMenuPopup(left, top); event.stopPropagation();/*from ww w . j a v a 2s . c o m*/ event.preventDefault(); } }
From source file:com.haulmont.cuba.web.widgets.client.addons.aceeditor.SuggesterConnector.java
License:Apache License
protected void updatePopupPosition(SuggestPopup popup) { int[] coords = widget.getCursorCoords(); int sx = Window.getScrollLeft(); int sy = Window.getScrollTop(); int x = coords[0] - sx; int y = coords[1] - sy + Y_OFFSET; /*//from w w w . j a va 2 s .c om int wx = Window.getClientWidth(); int wy = Window.getClientHeight(); int maxx = wx - SuggestPopup.WIDTH - (showDescriptions ? SuggestPopup.DESCRIPTION_WIDTH : 0); if (x > maxx) { x -= SuggestPopup.WIDTH + (showDescriptions ? SuggestPopup.DESCRIPTION_WIDTH : 0) + 50; } int maxy = wy - SuggestPopup.HEIGHT; if (y > maxy) { y -= SuggestPopup.HEIGHT + 50; } */ popup.setPopupPosition(x, y); }
From source file:com.haulmont.cuba.web.widgets.client.addons.popupbutton.VPopupButton.java
License:Apache License
void showPopup() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { if (position.equals("auto")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); if (direction.isHorizontalCenter()) { left -= (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()) / 2; } else if (direction.isLeft()) { left -= popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth(); }//from w w w .ja v a2 s. c o m int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int browserWindowHeight = Window.getClientHeight() + Window.getScrollTop(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > browserWindowHeight - extra) { top = getPopupPositionWidget().getAbsoluteTop() - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.setVisible(true); } else if (position.equals("fixed")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight() - Window.getScrollTop(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int clientHeight = Window.getClientHeight(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > clientHeight - extra) { top = (getPopupPositionWidget().getAbsoluteTop() - Window.getScrollTop()) - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.addStyleName("fixed"); popup.setVisible(true); } } }); }
From source file:com.lorepo.icplayer.client.module.choice.MyPopupPanel.java
License:Apache License
/** * Centers the popup in the browser window and shows it. If the popup was * already showing, then the popup is centered. *//*w w w.j ava 2s. co m*/ public void center() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false); setAnimationEnabled(false); show(); } int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; int top = (Window.getClientHeight() - getOffsetHeight()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); // Run the animation. The popup is already visible, so we can skip the // call to setState. if (initiallyAnimated) { impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)"); setVisible(true); resizeAnimation.run(ANIMATION_DURATION); } else { setVisible(true); } } }
From source file:com.lorepo.icplayer.client.module.choice.MyPopupPanel.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the popup * are known./*from w w w .j a va 2s . c o m*/ * * @param relativeObject the ui object to position relative to * @param offsetWidth the drop down's offset width * @param offsetHeight the drop down's offset height */ private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space for the // overflow to the right of the text box, then left-align the popup. // However, if there is not enough space on either side, stick with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space for the // overflow to the left of the text box, then right-align the popup. // However, if there is not enough space on either side, then stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then then position the popup above the text box. However, if there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }