From: Sander Jansen Date: 2003-02-28T09:36:03+09:00 Subject: Re: FXRuby FXTable columnwidth by content? On Thursday 27 February 2003 02:41 pm, Lyle Johnson wrote: > 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 > > Lyle -- "All I ask is a tall ship, and a load of contraband to fill her with..." -- Quark