private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) { AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); // Create the wrapper based on the vertical alignment. SafeStylesBuilder cssStyles = new SafeStylesBuilder().appendTrustedString(direction + ":0px;"); if (HasVerticalAlignment.ALIGN_TOP == valign) { return templates.imageWrapperTop(cssStyles.toSafeStyles(), image); } else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) { return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image); } else { int halfHeight = (int) Math.round(res.getHeight() / 2.0); cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;"); return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image); } }
public static String decorate(SafeHtml toDecorate, String aId, PublishedCell aCell, VerticalAlignmentConstant valign, SafeHtmlBuilder sb) { SafeStylesBuilder stb = new SafeStylesBuilder(); SafeUri imgSrc = null; if (aCell != null) { stb.append(SafeStylesUtils.fromTrustedString(aCell.toStyledWOBackground())); if (aCell.getIcon() != null) { ImageResource icon = aCell.getIcon(); imgSrc = icon.getSafeUri(); } } String decorId; if (aId != null && !aId.isEmpty()) { decorId = aId; } else { decorId = Document.get().createUniqueId(); } if (imgSrc != null) sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(), imgSrc, decorId, toDecorate)); else sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(), decorId, toDecorate)); return decorId; }
public ActionIconCellDecorator(ImageResource icon, Cell<C> cell, VerticalAlignmentConstant valign, int spacing, Delegate<C> delegate) { super(icon, cell, valign, spacing); this.delegate = delegate; this.iconHtml = getImageHtml(icon, valign); }
@Override public VerticalAlignmentConstant getVerticalCellAlignment() { return HasVerticalAlignment.ALIGN_TOP; }
/** * setCellVerticalAlignment */ public void setCellVerticalAlignment(Widget w, VerticalAlignmentConstant align) { vPanel.setCellVerticalAlignment(w, align); }
@SuppressWarnings("deprecation") protected void setCellVerticalAlignment(Element td, VerticalAlignmentConstant align) { setCellVerticalAlignment(DOM.asOld(td), align); }
/** * @deprecated Call and override {@link #setCellVerticalAlignment(Element, * VerticalAlignmentConstant)} instead. */ @Deprecated protected void setCellVerticalAlignment(com.google.gwt.user.client.Element td, VerticalAlignmentConstant align) { td.getStyle().setProperty("verticalAlign", align.getVerticalAlignString()); }
/** * Sets the vertical alignment of the specified cell. * * @param row the row of the cell whose alignment is to be set * @param column the column of the cell whose alignment is to be set * @param align the cell's new vertical alignment as specified in * {@link HasVerticalAlignment}. * @throws IndexOutOfBoundsException */ public void setVerticalAlignment(int row, int column, VerticalAlignmentConstant align) { prepareCell(row, column); DOM.setStyleAttribute(getCellElement(bodyElem, row, column), "verticalAlign", align.getVerticalAlignString()); }
/** * Sets the vertical alignment of the given widget within its cell. * * @param w the widget whose vertical alignment is to be set * @param align the widget's vertical alignment, as defined in * {@link HasVerticalAlignment}. */ public void setCellVerticalAlignment(Widget w, HasVerticalAlignment.VerticalAlignmentConstant align) { Element td = getWidgetTd(w); if (td != null) { setCellVerticalAlignment(td, align); } }
/** * setCellVerticalAlignment * * @param w * @param align */ public void setCellVerticalAlignment(Widget w, VerticalAlignmentConstant align) { vPanel.setCellVerticalAlignment(w, align); }
/** * Sets the horizontal and vertical alignment of the specified cell's * contents. * * @param row the row of the cell whose alignment is to be set * @param column the column of the cell whose alignment is to be set * @param hAlign the cell's new horizontal alignment as specified in * {@link HasHorizontalAlignment} * @param vAlign the cell's new vertical alignment as specified in * {@link HasVerticalAlignment} * @throws IndexOutOfBoundsException */ public void setAlignment(int row, int column, HorizontalAlignmentConstant hAlign, VerticalAlignmentConstant vAlign) { setHorizontalAlignment(row, column, hAlign); setVerticalAlignment(row, column, vAlign); }
/** * Sets the vertical alignment of the specified row. * * @param row the row whose alignment is to be set * @param align the row's new vertical alignment as specified in * {@link HasVerticalAlignment} * @throws IndexOutOfBoundsException */ public void setVerticalAlign(int row, VerticalAlignmentConstant align) { DOM.setStyleAttribute(ensureElement(row), "verticalAlign", align.getVerticalAlignString()); }
/** * Overloaded version for IsWidget. * * @see #setCellVerticalAlignment(Widget,HasVerticalAlignment.VerticalAlignmentConstant) */ public void setCellVerticalAlignment(IsWidget w, VerticalAlignmentConstant align) { this.setCellVerticalAlignment(w.asWidget(),align); }
public VerticalAlignmentConstant getVerticalCellAlignment();
public VerticalAlignmentConstant getVerticalAlignment() { return iVerticalAlignment; }
public void setVerticalAlignment(VerticalAlignmentConstant vertical) { iVerticalAlignment = vertical; }