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:com.risevision.viewer.client.widgets.oem.HelpFrameWidget.java

License:Open Source License

private void prepareFrame() {
    w = Window.getClientWidth() - 40;
    h = Window.getClientHeight() - 40;

    styleControls();//from   ww w .jav  a  2s  .  com

    add(outerPanel);

    outerPanel.add(webPageFrame, 0, 7);
    outerPanel.add(closePanel, w - 10, -17);

    initActions();
}

From source file:com.roughindustries.commonwealthcocktails.client.application.ApplicationPresenter.java

License:Apache License

@Override
protected void onBind() {

    step.setValue(25);/* w ww  .j  av a  2 s .c om*/
    current.setValue(25);
    next.setValue(current.intValue() + step.intValue());
    prev.setValue(0);

    lastScrollPos.setValue(0);
    lastMaxScrollTop.setValue(0);

    list.addAll(Collections.nCopies(current.intValue(), new ccCocktail()));

    final HTML f = new HTML("");
    Column<ccCocktail, SafeHtml> text = new Column<ccCocktail, SafeHtml>(new SafeHtmlCell()) {

        public SafeHtml getValue(ccCocktail cocktail) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            if (cocktail == null || cocktail.getCocktailName() == null) {
                sb.appendHtmlConstant("Loading ...");
                return sb.toSafeHtml();
            } else {
                sb.appendHtmlConstant(
                        "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>");
                sb.appendHtmlConstant("<tbody>");
                sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant(
                        "<td><img alt='Cocktail' src='https://s3.amazonaws.com/commonwealthcocktailbucket/noun_320760_cc.png' style='border-width: 0px; border-style: solid; margin: 0px; width: 100px; height: 100px;' /></td>");
                sb.appendHtmlConstant(
                        "<td border='0' cellpadding='1' cellspacing='1' style='width: 100%;' table=''>");
                sb.appendHtmlConstant(
                        "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>");
                sb.appendHtmlConstant("<tbody>");
                sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant("<td><b>" + cocktail.getCocktailName() + "</b></td>");
                sb.appendHtmlConstant("</tr>");
                sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant(
                        "<td><b>Origin: </b>"
                                + ((cocktail.getCocktailOrigin() == null)
                                        || (cocktail.getCocktailOrigin().length() == 0) ? ""
                                                : (cocktail.getCocktailOrigin().substring(0, 150) + "..."))
                                + "</td>");
                sb.appendHtmlConstant("</tr>");
                sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant("<td><b>Method: </b>"
                        + ((cocktail.getCocktailMethod() == null) || (cocktail.getCocktailMethod() == null) ? ""
                                : (cocktail.getCocktailMethod().substring(0, 150) + "..."))
                        + "</td>");
                sb.appendHtmlConstant("</tr>");
                sb.appendHtmlConstant("</tbody>");
                sb.appendHtmlConstant("</table>");
                sb.appendHtmlConstant("</td>");
                sb.appendHtmlConstant("</tr>");
                sb.appendHtmlConstant("</tbody>");
                sb.appendHtmlConstant("</table>");
                return sb.toSafeHtml();
            }
        }

    };
    getView().getCocktailGrid().addColumn(text);
    data.addAll(list);
    getView().getCocktailGrid().setRowData(0, data);
    getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue()));
    getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px");
    getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px");
    getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px");
    if (Window.getClientWidth() <= 768) {
        getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125);
    } else {
        getView().getBrand().setMarginLeft(0);
    }
    if (Window.getClientWidth() > (800)
            && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) {
        getView().getHeaderContainer()
                .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px");
        getView().getCocktailGrid().setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px");
        if (getView().getLeftBuffer().isVisible()) {
            getView().getLeftBuffer().setVisible(false);
            getView().getRightBuffer().setVisible(false);
        }
    } else if (Window.getClientWidth() <= (800 - NativeVerticalScrollbar.getNativeScrollbarWidth())) {
        getView().getHeaderContainer().setWidth(
                Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth())
                        + "px");
        getView().getCocktailGrid().setWidth(
                Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth())
                        + "px");

        if (getView().getLeftBuffer().isVisible()) {
            getView().getLeftBuffer().setVisible(false);
            getView().getRightBuffer().setVisible(false);
        }
    } else {
        getView().getHeaderContainer().setWidth("800px");
        getView().getCocktailGrid().setWidth("800px");
        if (!getView().getLeftBuffer().isVisible()) {
            getView().getLeftBuffer().setVisible(true);
            getView().getRightBuffer().setVisible(true);
        }
        getView().getLeftBuffer()
                .setWidth(Integer.toString(
                        (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2)
                        + "px");
        getView().getRightBuffer()
                .setWidth(Integer.toString(
                        (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2)
                        + "px");
    }
    getView().getScroll().addScrollHandler(new ScrollHandler() {

        @Override
        public void onScroll(ScrollEvent ev) {
            int oldScrollPos = lastScrollPos.intValue();
            lastScrollPos.setValue(getView().getScroll().getVerticalScrollPosition());

            // If scrolling up, ignore the event.
            if (oldScrollPos >= lastScrollPos.intValue()) {
                return;
            }

            // Height of grid contents (including outside the viewable area)
            // - height of the scroll panel
            int maxScrollTop = getView().getScroll().getWidget().getOffsetHeight()
                    - getView().getScroll().getOffsetHeight();
            if (lastScrollPos.intValue() == maxScrollTop) {
                if ((data.size() + step.intValue()) <= queryResultsCount.intValue()) {
                    prev.setValue(current);
                    current.setValue(next);
                    next.setValue(next.intValue() + step.intValue());
                    data.addAll(
                            new ArrayList<ccCocktail>(Collections.nCopies(step.intValue(), new ccCocktail())));
                } else {
                    int diff = queryResultsCount.intValue() - data.size();
                    if (diff > 0) {
                        step.setValue(diff);
                        prev.setValue(current);
                        current.setValue(next);
                        next.setValue(next.intValue() + step.intValue());
                        data.addAll(new ArrayList<ccCocktail>(Collections.nCopies(diff, new ccCocktail())));
                    } else {
                        step.setValue(0);
                    }
                }
                getView().getCocktailGrid().setRowData(0, data);
                getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue()));
                getView().getCocktailGrid().redraw();
                if (step.intValue() != 0) {
                    cocktailService.cocktailServer("", prev.intValue(), step.intValue(),
                            new AsyncCallback<ccCocktail[]>() {
                                public void onFailure(Throwable caught) {

                                }

                                public void onSuccess(ccCocktail[] result) {
                                    if (result != null) {
                                        for (ccCocktail item : result) {
                                            data.set(item.getPageRefID(), item);
                                        }
                                        getView().getCocktailGrid().setRowData(0, data);
                                        getView().getCocktailGrid()
                                                .setVisibleRange(new Range(0, current.intValue()));
                                        getView().getCocktailGrid().redraw();

                                    }
                                }
                            });
                }
            }
        }
    });
    Window.addWindowScrollHandler(new Window.ScrollHandler() {
        @Override
        public void onWindowScroll(com.google.gwt.user.client.Window.ScrollEvent event) {
            // Window.alert("Scrolling Window");
        }
    });
    cocktailService.getCount("", new AsyncCallback<Integer>() {
        public void onFailure(Throwable caught) {

        }

        public void onSuccess(Integer result) {
            queryResultsCount.setValue(result.intValue());
            cocktailService.cocktailServer("", prev.intValue(), current.intValue(),
                    new AsyncCallback<ccCocktail[]>() {
                        public void onFailure(Throwable caught) {

                        }

                        public void onSuccess(ccCocktail[] result) {
                            ArrayList<ccCocktail> removed = new ArrayList<ccCocktail>();
                            for (ccCocktail item : result) {
                                if (item != null) {
                                    removed.add(item);
                                }
                            }
                            result = removed.toArray(new ccCocktail[0]);
                            if (result != null) {
                                for (ccCocktail item : result) {
                                    data.set(item.getPageRefID(), item);
                                }
                                getView().getCocktailGrid().setRowData(0, data);
                                getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue()));
                                getView().getCocktailGrid().redraw();
                            }
                        }
                    });
        }
    });
    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px");
            getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px");
            getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px");

            if (Window.getClientWidth() <= 768) {
                getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125);
            } else {
                getView().getBrand().setMarginLeft(0);
            }

            if (Window.getClientWidth() > (800)
                    && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) {
                getView().getHeaderContainer()
                        .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px");
                getView().getCocktailGrid()
                        .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px");
                if (getView().getLeftBuffer().isVisible()) {
                    getView().getLeftBuffer().setVisible(false);
                    getView().getRightBuffer().setVisible(false);
                }
            } else if (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth())) {
                getView().getHeaderContainer()
                        .setWidth(Integer.toString(
                                Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth())
                                + "px");
                getView().getCocktailGrid()
                        .setWidth(Integer.toString(
                                Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth())
                                + "px");
                if (getView().getLeftBuffer().isVisible()) {
                    getView().getLeftBuffer().setVisible(false);
                    getView().getRightBuffer().setVisible(false);
                }
            } else {
                getView().getHeaderContainer().setWidth("800px");
                getView().getCocktailGrid().setWidth("800px");
                if (!getView().getLeftBuffer().isVisible()) {
                    getView().getLeftBuffer().setVisible(true);
                    getView().getRightBuffer().setVisible(true);
                }
                getView().getLeftBuffer().setWidth(Integer.toString(
                        (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2)
                        + "px");
                getView().getRightBuffer().setWidth(Integer.toString(
                        (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2)
                        + "px");
            }
        }

    });
}

