List of usage examples for com.google.gwt.dom.client Style clearPaddingTop
public void clearPaddingTop()
From source file:com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout.CubaFieldGroupLayoutComponentSlot.java
License:Apache License
@Override public void positionVertically(double currentLocation, double allocatedSpace, double marginBottom) { if (!isCaptionInline()) { super.positionVertically(currentLocation, allocatedSpace, marginBottom); return;/* w w w . j a v a2 s . c o m*/ } // CAUTION copied from VLayoutSlot.positionVertically(~) Style style = wrapper.getStyle(); double contentHeight = allocatedSpace; int captionHeight; VCaption caption = getCaption(); if (caption == null || caption.shouldBePlacedAfterComponent() || isCaptionInline()) { style.clearPaddingTop(); captionHeight = 0; } else { captionHeight = getCaptionHeight(); contentHeight -= captionHeight; if (contentHeight < 0) { contentHeight = 0; } style.setPaddingTop(captionHeight, Style.Unit.PX); } if (marginBottom > 0) { style.setMarginBottom(marginBottom, Style.Unit.PX); } else { style.clearMarginBottom(); } if (isRelativeHeight()) { style.setHeight(contentHeight, Style.Unit.PX); } else { style.clearHeight(); } double allocatedContentHeight = 0; if (isRelativeHeight()) { String height = getWidget().getElement().getStyle().getHeight(); double percentage = parsePercent(height); allocatedContentHeight = contentHeight * (percentage / 100); reportActualRelativeHeight(Math.round((float) allocatedContentHeight)); } AlignmentInfo alignment = getAlignment(); if (!alignment.isTop()) { double usedHeight; if (isRelativeHeight()) { if (isCaptionInline()) { usedHeight = allocatedContentHeight; } else { usedHeight = captionHeight + allocatedContentHeight; } } else { usedHeight = getUsedHeight(); } if (alignment.isVerticalCenter()) { currentLocation += (allocatedSpace - usedHeight) / 2d; } else { currentLocation += (allocatedSpace - usedHeight); } } style.setTop(currentLocation, Style.Unit.PX); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxConnector.java
License:Apache License
protected void layoutGroupBox() { CubaGroupBoxWidget panel = getWidget(); LayoutManager layoutManager = getLayoutManager(); if (isBordersVisible()) { int captionWidth = layoutManager.getOuterWidth(panel.captionNode); int captionStartWidth = layoutManager.getInnerWidth(panel.captionStartDeco); int totalMargin = captionWidth + captionStartWidth; panel.captionNode.getStyle().setWidth(captionWidth, Unit.PX); panel.captionWrap.getStyle().setPaddingLeft(totalMargin, Unit.PX); panel.captionStartDeco.getStyle().setMarginLeft(0 - totalMargin, Unit.PX); }//w w w .j a v a2 s . c o m Profiler.enter("CubaGroupBoxConnector.layout getHeights"); // Haulmont API get max height of caption components int top = layoutManager.getOuterHeight(panel.captionNode); top = Math.max(layoutManager.getOuterHeight(panel.captionStartDeco), top); top = Math.max(layoutManager.getOuterHeight(panel.captionEndDeco), top); int bottom = layoutManager.getInnerHeight(panel.bottomDecoration); Profiler.leave("PanelConnector.layout getHeights"); Style style = panel.getElement().getStyle(); int paddingTop = 0; int paddingBottom = 0; if (panel.hasAnyOuterMargin()) { Profiler.enter("PanelConnector.layout get values from styles"); // Clear previously set values style.clearPaddingTop(); style.clearPaddingBottom(); // Calculate padding from styles ComputedStyle computedStyle = new ComputedStyle(panel.getElement()); paddingTop = computedStyle.getIntProperty("padding-top"); paddingBottom = computedStyle.getIntProperty("padding-bottom"); Profiler.leave("PanelConnector.layout get values from styles"); } Profiler.enter("PanelConnector.layout modify style"); panel.captionWrap.getStyle().setMarginTop(-top, Style.Unit.PX); panel.bottomDecoration.getStyle().setMarginBottom(-bottom, Style.Unit.PX); style.setPaddingTop(top + paddingTop, Style.Unit.PX); style.setPaddingBottom(bottom + paddingBottom, Style.Unit.PX); Profiler.leave("PanelConnector.layout modify style"); // Update scroll positions Profiler.enter("PanelConnector.layout update scroll positions"); panel.contentNode.setScrollTop(panel.scrollTop); panel.contentNode.setScrollLeft(panel.scrollLeft); Profiler.leave("PanelConnector.layout update scroll positions"); // Read actual value back to ensure update logic is correct Profiler.enter("PanelConnector.layout read scroll positions"); panel.scrollTop = panel.contentNode.getScrollTop(); panel.scrollLeft = panel.contentNode.getScrollLeft(); Profiler.leave("PanelConnector.layout read scroll positions"); }
From source file:com.vaadin.client.ui.layout.VLayoutSlot.java
License:Apache License
public void positionVertically(double currentLocation, double allocatedSpace, double marginBottom) { Style style = wrapper.getStyle(); double contentHeight = allocatedSpace; int captionHeight; VCaption caption = getCaption();// w w w .j a v a2s . c o m if (caption == null || caption.shouldBePlacedAfterComponent()) { style.clearPaddingTop(); captionHeight = 0; } else { captionHeight = getCaptionHeight(); contentHeight -= captionHeight; if (contentHeight < 0) { contentHeight = 0; } style.setPaddingTop(captionHeight, Unit.PX); } if (marginBottom > 0) { style.setMarginBottom(marginBottom, Unit.PX); } else { style.clearMarginBottom(); } style.setHeight(contentHeight, Unit.PX); double allocatedContentHeight = 0; if (isRelativeHeight()) { String height = getWidget().getElement().getStyle().getHeight(); double percentage = parsePercent(height); allocatedContentHeight = contentHeight * (percentage / 100); reportActualRelativeHeight(Math.round((float) allocatedContentHeight)); } style.setTop(currentLocation, Unit.PX); double padding = 0; AlignmentInfo alignment = getAlignment(); if (!alignment.isTop()) { double usedHeight; if (isRelativeHeight()) { usedHeight = captionHeight + allocatedContentHeight; } else { usedHeight = getUsedHeight(); } if (alignment.isVerticalCenter()) { padding = (allocatedSpace - usedHeight) / 2d; } else { padding = (allocatedSpace - usedHeight); } padding += captionHeight; widget.getElement().getStyle().setTop(padding, Unit.PX); } else { // Reset top when changing back to align top widget.getElement().getStyle().clearTop(); } }
From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java
License:Apache License
/** * Update the offset off the caption relative to the slot * <p>//from w w w . ja v a2s.com * For internal use only. May be removed or replaced in the future. * * @param caption * The caption element * @deprecated As of 7.2, call or override * {@link #updateCaptionOffset(Element)} instead */ @Deprecated public void updateCaptionOffset(com.google.gwt.user.client.Element caption) { Element captionWrap = caption.getParentElement(); Style captionWrapStyle = captionWrap.getStyle(); captionWrapStyle.clearPaddingTop(); captionWrapStyle.clearPaddingRight(); captionWrapStyle.clearPaddingBottom(); captionWrapStyle.clearPaddingLeft(); Style captionStyle = caption.getStyle(); captionStyle.clearMarginTop(); captionStyle.clearMarginRight(); captionStyle.clearMarginBottom(); captionStyle.clearMarginLeft(); // Get caption position from the classname CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap); if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) { int captionWidth; if (layoutManager != null) { captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption); } else { captionWidth = caption.getOffsetWidth(); } if (captionWidth > 0) { if (captionPosition == CaptionPosition.LEFT) { captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX); captionStyle.setMarginLeft(-captionWidth, Unit.PX); } else { captionWrapStyle.setPaddingRight(captionWidth, Unit.PX); captionStyle.setMarginRight(-captionWidth, Unit.PX); } } } if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) { int captionHeight; if (layoutManager != null) { captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption); } else { captionHeight = caption.getOffsetHeight(); } if (captionHeight > 0) { if (captionPosition == CaptionPosition.TOP) { captionWrapStyle.setPaddingTop(captionHeight, Unit.PX); captionStyle.setMarginTop(-captionHeight, Unit.PX); } else { captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX); captionStyle.setMarginBottom(-captionHeight, Unit.PX); } } } }