Tk-ResizeButton
view release on metacpan or search on metacpan
ResizeButton.pm view on Meta::CPAN
A reference to the HList widget must by provided via the -widget
option. This allows the ResizeButton to update the column width
after resizing.
=item B<-column>
The column number that this ResizeButton is associated with must
also be provided to resize the appropriate column.
=back
=head1 AUTHOR
B<Shaun Wandler> <wandler@unixmail.compaq.com>
=head1 UPDATES
Updated by Slaven Rezic and Frank Herrmann
=over 4
=item position columnbar correctly and only use MoveColumnBar to move it instead
of destroying it and re-creating with CreateColumnBar
=item use Subwidget('scrolled') if it exists
=item don't give error if -command is not specified
=item don't let the user hide columns (minwidth?)
=back
=head1 KEYWORDS
Tk::HList
=cut
#########################################################################
# Tk::ResizeButton
# Summary: This widget creates a button for use in an HList header which
# provides methods for resizing a column. This was heavily
# leveraged from Columns.pm by Damion Wilson.
# Author: Shaun Wandler
# Date: $Date: 2003/02/17 16:46:54 $
# Revision: $Revision: 1.3 $
#########################################################################=
#####
#
# Updated by Slaven Rezic and Frank Herrmann
#
# XXX needs lot of work:
# * 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?)
use base qw(Tk::Derived Tk::Button);
Construct Tk::Widget 'ResizeButton';
sub ClassInit {
my ( $class, $mw ) = @_;
$class->SUPER::ClassInit($mw);
$mw->bind( $class, '<ButtonRelease-1>', 'ButtonRelease' );
$mw->bind( $class, '<ButtonPress-1>', 'ButtonPress' );
$mw->bind( $class, '<Motion>', 'ButtonOver' );
return $class;
}
sub Populate {
my ( $this, $args ) = @_;
# CREATE THE RESIZE CONTROLS
my $l_Widget;
for ( my $i = 0 ; $i < 2 ; ++$i ) {
$l_Widget = $this->Component(
'Frame' => 'Trim_' . $i,
-background => 'white',
-relief => 'raised',
-borderwidth => 2,
-width => 2,
)->place(
'-x' => -( $i * 3 + 2 ),
'-relheight' => 1.0,
'-anchor' => 'ne',
'-height' => -4,
'-relx' => 1.0,
'-y' => 2,
);
}
$l_Widget->bind( '<ButtonRelease-1>' => sub { $this->ButtonRelease(1); } );
$l_Widget->bind( '<ButtonPress-1>' => sub { $this->ButtonPress(1); } );
$l_Widget->bind( '<Motion>' => sub { $this->ButtonOver(1); } );
$this->SUPER::Populate($args);
$this->ConfigSpecs(
-widget => [ [ 'SELF', 'PASSIVE' ], 'Widget', 'Widget', undef ],
-column => [ [ 'SELF', 'PASSIVE' ], 'Column', 'Column', 0 ],
-minwidth => [ [ 'SELF', 'PASSIVE' ], 'minWidth', 'minWidth', 50 ],
);
# Keep track of last trim widget
$this->{'m_LastTrim'} = $l_Widget;
}
sub ButtonPress {
my ( $this, $p_Trim ) = ( shift, @_ );
$this->{'m_relief'} = $this->cget( -relief );
if ( $this->ButtonEdgeSelected() || $p_Trim ) {
$this->{'m_EdgeSelected'} = 1;
$this->{m_X} = $this->pointerx() - $this->rootx();
CreateColumnBar($this);
} else {
$this->configure( -relief => 'sunken' );
( run in 2.306 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )