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:next.i.view.widgets.XImage.java

License:Apache License

/**
 * Creates an image with a specified URL. The load event will be fired once
 * the image at the given URL has been retrieved by the browser.
 * /*  ww  w . j av  a 2  s  . c o m*/
 * @param url
 *          the URL of the image to be displayed
 */
public XImage(String url) {
    super(url);

    addLoadHandler(new LoadHandler() {
        @Override
        public void onLoad(LoadEvent event) {
            Element element = event.getRelativeElement();
            if (element == XImage.this.getElement()) {
                int originalHeight = XImage.this.getOffsetHeight();
                int originalWidth = XImage.this.getOffsetWidth();
                int clientW = Window.getClientWidth();
                int clientH = Window.getClientHeight();
                // Window.alert("originalHeight=" + originalHeight +
                // ", originalWidth=" + originalWidth);

                int size = 0;
                if (clientH > clientW) {
                    size = clientW;
                } else {
                    size = clientH;
                }

                size = size - 20/* padding */;

                // FIXME add orientation listener
                if (originalHeight > originalWidth) {
                    XImage.this.setHeight(size + "px");
                } else {
                    XImage.this.setWidth(size + "px");
                }
            }
        }
    });

}

From source file:next.interfaces.controller.DemoUtils.java

License:Apache License

public static void openGit(String source, final String url) {

    final XFlexTable tbl = new XFlexTable();

    final XButton btnCopy = new XButton("Copy", XButtonType.Shadow);
    btnCopy.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            markText(tbl.getWidget(0, 0).getElement());
        }/*from  w  ww .j a  va2  s .  com*/
    });

    final XButton btnGit = new XButton("View in GitHub", XButtonType.Shadow);
    btnGit.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            // Window.open(Globals.GIT_HOST + url + ".java", "_tab", "");
            // Utils.loadUrl(Globals.GIT_HOST + url + ".java");

            // This click handler seems to work best
            openURL(Globals.GIT_HOST + url + ".java");
        }
    });

    tbl.getElement().setId("codeText");
    String codeUrl = url.substring(url.lastIndexOf("/") + 1);
    HTTP.doGet(Globals.SOURCE_PATH.replace("$", codeUrl), new ResponseReader() {
        public void onSuccess(Response resp) {
            tbl.setWidget(0, 0, new HTML("<pre>" + toHighlighted(resp.getText()) + "</pre>"));
            tbl.setWidget(1, 0, btnCopy);
            tbl.setWidget(1, 1, btnGit);
        }
    });

    final XPopup popup = new XPopup();
    XDragScrollView view = new XDragScrollView();
    view.addStyleName("codeDemo");

    tbl.setWidget(0, 0, new XSpinner());
    tbl.setCellSpacing(10);

    FlexCellFormatter fcf = tbl.getFlexCellFormatter();
    fcf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    fcf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
    fcf.setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    fcf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    fcf.setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
    fcf.setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
    fcf.setColSpan(0, 0, 2);
    fcf.setWidth(1, 0, "50%");
    fcf.setWidth(1, 1, "50%");
    view.add(tbl);

    int h = Window.getClientHeight();
    int w = Window.getClientWidth();
    popup.setWidget(view);

    // mobile phone
    if (h + w < 1000) {
        popup.setTop("35px");
        popup.setRight("5%");
        popup.setLeft("5%");
        popup.setBottom("40px");

    } else {
        popup.setTop("35px");
        popup.setRight("5%");
        popup.setLeft("10%");
        popup.setBottom("30%");
    }

    popup.show();
}

From source file:next.keyboard.ui.Main.java

License:Apache License

