List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth
@Override public int getOffsetWidth()
From source file:org.gwtportlets.portlet.client.edit.PageEditorMenuBar.java
License:Open Source License
protected void onLoad() { super.onLoad(); final Widget p = getParent(); if (!(p instanceof PopupPanel)) { return;// w ww . ja v a2s . c o m } // reposition the popup so it does not go off screen etc p.setVisible(false); final int left = p.getAbsoluteLeft(); final int top = p.getAbsoluteTop(); LDOM.setPosition(p.getElement(), 0, 0); // put here so size is not constrained DeferredCommand.addCommand(new Command() { public void execute() { Rectangle nextTo = new Rectangle(); nextTo.x = left; nextTo.y = top; nextTo.width = 1; nextTo.height = 1; Rectangle r = LDOM.getNextToPosition(p.getOffsetWidth(), p.getOffsetHeight(), nextTo, true, 0); LDOM.setPosition(p.getElement(), r.x, r.y); p.setVisible(true); } }); }
From source file:org.gwtportlets.portlet.client.edit.row.RowLayoutEditor.java
License:Open Source License
/** * Figure out the best index for widget in our container assuming it is * dropped at clientX and clientY./*w w w. j av a2 s . c om*/ */ private int getDropIndex(int clientX, int clientY) { int wc = container.getWidgetCount(); if (getTargetLayout().isColumn()) { for (int i = wc - 1; i >= 0; i--) { Widget w = container.getWidget(i); int top = w.getAbsoluteTop(); if (clientY >= top) { return clientY >= top + w.getOffsetHeight() * 2 / 3 ? i + 1 : i; } } } else { for (int i = wc - 1; i >= 0; i--) { Widget w = container.getWidget(i); int left = w.getAbsoluteLeft(); if (clientX >= left) { return clientX >= left + w.getOffsetWidth() * 2 / 3 ? i + 1 : i; } } } return 0; }
From source file:org.gwtportlets.portlet.client.layout.LDOM.java
License:Open Source License
/** * Calculate a position for w so that it is next to the 'nextTo' element. * Both w and nextTo must be attached i.e. offsetWith and offsetHeight * are available. This method will not return a rectangle that is off * the screen./*from www .j ava 2 s . c om*/ * * @param spacing Pixels to keep between e and nextTo */ public static Rectangle getNextToPosition(Widget w, Element nextTo, int spacing) { Rectangle r = LDOM.getBounds(nextTo); // place to left or right if there is more space there int vert = Math.max(r.y, Window.getClientHeight() - r.y - r.height); int horiz = Math.max(r.x, Window.getClientWidth() - r.x - r.width); return getNextToPosition(w.getOffsetWidth(), w.getOffsetHeight(), r, horiz > vert, spacing); }
From source file:org.gwtportlets.portlet.client.layout.LDOM.java
License:Open Source License
/** * Calculate a position for w so that it is next to the 'nextTo' element. * Both w and nextTo must be attached i.e. offsetWith and offsetHeight * are available. This method will not return a rectangle that is off * the screen.//from ww w . j ava2s.co m * * @param toRightOrLeft Position to right or left (true) or below or above (false) * @param spacing Pixels to keep between e and nextTo */ public static Rectangle getNextToPosition(Widget w, Element nextTo, boolean toRightOrLeft, int spacing) { return getNextToPosition(w.getOffsetWidth(), w.getOffsetHeight(), LDOM.getBounds(nextTo), toRightOrLeft, spacing); }
From source file:org.jboss.ballroom.client.util.LoadingOverlay.java
License:Open Source License
public static void on(Widget parent, boolean loading) { if (parent != null && loading) { int left = parent.getAbsoluteLeft(); int top = parent.getAbsoluteTop(); int width = parent.getOffsetWidth(); int height = parent.getOffsetHeight(); p = new PopupPanel(); //p.setStylePrimaryName("bpm-loading-overlay"); p.setWidget(new Image("images/loading_lite.gif")); p.setPopupPosition(left + (width / 2) - 15, top + (height / 2) - 15); p.show();/*from w ww .jav a 2 s.c o m*/ } else { if (p != null) { p.hide(); p = null; } } }
From source file:org.jboss.bpm.console.client.common.LoadingOverlay.java
License:Open Source License
public static void on(Widget parent, boolean loading) { if (parent != null && loading) { int left = parent.getAbsoluteLeft(); int top = parent.getAbsoluteTop(); int width = parent.getOffsetWidth(); int height = parent.getOffsetHeight(); if (width > 100 & height > 100) // workaround hidden panels {//from w w w . j av a 2 s . co m p = new PopupPanel(); p.setStylePrimaryName("bpm-loading-overlay"); p.setWidget(new Image("images/loading_lite.gif")); p.setPopupPosition(left + (width / 2) - 15, top + (height / 2) - 15); p.show(); } } else { if (p != null) { p.hide(); p = null; } } }
From source file:org.jbpm.console.ng.gc.client.experimental.generic.popup.GenericPopupViewImpl.java
License:Apache License
@Override public void onResize() { Widget parent = container.getParent(); final int width = parent.getOffsetWidth(); final int height = parent.getOffsetHeight(); container.setWidth(width + "px"); container.setHeight(height + "px"); }
From source file:org.jbpm.designer.client.DesignerViewImpl.java
License:Apache License
@Override public void onResize() { //Layouts.setToFillParent(this); final Widget w = getParent(); final int width = w.getOffsetWidth(); final int height = w.getOffsetHeight(); this.setWidth(width + "px"); this.setHeight(height + "px"); ((RequiresResize) designerWidget.getView()).onResize(); }
From source file:org.jbpm.designer.client.DesignerWidgetView.java
License:Apache License
@Override public void onResize() { final Widget w = getParent(); final int width = w.getOffsetWidth(); final int height = w.getOffsetHeight(); inlineFrame.setWidth(width + "px"); inlineFrame.setHeight(height + "px"); }
From source file:org.jbpm.form.builder.ng.model.client.form.FBForm.java
License:Apache License
@Override public void add(PhantomPanel phantom, int x, int y) { for (int index = 0; index < getWidgetCount(); index++) { Widget item = getWidget(index); int left = item.getAbsoluteLeft(); int right = left + item.getOffsetWidth(); int top = item.getAbsoluteTop(); int bottom = top + item.getOffsetHeight(); if (x > left && x < right && y > top && y < bottom) { insert(phantom, index);//w w w . ja va 2 s .c o m break; } else if (x > right && y > top && y < bottom && index < (getWidgetCount() - 1)) { insert(phantom, index + 1); break; } else if (index == (getWidgetCount() - 1)) { add(phantom); break; } } }