From source file:com.sangnd.gwt.faceme.client.view.BoardViewMGwt.java

License:Open Source License

private void resizeScreen() {
    int w = Window.getClientWidth();
    int h = Window.getClientHeight() - 50;
    float rw = (float) w / Constant.SCREEN_WIDTH;
    float rh = (float) h / Constant.SCREEN_HEIGHT;
    if (rw < rh) {
        Constant.SCREEN_RATIO = rw;/*from w w w  . j a va2  s.co m*/
    } else {
        Constant.SCREEN_RATIO = rh;
    }
    int width = ((int) ((float) Constant.SCREEN_WIDTH * Constant.SCREEN_RATIO) - 40);
    int height = ((int) ((float) Constant.SCREEN_HEIGHT * Constant.SCREEN_RATIO) - 40);

    this.setWidth(width + "px");
    this.setHeight(height + "px");
    boardPanel.getElement().getStyle().setProperty("backgroundSize", width + "px " + height + "px");
    notiShape.getElement().getStyle().setProperty("left", (width - 200) / 2 + "px");
    notiShape.getElement().getStyle().setProperty("top", (height - 40) / 2 + "px");
    this.reDrawChess();
}

From source file:com.sciencegadgets.client.Moderator.java

License:Open Source License

private void fitWindow() {
    SGAHeight = Window.getClientHeight();
    SGAWidth = Window.getClientWidth();

    // Fill up the window
    scienceGadgetArea.setSize(SGAWidth + "px", SGAHeight + "px");
}

