-/*******************************************************************************\r
- * Copyright (c) 2007 SAS Institute.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * SAS Institute - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.utils.ui.internal.awt;\r
-\r
-import org.eclipse.swt.events.ControlAdapter;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-public class CleanResizeListener extends ControlAdapter {\r
-\r
- private Rectangle oldRect = null;\r
-\r
- public void controlResized(ControlEvent e) {\r
- assert e != null;\r
- assert Display.getCurrent() != null; // On SWT event thread\r
-\r
- // Prevent garbage from Swing lags during resize. Fill exposed areas\r
- // with background color.\r
- Composite composite = (Composite) e.widget;\r
- // Rectangle newRect = composite.getBounds();\r
- // newRect = composite.getDisplay().map(composite.getParent(), composite, newRect);\r
- Rectangle newRect = composite.getClientArea();\r
- if (oldRect != null) {\r
- int heightDelta = newRect.height - oldRect.height;\r
- int widthDelta = newRect.width - oldRect.width;\r
- if ((heightDelta > 0) || (widthDelta > 0)) {\r
- GC gc = new GC(composite);\r
- try {\r
- gc.fillRectangle(newRect.x, oldRect.height, newRect.width, heightDelta);\r
- gc.fillRectangle(oldRect.width, newRect.y, widthDelta, newRect.height);\r
- } finally {\r
- gc.dispose();\r
- }\r
- }\r
- }\r
- oldRect = newRect;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007 SAS Institute.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAS Institute - initial API and implementation
+ *******************************************************************************/
+package org.simantics.utils.ui.internal.awt;
+
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+public class CleanResizeListener extends ControlAdapter {
+
+ private Rectangle oldRect = null;
+
+ public void controlResized(ControlEvent e) {
+ assert e != null;
+ assert Display.getCurrent() != null; // On SWT event thread
+
+ // Prevent garbage from Swing lags during resize. Fill exposed areas
+ // with background color.
+ Composite composite = (Composite) e.widget;
+ // Rectangle newRect = composite.getBounds();
+ // newRect = composite.getDisplay().map(composite.getParent(), composite, newRect);
+ Rectangle newRect = composite.getClientArea();
+ if (oldRect != null) {
+ int heightDelta = newRect.height - oldRect.height;
+ int widthDelta = newRect.width - oldRect.width;
+ if ((heightDelta > 0) || (widthDelta > 0)) {
+ GC gc = new GC(composite);
+ try {
+ gc.fillRectangle(newRect.x, oldRect.height, newRect.width, heightDelta);
+ gc.fillRectangle(oldRect.width, newRect.y, widthDelta, newRect.height);
+ } finally {
+ gc.dispose();
+ }
+ }
+ }
+ oldRect = newRect;
+ }
+
+}