List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth
@Override public int getOffsetWidth()
From source file:com.fullmetalgalaxy.client.creation.WgtBoardEditTokens.java
License:Open Source License
@Override public void onScroll(Widget p_widget, int p_scrollLeft, int p_scrollTop) { m_layerCollection.redraw(p_scrollLeft, p_scrollTop, p_scrollLeft + p_widget.getOffsetWidth(), p_scrollTop + p_widget.getOffsetHeight()); }
From source file:com.fullmetalgalaxy.client.game.board.WgtBoardLayerBase.java
License:Open Source License
/** * set position of a widget as the widget is centered on the given position. * @param p_w//from w w w . j av a 2 s . co m * @param p_wgtPixPosition position in pixel */ private void setWidgetPixPosition(Widget p_w, AnPair p_wgtPixPosition) { super.setWidgetPosition(p_w, p_wgtPixPosition.getX() - p_w.getOffsetWidth() / 2, p_wgtPixPosition.getY() - p_w.getOffsetHeight() / 2); // p_w.setVisible( true ); }
From source file:com.fullmetalgalaxy.client.game.board.WgtBoardTorus.java
License:Open Source License
@Override public void onScroll(Widget p_widget, int p_scrollLeft, int p_scrollTop) { // should we move local layers AnPair pixCenter = new AnPair(p_scrollLeft + p_widget.getOffsetWidth() / 2, p_scrollTop + p_widget.getOffsetHeight() / 2); AnPair hexCenter = BoardConvert.convertPixPositionToHexPosition(pixCenter, getZoom(), new AnPair(0, 0)); int middleLocalLayerIX = 1; int middleLocalLayerIY = 1; if (GameEngine.game().getMapShape().isEWLinked()) { // east / west are linked (ie borderless) if (hexCenter.getX() < GameEngine.model().getGame().getLandWidth() / 3) middleLocalLayerIX = 0;//from www . j av a2 s. c o m if (hexCenter.getX() >= GameEngine.model().getGame().getLandWidth() * 2 / 3) middleLocalLayerIX = 2; // up to here middleLocalLayerIX is an offset on current m_middleLocalLayerI? // TODO remove that by using local convertPixPositionToHexPosition middleLocalLayerIX += m_middleLocalLayerIX - 1; if (middleLocalLayerIX > 2) middleLocalLayerIX -= 3; if (middleLocalLayerIX < 0) middleLocalLayerIX += 3; } if (GameEngine.game().getMapShape().isNSLinked()) { // north / south are linked (ie borderless) if (hexCenter.getY() < GameEngine.model().getGame().getLandHeight() / 3) middleLocalLayerIY = 0; if (hexCenter.getY() >= GameEngine.model().getGame().getLandHeight() * 2 / 3) middleLocalLayerIY = 2; // up to here middleLocalLayerIY is an offset on current m_middleLocalLayerI? middleLocalLayerIY += m_middleLocalLayerIY - 1; if (middleLocalLayerIY > 2) middleLocalLayerIY -= 3; if (middleLocalLayerIY < 0) middleLocalLayerIY += 3; } if (middleLocalLayerIX != m_middleLocalLayerIX || middleLocalLayerIY != m_middleLocalLayerIY) { if (p_widget instanceof WgtScroll) { int pxOffsetX = 0; int pxOffsetY = 0; if (m_middleLocalLayerIX == 0 && middleLocalLayerIX == 2) pxOffsetX -= m_localLayerHexWidth[1]; if (m_middleLocalLayerIX == 0 && middleLocalLayerIX == 1) pxOffsetX += m_localLayerHexWidth[2]; if (m_middleLocalLayerIX == 1 && middleLocalLayerIX == 2) pxOffsetX += m_localLayerHexWidth[0]; if (m_middleLocalLayerIX == 1 && middleLocalLayerIX == 0) pxOffsetX -= m_localLayerHexWidth[2]; if (m_middleLocalLayerIX == 2 && middleLocalLayerIX == 0) pxOffsetX += m_localLayerHexWidth[1]; if (m_middleLocalLayerIX == 2 && middleLocalLayerIX == 1) pxOffsetX -= m_localLayerHexWidth[0]; if (m_middleLocalLayerIY == 0 && middleLocalLayerIY == 2) pxOffsetY -= m_localLayerHexHeight[1]; if (m_middleLocalLayerIY == 0 && middleLocalLayerIY == 1) pxOffsetY += m_localLayerHexHeight[2]; if (m_middleLocalLayerIY == 1 && middleLocalLayerIY == 2) pxOffsetY += m_localLayerHexHeight[0]; if (m_middleLocalLayerIY == 1 && middleLocalLayerIY == 0) pxOffsetY -= m_localLayerHexHeight[2]; if (m_middleLocalLayerIY == 2 && middleLocalLayerIY == 0) pxOffsetY += m_localLayerHexHeight[1]; if (m_middleLocalLayerIY == 2 && middleLocalLayerIY == 1) pxOffsetY -= m_localLayerHexHeight[0]; pxOffsetX *= FmpConstant.getHexWidth(getZoom()) * 3 / 4; pxOffsetY *= FmpConstant.getHexHeight(getZoom()); pxOffsetX = ((WgtScroll) p_widget).getHorizontalScrollPosition() - pxOffsetX; pxOffsetY = ((WgtScroll) p_widget).getVerticalScrollPosition() - pxOffsetY; ((WgtScroll) p_widget).setScrollPositionSilent(pxOffsetX, pxOffsetY); } m_middleLocalLayerIY = middleLocalLayerIY; m_middleLocalLayerIX = middleLocalLayerIX; setLayersPositions(GameEngine.model().getGame()); } for (int ix = 0; ix < 3; ix++) for (int iy = 0; iy < 3; iy++) { int visibleLeftPix = p_scrollLeft - m_panel.getWidgetLeft(m_cadranLayers[ix][iy].asWidget()); int visibleTopPix = p_scrollTop - m_panel.getWidgetTop(m_cadranLayers[ix][iy].asWidget()); m_cadranLayers[ix][iy].redraw(visibleLeftPix, visibleTopPix, visibleLeftPix + p_widget.getOffsetWidth(), visibleTopPix + p_widget.getOffsetHeight()); } m_globalLayers.redraw(p_scrollLeft, p_scrollTop, p_scrollLeft + p_widget.getOffsetWidth(), p_scrollTop + p_widget.getOffsetHeight()); }
From source file:com.google.appinventor.client.editor.simple.components.MockComponentsUtil.java
License:Open Source License
/** * Returns the preferred size of the specified widget, * in an array of the form {@code [width, height]}. * <p>//from w w w . java 2s. co m * It is assumed that: * <ul> * <li>{@code w} has no parent</li> * <li>{@code w} has not been configured to be invisible</li> * </ul> */ public static int[] getPreferredSizeOfDetachedWidget(Widget w) { // Attach the widget to the DOM, so that its preferred size is calculated correctly RootPanel.get().add(w); String[] style = clearSizeStyle(w); int width = w.getOffsetWidth() + 4; int height = w.getOffsetHeight(); restoreSizeStyle(w, style); // Detach the widget from the DOM before returning RootPanel.get().remove(w); return new int[] { width, height }; }
From source file:com.google.appinventor.client.explorer.project.ProjectNodeContextMenu.java
License:Open Source License
/** * Shows a context menu for a node./*from ww w .j a v a 2s . c o m*/ * * @param node node for which to show the context menu * @param host widget to anchor context menu to */ public static void show(final ProjectNode node, Widget host) { List<CommandRegistry.Entry> entries = Ode.getCommandRegistry().get(node); if (entries.isEmpty()) { return; } final ContextMenu menu = new ContextMenu(); // Position the context menu to the East of the host widget. menu.setPopupPosition(host.getAbsoluteLeft() + host.getOffsetWidth(), host.getAbsoluteTop()); for (final CommandRegistry.Entry entry : entries) { final ProjectNodeCommand cmd = entry.getCommand(); // Create the menu item. menu.addItem(cmd.getLabel(), new Command() { @Override public void execute() { menu.hide(); cmd.execute(node); } }); } menu.show(); }
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
/** * Returns whether the specified widget contains a position given * by the absolute coordinates.//from ww w . j a v a 2s . c o m * * @param w widget to test * @param absX absolute x coordinate of position * @param absY absolute y coordinate of position * @return {@code true} if the position is within the widget, {@code false} * otherwise */ private static boolean isInside(Widget w, int absX, int absY) { int wx = w.getAbsoluteLeft(); int wy = w.getAbsoluteTop(); int ww = w.getOffsetWidth(); int wh = w.getOffsetHeight(); return (wx <= absX) && (absX < wx + ww) && (wy <= absY) && (absY < wy + wh); }
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
/** * Convenience method to set the height, width and position of the given widget * * @param panel/*w ww . j a v a 2s .c om*/ * @param dx * @param dy */ protected void dragResizeWidget(PopupPanel panel, int dx, int dy) { int x = this.getPopupLeft(); int y = this.getPopupTop(); Widget widget = panel.getWidget(); // left + right if ((this.dragMode % 3) != 1) { int w = widget.getOffsetWidth(); // left edge -> move left if ((this.dragMode % 3) == 0) { x += dx; w -= dx; } else { w += dx; } w = w < this.minWidth ? this.minWidth : w; widget.setWidth(w + "px"); } // up + down if ((this.dragMode / 3) != 1) { int h = widget.getOffsetHeight(); // up = dy is negative if ((this.dragMode / 3) == 0) { y += dy; h -= dy; } else { h += dy; } h = h < this.minHeight ? this.minHeight : h; widget.setHeight(h + "px"); } if (this.dragMode / 3 == 0 || this.dragMode % 3 == 0) panel.setPopupPosition(x, y); }
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
/** * Called when the minimize icon is clicked. The default implementation hides the container of the dialog box. * * @param event The {@link ClickEvent} to handle *///from ww w . j av a 2 s .c om protected void onMinimizeClick(ClickEvent event) { Widget widget = getWidget(); if (widget == null) return; boolean visible = widget.isVisible(); int offsetWidth = widget.getOffsetWidth(); widget.setVisible(!visible); this.minimized = visible; if (visible) { this.container.setWidth(offsetWidth + "px"); this.minimize.setStyleName("gwt-extras-dialog-maximize"); } else { this.container.setWidth(null); this.minimize.setStyleName("gwt-extras-dialog-minimize"); } }
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();//from w w w .j a va 2 s . c o m 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.gwtmodel.table.WSize.java
License:Apache License
public WSize(Widget w) { this.top = w.getAbsoluteTop(); this.left = w.getAbsoluteLeft(); this.height = w.getOffsetHeight(); this.width = w.getOffsetWidth(); this.w = w;/*from w w w. j a v a 2s . c o m*/ }