home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _8b6dca6cd4a766b9346848ce4d879200 < prev    next >
Text File  |  2004-06-01  |  2KB  |  57 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Listbox.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package Tk::Listbox;
  5.  
  6. #line 176 "..\blib\lib\Tk\Listbox.pm (autosplit into ..\blib\lib\auto\Tk\Listbox\FETCH.al)"
  7. # FETCH
  8. # -----
  9. # Return either the full contents or only the selected items in the
  10. # box depending on whether we tied it to an array or scalar respectively
  11. sub FETCH {
  12.   my $class = shift;
  13.  
  14.   my $self = ${$class->{OBJECT}};
  15.   my %options = %{$class->{OPTION}} if defined $class->{OPTION};;
  16.  
  17.   # Define the return variable
  18.   my $result;
  19.  
  20.   # Check whether we are have a tied array or scalar quantity
  21.   if ( @_ ) {
  22.      my $i = shift;
  23.      # The Tk:: Listbox has been tied to an array, we are returning
  24.      # an array list of the current items in the Listbox
  25.      $result = $self->get($i);
  26.   } else {
  27.      # The Tk::Listbox has been tied to a scalar, we are returning a
  28.      # reference to an array or hash containing the currently selected items
  29.      my ( @array, %hash );
  30.  
  31.      if ( defined $options{ReturnType} ) {
  32.  
  33.         # THREE-WAY SWITCH
  34.         if ( $options{ReturnType} eq "index" ) {
  35.            $result = [$self->curselection];
  36.         } elsif ( $options{ReturnType} eq "element" ) {
  37.        foreach my $selection ( $self->curselection ) {
  38.               push(@array,$self->get($selection)); }
  39.            $result = \@array;
  40.     } elsif ( $options{ReturnType} eq "both" ) {
  41.        foreach my $selection ( $self->curselection ) {
  42.               %hash = ( %hash, $selection => $self->get($selection)); }
  43.            $result = \%hash;
  44.     }
  45.      } else {
  46.         # return elements (default)
  47.         foreach my $selection ( $self->curselection ) {
  48.            push(@array,$self->get($selection)); }
  49.         $result = \@array;
  50.      }
  51.   }
  52.   return $result;
  53. }
  54.  
  55. # end of Tk::Listbox::FETCH
  56. 1;
  57.