List of usage examples for com.google.gwt.user.client Window getScrollLeft
public static int getScrollLeft()
From source file:org.unitime.timetable.gwt.mobile.client.widgets.MobileUniTimeFrameDialogImpl.java
License:Apache License
@Override public void openDialog(String title, String source, String width, String height) { if (isShowing()) hideDialog();/*from ww w.j ava 2 s. c om*/ GwtHint.hideHint(); iScrollLeft = Window.getScrollLeft(); iScrollTop = Window.getScrollTop(); Window.scrollTo(0, 0); LoadingWidget.getInstance().show("Loading " + title + " ..."); setText(title); String hash = null; int hashIdx = source.lastIndexOf('#'); if (hashIdx >= 0) { hash = source.substring(hashIdx); source = source.substring(0, hashIdx); } iFrame.setUrl(source + (source.indexOf('?') >= 0 ? "&" : "?") + "noCacheTS=" + new Date().getTime() + (hash == null ? "" : hash)); iCheckLoadingWidgetIsShowing.schedule(30000); History.newItem(title, false); iPopup.setPopupPosition(0, 0); iPopup.show(); RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN); }
From source file:org.utgenome.gwt.utgb.client.canvas.GWTGenomeCanvas.java
License:Apache License
public int getXOnCanvas(int clientX) { return clientX + Window.getScrollLeft() - basePanel.getAbsoluteLeft(); }
From source file:org.utgenome.gwt.utgb.client.canvas.GWTGraphCanvas.java
License:Apache License
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); int type = DOM.eventGetType(event); switch (type) { case Event.ONMOUSEOVER: break;//w w w .j av a2 s. c om case Event.ONMOUSEMOVE: { // show readLabels if (dragStartPoint.isDefined()) { // scroll the canvas int clientX = DOM.eventGetClientX(event) + Window.getScrollLeft(); //int clientY = DOM.eventGetClientY(event) + Window.getScrollTop(); DragPoint p = dragStartPoint.get(); int xDiff = clientX - p.x; //int yDiff = clientY - p.y; //panel.setWidgetPosition(canvas, xDiff, 0); } else { //Style.cursor(canvas, Style.CURSOR_AUTO); } break; } case Event.ONMOUSEOUT: { resetDrag(event); break; } case Event.ONMOUSEDOWN: { // invoke a click event int clientX = DOM.eventGetClientX(event) + Window.getScrollLeft(); int clientY = DOM.eventGetClientY(event) + Window.getScrollTop(); if (dragStartPoint.isUndefined()) { dragStartPoint.set(new DragPoint(clientX, clientY)); //Style.cursor(canvas, Style.CURSOR_RESIZE_E); event.preventDefault(); } break; } case Event.ONMOUSEUP: { resetDrag(event); break; } } }
From source file:org.utgenome.gwt.utgb.client.canvas.GWTGraphCanvas.java
License:Apache License
private void resetDrag(Event event) { int clientX = DOM.eventGetClientX(event) + Window.getScrollLeft(); //int clientY = DOM.eventGetClientY(event) + Window.getScrollTop(); // if (dragStartPoint.isDefined() && trackWindow != null) { // DragPoint p = dragStartPoint.get(); // int startDiff = trackWindow.convertToGenomePosition(clientX) - trackWindow.convertToGenomePosition(p.x); // if (startDiff != 0) { // int newStart = trackWindow.getStartOnGenome() - startDiff; // if (newStart < 1) // newStart = 1; // int newEnd = newStart + trackWindow.getSequenceLength(); // TrackWindow newWindow = trackWindow.newWindow(newStart, newEnd); // if (trackGroup != null) // trackGroup.setTrackWindow(newWindow); // }/* ww w . ja v a2 s. com*/ // } dragStartPoint.reset(); //Style.cursor(canvas, Style.CURSOR_AUTO); }
From source file:org.vaadin.addons.tuningdatefield.widgetset.client.ui.TuningDateFieldWidget.java
License:Apache License
public void updatePopupPosition() { // This has been copied from Vaadin VPopupCalendar (shame on me...) popup.setPopupPositionAndShow(new PositionCallback() { @Override/*from www .j av a2 s. co m*/ public void setPosition(int offsetWidth, int offsetHeight) { final int w = offsetWidth; final int h = offsetHeight; final int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); final int browserWindowHeight = Window.getClientHeight() + Window.getScrollTop(); int t = calendarToggle.getAbsoluteTop(); int l = calendarToggle.getAbsoluteLeft(); // Add a little extra space to the right to avoid // problems with IE7 scrollbars and to make it look // nicer. int extraSpace = 30; boolean overflowRight = false; if (l + +w + extraSpace > browserWindowWidth) { overflowRight = true; // Part of the popup is outside the browser window // (to the right) l = browserWindowWidth - w - extraSpace; } if (t + h + calendarToggle.getOffsetHeight() + 30 > browserWindowHeight) { // Part of the popup is outside the browser window // (below) t = browserWindowHeight - h - calendarToggle.getOffsetHeight() - 30; if (!overflowRight) { // Show to the right of the popup button unless we // are in the lower right corner of the screen l += calendarToggle.getOffsetWidth(); } } popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2); } }); }
From source file:org.waveprotocol.wave.client.common.util.OffsetPosition.java
License:Apache License
/** * Create a offset position base on the event's client X, Y. The return offset * position is relative to the Document body coordinate. * * @param event//w w w .j av a 2s . c om */ public OffsetPosition(Event event) { // convert the event's client coordinate system, which is client area base, to the // body position coordinate system. this.left = event.getClientX() + Window.getScrollLeft() - Document.get().getBodyOffsetLeft(); this.top = event.getClientY() + Window.getScrollTop() - Document.get().getBodyOffsetTop(); this.offsetParent = null; }
From source file:org.zanata.webtrans.client.ui.TooltipPopupPanel.java
License:Open Source License
private void position(final Element relativeObject, int offsetWidth, int offsetHeight) { int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left;//from w w w .jav a 2s .com 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:se.softhouse.garden.orchid.vaadin.widgetset.client.ui.VOrchidScrollTable.java
License:Open Source License
private void handleBodyContextMenu(ContextMenuEvent event) { if (this.enabled && this.bodyActionKeys != null) { int left = Util.getTouchOrMouseClientX(event.getNativeEvent()); int top = Util.getTouchOrMouseClientY(event.getNativeEvent()); top += Window.getScrollTop(); left += Window.getScrollLeft(); this.client.getContextMenu().showAt(this, left, top); // Only prevent browser context menu if there are action handlers // registered event.stopPropagation();/* w w w .ja v a 2 s .co m*/ event.preventDefault(); } }
From source file:se.umu.cs.ldbn.client.ui.window.WindowPanel.java
License:Apache License
public void show() { //this method is implemented very badly, we should find a better solution setVisible(true);/* w w w. j av a 2s. co m*/ Scheduler.get().scheduleDeferred(new Command() { public void execute() { //offset size is only available after the Widget is attached to the DOM int ow = getOffsetWidth(); int oh = getOffsetHeight(); int sl = Window.getScrollLeft(); int st = Window.getScrollTop(); int wcw = Window.getClientWidth(); int wch = Window.getClientHeight(); int left = (wcw - ow) >> 1; int top = (wch - oh) >> 1; left -= Document.get().getBodyOffsetLeft(); top -= Document.get().getBodyOffsetTop(); AbsolutePanel parent = (AbsolutePanel) getParent(); parent.setWidgetPosition(WindowPanel.this, sl + left, st + top); } }); }
From source file:stroom.widget.popup.client.view.PopupSupportImpl.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the * popup are known./*from w ww . j av a2s . c o m*/ */ private void positionPopup(final Popup popup, final PopupType popupType, final PopupPosition popupPosition, int offsetWidth, int offsetHeight) { int shadowWidth = 0; if (popupType != PopupType.POPUP) { shadowWidth = POPUP_SHADOW_WIDTH; } offsetWidth = offsetWidth - (2 * shadowWidth); offsetHeight = offsetHeight - (2 * shadowWidth); int left = -shadowWidth; if (HorizontalLocation.LEFT.equals(popupPosition.getHorizontalLocation())) { // Positioned to the left but aligned with the right edge of the // relative box. left = popupPosition.getRight() - offsetWidth + shadowWidth; } else { // Positioned to the right but aligned with the left edge of the // relative box. left = popupPosition.getLeft() - shadowWidth; } // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. final int windowRight = Window.getClientWidth() + Window.getScrollLeft(); final int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge of the // window final int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge of the // window final int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's width to // the right, and there IS enough space // for the overflow to the left, then show the popup on the left. If // there is not enough space on either side, then // position at the far left. if (distanceToWindowRight < offsetWidth) { if (distanceFromWindowLeft >= offsetWidth) { // Positioned to the left but aligned with the right edge of the // relative box. left = popupPosition.getRight() - offsetWidth + shadowWidth; } else { left = -shadowWidth; } } // Calculate top position for the popup int top = -shadowWidth; if (VerticalLocation.ABOVE.equals(popupPosition.getVerticalLocation())) { // Positioned above. top = popupPosition.getTop() - offsetHeight + shadowWidth; } else { // Default position is below. top = popupPosition.getBottom() - shadowWidth; } // Make sure scrolling is taken into account, since box.getAbsoluteTop() // takes scrolling into account. final int windowTop = Window.getScrollTop(); final int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the text // box. final int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the relative object. final int distanceToWindowBottom = windowBottom - top; // 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. If there is not enough // space above or below, then position at the very top. if (distanceToWindowBottom < offsetHeight) { if (distanceFromWindowTop >= offsetHeight) { // Positioned above. top = popupPosition.getTop() - offsetHeight + shadowWidth; } else { top = -shadowWidth; } } // Make sure the left and top positions are on screen. if (left + offsetWidth > windowRight) { left = windowRight - offsetWidth; } if (top + offsetHeight > windowBottom) { top = windowBottom - offsetHeight; } // Make sure left and top have not ended up less than 0. if (left < 0) { left = 0; } if (top < 0) { top = 0; } popup.setPopupPosition(left, top); }