Bug 5016 - Controlling shell min size during resize
Summary: Controlling shell min size during resize
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal with 9 votes (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-16 10:53 EDT by Simon Arsenault CLA
Modified: 2004-08-10 18:34 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Arsenault CLA 2001-10-16 10:53:57 EDT
We have a problem right now in Eclipse where a detach window can be resized to 
a small dot. We would like to control the resize so that it stops at a minimum 
size. The detach window does not have a title bar (if it did, we would get this 
behavior for free on windows). The title bar is not there because it was 
confusing to the user seeing what looked like two title bar in a detached 
window.

I could not find any api to do this. There is a resize callback, but at that 
point the shell is already resized. Is it valid in the resize callback to force 
the shell height/width back to a minimum? I've not tried this but I would 
suspect it may have a weird ui effect.

-----
Reply from Veronika...

I can't see any other way to limit the size of the shell given the current API.
You can change the size in the resize callback.  There is a slght flash as the 
size bounces but for now that is all that I think you can do.  I will run it 
past Steve when he gets back from OOPSLA.

public static void main (String [] args) {
	Display display = new Display ();
	final Shell shell = new Shell (display);
	shell.setLayout(new GridLayout());
	Button b = new Button(shell, SWT.PUSH);
	b.setText("Open Dialog ...");
	b.addListener(SWT.Selection, new Listener(){
		public void handleEvent (Event e) {
			final Shell dialog = new Shell(shell, SWT.SHELL_TRIM);
			dialog.addListener(SWT.Resize, new Listener() {
				public void handleEvent(Event e) {
					Point size = dialog.getSize();
					if (size.x < 100 || size.y < 100) {
						dialog.setSize(new Point
(Math.max(size.x, 100), Math.max(size.y, 100)));
					}
				}
			});
			dialog.open();
		}
	});
	
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
Comment 1 Steve Northover CLA 2003-01-02 17:55:23 EST
We should be using the platform to set the minimum (and maximum) size for a 
shell.
Comment 2 Steve Northover CLA 2004-08-04 19:19:26 EDT
We could consider adding Shell.get/setMinimumSize().  SSQ, your thoughts?  
This is a really old (but non-critical) bug report.
Comment 3 Silenio Quarti CLA 2004-08-05 10:03:55 EDT
We should do this.
Comment 4 Steve Northover CLA 2004-08-10 18:34:19 EDT
Fixed > 20040910

See Shell.setMinimumSize().