Tk::ResizeButton - provides a resizeable button to be used in an HList column
header.
use Tk;
use Tk::HList;
use Tk::ResizeButton;
my $mw = MainWindow->new();
# CREATE MY HLIST
my $hlist = $mw->Scrolled('HList',
-columns=>2,
-header => 1
)->pack(-side => 'left', -expand => 'yes', -fill => 'both');
# CREATE COLUMN HEADER 0
my $headerstyle = $hlist->ItemStyle('window', -padx => 0, -pady => 0);
my $header0 = $hlist->ResizeButton(
-text => 'Test Name',
-relief => 'flat', -pady => 0,
-command => sub { print "Hello, world!\n";},
-widget => \$hlist,
-column => 0
);
$hlist->header('create', 0,
-itemtype => 'window',
-widget => $header0,
-style=>$headerstyle
);
# CREATE COLUMN HEADER 1
my $header1 = $hlist->ResizeButton(
-text => 'Status',
-relief => 'flat',
-pady => 0,
-command => sub { print "Hello, world!\n";},
-widget => \$hlist,
-column => 1
);
$hlist->header('create', 1,
-itemtype => 'window',
-widget => $header1,
-style =>$headerstyle
);
The ResizeButton widget provides a resizeable button widget for use in an HList
column header. When placed in the column header, the edge of the widget can be
selected and dragged to a new location to change the size of the HList column.
When resizing the column, a column bar will also be placed over the HList
indicating the eventual size of the HList column. A command can also be bound
to the button to do things like sorting the column.
The widget takes all the options that Button does. In addition,
the following options must be specified:
- -widget
- A reference to the HList widget must by provided via the -widget option.
This allows the ResizeButton to update the column width after
resizing.
- -column
- The column number that this ResizeButton is associated with must also be
provided to resize the appropriate column.
Shaun Wandler <wandler@unixmail.compaq.com>
Updated by Slaven Rezic and Frank Herrmann
- position columnbar correctly and only use MoveColumnBar to move it instead
of destroying it and re-creating with CreateColumnBar
- use Subwidget('scrolled') if it exists
- don't give error if -command is not specified
- don't let the user hide columns (minwidth?)