Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TableItem Row resizing
TableItem Row resizing [message #441186] Wed, 11 August 2004 14:58 Go to next message
Eclipse UserFriend
Originally posted by: rohitdev.kulshrestha.patni.com

1. I need to Resize the cell height of
org.eclipse.swt.custom.TableTree.How do i do it?

2. I also need to display Image object in cell of it & be able to resize
the image for it.Can somebody help me out?
Re: TableItem Row resizing [message #441526 is a reply to message #441186] Mon, 16 August 2004 20:23 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Row height is based on the maximum value of either Font height or Image
height (see TableTree.setFont() and TableTreeItem.setImage()). There is no
independant way to set this. On almost all platforms, all rows must have
the same height.

Once an image is set into a Table (or TableTree) all subsequent images are
made the same size and there is no way to change the size of the images.
The size of the first image set in a table determines the height of all
images.

There is a problem in TableTree because as soon as the first TableTreeItem
is added to the TableTree, an image is created for the +/- and this
determines the height of all images that come after. Here is a hack to work
around this:

public static void main (String [] args) {
Display display = new Display ();
Image large = new Image(display,
Main.class.getResourceAsStream("images/image100x100.bmp"));
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
TableTree table = new TableTree(shell, SWT.BORDER);
TableColumn column1 = new TableColumn(table.getTable(), SWT.NONE);
TableColumn column2 = new TableColumn(table.getTable(), SWT.NONE);

//Begin Hack
TableItem bogus = new TableItem(table.getTable(), SWT.NONE);
bogus.setImage(large);
bogus.dispose();
// End Hack

for (int i = 0; i < 10; i++) {
TableTreeItem item = new TableTreeItem(table, SWT.NONE);
item.setText("item "+i);
item.setImage(1, large);
for (int j = 0; j < 3; j++) {
TableTreeItem item2 = new TableTreeItem(item, SWT.NONE);
item2.setText("item "+i+" "+j);
item2.setImage(1, large);
}
}
column1.setWidth(300);
column2.setWidth(200);
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}


"Rohitdev Kulshrestha" <rohitdev.kulshrestha@patni.com> wrote in message
news:cfdc5q$4m7$1@eclipse.org...
> 1. I need to Resize the cell height of
> org.eclipse.swt.custom.TableTree.How do i do it?
>
> 2. I also need to display Image object in cell of it & be able to resize
> the image for it.Can somebody help me out?
>
>
>
Re: TableItem Row resizing [message #441700 is a reply to message #441526] Fri, 20 August 2004 13:50 Go to previous message
Eclipse UserFriend
Originally posted by: rohitdev.kulshrestha.patni.com

Veronika Irvine wrote:

> Row height is based on the maximum value of either Font height or Image
> height (see TableTree.setFont() and TableTreeItem.setImage()). There is no
> independant way to set this. On almost all platforms, all rows must have
> the same height.

> Once an image is set into a Table (or TableTree) all subsequent images are
> made the same size and there is no way to change the size of the images.
> The size of the first image set in a table determines the height of all
> images.

> There is a problem in TableTree because as soon as the first TableTreeItem
> is added to the TableTree, an image is created for the +/- and this
> determines the height of all images that come after. Here is a hack to work
> around this:

> public static void main (String [] args) {
> Display display = new Display ();
> Image large = new Image(display,
> Main.class.getResourceAsStream("images/image100x100.bmp"));
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> TableTree table = new TableTree(shell, SWT.BORDER);
> TableColumn column1 = new TableColumn(table.getTable(), SWT.NONE);
> TableColumn column2 = new TableColumn(table.getTable(), SWT.NONE);

> //Begin Hack
> TableItem bogus = new TableItem(table.getTable(), SWT.NONE);
> bogus.setImage(large);
> bogus.dispose();
> // End Hack

> for (int i = 0; i < 10; i++) {
> TableTreeItem item = new TableTreeItem(table, SWT.NONE);
> item.setText("item "+i);
> item.setImage(1, large);
> for (int j = 0; j < 3; j++) {
> TableTreeItem item2 = new TableTreeItem(item, SWT.NONE);
> item2.setText("item "+i+" "+j);
> item2.setImage(1, large);
> }
> }
> column1.setWidth(300);
> column2.setWidth(200);
> shell.pack();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }


> "Rohitdev Kulshrestha" <rohitdev.kulshrestha@patni.com> wrote in message
> news:cfdc5q$4m7$1@eclipse.org...
> > 1. I need to Resize the cell height of
> > org.eclipse.swt.custom.TableTree.How do i do it?
> >
> > 2. I also need to display Image object in cell of it & be able to resize
> > the image for it.Can somebody help me out?
> >
> >
> >


I have tried out the code/hack youi suggested.But it did not seem to help.
Although the image was bigger then what i was getting previously.
So how do i progress ahead.
Do i need to write a new swidget ?
Also should future implementations of Tabletree should not have such
restrictions as it binds itself to firm restrictions & does not server the
purpose.

I request the SWT community members to please take it as a contructive
view for future implementaions.
Previous Topic:OS X Bug? MouseListener behaving incorrectly on Button
Next Topic:Scroll bar in shell
Goto Forum:
  


Current Time: Sat Apr 20 00:34:11 GMT 2024

Powered by FUDForum. Page generated in 0.02942 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top