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

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

Introduction

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

Prototype

public void setMarginLeft(double value, Unit unit) 

Source Link

Usage

From source file:client.ui.components.MaterialButton.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    if (animationEnabled) {
        ink.removeClassName(Class.ANIMATE.getName());

        Style style = ink.getStyle();
        int size = anchor.getOffsetWidth();

        style.setWidth(size, Style.Unit.PX);
        style.setHeight(size, Style.Unit.PX);
        style.setMarginLeft(-size / 2, Style.Unit.PX);
        style.setMarginTop(-size / 2, Style.Unit.PX);

        style.setLeft(event.getX(), Style.Unit.PX);
        style.setTop(event.getY(), Style.Unit.PX);

        ink.addClassName(Class.ANIMATE.getName());
    }/*from   w  w  w  . j  a  v  a  2s . c  o  m*/
}

From source file:client.ui.components.MaterialItem.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    if (animationEnabled) {
        Element inkElement = ink.getElement();

        inkElement.removeClassName(Class.ANIMATE.getName());

        Style style = inkElement.getStyle();
        int size = panel.getOffsetWidth();

        style.setWidth(size, Style.Unit.PX);
        style.setHeight(size, Style.Unit.PX);
        style.setMarginLeft(-size / 2, Style.Unit.PX);
        style.setMarginTop(-size / 2, Style.Unit.PX);

        style.setLeft(event.getX(), Style.Unit.PX);
        style.setTop(event.getY(), Style.Unit.PX);

        inkElement.addClassName(Class.ANIMATE.getName());
    }//from  w w w.  ja va2 s .  c om
}

From source file:com.vaadin.addon.spreadsheet.client.GroupingWidget.java

protected void copyfields(GroupingWidget newWidget) {
    newWidget.collapsed = collapsed;//from w  w  w  .j av a  2 s. c  o  m
    newWidget.index = index;
    newWidget.inversed = inversed;

    newWidget.btn.setInnerText(btn.getInnerText());

    Style style = newWidget.getElement().getStyle();

    newWidget.setStyleName(getStyleName());

    if (marginLeft > -1) {
        style.setMarginLeft(marginLeft, Unit.PX);
    }
    if (marginTop > -1) {
        style.setMarginTop(marginTop, Unit.PX);
    }
    if (height > -1) {
        style.setHeight(height, Unit.PX);
    }
    if (width > -1) {
        style.setWidth(width, Unit.PX);
    }
    if (top > -1) {
        style.setTop(top, Unit.PX);
    }
    if (left > -1) {
        style.setLeft(left, Unit.PX);
    }
}

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

License:Apache License

/**
 * Update the offset off the caption relative to the slot
 * <p>//  w w  w  .  ja v  a2s  . 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.VCustomScrollTable.java

License:Apache License

private void announceScrollPosition() {
    if (scrollPositionElement == null) {
        scrollPositionElement = DOM.createDiv();
        scrollPositionElement.setClassName(getStylePrimaryName() + "-scrollposition");
        scrollPositionElement.getStyle().setPosition(Position.ABSOLUTE);
        scrollPositionElement.getStyle().setDisplay(Display.NONE);
        getElement().appendChild(scrollPositionElement);
    }//from w  w  w .  j  a  v  a2  s  .c o m

    Style style = scrollPositionElement.getStyle();
    style.setMarginLeft(getElement().getOffsetWidth() / 2 - 80, Unit.PX);
    style.setMarginTop(-scrollBodyPanel.getOffsetHeight(), Unit.PX);

    // indexes go from 1-totalRows, as rowheaders in index-mode indicate
    int last = (firstRowInViewPort + pageLength);
    if (last > totalRows) {
        last = totalRows;
    }
    scrollPositionElement
            .setInnerHTML("<span>" + (firstRowInViewPort + 1) + " &ndash; " + (last) + "..." + "</span>");
    style.setDisplay(Display.BLOCK);
}

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

License:Apache License

@Override
public void setPopupPosition(int left, int top) {
    // TODO, this should in fact be part of
    // Document.get().getBodyOffsetLeft/Top(). Would require overriding DOM
    // for all permutations. Now adding fix as margin instead of fixing
    // left/top because parent class saves the position.
    Style style = getElement().getStyle();
    style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX);
    style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX);
    super.setPopupPosition(left, top);
    positionOrSizeUpdated(isAnimationEnabled() ? 0 : 1);
}

From source file:com.vaadin.terminal.gwt.client.ui.VCustomScrollTable.java

License:Apache License

protected void announceScrollPosition() {
    if (scrollPositionElement == null) {
        scrollPositionElement = DOM.createDiv();
        scrollPositionElement.setClassName(CLASSNAME + "-scrollposition");
        scrollPositionElement.getStyle().setPosition(Position.ABSOLUTE);
        scrollPositionElement.getStyle().setDisplay(Display.NONE);
        getElement().appendChild(scrollPositionElement);
    }/*from   w  ww  . ja  v  a 2  s  .c  o  m*/

    Style style = scrollPositionElement.getStyle();
    style.setMarginLeft(getElement().getOffsetWidth() / 2 - 80, Unit.PX);
    style.setMarginTop(-scrollBodyPanel.getOffsetHeight(), Unit.PX);

    // indexes go from 1-totalRows, as rowheaders in index-mode indicate
    int last = (firstRowInViewPort + pageLength);
    if (last > totalRows) {
        last = totalRows;
    }
    scrollPositionElement
            .setInnerHTML("<span>" + (firstRowInViewPort + 1) + " &ndash; " + (last) + "..." + "</span>");
    style.setDisplay(Display.BLOCK);
}