void initModuleLoad() {
    final RootPanel rootPanel = RootPanel.get("root");
    rootPanel.setVisible(false);//from   ww w  . j a v a 2s  . c  o  m

    final UiGinjector ctx = UiGinjector.INSTANCE;

    // init and make it visible
    // ctx.getUiSingleton().getWalletLeftMenu().show();

    rootPanel.add(new TextBoxWidget(ctx.getEventBus()));

    rootPanel.setVisible(true);

    RootPanel loadingPanel = RootPanel.get("loading");
    loadingPanel.setVisible(false);

    // Used for debuggin only
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            int cH = Window.getClientHeight();
            int cW = Window.getClientWidth();

            int scH = Window.getScrollTop();
            int scL = Window.getScrollLeft();
            Logger.debug("clientHeight:" + cH + ", clientWidth:" + cW + "| scrollTop:" + scH + ", scrollLeft:"
                    + scL);
        }
    });

    listenEventUpdates(ctx.getEventBus());

    // ctx.getEventBus().fireEvent(new LsShowSportsEvent(true));
    // RootPanel.get("root").setVisible(false);
}

From source file:next.keyboard.ui.Main.java

License:Apache License

void listenEventUpdates(TabletEventBus eventBus) {
    eventBus.addHandler(KeyboardOpenEvent.TYPE, new KeyboardOpenHandler() {
        @Override//w  w w  . j a va  2 s.c o  m
        public void onExecute(KeyboardOpenEvent e) {
            KeyboardTextBox box = e.getTextBox();
            UiGinjector ctx = UiGinjector.INSTANCE;
            final KeyboardPopup kb = ctx.getUiSingleton().getKeyboardPopup();
            kb.bind(box);
            box.setSelected(true);

            kb.setPopupPositionAndShow(new PositionCallback() {
                @Override
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int leftStart = (int) (offsetWidth / 2.0);
                    int topStart = Window.getClientHeight();
                    int topEnd = Window.getClientHeight() - offsetHeight;
                    kb.openAnimated_setPopupPosition(leftStart, leftStart, topStart, topEnd);
                }
            });
        }
    });
}

From source file:next.tablet.client.TabletEntryPoint.java

License:Apache License

public void initModuleLoad() {
    final RootPanel rootPanel = RootPanel.get("root");
    rootPanel.setVisible(false);// w w w.  j av  a2s. co m

    final UiGinjector ctx = UiGinjector.INSTANCE;

    // init and make it visible
    ctx.getUiSingleton().getWalletLeftMenu().show();
    ctx.getUiSingleton().getTopMenu().show();
    ctx.getUiSingleton().getTopMenu().getBackCommand().execute();
    ctx.getUiSingleton().getImagePage(); // init
    ctx.getEventBus().fireEvent(new ShowBackButtonEvent(Type.GAMES));

    rootPanel.setVisible(true);

    RootPanel loadingPanel = RootPanel.get("loading");
    loadingPanel.setVisible(false);

    // Used for debuggin only
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            int cH = Window.getClientHeight();
            int cW = Window.getClientWidth();

            int scH = Window.getScrollTop();
            int scL = Window.getScrollLeft();
            Logger.debug("clientHeight:" + cH + ", clientWidth:" + cW + "| scrollTop:" + scH + ", scrollLeft:"
                    + scL);
        }
    });

    // listenForEventUpdates();

    // ctx.getEventBus().fireEvent(new LsShowSportsEvent(true));
    // RootPanel.get("root").setVisible(false);

    Timer t2 = new Timer() {
        public void run() {
            ctx.getUiSingleton().getNotificationPage().doShow();
        }
    };
    t2.schedule(5000);

}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractStimulusPresenter.java

License:Open Source License

protected void touchInputReportSubmit(final Stimulus currentStimulus, final int dataChannel) {
    if (touchInputCapture != null) {
        final String touchReport = touchInputCapture.getTouchReport(Window.getClientWidth(),
                Window.getClientHeight());
        submissionService.submitTagPairValue(userResults.getUserData().getUserId(), getSelfTag(), dataChannel,
                "touchInputReport", currentStimulus.getUniqueId(), touchReport, duration.elapsedMillis());
        //            // todo: perhaps this is a bit heavy on local storage but at least only one touch event would be stored
        //            JSONObject storedStimulusJSONObject = localStorage.getStoredJSONObject(userResults.getUserData().getUserId(), currentStimulus);
        //            storedStimulusJSONObject = (storedStimulusJSONObject == null) ? new JSONObject() : storedStimulusJSONObject;
        //            storedStimulusJSONObject.put("touchInputReport", new JSONString(touchReport));
        //            localStorage.setStoredJSONObject(userResults.getUserData().getUserId(), currentStimulus, storedStimulusJSONObject);
    }//  www .  j ava  2  s  .  c om
    touchInputCapture = null;
}

