1 package org.simantics.document.swt.core.base;
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.custom.ScrolledComposite;
5 import org.eclipse.swt.graphics.Point;
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.swt.widgets.ScrollBar;
8 import org.simantics.utils.ui.SWTUtils;
10 public class ScrolledCompositeContent extends Composite implements Runnable {
12 public ScrolledCompositeContent(Composite parent, int style) {
16 public void refreshSize() {
17 SWTUtils.asyncExec(this, this);
22 if(isDisposed()) return;
24 ScrolledComposite sc = (ScrolledComposite)getParent();
25 int scWidth = sc.getSize().x;
27 ScrollBar bar = sc.getVerticalBar();
28 if(bar != null && bar.isVisible())
29 scWidth -= bar.getSize().x;
31 Point current = getSize();
32 Point target = computeSize(scWidth, SWT.DEFAULT, true);
34 if(!current.equals(target)) {
36 sc.getParent().layout(true, true);