|
|
Re: Editable Text to fill scrolled composite, but not expand it? [message #492773 is a reply to message #492436] |
Wed, 21 October 2009 16:34 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
The Label/Text has to be constrained by some means so that it knows where to
wrap, but setting a widthHint is not the only way to do this. If the
ScrolledComposite is using a GridLayout and the Label's layout data
specifies to fill horizontally then the Label should be auto-resized to
match its parent, and this is where it will wrap. Your case is probably
more complex than the snippet below, but hopefully this will provide some
clues...
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
ScrolledComposite c1 = new ScrolledComposite(shell, SWT.H_SCROLL |
SWT.V_SCROLL);
c1.setLayout(new GridLayout());
Text text = new Text(c1, SWT.MULTI | SWT.WRAP | SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL,
GridData.BEGINNING, true, false));
for (int i = 0; i < 999; i++) {
text.append(" asdf" + i);
}
c1.setContent(text);
c1.setAlwaysShowScrollBars(true);
c1.setExpandHorizontal(true);
c1.setExpandVertical(true);
c1.setMinSize(300, 300);
shell.setSize(300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
HTH,
Grant
"Torbj" <tgdahle@origin.no> wrote in message
news:hbkbi2$2g7$1@build.eclipse.org...
> By looking at the Label source code, it appears that SWT.WRAP is only used
for computing the label size if widthHint is set. Does this mean that the
only way to get the Label to dynamically wrap as its parent is resized is to
manually calculate a new widhHint, set it and run layout again?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03502 seconds