package Tk
::DragDrop
::SunDrop
;
require Tk
::DragDrop
::Rect
;
$VERSION = '3.015'; # $Id: //depot/Tk8/DragDrop/DragDrop/SunDrop.pm#15 $
use base qw(Tk::DragDrop::Rect);
use Tk
::DragDrop
::SunConst
;
Tk
::DragDrop
->Type('Sun');
my @fields = qw(name win X Y width height flags);
for ($i=0; $i < @fields; $i++)
*{"$fields[$i]"} = sub { shift->[$j] };
my ($site,$token,$e,$kind,$flags) = (@_);
$token->BackTrace('No flags') unless defined $flags;
my $sflags = $site->flags;
return if ($kind == _motion
&& !($sflags & MOTION
));
return if ($kind != _motion
&& !($sflags & ENTERLEAVE
));
my $data = pack('LLSSLL',$kind,$e->t,$e->X,$e->Y,$site->name,$flags);
$token->SendClientMessage('_SUN_DRAGDROP_PREVIEW',$site->win,32,$data);
my ($site,$token,$e) = @_;
$site->Preview($token,$e,_enter
,0);
my ($site,$token,$e) = @_;
$site->Preview($token,$e,_leave
,0);
my ($site,$token,$e) = @_;
$site->Preview($token,$e,_motion
,0);
my ($token,$seln,$offset,$max) = @_;
my ($w,$seln,$offset,$max) = @_;
my ($w,$seln,$offset,$max) = @_;
my ($w,$seln,$offset,$max) = @_;
my ($site,$token,$seln,$e) = @_;
$w->SelectionHandle('-selection'=>$seln,'-type'=>'_SUN_DRAGDROP_ACK',[\
&HandleAck
,$token,$seln]);
$w->SelectionHandle('-selection'=>$seln,'-type'=>'_SUN_DRAGDROP_DONE',[\
&HandleDone
,$token,$seln]);
my $atom = $w->InternAtom($seln);
my $flags = ACK_FLAG
| TRANSIENT_FLAG
;
my $data = pack('LLSSLL',$atom,$e->t,$e->X,$e->Y,$site->name,$flags);
$w->SendClientMessage('_SUN_DRAGDROP_TRIGGER',$site->win,32,$data);
my ($class,$token,$X,$Y) = @_;
$token->{'SunDD'} = [] unless exists $token->{'SunDD'};
my $site = $class->SUPER::FindSite
($token,$X,$Y);
my $id = $token->PointToWindow($X,$Y);
Tk
::catch
{ @prop = $token->property('get','_SUN_DRAGDROP_INTEREST', $id) };
if (!$@
&& shift(@prop) eq '_SUN_DRAGDROP_INTEREST' && shift(@prop) == 0)
my ($bx,$by) = $token->WindowXY($id);
$token->{'SunDDSeen'} = {} unless exists $token->{'SunDDSeen'};
return $site if $token->{'SunDDSeen'}{$id};
$token->{'SunDDSeen'}{$id} = 1;
my $sites = $token->{'SunDD'};
my $count = shift(@prop);
while (@prop && $count-- > 0)
my ($xid,$sn,$flags,$kind,$n) = splice(@prop,0,5);
warn "Don't understand site type $kind";
while (@prop >= 4 && $n-- > 0)
my ($x,$y,$w,$h) = splice(@prop,0,4);
push(@
$sites,bless [$sn,$xid,$x+$bx,$y+$by,$w,$h,$flags],$class);
return $class->SUPER::FindSite
($token,$X,$Y);
$id = $token->PointToWindow($X,$Y,$id)
delete $token->{'SunDD'} unless $busy;
delete $token->{'SunDDSeen'};
# this code is obsolete now that we look at properties ourselves
# which means we don't need dropsite manager running
unless (1 || $busy || exists $token->{'SunDD'})
Carp
::confess
('Already doing it!') if ($busy++);
my $mw = $token->MainWindow;
$token->{'SunDD'} = \
@sites;
@data = $mw->SelectionGet( '-selection'=>'_SUN_DRAGDROP_DSDM', '_SUN_DRAGDROP_SITE_RECTS');
$token->configure('-cursor'=>'hand2');
my $version = shift(@data);
warn "Unexpected site version $version";
push(@sites,bless [splice(@data,0,7)],$class);
return @
{$token->{'SunDD'}};