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

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

Introduction

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

Prototype

public void setMarginBottom(double value, Unit unit) 

Source Link

Usage

From source file:com.dianaui.universal.core.client.ui.InlineHelpBlock.java

License:Apache License

public InlineHelpBlock() {
    super();//from  w w w  . j av a2 s.  co m
    Style style = getElement().getStyle();
    style.setDisplay(Display.INLINE_BLOCK);
    style.setMarginTop(0, Unit.PX);
    style.setMarginBottom(5, Unit.PX);
    style.setPaddingLeft(10, Unit.PX);
}

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

License:Apache License

@Override
public void positionVertically(double currentLocation, double allocatedSpace, double marginBottom) {
    if (!isCaptionInline()) {
        super.positionVertically(currentLocation, allocatedSpace, marginBottom);
        return;/*w  ww.j ava 2  s . c  o m*/
    }

    // CAUTION copied from VLayoutSlot.positionVertically(~)
    Style style = wrapper.getStyle();

    double contentHeight = allocatedSpace;

    int captionHeight;
    VCaption caption = getCaption();
    if (caption == null || caption.shouldBePlacedAfterComponent() || isCaptionInline()) {
        style.clearPaddingTop();
        captionHeight = 0;
    } else {
        captionHeight = getCaptionHeight();
        contentHeight -= captionHeight;
        if (contentHeight < 0) {
            contentHeight = 0;
        }
        style.setPaddingTop(captionHeight, Style.Unit.PX);
    }

    if (marginBottom > 0) {
        style.setMarginBottom(marginBottom, Style.Unit.PX);
    } else {
        style.clearMarginBottom();
    }

    if (isRelativeHeight()) {
        style.setHeight(contentHeight, Style.Unit.PX);
    } else {
        style.clearHeight();
    }

    double allocatedContentHeight = 0;
    if (isRelativeHeight()) {
        String height = getWidget().getElement().getStyle().getHeight();
        double percentage = parsePercent(height);
        allocatedContentHeight = contentHeight * (percentage / 100);
        reportActualRelativeHeight(Math.round((float) allocatedContentHeight));
    }

    AlignmentInfo alignment = getAlignment();
    if (!alignment.isTop()) {
        double usedHeight;
        if (isRelativeHeight()) {
            if (isCaptionInline()) {
                usedHeight = allocatedContentHeight;
            } else {
                usedHeight = captionHeight + allocatedContentHeight;
            }
        } else {
            usedHeight = getUsedHeight();
        }
        if (alignment.isVerticalCenter()) {
            currentLocation += (allocatedSpace - usedHeight) / 2d;
        } else {
            currentLocation += (allocatedSpace - usedHeight);
        }
    }

    style.setTop(currentLocation, Style.Unit.PX);
}

From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java

License:sencha.com license

/**
 * Sets the spacing between portlets (defaults to 10).
 * //  w  w  w  .ja v a 2 s  .  c  o  m
 * @param spacing the spacing in pixels
 */
public void setSpacing(int spacing) {
    this.spacing = spacing;
    for (int i = 0; i < numColumns; i++) {
        CssFloatLayoutContainer con = getWidget(i);
        Style columnStyle = con.getElement().getStyle();
        columnStyle.setPaddingTop(spacing, Unit.PX);
        columnStyle.setPaddingRight((i < numColumns - 1) ? (spacing / 2) : spacing, Unit.PX);
        columnStyle.setPaddingBottom(0, Unit.PX); // bottom is set on the portlet
        columnStyle.setPaddingLeft((i > 0) ? (spacing / 2) : spacing, Unit.PX);

        for (int j = 0; j < con.getWidgetCount(); j++) {
            Style portletStyle = con.getWidget(j).getElement().getStyle();
            portletStyle.setMarginBottom(spacing, Unit.PX);
        }
    }
}

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

