Example usage for com.google.gwt.dom.client Style setRight

List of usage examples for com.google.gwt.dom.client Style setRight

Introduction

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

Prototype

public void setRight(double value, Unit unit) 

Source Link

Usage

From source file:com.alkacon.geranium.client.util.DebugLog.java

License:Open Source License

/**
 * Constructor.<p>/*from   ww  w  .ja  v  a2  s.  c  om*/
 */
@SuppressWarnings("unused")
private DebugLog() {

    if (!DEBUG) {
        return;
    }
    m_html = new HTML();
    initWidget(m_html);
    Style style = getElement().getStyle();
    style.setWidth(200, Unit.PX);
    style.setHeight(500, Unit.PX);
    style.setPadding(10, Unit.PX);
    style.setOverflow(Overflow.AUTO);
    style.setBorderStyle(BorderStyle.SOLID);
    style.setBorderColor(I_LayoutBundle.INSTANCE.constants().css().borderColor());
    style.setBorderWidth(1, Unit.PX);
    style.setPosition(Position.FIXED);
    style.setTop(50, Unit.PX);
    style.setRight(50, Unit.PX);
    style.setBackgroundColor(I_LayoutBundle.INSTANCE.constants().css().backgroundColorDialog());
    style.setZIndex(10);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout.CubaFieldGroupLayoutComponentSlot.java

License:Apache License

@Override
public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) {
    if (!isCaptionInline()) {
        super.positionHorizontally(currentLocation, allocatedSpace, marginRight);
        return;// ww  w  .j a  v  a 2  s . co  m
    }

    // CAUTION copied from VLayoutSlot.positionHorizontally(~)

    Style style = wrapper.getStyle();

    double availableWidth = allocatedSpace;

    VCaption caption = getCaption();
    Style captionStyle = caption != null ? caption.getElement().getStyle() : null;
    int captionWidth = getCaptionWidth();

    boolean clearCaptionRight = false;

    boolean captionAboveCompnent;
    if (caption == null) {
        captionAboveCompnent = false;
        style.clearPaddingLeft();

        clearCaptionRight = true;
    } else {
        captionAboveCompnent = !caption.shouldBePlacedAfterComponent();
        if (!captionAboveCompnent) {
            availableWidth -= captionWidth;
            if (availableWidth < 0) {
                availableWidth = 0;
            }
            captionStyle.clearLeft();
            captionStyle.setRight(0, Style.Unit.PX);
            style.setPaddingRight(captionWidth, Style.Unit.PX);
        } else {
            availableWidth -= captionWidth;
            if (availableWidth < 0) {
                availableWidth = 0;
            }
            style.setPaddingLeft(captionWidth, Style.Unit.PX);
            captionStyle.setLeft(0, Style.Unit.PX);
            captionStyle.clearRight();

            clearCaptionRight = true;
        }
    }

    // Take into account right indicators
    double indicatorsWidth = 0;
    if (rightCaption != null) {
        indicatorsWidth = WidgetUtil.getRequiredWidth(rightCaption);
        availableWidth -= indicatorsWidth;
        if (availableWidth < 0) {
            availableWidth = 0;
        }
        style.setPaddingRight(indicatorsWidth, Style.Unit.PX);
    } else if (clearCaptionRight) {
        style.clearPaddingRight();
    }

    if (marginRight > 0) {
        style.setMarginRight(marginRight, Style.Unit.PX);
    } else {
        style.clearMarginRight();
    }

    if (isRelativeWidth()) {
        style.setPropertyPx("width", (int) availableWidth);
    } else {
        style.clearProperty("width");
    }

    double allocatedContentWidth = 0;
    if (isRelativeWidth()) {
        String percentWidth = getWidget().getElement().getStyle().getWidth();
        double percentage = parsePercent(percentWidth);
        allocatedContentWidth = availableWidth * (percentage / 100);
        reportActualRelativeWidth(Math.round((float) allocatedContentWidth));
    }

    AlignmentInfo alignment = getAlignment();
    if (!alignment.isLeft()) {
        double usedWidth;
        if (isRelativeWidth()) {
            if (isCaptionInline()) {
                usedWidth = allocatedContentWidth + indicatorsWidth + captionWidth;
            } else {
                usedWidth = allocatedContentWidth + indicatorsWidth;
            }
        } else {
            usedWidth = getWidgetWidth() + indicatorsWidth;
        }
        if (alignment.isHorizontalCenter()) {
            currentLocation += (allocatedSpace - usedWidth) / 2d;
            if (captionAboveCompnent) {
                captionStyle.setLeft(Math.round(usedWidth - captionWidth) / 2, Style.Unit.PX);
            }
        } else {
            currentLocation += (allocatedSpace - usedWidth);
            if (captionAboveCompnent) {
                captionStyle.setLeft(Math.round(usedWidth - captionWidth), Style.Unit.PX);
            }
        }
    } else {
        if (captionAboveCompnent) {
            captionStyle.setLeft(0, Style.Unit.PX);
        }
    }

    style.setLeft(Math.round(currentLocation), Style.Unit.PX);
}

