List of usage examples for com.google.gwt.dom.client Style setHeight
public void setHeight(double value, Unit unit)
From source file:org.uberfire.client.util.Layouts.java
License:Apache License
/** * Sets the CSS on the given widget so it automatically fills the available space, rather than being sized based on * the amount of space required by its contents. This tends to be useful when building a UI that always fills the * available space on the screen, as most desktop application windows do. * <p>/* w w w . j ava2s .c o m*/ * To achieve this, the element is given relative positioning with top and left set to 0px and width and height set * to 100%. This makes the widget fill its nearest ancestor which has relative or absolute positioning. This * technique is compatible with GWT's LayoutPanel system. Note that, like LayoutPanels, this only works if the host * page is in standards mode (has a {@code <!DOCTYPE html>} header). * @param w the widget that should always fill its available space, rather than being sized to fit its contents. */ public static void setToFillParent(Widget w) { Element e = w.getElement(); Style s = e.getStyle(); s.setPosition(Position.RELATIVE); s.setTop(0.0, Unit.PX); s.setLeft(0.0, Unit.PX); s.setWidth(100.0, Unit.PCT); s.setHeight(100.0, Unit.PCT); }
From source file:org.uberfire.client.workbench.WorkbenchLayoutImpl.java
License:Apache License
private void updateMaximizedPanelSizes() { for (Widget w : maximizedWidgetOriginalStyles.keySet()) { Style style = w.getElement().getStyle(); style.setTop(perspectiveRootContainer.getAbsoluteTop(), Unit.PX); style.setLeft(perspectiveRootContainer.getAbsoluteLeft(), Unit.PX); style.setWidth(perspectiveRootContainer.getOffsetWidth(), Unit.PX); style.setHeight(perspectiveRootContainer.getOffsetHeight(), Unit.PX); if (w instanceof RequiresResize) { ((RequiresResize) w).onResize(); }//from w w w . j ava 2 s . com } }
From source file:org.uberfire.ext.widgets.table.client.ResizableMovableHeader.java
License:Apache License
private static void setLine(final Style style, final int width, final int top, final int height, final String color) { style.setPosition(Position.ABSOLUTE); style.setTop(top, PX);/*from w w w .j a va2 s. c o m*/ style.setHeight(height, PX); style.setWidth(width, PX); style.setBackgroundColor(color); style.setZIndex(Integer.MAX_VALUE); }
From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.BaseDOMElement.java
License:Apache License
/** * Transform the DOMElement based on the render context, such as scale and position. * @param context//from w w w. j a v a 2 s . c om */ protected void transform(final GridBodyCellRenderContext context) { final Transform transform = context.getTransform(); final double width = context.getCellWidth(); final double height = context.getCellHeight(); final Style style = widgetContainer.getElement().getStyle(); //Copy across GridWidget's opacity to DOMElements style.setOpacity(gridWidget.getAlpha()); //Reposition and transform the DOM Element style.setLeft((context.getAbsoluteCellX() * transform.getScaleX()) + transform.getTranslateX(), Style.Unit.PX); style.setTop((context.getAbsoluteCellY() * transform.getScaleY()) + transform.getTranslateY(), Style.Unit.PX); style.setWidth(width, Style.Unit.PX); style.setHeight(height, Style.Unit.PX); //If the DOMElement overlaps a fixed header clip content style.clearProperty("clip"); final double top = context.getAbsoluteCellY() + transform.getTranslateY(); final double left = context.getAbsoluteCellX() + transform.getTranslateX(); final boolean isFloating = context.isFloating(); boolean clip = false; double ct = 0.0; double cr = width; double cb = height; double cl = 0.0; final Group header = gridWidget.getHeader(); final double clipMinY = context.getClipMinY() + transform.getTranslateY(); final double clipMinX = context.getClipMinX() + transform.getTranslateX(); if (header != null) { if (top < clipMinY) { ct = clipMinY - top; clip = true; } } if (!isFloating && left < clipMinX) { cl = clipMinX - left; clip = true; } if (clip) { style.setProperty("clip", "rect(" + (int) ct + "px," + (int) cr + "px," + (int) cb + "px," + (int) cl + "px)"); } // --- Workaround for BS2 --- style.setProperty("WebkitBoxSizing", "border-box"); style.setProperty("MozBoxSizing", "border-box"); style.setProperty("boxSizing", "border-box"); style.setProperty("lineHeight", "normal"); // --- End workaround --- if (MathUtilities.isOne(transform.getScaleX()) && MathUtilities.isOne(transform.getScaleY())) { style.clearProperty("WebkitTransform"); style.clearProperty("MozTransform"); style.clearProperty("Transform"); style.clearProperty("MsTransform"); return; } final String scale = "scale(" + FORMAT.format(transform.getScaleX()) + ", " + FORMAT.format(transform.getScaleY()) + ")"; final String translate = "translate(" + FORMAT.format(((width - width * transform.getScaleX()) / -2.0)) + "px, " + FORMAT.format(((height - height * transform.getScaleY()) / -2.0)) + "px)"; style.setProperty("WebkitTransform", translate + " " + scale); style.setProperty("MozTransform", translate + " " + scale); style.setProperty("Transform", translate + " " + scale); style.setProperty("MsTransform", translate + " " + scale); }
From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.CheckBoxDOMElement.java
License:Apache License
public CheckBoxDOMElement(final CheckBox widget, final GridLayer gridLayer, final GridWidget gridWidget) { super(widget, gridLayer, gridWidget); final Style style = widget.getElement().getStyle(); style.setMarginTop(0, Style.Unit.PX); style.setMarginLeft(2, Style.Unit.PX); style.setWidth(SIZE, Style.Unit.PX); style.setHeight(SIZE, Style.Unit.PX); // --- Workaround for BS2 --- style.setPosition(Style.Position.RELATIVE); style.setPaddingTop(0, Style.Unit.PX); style.setPaddingBottom(0, Style.Unit.PX); style.setProperty("WebkitBoxSizing", "border-box"); style.setProperty("MozBoxSizing", "border-box"); style.setProperty("boxSizing", "border-box"); style.setProperty("lineHeight", "normal"); // --- End workaround --- getContainer().setWidget(widget);/* w w w. ja v a2 s . c o m*/ }
From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.ListBoxDOMElement.java
License:Apache License
public ListBoxDOMElement(final ListBox widget, final GridLayer gridLayer, final GridWidget gridWidget) { super(widget, gridLayer, gridWidget); final Style style = widget.getElement().getStyle(); style.setWidth(100, Style.Unit.PCT); style.setHeight(HEIGHT, Style.Unit.PX); style.setPaddingLeft(2, Style.Unit.PX); style.setPaddingRight(2, Style.Unit.PX); style.setFontSize(10, Style.Unit.PX); // --- Workaround for BS2 --- style.setPosition(Style.Position.RELATIVE); style.setPaddingTop(0, Style.Unit.PX); style.setPaddingBottom(0, Style.Unit.PX); style.setProperty("WebkitBoxSizing", "border-box"); style.setProperty("MozBoxSizing", "border-box"); style.setProperty("boxSizing", "border-box"); style.setProperty("lineHeight", "normal"); // --- End workaround --- getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX); getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX); getContainer().setWidget(widget);//w w w .ja va 2s . c om }
From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.TextBoxDOMElement.java
License:Apache License
public TextBoxDOMElement(final TextBox widget, final GridLayer gridLayer, final GridWidget gridWidget) { super(widget, gridLayer, gridWidget); final Style style = widget.getElement().getStyle(); style.setWidth(100, Style.Unit.PCT); style.setHeight(HEIGHT, Style.Unit.PX); style.setPaddingLeft(2, Style.Unit.PX); style.setPaddingRight(2, Style.Unit.PX); style.setFontSize(10, Style.Unit.PX); // --- Workaround for BS2 --- style.setPosition(Style.Position.RELATIVE); style.setPaddingTop(0, Style.Unit.PX); style.setPaddingBottom(0, Style.Unit.PX); style.setProperty("WebkitBoxSizing", "border-box"); style.setProperty("MozBoxSizing", "border-box"); style.setProperty("boxSizing", "border-box"); style.setProperty("lineHeight", "normal"); // --- End workaround --- getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX); getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX); getContainer().setWidget(widget);/*from w w w. ja v a 2 s . c o m*/ }
From source file:org.vaadin.alump.fancylayouts.gwt.client.GwtFancyPanel.java
License:Apache License
/** * Clear hardcoded position on the screen * // ww w .j a v a 2 s .c om * @param wrapper */ private void clearWrapperTransitionPosition(Element wrapper) { Style style = wrapper.getStyle(); style.clearPosition(); if (this.isScrollable()) { style.clearHeight(); } else { style.setHeight(100, Unit.PCT); } style.clearTop(); style.clearLeft(); style.clearOverflow(); }
From source file:org.vaadin.alump.fancylayouts.gwt.client.GwtFancyPanel.java
License:Apache License
/** * Set wrapper to hard coded position on the screen * //from w w w. j ava 2s. com * @param wrapper */ private void setWrapperTransitionPosition(Element wrapper) { Style style = wrapper.getStyle(); style.setTop(0, Unit.PX); style.setLeft(0, Unit.PX); style.setHeight(100, Unit.PCT); style.setPosition(Position.ABSOLUTE); style.setOverflow(Overflow.HIDDEN); }
From source file:org.waveprotocol.wave.client.doodad.attachment.render.ImageThumbnailWidget.java
License:Apache License
private void setImageSize() { int width = isFullSize ? attachmentWidth : thumbnailWidth; int height = isFullSize ? attachmentHeight : thumbnailHeight; image.setPixelSize(width, height);/*from w w w . java 2s .c o m*/ //TODO(user,danilatos): Whinge about how declarative UI doesn't let us avoid this hack: Style pstyle = image.getElement().getParentElement().getParentElement().getStyle(); if (width == 0) { image.setWidth(""); pstyle.clearWidth(); } else { pstyle.setWidth(width, Unit.PX); } if (height == 0) { image.setHeight(""); pstyle.clearHeight(); } else { pstyle.setHeight(height, Unit.PX); } String url = isFullSize ? attachmentUrl : thumbnailUrl; if (url != null) { if (doubleBufferLoader == null) { doubleBufferLoader = new DoubleBufferImage(spin, errorLabel, image); } doubleBufferLoader.loadImage(url); DOM.setStyleAttribute(image.getElement(), "visibility", ""); } // NOTE(user): IE requires that the imageCaptionContainer element has a width // in order to correctly center the caption. if (DO_FRAME_WIDTH_UPDATE) { captionPanel.getElement().getStyle().setWidth(width, Unit.PX); } }