List of usage examples for com.google.gwt.dom.client Style setTop
public void setTop(double value, Unit unit)
From source file:com.preferanser.client.application.mvp.ImageDragController.java
License:Open Source License
private void updatePosition(Point point) { Style style = cardWidget.getElement().getStyle(); style.setLeft(point.getX(), Style.Unit.PX); style.setTop(point.getY(), Style.Unit.PX); }
From source file:com.sciencegadgets.client.algebra.EquationLayer.java
License:Open Source License
@Override protected void onLoad() { super.onLoad(); eqHTML.getElement().getStyle().setVisibility(Visibility.HIDDEN); add(eqHTML);/* w w w . j av a2 s.c om*/ final Style style = eqHTML.getElement().getStyle(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { style.setTop(((getOffsetHeight() - eqHTML.getOffsetHeight())) / 2, Unit.PX); style.setLeft(((getOffsetWidth() - eqHTML.getOffsetWidth())) / 2, Unit.PX); eqHTML.getElement().getStyle().clearVisibility(); } }); }
From source file:com.sitecake.contentmanager.client.toolbar.ContentManagerToolbar.java
private void setPosition(int x, int y, boolean constraint, boolean save) { int windowWidth = Window.getClientWidth(); int windowHeight = Window.getClientHeight(); int elementWidth = getElement().getOffsetWidth(); int elementHeight = getElement().getOffsetHeight(); int maxWidth = windowWidth - elementWidth; int maxHeight = windowHeight - elementHeight; if (constraint) { x = (x < 0) ? 0 : ((x > maxWidth) ? maxWidth : x); y = (y < 0) ? 0 : ((y > maxHeight) ? maxHeight : y); }//from ww w . j a v a 2 s .c o m Style style = getElement().getStyle(); style.setLeft(x, Unit.PX); style.setTop(y, Unit.PX); if (y > windowHeight / 2) { addStyleName(EditorClientBundle.INSTANCE.css().toolbarBottomPosition()); newItems.addStyleName(EditorClientBundle.INSTANCE.css().toolbarIconsUp()); newItems.removeStyleName(EditorClientBundle.INSTANCE.css().toolbarIconsDown()); } else { removeStyleName(EditorClientBundle.INSTANCE.css().toolbarBottomPosition()); newItems.addStyleName(EditorClientBundle.INSTANCE.css().toolbarIconsDown()); newItems.removeStyleName(EditorClientBundle.INSTANCE.css().toolbarIconsUp()); } if (save) { propertyManager.setProperty(POSITION_X, x, PropertyScope.APPLICATION); propertyManager.setProperty(POSITION_Y, y, PropertyScope.APPLICATION); } }
From source file:com.smartgwt.mobile.client.widgets.Canvas.java
License:Open Source License
@SGWTInternal protected static void _hideAddressBarNow() { // In iOS 7, the scrollTo() hack to hide the address bar does not work anymore. // http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review // We still run some code in _maybeHideAddressBar() on iPad, however, to work around // the issue that 20px is cut off from the top or bottom in landscape mode. // Also, on iPhone running in a UIWebView, we need to move up the RootLayoutPanel's // bottom coord. final Style rootLayoutPanelElementStyle = RootLayoutPanel.get().getElement().getStyle(); if (IMPL.isIOSMin7_0()) { if (!Canvas.isUIWebView()) { // Work around an issue with iOS 7 Mobile Safari on an iPad in landscape mode. // http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue // http://stackoverflow.com/questions/18855642/ios-7-css-html-height-100-692px if (Canvas.isIPad()) { if (Page.getOrientation() == PageOrientation.LANDSCAPE) { rootLayoutPanelElementStyle.setHeight(Window.getClientHeight() - 20, Style.Unit.PX); } else { rootLayoutPanelElementStyle.setHeight(100, Style.Unit.PCT); }/*from ww w. j a va2 s. c o m*/ // On iPhone running iOS 7.1 using the 'minimal-ui' viewport parameter, the top 20 CSS pixels // in landscape mode should not be used because tapping within this area causes the browser // chrome to be revealed: http://www.mobilexweb.com/blog/ios-7-1-safari-minimal-ui-bugs } else if (Canvas.isIPhone() && IMPL.isIOSMin7_1()) { if (Page.getOrientation() == PageOrientation.LANDSCAPE) { rootLayoutPanelElementStyle.clearHeight(); rootLayoutPanelElementStyle.setTop(20, Style.Unit.PX); } else { rootLayoutPanelElementStyle.setHeight(100, Style.Unit.PCT); rootLayoutPanelElementStyle.setTop(0, Style.Unit.PX); } } // Since, when running in a UIWebView, the device-width/device-height // includes the height of the status bar, set the bottom of the RootLayoutPanel's // element to 20px (the standard height of the status bar). } else if (Canvas.isUIWebView()) { rootLayoutPanelElementStyle.clearHeight(); rootLayoutPanelElementStyle.setBottom(20.0, Style.Unit.PX); } Window.scrollTo(0, 0); } else if (isIPhone() && !isStandAlone() && !isUIWebView()) { rootLayoutPanelElementStyle.setHeight(Window.getClientHeight() + 100 - 40, Style.Unit.PX); Window.scrollTo(0, 0); } else { rootLayoutPanelElementStyle.setHeight(Window.getClientHeight(), Style.Unit.PX); } }
From source file:com.vaadin.addon.spreadsheet.client.GroupingWidget.java
protected void copyfields(GroupingWidget newWidget) { newWidget.collapsed = collapsed;/*from w w w . j a va 2 s .c om*/ newWidget.index = index; newWidget.inversed = inversed; newWidget.btn.setInnerText(btn.getInnerText()); Style style = newWidget.getElement().getStyle(); newWidget.setStyleName(getStyleName()); if (marginLeft > -1) { style.setMarginLeft(marginLeft, Unit.PX); } if (marginTop > -1) { style.setMarginTop(marginTop, Unit.PX); } if (height > -1) { style.setHeight(height, Unit.PX); } if (width > -1) { style.setWidth(width, Unit.PX); } if (top > -1) { style.setTop(top, Unit.PX); } if (left > -1) { style.setLeft(left, Unit.PX); } }
From source file:com.vaadin.addon.spreadsheet.client.SheetWidget.java
/** * Updates the left & top style property for sheet panes depending if * headers are shown or not./*from w ww. j a va 2s . co m*/ */ void updateSheetPanePositions() { int extraSize = horizontalSplitPosition > 0 ? 1 : 0; if (spreadsheet.getAttribute("class").contains("report")) { extraSize = 0; } int widthIncrease = 0; if (rowHeaders != null && !rowHeaders.isEmpty()) { widthIncrease = getRowHeaderSize(); } int heightIncrease = 0; if (colHeaders != null && !colHeaders.isEmpty()) { heightIncrease = getColHeaderSize(); } // Measure formula bar height int formulaBarHeight = 0; if (actionHandler.getFormulaBarWidget() != null) { MeasuredSize measuredSize = new MeasuredSize(); measuredSize.measure(actionHandler.getFormulaBarWidget().getElement()); formulaBarHeight = (int) measuredSize.getOuterHeight(); } int addedHeaderHeight = updateExtraColumnHeaderElements(formulaBarHeight); int addedHeaderWidth = updateExtraRowHeaderElements(formulaBarHeight); updateExtraCornerElements(formulaBarHeight, addedHeaderHeight, addedHeaderWidth); if (!displayRowColHeadings) { widthIncrease = 0; heightIncrease = 0; } topOffset = heightIncrease + formulaBarHeight + addedHeaderHeight; leftOffset = widthIncrease + addedHeaderWidth; Style style = topLeftPane.getStyle(); style.setWidth(leftFrozenPanelWidth + widthIncrease + 1, Unit.PX); style.setHeight(topFrozenPanelHeight + heightIncrease, Unit.PX); style.setTop(formulaBarHeight + addedHeaderHeight, Unit.PX); style.setLeft(addedHeaderWidth, Unit.PX); style = topRightPane.getStyle(); // left offset is the same as the width increase style.setLeft(leftFrozenPanelWidth + leftOffset + extraSize, Unit.PX); style.setHeight(topFrozenPanelHeight + heightIncrease, Unit.PX); style.setTop(formulaBarHeight + addedHeaderHeight, Unit.PX); style = bottomLeftPane.getStyle(); // The +1 is to accommodate the vertical border of the freeze pane style.setWidth(leftFrozenPanelWidth + widthIncrease + 1, Unit.PX); style.setTop(topFrozenPanelHeight + topOffset, Unit.PX); style.setLeft(addedHeaderWidth, Unit.PX); style = sheet.getStyle(); style.setLeft(leftFrozenPanelWidth + leftOffset + extraSize, Unit.PX); style.setTop(topFrozenPanelHeight + topOffset, Unit.PX); style = corner.getStyle(); style.setTop(formulaBarHeight + addedHeaderHeight, Unit.PX); style.setLeft(addedHeaderWidth, Unit.PX); }
From source file:com.vaadin.client.debug.internal.Highlight.java
License:Apache License
/** * Highlight the given {@link Element} using the given color. * <p>/*from ww w. ja v a2s . co m*/ * Pass the returned highlight {@link Element} to {@link #hide(Element)} to * remove this particular highlight. * </p> * * @param element * Element to highlight * @param color * Color of highlight * @return Highlight element */ static Element show(Element element, String color) { if (element != null) { if (highlights == null) { highlights = new HashSet<Element>(); } Element highlight = DOM.createDiv(); Style style = highlight.getStyle(); style.setTop(element.getAbsoluteTop(), Unit.PX); style.setLeft(element.getAbsoluteLeft(), Unit.PX); int width = element.getOffsetWidth(); if (width < MIN_WIDTH) { width = MIN_WIDTH; } style.setWidth(width, Unit.PX); int height = element.getOffsetHeight(); if (height < MIN_HEIGHT) { height = MIN_HEIGHT; } style.setHeight(height, Unit.PX); RootPanel.getBodyElement().appendChild(highlight); style.setPosition(Position.ABSOLUTE); style.setZIndex(VWindow.Z_INDEX + 1000); style.setBackgroundColor(color); style.setOpacity(DEFAULT_OPACITY); if (BrowserInfo.get().isIE()) { style.setProperty("filter", "alpha(opacity=" + (DEFAULT_OPACITY * 100) + ")"); } highlights.add(highlight); return highlight; } return null; }
From source file:com.vaadin.client.ui.dd.VaaclipseDragAndDropManager.java
License:Apache License
private void updateDragImagePosition() { if (currentDrag.getCurrentGwtEvent() != null && dragElement != null) { Style style = dragElement.getStyle(); int clientY = Util.getTouchOrMouseClientY(currentDrag.getCurrentGwtEvent()); int clientX = Util.getTouchOrMouseClientX(currentDrag.getCurrentGwtEvent()); style.setTop(clientY, Unit.PX); style.setLeft(clientX, Unit.PX); }// w w w.java2s .c o m }
From source file:com.vaadin.client.ui.dd.VDragAndDropManager.java
License:Apache License
protected void updateDragImagePosition(NativeEvent gwtEvent, Element dragImage) { if (gwtEvent != null && dragImage != null) { Style style = dragImage.getStyle(); int clientY = WidgetUtil.getTouchOrMouseClientY(gwtEvent); int clientX = WidgetUtil.getTouchOrMouseClientX(gwtEvent); style.setTop(clientY, Unit.PX); style.setLeft(clientX, Unit.PX); }//from w ww . j a v a2 s .c o m }
From source file:com.vaadin.client.ui.FocusableScrollPanel.java
License:Apache License
@Override public void setWidget(Widget w) { super.setWidget(w); if (useFakeFocusElement()) { if (focusElement.getParentElement() == null) { Style style = focusElement.getStyle(); style.setPosition(Position.FIXED); style.setTop(0, Unit.PX); style.setLeft(0, Unit.PX);/*from w w w .j a v a2 s . co m*/ if (browserInfo.isIE() || browserInfo.isEdge()) { // for #15294: artificially hide little bit more the // focusElement, otherwise IE will make the window to scroll // into it when focused style.setLeft(-999, Unit.PX); } getElement().appendChild(focusElement); /* Sink from focusElemet too as focusa and blur don't bubble */ DOM.sinkEvents(focusElement, Event.FOCUSEVENTS); // revert to original, not focusable getElement().setPropertyObject("tabIndex", null); } else { moveFocusElementAfterWidget(); } } }