Rectangle screenSize = display.getPrimaryMonitor().getBounds(); shell.setLocation( ( screenSize.width - shell.getBounds().width ) / 2, ( screenSize.height - shell.getBounds().height ) / 2 ); closeButton.setFocus();
protected Splash( Display display, Shell splashShell ) throws KettleException { log = new LogChannel( Spoon.APP_NAME ); Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
Monitor widgetMonitor = mTextWidget.getMonitor(); Rectangle monitorRect = widgetMonitor.getBounds(); if(monitorRect.x < 0){ // shown in left monitor, starting from the main monitor } if(monitorRect.x > monitorRect.width){ // shown in right monitor, starting from the main monitor }
TouchSource findTouchSource (int /*long*/ touchDevice, Monitor monitor) { if (touchSources == null) touchSources = new TouchSource [4]; int length = touchSources.length; for (int i=0; i<length; i++) { if (touchSources [i] != null && touchSources [i].handle == touchDevice) { return touchSources [i]; } } int index = 0; while (index < length) { if (touchSources [index] == null) break; index++; } if (index == length) { TouchSource [] newTouchSources = new TouchSource [length + 4]; System.arraycopy (touchSources, 0, newTouchSources, 0, length); touchSources = newTouchSources; } return touchSources [index] = new TouchSource (touchDevice, true, monitor.getBounds ()); }
/** * Make the window use all the screen and remove the title bar. */ void setFullScreen() { this.shell.setFullScreen(true); this.shell.setFocus(); final Monitor m = Display.getDefault().getPrimaryMonitor(); this.shell.setBounds(-1, -1, m.getBounds().width + 2, m.getBounds().height + 2); this.screenSize = new ScreenSize(m.getBounds().width, m.getBounds().height); }
@Override protected Point getInitialLocation(Point initialSize) { Point location = getTargetLocation(); Point size = target.getSize(); int x = location.x + size.x / 2 - initialSize.x / 2; int y = location.y + size.y; Rectangle bounds = target.getMonitor().getBounds(); if (y + initialSize.y > bounds.y + bounds.height) { y = location.y - initialSize.y; } return new Point(x, y); }
/** Returns the monitor (if any) which contains the given point. */ public static Optional<Monitor> monitorFor(Point p) { Monitor[] monitors = assertUI().getMonitors(); for (Monitor monitor : monitors) { Rectangle bounds = monitor.getBounds(); if (bounds.contains(p)) { return Optional.of(monitor); } } return Optional.empty(); }
/** * Either show or hide the fake tooltip. The tooltip will become visible in * case the given tooltip is a valid URL (non strict match). * * @param tooltip The new value of the Tooltip * @param control The control the tooltip is appearing on */ public void updateFakeTooltip(String tooltip, Control control) { Rectangle rect = control.getMonitor().getBounds(); updateFakeTooltip(tooltip, rect, false); }
public void updateFakeTooltip(String tooltip, Composite c) { Rectangle rect = c.getMonitor().getBounds(); updateFakeTooltip(tooltip, rect, false); }
public static void centerShell(Shell shell) { Rectangle displayBounds = shell.getDisplay().getPrimaryMonitor().getBounds(); Rectangle shellBounds = shell.getBounds(); int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1; int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1; shell.setLocation(x, y); }
/** * Increase the size of this dialog's <code>Shell</code> by the specified amounts. * Do not increase the size of the Shell beyond the bounds of the Display. */ protected void setShellSize(int width, int height) { Rectangle bounds = getShell().getMonitor().getBounds(); getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height)); }
/** * Centers the shell on the display. * The used monitor will always the first one. */ protected void centerShell() { Rectangle r = shell.getDisplay().getMonitors()[0].getBounds(); int shellX = (r.width - shell.getSize().x) / 2; int shellY = (r.height - shell.getSize().y) / 2; shell.setLocation(shellX, shellY); }
/** * Centers the shell on the display. * The used monitor will always the first one. */ protected void centerShell() { Rectangle r = shell.getDisplay().getMonitors()[0].getBounds(); int shellX = (r.width - shell.getSize().x) / 2; int shellY = (r.height - shell.getSize().y) / 2; shell.setLocation(shellX, shellY); }
private void positionWindow() { // place the window near the lower right-hand corner Monitor primary = display.getPrimaryMonitor(); Rectangle bounds = primary.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) - 5; int y = bounds.y + (bounds.height - rect.height) - 35; shell.setLocation(x, y); }
/** * Center a shell on the monitor * * @param display The display * @param shell The shell to center */ public static void centerShell(Display display, Shell shell) { Rectangle displayBounds = display.getPrimaryMonitor().getBounds(); Rectangle shellBounds = shell.getBounds(); int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1; int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1; shell.setLocation(x, y); }
/** * Centers the given shell on the parent shell. * * If the parent shell is null, the shell is centered on the display. * * If more than one monitor is used, the shell is centered on the * primary monitor. */ public static void centerShell(Shell parentShell, Shell shell) { Rectangle parentRect; Rectangle splashRect = shell.getBounds(); if (parentShell == null) { parentRect = shell.getDisplay().getPrimaryMonitor().getBounds(); } else { parentRect = parentShell.getBounds(); } int x = parentRect.x + (parentRect.width - splashRect.width) / 2; int y = parentRect.y + (parentRect.height - splashRect.height) / 2; shell.setLocation(x, y); }
@Override protected Point getInitialLocation(Point initialSize) { if (getShell().getParent() == null) { return super.getInitialLocation(initialSize); } Rectangle bounds = getShell().getParent().getMonitor().getBounds(); GC gc = new GC(getShell().getDisplay()); int textExtendX = gc.textExtent(message).x; gc.dispose(); return new Point(bounds.x + bounds.width / 2 - textExtendX / 2, bounds.y + bounds.height / 5); }
public void getChildAtPoint(AccessibleControlEvent e) { NSPoint testPoint = new NSPoint(); testPoint.x = e.x; Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); testPoint.y = (int) (primaryMonitor.getBounds().height - e.y); Iterator iter = childRowToIdMap.values().iterator(); while (iter.hasNext()) { AccessibleTableRow row = (AccessibleTableRow) iter.next(); NSValue locationValue = new NSValue(row.getPositionAttribute(ACC.CHILDID_SELF).id); NSPoint location = locationValue.pointValue(); NSValue sizeValue = new NSValue(row.getSizeAttribute(ACC.CHILDID_SELF)); NSSize size = sizeValue.sizeValue(); if (location.y < testPoint.y && testPoint.y < (location.y + size.height)) { AccessibleControlEvent e2 = new AccessibleControlEvent(e.getSource()); e2.x = (int) testPoint.x; e2.y = (int) testPoint.y; row.getChildAtPoint(e); break; } } }