Example usage for com.google.gwt.dom.client SpanElement getStyle

List of usage examples for com.google.gwt.dom.client SpanElement getStyle

Introduction

In this page you can find the example usage for com.google.gwt.dom.client SpanElement getStyle.

Prototype

@Override
    public Style getStyle() 

Source Link

Usage

From source file:com.google.speedtracer.client.util.dom.ImageResourceElementCreator.java

License:Apache License

public static Element createElementFrom(ImageResource resource) {
    SpanElement img = DocumentExt.get().createSpanElement();
    String style = "url(" + resource.getURL() + ") no-repeat " + (-resource.getLeft() + "px ")
            + (-resource.getTop() + "px");
    img.getStyle().setProperty("background", style);
    img.getStyle().setPropertyPx("width", resource.getWidth());
    img.getStyle().setPropertyPx("height", resource.getHeight());
    img.getStyle().setDisplay(Display.INLINE_BLOCK);
    return img;//from   ww  w.  j a  va2 s  .  c  o  m
}

From source file:com.smartgwt.mobile.client.widgets.layout.NavigationBar.java

License:Open Source License

@SGWTInternal
public void _layOutMembers() {
    if (!isAttached())
        return;//from ww  w.  j a  va2s  . com
    if (!isVisible() || !navStack.isVisible())
        return;
    if (layoutTimer == null) {
        layoutTimer = new Timer() {

            @Override
            public void run() {
                final float _1vw = Window.getClientWidth(); // 1 viewport width
                final NavigationItem item = ensureItem();
                final Header1 titleView = item.getTitleView();
                final float minTitleViewWidth, titleViewContentWidth;
                if (titleView == null) {
                    minTitleViewWidth = 0.0f;
                    titleViewContentWidth = 0.0f;
                } else {
                    final SpanElement span = titleView._getSpan();
                    span.getStyle().clearPadding();
                    final float titleViewWidth = ElementUtil.getOuterWidth(titleView.getElement(), true);
                    minTitleViewWidth = titleViewWidth - titleView.getElement().getClientWidth();
                    titleViewContentWidth = span.getOffsetWidth();
                }
                final float titleViewAutoWidth = minTitleViewWidth + titleViewContentWidth;
                final NavigationButton leftButton = item.getLeftButton();
                final Canvas rightBarItem = item.getRightBarItem();
                final float leftButtonHMargin, absoluteMinLeftButtonWidth, leftButtonContentWidth;
                if (leftButton == null) {
                    leftButtonHMargin = 0.0f;
                    absoluteMinLeftButtonWidth = 0.0f;
                    leftButtonContentWidth = 0.0f;
                } else {
                    final Element element = leftButton.getElement();
                    leftButtonHMargin = ElementUtil.getHMarginWidth(element);
                    absoluteMinLeftButtonWidth = ElementUtil.getMinMarginBoxWidth(element);
                    leftButtonContentWidth = leftButton._getContentWidth();
                }
                final float rightBarItemHMargin, absoluteMinRightBarItemWidth, rightBarItemContentWidth;
                if (rightBarItem == null) {
                    rightBarItemHMargin = 0.0f;
                    absoluteMinRightBarItemWidth = 0.0f;
                    rightBarItemContentWidth = 0.0f;
                } else {
                    final Element element = rightBarItem.getElement();
                    rightBarItemHMargin = ElementUtil.getHMarginWidth(element);
                    absoluteMinRightBarItemWidth = ElementUtil.getMinMarginBoxWidth(element);
                    rightBarItemContentWidth = ((NavigationBarItem) rightBarItem)._getContentWidth();
                }
                final float leftButtonAutoWidth = absoluteMinLeftButtonWidth + leftButtonContentWidth,
                        rightBarItemAutoWidth = absoluteMinRightBarItemWidth + rightBarItemContentWidth;

                final float totalWidth = titleViewAutoWidth + leftButtonAutoWidth + rightBarItemAutoWidth;

                float newLeftButtonMarginBoxWidth = 0.0f, newRightButtonMarginBoxWidth = 0.0f;
                if (totalWidth + 0.000001f >= _1vw) {
                    final float minLeftButtonWidth = leftButton == null ? 0.0f
                            : absoluteMinLeftButtonWidth + Math.min(53.0f, leftButtonContentWidth),
                            minRightBarItemWidth = rightBarItem == null ? 0.0f
                                    : absoluteMinRightBarItemWidth + (rightBarItem instanceof NavigationButtons
                                            ? rightBarItemContentWidth
                                            : Math.min(53.0f, rightBarItemContentWidth));
                    assert minLeftButtonWidth <= leftButtonAutoWidth + 0.000001f;
                    assert minRightBarItemWidth <= rightBarItemAutoWidth + 0.000001f;

                    final float r = _1vw - titleViewAutoWidth - minLeftButtonWidth - minRightBarItemWidth;
                    if (r < 0.000001f) {
                        newLeftButtonMarginBoxWidth = minLeftButtonWidth;
                        newRightButtonMarginBoxWidth = minRightBarItemWidth;
                    } else { // The title gets as much width as it needs while still giving the left and/or right
                             // buttons a minimum client width (at most 53px).  The remaining width is distributed to
                             // the left and right buttons.
                        if (leftButton != null || rightBarItem != null) {
                            final float denominator = leftButtonAutoWidth - minLeftButtonWidth
                                    + rightBarItemAutoWidth - minRightBarItemWidth;
                            if (denominator < 2.0f + 0.000001f) {
                                newLeftButtonMarginBoxWidth = minLeftButtonWidth;
                                newRightButtonMarginBoxWidth = minRightBarItemWidth;
                            } else {
                                newLeftButtonMarginBoxWidth = minLeftButtonWidth
                                        + (leftButtonAutoWidth - minLeftButtonWidth) / denominator * r;
                                newRightButtonMarginBoxWidth = minRightBarItemWidth
                                        + (rightBarItemAutoWidth - minRightBarItemWidth) / denominator * r;
                            }
                        }
                    }
                } else {
                    newLeftButtonMarginBoxWidth = leftButtonAutoWidth;
                    newRightButtonMarginBoxWidth = rightBarItemAutoWidth;

                    final float leftButtonExtra = Math.max(0.0f, leftButtonAutoWidth - rightBarItemAutoWidth),
                            rightButtonExtra = Math.max(0.0f, rightBarItemAutoWidth - leftButtonAutoWidth);
                    float r = _1vw - totalWidth;
                    assert r + 0.000001f >= 0.0f;
                    if (titleView != null) {
                        if (r + 0.000001f >= leftButtonExtra + rightButtonExtra) {
                            final float rightPadding = leftButtonExtra, leftPadding = rightButtonExtra;
                            final SpanElement span = titleView._getSpan();
                            final Style spanStyle = span.getStyle();
                            spanStyle.setPaddingRight(rightPadding, Unit.PX);
                            spanStyle.setPaddingLeft(leftPadding, Unit.PX);
                        } else {
                            if (leftButtonExtra + 0.000001f >= rightButtonExtra) {
                                final float rightPadding = r;
                                final SpanElement span = titleView._getSpan();
                                span.getStyle().setPaddingRight(rightPadding, Unit.PX);
                            } else {
                                final float leftPadding = r;
                                final SpanElement span = titleView._getSpan();
                                span.getStyle().setPaddingLeft(leftPadding, Unit.PX);
                            }
                        }
                    }
                }
                if (leftButton != null) {
                    ElementUtil.setBorderBoxWidth(leftButton.getElement(),
                            newLeftButtonMarginBoxWidth - leftButtonHMargin);
                }
                if (rightBarItem != null) {
                    ElementUtil.setBorderBoxWidth(rightBarItem.getElement(),
                            newRightButtonMarginBoxWidth - rightBarItemHMargin);
                }
                if (titleView != null) {
                    // Instead of setting the left and right padding, set the `left' and `right'
                    // CSS properties.
                    // There is a WebKit bug that affects iOS 6 where left and right padding
                    // is incorrectly factored into the calculation of how wide the <h1>
                    // element is for the purpose of centering the text.
                    // https://bugs.webkit.org/show_bug.cgi?id=75277
                    titleView.getElement().getStyle().setLeft(newLeftButtonMarginBoxWidth, Unit.PX);
                    titleView.getElement().getStyle().setRight(newRightButtonMarginBoxWidth, Unit.PX);
                    titleView.getElement().getStyle().clearVisibility();
                }

                layoutTimer = null;
            } // run()
        };
        layoutTimer.schedule(1);
    }
}

