Kuix project tracker

#39 TableLayout Error while calculating Table-cell metrics

2009-05-28 01:17  |   Trivial 
Submit by pstefan

State: Opened
Priority: Trivial
Type: Bug
Milestone: -
Release: Kuix 1.1.0
Body:

There is a bug in the LayoutTable.

I've created a table with 3 cols and 3 rows. Each cell contained a TextArea Widget. If the text in the cells is short enough, the table is fully shown on the screen. If a text is too long, it won't be broken into the next line at a space char. Instead the tables width exceeds the size of the screen. The table isn't shown fully on the screen any more.

I've debugged into it and found out that the width of the cell widget is calculated with a preferredSize of the screen width. That means that each cell of my 3 cols can get a width up to the screen width. In the worst case this means that the table can get a width of 3 times of the screen width.

The solution is quite easy. When calculation the widgetMetrics of each cells widget, the preferedWidth-Parameter is changed to 0 instead of width. This solves the problem and all works still fine.

I've added  the patch for this bug at the end of the ticket!

Thx!

 

Index: TableLayout.java
===================================================================
--- TableLayout.java (revision 133)
+++ TableLayout.java (working copy)
@@ -99,7 +99,7 @@
  continue;
  }
 
- Metrics widgetMetrics = widget.getPreferredSize(width);
+ Metrics widgetMetrics = widget.getPreferredSize(0);
  if (first == null) {
  first = current = widgetMetrics;
  } else {