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

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

Introduction

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

Prototype

public void setWidth(double value, Unit unit) 

Source Link

Usage

From source file:com.vaadin.terminal.gwt.client.VUIDLBrowser.java

License:Open Source License

static void highlight(Paintable paintable) {
    Widget w = (Widget) paintable;/*from   www.j av  a2s  . c om*/
    if (w != null) {
        Style style = highlight.getStyle();
        style.setTop(w.getAbsoluteTop(), Unit.PX);
        style.setLeft(w.getAbsoluteLeft(), Unit.PX);
        style.setWidth(w.getOffsetWidth(), Unit.PX);
        style.setHeight(w.getOffsetHeight(), Unit.PX);
        RootPanel.getBodyElement().appendChild(highlight);
    }
}

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

License:Apache License

/**
 * Creates a new Escalator widget instance.
 *///from  www . j  a va2  s . co m
public Escalator() {

    detectAndApplyPositionFunction();
    getLogger().info("Using " + position.getClass().getSimpleName() + " for position");

    final Element root = DOM.createDiv();
    setElement(root);

    setupScrollbars(root);

    tableWrapper = DivElement.as(DOM.createDiv());

    root.appendChild(tableWrapper);

    final Element table = DOM.createTable();
    tableWrapper.appendChild(table);

    table.appendChild(headElem);
    table.appendChild(bodyElem);
    table.appendChild(footElem);

    Style hCornerStyle = headerDeco.getStyle();
    hCornerStyle.setWidth(verticalScrollbar.getScrollbarThickness(), Unit.PX);
    hCornerStyle.setDisplay(Display.NONE);
    root.appendChild(headerDeco);

    Style fCornerStyle = footerDeco.getStyle();
    fCornerStyle.setWidth(verticalScrollbar.getScrollbarThickness(), Unit.PX);
    fCornerStyle.setDisplay(Display.NONE);
    root.appendChild(footerDeco);

    Style hWrapperStyle = horizontalScrollbarDeco.getStyle();
    hWrapperStyle.setDisplay(Display.NONE);
    hWrapperStyle.setHeight(horizontalScrollbar.getScrollbarThickness(), Unit.PX);
    root.appendChild(horizontalScrollbarDeco);

    setStylePrimaryName("v-escalator");

    spacerDecoContainer.setAttribute("aria-hidden", "true");

    // init default dimensions
    setHeight(null);
    setWidth(null);

    publishJSHelpers(root);
}

From source file:edu.bsu.storygame.html.HtmlNativeTextField.java

License:Open Source License

@Override
public void setBounds(IRectangle bounds) {
    Style style = element.getStyle();
    style.setLeft(bounds.x(), Style.Unit.PX);
    style.setTop(bounds.y(), Style.Unit.PX);
    style.setWidth(bounds.width(), Style.Unit.PX);
    style.setHeight(bounds.height(), Style.Unit.PX);
}

From source file:fi.jasoft.dragdroplayouts.client.ui.gridlayout.VDDGridLayout.java

License:Apache License

/**
 * Emphasizes a component container when user is hovering a dragged component over the container.
 * /*from ww w. j  av a2  s . com*/
 * @param container The container
 * @param event
 */
protected void emphasis(CellDetails cell, VDragEvent event) {

    Style shadowStyle = dragShadow.getElement().getStyle();
    shadowStyle.setPosition(Position.ABSOLUTE);
    shadowStyle.setWidth(cell.width, Unit.PX);
    shadowStyle.setHeight(cell.height, Unit.PX);
    shadowStyle.setLeft(cell.x, Unit.PX);
    shadowStyle.setTop(cell.y, Unit.PX);

    // Remove any existing empasis
    deEmphasis();

    // Ensure we are not dragging ourself into ourself
    ComponentConnector draggedConnector = (ComponentConnector) event.getTransferable()
            .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);

    if (draggedConnector != null && draggedConnector.getWidget() == VDDGridLayout.this) {
        return;
    }

    HorizontalDropLocation hl = getHorizontalDropLocation(cell, event);
    VerticalDropLocation vl = getVerticalDropLocation(cell, event);

    // Apply over style
    UIObject.setStyleName(dragShadow.getElement(), OVER, true);

    // Add vertical location dependent style
    UIObject.setStyleName(dragShadow.getElement(), OVER + "-" + vl.toString().toLowerCase(), true);

    // Add horizontal location dependent style
    UIObject.setStyleName(dragShadow.getElement(), OVER + "-" + hl.toString().toLowerCase(), true);

}

