List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:edu.caltech.ipac.firefly.visualize.WebMouseReadout.java
private ScreenPt adjustXY(int x, int y) { int popWidth = _popupPanel.getPopupPanel().getOffsetWidth(); int popHeight = _popupPanel.getPopupPanel().getOffsetHeight(); int bWidth = Window.getClientWidth(); int bHeight = Window.getClientHeight(); int sx = Window.getScrollLeft(); int sy = Window.getScrollTop(); if (x + popWidth > bWidth) x = (bWidth - popWidth) + sx;/* w w w . j a va2s . c o m*/ if (y + popHeight > bHeight) y = (bHeight - popHeight) + sy; if (x < sx) x = sx; if (y < sy) y = sy; return new ScreenPt(x, y); }
From source file:fr.putnami.pwt.core.widget.client.Affix.java
License:Open Source License
public void resetPosistion() { if (!this.isVisible()) { return;//from w ww . j a v a 2 s. c om } int scrollTop = Window.getScrollTop(); int docHeigth = Document.get().getScrollHeight(); this.getElement().getStyle().clearHeight(); this.offsetHeight = this.getElement().getClientHeight(); int top = this.pinnedOffset - scrollTop - this.offsetTop; int bottom = docHeigth - scrollTop - this.offsetBottom - this.offsetTop - this.offsetHeight; if (bottom <= 0 || this.fixBottom != Integer.MIN_VALUE) { this.toggleAffix(Affixed.BOTTOM); } else if (top >= 0) { this.toggleAffix(Affixed.TOP); } else { this.toggleAffix(Affixed.AFFIX); } }
From source file:fr.putnami.pwt.core.widget.client.Affix.java
License:Open Source License
protected void toggleAffix(Affixed affix) { Element e = this.getElement(); Style style = e.getStyle();//from w w w. j av a2s .com if (this.affixed != affix) { this.clearElementStyle(); this.affixed = affix; StyleUtils.addStyle(e, this.affixed); } switch (affix) { case AFFIX: style.setTop(this.offsetTop, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX); break; case BOTTOM: int docHeigth = Document.get().getScrollHeight(); int scrollTop = Window.getScrollTop(); int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth); if (this.fixBottom != Integer.MIN_VALUE) { bottom = Math.max(bottom, this.fixBottom); } style.setPosition(Position.FIXED); style.setBottom(bottom, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); break; default: break; } }
From source file:fr.putnami.pwt.core.widget.client.base.SimpleDropdown.java
License:Open Source License
@Override public void open() { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN); Element menuElt = this.menuContainer.getElement(); int topMenu = menuElt.getAbsoluteTop() - Window.getScrollTop(); int menuHeight = menuElt.getOffsetHeight(); int anchorHeight = this.anchor.getOffsetHeight(); int clientHeight = Window.getClientHeight(); if (topMenu + menuHeight > clientHeight && topMenu >= anchorHeight + menuHeight) { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_UP); }//from w ww. ja v a 2 s.c o m int leftMenu = menuElt.getAbsoluteLeft() - Window.getScrollLeft(); int menuWidth = menuElt.getOffsetWidth(); int anchorWidth = this.anchor.getOffsetWidth(); int clientWidth = Window.getClientWidth(); if (leftMenu + menuWidth > clientWidth && leftMenu >= anchorWidth + menuWidth) { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_LEFT); } this.open = true; this.updateHandlers(); }
From source file:geogebra.web.gui.util.PopupPanel.java
License:Apache License
/** * Centers the popup in the browser window and shows it. If the popup was * already showing, then the popup is centered. */// w ww .j av a 2 s . c om public void center() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false); setAnimationEnabled(false); show(); } // If left/top are set from a previous center() call, and our content // has changed, we may get a bogus getOffsetWidth because our new content // is wrapping (giving a lower offset width) then it would without the // previous left. Setting left/top back to 0 avoids this. Element elem = getElement(); elem.getStyle().setPropertyPx("left", 0); elem.getStyle().setPropertyPx("top", 0); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; int top = (Window.getClientHeight() - getOffsetHeight()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); // Run the animation. The popup is already visible, so we can skip the // call to setState. if (initiallyAnimated) { impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)"); setVisible(true); resizeAnimation.run(ANIMATION_DURATION); } else { setVisible(true); } } }
From source file:geogebra.web.gui.view.algebra.RadioButtonTreeItem.java
License:Open Source License
private void onRightClick(int x, int y) { if (av.isEditing() || isThisEdited() || newCreationMode) return;//from www . j a v a 2s .co m SelectionManager selection = app.getSelectionManager(); GPoint point = new GPoint(x + Window.getScrollLeft(), y + Window.getScrollTop()); if (geo != null) { if (selection.containsSelectedGeo(geo)) {// popup // menu for // current // selection // (including // selected // object) ((GuiManagerW) app.getGuiManager()).showPopupMenu(selection.getSelectedGeos(), av, point); } else {// select only this object and popup menu selection.clearSelectedGeos(false); selection.addSelectedGeo(geo, true, true); ArrayList<GeoElement> temp = new ArrayList<GeoElement>(); temp.add(geo); ((GuiManagerW) app.getGuiManager()).showPopupMenu(temp, av, point); } } }
From source file:io.apiman.manager.ui.client.local.services.MouseOverService.java
License:Apache License
/** * Returns true if the mouse coordinates fall within the bounding box * of the given widget./* www . j a v a2 s. c o m*/ * @param w * @param info * @param clientX * @param clientY */ private boolean isMouseInWidget(Widget w, WidgetMouseTrackingInfo info, int clientX, int clientY) { try { int top = w.getElement().getAbsoluteTop() - Window.getScrollTop() - info.extraTop; int bottom = top + w.getElement().getClientHeight() + info.extraBottom; int left = w.getElement().getAbsoluteLeft() - Window.getScrollLeft() - info.extraLeft; int right = left + w.getElement().getClientWidth() + info.extraRight; // logger.info("Client: {0},{1} Widget: {2},{3} -> {4},{5}", clientX, clientY, left, top, right, bottom); return clientX >= left && clientX <= right && clientY >= top && clientY <= bottom; } catch (Throwable t) { return false; } }
From source file:jetbrains.jetpad.cell.toDom.CellContainerToDomMapper.java
License:Apache License
@Override protected void onAttach(MappingContext ctx) { super.onAttach(ctx); getSource().setCellContainerPeer(createCellContainerPeer()); disablePopup(getTarget());/*from w w w . j a va 2 s.c o m*/ getTarget().setTabIndex(0); getTarget().addClassName(CSS.rootContainer()); getTarget().appendChild(myLineHighlight1); getTarget().appendChild(myLineHighlight2); getTarget().appendChild(myContent); refreshLineHighlight(); myScrollLeft = Window.getScrollLeft(); myScrollTop = Window.getScrollTop(); myWindowReg = Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override public void onWindowScroll(Window.ScrollEvent event) { myScrollLeft = event.getScrollLeft(); myScrollTop = event.getScrollTop(); } }); }
From source file:jetbrains.jetpad.cell.toDom.PopupPositioner.java
License:Apache License
private Rectangle getVisiblePart() { if (DomUtil.hasScrollers(myContext.rootElement)) { return DomUtil.visiblePart(myContext.rootElement); } else {/*from ww w .j a va 2s. com*/ return new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); } }
From source file:jetbrains.jetpad.projectional.domUtil.DomUtil.java
License:Apache License
public static Rectangle visiblePart(Element ctx, Rectangle rect) { while (true) { if (ctx.getOffsetParent() == null) { Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); return visibleArea.intersect(rect); } else {/*from ww w . j av a2 s. c o m*/ Rectangle visible; if (hasScroller(ctx)) { visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight()); Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop()); rect = rect.sub(scroll); } else { visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight()); } Rectangle newRect = visible.intersect(rect); Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop()); ctx = ctx.getOffsetParent(); rect = newRect.add(offset); } } }