Joel VanderWerf
2007-May-20 01:02 UTC
[fxruby-users] a table column that fills horizontally
Is there a way to specify that a table column should resize itself to fill available space, so that it is just big enough that there is no unused space in the table, but there is no horizontal scroll bar? That might be too special a situation for FXTable in general to handle, but anyway here''s a way to do it (tested a little). The +fill+ variable is the column number of the column that should adjust its width. fill_resizer = proc do other_width = table.verticalScrollBar.width + table.rowHeaderWidth + (0...columns.size).inject(0){|sum,c| sum + (c == fill ? 0 : table.getColumnWidth(c))} table.setColumnWidth fill, table.width - other_width - 1 false end table.connect(SEL_CONFIGURE, &fill_resizer) table.columnHeader.connect(SEL_CHANGED, &fill_resizer) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
On 5/19/07, Joel VanderWerf <vjoel at path.berkeley.edu> wrote:> Is there a way to specify that a table column should resize itself to > fill available space, so that it is just big enough that there is no > unused space in the table, but there is no horizontal scroll bar?No, nothing like that built in.> That might be too special a situation for FXTable in general to handle, > but anyway here''s a way to do it (tested a little). The +fill+ variable > is the column number of the column that should adjust its width.<snip> Looks good!
Joel VanderWerf
2007-May-20 23:03 UTC
[fxruby-users] a table column that fills horizontally
Joel VanderWerf wrote:> Is there a way to specify that a table column should resize itself to > fill available space, so that it is just big enough that there is no > unused space in the table, but there is no horizontal scroll bar? > > That might be too special a situation for FXTable in general to handle, > but anyway here''s a way to do it (tested a little). The +fill+ variable > is the column number of the column that should adjust its width. > > fill_resizer = proc do > other_width = table.verticalScrollBar.width + > table.rowHeaderWidth + > (0...columns.size).inject(0){|sum,c| sum + > (c == fill ? 0 : table.getColumnWidth(c))} > table.setColumnWidth fill, table.width - other_width - 1 > false > end > table.connect(SEL_CONFIGURE, &fill_resizer) > table.columnHeader.connect(SEL_CHANGED, &fill_resizer) >This is a slight improvement that is sensitive to whether the scroll bar is shown: fill_resizer = proc do other_width = table.rowHeaderWidth + (0...columns.size).inject(0){|sum,c| sum + (c == fill ? 0 : table.getColumnWidth(c))} vsb = table.verticalScrollBar other_width += vsb.width if vsb.shown? table.setColumnWidth fill, table.width - other_width - 1 false end table.connect(SEL_CONFIGURE, &fill_resizer) table.columnHeader.connect(SEL_CHANGED, &fill_resizer) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407