Example usage for com.vaadin.client ComputedStyle getPadding

List of usage examples for com.vaadin.client ComputedStyle getPadding

Introduction

In this page you can find the example usage for com.vaadin.client ComputedStyle getPadding.

Prototype

public final int[] getPadding() 

Source Link

Document

Get current padding values from the DOM.

Usage

From source file:info.magnolia.ui.vaadin.gwt.client.layout.thumbnaillayout.widget.ThumbnailsSizeKeeper.java

License:Open Source License

private void updateCalculatedOffsetSizes() {
    ComputedStyle cs;

    int[] padding;
    int[] border;
    int[] margin;

    if (thumbnailParent.getChildCount() > 0) {
        final Element firstThumbnail = Element.as(thumbnailParent.getFirstChild());
        cs = new ComputedStyle(firstThumbnail);

        padding = cs.getPadding();
        border = cs.getBorder();//from  w  w w  .  jav a 2  s . com
        margin = cs.getMargin();
    } else {
        final Element stub = Element.as(DOM.createDiv());
        stub.addClassName("thumbnail");
        thumbnailParent.appendChild(stub);
        cs = new ComputedStyle(stub);
        padding = cs.getPadding();
        border = cs.getBorder();
        margin = cs.getMargin();

        thumbnailParent.removeChild(stub);
    }

    horizontalDecorations = padding[1] + padding[3] + border[1] + border[3] + margin[1] + margin[3];
    verticalDecorations = padding[0] + padding[2] + border[0] + border[2] + margin[0] + margin[2];

    this.unscaledWidth = baseWidth + horizontalDecorations;
    this.unscaledHeight = baseHeight + verticalDecorations;

    this.calculatedWidth = scaleDimension(baseWidth, ratio);
    this.calculatedHeight = scaleDimension(baseHeight, ratio);

}

From source file:info.magnolia.ui.vaadin.gwt.client.richtext.TextAreaStretcherConnector.java

License:Open Source License

private void updateSize() {
    if (!getState().isCollapsed) {
        stretchControl.replaceClassName("icon-open-fullscreen-2", "icon-close-fullscreen-2");
        stretchControl.replaceClassName(COLLAPSED, STRETCHED);
        form.asWidget().addStyleName("textarea-stretched");

        Style style = textWidget.getElement().getStyle();
        style.setPosition(Style.Position.ABSOLUTE);
        Element header = getDialogHeaderElement();
        ComputedStyle headerCS = new ComputedStyle(header);

        int top = form.getAbsoluteTop() - dialog.getAbsoluteTop();
        top = isOverlay ? top : top + headerCS.getPadding()[0] + headerCS.getPadding()[2];

        int left = isOverlay ? 0 : form.getAbsoluteLeft();

        style.setLeft(left, Style.Unit.PX);
        style.setTop(top, Style.Unit.PX);

        stretchTextArea(style);/*from  w w  w  . j a  va2 s.co  m*/
        style.setZIndex(5);

        if (!isOverlay && !isRichTextEditor) {
            stretchControl.getStyle().setTop(top + 5, Style.Unit.PX);
            stretchControl.getStyle().setLeft(
                    left + textWidget.getOffsetWidth() - stretchControl.getOffsetWidth() - 5, Style.Unit.PX);

        }

        hideOtherStretchers();
    } else {
        stretchControl.replaceClassName(STRETCHED, COLLAPSED);
        stretchControl.replaceClassName("icon-close-fullscreen-2", "icon-open-fullscreen-2");
        form.asWidget().removeStyleName(TEXTAREA_STRETCHED);
        clearTraces();
    }
}