[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: How to set the row height in a Table?
|
Different row heights works fine on Linux. I'm quite sure that I've seen
it on Windows as well.
Try modifying SWT Snippet 271 [1] to set the height to different values.
ackage org.eclipse.swt.snippets;
/*
* Table snippet: specify custom content dimensions in a table with no
columns
*
* For a detailed explanation of this snippet see
*
http://www.eclipse.org/articles/Article-CustomDrawingTableAndTreeItems/customDraw.htm#_example1
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*
* @since 3.2
*/
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class Snippet271 {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,250);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10,10,150,200);
table.setLinesVisible(true);
for (int i = 0; i < 5; i++) {
TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setData(i);
tableItem.setText("item " + i);
}
/*
* NOTE: MeasureItem is called repeatedly. Therefore it is critical
* for performance that this method be as efficient as possible.
*/
table.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
int clientWidth = table.getClientArea().width;
event.height = (Integer)(event.item.getData()) * 10;
event.width = clientWidth * 2;
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
HTH,
Wayne
[1]http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet271.java?view=co
On Mon, 2008-06-16 at 07:46 +0200, Viliam Durina wrote:
> As far as I know, even custom drawn tables don't support multiple rows having different heights (at least on Windows). You'd have to custom draw the entire control (e.g. extend Canvas)... I'd be interested if setting the height for every row is possible with standard table...
>
> Viliam
>
> jeffty wrote / napÃsal(a):
> > Thank you!
> > Tom Schindl wrote:
> >> Not supported you need to switch to a custom drawn table/tree.
> >>
> >> Tom
> >>
> >> jeffty schrieb:
> >>> Hi,
> >>> I try but fail to find the API to set the row height of a Table.
> >>> The only way I know is:
> >>> table.addListener(SWT.MeasureItem, new Listener() {
> >>> public void handleEvent(Event event) {
> >>> event.height =rowHeight;
> >>> }
> >>> });
> >>>
> >>> And which set the height of all the rows. How to set the height
> >>> for every row?
> >>> Thanks in advance!
> >>
> >>