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

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

Introduction

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

Prototype

public static int getScrollTop() 

Source Link

Usage

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * translates a <code>GraphicObject</code> if the current <code>GraphicObject</code>
 * is not null. Shows also the coordinate of the mouse
 *//* w w w  .  j  a va  2s . c om*/
public void mouseMoved(GraphicObject graphicObject, Event evt) {
    if (current != null) {
        int x = DOM.eventGetClientX(evt);
        int y = DOM.eventGetClientY(evt);
        int newX = x - canvas.getAbsoluteLeft() + Window.getScrollLeft();
        int newY = y - canvas.getAbsoluteTop() + Window.getScrollTop();
        html.setHTML(newX + "," + newY + " [" + x + "," + y + "]");
        popup.setPopupPosition(10 + newX + canvas.getAbsoluteLeft(), newY + canvas.getAbsoluteTop());
        Color color = current.getFillColor();
        Color reverseColor = color.reverse();
        reverseColor.setAlpha(255);
        DOM.setStyleAttribute(html.getElement(), "color", reverseColor.toHex());
        popup.show();
        if (movable) {

            if (current.getGroup() != null) {
                GraphicObject object = this.current.getGroup();
                object.translate(newX - lastPosition[0], newY - lastPosition[1]);

            } else {
                current.translate(newX - lastPosition[0], newY - lastPosition[1]);
            }

            lastPosition[0] = newX;
            lastPosition[1] = newY;
        }
    } else {
        popup.hide();
    }

}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Selects a <code>GraphicObject</code> when a mouse is pressed on a <code>GraphicObject</code>
 * in the canvas. Keeps also the postion of the mouse. The <code>GraphicObject</code>
 *  is also movable./* ww  w .j av  a 2  s.c  om*/
 */
public void mousePressed(GraphicObject graphicObject, Event evt) {
    if (graphicObject != null) {
        int x = DOM.eventGetClientX(evt);
        int y = DOM.eventGetClientY(evt);
        selectObject(graphicObject);
        movable = true;
        this.lastPosition[0] = x - canvas.getAbsoluteLeft() + Window.getScrollLeft();
        this.lastPosition[1] = y - canvas.getAbsoluteTop() + Window.getScrollTop();

    }

}

From source file:com.risevision.ui.client.common.widgets.colorPicker.SliderBar.java

License:Artistic License

/**
 * Fired whenever a browser event is received.
 * @param event Event to process//from   w  ww  .ja  v a  2 s . c o  m
 */
@Override
public void onBrowserEvent(Event 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) {
            event.preventDefault();

            if (vertical) {
                int y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop();

                if (y < 0)
                    y = 0;
                if (y > 256)
                    y = 256;

                slider.getElement().getStyle().setProperty("top", y - 4 + "px");

                if (parent != null) {
                    parent.onBarSelected(mode, y);
                }
            } else {
                int x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft();

                if (x < 0)
                    x = 0;
                if (x > 256)
                    x = 256;

                slider.getElement().getStyle().setProperty("left", 256 - x - 4 + "px");

                if (parent != null) {
                    parent.onBarSelected(mode, x);
                }
            }
        }
    }
}

From source file:com.risevision.ui.client.common.widgets.colorPicker.SliderMap.java

License:Artistic License

/**
 * Fired whenever a browser event is received.
 * @param event Event to process//from   w ww.  j  a  v a 2 s  .  co  m
 */
@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) {
            event.preventDefault();

            int x = event.getClientX() - colorUnderlay.getAbsoluteLeft() + 1 + Window.getScrollLeft();
            int y = event.getClientY() - colorUnderlay.getAbsoluteTop() + 1 + Window.getScrollTop();

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

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

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

From source file:com.risevision.ui.client.common.widgets.SliderBarWidget.java

License:Artistic License

/**
 * Fired whenever a browser event is received.
 * @param event Event to process/* ww  w.  j a  v  a2s  .c om*/
 */
@Override
public void onBrowserEvent(Event 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) {
            event.preventDefault();

            if (vertical) {
                int y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop() - 7;

                if (y < 0)
                    y = 0;
                if (y > length)
                    y = length;

                thumb.getStyle().setProperty("top", y - halfThumb + "px");

                pos = y;
            } else {
                int x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft() - 7;

                if (x < 0)
                    x = 0;
                if (x > length)
                    x = length;

                thumb.getStyle().setProperty("left", x - halfThumb + "px");

                pos = x;
            }
            if (onBarSelected != null) {
                onBarSelected.execute();
            }
        }
    }
}

