@Override public StylesBuilder height(double value, Unit unit) { delegate.assertCanAddStyleProperty().setHeight(value, unit); return this; }
@Override protected void onUpdate(double progress) { double delta = (endSize - startSize) * progress; double newSize = startSize + delta; borderElement.getStyle().setHeight(newSize, Unit.PX); }
/** * Set the height in pixels of the scrollable content that the scrollbar * controls. * * <p> * This is not the same as the maximum scroll top position. The maximum scroll * position equals the <code>scrollHeight- offsetHeight</code>; * * @param height the size height pixels */ public void setScrollHeight(int height) { contentDiv.getStyle().setHeight(height, Unit.PX); }
@Override protected void onComplete() { if (endSize == 0) { borderElement.getStyle().setDisplay(Display.NONE); return; } borderElement.getStyle().setHeight(endSize, Unit.PX); }
@Override protected void onUpdate(double progress) { if (opening) { double curHeight = progress * height; animFrame.getStyle().setHeight(curHeight, Unit.PX); } else { double curHeight = (1.0 - progress) * height; animFrame.getStyle().setHeight(curHeight, Unit.PX); } // Remind IE6 that we want the overflow to be hidden. animFrame.getStyle().setOverflow(Overflow.HIDDEN); animFrame.getStyle().setPosition(Position.RELATIVE); }
} else { requiredFieldsNoteLabel.setVisible(false); requiredFieldsNoteLabel.getElement().getParentElement().getStyle().setHeight(0, Unit.PX);
public void onResize(ResizeEvent event) { Style style = glass.getStyle(); int winWidth = Window.getClientWidth(); int winHeight = Window.getClientHeight(); // Hide the glass while checking the document size. Otherwise it would // interfere with the measurement. style.setDisplay(Display.NONE); style.setWidth(0, Unit.PX); style.setHeight(0, Unit.PX); int width = Document.get().getScrollWidth(); int height = Document.get().getScrollHeight(); // Set the glass size to the larger of the window's client size or the // document's scroll size. style.setWidth(Math.max(width, winWidth), Unit.PX); style.setHeight(Math.max(height, winHeight), Unit.PX); // The size is set. Show the glass again. style.setDisplay(Display.BLOCK); } };
@Override protected void onStart() { if (opening) { animFrame.getStyle().setHeight(1.0, Unit.PX); animFrame.getStyle().setPosition(Position.RELATIVE); animFrame.getStyle().clearDisplay(); height = contentContainer.getScrollHeight(); } else { height = contentContainer.getOffsetHeight(); } }
/** * Update the layout. */ private void forceLayout() { // No sense in doing layout if we aren't attached or have no content. if (!isAttached() || content == null) { return; } // Resize the content area to fit between the header and footer. int remainingHeight = getElement().getClientHeight(); if (header != null) { int height = Math.max(0, headerContainer.getOffsetHeight()); remainingHeight -= height; contentContainer.getStyle().setTop(height, Unit.PX); } else { contentContainer.getStyle().setTop(0.0, Unit.PX); } if (footer != null) { remainingHeight -= footerContainer.getOffsetHeight(); } contentContainer.getStyle().setHeight(Math.max(0, remainingHeight), Unit.PX); // Provide resize to child. if (content instanceof RequiresResize) { ((RequiresResize) content).onResize(); } }
protected static DivElement createRuler(Unit widthUnit, Unit heightUnit) { DivElement ruler = Document.get().createDivElement(); ruler.setInnerHTML(" "); Style style = ruler.getStyle(); style.setPosition(Position.ABSOLUTE); style.setZIndex(-32767); // Position the ruler off the top edge, double the size just to be // extra sure it doesn't show up on the screen. style.setTop(-20, heightUnit); // Note that we are making the ruler element 10x10, because some browsers // generate non-integral ratios (e.g., 1em == 13.3px), so we need a little // extra precision. style.setWidth(10, widthUnit); style.setHeight(10, heightUnit); style.setVisibility(Visibility.HIDDEN); State.HIDDEN.set(ruler, true); return ruler; }
/** * Redraw the widget. */ public void redraw() { SafeHtmlBuilder sb = new SafeHtmlBuilder(); cell.render(createContext(), value, sb); getElement().setInnerSafeHtml(sb.toSafeHtml()); /* * The rendered Cell should fill the root element so height and width styles * applied to the widget also apply to the Cell. If there is exactly one * child element, the height and width are set to 100% to fill the parent. */ Element child = getElement().getFirstChildElement(); if (child != null && child.getNextSiblingElement() == null) { child.getStyle().setHeight(100, Unit.PCT); child.getStyle().setWidth(100, Unit.PCT); } }
int height = offsetHeight + 100; int width = offsetWidth + 100; expandableInner.getStyle().setHeight(height, Unit.PX); expandableInner.getStyle().setWidth(width, Unit.PX); expandable.setScrollTop(height);
@Override protected void onUpdate(double progress) { double delta = (endSize - startSize) * progress; double newSize = startSize + delta; borderElement.getStyle().setHeight(newSize, Unit.PX); }
scrollLock.getStyle().setLeft(0, Unit.PX); scrollLock.getStyle().setHeight(1, Unit.PX); scrollLock.getStyle().setWidth(1, Unit.PX); getElement().appendChild(scrollLock);
expandable.getStyle().setVisibility(Visibility.HIDDEN); expandable.getStyle().setPosition(Position.ABSOLUTE); expandable.getStyle().setHeight(100.0, Unit.PCT); expandable.getStyle().setWidth(100.0, Unit.PCT); expandable.getStyle().setOverflow(Overflow.SCROLL); collapsible.getStyle().setVisibility(Visibility.HIDDEN); collapsible.getStyle().setPosition(Position.ABSOLUTE); collapsible.getStyle().setHeight(100.0, Unit.PCT); collapsible.getStyle().setWidth(100.0, Unit.PCT); collapsible.getStyle().setOverflow(Overflow.SCROLL); collapsibleInner = Document.get().createDivElement().cast(); collapsibleInner.getStyle().setWidth(200, Unit.PCT); collapsibleInner.getStyle().setHeight(200, Unit.PCT); collapsible.appendChild(collapsibleInner); DOM.sinkEvents(collapsible, Event.ONSCROLL);
int height = Math.max(Window.getClientHeight(), Document.get().getScrollHeight()); glassElem.getStyle().setHeight(height, Unit.PX); glassElem.getStyle().setWidth(width, Unit.PX); Document.get().getBody().appendChild(glassElem);
public HeaderPanel() { // Create the outer element Element elem = Document.get().createDivElement().cast(); elem.getStyle().setPosition(Position.RELATIVE); elem.getStyle().setOverflow(Overflow.HIDDEN); setElement(elem); // Create a delegate to handle resize from the header and footer. ResizeLayoutPanel.Impl.Delegate resizeDelegate = new ResizeLayoutPanel.Impl.Delegate() { public void onResize() { scheduledLayout(); } }; // Create the header container. headerContainer = createContainer(); headerContainer.getStyle().setTop(0.0, Unit.PX); headerImpl.init(headerContainer, resizeDelegate); elem.appendChild(headerContainer); // Create the footer container. footerContainer = createContainer(); footerContainer.getStyle().setBottom(0.0, Unit.PX); footerImpl.init(footerContainer, resizeDelegate); elem.appendChild(footerContainer); // Create the content container. contentContainer = createContainer(); contentContainer.getStyle().setOverflow(Overflow.HIDDEN); contentContainer.getStyle().setTop(0.0, Unit.PX); contentContainer.getStyle().setHeight(0.0, Unit.PX); elem.appendChild(contentContainer); }
/** * Recalculate the height and width of a native scrollbar. */ private static void maybeRecalculateNativeScrollbarSize() { // Check if the size has already been calculated. if (nativeHeight > -1) { return; } // Create a scrollable element and attach it to the body. Element scrollable = Document.get().createDivElement(); scrollable.getStyle().setPosition(Position.ABSOLUTE); scrollable.getStyle().setTop(-1000.0, Unit.PX); scrollable.getStyle().setLeft(-1000.0, Unit.PX); scrollable.getStyle().setHeight(100.0, Unit.PX); scrollable.getStyle().setWidth(100.0, Unit.PX); scrollable.getStyle().setOverflow(Overflow.SCROLL); scrollable.getStyle().setProperty("direction", "rtl"); Document.get().getBody().appendChild(scrollable); // Add some content. Element content = Document.get().createDivElement(); content.setInnerText("content"); scrollable.appendChild(content); // Measure the height and width. nativeHeight = scrollable.getOffsetHeight() - scrollable.getClientHeight(); nativeWidth = scrollable.getOffsetWidth() - scrollable.getClientWidth(); nativeRtl = (content.getAbsoluteLeft() > scrollable.getAbsoluteLeft()); // Detach the scrollable element. scrollable.removeFromParent(); }
/** {@inheritDoc} */ @Override protected void onAttach() { super.onAttach(); Style style = getElement().getParentElement().getStyle(); style.setHeight(100, PCT); style.setWidth(100, PCT); }