From source file:nl.mpi.tg.eg.experiment.client.view.AbstractView.java

License:Open Source License

public AbstractView() {
    super(Style.Unit.PX);
    setWidth(Window.getClientWidth() + "px");
    setHeight(Window.getClientHeight() + "px");
    Window.addResizeHandler(new ResizeHandler() {

        @Override/*from  w ww.j  a  va  2 s .c o m*/
        public void onResize(ResizeEvent event) {
            int height = event.getHeight();
            setHeight(height + "px");
            int width = event.getWidth();
            setWidth(width + "px");
            parentResized(height, width, "px");
        }
    });
}

From source file:nl.mpi.tg.eg.experiment.client.view.AbstractView.java

License:Open Source License

public void resizeView() {
    int height = Window.getClientHeight();
    setHeight(height + "px");
    int width = Window.getClientWidth();
    setWidth(width + "px");
    parentResized(height, width, "px");
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

public ColourPickerCanvasView() throws CanvasError {
    setStylePrimaryName("stimulusScreen");
    final int clientHeight = Window.getClientHeight();
    final int clientWidth = Window.getClientWidth();
    final int minClient = (clientHeight > clientWidth) ? clientWidth : clientHeight;
    stimulusTextHeight = (int) (minClient * 0.08);
    selectedColourPanelHeight = (int) (minClient * 0.25);
    selectedColourPanelWidth = (int) (minClient * 0.47);
    //        buttonTextHeight = (int) (minClient * 0.05);
    buttonHeight = (int) (minClient * 0.1);
    buttonWidth = (int) (minClient * 0.47);
    stimulusPanel = new VerticalPanel();
    stimulusPanel.addStyleName("stimulusPanel");
    stimulusPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    outerGrid = new Grid(2, 2);
    innerGrid = new Grid(6, 2);
    pickerPanel = new Grid(1, 2);
    progressPanel = new Grid(1, 3);
    progressPanel.setWidth("100%");
    infoButton = new Button();
    infoButton.addStyleName("stimulusHelpButton");
    //        infoButton.getElement().getStyle().setFontSize(buttonTextHeight, Unit.PX);
    selectedColourPanel = new VerticalPanel();
    progressLabel = new Label();
    progressLabel.addStyleName("stimulusProgressLabel");
    mainCanvas = Canvas.createIfSupported();
    hueCanvas = Canvas.createIfSupported();

    if (mainCanvas == null || hueCanvas == null) {
        throw new CanvasError("Failed to create a canvas for the stimulus screen.");
    } else {//from   ww w  . j  a  v a  2  s .c  om
        pickerPanel.setCellPadding(5);
        pickerPanel.setWidget(0, 0, mainCanvas);
        pickerPanel.setWidget(0, 1, hueCanvas);
        final Label selectedColourLabel = new Label("");
        selectedColourLabel.setHeight(selectedColourPanelHeight + "px");
        selectedColourLabel.setWidth(selectedColourPanelWidth + "px");
        selectedColourPanel.add(selectedColourLabel);
        mainCanvas.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                event.preventDefault();
                setColour(event, mainCanvas, selectedColourPanel);
            }
        });
        hueCanvas.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                event.preventDefault();
                setHue(event, hueCanvas);
                setColour(event, hueCanvas, selectedColourPanel);
            }
        });
        mainCanvas.addTouchStartHandler(new TouchStartHandler() {

            @Override
            public void onTouchStart(TouchStartEvent event) {
                event.preventDefault();
                setColour(event, mainCanvas, selectedColourPanel);
            }
        });
        mainCanvas.addTouchMoveHandler(new TouchMoveHandler() {

            @Override
            public void onTouchMove(TouchMoveEvent event) {
                event.preventDefault();
                setColour(event, mainCanvas, selectedColourPanel);
            }
        });
        mainCanvas.addTouchEndHandler(new TouchEndHandler() {

            @Override
            public void onTouchEnd(TouchEndEvent event) {
                event.preventDefault();
                setColour(event, mainCanvas, selectedColourPanel);
            }
        });
        hueCanvas.addTouchStartHandler(new TouchStartHandler() {

            @Override
            public void onTouchStart(TouchStartEvent event) {
                event.preventDefault();
                setHue(event, hueCanvas);
                setColour(event, hueCanvas, selectedColourPanel);
            }
        });
        hueCanvas.addTouchMoveHandler(new TouchMoveHandler() {

            @Override
            public void onTouchMove(TouchMoveEvent event) {
                event.preventDefault();
                setHue(event, hueCanvas);
                setColour(event, hueCanvas, selectedColourPanel);
            }
        });
        hueCanvas.addTouchEndHandler(new TouchEndHandler() {

            @Override
            public void onTouchEnd(TouchEndEvent event) {
                event.preventDefault();
                setHue(event, hueCanvas);
                setColour(event, hueCanvas, selectedColourPanel);
            }
        });
    }
    progressPanel.setWidget(0, 1, progressLabel);
    progressPanel.setWidget(0, 2, infoButton);
    progressPanel.setStylePrimaryName("headerPanel");
    progressPanel.getColumnFormatter().setWidth(1, "100%");
    addNorth(progressPanel, 50);
    add(outerGrid);
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

