require Tk
::DragDrop
::Common
;
require Tk
::DragDrop
::Rect
;
$VERSION = '3.021'; # $Id: //depot/Tk8/DragDrop/DropSite.pm#21 $
use base qw(Tk::DragDrop::Common Tk::DragDrop::Rect);
Construct Tk
::Widget
'DropSite';
use vars
qw(%type @types);
Tk::DragDrop->Tk::DragDrop::Common::Type('Local');
# Are these really methods of Tk::DragDrop::Rect ?
foreach my $name (qw(x y X Y width height widget))
*{"$key"} = sub { shift->{$key} };
# Dropping side API - really only here for Local drops
# inheritance is a mess right now.
# No need to clear cached sites we see live data
# this should be inheritable - so that receive side of XDND can re-use it.
my ($class,$widget) = @_;
my $sites = $t->{'DropSites'};
$sites = $sites->{'Local'};
push(@list,@
{$sites}) if ($sites);
$cb->Call(@_,$X - $site->X, $Y - $site->Y);
my ($site,$token,$seln,$event) = @_;
$site->Apply(-dropcommand
=> $X, $Y, $seln);
$site->Apply(-entercommand
=> $X, $Y, 0);
my ($site,$token,$event) = @_;
$site->Apply(-entercommand
=> $event->X, $event->Y, 1);
my ($site,$token,$event) = @_;
$site->Apply(-entercommand
=> $event->X, $event->Y, 0);
my ($site,$token,$event) = @_;
$site->Apply(-motioncommand
=> $event->X, $event->Y);
# This is receive side API.
my ($class,$t,$sites) = @_;
unless (grep($_ == $t,@toplevels))
$Tk::DragDrop
::types
{'Local'} = $class if (@
$sites);
$t->OnDestroy(sub { @toplevels = grep($_ != $t,@toplevels) });
foreach my $type (@types)
my $sites = $t->{'DropSites'}->{$type};
my $class = $type{$type};
$class->NoteSites($t,$sites);
my $t = $obj->widget->toplevel;
unless ($t->{'DropUpdate'})
$t->afterIdle(sub { UpdateDropSites
($t) });
$w->bindtags([grep($_ ne $obj,$w->bindtags)]);
foreach my $type (@
{$obj->{'-droptypes'}})
my $a = $t->{'DropSites'}->{$type};
@
$a = grep($_ ne $obj,@
$a);
$obj->QueueDropSiteUpdate;
# Note size of widget and arrange to update properties etc.
$obj->{'width'} = $w->Width;
$obj->{'height'} = $w->Height;
$obj->QueueDropSiteUpdate;
foreach my $type (@types)
my $sites = $t->{'DropSites'}->{$type};
$cb->Call(@_) if (defined $cb);
# Tk::DragDrop->Type('Local');
my ($class,$w,%args) = @_;
if (exists $args{'-droptypes'})
# Convert single type to array-of-one
$args{'-droptypes'} = [$args{'-droptypes'}] unless (ref $args{'-droptypes'});
# Default to all known types.
$args{'-droptypes'} = \
@types;
while (($key,$val) = each %args)
$val = Tk
::Callback
->new($val);
my $obj = bless \
%args,$class;
unless (exists $t->{'DropSites'})
foreach $type (@
{$args{'-droptypes'}})
Tk
::DropSite
->import($type) unless (exists $type{$type});
my $class = $type{$type};
# Should this be indexed by type or class ?
unless (exists $t->{'DropSites'}->{$type})
$t->{'DropSites'}->{$type} = [];
push(@
{$t->{'DropSites'}->{$type}},$obj);
$w->OnDestroy([$obj,'delete']);
$w->bindtags([$w->bindtags,$obj]);
$w->Tk::bind($obj,'<Map>',[$obj,'DropSiteUpdate']);
$w->Tk::bind($obj,'<Unmap>',[$obj,'DropSiteUpdate']);
$t->Tk::bind($class,'<Configure>',[\
&TopSiteUpdate
,$t]);
unless (grep($_ eq $class,$t->bindtags))
$t->bindtags([$t->bindtags,$class]);