/** * Sets the minimal shell height. * * @param shell the shell * @param controls the controls to measure * @param margin the margin between the components * @param extra the extra padding */ public static void setMinimalShellHeight( Shell shell, Control[] controls, int margin, int extra ) { int height = 0; for ( int i = 0; i < controls.length; i++ ) { Rectangle bounds = controls[ i ].getBounds(); height += bounds.height + margin; } height += extra; shell.setSize( shell.getBounds().width, height ); }
public static Point calculateControlPosition( Control control ) { // Calculate the exact location... // Rectangle r = control.getBounds(); Point p = control.getParent().toDisplay( r.x, r.y ); return p; /* * Point location = control.getLocation(); * * Composite parent = control.getParent(); while (parent!=null) { * * Composite newParent = parent.getParent(); if (newParent!=null) { location.x+=parent.getLocation().x; * location.y+=parent.getLocation().y; } else { if (parent instanceof Shell) { // Top level shell. Shell shell = * (Shell)parent; Rectangle bounds = shell.getBounds(); Rectangle clientArea = shell.getClientArea(); location.x += * bounds.width-clientArea.width; location.y += bounds.height-clientArea.height; } } parent = newParent; } * * return location; */ }
Rectangle bounds = control.getBounds(); Point location = GUIResource.calculateControlPosition( control );
Point minimumSize() { Rectangle clientArea = getClientArea(); int width = 0, height = 0; for( Control child : children ) { Rectangle rect = child.getBounds(); width = Math.max( width, rect.x - clientArea.x + rect.width ); height = Math.max( height, rect.y - clientArea.y + rect.height ); } return new Point( width, height ); }
public void getLocation(AccessibleControlEvent e) { Rectangle location = control.getBounds(); Point pt = control.toDisplay(new Point(location.x, location.y)); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
@Override Rectangle getClipping() { if( clippingRect == null ) { return control.getBounds(); } return new Rectangle( clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height ); }
Point minimumSize (int wHint, int Hint, boolean changed) { Control [] children = _getChildren (); Rectangle clientArea = getClientArea(); int width = 0, height = 0; for (int i=0; i<children.length; i++) { Rectangle rect = children [i].getBounds (); width = Math.max (width, rect.x - clientArea.x + rect.width); height = Math.max (height, rect.y - clientArea.y + rect.height); } return new Point (width, height); }
/** * Determines whether the bounds of the given control have changed during the * processing of the current request and if so, writes JavaScript code to the * response that updates the client-side bounds. * * @param control the control whose bounds to write * @throws IOException */ public static void writeBounds( Control control ) throws IOException { Composite parent = control.getParent(); WidgetLCAUtil.writeBounds( control, parent, control.getBounds() ); }
/** Returns this corner's position on the given control in display coordinates. */ public Point getPosition(Control control) { if (control instanceof Shell) { return getPosition(control.getBounds()); } else { return control.getDisplay().map(control.getParent(), null, getPosition(control.getBounds())); } }
public void addEndRect(Control ctrl) { Rectangle ctrlBounds = ctrl.getBounds(); Rectangle endRect = Geometry.toDisplay(ctrl.getParent(), ctrlBounds); addEndRect(endRect); }
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) { super.scroll(destX, destY, x, y, width, height, false); if (all) { int deltaX = destX - x, deltaY = destY - y; Control[] children = getChildren(); for (int i=0; i<children.length; i++) { Control child = children[i]; Rectangle rect = child.getBounds(); child.setLocation(rect.x + deltaX, rect.y + deltaY); } } }
private boolean contains(int x, int y) { if (control instanceof Scrollable) { return ((Scrollable) control).getClientArea().contains(x, y); } else { return control.getBounds().contains(x, y); } }
private boolean isAfter(Control trimCtrl, DnDInfo info) { Rectangle bounds = trimCtrl.getBounds(); bounds = trimCtrl.getDisplay().map(trimCtrl.getParent(), null, bounds); Point center = new Point(bounds.x + (bounds.width / 2), bounds.y + (bounds.height / 2)); boolean horizontal = trimBar.getSide() == SideValue.TOP || trimBar.getSide() == SideValue.BOTTOM; boolean after = horizontal ? info.cursorPos.x > center.x : info.cursorPos.y > center.y; return after; }
private boolean isAfter(Control trimCtrl, DnDInfo info) { Rectangle bounds = trimCtrl.getBounds(); bounds = trimCtrl.getDisplay().map(trimCtrl.getParent(), null, bounds); Point center = new Point(bounds.x + (bounds.width / 2), bounds.y + (bounds.height / 2)); boolean horizontal = trimBar.getSide() == SideValue.TOP || trimBar.getSide() == SideValue.BOTTOM; boolean after = horizontal ? info.cursorPos.x > center.x : info.cursorPos.y > center.y; return after; }
@Override public void mouseDoubleClick(MouseEvent e) { Control content= getContent(); if (content != null && content.getBounds().contains(e.x, e.y)) return; Control parent= getParent(); if (parent instanceof Splitter) ((Splitter)parent).setMaximizedControl(CompareViewerPane.this); } };
public void lazyOpen(String text) { Control c = Display.getDefault().getCursorControl(); if (c != null) { open(c.toDisplay(new Point(0, c.getBounds().height)), text); } else { Rectangle bounds = Display.getDefault().getBounds(); open(new Point(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2), text); } }
private Rectangle getRectangle(MUIElement element) { if (element.getWidget() instanceof Rectangle) return (Rectangle) element.getWidget(); else if (element.getWidget() instanceof Control) return ((Control) (element.getWidget())).getBounds(); return null; }
private void showProposalsMenu() { Control control = getControl(); Rectangle bounds = control.getBounds(); bounds.y += bounds.height + 5; Point point = control.toDisplay( bounds.x, bounds.y ); proposalsMenu.setLocation( point ); proposalsMenu.setVisible( true ); }
public void run() { Rectangle itemRect = item.getDisplay().map( hit.getParent(), item, hit.getBounds()); Point origin = item.getOrigin(); origin.y = itemRect.y; item.setOrigin(origin); } });