From source file:com.sciencegadgets.client.ui.Prompt.java

License:Open Source License

@Override
public void resize() {
    flowPanel.setPixelSize((int) (Window.getClientWidth() * WIDTH_FRACTION),
            (int) (Window.getClientHeight() * HEIGHT_FRACTION));
}

From source file:com.seanchenxi.gwt.effect.core.Fly.java

License:Apache License

public void setTargetRelativeToCenter(int left, int top) {
    this.targetLeft = left + (Window.getClientWidth() - getWidget().getOffsetWidth()) >> 1;
    this.targetTop = top + (Window.getClientHeight() - getWidget().getOffsetHeight()) >> 1;
}

From source file:com.seanchenxi.gwt.effect.core.Fly.java

License:Apache License

@Override
public boolean doPrepare() {
    getStyle().setPosition(Position.ABSOLUTE);
    if (targetTop == -1) {
        targetLeft = (Window.getClientWidth() - getWidget().getOffsetWidth()) >> 1;
        targetTop = (Window.getClientHeight() - getWidget().getOffsetHeight()) >> 1;
    }/* w  w  w  . j a va  2s. c om*/
    startLeft = getWidget().getAbsoluteLeft();
    startTop = getWidget().getAbsoluteTop();
    distL = targetLeft - startLeft;
    distT = targetTop - startTop;
    return true;
}

