Example usage for com.google.gwt.user.client Window getScrollLeft

List of usage examples for com.google.gwt.user.client Window getScrollLeft

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getScrollLeft.

Prototype

public static int getScrollLeft() 

Source Link

Usage

From source file:com.claudiushauptmann.gwt.maps.gxt.client.MarkerGXTController.java

License:Apache License

/**
 * Updates the tip position. This method is called by its base class when
 * the mouse moves and the tip position has to be updated.
 *///from   w ww . j a v  a2 s . co m
@Override
protected void updateTipPosition() {
    if (currentTip != null) {
        int x = mapMenuController.getCurrentMousePosition().getX() + 20;
        int y = mapMenuController.getCurrentMousePosition().getY() + 20;

        int width = currentTip.getWidth();
        int height = currentTip.getHeight();

        if ((x + width) > Window.getClientWidth() + Window.getScrollLeft() - 10) {
            x = mapMenuController.getCurrentMousePosition().getX() - 20 - width;
        }
        if ((y + height) > Window.getClientHeight() + Window.getScrollTop() - 10) {
            y = mapMenuController.getCurrentMousePosition().getY() - 20 - height;
        }

        currentTip.setPosition(x, y);
    }
}

From source file:com.google.appinventor.client.widgets.properties.AdditionalChoicePropertyEditor.java

License:Open Source License

/**
 * Opens the additional choice dialog.//  w ww .ja  va 2  s  .  c  o m
 */
protected void openAdditionalChoiceDialog() {
    popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            // adjust the x and y positions so that the entire panel
            // is on-screen
            int xPosition = getAbsoluteLeft();
            int yPosition = getAbsoluteTop();
            int xExtrude = xPosition + offsetWidth - Window.getClientWidth() - Window.getScrollLeft();
            int yExtrude = yPosition + offsetHeight - Window.getClientHeight() - Window.getScrollTop();
            if (xExtrude > 0) {
                xPosition -= (xExtrude + ADDITIONAL_CHOICE_ONSCREEN_PADDING);
            }
            if (yExtrude > 0) {
                yPosition -= (yExtrude + ADDITIONAL_CHOICE_ONSCREEN_PADDING);
            }
            popup.setPopupPosition(xPosition, yPosition);
        }
    });
}

From source file:com.google.code.p.gwtchismes.client.GWTCDatePickerAbstract.java

License:Apache License

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);/* w w w  .j a v a 2s . c om*/
        }

        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);
    }
}

From source file:com.google.gerrit.client.change.RightSidePopdownAction.java

License:Apache License

void show() {
    if (popup != null) {
        button.removeStyleName(style.selected());
        popup.hide();//ww  w . j  av  a2s.c om
        return;
    }

    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);
        }
    };
    p.setStyleName(style.replyBox());
    p.addAutoHidePartner(button.getElement());
    p.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            if (popup == p) {
                button.removeStyleName(style.selected());
                popup = null;
            }
        }
    });
    p.add(getWidget());
    p.showRelativeTo(relativeTo);
    GlobalKey.dialog(p);
    button.addStyleName(style.selected());
    popup = p;
}

From source file:com.google.gerrit.client.ErrorDialog.java

License:Apache License

protected ErrorDialog() {
    super(/* auto hide */false, /* modal */true);
    setGlassEnabled(true);//from   w ww.j  ava  2 s. c om
    getGlassElement().addClassName(Gerrit.RESOURCES.css().errorDialogGlass());

    text = new Label();
    text.setStyleName(Gerrit.RESOURCES.css().errorDialogTitle());

    body = new FlowPanel();

    final FlowPanel buttons = new FlowPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().errorDialogButtons());

    closey = new Button();
    closey.setText(Gerrit.C.errorDialogContinue());
    closey.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });
    closey.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            // if the close button is triggered by a key we need to consume the key
            // event, otherwise the key event would be propagated to the parent
            // screen and eventually trigger some unwanted action there after the
            // error dialog was closed
            event.stopPropagation();
        }
    });
    buttons.add(closey);

    final FlowPanel center = new FlowPanel();
    center.add(text);
    center.add(body);
    center.add(buttons);

    setText(Gerrit.C.errorDialogTitle());
    addStyleName(Gerrit.RESOURCES.css().errorDialog());
    add(center);

    int l = Window.getScrollLeft() + 20;
    int t = Window.getScrollTop() + 20;
    setPopupPosition(l, t);
}