From source file:com.risevision.ui.client.common.widgets.socialConnector.NetworkTypeSelectWidget.java

License:Open Source License

public NetworkTypeSelectWidget() {
    super("Add");
    MenuBar popupMenuBar = new MenuBar(true);

    for (final NetworkType networkType : NetworkType.values()) {
        MenuItem item = new MenuItem(networkType.getDefaultName(), true, new Command() {

            @Override/*from w  w  w  .j  av a 2 s .  c  o  m*/
            public void execute() {
                Window.open(networkType.getRequestUrl(), "_blank", "");
                menuPanel.hide();
            }
        });

        popupMenuBar.addItem(item);
    }

    //      MenuItem foursquareItem = new MenuItem(NetworkType.foursquare.getDefaultName(), true, 
    //            new Command() {
    //         
    //               @Override
    //               public void execute() {
    //                  Window.open(NetworkType.foursquare.getRequestUrl(), "_blank", "");
    //                  menuPanel.hide();
    //               }
    //            });
    //      MenuItem twitterItem = new MenuItem(RiseUtils.capitalizeFirstLetter(NetworkType.twitter.getDefaultName()), true, 
    //            new Command() {
    //         
    //               @Override
    //               public void execute() {
    //                  Window.open(NetworkType.twitter.getRequestUrl(), "_blank", "");
    //                  menuPanel.hide();
    //               }
    //            });
    //      
    //      popupMenuBar.addItem(foursquareItem);
    //      popupMenuBar.addItem(twitterItem);

    popupMenuBar.setVisible(true);
    menuPanel.add(popupMenuBar);

    addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            int x = event.getClientX() + Window.getScrollLeft() + 1;
            int y = event.getClientY() + Window.getScrollTop() + 1;
            menuPanel.setPopupPosition(x, y);
            menuPanel.show();
        }
    });
}

From source file:com.risevision.ui.client.presentation.common.ItemTypeSelectWidget.java

License:Open Source License

public ItemTypeSelectWidget(int row, boolean enableCopy) {
    super("Add");
    this.row = row;

    MenuItem copyItem = new MenuItem("Copy", true, new Command() {
        @Override/*  w w  w. jav a2  s. co m*/
        public void execute() {
            copyItem();
        }
    });

    final MenuItem pasteItem = new MenuItem("Paste", true, new Command() {
        @Override
        public void execute() {
            pasteItem();
        }
    });

    final MenuItem contentItem = new MenuItem("Content", true, new Command() {
        @Override
        public void execute() {
            final HashMap<String, Object> data = new HashMap<String, Object>();
            data.put("via", PlaceholderManageWidget.VIA_STORE);
            data.put("storePath", "products/");
            selectItem(PlaylistItemInfo.TYPE_GADGET, data);
        }
    });

    final MenuItem byUrlItem = new MenuItem("Content by URL", true, new Command() {
        @Override
        public void execute() {
            final HashMap<String, Object> data = new HashMap<String, Object>();
            data.put("via", GadgetSelectWidget.Content.SELECT_GADGET_BY_URL);
            selectItem(PlaylistItemInfo.TYPE_GADGET, data);
        }
    });

    final MenuItem byCompanyItem = new MenuItem("Your Content", true, new Command() {
        @Override
        public void execute() {
            final HashMap<String, Object> data = new HashMap<String, Object>();
            data.put("via", GadgetSelectWidget.Content.SELECT_GADGET_FROM_COMPANY);
            selectItem(PlaylistItemInfo.TYPE_GADGET, data);
        }
    });

    final MenuItem sharedGadgetsItem = new MenuItem("Content Shared with You", true, new Command() {
        @Override
        public void execute() {
            final HashMap<String, Object> data = new HashMap<String, Object>();
            data.put("via", GadgetSelectWidget.Content.SELECT_GADGET_FROM_SHARED);
            selectItem(PlaylistItemInfo.TYPE_GADGET, data);
        }
    });

    copyItem.setEnabled(enableCopy);

    popupMenuBar.addItem(copyItem);
    popupMenuBar.addItem(pasteItem);
    popupMenuBar.addSeparator();

    popupMenuBar.addItem(contentItem);

    addMenuOption(RiseUtils.capitalizeFirstLetter(PlaylistItemInfo.TYPE_TEXT), PlaylistItemInfo.TYPE_TEXT);
    addMenuOption(RiseUtils.capitalizeFirstLetter(PlaylistItemInfo.TYPE_PRESENTATION),
            PlaylistItemInfo.TYPE_PRESENTATION);
    addMenuOption(RiseUtils.capitalizeFirstLetter(PlaylistItemInfo.TYPE_IMAGE), PlaylistItemInfo.TYPE_IMAGE);
    //      addMenuOption(RiseUtils.capitalizeFirstLetter(PlaylistItemInfo.TYPE_VIDEO), PlaylistItemInfo.TYPE_VIDEO);
    addMenuOption(PlaylistItemInfo.TYPE_HTML, PlaylistItemInfo.TYPE_HTML);

    popupMenuBar.addSeparator();
    popupMenuBar.addItem(byUrlItem);
    popupMenuBar.addItem(byCompanyItem);
    popupMenuBar.addItem(sharedGadgetsItem);

    popupMenuBar.setVisible(true);
    menuPanel.add(popupMenuBar);

    addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            int x = event.getClientX() + Window.getScrollLeft() + 1;
            int y = event.getClientY() + Window.getScrollTop() + 1;
            menuPanel.setPopupPosition(x, y);

            pasteItem.setEnabled(enablePaste);

            menuPanel.show();
        }
    });
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.ContextMenu.java

