Subject: | A better way to handle the -lastcolumn option |
One thing that's annoyed me in the past with HList is the last column.
HList stretches the last column's header to fill in the remainder of the
space within the widget. It's annoying because the list entries for that
final column are not likewise stretched.
A way I've worked around this is to add an additional column that I do
not intend to use. No header button, no data in the column, nada. The
resulting effect looks like similar Win32 controls. The problem is that
now there is this faux header up there and suddenly you'd like to be
able to resize that penultimate column, but can't because it's the
ResizeHeaderButton, but not the last column.
I think your header method is slightly flawed in how it uses the
-lastcolumn option you've setup. One possible fix would be to replace
the following block (on or around line 362):
# Create a new Resize Button
my $header = $this->HeaderResizeButton(%args,
-column => $column,
-lastcolumn => $column
-highlightthickness => 0,
);
To this:
# Create a new Resize Button
my $lastCol = 0;
$lastCol = 1 if $this->cget(-columns) == ($column + 1);
my $header = $this->HeaderResizeButton(%args,
-column => $column,
-lastcolumn => $lastCol,
-highlightthickness => 0,
);
When you do this, you no longer need the following lines:
# remove the last column-flag in the row
# before to allow drawing the bar
if ($column > 0) {
my $lastcolumn = $this->{m_headerwidget}{$column - 1};
$lastcolumn->configure(-lastcolumn => 0);
}
Because it's handled for each header as you create it. -columns is
a static attribute for HList and can not be changed after the HList
has been created so it's safe to use.
Try it out yourself, but creating an additional column in
whatver test code you may have for the widget.
Regards,
Rob Seegel