/** * 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 } }
Text tfNext = new Text(shell, SWT.BORDER); tfNext.setText("TF without tooltip"); shell.setBounds(50, 50, 300, 200); shell.open(); while (!shell.isDisposed()) {
@Override public void setBounds( Rectangle bounds ) { Shell.this.setBounds( bounds, false ); }
public void run() { if (!shell.isDisposed()) // RAP [bm]: SWT.RIGHT_TO_LEFT missing // shell.setBounds(bounds.x + ((getDefaultOrientation() == SWT.RIGHT_TO_LEFT) ? trayWidth : 0), bounds.y, bounds.width - trayWidth, bounds.height); shell.setBounds(bounds.x + 0, bounds.y, bounds.width - trayWidth, bounds.height); // RAPEND: [bm] } });
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) {
Image image = new Image(display, "c:\\picture.jpeg"); Shell shell = new Shell(SWT.NO_TRIM); shell.setBounds(10,10,200,200); shell.setBackgroundImage(image); shell.setBackgroundMode(SWT.INHERIT_DEFAULT); Label label = new Label(shell, SWT.NONE); label.setText("LAbel text here. ");
/** * Initialize the dialog bounds with the bounds saved * from the settings. */ @Override protected void initializeBounds() { if (bounds != null) { getShell().setBounds(bounds); } else { super.initializeBounds(); } }
public void run() { clearSizeUpdate(); while (!windowsToUpdate.isEmpty()) { MWindow window = windowsToUpdate.remove(0); Shell shell = (Shell) window.getWidget(); if (shell == null || shell.isDisposed()) continue; shell.setBounds(window.getX(), window.getY(), window.getWidth(), window.getHeight()); } } }
protected void initializeBounds() { if (resizeListener != null) { shell.removeListener(SWT.Resize,resizeListener); } if (resizeHasOccurred) { // Check if shell size has been set already. return; } Point size = getInitialSize(); Point location = getInitialLocation(size); shell.setBounds(location.x, location.y, size.x, size.y); }
/** * Constrain the shell size to be no larger than the display bounds. * * @since 2.0 */ protected void constrainShellSize() { // limit the shell size to the display size Rectangle bounds = shell.getBounds(); Rectangle constrained = getConstrainedShellBounds(bounds); if (!bounds.equals(constrained)) { shell.setBounds(constrained); } }
/** * Constrain the shell size to be no larger than the display bounds. * * @since 1.0 */ protected void constrainShellSize() { // limit the shell size to the display size Rectangle bounds = shell.getBounds(); Rectangle constrained = getConstrainedShellBounds(bounds); if (!bounds.equals(constrained)) { shell.setBounds(constrained); } }
/** * Constrain the shell size to be no larger than the display bounds. * * @since 2.0 */ protected void constrainShellSize() { // limit the shell size to the display size Rectangle bounds = shell.getBounds(); Rectangle constrained = getConstrainedShellBounds(bounds); if (!bounds.equals(constrained)) { shell.setBounds(constrained); } }
@Override protected void prepareOpen() { determineImageFromStyle(); shell = new Shell( parent, SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL ); shell.setText( title ); createControls(); shell.setBounds( computeShellBounds() ); shell.pack(); }
/** * This method should initialize the dialog bounds. */ @Override protected void initializeBounds() { super.initializeBounds(); refreshDialogSize(); boolean modalitySwitch = getBooleanValue(IStatusDialogConstants.MODALITY_SWITCH); if (modalitySwitch) { getShell().setBounds(getShellBounds()); } }
public int createAndOpen() { create(); getShell().setText(title); Rectangle r = getShell().getBounds(); getShell().setBounds(r.x + 80, r.y + 80, r.width, r.height); setBlockOnOpen(true); return open(); }
/** * @param parent */ public TableTextEditor(TableCursor parent, int style) { m_shell = new Shell(parent.getShell(), SWT.TOOL); m_shell.setBounds(computeBounds(parent, style)); m_shell.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_GREEN)); FillLayout layout = new FillLayout(); layout.marginHeight = BORDER_WIDTH; layout.marginWidth = BORDER_WIDTH; m_shell.setLayout(layout); m_text = new Text(m_shell, style); m_text.setBackground(m_text.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); }
@Override public void expansionStateChanged(ExpansionEvent e) { launchData.setShowRecentWorkspaces(((ExpandableComposite) e.getSource()).isExpanded()); Point size = getInitialSize(); Shell shell = getShell(); shell.setBounds(getConstrainedShellBounds( new Rectangle(shell.getLocation().x, shell.getLocation().y, size.x, size.y))); } });
public SplitFeedbackOverlay(Shell dragShell, Rectangle rect, int side, float pct, boolean enclosed, boolean modified) { outerRect = rect; curSide = side; ratio = pct; feedbackShell = new Shell(dragShell, SWT.NO_TRIM); feedbackShell.setBounds(dragShell.getBounds()); MWindow winModel = (MWindow) dragShell.getData(AbstractPartRenderer.OWNING_ME); stylingEngine = winModel.getContext().get(IStylingEngine.class); // Show the appropriate feedback rectangles setFeedback(enclosed, modified); defineRegion(); }
/** * 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); }