From source file:com.moesol.gwt.maps.client.TiledImageLayer.java

License:Open Source License

private void positionOneImage(ViewBox vb, TileCoords tileCoords) {
    if (tileCoords == null) {
        return;/*from ww  w . java2 s . com*/
    }
    ImageDiv image = (ImageDiv) m_tileImageMgr.findOrCreateImage(vb, tileCoords);
    setImageZIndex(image, m_layerSet.getZIndex());
    int x = tileCoords.getOffsetX();
    int y = tileCoords.getOffsetY();
    int width = tileCoords.getTileWidth();
    int height = tileCoords.getTileHeight();
    BoxBounds b = m_divWorker.computePercentBounds(x, y, width, height);

    Style imageStyle = image.getElement().getStyle();
    imageStyle.setLeft(b.left, Unit.PCT);
    imageStyle.setRight(100 - b.right, Unit.PCT);
    imageStyle.setTop(b.top, Unit.PCT);
    imageStyle.setBottom(100 - b.bottom, Unit.PCT);
}

From source file:com.vaadin.client.metadata.ConnectorBundleLoader.java

License:Apache License

private void notice(String productName) {
    if (notice == null) {
        notice = new HTML();
        notice.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                notice.removeFromParent();
            }//from  w  ww.ja v a  2 s  .  c  o  m
        });
        notice.addTouchStartHandler(new TouchStartHandler() {
            public void onTouchStart(TouchStartEvent event) {
                notice.removeFromParent();
            }
        });
    }
    String msg = notice.getText().trim();
    msg += msg.isEmpty() ? "Using Evaluation License of: " : ", ";
    notice.setText(msg + productName);
    RootPanel.get().add(notice);

    notice.getElement().setClassName("");
    Style s = notice.getElement().getStyle();

    s.setPosition(Position.FIXED);
    s.setTextAlign(TextAlign.CENTER);
    s.setRight(0, Unit.PX);
    s.setLeft(0, Unit.PX);
    s.setBottom(0, Unit.PX);
    s.setProperty("padding", "0.5em 1em");

    s.setProperty("font-family", "sans-serif");
    s.setFontSize(12, Unit.PX);
    s.setLineHeight(1.1, Unit.EM);

    s.setColor("white");
    s.setBackgroundColor("black");
    s.setOpacity(0.7);

    s.setZIndex(2147483646);
    s.setProperty("top", "auto");
    s.setProperty("width", "auto");
    s.setDisplay(Display.BLOCK);
    s.setWhiteSpace(WhiteSpace.NORMAL);
    s.setVisibility(Visibility.VISIBLE);
    s.setMargin(0, Unit.PX);
}

From source file:com.vaadin.client.ui.layout.VLayoutSlot.java

License:Apache License

