List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:com.google.livingstories.client.ui.Slideshow.java
License:Apache License
private void showPopup() { popup.setPopupPositionAndShow(new PositionCallback() { @Override//from ww w . j a v a2 s .c om public void setPosition(int offsetWidth, int offsetHeight) { popup.setPopupPosition(Window.getScrollLeft() + (Window.getClientWidth() - offsetWidth) / 2, Window.getScrollTop() + (Window.getClientHeight() - offsetHeight) / 2 - WINDOW_PADDING / 4); } }); }
From source file:com.google.mobile.trippy.web.client.widget.DefaultToast.java
License:Apache License
public void showLoading(String message) { loadingLabel.setText(message);/* w ww . 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.google.webcourse.picasaapp.client.PicasaApp.java
License:Apache License
/** * Causes the UI elements to be layed out. *//*from w w w .j a va2 s . c o m*/ public void onResize(ResizeEvent event) { int height = Window.getClientHeight() - thumbnailList.getAbsoluteTop(); thumbnailList.setHeight((height + Window.getScrollTop()) - 5 + "px"); int photoWidth = Window.getClientWidth() - SIDE_COLUMNS_WIDTH_SUM; photoView.setPhotoWidth(photoWidth); }
From source file:com.gwtplatform.mvp.client.view.CenterPopupPositioner.java
License:Apache License
/** * By default this method centers the popup vertically. * You can override this method to change the vertical position of the popup. * @param popupHeight/*from www . ja v a2 s. c o m*/ * @return the top position of the popup. */ protected int getTop(int popupHeight) { return ((Window.getClientHeight() - popupHeight) / 2) + Window.getScrollTop(); }
From source file:com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner.java
License:Apache License
@Override protected int getTop(int popupHeight) { int top = widget.getAbsoluteTop(); int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); int distanceFromWindowTop = top - windowTop; int distanceToWindowBottom = windowBottom - (top + widget.getOffsetHeight()); if (distanceToWindowBottom < popupHeight && distanceFromWindowTop >= popupHeight) { top -= popupHeight;//from ww w . j av a 2 s . c o m } else { top += widget.getOffsetHeight(); } return top; }
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();// w w w.java 2 s .c om 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 av a2 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 .j av a 2 s. co 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. *///ww w . ja v a 2 s . c om 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.// w w w.j a va 2 s . 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); }