License:Apache License

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

    double contentHeight = allocatedSpace;

    int captionHeight;
    VCaption caption = getCaption();/*from w ww .  jav  a  2 s. c o m*/
    if (caption == null || caption.shouldBePlacedAfterComponent()) {
        style.clearPaddingTop();
        captionHeight = 0;
    } else {
        captionHeight = getCaptionHeight();
        contentHeight -= captionHeight;
        if (contentHeight < 0) {
            contentHeight = 0;
        }
        style.setPaddingTop(captionHeight, Unit.PX);
    }

    if (marginBottom > 0) {
        style.setMarginBottom(marginBottom, Unit.PX);
    } else {
        style.clearMarginBottom();
    }

    style.setHeight(contentHeight, Unit.PX);

    double allocatedContentHeight = 0;
    if (isRelativeHeight()) {
        String height = getWidget().getElement().getStyle().getHeight();
        double percentage = parsePercent(height);
        allocatedContentHeight = contentHeight * (percentage / 100);
        reportActualRelativeHeight(Math.round((float) allocatedContentHeight));
    }

    style.setTop(currentLocation, Unit.PX);
    double padding = 0;
    AlignmentInfo alignment = getAlignment();
    if (!alignment.isTop()) {
        double usedHeight;
        if (isRelativeHeight()) {
            usedHeight = captionHeight + allocatedContentHeight;
        } else {
            usedHeight = getUsedHeight();
        }
        if (alignment.isVerticalCenter()) {
            padding = (allocatedSpace - usedHeight) / 2d;
        } else {
            padding = (allocatedSpace - usedHeight);
        }
        padding += captionHeight;

        widget.getElement().getStyle().setTop(padding, Unit.PX);
    } else {
        // Reset top when changing back to align top
        widget.getElement().getStyle().clearTop();

    }
}

From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java

License:Apache License

/**
 * Update the offset off the caption relative to the slot
 * <p>//from w w  w. j a  v  a 2  s.c o m
 * For internal use only. May be removed or replaced in the future.
 * 
 * @param caption
 *            The caption element
 * @deprecated As of 7.2, call or override
 *             {@link #updateCaptionOffset(Element)} instead
 */
@Deprecated
public void updateCaptionOffset(com.google.gwt.user.client.Element caption) {

    Element captionWrap = caption.getParentElement();

    Style captionWrapStyle = captionWrap.getStyle();
    captionWrapStyle.clearPaddingTop();
    captionWrapStyle.clearPaddingRight();
    captionWrapStyle.clearPaddingBottom();
    captionWrapStyle.clearPaddingLeft();

    Style captionStyle = caption.getStyle();
    captionStyle.clearMarginTop();
    captionStyle.clearMarginRight();
    captionStyle.clearMarginBottom();
    captionStyle.clearMarginLeft();

    // Get caption position from the classname
    CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap);

    if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) {
        int captionWidth;
        if (layoutManager != null) {
            captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption);
        } else {
            captionWidth = caption.getOffsetWidth();
        }
        if (captionWidth > 0) {
            if (captionPosition == CaptionPosition.LEFT) {
                captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX);
                captionStyle.setMarginLeft(-captionWidth, Unit.PX);
            } else {
                captionWrapStyle.setPaddingRight(captionWidth, Unit.PX);
                captionStyle.setMarginRight(-captionWidth, Unit.PX);
            }
        }
    }
    if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) {
        int captionHeight;
        if (layoutManager != null) {
            captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption);
        } else {
            captionHeight = caption.getOffsetHeight();
        }
        if (captionHeight > 0) {
            if (captionPosition == CaptionPosition.TOP) {
                captionWrapStyle.setPaddingTop(captionHeight, Unit.PX);
                captionStyle.setMarginTop(-captionHeight, Unit.PX);
            } else {
                captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX);
                captionStyle.setMarginBottom(-captionHeight, Unit.PX);
            }
        }
    }
}

From source file:com.vaadin.client.ui.window.WindowConnector.java

License:Apache License