From source file:com.google.gerrit.client.patches.PatchBrowserPopup.java

License:Apache License

@Override
public void setPosition(final int myWidth, int myHeight) {
    final int dLeft = (Window.getClientWidth() - myWidth) >> 1;
    final int cHeight = Window.getClientHeight();
    final int cHeight2 = 2 * cHeight / 3;
    final int sLeft = Window.getScrollLeft();
    final int sTop = Window.getScrollTop();

    if (myHeight > cHeight2) {
        sp.setHeight((cHeight2 - 50) + "px");
        myHeight = getOffsetHeight();//w  w  w. j  av a 2s.co  m
    }
    setPopupPosition(sLeft + dLeft, (sTop + cHeight) - (myHeight + 10));
}

From source file:com.google.livingstories.client.ui.AnchoredPanel.java

License:Apache License

public void reposition() {
    Widget content = getWidget();/*from ww  w. j  a v a  2s. co  m*/
    Element boundingBox = getElement().getParentElement();
    int windowTop = Window.getScrollTop();
    int windowLeft = Window.getScrollLeft();
    int topBound = boundingBox.getAbsoluteTop();
    int bottomBound = topBound + boundingBox.getOffsetHeight() - content.getOffsetHeight();
    if (!scrolling) {
        if (windowTop > topBound && windowTop < bottomBound) {
            scrolling = true;
            Style style = content.getElement().getStyle();
            style.setProperty("position", "fixed");
            style.setPropertyPx("top", 0);
            style.setPropertyPx("left", boundingBox.getAbsoluteLeft() - windowLeft);
        }
    } else {
        if (windowTop < topBound) {
            scrolling = false;
            Style style = content.getElement().getStyle();
            style.setProperty("position", "relative");
            style.setPropertyPx("top", 0);
            style.setPropertyPx("left", 0);
        } else if (windowTop > bottomBound) {
            scrolling = false;
            Style style = content.getElement().getStyle();
            style.setProperty("position", "relative");
            // Can't use bottom:0px here because the spacer has no height.
            // Even if we set the spacer's height to be 100%, it won't necessarily
            // work if this panel is in a table cell.
            style.setPropertyPx("top", bottomBound - topBound);
            style.setPropertyPx("left", 0);
        } else {
            content.getElement().getStyle().setPropertyPx("left", boundingBox.getAbsoluteLeft() - windowLeft);
        }
    }
}

From source file:com.google.livingstories.client.ui.Lightbox.java

License:Apache License

/**
 * Reimplementation of center() that does not allow the popup to extend above or to the left
 * of the current scroll position./*from  w  w w . j a v  a2  s .  c  om*/
 */
@Override
public void center() {
    setPopupPositionAndShow(new PositionCallback() {
        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            int left = Math.max(0, (Window.getClientWidth() - getOffsetWidth()) / 2);
            int top = Math.max(0, (Window.getClientHeight() - getOffsetHeight()) / 2);
            setPopupPosition(Window.getScrollLeft() + left, Window.getScrollTop() + top);
        }
    });
}

From source file:com.google.livingstories.client.ui.Slideshow.java

License:Apache License

private void showFilmstrip() {
    if (allImages.size() > 1) {
        filmstripPopup.setPopupPositionAndShow(new PositionCallback() {
            @Override//from w w w .  j a  v  a 2 s. co m
            public void setPosition(int offsetWidth, int offsetHeight) {
                filmstripPopup.setPopupPosition(
                        Window.getScrollLeft() + (Window.getClientWidth() - offsetWidth) / 2,
                        Window.getScrollTop() + (Window.getClientHeight() - offsetHeight));
            }
        });
    }
}

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 av  a 2 s .  c o m
        public void setPosition(int offsetWidth, int offsetHeight) {
            popup.setPopupPosition(Window.getScrollLeft() + (Window.getClientWidth() - offsetWidth) / 2,
                    Window.getScrollTop() + (Window.getClientHeight() - offsetHeight) / 2 - WINDOW_PADDING / 4);
        }
    });
}