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

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

Introduction

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

Prototype

public static int getClientHeight() 

Source Link

Usage

From source file:asquare.gwt.debug.client.DebugConsole.java

License:Apache License

/**
 * Creates the console, installs the enabler key listener. 
 * The console is not yet attached to the DOM. 
 *///from ww w .j  ava2 s .c  o  m
protected DebugConsole() {
    super(false, false);
    setStyleName("tk-DebugConsole");
    DOM.setStyleAttribute(getElement(), "border", "solid black 1px");
    DOM.setStyleAttribute(getElement(), "background", "white");

    setHTML("<div style='margin: 2px; padding: 3px; background-color: rgb(195, 217, 255); font-weight: bold; font-size: smaller; cursor: default;'>Debug Console</div>");

    m_content.setWordWrap(false);
    DOM.setStyleAttribute(m_content.getElement(), "margin", "2px");
    DOM.setStyleAttribute(m_content.getElement(), "padding", "3px");

    VerticalPanel outer = new VerticalPanel();

    ScrollPanel scrollPanel = new ScrollPanel(m_content);
    scrollPanel.setAlwaysShowScrollBars(true);
    scrollPanel.setSize("40em", "20em");
    outer.add(scrollPanel);

    HorizontalPanel controls = new HorizontalPanel();
    DOM.setStyleAttribute(controls.getElement(), "margin", "2px");
    controls.setWidth("100%");
    outer.add(controls);

    HorizontalPanel controlsLeft = new HorizontalPanel();
    controls.add(controlsLeft);
    controls.setCellHorizontalAlignment(controlsLeft, HorizontalPanel.ALIGN_LEFT);

    HorizontalPanel controlsRight = new HorizontalPanel();
    controls.add(controlsRight);
    controls.setCellHorizontalAlignment(controlsRight, HorizontalPanel.ALIGN_RIGHT);

    final Button toggleDebugButton = new Button("Toggle&nbsp;Debug");
    DOM.setElementProperty(toggleDebugButton.getElement(), "title", "Toggles output of debug statements");
    controlsLeft.add(toggleDebugButton);

    updateDisableButtonText();
    DOM.setElementProperty(m_disableButton.getElement(), "title",
            "Prevents this console from appearing when debug statements are printed");
    controlsLeft.add(m_disableButton);

    final Button clearButton = new Button("Clear");
    DOM.setElementProperty(clearButton.getElement(), "title", "Clears all messages in the console");
    controlsRight.add(clearButton);

    final Button hideButton = new Button("Hide");
    DOM.setStyleAttribute(hideButton.getElement(), "textAlign", "right");
    controlsRight.add(hideButton);

    setWidget(outer);
    m_left = Window.getClientWidth() / 2 - 640 / 2;
    m_top = Window.getClientHeight() / 2;

    m_enabler.install();

    ClickHandler handler = new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (sender == clearButton) {
                clearMessages();
            } else if (sender == hideButton) {
                hide();
            } else if (sender == m_disableButton) {
                disable();
            } else if (sender == toggleDebugButton) {
                if (Debug.isEnabled()) {
                    Debug.disable();
                } else {
                    Debug.enable();
                }
            } else {
                assert false;
            }
        }
    };
    toggleDebugButton.addClickHandler(handler);
    m_disableButton.addClickHandler(handler);
    clearButton.addClickHandler(handler);
    hideButton.addClickHandler(handler);

    sinkEvents(Event.ONMOUSEDOWN);
    preventSelectionInIE(getElement());
}

From source file:au.com.gworks.gwt.petstore.client.AccountSignInController.java

License:Apache License

public void showView() {
    int xPos = (Window.getClientWidth() / 3);
    int yPos = (Window.getClientHeight() / 3);

    view.setPopupPosition(xPos, yPos);// w  w  w  .ja  va 2s.  c  om
    view.clearForm();
    view.show();
}

From source file:bufferings.ktr.wjr.client.ui.WjrPopupPanel.java

License:Apache License

/**
 * Adjusts the position of the panel.//w  w w.ja v  a  2 s.  c o  m
 */
private void adjustPosition() {
    int left = 13;
    int top = (Window.getClientHeight() - 48);

    left += Window.getScrollLeft();
    top += Window.getScrollTop();

    getElement().getStyle().setPropertyPx("left", left);
    getElement().getStyle().setPropertyPx("top", top);
}

From source file:burrito.client.Burrito.java

License:Apache License

private static void updateEditFormButtons() {
    if (currentEditForm != null) {
        int bottomOfWindow = Window.getClientHeight() + Window.getScrollTop();
        int bottomOfEditForm = currentEditForm.getAbsoluteTop() + currentEditForm.getOffsetHeight();
        if (bottomOfEditForm > bottomOfWindow) {
            currentEditForm.makeButtonsStick(true);
        } else {/*from  w w w.j ava2  s.c o  m*/
            currentEditForm.makeButtonsStick(false);
        }
    }
}

From source file:ca.wimsc.client.common.widgets.google.TouchHandler.java

License:Apache License

/**
 * Touch move handler.//from w  ww. j a  v  a  2s .  c om
 *
 * @param e The touchmove event.
 */
