The question is short. is there a good way to set the columnwidth of a
FXTable object relativ to it’s content?.
what i’m doing at the moment and which i think is rather ugly is:
table.setColumnWidht(3,(table.getItemText(3,3).to_s.size * 7)
i’d expect something to autoresize columns based on their content, but i
haven’t found yet. is there non, or am i to blind?
thanks in advance
Matthias
···
–
/"
\ /
X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
/ \
Matthias Wieding-Drewes wrote:
The question is short. Is there a good way to set the column width of a
FXTable object relative to its content?
No, there is no way to automatically resize a column based on the
width of the “widest” item’s content width. The code that does the
resizing would look something like this:
def resizeColumn(col)
maxWidth = 0
0.upto(numRows - 1) { |row|
itemWidth = getItem(row, col).getWidth(self)
maxWidth = (itemWidth > maxWidth) ? itemWidth : maxWidth
}
setColumnWidth(col, maxWidth)
end
If you are interested in this being added to FXTable, be sure to request
it from Jeroen (FOX’s author).
Hope this helps,
Lyle
Matthias Wieding-Drewes wrote:
The question is short. Is there a good way to set the column width of a
FXTable object relative to its content?
No, there is no way to automatically resize a column based on the
width of the “widest” item’s content width. The code that does the
resizing would look something like this:
def resizeColumn(col)
maxWidth = 0
0.upto(numRows - 1) { |row|
itemWidth = getItem(row, col).getWidth(self)
maxWidth = (itemWidth > maxWidth) ? itemWidth : maxWidth
}
setColumnWidth(col, maxWidth)
end
If you are interested in this being added to FXTable, be sure to request
it from Jeroen (FOX’s author).
Hope this helps,
As of FOX 1.1.23 there is such functionality in FXTable:
FXTable has two new API’s, getMinRowHeight() and getMinColumnwidth() which
compute the minimum height or width of a row or column in the table based on
the contents of the items; this substantially simplifies setting up a
sensible initial table display.
FXTableItem’s getHeight() and getWidth() now yield sensible values; your
subclass of FXTableItem should overload them if the size computation needs to
be different.
Ofcourse you can’t use it since FXRuby uses the stable tree…
Sander
···
On Thursday 27 February 2003 02:41 pm, Lyle Johnson wrote:
Lyle
–
“All I ask is a tall ship, and a load of contraband to fill her with…”
– Quark