home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Rect.pm < prev    next >
Encoding:
Perl POD Document  |  2003-12-14  |  1.4 KB  |  81 lines

  1. package Tk::DragDrop::Rect;
  2. use Carp;
  3.  
  4. # Proxy class which represents sites to the dropping side
  5.  
  6. use vars qw($VERSION);
  7. $VERSION = sprintf '4.%03d', q$Revision: #6 $ =~ /\D(\d+)\s*$/;
  8.  
  9. sub Over
  10. {
  11.  my ($site,$X,$Y) = @_;
  12.  my $x = $site->X;
  13.  my $y = $site->Y;
  14.  my $w = $site->width;
  15.  my $h = $site->height;
  16.  
  17.  my $val = ($X >= $x && $X < ($x + $w) && $Y >= $y && $Y < ($y + $h));
  18.  # print "Over ",$site->Show," $X,$Y => $val\n";
  19.  return $val;
  20. }
  21.  
  22. sub FindSite
  23. {
  24.  my ($class,$widget,$X,$Y) = @_;
  25.  foreach my $site ($class->SiteList($widget))
  26.   {
  27.    return $site if ($site->Over($X,$Y));
  28.   }
  29.  return undef;
  30. }
  31.  
  32. sub NewDrag
  33. {
  34.  my ($class,$widget) = @_;
  35. }
  36.  
  37. sub Match
  38. {
  39.  my ($site,$other) = @_;
  40.  return 0 unless (defined $other);
  41.  return 1 if ($site == $other);
  42.  return 0 unless (ref($site) eq ref($other));
  43.  for ("$site")
  44.   {
  45.    if (/ARRAY/)
  46.     {
  47.      my $i;
  48.      return 0 unless (@$site == @$other);
  49.      for ($i = 0; $i < @$site; $i++)
  50.       {
  51.        return 0 unless ($site->[$i] == $other->[$i]);
  52.       }
  53.      return 1;
  54.     }
  55.    elsif (/SCALAR/)
  56.     {
  57.      return $site == $other;
  58.     }
  59.    elsif (/HASH/)
  60.     {
  61.      my $key;
  62.      foreach $key (keys %$site)
  63.       {
  64.        return 0 unless exists $other->{$key};
  65.        return 0 unless ($other->{$key} eq $site->{$key});
  66.       }
  67.      foreach $key (keys %$other)
  68.       {
  69.        return 0 unless exists $site->{$key};
  70.        return 0 unless ($other->{$key} eq $site->{$key});
  71.       }
  72.      return 1;
  73.     }
  74.    return 0;
  75.   }
  76.  return 0;
  77. }
  78.  
  79.  
  80. 1;
  81.