public WindowProperty( Shell shell ) { name = shell.getText(); maximized = shell.getMaximized(); rectangle = shell.getBounds(); }
/** * Overridden to auto-size the shell according to the selected width. */ @Override protected void constrainShellSize() { super.constrainShellSize(); try { // the shell property within the Windows class is private - need to access it via reflection final Field shellField = Window.class.getDeclaredField( "shell" ); shellField.setAccessible( true ); final Shell thisShell = (Shell) shellField.get( this ); thisShell.pack(); final int height = thisShell.computeSize( width, SWT.DEFAULT ).y; thisShell.setBounds( thisShell.getBounds().x, thisShell.getBounds().y, width + 4, height + 2 ); } catch ( final Exception e ) { // nothing to do } }
/** * 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 ); }
protected void setPosition() { Rectangle shellBounds = getParent().getBounds(); Point dialogSize = dialog.getSize(); dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); } }
private void setPosition() { Rectangle shellBounds = getParent().getBounds(); Point dialogSize = dialog.getSize(); dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); } }
protected void setMiddle() { Rectangle screenSize = shell.getParent().getBounds(); Rectangle shellSize = shell.getBounds(); shell.setLocation(screenSize.x + screenSize.width / 2 - shellSize.width / 2, screenSize.y + screenSize.height / 2 - shellSize.height / 2); }
public void widgetSelected( SelectionEvent event ) { if ( list.getSelectionCount() <= 0 ) { return; } String name = list.getSelection()[0]; String value = variables.getVariable( name ); Rectangle shellBounds = shell.getBounds(); String message = BaseMessages.getString( PKG, "TextVar.VariableValue.Message", name, value ); if ( name.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { message += BaseMessages.getString( PKG, "TextVar.InternalVariable.Message" ); } toolTip.setText( message ); toolTip.hide(); toolTip.show( new Point( shellBounds.width, 0 ) ); } } );
protected void openDialog() { shell.pack(); // Set the focus on the OK button wOK.setFocus(); Rectangle shellBounds = getParent().getBounds(); Point dialogSize = shell.getSize(); shell.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); shell.open(); while ( !shell.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } }
public void dispose() { props.setScreen( new WindowProperty( shell ) ); bounds = shell.getBounds(); hscroll = wFields.getHorizontalBar().getSelection(); vscroll = wFields.getVerticalBar().getSelection(); shell.dispose(); }
public void dispose() { props.setScreen( new WindowProperty( shell ) ); bounds = shell.getBounds(); hscroll = wFields.getHorizontalBar().getSelection(); vscroll = wFields.getVerticalBar().getSelection(); shell.dispose(); }
/** * * @param shell * the shell. */ public OlapInputAboutDialog( final Shell shell ) { this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET ); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; this.dialog.setLayout( gridLayout ); this.dialog.setText( BaseMessages.getString( PKG, "OlapInputDialog.About.Shell.Title" ) ); this.dialog.setImage( shell.getImage() ); this.buildIconCell(); this.buildPluginInfoCell(); this.buildOkButton(); this.dialog.pack(); Rectangle shellBounds = shell.getBounds(); Point dialogSize = this.dialog.getSize(); this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); }
/** * * @param shell * the shell. */ public SapInputAboutDialog( final Shell shell ) { this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET ); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; this.dialog.setLayout( gridLayout ); this.dialog.setText( BaseMessages.getString( PKG, "SapInputDialog.About.Shell.Title" ) ); this.dialog.setImage( shell.getImage() ); this.buildIconCell(); this.buildPluginInfoCell(); this.buildOkButton(); this.dialog.pack(); Rectangle shellBounds = shell.getBounds(); Point dialogSize = this.dialog.getSize(); this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); }
/** * * @param shell * the shell. */ public TeraFastAboutDialog( final Shell shell ) { this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET ); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; this.dialog.setLayout( gridLayout ); this.dialog.setText( BaseMessages.getString( PKG, "TeraFastDialog.About.Shell.Title" ) ); this.dialog.setImage( shell.getImage() ); this.buildIconCell(); this.buildPluginInfoCell(); this.buildOkButton(); this.dialog.pack(); Rectangle shellBounds = shell.getBounds(); Point dialogSize = this.dialog.getSize(); this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 ); }
shell.open(); Rectangle shellBounds = getParent().getBounds(); Point dialogSize = shell.getSize();
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 ); } }
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 ); } }
Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) {
ShellMetricsResizeListener(Shell shell, String sConfigPrefix) { this.sConfigPrefix = sConfigPrefix; state = calcState(shell); if (state == SWT.NONE) bounds = shell.getBounds(); shell.addListener(SWT.Resize, this); shell.addListener(SWT.Move, this); shell.addListener(SWT.Dispose, this); }