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

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

Introduction

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

Prototype

public static int getClientWidth() 

Source Link

Usage

From source file:com.ait.lienzo.client.widget.LienzoPanel.java

License:Open Source License

public LienzoPanel(final Viewport view) {
    if (false == view.adopt(this)) {
        throw new IllegalArgumentException("Viewport is already adopted.");
    }/*from   w  w w  . j  a  v  a2  s  .c o m*/
    m_view = view;

    setWidth("100%");

    setHeight("100%");

    doPostCTOR(Window.getClientWidth(), Window.getClientHeight(), true);
}

From source file:com.ait.lienzo.client.widget.panel.impl.LienzoPanelImpl.java

License:Open Source License

public LienzoPanelImpl(final Viewport view) {
    if (false == view.adopt(this)) {
        throw new IllegalArgumentException("Viewport is already adopted.");
    }/*from w  w  w  .  jav  a2 s . co m*/
    m_view = view;

    setWidth("100%");

    setHeight("100%");

    doPostCTOR(Window.getClientWidth(), Window.getClientHeight(), true);
}

From source file:com.ait.toolkit.clientio.client.ClientIOInfoBox.java

License:Open Source License

private void say() {
    say(0, (Window.getClientWidth() / 2) - 200);
}

From source file:com.ait.toolkit.gmaps.client.GMapWidget.java

License:Open Source License

@Override
protected void onAttach() {
    super.onAttach();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override//from ww  w  .  j  a v  a 2s.c  o m
        public void execute() {
            setUpMap(div, options.getJsObj());
            GMapWidget.this.getElement().getStyle().setWidth(Window.getClientWidth(), Unit.PX);
            GMapWidget.this.getElement().getStyle().setHeight(Window.getClientHeight(), Unit.PX);
            GMapWidget.this.setWidth(Window.getClientWidth() + "px");
            GMapWidget.this.setHeight(Window.getClientHeight() + "px");
        }
    });
}

From source file:com.ait.toolkit.gmaps.client.GMapWidget.java

License:Open Source License

public void strech() {
    this.getElement().getStyle().setWidth(Window.getClientWidth(), Unit.PX);
    this.getElement().getStyle().setHeight(Window.getClientHeight(), Unit.PX);
    this.setWidth(Window.getClientWidth() + "px");
    this.setHeight(Window.getClientHeight() + "px");
}

From source file:com.alkacon.acacia.client.ui.InlineEditOverlay.java

License:Open Source License

/**
 * Sets position and size of the overlay area.<p>
 * /*w  w w  .ja v a2 s  .c o  m*/
 * @param posX the new X position
 * @param posY the new Y position
 * @param height the new height
 * @param width the new width
 */
