Made SimulationView(Editor) a View again
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / util / OverlappingFillLayout.java
diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/OverlappingFillLayout.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/OverlappingFillLayout.java
new file mode 100644 (file)
index 0000000..839ba71
--- /dev/null
@@ -0,0 +1,37 @@
+package net.mograsim.plugin.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+public class OverlappingFillLayout extends Layout
+{
+       @Override
+       protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
+       {
+               Point size = new Point(wHint == SWT.DEFAULT ? 0 : wHint, hHint == SWT.DEFAULT ? 0 : hHint);
+
+               Control[] children = composite.getChildren();
+               for (Control child : children)
+               {
+                       Point childSize = child.computeSize(wHint, hHint, flushCache);
+                       size.x = Math.max(size.x, childSize.x);
+                       size.y = Math.max(size.y, childSize.y);
+               }
+
+               return size;
+       }
+
+       @Override
+       protected void layout(Composite composite, boolean flushCache)
+       {
+               Rectangle bounds = composite.getClientArea();
+
+               Control[] children = composite.getChildren();
+               for (Control child : children)
+                       child.setBounds(bounds);
+       }
+}
\ No newline at end of file