@SuppressWarnings("unused")
private void onMove(final TouchEvent e) {
    if (!tracking || dragDelegate == null) {
        return;
    }

    // Prevent native scrolling.
    e.preventDefault();

    com.google.gwt.dom.client.Touch touch = getTouchFromEvent(e);
    Point touchCoordinate = new Point(touch.getPageX(), touch.getPageY());

    double moveX = lastTouchPosition.x - touchCoordinate.x;
    double moveY = lastTouchPosition.y - touchCoordinate.y;
    totalMoveX += Math.abs(moveX);
    totalMoveY += Math.abs(moveY);
    lastTouchPosition.x = touchCoordinate.x;
    lastTouchPosition.y = touchCoordinate.y;

    // Handle case where they are getting close to leaving the window.
    // End events are unreliable when the touch is leaving the viewport area.
    // If they are close to the bottom or the right, and we don't get any other
    // touch events for another 100ms, assume they have left the screen. This
    // does not seem to be a problem for scrolling off the top or left of the
    // viewport area.
    if (scrollOffTimer != null) {
        scrollOffTimer.cancel();
    }
    if ((Window.getClientHeight() - touchCoordinate.y) < TOUCH_END_WORKAROUND_THRESHOLD
            || (Window.getClientWidth() - touchCoordinate.x) < TOUCH_END_WORKAROUND_THRESHOLD) {

        scrollOffTimer = new Timer() {
            @Override
            public void run() {
                e.setTimeStamp(Duration.currentTimeMillis());
                onEnd(e);
            }
        };
        scrollOffTimer.schedule(100);
    }

    boolean firstDrag = false;
    if (!dragging) {
        if (totalMoveY > MIN_TRACKING_FOR_DRAG || totalMoveX > MIN_TRACKING_FOR_DRAG) {
            dragging = true;
            firstDrag = true;
            dragDelegate.onDragStart(e);
        }
    }

    if (dragging) {
        dragDelegate.onDragMove(e);

        lastEvent = e;

        // This happens when they are dragging slowly. If they are dragging slowly
        // then we should reset the start time and position to where they are now.
        // This will be important during the drag end when we report to the
        // draggable delegate what kind of drag just happened.
        if (e.getTimeStamp() - recentTime > MAX_TRACKING_TIME) {
            recentTime = e.getTimeStamp();
            recentTouchPosition = touchCoordinate;
        }
    }
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void scrollIntoView(Element elem, int fromTop, boolean forceFromTop) {
    int y1 = Document.get().getBodyOffsetTop() + Window.getScrollTop();
    int y2 = y1 + Window.getClientHeight();
    Element parent = elem.getParentElement();
    int absoluteTop = elem.getAbsoluteTop();
    int offsetHeight = elem.getOffsetHeight();
    int absoluteBottom = absoluteTop + offsetHeight;
    boolean recalcAbsoluteTopAfterScroll = true;
    if (absoluteTop == 0) {
        Text tptCopy = tempPositioningText;
        tempPositioningText = null;/*  ww w.jav a  2 s.  c  o m*/
        Element positioning = WidgetUtils.getElementForPositioning0(elem);
        if (positioning != null) {
            absoluteTop = positioning.getAbsoluteTop();
            recalcAbsoluteTopAfterScroll = false;
        }
        releaseTempPositioningText();
        tempPositioningText = tptCopy;
    }
    if (!forceFromTop && (absoluteTop >= y1 && absoluteTop < y2)) {
        return;
    }
    if (forceFromTop && LooseContext.is(CONTEXT_REALLY_ABSOLUTE_TOP)) {
        int to = absoluteTop - fromTop;
        scrollBodyTo(to);
        return;
    }
    scrollElementIntoView(elem);
    y1 = Document.get().getBodyOffsetTop() + Window.getScrollTop();
    y2 = y1 + Window.getClientHeight();
    // not sure why...but I feel there's a reason
    if (recalcAbsoluteTopAfterScroll) {
        absoluteTop = elem.getAbsoluteTop();
    }
    if (absoluteTop < y1 || absoluteTop > y2 || fromTop != 0) {
        scrollBodyTo((Math.max(0, absoluteTop - fromTop)));
    }
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void scrollIntoViewWhileKeepingRect(Rect bounds, Widget widget, int pad) {
    // assume widget is below bounds
    int scrollTop = Window.getScrollTop();
    int clientHeight = Window.getClientHeight();
    int widgetTop = widget.getAbsoluteTop();
    int widgetHeight = widget.getOffsetHeight();
    if (widgetTop + widgetHeight + pad > scrollTop + clientHeight) {
        int bestDeltaDown = widgetTop + widgetHeight + pad - (scrollTop + clientHeight);
        int delta = Math.min(bounds.y1 - scrollTop, bestDeltaDown);
        delta = Math.max(0, delta);
        smoothScrollTo(scrollTop + delta, widget);
    }//from w  w w .j a  va  2  s .  c o  m
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.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  .java2  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:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java

License:Apache License

/**
 * Positions the popup, called after the offset width and height of the
 * popup are known./*from  w w w  .java 2s. c  om*/
 * 
 * @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);
}

From source file:cc.alcina.framework.gwt.client.widget.GlassDisplayer.java

License:Apache License

public void show(boolean show) {
    RootPanel.get().setStyleName("glass-showing", show);
    if (!show) {//from w w  w  .j ava2s.c  o m
        if (glass != null) {
            glass.hide();
        }
        return;
    }
    if (glass == null) {
        glass = new PopupPanel();
        fp = new FlowPanelClickable();
        fp.setStyleName("alcina-GlassPanel");
        fp.setWidth(Window.getClientWidth() + "px");
        fp.setHeight(Math.max(Document.get().getBody().getOffsetHeight(), Window.getClientHeight()) + "px");
        Style style = fp.getElement().getStyle();
        style.setBackgroundColor("#000");
        updateOpacity();
        glass.setStyleName("alcina-GlassPopup");
        glass.add(fp);
        glass.setAnimationEnabled(false);
    }
    glass.show();
}