private void setSelectPosition(int posX, int posY, int height, int width) {

    int useWidth = Window.getClientWidth();
    int bodyWidth = RootPanel.getBodyElement().getClientWidth() + RootPanel.getBodyElement().getOffsetLeft();
    if (bodyWidth > useWidth) {
        useWidth = bodyWidth;
    }
    int useHeight = Window.getClientHeight();
    int bodyHeight = RootPanel.getBodyElement().getClientHeight() + RootPanel.getBodyElement().getOffsetTop();
    if (bodyHeight > useHeight) {
        useHeight = bodyHeight;
    }

    m_overlayLeftStyle.setWidth(posX - m_offset, Unit.PX);
    m_overlayLeftStyle.setHeight(useHeight, Unit.PX);

    m_borderLeftStyle.setHeight(height + (2 * m_offset), Unit.PX);
    m_borderLeftStyle.setTop(posY - (2 * m_offset), Unit.PX);
    m_borderLeftStyle.setLeft(posX - (2 * m_offset), Unit.PX);

    m_overlayTopStyle.setLeft(posX - m_offset, Unit.PX);
    m_overlayTopStyle.setWidth(width + (2 * m_offset), Unit.PX);
    m_overlayTopStyle.setHeight(posY - m_offset, Unit.PX);

    m_borderTopStyle.setLeft(posX - m_offset, Unit.PX);
    m_borderTopStyle.setTop(posY - (2 * m_offset), Unit.PX);
    if (m_hasButtonBar) {
        m_borderTopStyle.setWidth(width + (2 * m_offset) + BUTTON_BAR_WIDTH, Unit.PX);
    } else {
        m_borderTopStyle.setWidth(width + (2 * m_offset), Unit.PX);
    }

    m_overlayBottomStyle.setLeft(posX - m_offset, Unit.PX);
    m_overlayBottomStyle.setWidth(width + m_offset + m_offset, Unit.PX);
    m_overlayBottomStyle.setHeight(useHeight - posY - height - m_offset, Unit.PX);
    m_overlayBottomStyle.setTop(posY + height + m_offset, Unit.PX);

    m_borderBottomStyle.setLeft(posX - m_offset, Unit.PX);
    m_borderBottomStyle.setTop((posY + height) + m_offset, Unit.PX);
    if (m_hasButtonBar) {
        m_borderBottomStyle.setWidth(width + (2 * m_offset) + BUTTON_BAR_WIDTH, Unit.PX);
    } else {
        m_borderBottomStyle.setWidth(width + (2 * m_offset), Unit.PX);
    }

    m_overlayRightStyle.setLeft(posX + width + m_offset, Unit.PX);
    m_overlayRightStyle.setWidth(useWidth - posX - width - m_offset, Unit.PX);
    m_overlayRightStyle.setHeight(useHeight, Unit.PX);

    m_borderRightStyle.setHeight(height + (2 * m_offset), Unit.PX);
    m_borderRightStyle.setTop(posY - (2 * m_offset), Unit.PX);
    if (m_hasButtonBar) {
        m_borderRightStyle.setLeft(posX + width + m_offset + BUTTON_BAR_WIDTH, Unit.PX);
    } else {
        m_borderRightStyle.setLeft(posX + width + m_offset, Unit.PX);
    }

    m_buttonBar.getStyle().setTop(posY - m_offset, Unit.PX);
    m_buttonBar.getStyle().setHeight(height + (2 * m_offset), Unit.PX);
    m_buttonBar.getStyle().setLeft(posX + width + m_offset + 1, Unit.PX);
}

From source file:com.alkacon.geranium.client.dnd.DNDHandler.java

License:Open Source License

/**
 * Convenience method to get the appropriate scroll direction.<p>
 * //from   w w w  . j  av a2 s .  co  m
 * @param offset the scroll parent border offset, if the cursor is within the border offset, scrolling should be triggered
 * 
 * @return the scroll direction
 */
private Direction getScrollDirection(int offset) {

    if (m_scrollElement == null) {
        Element body = RootPanel.getBodyElement();
        int windowHeight = Window.getClientHeight();
        int bodyHeight = body.getClientHeight();
        if (windowHeight < bodyHeight) {
            if (((windowHeight - m_clientY) < offset)
                    && (Window.getScrollTop() < (bodyHeight - windowHeight))) {
                return Direction.down;
            }
            if ((m_clientY < offset) && (Window.getScrollTop() > 0)) {
                return Direction.up;
            }
        }

        int windowWidth = Window.getClientWidth();
        int bodyWidth = body.getClientWidth();
        if (windowWidth < bodyWidth) {
            if (((windowWidth - m_clientX) < offset) && (Window.getScrollLeft() < (bodyWidth - windowWidth))) {
                return Direction.right;
            }
            if ((m_clientX < offset) && (Window.getScrollLeft() > 0)) {
                return Direction.left;
            }
        }

        return null;
    } else {
        int outerHeight = m_scrollElement.getClientHeight();
        int innerHeight = m_scrollElement.getScrollHeight();
        if (outerHeight < innerHeight) {
            if ((((outerHeight + m_scrollElement.getAbsoluteTop()) - m_clientY) < offset)
                    && (m_scrollElement.getScrollTop() < (innerHeight - outerHeight))) {
                return Direction.down;
            }
            if (((m_clientY - m_scrollElement.getAbsoluteTop()) < offset)
                    && (m_scrollElement.getScrollTop() > 0)) {
                return Direction.up;
            }
        }
        int outerWidth = m_scrollElement.getClientWidth();
        int innerWidth = m_scrollElement.getScrollWidth();
        if (outerWidth < innerWidth) {
            if ((((outerWidth + m_scrollElement.getAbsoluteLeft()) - m_clientX) < offset)
                    && (m_scrollElement.getScrollLeft() < (innerWidth - outerWidth))) {
                return Direction.right;
            }
            if (((m_clientX - m_scrollElement.getAbsoluteLeft()) < offset)
                    && (m_scrollElement.getScrollLeft() > 0)) {
                return Direction.left;
            }
        }
        return null;
    }
}

