List of usage examples for com.google.gwt.dom.client Style setPropertyPx
public void setPropertyPx(String name, int value)
From source file:com.ksyzt.gwt.client.ui.richeditor.RichTextToolbar.java
License:Open Source License
/** * Method to create the colorlist for the toolbar *. * * @return the color label//from w w w. jav a2 s.c om */ private ColorLabel createColorList() { colorlist = new ColorLabel(); Style style = colorlist.getElement().getStyle(); style.setDisplay(Display.BLOCK); style.setPropertyPx("lineHeight", 14); style.setCursor(Cursor.POINTER); colorlist.setWidth("60px"); colorlist.addMessageHandler(m_color_handler); return colorlist; }
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * * @param size/* w w w. j a v a 2 s .c om*/ * @return */ private HTML createSrokeSize(int size, ACTION action) { HTML strokeSize = new HTML(" "); strokeSize.setStylePrimaryName("strokeProperty"); strokeSize.setTitle("Size of stroke " + size); Style style = strokeSize.getElement().getStyle(); style.setProperty("borderTop", "solid"); style.setPropertyPx("borderWidth", size); palette.add(strokeSize); this.addAction(strokeSize, action); return strokeSize; }
From source file:com.sencha.gxt.widget.core.client.ListView.java
License:sencha.com license
private void ensureFocusElement() { if (focusEl != null) { focusEl.removeFromParent();//from w w w .j av a 2 s. co m } focusEl = (XElement) getElement().appendChild(focusImpl.createFocusable()); focusEl.addClassName(CommonStyles.get().noFocusOutline()); if (focusEl.hasChildNodes()) { focusEl.getFirstChildElement().addClassName(CommonStyles.get().noFocusOutline()); com.google.gwt.dom.client.Style focusElStyle = focusEl.getFirstChildElement().getStyle(); focusElStyle.setBorderWidth(0, Unit.PX); focusElStyle.setFontSize(1, Unit.PX); focusElStyle.setPropertyPx("lineHeight", 1); } focusEl.setLeft(0); focusEl.setTop(0); focusEl.makePositionable(true); focusEl.addEventsSunk(Event.FOCUSEVENTS); }
From source file:com.tractionsoftware.gwt.user.client.util.Geometry.java
License:Apache License
/** * Sets the position of a UIObject/*from w w w .j a v a2 s .co m*/ */ public static final void setPosition(UIObject o, Rect pos) { Style style = o.getElement().getStyle(); style.setPropertyPx("left", pos.x); style.setPropertyPx("top", pos.y); }
From source file:com.vaadin.client.ui.layout.VLayoutSlot.java
License:Apache License
public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) { Style style = wrapper.getStyle(); double availableWidth = allocatedSpace; VCaption caption = getCaption();/*from w w w. j a v a 2 s .co m*/ Style captionStyle = caption != null ? caption.getElement().getStyle() : null; int captionWidth = getCaptionWidth(); boolean captionAboveCompnent; if (caption == null) { captionAboveCompnent = false; style.clearPaddingRight(); } else { captionAboveCompnent = !caption.shouldBePlacedAfterComponent(); if (!captionAboveCompnent) { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } captionStyle.clearLeft(); captionStyle.setRight(0, Unit.PX); style.setPaddingRight(captionWidth, Unit.PX); } else { captionStyle.setLeft(0, Unit.PX); captionStyle.clearRight(); style.clearPaddingRight(); } } if (marginRight > 0) { style.setMarginRight(marginRight, Unit.PX); } else { style.clearMarginRight(); } style.setPropertyPx("width", (int) availableWidth); double allocatedContentWidth = 0; if (isRelativeWidth()) { String percentWidth = getWidget().getElement().getStyle().getWidth(); double percentage = parsePercent(percentWidth); allocatedContentWidth = availableWidth * (percentage / 100); reportActualRelativeWidth(Math.round((float) allocatedContentWidth)); } style.setLeft(Math.round(currentLocation), Unit.PX); AlignmentInfo alignment = getAlignment(); if (!alignment.isLeft()) { double usedWidth; if (isRelativeWidth()) { usedWidth = allocatedContentWidth; } else { usedWidth = getWidgetWidth(); } double padding = (allocatedSpace - usedWidth); if (alignment.isHorizontalCenter()) { padding = padding / 2; } long roundedPadding = Math.round(padding); if (captionAboveCompnent) { captionStyle.setLeft(roundedPadding, Unit.PX); } widget.getElement().getStyle().setLeft(roundedPadding, Unit.PX); } else { if (captionAboveCompnent) { captionStyle.setLeft(0, Unit.PX); } // Reset left when changing back to align left widget.getElement().getStyle().clearLeft(); } }
From source file:com.vaadin.client.ui.VTabsheet.java
License:Apache License
/** For internal use only. May be removed or replaced in the future. */ public void updateDynamicWidth() { // Find width consumed by tabs TableCellElement spacerCell = ((TableElement) tb.getElement().cast()).getRows().getItem(0).getCells() .getItem(tb.getTabCount());//www . j ava 2s . c om int spacerWidth = spacerCell.getOffsetWidth(); DivElement div = (DivElement) spacerCell.getFirstChildElement(); int spacerMinWidth = spacerCell.getOffsetWidth() - div.getOffsetWidth(); int tabsWidth = tb.getOffsetWidth() - spacerWidth + spacerMinWidth; // Find content width Style style = tabPanel.getElement().getStyle(); String overflow = style.getProperty("overflow"); style.setProperty("overflow", "hidden"); style.setPropertyPx("width", tabsWidth); boolean hasTabs = tabPanel.getWidgetCount() > 0; Style wrapperstyle = null; if (hasTabs) { wrapperstyle = getCurrentlyDisplayedWidget().getElement().getParentElement().getStyle(); wrapperstyle.setPropertyPx("width", tabsWidth); } // Get content width from actual widget int contentWidth = 0; if (hasTabs) { contentWidth = getCurrentlyDisplayedWidget().getOffsetWidth(); } style.setProperty("overflow", overflow); // Set widths to max(tabs,content) if (tabsWidth < contentWidth) { tabsWidth = contentWidth; } int outerWidth = tabsWidth + getContentAreaBorderWidth(); tabs.getStyle().setPropertyPx("width", outerWidth); style.setPropertyPx("width", tabsWidth); if (hasTabs) { wrapperstyle.setPropertyPx("width", tabsWidth); } contentNode.getStyle().setPropertyPx("width", tabsWidth); super.setWidth(outerWidth + "px"); updateOpenTabSize(); }
From source file:com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout.java
License:Open Source License
protected boolean measureMarginsAndSpacing() { if (!isAttached()) { return false; }// w w w . j a va2s. co m // Measure spacing (actually CSS padding) measurement3.setClassName(STYLENAME_SPACING + (spacingEnabled ? "-on" : "-off")); String sn = getStylePrimaryName() + "-margin"; if (activeMarginsInfo.hasTop()) { sn += " " + STYLENAME_MARGIN_TOP; } if (activeMarginsInfo.hasBottom()) { sn += " " + STYLENAME_MARGIN_BOTTOM; } if (activeMarginsInfo.hasLeft()) { sn += " " + STYLENAME_MARGIN_LEFT; } if (activeMarginsInfo.hasRight()) { sn += " " + STYLENAME_MARGIN_RIGHT; } // Measure top and left margins (actually CSS padding) measurement.setClassName(sn); root.appendChild(helper); activeSpacing.vSpacing = measurement3.getOffsetHeight(); activeSpacing.hSpacing = measurement3.getOffsetWidth(); activeMargins.setMarginTop(measurement2.getOffsetTop()); activeMargins.setMarginLeft(measurement2.getOffsetLeft()); activeMargins.setMarginRight(measurement.getOffsetWidth() - activeMargins.getMarginLeft()); activeMargins.setMarginBottom(measurement.getOffsetHeight() - activeMargins.getMarginTop()); // ApplicationConnection.getConsole().log("Margins: " + activeMargins); // ApplicationConnection.getConsole().log("Spacing: " + activeSpacing); // Util.alert("Margins: " + activeMargins); root.removeChild(helper); // apply margin Style style = root.getStyle(); style.setPropertyPx("marginLeft", activeMargins.getMarginLeft()); style.setPropertyPx("marginRight", activeMargins.getMarginRight()); style.setPropertyPx("marginTop", activeMargins.getMarginTop()); style.setPropertyPx("marginBottom", activeMargins.getMarginBottom()); return true; }
From source file:com.vaadin.terminal.gwt.client.ui.VTabsheet.java
License:Open Source License
private void updateDynamicWidth() { // Find width consumed by tabs TableCellElement spacerCell = ((TableElement) tb.getElement().cast()).getRows().getItem(0).getCells() .getItem(tb.getTabCount());//from www . j a v a 2 s. c om int spacerWidth = spacerCell.getOffsetWidth(); DivElement div = (DivElement) spacerCell.getFirstChildElement(); int spacerMinWidth = spacerCell.getOffsetWidth() - div.getOffsetWidth(); int tabsWidth = tb.getOffsetWidth() - spacerWidth + spacerMinWidth; // Find content width Style style = tp.getElement().getStyle(); String overflow = style.getProperty("overflow"); style.setProperty("overflow", "hidden"); style.setPropertyPx("width", tabsWidth); boolean hasTabs = tp.getWidgetCount() > 0; Style wrapperstyle = null; if (hasTabs) { wrapperstyle = tp.getWidget(tp.getVisibleWidget()).getElement().getParentElement().getStyle(); wrapperstyle.setPropertyPx("width", tabsWidth); } // Get content width from actual widget int contentWidth = 0; if (hasTabs) { contentWidth = tp.getWidget(tp.getVisibleWidget()).getOffsetWidth(); } style.setProperty("overflow", overflow); // Set widths to max(tabs,content) if (tabsWidth < contentWidth) { tabsWidth = contentWidth; } int outerWidth = tabsWidth + getContentAreaBorderWidth(); tabs.getStyle().setPropertyPx("width", outerWidth); style.setPropertyPx("width", tabsWidth); if (hasTabs) { wrapperstyle.setPropertyPx("width", tabsWidth); } contentNode.getStyle().setPropertyPx("width", tabsWidth); super.setWidth(outerWidth + "px"); updateOpenTabSize(); }
From source file:fr.putnami.pwt.core.widget.client.Image.java
License:Open Source License
private void resetSize() { Style imgStyle = this.imgElement.getStyle(); imgStyle.clearProperty(Image.PROP_WIDTH); imgStyle.clearProperty(Image.PROP_HEIGHT); imgStyle.clearProperty(Image.PROP_MAX_WIDTH); imgStyle.clearProperty(Image.PROP_MAX_HEIGHT); if (this.widthPx > 0) { imgStyle.setPropertyPx(this.keepPropertions ? Image.PROP_MAX_WIDTH : Image.PROP_WIDTH, this.widthPx); }/*from w w w . j a v a 2s .c o m*/ if (this.heightPx > 0) { imgStyle.setPropertyPx(this.keepPropertions ? Image.PROP_MAX_HEIGHT : Image.PROP_HEIGHT, this.heightPx); } }
From source file:org.cruxframework.crux.core.client.screen.widgets.ScreenBlocker.java
License:Apache License
private static void expandElementToScreen(Widget widget) { Style style = widget.getElement().getStyle(); style.setProperty("position", "absolute"); style.setPropertyPx("top", 0); style.setPropertyPx("left", 0); style.setProperty("width", "100%"); style.setProperty("height", "100%"); }