Example usage for com.google.gwt.user.client Window getScrollLeft

List of usage examples for com.google.gwt.user.client Window getScrollLeft

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getScrollLeft.

Prototype

public static int getScrollLeft() 

Source Link

Usage

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.//from  w  ww  .ja 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 www  .j  ava2s.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  w ww .  jav a  2 s.c  om
        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 w  ww .  j a va2s  .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);
        }
    }
}

From source file:jetbrains.jetpad.projectional.view.toGwt.ViewContainerToElementMapper.java

License:Apache License

private void update() {
    Rectangle newRect = new Rectangle(Window.getScrollLeft() - myRootDiv.getAbsoluteLeft(),
            Window.getScrollTop() - myRootDiv.getAbsoluteTop(), Window.getClientWidth(),
            Window.getClientHeight());
    if (myVisibleArea.get() != null && myVisibleArea.get().contains(newRect))
        return;/*w ww .ja v  a2s.c  o m*/
    myVisibleArea.set(expand(newRect));
}

From source file:jetbrains.jetpad.projectional.view.toGwt.ViewContainerToElementMapper.java

License:Apache License

private MouseEvent toMouseEvent(Event e) {
    int cx = e.getClientX();
    int cy = e.getClientY();

    int scrollLeft = Window.getScrollLeft();
    int scrollTop = Window.getScrollTop();

    int absoluteLeft = myRootDiv.getAbsoluteLeft();
    int absoluteTop = myRootDiv.getAbsoluteTop();

    int elScrollTop = myRootDiv.getScrollTop();
    int elScrollLeft = myRootDiv.getScrollLeft();

    int x = cx + scrollLeft - absoluteLeft + elScrollLeft;
    int y = cy + scrollTop - absoluteTop + elScrollTop;

    return new MouseEvent(x, y);
}

From source file:net.auroris.ColorPicker.client.SliderMap.java

License:GNU Affero Public License

/**
 * Fired whenever a browser event is received.
 * @param event Event to process/*  www . j  a  v  a2 s .  c om*/
 */
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEUP:
        Event.releaseCapture(this.getElement());
        capturedMouse = false;
        break;
    case Event.ONMOUSEDOWN:
        Event.setCapture(this.getElement());
        capturedMouse = true;
    case Event.ONMOUSEMOVE:
        if (capturedMouse) {
            DOM.eventPreventDefault(event);

            int x = DOM.eventGetClientX(event) - colorUnderlay.getAbsoluteLeft() + 1 + Window.getScrollLeft();
            int y = DOM.eventGetClientY(event) - colorUnderlay.getAbsoluteTop() + 1 + Window.getScrollTop();

            if (x < 0)
                x = 0;
            if (x > 128)
                x = 128;
            if (y < 0)
                y = 0;
            if (y > 128)
                y = 128;

            DOM.setStyleAttribute(slider.getElement(), "left", x - 7 + "px");
            DOM.setStyleAttribute(slider.getElement(), "top", y - 7 + "px");

            if (parent != null) {
                parent.onMapSelected(x, y);
            }
        }
    }
}

From source file:net.dancioi.jcsphotogallery.client.view.PopupGeneric.java

License:Open Source License

private void initialize() {
    browserWindowWidth = Window.getClientWidth();
    browserWindowHeight = Window.getClientHeight();
    browserScrollLeft = Window.getScrollLeft();
    browserScrollTop = Window.getScrollTop();
}

From source file:net.sf.mmm.client.ui.gwt.widgets.PopupWindow.java

License:Apache License

/**
 * {@inheritDoc}/*w w  w  .  j  a v  a 2s . co  m*/
 */
@Override
public void setMaximized(boolean maximized) {

    if (this.maximized == maximized) {
        return;
    }
    if (maximized) {
        this.savedX = getAbsoluteLeft();
        this.savedY = getAbsoluteTop();
        this.savedWidth = getOffsetWidth();
        this.savedHeight = getOffsetHeight();
        setPopupPosition(Window.getScrollLeft(), Window.getScrollTop());
        setPixelSize(Window.getClientWidth(), Window.getClientHeight());
        if (this.movable) {
            this.titleBar.removeStyleName(CssStyles.MOVABLE);
        }
        if (this.resizable) {
            doSetResizable(false);
        }
    } else {
        setPopupPosition(this.savedX, this.savedY);
        setPixelSize(this.savedWidth, this.savedHeight);
        if (this.movable) {
            this.titleBar.addStyleName(CssStyles.MOVABLE);
        }
        if (this.resizable) {
            doSetResizable(true);
        }
    }
    this.maximized = maximized;
    this.maximizeButton.setValue(Boolean.valueOf(maximized), false);
}

From source file:next.celebs.page.SearchImageWidget.java

License:Apache License

void setPopupPosition(Photo p, OverlayPopup popup) {
    int w = p.getWidth() > 1024 ? 1024 : p.getWidth();
    int h = p.getHeight() > 550 ? 550 : p.getHeight();
    int left = (Window.getClientWidth() - w) >> 1;
    int top = (Window.getClientHeight() - h) >> 1;
    popup.setPopupPosition(Math.max(Window.getScrollLeft() + left, 0),
            Math.max(Window.getScrollTop() + top, 0));
}