@Override
public void layout() {
    LayoutManager lm = getLayoutManager();
    VWindow window = getWidget();//from   www. j  a va 2 s  . c  om
    ComponentConnector content = getContent();
    boolean hasContent = (content != null);
    Element contentElement = window.contentPanel.getElement();

    Style contentStyle = window.contents.getStyle();

    int headerHeight = lm.getOuterHeight(window.header);
    contentStyle.setPaddingTop(headerHeight, Unit.PX);
    contentStyle.setMarginTop(-headerHeight, Unit.PX);

    int footerHeight = lm.getOuterHeight(window.footer);
    contentStyle.setPaddingBottom(footerHeight, Unit.PX);
    contentStyle.setMarginBottom(-footerHeight, Unit.PX);

    int minWidth = lm.getOuterWidth(window.header) - lm.getInnerWidth(window.header);
    int minHeight = footerHeight + headerHeight;

    getWidget().getElement().getStyle().setPropertyPx("minWidth", minWidth);
    getWidget().getElement().getStyle().setPropertyPx("minHeight", minHeight);

    /*
     * Must set absolute position if the child has relative height and
     * there's a chance of horizontal scrolling as some browsers will
     * otherwise not take the scrollbar into account when calculating the
     * height.
     */
    if (hasContent) {
        Element layoutElement = content.getWidget().getElement();
        Style childStyle = layoutElement.getStyle();

        // IE8 needs some hackery to measure its content correctly
        WidgetUtil.forceIE8Redraw(layoutElement);

        if (content.isRelativeHeight() && !BrowserInfo.get().isIE9()) {
            childStyle.setPosition(Position.ABSOLUTE);

            Style wrapperStyle = contentElement.getStyle();
            if (window.getElement().getStyle().getWidth().length() == 0 && !content.isRelativeWidth()) {
                /*
                 * Need to lock width to make undefined width work even with
                 * absolute positioning
                 */
                int contentWidth = lm.getOuterWidth(layoutElement);
                wrapperStyle.setWidth(contentWidth, Unit.PX);
            } else {
                wrapperStyle.clearWidth();
            }
        } else {
            childStyle.clearPosition();
        }
    }

}

From source file:ilarkesto.gwt.client.desktop.fields.FieldEditorDialogBox.java

License:Open Source License

private Label createErrorLabel() {
    Label label = new Label();
    Style style = label.getElement().getStyle();
    style.setDisplay(Display.NONE);/*from w w w . ja  v a2  s  . c  o  m*/
    style.setColor("#cc0000");
    style.setMarginTop(Widgets.defaultSpacing, Unit.PX);
    style.setMarginBottom(Widgets.defaultSpacing, Unit.PX);
    return label;
}

From source file:ilarkesto.gwt.client.desktop.Widgets.java

License:Open Source License

public static Widget verticalLine(int margin) {
    SimplePanel spacer = new SimplePanel();
    Style style = spacer.getElement().getStyle();
    style.setWidth(100, Unit.PCT);/*from w  w w. j  av  a 2 s. c om*/
    style.setHeight(1, Unit.PX);
    style.setBackgroundColor("#eeeeee");
    style.setMarginTop(margin, Unit.PX);
    style.setMarginBottom(margin, Unit.PX);
    return spacer;
}

From source file:org.gwtbootstrap3.client.ui.InlineHelpBlock.java

License:Apache License

public InlineHelpBlock() {
    super();/*  w  ww  .j a v  a 2s.c o  m*/
    Style style = getElement().getStyle();
    style.setDisplay(Display.INLINE_BLOCK);
    style.setMarginTop(0, Unit.PX);
    style.setMarginBottom(0, Unit.PX);
    style.setPaddingLeft(10, Unit.PX);
}

From source file:org.jbpm.form.builder.ng.model.common.panels.FieldSetPanel.java

License:Apache License

public FieldSetPanel() {
    super();//from  ww  w .ja  v  a  2  s  . c o  m
    Style divStyle = getElement().getStyle();
    Style lgndStyle = legend.getStyle();

    divStyle.setBorderWidth(2, Unit.PX);
    divStyle.setBorderStyle(BorderStyle.SOLID);
    divStyle.setMarginTop(0.5, Unit.EM);
    divStyle.setMarginBottom(0.5, Unit.EM);
    divStyle.setMarginRight(0, Unit.PX);
    divStyle.setMarginLeft(0, Unit.PX);
    divStyle.setPaddingTop(0, Unit.PX);
    divStyle.setPaddingBottom(0, Unit.PX);
    divStyle.setPaddingRight(0.5, Unit.EM);
    divStyle.setPaddingLeft(0.5, Unit.EM);

    lgndStyle.setFontSize(100.0, Unit.PCT);
    lgndStyle.setFontWeight(FontWeight.NORMAL);
    lgndStyle.setMarginTop(-0.5, Unit.EM);
    lgndStyle.setMarginRight(0, Unit.PX);
    lgndStyle.setMarginLeft(0, Unit.PX);
    lgndStyle.setMarginBottom(0, Unit.PX);
    lgndStyle.setBackgroundColor("white");
    lgndStyle.setColor("black");
    lgndStyle.setFloat(Style.Float.LEFT);
    lgndStyle.setPaddingTop(0, Unit.PX);
    lgndStyle.setPaddingBottom(0, Unit.PX);
    lgndStyle.setPaddingRight(2, Unit.PX);
    lgndStyle.setPaddingLeft(2, Unit.PX);

    getElement().appendChild(legend);
}