1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/usr/bin/perl -w
# $Id: viewer,v 1.2 2002/07/27 20:11:17 tom Exp $
#
# Purpose:
# To demonstrate the Perl5 Cdk Viewer Widget.
#
# Initialize Cdk.
#
use Cdk;
use Getopt::Long;
Cdk::init();
# Get the screen dimensions.
my ($rows, $cols) = Cdk::getCdkScreenDim ();
# Parse the command line options.
my $ret = GetOptions ('f|file:s', 'h|height:i', 'w|width:i');
my $height = $opt_h || $rows-2;
my $width = $opt_w || $cols;
my $filename = $opt_f;
# Activate the object.
if (!defined $filename)
{
# Create a file selector widget to get the filename.
my $fselect = new Cdk::Fselect ('Label' => "Filename:",
'Height' => $height,
'Width' => $width);
# Get the filename.
$filename = $fselect->activate();
}
# Open the file and load it up.
my @info = qx (cat $filename); chomp @info;
# Create the viewer object.
my $viewer = new Cdk::Viewer ('Buttons' => [ "<<OK>>" ],
'Height' => $height,
'Width' => $width);
# Set the contents of the viewer.
$viewer->set ('Title' => "<C></5>File: $filename",
'Info' => \@info);
# Activate the viewer.
my $selection = $viewer->activate();
# End Cdk.
Cdk::end();
|