public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) {
    Style style = wrapper.getStyle();

    double availableWidth = allocatedSpace;

    VCaption caption = getCaption();//from   w  ww  .  j a  v  a  2s . co m
    Style captionStyle = caption != null ? caption.getElement().getStyle() : null;
    int captionWidth = getCaptionWidth();

    boolean captionAboveCompnent;
    if (caption == null) {
        captionAboveCompnent = false;
        style.clearPaddingRight();
    } else {
        captionAboveCompnent = !caption.shouldBePlacedAfterComponent();
        if (!captionAboveCompnent) {
            availableWidth -= captionWidth;
            if (availableWidth < 0) {
                availableWidth = 0;
            }
            captionStyle.clearLeft();
            captionStyle.setRight(0, Unit.PX);
            style.setPaddingRight(captionWidth, Unit.PX);
        } else {
            captionStyle.setLeft(0, Unit.PX);
            captionStyle.clearRight();
            style.clearPaddingRight();
        }
    }

    if (marginRight > 0) {
        style.setMarginRight(marginRight, Unit.PX);
    } else {
        style.clearMarginRight();
    }

    style.setPropertyPx("width", (int) availableWidth);

    double allocatedContentWidth = 0;
    if (isRelativeWidth()) {
        String percentWidth = getWidget().getElement().getStyle().getWidth();
        double percentage = parsePercent(percentWidth);
        allocatedContentWidth = availableWidth * (percentage / 100);
        reportActualRelativeWidth(Math.round((float) allocatedContentWidth));
    }

    style.setLeft(Math.round(currentLocation), Unit.PX);
    AlignmentInfo alignment = getAlignment();
    if (!alignment.isLeft()) {
        double usedWidth;
        if (isRelativeWidth()) {
            usedWidth = allocatedContentWidth;
        } else {
            usedWidth = getWidgetWidth();
        }

        double padding = (allocatedSpace - usedWidth);
        if (alignment.isHorizontalCenter()) {
            padding = padding / 2;
        }

        long roundedPadding = Math.round(padding);
        if (captionAboveCompnent) {
            captionStyle.setLeft(roundedPadding, Unit.PX);
        }
        widget.getElement().getStyle().setLeft(roundedPadding, Unit.PX);
    } else {
        if (captionAboveCompnent) {
            captionStyle.setLeft(0, Unit.PX);
        }
        // Reset left when changing back to align left
        widget.getElement().getStyle().clearLeft();
    }

}

From source file:com.vaadin.client.widgets.JsniWorkaround.java

License:Apache License

private void setupScrollbars(final Element root) {

    ScrollHandler scrollHandler = new ScrollHandler() {
        @Override/* www .j a va 2  s .c  o  m*/
        public void onScroll(ScrollEvent event) {
            scroller.onScroll();
            fireEvent(new ScrollEvent());
        }
    };

    int scrollbarThickness = WidgetUtil.getNativeScrollbarSize();
    if (BrowserInfo.get().isIE()) {
        /*
         * IE refuses to scroll properly if the DIV isn't at least one pixel
         * larger than the scrollbar controls themselves. But, probably
         * because of subpixel rendering, in Grid, one pixel isn't enough,
         * so we'll add two instead.
         */
        if (BrowserInfo.get().isIE9()) {
            scrollbarThickness += 2;
        } else {
            scrollbarThickness += 1;
        }
    }

    root.appendChild(verticalScrollbar.getElement());
    verticalScrollbar.addScrollHandler(scrollHandler);
    verticalScrollbar.setScrollbarThickness(scrollbarThickness);

    if (BrowserInfo.get().isIE8()) {
        /*
         * IE8 will have to compensate for a misalignment where it pops the
         * scrollbar outside of its box. See Bug 3 in
         * http://edskes.net/ie/ie8overflowandexpandingboxbugs.htm
         */
        Style vScrollStyle = verticalScrollbar.getElement().getStyle();
        vScrollStyle.setRight(verticalScrollbar.getScrollbarThickness() - 1, Unit.PX);
    }

    root.appendChild(horizontalScrollbar.getElement());
    horizontalScrollbar.addScrollHandler(scrollHandler);
    horizontalScrollbar.setScrollbarThickness(scrollbarThickness);
    horizontalScrollbar.addVisibilityHandler(new ScrollbarBundle.VisibilityHandler() {

        private boolean queued = false;

        @Override
        public void visibilityChanged(ScrollbarBundle.VisibilityChangeEvent event) {
            if (queued) {
                return;
            }
            queued = true;

            /*
             * We either lost or gained a scrollbar. In any case, we
             * need to change the height, if it's defined by rows.
             */
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                @Override
                public void execute() {
                    applyHeightByRows();
                    queued = false;
                }
            });
        }
    });

    /*
     * Because of all the IE hacks we've done above, we now have scrollbars
     * hiding underneath a lot of DOM elements.
     * 
     * This leads to problems with OSX (and many touch-only devices) when
     * scrollbars are only shown when scrolling, as the scrollbar elements
     * are hidden underneath everything. We trust that the scrollbars behave
     * properly in these situations and simply pop them out with a bit of
     * z-indexing.
     */
    if (WidgetUtil.getNativeScrollbarSize() == 0) {
        verticalScrollbar.getElement().getStyle().setZIndex(90);
        horizontalScrollbar.getElement().getStyle().setZIndex(90);
    }
}