public void setInstructions(final String instructions, final String infoButtonChar,
        final String closeButtonLabel) {
    final HTML instructionsLabel = new HTML(instructions);
    final PopupPanel popupPanel = new PopupPanel(false); // the close action to this panel causes background buttons to be clicked
    popupPanel.setGlassEnabled(true);//from  ww  w  .  j  av  a 2  s .  co m
    popupPanel.setStylePrimaryName("stimulusHelpPanel");
    instructionsLabel.setStylePrimaryName("stimulusHelpText");
    instructionsScrollPanel = new ScrollPanel(instructionsLabel);
    instructionsScrollPanel.getElement().getStyle().setPropertyPx("maxHeight", Window.getClientHeight() - 150);
    final VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.add(instructionsScrollPanel);
    final Button closeButton = new Button(closeButtonLabel);
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    verticalPanel.add(closeButton);
    popupPanel.setWidget(verticalPanel);
    infoButton.setText(infoButtonChar);
    final SingleShotEventListner infoSingleShotEventListner = new SingleShotEventListner() {

        @Override
        protected void singleShotFired() {
            if (infoButton.isEnabled()) {
                //                    outerGrid.clear(); // users found that hiding the picker screen made it hard to understand the instruction text
                popupPanel.center();
                infoButton.setEnabled(false);
                resetSingleShot();
            }
        }
    };
    infoButton.addClickHandler(infoSingleShotEventListner);
    infoButton.addTouchStartHandler(infoSingleShotEventListner);
    infoButton.addTouchMoveHandler(infoSingleShotEventListner);
    infoButton.addTouchEndHandler(infoSingleShotEventListner);
    final SingleShotEventListner instructionsSingleShotEventListner1 = new SingleShotEventListner() {

        @Override
        protected void singleShotFired() {
            popupPanel.hide();
            resizeView();
            infoButton.setEnabled(true);
            resetSingleShot();
        }
    };
    closeButton.addClickHandler(instructionsSingleShotEventListner1);
    closeButton.addTouchStartHandler(instructionsSingleShotEventListner1);
    closeButton.addTouchMoveHandler(instructionsSingleShotEventListner1);
    closeButton.addTouchEndHandler(instructionsSingleShotEventListner1);
    popupPanel.addCloseHandler(new CloseHandler<PopupPanel>() {

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            instructionsScrollPanel = null;
            //                instructionsSingleShotEventListner1.eventFired();
            //                infoButton.setEnabled(true);
            //                resizeView();
        }
    });
    popupPanel.center();
}