List of usage examples for com.google.gwt.dom.client Style setPropertyPx
public void setPropertyPx(String name, int value)
From source file:com.extjs.gxt.ui.client.widget.treepanel.TreePanel.java
License:sencha.com license
private void ensureFocusElement() { if (focusEl != null) { focusEl.removeFromParent();//from www .j av a 2 s .co m } focusEl = new El(DOM.asOld(focusImpl.createFocusable())); focusEl.dom.getStyle().setProperty("outline", "none"); getElement().appendChild(focusEl.dom); if (focusEl.dom.hasChildNodes()) { focusEl.dom.getFirstChildElement().getStyle().setProperty("outline", "none"); com.google.gwt.dom.client.Style focusElStyle = focusEl.dom.getFirstChildElement().getStyle(); focusElStyle.setProperty("borderWidth", "0px"); focusElStyle.setProperty("fontSize", "1px"); focusElStyle.setPropertyPx("lineHeight", 1); } focusEl.setLeft(0); focusEl.setTop(0); focusEl.makePositionable(true); focusEl.addEventsSunk(Event.FOCUSEVENTS); }
From source file:com.google.gerrit.client.change.RightSidePopdownAction.java
License:Apache License
void show() { if (popup != null) { button.removeStyleName(style.selected()); popup.hide();//from www. j a va2 s.co m return; } final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; p.setStyleName(style.replyBox()); p.addAutoHidePartner(button.getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { button.removeStyleName(style.selected()); popup = null; } } }); p.add(getWidget()); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); button.addStyleName(style.selected()); popup = p; }
From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.LeftTabPanel.java
License:Apache License
public LeftTabPanel() { initWidget(main);/* w ww. j a v a2s. co m*/ main.add(left); left.add(leftTree); DecoratorPanel decorator = new DecoratorPanel(); Style decoratorStyle = decorator.getElement().getStyle(); decoratorStyle.setPropertyPx("marginLeft", 15); Style rightStyle = right.getElement().getStyle(); rightStyle.setPropertyPx("margin", 5); decorator.add(right); main.add(decorator); leftTree.addSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { String name = event.getSelectedItem().getText(); setWidget(right, cogs.get(name)); } }); }
From source file:com.google.livingstories.client.ui.AnchoredPanel.java
License:Apache License
@Override public void setWidget(Widget widget) { super.setWidget(widget); Style style = widget.getElement().getStyle(); style.setProperty("position", "relative"); style.setPropertyPx("left", 0); style.setPropertyPx("top", 0); removeHandlers();// w w w. j ava 2 s .c om scrollHandler = Window.addWindowScrollHandler(new ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { reposition(); } }); resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { reposition(); } }); }
From source file:com.google.livingstories.client.ui.AnchoredPanel.java
License:Apache License
public void reposition() { Widget content = getWidget();/* ww w .j a v a 2s . c o m*/ Element boundingBox = getElement().getParentElement(); int windowTop = Window.getScrollTop(); int windowLeft = Window.getScrollLeft(); int topBound = boundingBox.getAbsoluteTop(); int bottomBound = topBound + boundingBox.getOffsetHeight() - content.getOffsetHeight(); if (!scrolling) { if (windowTop > topBound && windowTop < bottomBound) { scrolling = true; Style style = content.getElement().getStyle(); style.setProperty("position", "fixed"); style.setPropertyPx("top", 0); style.setPropertyPx("left", boundingBox.getAbsoluteLeft() - windowLeft); } } else { if (windowTop < topBound) { scrolling = false; Style style = content.getElement().getStyle(); style.setProperty("position", "relative"); style.setPropertyPx("top", 0); style.setPropertyPx("left", 0); } else if (windowTop > bottomBound) { scrolling = false; Style style = content.getElement().getStyle(); style.setProperty("position", "relative"); // Can't use bottom:0px here because the spacer has no height. // Even if we set the spacer's height to be 100%, it won't necessarily // work if this panel is in a table cell. style.setPropertyPx("top", bottomBound - topBound); style.setPropertyPx("left", 0); } else { content.getElement().getStyle().setPropertyPx("left", boundingBox.getAbsoluteLeft() - windowLeft); } } }
From source file:com.google.speedtracer.client.view.GraphCallout.java
License:Apache License
private void paint(int xPosition, int durationPixels) { canvas.setStrokeStyle(Color.BLACK); canvas.setLineWidth(2.0);// ww w . ja va 2s .c om canvas.beginPath(); // Determine which horizontal direction the leader should be drawn. int distanceFromRight = Window.getInnerWidth() - (parentElement.getAbsoluteLeft() + xPosition); boolean reverseLeader = distanceFromRight < reverseTippingPoint; Style canvasStyle = canvas.getElement().getStyle(); Style labelStyle = label.getStyle(); Style durationStyle = element.getStyle(); // If the duration div runs off of the left, it overwrites the // title, so fix that up. if (xPosition <= 0) { durationPixels += xPosition; xPosition = 0; durationStyle.setProperty("borderLeft", "none"); } else { durationStyle.setProperty("borderLeft", "1px solid #000"); } // Set the width of the duration div if (reverseLeader) { durationPixels = Math.min(distanceFromRight, durationPixels); } durationStyle.setProperty("display", "block"); durationStyle.setPropertyPx("width", Math.max(durationPixels, MINIMUM_DURATION_DISPLAY_WIDTH)); durationStyle.setPropertyPx("left", xPosition); if (reverseLeader) { // Close to the right margin, so flip the direction of the leader // draw the vertical part on the right side of the canvas. labelStyle.setPropertyPx("left", -(css.leadWidth() + label.getOffsetWidth())); canvasStyle.setPropertyPx("left", -css.leadWidth()); // Draw the leader canvas.moveTo(css.leadWidth(), css.leadHeight()); canvas.setLineWidth(1.0); canvas.lineTo(0, 0); } else { // Draw the vertical part of the leader on the left side of the canvas. // If the xPosition would run into the scale label, move it over a little. int labelOffset = css.leadWidth() + ((xPosition <= 20) ? 20 : 0); labelStyle.setPropertyPx("left", labelOffset); canvasStyle.setPropertyPx("left", 0); // Draw the leader canvas.moveTo(0, css.leadHeight()); canvas.setLineWidth(0.5); canvas.lineTo(css.leadWidth(), 0); } canvas.stroke(); }
From source file:com.google.speedtracer.client.visualizations.view.EventTraceBreakdown.java
License:Apache License
public Renderer createRenderer(UiEvent event, int depth) { ensureMasterIsRendered();/*from w w w .ja v a2 s .c o m*/ int width = (int) (event.getDuration() * domainToPixels); // We may have truncated something that, on aggregate may matter. // If this node has a dominant color set, then it contains a child that is // one of the important ones... show it with a 1 pixel bar. if (width == 0 && presenter.hasDominantType(event, rootEvent, domainToPixels)) { width = 1; } Css css = resources.eventTraceBreakdownCss(); final Canvas canvas = new Canvas(width, COORD_HEIGHT); canvas.setLineWidth(2); final Element element = canvas.getElement(); final Style style = element.getStyle(); element.setClassName(css.eventGraph()); style.setPropertyPx("left", getLeftOffset(event, depth)); style.setPropertyPx("width", width); return new Renderer(canvas, event); }
From source file:com.googlesource.gerrit.plugins.cookbook.client.PopDownButton.java
License:Apache License
private void show() { if (popup != null) { getElement().getStyle().clearFontWeight(); popup.hide();/* w ww .ja v a 2 s .c om*/ return; } final Widget relativeTo = getParent(); final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; Style popupStyle = p.getElement().getStyle(); popupStyle.setBorderWidth(0, Unit.PX); popupStyle.setBackgroundColor("#EEEEEE"); p.addAutoHidePartner(getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { getElement().getStyle().clearFontWeight(); popup = null; } } }); p.add(widget); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); getElement().getStyle().setFontWeight(FontWeight.BOLD); popup = p; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.aggregation.TableAggregationRow.java
License:Apache License
public void setCellWidth(int cellIx, int width) { // CAUTION: copied from VScrollTableRow with small changes final Element cell = DOM.getChild(tr, cellIx); Style wrapperStyle = cell.getFirstChildElement().getStyle(); int wrapperWidth = width; if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isOpera10()) { /*/* w ww.java 2 s . co m*/ * Some versions of Webkit and Opera ignore the width * definition of zero width table cells. Instead, use 1px * and compensate with a negative margin. */ if (width == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Style.Unit.PX); } else { wrapperStyle.clearMarginRight(); } } wrapperStyle.setPropertyPx("width", wrapperWidth); cell.getStyle().setPropertyPx("width", width); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout.CubaFieldGroupLayoutComponentSlot.java
License:Apache License
@Override public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) { if (!isCaptionInline()) { super.positionHorizontally(currentLocation, allocatedSpace, marginRight); return;// w w w .j a va 2 s.com } // CAUTION copied from VLayoutSlot.positionHorizontally(~) Style style = wrapper.getStyle(); double availableWidth = allocatedSpace; VCaption caption = getCaption(); Style captionStyle = caption != null ? caption.getElement().getStyle() : null; int captionWidth = getCaptionWidth(); boolean clearCaptionRight = false; boolean captionAboveCompnent; if (caption == null) { captionAboveCompnent = false; style.clearPaddingLeft(); clearCaptionRight = true; } else { captionAboveCompnent = !caption.shouldBePlacedAfterComponent(); if (!captionAboveCompnent) { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } captionStyle.clearLeft(); captionStyle.setRight(0, Style.Unit.PX); style.setPaddingRight(captionWidth, Style.Unit.PX); } else { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingLeft(captionWidth, Style.Unit.PX); captionStyle.setLeft(0, Style.Unit.PX); captionStyle.clearRight(); clearCaptionRight = true; } } // Take into account right indicators double indicatorsWidth = 0; if (rightCaption != null) { indicatorsWidth = WidgetUtil.getRequiredWidth(rightCaption); availableWidth -= indicatorsWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingRight(indicatorsWidth, Style.Unit.PX); } else if (clearCaptionRight) { style.clearPaddingRight(); } if (marginRight > 0) { style.setMarginRight(marginRight, Style.Unit.PX); } else { style.clearMarginRight(); } if (isRelativeWidth()) { style.setPropertyPx("width", (int) availableWidth); } else { style.clearProperty("width"); } double allocatedContentWidth = 0; if (isRelativeWidth()) { String percentWidth = getWidget().getElement().getStyle().getWidth(); double percentage = parsePercent(percentWidth); allocatedContentWidth = availableWidth * (percentage / 100); reportActualRelativeWidth(Math.round((float) allocatedContentWidth)); } AlignmentInfo alignment = getAlignment(); if (!alignment.isLeft()) { double usedWidth; if (isRelativeWidth()) { if (isCaptionInline()) { usedWidth = allocatedContentWidth + indicatorsWidth + captionWidth; } else { usedWidth = allocatedContentWidth + indicatorsWidth; } } else { usedWidth = getWidgetWidth() + indicatorsWidth; } if (alignment.isHorizontalCenter()) { currentLocation += (allocatedSpace - usedWidth) / 2d; if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth) / 2, Style.Unit.PX); } } else { currentLocation += (allocatedSpace - usedWidth); if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth), Style.Unit.PX); } } } else { if (captionAboveCompnent) { captionStyle.setLeft(0, Style.Unit.PX); } } style.setLeft(Math.round(currentLocation), Style.Unit.PX); }