List of usage examples for com.google.gwt.dom.client Style setWidth
public void setWidth(double value, Unit unit)
From source file:ilarkesto.gwt.client.desktop.Widgets.java
License:Open Source License
public static Widget verticalSpacer(int height) { SimplePanel spacer = new SimplePanel(); Style style = spacer.getElement().getStyle(); style.setWidth(1, Unit.PX); spacer.getElement().getStyle().setHeight(height, Unit.PX); return spacer; }
From source file:ilarkesto.gwt.client.integration.ace.AceEditor.java
License:Open Source License
@Override public Widget asWidget() { if (div == null) { div = new SimplePanel(); div.getElement().setId(id);/*from ww w.ja v a2 s.c o m*/ Style style = div.getElement().getStyle(); // style.setPosition(Position.ABSOLUTE); // style.setTop(0, Unit.PX); // style.setRight(0, Unit.PX); // style.setBottom(0, Unit.PX); // style.setLeft(0, Unit.PX); style.setWidth(800, Unit.PX); // style.setHeight(400, Unit.PX); style.setBackgroundColor("yellow"); div.addAttachHandler(new AttachEvent.Handler() { @Override public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) { activate(); } } }); } return div; }
From source file:info.magnolia.ui.vaadin.gwt.client.layout.thumbnaillayout.widget.ThumbnailsSizeKeeper.java
License:Open Source License
private void doSetThumbnailSize(int width, int height, Element element) { final Style style = element.getStyle(); style.setFontSize(width * 0.75d, Style.Unit.PX); style.setWidth(width, Style.Unit.PX); style.setHeight(height, Style.Unit.PX); Style imageStyle = element.getElementsByTagName(ImageElement.TAG).getItem(0).getStyle(); imageStyle.setProperty("maxWidth", width + "px"); imageStyle.setProperty("maxHeight", height + "px"); }
From source file:info.magnolia.ui.vaadin.gwt.client.richtext.TextAreaStretcherConnector.java
License:Open Source License
private void stretchTextArea(Style style) { style.setWidth(form.getOffsetWidth(), Style.Unit.PX); adjustTextAreaHeightToScreen(getConnection().getUIConnector().getWidget().getOffsetHeight()); }
From source file:jetbrains.jetpad.cell.toDom.CellContainerToDomMapper.java
License:Apache License
private void refreshLineHighlight() { if (myLineHighlightUpToDate || !isAttached()) return;//from w w w.j av a 2 s . c om Cell current = getSource().focusedCell.get(); for (Element e : Arrays.asList(myLineHighlight1, myLineHighlight2)) { Style style = e.getStyle(); if (current == null || !Cells.isLeaf(current)) { style.setVisibility(Style.Visibility.HIDDEN); } else { int deltaTop = myContent.getAbsoluteTop() - getTarget().getAbsoluteTop(); style.setVisibility(Style.Visibility.VISIBLE); int rootTop = myContent.getAbsoluteTop(); final Element currentElement = getElement(current); int currentTop = currentElement.getAbsoluteTop(); style.setTop(currentTop - rootTop + deltaTop, Style.Unit.PX); style.setHeight(currentElement.getClientHeight(), Style.Unit.PX); if (e == myLineHighlight2) { style.setWidth(0, Style.Unit.PX); style.setWidth(getTarget().getScrollWidth(), Style.Unit.PX); } } } myLineHighlightUpToDate = true; }
From source file:jetbrains.jetpad.projectional.domUtil.DomTextEditor.java
License:Apache License
private void updateCaretAndSelection() { Style caretStyle = myCaretDiv.getStyle(); updateCaretPosition();/*from ww w . j a v a2 s.co m*/ caretStyle.setTop(0, Style.Unit.PX); caretStyle.setWidth(1, Style.Unit.PX); caretStyle.setHeight(getLineHeight(), Style.Unit.PX); caretStyle.setBackgroundColor("black"); Style selectionStyle = mySelectionDiv.getStyle(); selectionStyle.setTop(0, Style.Unit.PX); selectionStyle.setHeight(getLineHeight(), Style.Unit.PX); selectionStyle.setBackgroundColor("Highlight"); selectionStyle.setColor("HighlightText"); updateSelectionBoundsAndText(); }
From source file:jetbrains.jetpad.projectional.domUtil.DomTextEditor.java
License:Apache License
private void updateSelectionBoundsAndText() { int left = Math.min(myCaretPosition, mySelectionStart); int right = Math.max(myCaretPosition, mySelectionStart); String text = myText == null ? "" : myText; text = text.substring(left, right);/*w w w. java2 s. co m*/ Style selectionStyle = mySelectionDiv.getStyle(); selectionStyle.setLeft(getCaretOffset(left), Style.Unit.PX); selectionStyle.setWidth(getCaretOffset(right) - getCaretOffset(left), Style.Unit.PX); mySelectionDiv.setInnerText(TextMetricsCalculator.normalize(text)); }
From source file:jetbrains.jetpad.projectional.view.toGwt.BaseViewMapper.java
License:Apache License
@Override protected void registerSynchronizers(SynchronizersConfiguration conf) { super.registerSynchronizers(conf); Style targetStyle = getTarget().getStyle(); if (!isDomPosition()) { targetStyle.setPosition(Style.Position.ABSOLUTE); } else {/*from w w w .j a v a 2 s . c om*/ targetStyle.setPosition(Style.Position.RELATIVE); } if (!isDomPosition() || !isDomLayout()) { final ReadableProperty<Rectangle> positionInParent; if (getParent() instanceof BaseViewMapper) { final BaseViewMapper<?, ?> parent = (BaseViewMapper<?, ?>) getParent(); positionInParent = new DerivedProperty<Rectangle>(getSource().bounds(), parent.getSource().bounds()) { @Override public Rectangle doGet() { Rectangle sourceBounds = getSource().bounds().get(); Rectangle parentSourceBounds = parent.getSource().bounds().get(); return sourceBounds.sub(parentSourceBounds.origin); } }; } else { positionInParent = getSource().bounds(); } final Value<Boolean> valid = new Value<>(false); conf.add(Synchronizers.forEventSource(EventSources.composite(positionInParent, getSource().border()), new Runnable() { @Override public void run() { valid.set(false); whenValid(new Runnable() { @Override public void run() { if (valid.get()) return; final Rectangle value = positionInParent.get(); Style style = getTarget().getStyle(); if (!isDomPosition()) { style.setLeft(value.origin.x, Style.Unit.PX); style.setTop(value.origin.y, Style.Unit.PX); } if (!isDomLayout()) { int width = value.dimension.x; int height = value.dimension.y; style.setWidth(width, Style.Unit.PX); style.setHeight(height, Style.Unit.PX); } valid.set(true); } }); } })); } if (!isCustomBackgroundSync()) { conf.add(Synchronizers.forPropsOneWay(getSource().background(), new WritableProperty<Color>() { @Override public void set(Color value) { Style style = getTarget().getStyle(); if (value == null) { style.setBackgroundColor(null); } else { style.setBackgroundColor(value.toCssColor()); } } })); } conf.add(Synchronizers.forPropsOneWay(getSource().border(), new WritableProperty<Color>() { @Override public void set(Color value) { Style style = getTarget().getStyle(); if (value != null) { style.setOutlineColor(value.toCssColor()); style.setOutlineWidth(1, Style.Unit.PX); style.setOutlineStyle(Style.OutlineStyle.SOLID); } else { style.clearOutlineStyle(); style.clearOutlineColor(); style.clearBorderWidth(); } } })); conf.add(Synchronizers.forPropsOneWay(getSource().visible(), new WritableProperty<Boolean>() { @Override public void set(final Boolean value) { whenValid(new Runnable() { @Override public void run() { getTarget().getStyle().setDisplay(value ? Style.Display.BLOCK : Style.Display.NONE); } }); } })); conf.add(Synchronizers.forPropsOneWay(getSource().hasShadow(), new WritableProperty<Boolean>() { @Override public void set(Boolean value) { if (value) { getTarget().getStyle().setProperty("boxShadow", "2px 2px 4px black"); } else { getTarget().getStyle().setProperty("boxShadow", null); } } })); }
From source file:next.i.controller.Utils.java
License:Apache License
static void fillParent(Element elem) { Style style = elem.getStyle(); style.setPosition(Position.ABSOLUTE); style.setLeft(0, PX);//from w w w .j a v a2 s . co m style.setTop(0, PX); style.setRight(0, PX); style.setBottom(0, PX); style.setWidth(100, Unit.PCT); style.setHeight(100, Unit.PCT); }
From source file:org.anstis.client.grid.widget.dom.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 ava 2 s. com */ protected void transform(final GridCellRenderContext context) { final Transform transform = context.getTransform(); final double width = context.getWidth(); final double height = context.getHeight(); final Style style = container.getElement().getStyle(); //Reposition and transform the DOM Element style.setLeft((context.getX() * transform.getScaleX()) + transform.getTranslateX(), Style.Unit.PX); style.setTop((context.getY() * transform.getScaleY()) + transform.getTranslateY(), Style.Unit.PX); style.setWidth(width, Style.Unit.PX); style.setHeight(height, Style.Unit.PX); if (isOne(transform.getScaleX()) && isOne(transform.getScaleY())) { style.clearProperty("WebkitTransform"); style.clearProperty("MozTransform"); style.clearProperty("Transform"); 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); }