Example usage for com.google.gwt.user.client.ui Widget getAbsoluteTop

List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getAbsoluteTop.

Prototype

public int getAbsoluteTop() 

Source Link

Document

Gets the object's absolute top position in pixels, as measured from the browser window's client area.

Usage

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Returns true if the target widget is vertically scrolled into view.
 *
 * @param minPixels the minimum number of pixels that must be visible to count as "in view".
 *///ww  w .  j  av  a 2  s .c  o m
public static boolean isScrolledIntoView(Widget target, int minPixels) {
    int wtop = Window.getScrollTop(), wheight = Window.getClientHeight();
    int ttop = target.getAbsoluteTop();
    if (ttop > wtop) {
        return (wtop + wheight - ttop > minPixels);
    } else {
        return (ttop + target.getOffsetHeight() - wtop > minPixels);
    }
}

From source file:com.totsp.gwittir.client.ui.table.GridForm.java

License:Open Source License

private void render() {
    if (this.binding.getChildren().size() > 0) {
        this.binding.unbind();
        this.binding.getChildren().clear();
    }/*from   ww  w. j a v a  2s .  c om*/

    int row = 0;

    for (int i = 0; i < this.fields.length;) {
        for (int col = 0; (col < this.columns) && (i < fields.length); col++) {
            final Field field = this.fields[i];

            if (field == null) {
                i++;

                continue;
            }

            Widget widget = (Widget) this.createWidget(this.binding, field,
                    (SourcesPropertyChangeEvents) this.getValue());
            Label label = new Label(field.getLabel());
            this.base.setWidget(row, col * 2, label);
            this.base.getCellFormatter().setStyleName(row, col * 2, "label");
            this.base.setWidget(row, (col * 2) + 1, widget);
            this.base.getCellFormatter().setStyleName(row, (col * 2) + 1, "field");

            if (field.getHelpText() != null) {
                label.addClickListener(new ClickListener() {
                    public void onClick(Widget widget) {
                        final PopupPanel p = new PopupPanel(true);
                        p.setStyleName("gwittir-GridForm-Help");
                        p.setWidget(new HTML(field.getHelpText()));
                        p.setPopupPosition(widget.getAbsoluteLeft(),
                                widget.getAbsoluteTop() + widget.getOffsetHeight());
                        p.show();
                    }
                });
            }

            i++;
        }

        row++;
    }
}

From source file:com.totsp.gwittir.client.validator.PopupValidationFeedback.java

License:Open Source License

public void handleException(Object source, ValidationException exception) {
    final Widget w = (Widget) source;
    final PopupPanel p = new PopupPanel(false);
    popups.put(source, p);/* www .  j  av a  2 s .  c o m*/
    p.setStyleName("gwittir-ValidationPopup");
    p.setWidget(new Label(this.getMessage(exception)));
    p.setPopupPosition(-5000, -5000);
    p.show();
    if (this.position == BOTTOM) {
        p.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop() + w.getOffsetHeight());
    } else if (this.position == RIGHT) {
        p.setPopupPosition(w.getAbsoluteLeft() + w.getOffsetWidth(), w.getAbsoluteTop());
    } else if (this.position == LEFT) {
        p.setPopupPosition(w.getAbsoluteLeft() - p.getOffsetWidth(), w.getAbsoluteTop());
    } else if (this.position == TOP) {
        p.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop() - p.getOffsetHeight());
    }
    if (w instanceof SourcesPropertyChangeEvents) {
        GWT.log("is PCE", null);
        PropertyChangeListener attachListener = new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                if (((Boolean) propertyChangeEvent.getNewValue()).booleanValue()) {
                    p.setVisible(true);
                } else {
                    p.setVisible(false);
                }
            }

        };
        listeners.put(w, attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("attached", attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("visible", attachListener);
    }
}

From source file:com.vaadin.client.VUIDLBrowser.java

License:Apache License

