aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2002-11-18 16:36:53 +0000
committermertz2002-11-18 16:36:53 +0000
commitd953c1777587adf946a07d505c9f5d52325a0c1d (patch)
treeee243ad2a404e7df927585b6e1ef7fa29e3d6dca
parente64b19fded508cab4da6d48d10f3ec32f3540871 (diff)
downloadtkzinc-d953c1777587adf946a07d505c9f5d52325a0c1d.zip
tkzinc-d953c1777587adf946a07d505c9f5d52325a0c1d.tar.gz
tkzinc-d953c1777587adf946a07d505c9f5d52325a0c1d.tar.bz2
tkzinc-d953c1777587adf946a07d505c9f5d52325a0c1d.tar.xz
ajout de la methode de compatibilit� coords0 pour remplacer la m�thode coords
dans les vieilles applications.
-rw-r--r--Perl/Zinc.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/Perl/Zinc.pm b/Perl/Zinc.pm
index 1bd3fc1..2161e12 100644
--- a/Perl/Zinc.pm
+++ b/Perl/Zinc.pm
@@ -7,6 +7,7 @@ package Tk::Zinc;
use Tk;
#use AutoLoader;
#use Exporter;
+use Carp;
use base qw(Tk::Widget);
Construct Tk::Widget 'Zinc';
@@ -47,6 +48,52 @@ Tk::Methods("add", "addtag", "anchorxy", "bbox", "becomes", "bind", "cget",
"select", "smooth", "tapply", "tdelete", "transform", "translate",
"treset", "trestore", "tsave", "type", "vertexat");
+## coord0 is a compatibility function usefull for porting old application
+## previously running with Tk::Zinc V <= 3.2.6a
+## The Zinc methode coords0 can/should replace coords as long as no control points are
+## used in curve or rectangle or an arc...
+## This can dramaticaly simplify the port of an old application from Zinc V<3.2.6a to
+## a newer version of Zinc. HOWEVER YOU STILL MUST CHANGE THE CODE OF THIS OLD APPICATION
+##
+## Remember: the incompatible change in Zinc is due to the introduction of
+## control points in curves (and a future release, in arc or rectangle items...)
+sub coords0 {
+ if (wantarray) {
+ ## we are in list context, so we should convert the returned value
+ ## to match the specification of Zinc Version <= 3.2.6a
+ my @res = &Tk::Zinc::coords(@_);
+ if ( !ref $res[0] ) {
+ ## The first item of the list is not a reference, so the
+ ## list is guarranted to be a flat list (x, y, x, y, ... x, y)
+ return @res;
+ }
+ else {
+ ## The list is a list of references like : [x y] or [x y symbol]
+ ## In the latter case, coord0 should warn that there is a control point!
+ ## coord0 will return a flatten list of (x, y, ... x , y)
+ my @res0;
+ foreach my $ref (@res) {
+ my @array = ${$ref};
+ if ($#array > 1) {
+ my $item = $_[1];
+ my $zinc = $_[0];
+ my $type = $zinc->type($item);
+ carp "Using Zinc coord0 compatibility method with item $item (type=$type) which contains a control point: @array";
+ }
+ push @res0, $array[0];
+ push @res0, $array[1];
+ }
+ return @res0;
+ }
+ }
+ else {
+ ## contexte scalaire
+ ## le résultats n'étais pas utilisés jusqu'à présent, vu le bug...
+ ## donc inutile de le convertir!
+ return &Tk::Zinc::coords(@_);
+ }
+}
+
1;
__END__