/** * Returns a rectangle describing the receiver's size and location * relative to its device. Note that on multi-monitor systems the * origin can be negative. * * @return the receiver's bounding rectangle */ public Rectangle getBounds() { return display.getBounds(); }
private ClipScreen(Display display, Image screenImage, boolean closeDisplayOnEnd){ this.closeDisplayOnEnd = closeDisplayOnEnd; this.screenImage = screenImage; this.display = display; Rectangle screenRec = display.getBounds(); screenWidth = screenRec.width; screenHeight = screenRec.height; }
@Override public final int getScreenWidth() { return c.getDisplay().getBounds().width; }
final Display display = getShell().getDisplay(); final Monitor monitor = display.getPrimaryMonitor(); final Rectangle rect; if (monitor != null) { rect = monitor.getClientArea(); } else { // In case we cannot find the primary monitor get the entire display rectangle // Note that it may include the dimensions of multiple monitors. rect = display.getBounds(); } System.out.println("Monitor width=" + String.valueOf(rect.width)); System.out.println("Monitor height=" + String.valueOf(rect.height));
@Override public final int getScreenHeight() { return c.getDisplay().getBounds().height; }
private Point getInitialDialogLocation( Point initialSize ) { Rectangle dispayBounds = getShell().getDisplay().getBounds(); Point centerPoint = Geometry.centerPoint( dispayBounds ); int x = centerPoint.x - ( initialSize.x / 2 ); int y = Math.min( centerPoint.y - ( initialSize.y * 2 / 3 ), dispayBounds.height - initialSize.y ); return new Point( x, Math.max( 0, y ) ); } //RAPEND [if]
private Rectangle computeShellBounds() { Rectangle result = new Rectangle( 0, 0, 0, 0 ); Point preferredSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); Rectangle displaySize = parent.getDisplay().getBounds(); result.x = ( displaySize.width - preferredSize.x ) / 2 + displaySize.x; result.y = ( displaySize.height - preferredSize.y ) / 2 + displaySize.y; result.width = Math.min( preferredSize.x, MAX_WIDTH ); result.height = preferredSize.y; return result; }
@Override protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); // On large fonts this can make this dialog huge widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); // On large fonts this can make this dialog huge widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
@Override protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); // On large fonts this can make this dialog huge widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
@Override public IDimension screenSize () { Rectangle db = plat.display().getBounds(); return new Dimension(db.width, db.height); }
void webView_setFrame(long /*int*/ sender, long /*int*/ frame) { NSRect rect = new NSRect(); OS.memmove(rect, frame, NSRect.sizeof); /* convert to SWT system coordinates */ Rectangle bounds = browser.getDisplay().getBounds(); location = new Point((int)rect.x, bounds.height - (int)rect.y - (int)rect.height); size = new Point((int)rect.width, (int)rect.height); }
/** * Sets the size of the shell to it's "packed" size, * unless that makes it bigger than the display, * in which case set it to 9/10 of display size. */ private static void setShellSize (Display display, Shell shell) { Rectangle bounds = display.getBounds(); Point size = shell.computeSize (SWT.DEFAULT, SWT.DEFAULT); if (size.x > bounds.width) size.x = bounds.width * 9 / 10; if (size.y > bounds.height) size.y = bounds.height * 9 / 10; shell.setSize (size); }
@Override public IDimension screenSize () { Rectangle db = plat.display().getBounds(); return new Dimension(db.width, db.height); }
private void configureShell() { shell.setText( title ); Rectangle displaySize = parent.getDisplay().getBounds(); Point prefSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); shell.setSize( prefSize ); int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x; int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y; shell.setLocation( new Point( locationX, locationY ) ); shell.pack(); }
private void layoutAndCenterShell() { Point prefSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); // leave some space in preview area for larger fonts prefSize.y += 50; shell.setSize( prefSize ); Rectangle displaySize = parent.getDisplay().getBounds(); int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x; int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y; shell.setLocation( locationX, locationY ); }
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); } }
static void readBounds( final Display display ) { Rectangle oldBounds = display.getBounds(); int width = readIntPropertyValue( display, "bounds.width", oldBounds.width ); int height = readIntPropertyValue( display, "bounds.height", oldBounds.height ); Rectangle bounds = new Rectangle( 0, 0, width, height ); getDisplayAdapter( display ).setBounds( bounds ); }
public void handleNotifyResize( Display display ) { Event event = new Event(); event.display = display; event.type = SWT.Resize; event.time = EventUtil.getLastEventTime(); event.setBounds( display.getBounds() ); getDisplayAdapter( display ).notifyListeners( SWT.Resize, event ); }