From source file:geogebra.web.gui.app.docklayout.LayoutImpl.java

License:Apache License

public void fillParent(Element elem) {
    Style style = elem.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, PX);/* ww w .  j  a v  a  2s. c o m*/
    style.setTop(0, PX);
    style.setRight(0, PX);
    style.setBottom(0, PX);
}

From source file:geogebra.web.gui.app.docklayout.LayoutImpl.java

License:Apache License

public void layout(Layer layer) {
    Style style = layer.container.getStyle();

    if (layer.visible) {
        style.clearDisplay();//from  w  w  w. ja  v  a  2  s  . co  m
    } else {
        style.setDisplay(Display.NONE);
    }

    style.setProperty("left", layer.setLeft ? (layer.left + layer.leftUnit.getType()) : "");
    style.setProperty("top", layer.setTop ? (layer.top + layer.topUnit.getType()) : "");
    style.setProperty("right", layer.setRight ? (layer.right + layer.rightUnit.getType()) : "");
    style.setProperty("bottom", layer.setBottom ? (layer.bottom + layer.bottomUnit.getType()) : "");
    style.setProperty("width", layer.setWidth ? (layer.width + layer.widthUnit.getType()) : "");
    style.setProperty("height", layer.setHeight ? (layer.height + layer.heightUnit.getType()) : "");

    style = layer.child.getStyle();
    switch (layer.hPos) {
    case BEGIN:
        style.setLeft(0, Unit.PX);
        style.clearRight();
        break;
    case END:
        style.clearLeft();
        style.setRight(0, Unit.PX);
        break;
    case STRETCH:
        style.setLeft(0, Unit.PX);
        style.setRight(0, Unit.PX);
        break;
    }

    switch (layer.vPos) {
    case BEGIN:
        style.setTop(0, Unit.PX);
        style.clearBottom();
        break;
    case END:
        style.clearTop();
        style.setBottom(0, Unit.PX);
        break;
    case STRETCH:
        style.setTop(0, Unit.PX);
        style.setBottom(0, Unit.PX);
        break;
    }
}

From source file:next.i.controller.Utils.java

License:Apache License

static void fillParent(Element elem) {
    Style style = elem.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, PX);/*from  w w w .j  av a 2  s . c  o  m*/
    style.setTop(0, PX);
    style.setRight(0, PX);
    style.setBottom(0, PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
}

From source file:org.jboss.errai.mvp.client.presenters.RootView.java

License:Apache License

public void ensureGlass() {
    if (glass == null) {
        glass = Document.get().createDivElement();

        Style style = glass.getStyle();
        style.setPosition(Style.Position.ABSOLUTE);
        style.setLeft(0, Style.Unit.PX);
        style.setTop(0, Style.Unit.PX);
        style.setRight(0, Style.Unit.PX);
        style.setBottom(0, Style.Unit.PX);
        style.setZIndex(2147483647); // Maximum z-index
    }//from  www  . j  a v a  2  s.  co m
}