SashForm children width [message #648333] |
Wed, 12 January 2011 08:37  |
Eclipse User |
|
|
|
Hi,
I've got an horizontal SashForm with two children. The one on the left should always be, at least, 200 pixels width.
I've disallowed dragging the sash below 200px, but the problem comes when the shell is resized. I've added a ControlListener to the left component. In its controlResized event I check the component width. When it's smaller than 200, I set its bounds' width to 200. It apparently works as the component gets resized to that width, but the sashform stops working - the sash is no longer visible, it remains under the component.
Does anybody know what am I missing?
Thanks in advance
|
|
|
|
|
|
Re: SashForm children width [message #649987 is a reply to message #648333] |
Fri, 21 January 2011 05:07   |
Eclipse User |
|
|
|
Quote: | Which platform are you using? Can you paste an example snippet showing your problem?
|
I'm using Linux/GTK, although this should work on other platforms (win32 and macosx). Here's the snippet:
public class SashExample {
public static void main(String[] args) {
final int MIN_SIZE = 150;
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final SashForm sashForm = new SashForm(shell, SWT.NONE);
final Composite left = new Composite(sashForm, SWT.BORDER);
final Composite right = new Composite(sashForm, SWT.BORDER);
left.setLayout(new RowLayout());
right.setLayout(new RowLayout());
new Label(left, SWT.NONE).setText("Left side");
new Label(right, SWT.NONE).setText("Right side");
left.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
if (left.getBounds().width < MIN_SIZE) {
int totalWidth = sashForm.getClientArea().width;
sashForm.setWeights(new int[] {MIN_SIZE, totalWidth - MIN_SIZE});
}
}
});
sashForm.setWeights(new int [] {1, 3});
shell.setSize(1000, 600);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Thanks!
|
|
|
|
Powered by
FUDForum. Page generated in 0.53275 seconds