From source file:forplay.html.HtmlImageLayerDom.java

License:Apache License

private void applySize() {
    Style style = element().getStyle();
    style.setWidth(widthSet ? width : htmlImage.img.getWidth(), Unit.PX);
    style.setHeight(heightSet ? height : htmlImage.img.getHeight(), Unit.PX);
    if (sourceRectSet) {
        applyBackgroundSize();/*from w ww . ja v  a  2  s.c om*/
    }
}

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  w w w .  ja  v  a2  s.  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;
}

From source file:fr.putnami.pwt.core.widget.client.Affix.java

License:Open Source License

protected void toggleAffix(Affixed affix) {
    Element e = this.getElement();
    Style style = e.getStyle();

    if (this.affixed != affix) {
        this.clearElementStyle();
        this.affixed = affix;
        StyleUtils.addStyle(e, this.affixed);
    }//www.  ja v  a  2s . c  o m

    switch (affix) {
    case AFFIX:
        style.setTop(this.offsetTop, Unit.PX);
        style.setWidth(this.offsetWidth, Unit.PX);
        style.setHeight(this.offsetHeight, Unit.PX);
        style.setZIndex(this.layerIndex);
        e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX);
        break;
    case BOTTOM:
        int docHeigth = Document.get().getScrollHeight();
        int scrollTop = Window.getScrollTop();

        int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth);
        if (this.fixBottom != Integer.MIN_VALUE) {
            bottom = Math.max(bottom, this.fixBottom);
        }
        style.setPosition(Position.FIXED);
        style.setBottom(bottom, Unit.PX);
        style.setWidth(this.offsetWidth, Unit.PX);
        style.setHeight(this.offsetHeight, Unit.PX);
        style.setZIndex(this.layerIndex);
        break;
    default:
        break;
    }
}

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

License:Apache License

protected static DivElement createRuler(Unit widthUnit, Unit heightUnit) {
    DivElement ruler = Document.get().createDivElement();
    ruler.setInnerHTML(" ");
    Style style = ruler.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(-32767);//from   w ww  . ja  v a  2  s  . c  om

    // Position the ruler off the top edge, double the size just to be
    // extra sure it doesn't show up on the screen.
    style.setTop(-20, heightUnit);

    // Note that we are making the ruler element 10x10, because some browsers
    // generate non-integral ratios (e.g., 1em == 13.3px), so we need a little
    // extra precision.
    style.setWidth(10, widthUnit);
    style.setHeight(10, heightUnit);

    style.setVisibility(Visibility.HIDDEN);
    State.HIDDEN.set(ruler, true);
    return ruler;
}

From source file:gwt.material.design.addins.client.cutout.MaterialCutOut.java

License:Apache License

protected void setCutOutStyle() {
    Style style = getElement().getStyle();
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);/* w  w  w.j a  va2 s .com*/
    style.setPosition(Position.FIXED);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setZIndex(10000);

    focusElement.setClassName(AddinsCssName.MATERIAL_CUTOUT_FOCUS);
    style = focusElement.getStyle();
    style.setProperty("content", "\'\'");
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(-1);
}

From source file:gwt.material.design.addins.client.cutout.MaterialCutOut.java

License:Apache License

/**
 * Gets the computed background color, based on the backgroundColor CSS
 * class.//  www  .  j  a  v a  2  s  .  co  m
 */
protected void setupComputedBackgroundColor() {
    // temp is just a widget created to evaluate the computed background
    // color
    MaterialWidget temp = new MaterialWidget(Document.get().createDivElement());
    temp.setBackgroundColor(backgroundColor);

    // setting a style to make it invisible for the user
    Style style = temp.getElement().getStyle();
    style.setPosition(Position.FIXED);
    style.setWidth(1, Unit.PX);
    style.setHeight(1, Unit.PX);
    style.setLeft(-10, Unit.PX);
    style.setTop(-10, Unit.PX);
    style.setZIndex(-10000);

    // adding it to the body (on Chrome the component must be added to the
    // DOM before getting computed values).
    String computed = ColorHelper.setupComputedBackgroundColor(backgroundColor);

    // convert rgb to rgba, considering the opacity field
    if (opacity < 1 && computed.startsWith("rgb(")) {
        computed = computed.replace("rgb(", "rgba(").replace(")", ", " + opacity + ")");
    }

    computedBackgroundColor = computed;
}