static void highlight(ComponentConnector paintable) {
    if (paintable != null) {
        Widget w = paintable.getWidget();
        Style style = highlight.getStyle();
        style.setTop(w.getAbsoluteTop(), Unit.PX);
        style.setLeft(w.getAbsoluteLeft(), Unit.PX);
        style.setWidth(w.getOffsetWidth(), Unit.PX);
        style.setHeight(w.getOffsetHeight(), Unit.PX);
        RootPanel.getBodyElement().appendChild(highlight);
    }//w  w w  . j  a  v  a 2  s .  c om
}

From source file:com.vaadin.terminal.gwt.client.VUIDLBrowser.java

License:Open Source License

static void highlight(Paintable paintable) {
    Widget w = (Widget) paintable;
    if (w != null) {
        Style style = highlight.getStyle();
        style.setTop(w.getAbsoluteTop(), Unit.PX);
        style.setLeft(w.getAbsoluteLeft(), Unit.PX);
        style.setWidth(w.getOffsetWidth(), Unit.PX);
        style.setHeight(w.getOffsetHeight(), Unit.PX);
        RootPanel.getBodyElement().appendChild(highlight);
    }//from  w  w  w .j a  v  a2  s. c  o m
}

From source file:com.xpn.xwiki.gwt.api.client.app.XWikiGWTDefaultApp.java

License:Open Source License

public static int getAbsoluteTop(Widget widget) {
    if (isMSIE())
        return widget.getAbsoluteTop();
    else if (widget instanceof ScrollPanel)
        return widget.getAbsoluteTop() + ((ScrollPanel) widget).getScrollPosition();
    else//w ww.j ava  2 s  . com
        return widget.getAbsoluteTop();
}

From source file:com.youtube.statistics.client.RecentQueriesPanel.java

License:Apache License

public RecentQueriesPanel(Widget parent) {
    panel = new VerticalPanel();
    panel.addStyleName("recentQueriesPanel");

    // Calculate the position to be twice the width of the button, and align
    // with the right hand edge of the parent, allowing for a margin.
    int margin = 2;
    int width = 2 * parent.getOffsetWidth();
    int top = parent.getAbsoluteTop() + parent.getOffsetHeight() + margin;
    int right = parent.getAbsoluteLeft() + parent.getOffsetWidth() - margin;
    int left = right - width;

    panel.getElement().getStyle().setPropertyPx("left", left);
    panel.getElement().getStyle().setPropertyPx("top", top);
    panel.getElement().getStyle().setPropertyPx("width", width);
    panel.setVisible(false);/*from ww  w .  j ava 2 s .  co  m*/
}

From source file:de.eckhartarnold.client.MovablePopupPanel.java

License:Apache License

private boolean isTargetChildWidget(NativeEvent event) {
    Widget child = getWidget();
    Element target = Element.as(event.getEventTarget());
    int x = child.getAbsoluteLeft();
    int y = child.getAbsoluteTop();
    int w = child.getOffsetWidth();
    int h = Toolbox.getOffsetHeight(child);
    int ex = event.getClientX();
    int ey = event.getClientY();

    return (ex >= x && ey >= y && ex < x + w && ey < y + h)
            || this.getWidget().getElement().isOrHasChild(target);
}

From source file:de.eckhartarnold.client.Tooltip.java

License:Apache License

public void onMouseOver(MouseOverEvent event) {
    Widget sender = (Widget) event.getSource();
    timer.posX = sender.getAbsoluteLeft() + sender.getOffsetWidth() - X_OFFSET;
    timer.posY = sender.getAbsoluteTop() + Toolbox.getOffsetHeight(sender) - Y_OFFSET;
    timerExpired = false;/*from  w ww  .ja va 2 s . c  om*/
    if (limit != 0)
        timer.schedule(delay);
}

From source file:edu.caltech.ipac.firefly.ui.background.BackgroundGroupsDialog.java

private void animateHide() {
    Widget w = getDialogWidget();
    int cX = w.getAbsoluteLeft() + w.getOffsetWidth() / 2;
    int cY = w.getAbsoluteTop() + w.getOffsetHeight() / 2;

    if (getVisibleCnt() > 0) {
        Application.getInstance().getBackgroundManager().animateToManager(cX, cY, 500);
    }/*from  w w w. ja v a2 s.c om*/
}