Improved usage of CoreModelParametersBuilder
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / util / OverlappingFillLayout.java
1 package net.mograsim.plugin.util;
2
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.graphics.Point;
5 import org.eclipse.swt.graphics.Rectangle;
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.swt.widgets.Control;
8 import org.eclipse.swt.widgets.Layout;
9
10 public class OverlappingFillLayout extends Layout
11 {
12         @Override
13         protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
14         {
15                 Point size = new Point(wHint == SWT.DEFAULT ? 0 : wHint, hHint == SWT.DEFAULT ? 0 : hHint);
16
17                 Control[] children = composite.getChildren();
18                 for (Control child : children)
19                 {
20                         Point childSize = child.computeSize(wHint, hHint, flushCache);
21                         size.x = Math.max(size.x, childSize.x);
22                         size.y = Math.max(size.y, childSize.y);
23                 }
24
25                 return size;
26         }
27
28         @Override
29         protected void layout(Composite composite, boolean flushCache)
30         {
31                 Rectangle bounds = composite.getClientArea();
32
33                 Control[] children = composite.getChildren();
34                 for (Control child : children)
35                         child.setBounds(bounds);
36         }
37 }