Subject: | Various patches |
Hello Frank,
attached is a patch to ResizeButton which solves some of the remaining
problems.
Regards,
Slaven
Subject: | resizebutton001.patch |
#
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# If you have a decent Bourne-type shell:
# STEP 2: Run the shell with this file as input.
# If you don't have such a shell, you may need to manually create
# the files as shown below.
# STEP 3: Run the 'patch' program with this file as input.
#
# These are the commands needed to create/delete files/directories:
#
touch 'Changes'
chmod 0660 'Changes'
#
# This command terminates the shell and need not be executed manually.
exit
#
#### End of Preamble ####
#### Patch data follows ####
diff -up /dev/null 'Changes'
Index: ./Changes
*** ./Changes Thu Jan 1 01:00:00 1970
--- ./Changes Sat Nov 11 15:21:10 2006
***************
*** 0 ****
--- 1,12 ----
+ History for Tk::ResizeButton
+
+ version 0.02
+ o use Subwidget('scrolled') if it exists (-widget is now set with a
+ METHOD)
+ o position columnbar correctly and only use PlaceColumnBar to move it
+ instead of destroying it and re-creating with CreateColumnBar
+ o now with $VERSION for CPAN
+ o all CreateColumnBar calls are now method calls
+
+ version 0.01
+ o CPAN release by XPIX
diff -up '../../build/Tk-ResizeButton-0.01/MANIFEST' 'MANIFEST'
Index: ./MANIFEST
--- ./MANIFEST Thu Apr 17 16:35:18 2003
+++ ./MANIFEST Sat Nov 11 15:18:26 2006
@@ -4,3 +4,4 @@ README
ResizeButton.pm
demos/test.pl
t/00_test.t
+Changes
diff -up '../../build/Tk-ResizeButton-0.01/Makefile.PL' 'Makefile.PL'
Index: ./Makefile.PL
--- ./Makefile.PL Thu Apr 17 16:23:20 2003
+++ ./Makefile.PL Sat Nov 11 15:21:44 2006
@@ -3,7 +3,7 @@ use ExtUtils::MakeMaker;
WriteMakefile (
'NAME' => 'Tk::ResizeButton',
'DISTNAME' => 'Tk-ResizeButton',
- 'VERSION' => '0.01',
+ 'VERSION' => '0.02',
'AUTHOR' => 'Frank Herrmann <xpix@netzwert.ag>',
'PREREQ_PM' => { 'Tk' => 0 },
diff -up '../../build/Tk-ResizeButton-0.01/ResizeButton.pm' 'ResizeButton.pm'
Index: ./ResizeButton.pm
--- ./ResizeButton.pm Thu Apr 17 16:17:21 2003
+++ ./ResizeButton.pm Sat Nov 11 15:16:00 2006
@@ -11,6 +11,8 @@ $Revision =~ s/^\$\S+:\s*(.*?)\s*\$$/
$CheckinDate =~ s/^\$\S+:\s*(.*?)\s*\$$/$1/sx;
$CheckinUser =~ s/^\$\S+:\s*(.*?)\s*\$$/$1/sx;
+our $VERSION = '0.01';
+
#-------------------------------------------------
#-- package Tk::ResizeButton ---------------------
#-------------------------------------------------
@@ -101,12 +103,9 @@ B<Shaun Wandler> <wandler@unixmail.compa
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
+=head1 TODO
-=item use Subwidget('scrolled') if it exists
+=over 4
=item don't give error if -command is not specified
@@ -134,13 +133,6 @@ Tk::HList
# 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';
@@ -183,7 +175,7 @@ sub Populate {
$this->SUPER::Populate($args);
$this->ConfigSpecs(
- -widget => [ [ 'SELF', 'PASSIVE' ], 'Widget', 'Widget', undef ],
+ -widget => [ [ 'SELF', 'METHOD' ], 'Widget', 'Widget', undef ],
-column => [ [ 'SELF', 'PASSIVE' ], 'Column', 'Column', 0 ],
-minwidth => [ [ 'SELF', 'PASSIVE' ], 'minWidth', 'minWidth', 50 ],
);
@@ -192,6 +184,20 @@ sub Populate {
$this->{'m_LastTrim'} = $l_Widget;
}
+sub widget {
+ my $this = shift;
+ if (@_) {
+ my $widget = $_[0];
+ my $scrolled = $$widget->Subwidget("scrolled");
+ if (Tk::Exists($scrolled)) {
+ $this->{Configure}{'-widget'} = \$scrolled;
+ } else {
+ $this->{Configure}{'-widget'} = $widget;
+ }
+ }
+ $this->{Configure}{'-widget'};
+}
+
sub ButtonPress {
my ( $this, $p_Trim ) = ( shift, @_ );
@@ -199,7 +205,7 @@ sub ButtonPress {
if ( $this->ButtonEdgeSelected() || $p_Trim ) {
$this->{'m_EdgeSelected'} = 1;
$this->{m_X} = $this->pointerx() - $this->rootx();
- CreateColumnBar($this);
+ $this->CreateColumnBar;
} else {
$this->configure( -relief => 'sunken' );
$this->{m_X} = -1;
@@ -219,7 +225,7 @@ sub ButtonRelease {
if ( $this->{m_X} >= 0 ) {
my $l_NewWidth = ( $this->pointerx() - $this->rootx() );
- my $hlist = $this->cget( -widget );
+ my $hlist = $this->cget('-widget');
my $col = $this->cget( -column );
$$hlist->columnWidth( $col, $l_NewWidth + 5 )
if(($l_NewWidth + 5) > $this->cget( -minwidth ));
@@ -245,11 +251,9 @@ sub ButtonEdgeSelected {
sub ButtonOver {
my ( $this, $p_Trim ) = @_;
my ($cursor);
- my $hlist = $this->cget( -widget );
if ( $this->{'m_EdgeSelected'} || $this->ButtonEdgeSelected() || $p_Trim ) {
if ( $this->{columnBar} ) {
- $this->{columnBar}->destroy;
- CreateColumnBar($this);
+ $this->PlaceColumnBar(100);
}
$cursor = 'sb_h_double_arrow';
} else {
@@ -263,26 +267,30 @@ sub ButtonOver {
sub CreateColumnBar {
my ($this) = @_;
- my $hlist = $this->cget( -widget );
+ my $hlist = $this->cget('-widget');
my $height = $$hlist->height() - $this->height();
- my $x = $$hlist->pointerx() - $$hlist->rootx();
+ my $x = $this->rootx + $this->width - $$hlist->rootx;
-# my $x = $this->rootx + $this->width - $$hlist->rootx;
$this->{columnBar} = $$hlist->Frame(
-background => 'white',
-relief => 'raised',
-borderwidth => 2,
-width => 2,
);
+ $this->{columnBarHeight} = $height;
+ $this->{columnBarDeltaX} = $$hlist->pointerx - $x;
-#FIXFIX: Some fudge factors were used here to place the column
-# bar at the correct place. It appears that hlist->rootx is
-# relative to the scrollbar, while when placing the columnbar
-# the x location is relative to hlist widget. This definitely
-# doesn't work when using a non-scrolled hlist.
+ $this->PlaceColumnBar;
+}
+
+sub PlaceColumnBar {
+ my ($this) = @_;
+
+ my $hlist = $this->cget('-widget');
+ my $x = $$hlist->pointerx - $this->{columnBarDeltaX};
$this->{columnBar}->place(
'-x' => $x,
- '-height' => $height - 5,
+ '-height' => $this->{columnBarHeight} - 5,
'-relx' => 0.0,
'-rely' => 0.0,
'-y' => $this->height() + 5,
diff -up '../../build/Tk-ResizeButton-0.01/demos/test.pl' 'demos/test.pl'
Index: ./demos/test.pl
--- ./demos/test.pl Thu Apr 17 16:27:37 2003
+++ ./demos/test.pl Sat Nov 11 15:19:58 2006
@@ -1,19 +1,21 @@
#!perl
use strict;
-use lib '/Homes/xpix/projekts/Tk-Moduls',
- 'X:\projekts\Tk-Moduls';
+use FindBin;
+use blib "$FindBin::RealBin/..";
use Tk;
use Tk::HList;
use Tk::ResizeButton;
+ use Tk::ItemStyle;
my $mw = MainWindow->new();
# CREATE MY HLIST
my $hlist = $mw->Scrolled('HList',
- -columns=>2,
- -header => 1
+ -columns=>3,
+ -header => 1,
+ -scrollbars => "sw",
)->pack(-side => 'left', -expand => 'yes', -fill => 'both');
# CREATE COLUMN HEADER 0
@@ -43,6 +45,21 @@ use lib '/Homes/xpix/projekts/Tk-Moduls'
$hlist->header('create', 1,
-itemtype => 'window',
-widget => $header1,
+ -style =>$headerstyle
+ );
+
+ # CREATE COLUMN HEADER 2
+ my $header2 = $hlist->ResizeButton(
+ -text => 'Status 2',
+ -relief => 'flat',
+ -pady => 0,
+ -command => sub { print "Hello, world!\n";},
+ -widget => \$hlist,
+ -column => 2
+ );
+ $hlist->header('create', 2,
+ -itemtype => 'window',
+ -widget => $header2,
-style =>$headerstyle
);
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Sat Nov 11 15:21:57 2006
# Generated by : makepatch 2.03
# Recurse directories : Yes
# Excluded files : (\A|/).*\~\Z
# (\A|/).*\.a\Z
# (\A|/).*\.bak\Z
# (\A|/).*\.BAK\Z
# (\A|/).*\.elc\Z
# (\A|/).*\.exe\Z
# (\A|/).*\.gz\Z
# (\A|/).*\.ln\Z
# (\A|/).*\.o\Z
# (\A|/).*\.obj\Z
# (\A|/).*\.olb\Z
# (\A|/).*\.old\Z
# (\A|/).*\.orig\Z
# (\A|/).*\.rej\Z
# (\A|/).*\.so\Z
# (\A|/).*\.Z\Z
# (\A|/)\.del\-.*\Z
# (\A|/)\.make\.state\Z
# (\A|/)\.nse_depinfo\Z
# (\A|/)core\Z
# (\A|/)tags\Z
# (\A|/)TAGS\Z
# c 'Changes' 0 1163254870 0100660
# p 'MANIFEST' 91 1163254706 0100640
# p 'Makefile.PL' 277 1163254904 0100751
# p 'ResizeButton.pm' 8317 1163254560 0100775
# p 'demos/test.pl' 1254 1163254798 0100751
#### End of ApplyPatch data ####
#### End of Patch kit [created: Sat Nov 11 15:21:57 2006] ####
#### Patch checksum: 274 8751 23856 ####
#### Checksum: 304 9748 42122 ####