List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:org.freemedsoftware.gwt.client.widget.CustomCanvas.java
License:Open Source License
/** * Calculate relative Y coordinate on the Canvas element from a * <HasNativeEvent> event./*w w w. ja va 2 s . c om*/ * * @param event * @return */ public int getYCoordFromEvent(HasNativeEvent event) { return event.getNativeEvent().getClientY() - getAbsoluteTop() + Window.getScrollTop(); }
From source file:org.freemedsoftware.gwt.client.widget.Toaster.java
License:Open Source License
protected void refreshDisplay() { // If there are items... if (items.keySet().size() > 0) { // Set positioning at bottom left of screen try {/*from w w w. j a v a2 s. c o m*/ hide(); } catch (Exception e) { GWT.log("Exception", e); } // Loop through and set CSS properly Iterator<String> ks = items.keySet().iterator(); while (ks.hasNext()) { final String k = (String) ks.next(); if (!ks.hasNext()) { // If this is the last one, set to special ((HTML) itemWidgets.get(k)).setStylePrimaryName("freemed-ToasterItem-Last"); } else { // Otherwise regular style ((HTML) itemWidgets.get(k)).setStylePrimaryName("freemed-ToasterItem"); } } try { setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = (Window.getClientWidth() - offsetWidth) - 5; int top = (Window.getClientHeight() - offsetHeight) - 5; setPopupPosition(left, top + Window.getScrollTop()); } }); } catch (Exception e) { GWT.log("Exception attempting to popup toaster", e); } } else { hide(); } }
From source file:org.geomajas.gwt2.plugin.corewidget.example.client.sample.map.MapLegendDropDown.java
License:Open Source License
private int calculateTop(int offsetHeight) { // Calculate top position for the popup int top = this.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/*from w w w.j a va 2s .c om*/ int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + this.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 += this.getOffsetHeight(); } return top; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.BusyPopup.java
License:Apache License
public void rollDown() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false);// www . ja v a 2 s . c o m setAnimationEnabled(false); show(); } Element elem = getElement(); elem.getStyle().setPropertyPx("left", 0); elem.getStyle().setPropertyPx("top", 0); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; int top = -getOffsetHeight(); setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, -getOffsetHeight())); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); if (initiallyAnimated) { setVisible(true); rollAnimation.run(ANIMATION_DURATION); } else { setVisible(true); } } }
From source file:org.kie.dockerui.client.widgets.container.logs.KieContainerLogs.java
License:Apache License
private void updateTimerMillis() { final int secRemaining = (refreshMillis / 1000) - currentTimerSec; timeOutPopupCounterText.setText(Constants.INSTANCE.nextRefresh() + " " + secRemaining + "s"); timeOutPopupCounterPanel.setVisible(true); if (windowScrollHandlerRegistration == null) { windowScrollHandlerRegistration = Window.addWindowScrollHandler(windowScrollHandler); updateTimerMillisPosition(Window.getScrollTop()); }/*from w ww . j a v a 2s . c o m*/ }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.annotater.ImageAnnotater.java
License:Apache License
@Override public void onMouseDown(Event event) { super.onMouseDown(event); if (writing /* || processing */) { Log.debug("ImageAnnotater] Ignore mouse down event"); return;/* w w w . j av a 2s . com*/ } if (processing) { divElement.getParentElement().removeChild(divElement); } image = getRootImage(event); int[] absoluteTopLeft = Utils.getAbsoluteTopLeft(image, Document.get()); ax = event.getClientX() - absoluteTopLeft[1] + Window.getScrollLeft(); ay = event.getClientY() - absoluteTopLeft[0] + Window.getScrollTop(); bx = ax; by = ay; writing = true; processing = true; controller.disablePopupListeners(); addMap(ax, ay, bx, by, image); }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.annotater.ImageAnnotater.java
License:Apache License
@Override public void onMouseMove(Event event) { super.onMouseMove(event); if (!writing) { return;/*from w w w . j ava 2s . c o m*/ } String nodeName = event.getTarget().getNodeName(); if (nodeName.equalsIgnoreCase("img")) { ImageElement newImage = ImageElement.as(event.getTarget()); if ((!image.equals(newImage) || ax == -1 || ay == -1) && !controller.isMultiImage()) { refresh(); } } int[] absoluteTopLeft = Utils.getAbsoluteTopLeft(image, Document.get()); bx = event.getClientX() - absoluteTopLeft[1] + Window.getScrollLeft(); by = event.getClientY() - absoluteTopLeft[0] + Window.getScrollTop(); updateMap(ax, ay, bx, by, image); }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.annotater.ImageAnnotater.java
License:Apache License
@Override public void onMouseUp(Event event) { if (!hasMoved() && writing) { Log.debug("cancel mouse up image"); cancelMap();/*from ww w.j av a 2 s .com*/ controller.setNewAnnotationPopup(null); if (controller.isAnnotationsVisible()) { controller.enablePopupListeners(); } super.onMouseUp(event); return; } super.onMouseUp(event); if (!writing) { return; } String nodeName = event.getTarget().getNodeName(); if (nodeName.equalsIgnoreCase("img")) { ImageElement newImage = ImageElement.as(event.getTarget()); if ((!image.equals(newImage) || ax == -1 || ay == -1) && !controller.isMultiImage()) { refresh(); } } int[] absoluteTopLeft = Utils.getAbsoluteTopLeft(image, Document.get()); bx = event.getClientX() - absoluteTopLeft[1] + Window.getScrollLeft(); by = event.getClientY() - absoluteTopLeft[0] + Window.getScrollTop(); addMapAndGetAnnot(new int[] { ax, ay, bx, by }, image); if (controller.isAnnotationsVisible()) { controller.enablePopupListeners(); } writing = false; addAnnotationPopup(); controller.enablePopupListeners(); }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.listener.AnnotationPopupEventListener.java
License:Apache License
private void onEvent(Event event) { if (annotation == null || controller == null || !enabled) { AnnotationFrameApplication.getMainEventListener().onBrowserEvent(event); return;/* w ww .j a va 2 s . c om*/ } if (event.getTypeInt() == Event.ONMOUSEOVER) { if (!annotationPopup.isShown()) { annotationPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop()); annotationPopup.show(); } // reset the timer timer.cancel(); } else if (event.getTypeInt() == Event.ONMOUSEOUT) { timer.schedule(AnnotationConstant.POPUP_PANEL_BLINK_TIMEOUT_MILI); } }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.NewAnnotationPopup.java
License:Apache License
@Override public void show() { Log.debug("popup.show: " + Window.getScrollTop() + 50); setPopupPosition(50 + Window.getScrollLeft(), Window.getScrollTop() + 50); controller.openCreationPopup();// w w w .j a v a 2 s . c o m super.show(); }