# Converted from listbox.tcl -- # # This file defines the default bindings for Tk listbox widgets. # # @(#) listbox.tcl 1.7 94/12/17 16:05:18 # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Modifications from standard Listbox.pm # -------------------------------------- # 27-JAN-2001 Alasdair Allan # Modified for local use by adding tied scalar and arrays # Implemented TIESCALAR, TIEARRAY, FETCH, FETCHSIZE, STORE, CLEAR & EXTEND # 31-JAN-2001 Alasdair Allan # Made changes suggested by Tim Jenness # 03-FEB-2001 Alasdair Allan # Modified STORE for tied scalars to clear and select elements # 06-FEB-2001 Alasdair Allan # Added POD documentation for tied listbox # 13-FEB-2001 Alasdair Allan # Implemented EXISTS, DELETE, PUSH, POP, SHIFT & UNSHIFT for tied arrays # 14-FEB-2001 Alasdair Allan # Implemented SPLICE for tied arrays, all tied functionality in place # 16-FEB-2001 Alasdair Allan # Tweak to STORE interface for tied scalars # 23-FEB-2001 Alasdair Allan # Added flag to FETCH for tied scalars, modified to return hashes # 24-FEB-2001 Alasdair Allan # Updated Pod documentation # package Tk::Listbox; use vars qw($VERSION @Selection $Prev); use strict; $VERSION = sprintf '4.%03d', q$Revision: #14 $ =~ /\D(\d+)\s*$/; use Tk qw(Ev $XS_VERSION); use Tk::Clipboard (); use AutoLoader; use base qw(Tk::Clipboard Tk::Widget); Construct Tk::Widget 'Listbox'; bootstrap Tk::Listbox; sub Tk_cmd { \&Tk::listbox } Tk::Methods('activate','bbox','curselection','delete','get','index', 'insert','itemcget','itemconfigure','nearest','scan','see', 'selection','size','xview','yview'); use Tk::Submethods ( 'selection' => [qw(anchor clear includes set)], 'scan' => [qw(mark dragto)], 'xview' => [qw(moveto scroll)], 'yview' => [qw(moveto scroll)], ); *Getselected = \&getSelected; sub clipEvents { return qw[Copy]; } sub BalloonInfo { my ($listbox,$balloon,$X,$Y,@opt) = @_; my $e = $listbox->XEvent; return if !$e; my $index = $listbox->index('@' . $e->x . ',' . $e->y); foreach my $opt (@opt) { my $info = $balloon->GetOption($opt,$listbox); if ($opt =~ /^-(statusmsg|balloonmsg)$/ && UNIVERSAL::isa($info,'ARRAY')) { $balloon->Subclient($index); if (defined $info->[$index]) { return $info->[$index]; } return ''; } return $info; } } sub ClassInit { my ($class,$mw) = @_; $class->SUPER::ClassInit($mw); # Standard Motif bindings: $mw->bind($class,'<1>',[sub { my $w = shift; if (Tk::Exists($w)) { $w->BeginSelect(@_); } }, Ev('index',Ev('@'))]); $mw->bind($class, '' => \&Tk::NoOp); $mw->bind($class,'',['Motion',Ev('index',Ev('@'))]); $mw->bind($class,'','ButtonRelease_1'); ; $mw->bind($class,'',['BeginExtend',Ev('index',Ev('@'))]); $mw->bind($class,'',['BeginToggle',Ev('index',Ev('@'))]); $mw->bind($class,'',['AutoScan',Ev('x'),Ev('y')]); $mw->bind($class,'','CancelRepeat'); $mw->bind($class,'',['UpDown',-1]); $mw->bind($class,'',['ExtendUpDown',-1]); $mw->bind($class,'',['UpDown',1]); $mw->bind($class,'',['ExtendUpDown',1]); $mw->XscrollBind($class); $mw->bind($class,'', sub { my $w = shift; $w->yview('scroll',-1,'pages'); $w->activate('@0,0'); }); $mw->bind($class,'', sub { my $w = shift; $w->yview('scroll',1,'pages'); $w->activate('@0,0'); }); $mw->bind($class,'', ['xview', 'scroll', -1, 'pages']); $mw->bind($class,'', ['xview', 'scroll', 1, 'pages']); # and defined in XscrollBind $mw->bind($class,'','Cntrl_Home'); ; $mw->bind($class,'',['DataExtend',0]); $mw->bind($class,'','Cntrl_End'); ; $mw->bind($class,'',['DataExtend','end']); # XXX What about <>? Already handled in Tk::Clipboard? # $class->clipboardOperations($mw,'Copy'); $mw->bind($class,'',['BeginSelect',Ev('index','active')]); $mw->bind($class,'