From source file:com.alkacon.geranium.client.ui.HighlightingBorder.java

License:Open Source License

/**
 * Sets the border position.<p>//www  .  j a  v  a2s .  c  o  m
 * 
 * @param height the height
 * @param width the width
 * @param positionLeft the absolute left position
 * @param positionTop the absolute top position
 */
public void setPosition(int height, int width, int positionLeft, int positionTop) {

    positionLeft -= BORDER_OFFSET;

    // make sure highlighting does not introduce additional horizontal scroll-bars
    if ((m_positioningParent == null) && (positionLeft < 0)) {
        // position left should not be negative
        width += positionLeft;
        positionLeft = 0;
    }
    width += (2 * BORDER_OFFSET) - BORDER_WIDTH;
    if ((m_positioningParent == null) && (Window.getClientWidth() < (width + positionLeft))
            && (Window.getScrollLeft() == 0)) {
        // highlighting should not extend over the right hand 
        width = Window.getClientWidth() - (positionLeft + BORDER_WIDTH);
    }
    Style style = getElement().getStyle();
    style.setLeft(positionLeft, Unit.PX);
    style.setTop(positionTop - BORDER_OFFSET, Unit.PX);
    setHeight((height + (2 * BORDER_OFFSET)) - BORDER_WIDTH);
    setWidth(width);
}

From source file:com.alkacon.geranium.client.ui.input.A_SelectBox.java

License:Open Source License

/**
 * Internal method which is called when the selector is opened.<p>
 *///from  w ww .ja  v a2  s.c om
protected void open() {

    if (!m_enabled) {
        return;
    }

    m_openClose.setDown(true);
    if (m_maxCellWidth == 0) {
        initMaxCellWidth();
    }
    int selectorWidth = m_maxCellWidth;
    // should not be any wider than the actual window
    int windowWidth = Window.getClientWidth();
    if (m_maxCellWidth > windowWidth) {
        selectorWidth = windowWidth - 10;
    }
    m_popup.setWidth(selectorWidth + "px");
    m_popup.show();
    int panelTop = m_panel.getElement().getAbsoluteTop();
    int openerHeight = DomUtil.getCurrentStyleInt(m_opener.getElement(), DomUtil.Style.height);
    int popupHeight = m_popup.getOffsetHeight();
    int dx = 0;
    if (selectorWidth > (m_opener.getOffsetWidth() - 2)) {
        int spaceOnTheRight = (Window.getClientWidth() + Window.getScrollLeft()) - m_opener.getAbsoluteLeft()
                - selectorWidth - 2;
        dx = spaceOnTheRight < 0 ? spaceOnTheRight : 0;
    }
    if (((Window.getClientHeight() - (panelTop + openerHeight)) < popupHeight) && (panelTop > popupHeight)) {
        DomUtil.positionElement(m_popup.getElement(), m_panel.getElement(), dx, -(popupHeight - 2));
        m_selectBoxState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerBottom());
        m_selectorState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerTop());
    } else {
        DomUtil.positionElement(m_popup.getElement(), m_panel.getElement(), dx, openerHeight);
        m_selectBoxState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerTop());
        m_selectorState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerBottom());
    }
    // m_selectBoxState.setValue(CSS.selectBoxOpen());
}

From source file:com.alkacon.geranium.client.ui.Popup.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.PopupPanel#center()
 *///from  w  ww . j  a  va  2 s . c o m
@Override
public void center() {

    if (Position.FIXED.getCssName().equals(getElement().getStyle().getPosition())) {
        show();
        // keep position fixed, as may have been set to absolute
        setPositionFixed();
        int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
        int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
        setPopupPosition(Math.max(left, 0), Math.max(top, 0));
    } else {
        super.center();
        if (m_resizeHandlerRegistration == null) {
            m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

                public void onResize(ResizeEvent event) {

                    m_windowWidth = event.getWidth();
                }
            });
        }
    }
}