Rectangle entireClientArea = shell.getDisplay().getClientArea(); Rectangle resizedRect = Geometry.copy( shellSize ); constrainRectangleToContainer( resizedRect, entireClientArea );
/** * Returns a rectangle which describes the area of the * receiver which is capable of displaying data. * * @return the client area */ public Rectangle getClientArea() { return display.getClientArea(); }
private static void setSafeBounds(Shell s, int x, int y, int width, int height) { Rectangle clientArea = s.getDisplay().getClientArea(); width = Math.min(clientArea.width, width); height = Math.min(clientArea.height, height); x = Math.min(x + width, clientArea.x + clientArea.width) - width; y = Math.min(y + height, clientArea.y + clientArea.height) - height; x = Math.max(x, clientArea.x); y = Math.max(y, clientArea.y); s.setBounds(x, y, width, height); } public void setLocation(int x, int y) {
@Override protected Point getInitialSize() { Point result= super.getInitialSize(); if (fSize != null) { result.x= Math.max(result.x, fSize.x); result.y= Math.max(result.y, fSize.y); Rectangle display= getShell().getDisplay().getClientArea(); result.x= Math.min(result.x, display.width); result.y= Math.min(result.y, display.height); } return result; }
protected Point getInitialSize() { Point result= super.getInitialSize(); if (fSize != null) { result.x= Math.max(result.x, fSize.x); result.y= Math.max(result.y, fSize.y); Rectangle display= getShell().getDisplay().getClientArea(); result.x= Math.min(result.x, display.width); result.y= Math.min(result.y, display.height); } return result; }
protected Point getInitialSize() { Point result= super.getInitialSize(); if (fSize != null) { result.x= Math.max(result.x, fSize.x); result.y= Math.max(result.y, fSize.y); Rectangle display= getShell().getDisplay().getClientArea(); result.x= Math.min(result.x, display.width); result.y= Math.min(result.y, display.height); } return result; }
protected Point getInitialSize() { Point result= super.getInitialSize(); if (fSize != null) { result.x= Math.max(result.x, fSize.x); result.y= Math.max(result.y, fSize.y); Rectangle display= getShell().getDisplay().getClientArea(); result.x= Math.min(result.x, display.width); result.y= Math.min(result.y, display.height); } return result; }
protected Point getInitialSize() { Point result = super.getInitialSize(); if(size != null) { result.x = Math.max(result.x, size.x); result.y = Math.max(result.y, size.y); Rectangle display = getShell().getDisplay().getClientArea(); result.x = Math.min(result.x, display.width); result.y = Math.min(result.y, display.height); } return result; }
@Override protected Point getInitialSize() { Point result= super.getInitialSize(); if (fSize != null) { result.x= Math.max(result.x, fSize.x); result.y= Math.max(result.y, fSize.y); Rectangle display= getShell().getDisplay().getClientArea(); result.x= Math.min(result.x, display.width); result.y= Math.min(result.y, display.height); } return result; }
protected Point getInitialLocation(Point initialSize) { Composite parentShell = shell.getParent(); Rectangle containerBounds = (parentShell != null) ? parentShell.getBounds() : shell.getDisplay().getClientArea(); int x = Math.max(0, containerBounds.x + (containerBounds.width - initialSize.x) / 2); int y = Math.max(0, containerBounds.y + (containerBounds.height - initialSize.y) / 3); return new Point(x, y); }
/** * Return the number of rows available in the current display using the current font. * * @param parent * The Composite whose Font will be queried. * @return The result of the display size divided by the font size. */ private int availableRows(Composite parent) { int fontHeight = (parent.getFont().getFontData())[0].getHeight(); int displayHeight = parent.getDisplay().getClientArea().height; return displayHeight / fontHeight; }
private boolean useHeightHint(Composite parent) { int fontHeight= (parent.getFont().getFontData())[0].getHeight(); int displayHeight= parent.getDisplay().getClientArea().height; return (displayHeight / fontHeight) > 50; }
/** * Return the number of rows available in the current display using the current font. * * @param parent * The Composite whose Font will be queried. * @return int The result of the display size divided by the font size. */ private int availableRows(Composite parent) { int fontHeight = (parent.getFont().getFontData())[0].getHeight(); int displayHeight = parent.getDisplay().getClientArea().height; return displayHeight / fontHeight; }
/** * Return the number of rows available in the current display using the * current font. * @param parent The Composite whose Font will be queried. * @return int The result of the display size divided by the font size. */ public static int availableRows(Composite parent) { int fontHeight = (parent.getFont().getFontData())[0].getHeight(); int displayHeight = parent.getDisplay().getClientArea().height; return displayHeight / fontHeight; }
/** * Return the number of rows available in the current display using the * current font. * @param parent The Composite whose Font will be queried. * @return int The result of the display size divided by the font size. */ public static int availableRows(Composite parent) { int fontHeight = (parent.getFont().getFontData())[0].getHeight(); int displayHeight = parent.getDisplay().getClientArea().height; return displayHeight / fontHeight; }
private boolean useHeightHint(Composite parent) { int fontHeight= (parent.getFont().getFontData())[0].getHeight(); int displayHeight= parent.getDisplay().getClientArea().height; return (displayHeight / fontHeight) > 50; }
protected Point getStackedLocation(Shell shell, Shell parent) { Point p= parent.getLocation(); Point size= parent.getSize(); p.x += size.x / 4; p.y += size.y; p= parent.toDisplay(p); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); shiftHorizontalLocation(p, shellBounds, displayBounds); shiftVerticalLocation(p, shellBounds, displayBounds); return p; }
protected Point getAboveLocation(Shell shell, int offset) { StyledText text= fViewer.getTextWidget(); Point location= text.getLocationAtOffset(offset); location= text.toDisplay(location); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); location.y=location.y - shellBounds.height; shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds); return location; }
protected Point getAboveLocation(Shell shell, int offset) { StyledText text= fViewer.getTextWidget(); Point location= text.getLocationAtOffset(offset); location= text.toDisplay(location); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); location.y=location.y - shellBounds.height; shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds); return location; }
protected Point getStackedLocation(Shell shell, Shell parent) { Point p= parent.getLocation(); Point size= parent.getSize(); p.x += size.x / 4; p.y += size.y; p= parent.toDisplay(p); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); shiftHorizontalLocation(p, shellBounds, displayBounds); shiftVerticalLocation(p, shellBounds, displayBounds); return p; }