From source file:com.vaadin.terminal.gwt.client.ui.VOverlay.java

License:Open Source License

@Override
public void setPopupPosition(int left, int top) {
    // TODO, this should in fact be part of
    // Document.get().getBodyOffsetLeft/Top(). Would require overriding DOM
    // for all permutations. Now adding fix as margin instead of fixing
    // left/top because parent class saves the position.
    Style style = getElement().getStyle();
    style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX);
    style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX);
    super.setPopupPosition(left, top);
    updateShadowSizeAndPosition(isAnimationEnabled() ? 0 : 1);
}

From source file:com.vaadin.terminal.gwt.client.ui.VScrollTable.java

License:Open Source License

private void announceScrollPosition() {
    if (scrollPositionElement == null) {
        scrollPositionElement = DOM.createDiv();
        scrollPositionElement.setClassName(CLASSNAME + "-scrollposition");
        scrollPositionElement.getStyle().setPosition(Position.ABSOLUTE);
        scrollPositionElement.getStyle().setDisplay(Display.NONE);
        getElement().appendChild(scrollPositionElement);
    }//  ww  w .j  a  v  a 2 s . co  m

    Style style = scrollPositionElement.getStyle();
    style.setMarginLeft(getElement().getOffsetWidth() / 2 - 80, Unit.PX);
    style.setMarginTop(-scrollBodyPanel.getOffsetHeight(), Unit.PX);

    // indexes go from 1-totalRows, as rowheaders in index-mode indicate
    int last = (firstRowInViewPort + pageLength);
    if (last > totalRows) {
        last = totalRows;
    }
    scrollPositionElement
            .setInnerHTML("<span>" + (firstRowInViewPort + 1) + " &ndash; " + (last) + "..." + "</span>");
    style.setDisplay(Display.BLOCK);
}

From source file:fr.mncc.gwttoolbox.ui.client.LightBox.java

License:Open Source License

private void addColumnElem(int i, Element elem, int elemWidth, int elemHeight, int rowspan) {
    ImageSize newSize = fitWidth(elemWidth, elemHeight, 1 + Math.abs(rowspan));
    newSize.height_ -= (columnsHeight_[i] + newSize.height_ + margin_) % DELTA;

    Style elemStyle = elem.getStyle();
    elemStyle.setMarginLeft(extraMargin_ + margin_ + (columnsWidth_ + margin_) * (i + (rowspan == -1 ? -1 : 0)),
            Style.Unit.PX);/*from ww w .  j av  a 2s  .c  o  m*/
    elemStyle.setMarginTop(columnsHeight_[i], Style.Unit.PX);
    elemStyle.setWidth(newSize.width_, Style.Unit.PX);
    elemStyle.setHeight(newSize.height_, Style.Unit.PX);

    int nextHeight = columnsHeight_[i] + newSize.height_ + margin_;
    columnsHeight_[i + rowspan] = columnsHeight_[i] = nextHeight;
}