[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Layouts, minimal height and grabExcessXXXSpace

It might be easier to use a FormLayout, because you will have a bit more 
control.
For example, here is a snippet.
Hope this helps,
Carolyn

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class FormWithTables {
 public static void main (String [] args) {
  Display display = new Display ();
  Shell shell = new Shell (display);
  FormLayout formLayout = new FormLayout ();
  formLayout.marginWidth = 4;
  formLayout.marginHeight = 4;
  formLayout.spacing = 4;
  shell.setLayout (formLayout);

  Button button1 = new Button (shell, SWT.PUSH);
  button1.setText ("button1");
  Point size = button1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  int center = size.y / 2;

  Table table0 = new Table (shell, SWT.BORDER);
  table0.setLinesVisible (true);
  for (int i = 0; i < 5; i++) {
  TableItem tableItem = new TableItem (table0, SWT.NONE);
   tableItem.setText ("Item" + i);
  }

  Table table2 = new Table (shell, SWT.BORDER);
  table2.setLinesVisible (true);
  for (int i = 0; i < 5; i++) {
  TableItem tableItem = new TableItem (table2, SWT.NONE);
   tableItem.setText ("Item" + i);
  }

  FormData data = new FormData ();
  data.top = new FormAttachment (0, 0);
  data.bottom = new FormAttachment (button1, 0, SWT.DEFAULT);
  table0.setLayoutData (data);

  data = new FormData ();
  data.left = new FormAttachment (table0, 0, SWT.CENTER);
  data.top = new FormAttachment (50, -center);
  button1.setLayoutData (data);

  data = new FormData ();
  data.top = new FormAttachment (button1, 0, SWT.DEFAULT);
  data.bottom = new FormAttachment (100, 0);
  table2.setLayoutData (data);

  shell.pack ();
  shell.open ();

  while (!shell.isDisposed ()) {
   if (!display.readAndDispatch ())
    display.sleep ();
  }
  display.dispose ();
 }
}


"Christophe Fondacci" <cfondacci@xxxxxxx> wrote in message 
news:ftvukp$src$1@xxxxxxxxxxxxxxxxxxxx
> Woops, sorry I know how to set the minimal height, but I would still like 
> to know if it is possible for 2 controls to grab excess vertical space and 
> to constrain them with the same height, whatever their content.
> Thanks
>
> "Christophe Fondacci" <cfondacci@xxxxxxx> a écrit dans le message de 
> news:ftvuak$m5i$1@xxxxxxxxxxxxxxxxxxxx
>> Hello all,
>>
>> I have a little problem with SWT.
>> Here it is :
>> - I created 2 tables vertically inside a grid composite, separated by a 
>> button. The idea is to select an item from the top table and to use the 
>> buttons to transfer this item to the bottom table.
>> - I would like those 2 tables to grab excess vertical space, and the 
>> buttons to always keep the minimal required height (which is the default)
>> - Therefore I set the grabExcessVerticalSpace to true for my 2 tables 
>> control
>> - I do not know the content of those tables at compile time, it depends 
>> on what i am editing...
>>
>> The problem is that when, for example, my first table (the one on top) 
>> contains 100 items and the second table is empty, the topmost table takes 
>> the entire vertical space and the bottom table is nearly not visible.
>>
>> I would like those 2 tables to have the same height and to grab the 
>> excess height space. I haven't found any way to do this. At least I would 
>> like to be able to specify a minimal height for both table to guarantee a 
>> minimum visible height for those table controls. Don't know how to do 
>> that either.
>>
>> Could someone help me please ?
>> Thanks,
>> Christophe.
>