size of WorkbenchWindowControlContribution [message #537179] |
Tue, 01 June 2010 14:53 |
Stella Levin Messages: 89 Registered: July 2009 |
Member |
|
|
Hi, I defined Text field and image contribution to toolbar as follows. I want it to be like a line with link in a browser. The text value may change, but it should have constant width, much larger than it is created now. text.setSize and composite.setSize doesn't help.
public class ContextField extends WorkbenchWindowControlContribution {
protected Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(3, false);
composite.setLayout(layout);
Label labelImage = new Label(composite, SWT.RIGHT);
labelImage.setImage(image);
labelImage.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));
text = new Text(composite, SWT.SINGLE | SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Point p = text.getSize();
composite.setSize(320, p.y); // try 1 - doesn't help
p = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
System.out.println("text width=" + p.x + " height=" + p.y);
p = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
composite.setSize(350, p.y); // try 2 - doesn't help
System.out.println("Composite width=" + p.x + " height=" + p.y);
return composite;
}
@Override
public boolean isDynamic() {
return true;
}
Thanks
|
|
|
|
Powered by
FUDForum. Page generated in 0.06001 seconds