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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#!/usr/bin/perl -w
# $Id: postProcess,v 1.3 2002/07/27 20:15:12 tom Exp $
#
# Purpose:
# To demonstrate the postProcess method.
#
# Initialize Cdk.
#
use Cdk;
Cdk::init();
# Set up the scrolling list.
my @commandItems = ("Add Account ",
"Delete Account ",
"Account Information ",
"Change Account Password ",
"Change Account Shell ",
"Change Account Directory",
"Quit ");
my @commandInfo = ("<C>Adds a new account to the system.",
"<C>Deletes an exiting account from the system.",
"<C>Provides information about a given account.",
"<C>Changes a given account's current password.",
"<C>Changes a given account's login shell.",
"<C>Changes a given account's login directory.",
"<C>Exits this interface.");
my @initMessage = ("******************************************************");
# Create the title.
my $title = new Cdk::Label ('Message' => ["<C></B/5>Unix System Admin Interface."],
'Ypos' => "TOP",
'Xpos' => "LEFT");
# Create the scrolling list object.
my $scroll = new Cdk::Scroll ('Title' => "<C></U/5>Pick An Option",
'Highlight' => "</B/R/24>",
'Height' => 10,
'Width' => 35,
'Numbers' => "TRUE",
'List' => \@commandItems);
# Set the post-process for the scrolling list.
$scroll->postProcess ('Function' => sub { setInfoLabelCB();} );
# Create the scrolling list item label.
my $infoLabel = new Cdk::Label ('Message' => \@initMessage, 'Xpos' => 1, 'Ypos' => 3);
# Set the contents of the info label.
$infoLabel->set ('Message' => ["$commandInfo[0]"]);
$infoLabel->draw();
# Draw the screen.
$title->draw();
$infoLabel->draw();
# Do this forever.
for (;;)
{
# Activate the scrolling list.
my $item = $scroll->activate();
}
# Exit Cdk.
Cdk::end();
#
#
#
sub setInfoLabelCB
{
# Get the current itrm from the scrolling list.
my ($size, $currentItem) = $scroll->info();
# Set the info in the label.
$infoLabel->set ('Message' => ["$commandInfo[$currentItem]"]);
$infoLabel->draw();
return 1;
}
|