From source file:com.sencha.gxt.cell.core.client.form.ComboBoxCell.java

License:sencha.com license

protected void restrict(XElement parent) {
    XElement wrapper = parent.getFirstChildElement().cast();
    int width = Math.max(wrapper.getWidth(true), minListWidth);

    listContainer.getElement().setVisibility(false);
    listView.setHeight("auto");
    listContainer.setHeight("auto");

    int fh = 0;//from   w  w  w .  j av  a2  s  .  c o  m
    int h = fh + listContainer.getOffsetHeight();
    int mH = Math.min(maxHeight, Window.getClientHeight() - 10);
    h = Math.min(h, mH);

    int aw = width - listContainer.getElement().getFrameWidth(Side.LEFT, Side.RIGHT);

    listContainer.getElement().makePositionable(true);
    listContainer.setPixelSize(aw, h);
    listContainer.getElement().setVisibility(true);

    listView.setWidth(aw);
    listView.setHeight(h - 2 - (pagingToolBar != null ? pagingToolBar.getOffsetHeight() : 0));

    if (selectedItem != null) {
        int index = getStore().indexOf(selectedItem);
        if (index == -1) {
            // item not found in store using .equals method. try using Key
            selectedItem = getStore().findModel(selectedItem);
            index = getStore().indexOf(selectedItem);
        }

        if (selectedItem != null) {
            listView.getElement(index).scrollIntoView();
        }
    }

    listContainer.getElement().alignTo(wrapper, new AnchorAlignment(Anchor.TOP_LEFT, Anchor.BOTTOM_LEFT, true),
            0, 0);

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            listContainer.sync(true);
        }
    });
}

From source file:com.sencha.gxt.fx.client.Draggable.java

License:sencha.com license

protected void handleStart(int x, int y, Event event, Element target) {
    startBounds = dragWidgetElement.getBounds();

    startElement = target;// w  w  w.  j  a va  2  s . c  o m

    dragStartX = x;
    dragStartY = y;

    eventPreview.add();

    clientWidth = Window.getClientWidth() + XDOM.getBodyScrollLeft();
    clientHeight = Window.getClientHeight() + XDOM.getBodyScrollTop();

    if (container != null) {
        conX = container.getAbsoluteLeft();
        conY = container.getAbsoluteTop();
        conWidth = container.getOffsetWidth();
        conHeight = container.getOffsetHeight();
    }

    if (startDragDistance == 0) {
        startDrag(event);
    }
}

From source file:com.sencha.gxt.fx.client.Shim.java

License:sencha.com license

/**
 * Creates and covers the area with a Shim. If shimIframes is true will only
 * covers IFrames.//w ww . j  av  a2 s  .  c o  m
 * 
 * @param shimIframes true if you want to cover only iframes
 */
public void cover(boolean shimIframes) {
    XElement body = Document.get().getBody().<XElement>cast();
    if (shimIframes) {
        NodeList<Element> elements = body.select("iframe:not(.x-noshim)");
        shim(elements);
        elements = body.select("object:not(.x-noshim)");
        shim(elements);
        elements = body.select("applet:not(.x-noshim)");
        shim(elements);
        elements = body.select("embed:not(.x-noshim)");
        shim(elements);
    } else {
        shims.add(createShim(null, 0, 0, Window.getClientWidth(), Window.getClientHeight()));
    }
}