#!/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 = ("Adds a new account to the system.", "Deletes an exiting account from the system.", "Provides information about a given account.", "Changes a given account's current password.", "Changes a given account's login shell.", "Changes a given account's login directory.", "Exits this interface."); my @initMessage = ("******************************************************"); # Create the title. my $title = new Cdk::Label ('Message' => ["Unix System Admin Interface."], 'Ypos' => "TOP", 'Xpos' => "LEFT"); # Create the scrolling list object. my $scroll = new Cdk::Scroll ('Title' => "Pick An Option", 'Highlight' => "", '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; }