License:Open Source License

public void showAt(Event e, int width) {
    if (vP != null) {
        int x = e.getClientX() + Window.getScrollLeft();
        int y = e.getClientY() + Window.getScrollTop();
        if (newPopup) {
            Popup.showRoundedPopup(vP, "", pp, x, y, width, false);
            newPopup = false;//from w ww.j  av  a  2  s  .c  o m
        } else {
            pp.setPopupPosition(x, y);
            pp.show();
        }
    } else {
        Popup.showErrorPopup("", Popup.ERROR_MSG_PREFIX.NONE, "Error. Contextmenu is empty.",
                Popup.ERROR_LVL.NORMAL, null);
    }
}

From source file:com.tasktop.c2c.server.tasks.client.widgets.TaskDetailsPopupPanel.java

License:Open Source License

public void showAt(final int targetAbsoluteLeft, final int targetAbsoluteTop, final int targetOffsetWidth,
        final int targetOffsetHeight) {
    setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        @Override//from   w  w  w.j  a  v  a 2  s .c om
        public void setPosition(int offsetWidth, int offsetHeight) {
            // There doesn't appear to be a reliable way to get the width and height of this popup from the element
            // itself, so I have to resort to hardcoded values (spent a couple of hours trying to get the right
            // values here - popup.getWidget().getElement().getClientHeight() returned the correct height, but the
            // width was way off
            int popupWidth = 297;
            int popupHeight = 350;
            int anchorRight = targetAbsoluteLeft + targetOffsetWidth;
            int anchorBottom = targetAbsoluteTop + targetOffsetHeight;
            int windowRight = Window.getClientWidth() + Window.getScrollLeft();
            int windowBottom = Window.getScrollTop() + Window.getClientHeight();

            // By default, set our left and top to be just below the Anchor's bottom right corner.
            int popupLeft = anchorRight;
            int popupTop = anchorBottom;

            if ((popupLeft + popupWidth) > windowRight) {
                // If there's not enough space to the right, then make sure our popup is touching the
                // right edge of the screen
                popupLeft = windowRight - popupWidth;
            }

            if ((popupTop + popupHeight) > windowBottom) {
                // If there's not enough space at the bottom, then make sure our popup is touching the
                // bottom edge of the screen
                popupTop = windowBottom - popupHeight;
            }
            setPopupPosition(popupLeft, popupTop);
        }
    });
}

From source file:com.thinqq.qsports.client.userprofile.UserProfileViewImpl.java

License:Open Source License

@Override
public void showCreateTeamView(EditTeamProfile newTeamView) {
    newTeamView.setPopupPosition(Window.getScrollLeft() + 200, Window.getScrollTop() + 200);
    newTeamView.show();

}