/** * This method is needed in the case where the display has multiple monitors, but they do not form a uniform * rectangle. In this case, it is possible for Geometry.moveInside() to not detect that the window is partially or * completely clipped. We check to make sure at least the upper left portion of the rectangle is visible to give the * user the ability to reposition the dialog in this rare case. * * @param constrainee * @param display * @return */ private boolean isClippedByUnalignedMonitors( Rectangle constrainee, Display display ) { boolean isClipped; Monitor[] monitors = display.getMonitors(); if ( monitors.length > 0 ) { // Loop searches for a monitor proving false isClipped = true; for ( Monitor monitor : monitors ) { if ( monitor.getClientArea().contains( constrainee.x + 10, constrainee.y + 10 ) ) { isClipped = false; break; } } } else { isClipped = false; } return isClipped; }
Rectangle screenSize = display.getPrimaryMonitor().getBounds(); shell.setLocation( ( screenSize.width - shell.getBounds().width ) / 2, ( screenSize.height - shell.getBounds().height ) / 2 ); closeButton.setFocus();
shell.setLocation(primary.getClientArea().x, primary.getClientArea().y); shell.setSize(primary.getClientArea().width, primary.getClientArea().height); final Button b = new Button(controlsComposite, SWT.CHECK); b.setData(m); final boolean isPrimary = m.equals(d.getPrimaryMonitor()); b.setText(i + " " + m.getBounds().width + "x" + m.getBounds().height + (isPrimary ? " PRIMARY" : "")); b.setSelection(!isPrimary);
/** * Returns an array of monitors attached to the device. * * @return the array of monitors * * @since 1.2 */ public Monitor[] getMonitors() { checkDevice(); if( monitor == null ) { monitor = new Monitor( this ); } return new Monitor[] { monitor }; }
int /*long*/ monitorEnumProc (int /*long*/ hmonitor, int /*long*/ hdc, int /*long*/ lprcMonitor, int /*long*/ dwData) { if (monitorCount >= monitors.length) { Monitor[] newMonitors = new Monitor [monitors.length + 4]; System.arraycopy (monitors, 0, newMonitors, 0, monitors.length); monitors = newMonitors; } MONITORINFO lpmi = new MONITORINFO (); lpmi.cbSize = MONITORINFO.sizeof; OS.GetMonitorInfo (hmonitor, lpmi); Monitor monitor = new Monitor (); monitor.handle = hmonitor; Rectangle boundsInPixels = new Rectangle (lpmi.rcMonitor_left, lpmi.rcMonitor_top, lpmi.rcMonitor_right - lpmi.rcMonitor_left,lpmi.rcMonitor_bottom - lpmi.rcMonitor_top); monitor.setBounds (DPIUtil.autoScaleDown (boundsInPixels)); Rectangle clientAreaInPixels = new Rectangle (lpmi.rcWork_left, lpmi.rcWork_top, lpmi.rcWork_right - lpmi.rcWork_left, lpmi.rcWork_bottom - lpmi.rcWork_top); monitor.setClientArea (DPIUtil.autoScaleDown (clientAreaInPixels)); monitors [monitorCount++] = monitor; return 1; }
void updateSystemUIMode () { if ((window.collectionBehavior() & OS.NSWindowCollectionBehaviorFullScreenPrimary) != 0) return; if (!getMonitor ().equals (display.getPrimaryMonitor ())) return; int mode = display.systemUIMode, options = display.systemUIOptions; if (fullScreen) { mode = OS.kUIModeAllHidden; if (menuBar != null) { mode = OS.kUIModeContentHidden; } options = 0; } int[] uiMode = new int[1], uiOptions = new int[1]; OS.GetSystemUIMode(uiMode, uiOptions); if (uiMode[0] != mode || uiOptions[0] != options) OS.SetSystemUIMode (mode, options); if (fullScreen) window.setFrame(fullScreenFrame, true); }
shell.setLocation(primary.getClientArea().x, primary.getClientArea().y); shell.setSize(primary.getClientArea().width, primary.getClientArea().height); final Button b = new Button(controlsComposite, SWT.CHECK); b.setData(m); final boolean isPrimary = m.equals(d.getPrimaryMonitor()); b.setText(i + " " + m.getBounds().width + "x" + m.getBounds().height + (isPrimary ? " PRIMARY" : "")); b.setSelection(!isPrimary);
lpmi.cbSize = MONITORINFO.sizeof; OS.GetMonitorInfo (hmonitor, lpmi); Monitor monitor = new Monitor (); monitor.handle = hmonitor; Rectangle bounds = new Rectangle (lpmi.rcMonitor_left, lpmi.rcMonitor_top, lpmi.rcMonitor_right - lpmi.rcMonitor_left, lpmi.rcMonitor_bottom - lpmi.rcMonitor_top); bounds = DPIUtil.autoScaleDown (bounds); monitor.setBounds (bounds); Rectangle clientArea = new Rectangle (lpmi.rcWork_left, lpmi.rcWork_top, lpmi.rcWork_right - lpmi.rcWork_left, lpmi.rcWork_bottom - lpmi.rcWork_top); clientArea = DPIUtil.autoScaleDown (clientArea); monitor.setClientArea (clientArea); return monitor;
if (getMonitor().equals(display.getPrimaryMonitor ())) { if (menuBar != null) { double /*float*/ menuBarHt = NSStatusBar.systemStatusBar().thickness();
public static void setSize( Shell shell, int minWidth, int minHeight, boolean packIt ) { PropsUI props = PropsUI.getInstance(); WindowProperty winprop = props.getScreen( shell.getText() ); if ( winprop != null ) { winprop.setShell( shell, minWidth, minHeight ); } else { if ( packIt ) { shell.pack(); } else { shell.layout(); } // OK, sometimes this produces dialogs that are waay too big. // Try to limit this a bit, m'kay? // Use the same algorithm by cheating :-) // winprop = new WindowProperty( shell ); winprop.setShell( shell, minWidth, minHeight ); // Now, as this is the first time it gets opened, try to put it in the middle of the screen... Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor(); } Rectangle monitorClientArea = monitor.getClientArea(); int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2; int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2; shell.setLocation( middleX, middleY ); } }
protected Splash( Display display, Shell splashShell ) throws KettleException { log = new LogChannel( Spoon.APP_NAME ); Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
checkDevice (); if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { Monitor monitor = new Monitor(); int width = OS.GetSystemMetrics (OS.SM_CXSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYSCREEN); Rectangle bounds = new Rectangle (0, 0, width, height); bounds = DPIUtil.autoScaleDown (bounds); monitor.setBounds (bounds); RECT rect = new RECT (); OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0); Rectangle clientArea = new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); clientArea = DPIUtil.autoScaleDown (clientArea); monitor.setClientArea( clientArea); return monitor;
public static void setSize( Shell shell, int prefWidth, int prefHeight ) { PropsUI props = PropsUI.getInstance(); WindowProperty winprop = props.getScreen( shell.getText() ); if ( winprop != null ) { winprop.setShell( shell, prefWidth, prefHeight ); } else { shell.layout(); winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) ); winprop.setShell( shell ); // Now, as this is the first time it gets opened, try to put it in the middle of the screen... Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor(); } Rectangle monitorClientArea = monitor.getClientArea(); int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2; int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2; shell.setLocation( middleX, middleY ); } }
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 }
uiSession = ContextProvider.getUISession(); shells = new ArrayList<>(); monitor = new Monitor( this ); cursorLocation = new Point( 0, 0 ); bounds = readInitialBounds();
monitor = shell.getParent().getMonitor(); Rectangle monitorClientArea = monitor.getClientArea(); constrainRectangleToContainer( resizedRect, monitorClientArea );