[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: SWT.EraseItem draw event

Hi Aristide,

Specifying the width does not change anything for you because your table has
columns, and it's the column widths that determine the widths of their
cells.  To change your column width you should use
TableColumn.setWidth(300), or alternatively pack() the column (if you do
this then the width from your MeasureItem callbacks will be used to
determine the column's new size).

Grant


"Aristide Lecomte" <spam@xxxxxxxx> wrote in message
news:el44oo$od4$1@xxxxxxxxxxxxxxxxxxxx
> Hi all,
>
>   I use Eclipse 3.2.1
>   I am creating a view (for a plugin) wich contains a table. As I want
> to customize the table I use the SWT.EraseItem draw event where I change
> the cell size. If the change of the heigth works the change of the width
> does not. Is it a bug or have I done something wrong ?
>
> public void createPartControl(Composite parent) {
>     Display display = parent.getDisplay();
>
>     final Table table = new Table(parent, SWT.NONE);
>     table.setBounds(10, 10, 150, 200);
>     table.setLinesVisible(true);
>
>     final TableColumn column0 = new TableColumn(table, SWT.NONE);
> column0.setWidth(100);
>     final TableColumn column1 = new TableColumn(table, SWT.NONE);
> column1.setWidth(100);
>     for (int i = 0; i < 5; i++) {
>        TableItem item = new TableItem(table, SWT.NONE);
>        item.setText(0, "item " + i + " col 0");
>        item.setText(1, "item " + i + " col 1");
>     }
>
>     final Color red = display.getSystemColor(SWT.COLOR_RED);
>     final Color yellow = display.getSystemColor(SWT.COLOR_YELLOW);
>
>     table.addListener(SWT.MeasureItem, new Listener() {
>        public void handleEvent(Event event) {
>
>           int clientWidth = table.getClientArea().width;
> event.height = 100; // works
> event.width = 300; // does not work !!!????
>
>        }
>     });
> }