List of usage examples for com.google.gwt.user.client Window getClientHeight
public static int getClientHeight()
From source file:com.threerings.gwt.ui.Popups.java
License:Open Source License
/** * Centers the supplied vertically on the supplied trigger widget. The popup's showing state * will be preserved./*from w w w .ja v a 2s . c o m*/ * * @return the supplied popup. */ public static <T extends PopupPanel> T centerOn(T popup, int ypos) { boolean wasHidden = !popup.isShowing(); boolean wasVisible = popup.isVisible(); if (wasVisible) { popup.setVisible(false); } if (wasHidden) { popup.show(); } int left = (Window.getClientWidth() - popup.getOffsetWidth()) >> 1; int top = ypos - popup.getOffsetHeight() / 2; // bound the popup into the visible browser area if possible if (popup.getOffsetHeight() < Window.getClientHeight()) { top = Math.min(Math.max(0, top), Window.getClientHeight() - popup.getOffsetHeight()); } popup.setPopupPosition(left, top); if (wasHidden) { popup.hide(); } if (wasVisible) { popup.setVisible(true); } return popup; }
From source file:com.threerings.gwt.ui.Widgets.java
License:Open Source License
/** * Wraps the supplied contents in a scroll panel that will set the max-width to * Window.getClientWidth()-xpad and the max-height to Window.getClientHeight()-ypad. If either * xpad or ypad are less than zero, the max-size attribute on that axis will not be set. *//*w w w .j a v a 2 s.c om*/ public static ScrollPanel newScrollPanel(Widget contents, int xpad, int ypad) { ScrollPanel panel = new ScrollPanel(contents); if (xpad >= 0) { String maxWidth = (Window.getClientWidth() - xpad) + "px"; DOM.setStyleAttribute(panel.getElement(), "maxWidth", maxWidth); } if (ypad >= 0) { String maxHeight = (Window.getClientHeight() - ypad) + "px"; DOM.setStyleAttribute(panel.getElement(), "maxHeight", maxHeight); } return panel; }
From source file:com.threerings.gwt.util.WindowUtil.java
License:Open Source License
/** * Returns the vertical scroll position needed to place the specified target widget in view, * while trying to minimize scrolling.// w w w .j ava 2 s .c o m */ public static int getScrollIntoView(Widget target) { int top = Window.getScrollTop(), height = Window.getClientHeight(); int ttop = target.getAbsoluteTop(), theight = target.getOffsetHeight(); // if the target widget is taller than the browser window, or is above the current scroll // position of the browser window, scroll the top of the widget to the top of the window if (theight > height || ttop < top) { return ttop; // otherwise scroll the bottom of the widget to the bottom of the window } else if (ttop + theight > top + height) { return ttop - (height - theight); } else { return top; // no scrolling needed } }
From source file:com.threerings.gwt.util.WindowUtil.java
License:Open Source License
/** * Returns the vertical scroll position needed to center the target widget vertically in the * browser viewport. If the widget is taller than the viewport, its top is returned. *//*from w ww .j a va 2s. c o m*/ public static int getScrollToMiddle(Widget target) { int wheight = Window.getClientHeight(), theight = target.getOffsetHeight(); int ttop = target.getAbsoluteTop(); return Math.max(ttop, ttop + (wheight - theight)); }
From source file:com.threerings.gwt.util.WindowUtil.java
License:Open Source License
/** * Returns true if the target widget is vertically scrolled into view. * * @param minPixels the minimum number of pixels that must be visible to count as "in view". *//*w ww.j a v a 2s . c om*/ public static boolean isScrolledIntoView(Widget target, int minPixels) { int wtop = Window.getScrollTop(), wheight = Window.getClientHeight(); int ttop = target.getAbsoluteTop(); if (ttop > wtop) { return (wtop + wheight - ttop > minPixels); } else { return (ttop + target.getOffsetHeight() - wtop > minPixels); } }
From source file:com.threerings.perf.html.PerfTestHtml.java
public void onModuleLoad() { HtmlPlatform.Config config = new HtmlPlatform.Config(); config.antiAliasing = false;//from w w w . j a va 2 s. c o m config.backgroundFrameMillis = 100; // 10 fps background rendering final HtmlPlatform plat = new HtmlPlatform(config); //plat.assets().setPathPrefix("playn-perf/"); plat.graphics().setSize(Window.getClientWidth(), Window.getClientHeight()); Window.scrollTo(0, 0); plat.log().setCollector(new Collector() { public void logged(Level level, String msg, Throwable e) { log(level.toString() + ": " + msg); if (e != null) { log(e.getMessage()); } } native void log(String msg) /*-{ console.log(msg); }-*/; }); new PerfTest(plat); plat.start(); }
From source file:com.tractionsoftware.gwt.user.client.util.Geometry.java
License:Apache License
/** * This takes into account scrolling and will be in absolute * coordinates where the top left corner of the page is 0,0 but * the viewport may be scrolled to something else. *///from w w w.ja va 2 s . c o m public static final Rect getViewportBounds() { return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); }
From source file:com.ui.gwt.mobile.client.components.mobile.TouchHandler.java
License:Apache License
/** * Touch move handler./*ww w . j a va 2 s.c om*/ * * @param e The touchmove event. */ private void onMove(final TouchEvent e) { if (!tracking || dragDelegate == null) { return; } // Prevent native scrolling. e.preventDefault(); 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:com.urlisit.siteswrapper.cloud.client.RenderedPage.java
License:Apache License
private static void sizeLayoutElements() { RenderedPage.windowHeight = Window.getClientHeight(); RenderedPage.windowWidth = Window.getClientWidth(); RenderedPage.mainPanel.setHeight(RenderedPage.windowHeight + "px"); RenderedPage.mainPanel.setWidth(RenderedPage.windowWidth + "px"); RenderedPage.locLangSelectorWidth = (int) Math .round(RenderedPage.locLangSelectorWidthPercent * RenderedPage.windowWidth); RenderedPage.locLangSelectorHeight = (int) Math .round(RenderedPage.locLangSelectorHeightPercent * RenderedPage.windowHeight); RenderedPage.locLangSelectorTop = (int) Math .round(RenderedPage.locLangSelectorTopPercent * RenderedPage.windowHeight); RenderedPage.locLangSelectorLeft = (int) Math .round(RenderedPage.locLangSelectorLeftPercent * RenderedPage.windowWidth); RenderedPage.locLangSelector.setSize(RenderedPage.locLangSelectorWidth + "px", RenderedPage.locLangSelectorHeight + "px"); RenderedPage.searchFieldWidth = (int) Math .round(RenderedPage.searchFieldWidthPercent * RenderedPage.windowWidth); ;//from w w w . ja v a2 s . c o m RenderedPage.searchFieldHeight = (int) Math .round(RenderedPage.searchFieldHeightPercent * RenderedPage.windowHeight); RenderedPage.searchFieldLeft = (int) Math .round(RenderedPage.searchFieldLeftPercent * RenderedPage.windowWidth); RenderedPage.searchFieldTop = (int) Math .round(RenderedPage.searchFieldTopPercent * RenderedPage.windowHeight); RenderedPage.searchField.setPixelSize(RenderedPage.searchFieldWidth, RenderedPage.searchFieldHeight); RenderedPage.searchButtonHeight = (int) Math .round(RenderedPage.searchButtonHeightPercent * RenderedPage.windowHeight); RenderedPage.searchButtonWidth = (int) Math .round(RenderedPage.searchButtonHeight * RenderedPage.searchButtonWidthPercent); RenderedPage.searchButtonLeft = (int) Math .round(RenderedPage.searchButtonLeftPercent * RenderedPage.windowWidth); RenderedPage.searchButtonTop = (int) Math .round(RenderedPage.searchButtonTopPercent * RenderedPage.windowHeight); RenderedPage.searchButton.setPixelSize(RenderedPage.searchButtonWidth, RenderedPage.searchButtonHeight); RenderedPage.mainMenuTop = (int) Math.round(RenderedPage.mainMenuTopPercent * RenderedPage.windowHeight); RenderedPage.mainMenu.getElement().getStyle().setWidth(RenderedPage.windowWidth, Style.Unit.PX); }
From source file:com.urlisit.siteswrapper.cloud.view.Koninklijke.java
License:Apache License
@Override protected void initWidget(Widget widget) { presenter.bindView(this); viewPanel = (AbsolutePanel) widget;// w w w . j a va 2s. c om viewPanel.setPixelSize(Window.getClientWidth(), Window.getClientHeight()); viewPanel.getElement().getStyle().setPosition(Position.RELATIVE); super.initWidget(viewPanel); }