| Summary: | Children of a shell are not resized until after the resize event comes in | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Tod Creasey <Tod_Creasey> |
| Component: | SWT | Assignee: | Steve Northover <snorthov> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 63694 | ||
Tod, I don't see the bug. The resize event for the shell comes in when the shell is resized. If there is no layout, the size of the children do not change. If there is a layout, then the layout uses the new size of the shell to position the children. Am I missing something? The problem is that I am getting a resize event and the shell is a different size but not its widgets (thier resize happens later). I am trying to calculate an ellipsis based on the size of the label but I can only get notification of the resize from the shell resize. |
3.0 When you get a resize event due to a maximize from the shell it is before it's children are resized. As a result you cannot make any decision based on the size of the parent. This may also be true on a regular resize but those events come in so fast that you do not notice. STEPS 1) Run the example below 2) Maximize - you will see that the label size is too small 3) Minimize - you will get the maximized size. import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class ShellResizeTest { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); GridLayout layout = new GridLayout(); shell.setLayout(layout); final Label label = new Label(shell,SWT.NONE); label.setText("String"); GridData labelData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); label.setLayoutData(labelData); label.setBackground(display.getSystemColor (SWT.COLOR_DARK_YELLOW)); shell.addListener(SWT.Resize, new Listener(){ /* (non-Javadoc) * @see org.eclipse.swt.widgets.Listener#handleEvent (org.eclipse.swt.widgets.Event) */ public void handleEvent(Event event) { System.out.println(label.getSize().x); } }); shell.setBounds(0,0,300,100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }