From 661c41a09e39a182865e0b51e34cc995a0dc96e8 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 12 May 2010 16:54:37 +0000 Subject: move tlperl.straw to tlperl git-svn-id: svn://tug.org/texlive/trunk@18210 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tlperl/lib/Tk/Listbox.pm | 910 ++++++++++++++++++++++++++++++++++ 1 file changed, 910 insertions(+) create mode 100755 Master/tlpkg/tlperl/lib/Tk/Listbox.pm (limited to 'Master/tlpkg/tlperl/lib/Tk/Listbox.pm') diff --git a/Master/tlpkg/tlperl/lib/Tk/Listbox.pm b/Master/tlpkg/tlperl/lib/Tk/Listbox.pm new file mode 100755 index 00000000000..249a8eed7f4 --- /dev/null +++ b/Master/tlpkg/tlperl/lib/Tk/Listbox.pm @@ -0,0 +1,910 @@ +# 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,'