From source file:geogebra.web.gui.view.algebra.RadioButtonTreeItem.java

License:Open Source License

private static void updateNewStatic(SpanElement se) {
    se.getStyle().setProperty("display", "-moz-inline-box");
    se.getStyle().setDisplay(Style.Display.INLINE_BLOCK);
    se.setDir("ltr");
}

From source file:geogebra.web.gui.view.algebra.RadioButtonTreeItem.java

License:Open Source License

private void updateColor(SpanElement se) {
    if (geo != null) {
        se.getStyle().setColor(GColor.getColorString(geo.getAlgebraColor()));
    }
}

From source file:org.dashbuilder.client.cms.widget.PerspectivesExplorerView.java

License:Apache License

@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);/*from   w ww .  ja  v  a  2s.  co m*/

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("fa fa-file-text-o");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] { icon, anchor });
    perspectivesDiv.appendChild((Node) gi);
}

From source file:org.uberfire.ext.widgets.common.client.dropdown.LiveSearchDropDownView.java

License:Apache License

@Override
public void noItems(String msg) {
    removeAllChildren(dropDownMenu);/*from  w ww.  j a v  a  2  s .c  om*/
    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(msg);
    span.getStyle().setPropertyPx("marginLeft", 10);
    dropDownMenu.appendChild((Node) span);
}