#!../../../perl
#
# Purpose:
# This script demonstrates the Cdk widget set and how you can use them.
#
#
# Use the Cdk module.
#
use Cdk;
Cdk::init();
# Set up the label rows.
my @titleMessage = ("<C></5>This is a CDK demo script<!5>",
"<C></5>It will demonstrate all of the<!5>",
"<C></5>widgets available with the<!5>",
"<C></5/U>Cdk Perl 5 extension.<!5>");
# Create the title.
my $title = new Cdk::Label ('Mesg' => \@titleMessage, 'Box' => "FALSE");
# Set some global vars
my $CONTINUE = "Press Any Key To Continue.";
my $HOME = $ENV{'HOME'};
# Create the menu.
my $currentLoc = 0;
my @mLoc = ("Switch to Pull-Up Menu", "Switch to Pull-Down Menu");
my @fMenu = ("</5>File<!5>",
"</5>Open<!5>",
"</5>Quit<!5>");
my @iMenu = ("</5>Info<!5>",
"</5>Date <!5>",
"</5>Label <!5>",
"</5>Viewer <!5>",
"</5>Scrolling Window<!5>");
my @eMenu = ("</5>Entry<!5>",
"</5>Entry Field <!5>",
"</5>Item List <!5>",
"</5>Template <!5>",
"</5>Matrix <!5>",
"</5>Multiple Line Entry Field<!5>",
"</5>Scale <!5>");
my @lMenu = ("</5>Lists<!5>",
"</5>Dialog <!5>",
"</5>Radio List <!5>",
"</5>Selection List<!5>",
"</5>Scrolling List<!5>");
my @mMenu = ("</5>Misc<!5>",
"</5>Histogram<!5>",
"</5>Graph <!5>",
"</5>Marquee <!5>",
"</5>Menu <!5>",
"</5>$mLoc[$currentLoc]");
my @hMenu = ("</5>Help<!5>",
"</5>Help <!5>",
"</5>About...<!5>");
# Create the pulldown menu menu lists.
my @menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
# Set the location of the menus
my @menuloc = ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "RIGHT");
# Create the menu highlight color.
my $highlight = Cdk::makeColorChtype ("A_REVERSE", 16);
# Create the menu
my $menu = new Cdk::Menu ('Menulist' => \@menulist,
'Menuloc' => \@menuloc,
'Tattrib' => $highlight,
'SubTattrib' => $highlight);
# Create the callback for the menu.
$menu->bind ('Key' => '?', 'Function' => sub { main::menuCallback($menu); });
# Create the scrolling window.
my $swindow = new Cdk::Swindow ('Title' => "<C></U>Menu Selection History<!U>",
'Lines' => 200,
'Height' => 6,
'Width' => 60,
'Ypos' => "BOTTOM");
my $menuItemCount = 0;
# Let the user play.
for (;;)
{
# Redraw the screen.
Cdk::refreshCdkScreen();
# Get the selection.
my ($submenu, $submenuItem) = $menu->activate();
my $menuSelection = $menulist[$submenu]->[$submenuItem];
# I'm going to use the name, instead of the numeric value to
# determine what was picked. But either way is acceptable.
if ($menuSelection =~ "Label")
{
my @mesg = ("<C>You just selected the Cdk label widget",
"<C>demo. The labels have many personalities",
"<C>To discover them all, use the help option",
"<C>and pick the Label item.", "",
"<C>$CONTINUE");
labelDemo (@mesg);
}
elsif ($menuSelection =~ "Date")
{
my $date = qx (date); chomp $date;
my @mesg = ("<C>The current time is:", "",
"</C></R>$date", "",
"</C>$CONTINUE");
labelDemo (@mesg);
}
elsif ($menuSelection =~ "Scrolling Window")
{
# Put a message inside the scrolling window.
$swindow->addline ('Info' => "<C></R>This is the scrolling window. It's purpose");
$swindow->addline ('Info' => "<C>is to act as an information window. It also");
$swindow->addline ('Info' => "<C>has the ability to display </15>colors<!15>");
$swindow->addline ('Info' => "<C>and </B>attributes<!B>.");
}
elsif ($menuSelection =~ "Viewer" || $menuSelection =~ "Open")
{
viewerDemo();
}
elsif ($menuSelection =~ "Multiple Line Entry Field")
{
mentryDemo();
}
elsif ($menuSelection =~ "Entry Field")
{
entryDemo();
}
elsif ($menuSelection =~ "Item List")
{
itemlistDemo();
}
elsif ($menuSelection =~ "Template")
{
templateDemo();
}
elsif ($menuSelection =~ "Matrix")
{
matrixDemo();
}
elsif ($menuSelection =~ "$mLoc[$currentLoc]")
{
# We are going to switch the menu type.
if ($currentLoc == 0)
{
# Pull-Down to Pull-Up
$currentLoc = 1;
@mMenu = ("</5>Misc<!5>",
"</5>Histogram<!5>",
"</5>Graph <!5>",
"</5>Marquee <!5>",
"</5>Menu <!5>",
"</5>$mLoc[$currentLoc]");
@menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
undef $menu;
$menu = new Cdk::Menu ('Menulist' => \@menulist,
'Menuloc' => \@menuloc,
'Tattrib' => $highlight,
'Menupos' => "BOTTOM",
'SubTattrib' => $highlight);
}
elsif ($currentLoc == 1)
{
# Pull-Up to Pull-Down
$currentLoc = 0;
@mMenu = ("</5>Misc<!5>",
"</5>Histogram<!5>",
"</5>Graph <!5>",
"</5>Marquee <!5>",
"</5>Menu <!5>",
"</5>$mLoc[$currentLoc]");
@menulist = (\@fMenu, \@iMenu, \@eMenu, \@lMenu, \@mMenu, \@hMenu);
undef $menu;
$menu = new Cdk::Menu ('Menulist' => \@menulist,
'Menuloc' => \@menuloc,
'Tattrib' => $highlight,
'Menupos' => "TOP",
'SubTattrib' => $highlight);
}
}
elsif ($menuSelection =~ "Menu")
{
# Pop up a message stating what we got.
my @mesg = ("<C>The Cdk Menu widget is what",
"is driving this application.", "",
"<C>$CONTINUE");
labelDemo (@mesg);
}
elsif ($menuSelection =~ "Dialog")
{
dialogDemo();
}
elsif ($menuSelection =~ "Scrolling List")
{
scrollDemo();
}
elsif ($menuSelection =~ "Selection List")
{
selectionDemo();
}
elsif ($menuSelection =~ "Radio List")
{
radioDemo();
}
elsif ($menuSelection =~ "Histogram")
{
histogramDemo();
}
elsif ($menuSelection =~ "Graph")
{
graphDemo();
}
elsif ($menuSelection =~ "Scale")
{
scaleDemo();
}
elsif ($menuSelection =~ "Marquee")
{
marqueeDemo();
}
elsif ($menuSelection =~ "Help")
{
help();
}
elsif ($menuSelection =~ "About...")
{
# Pop up a message about this script.
my @mesg = ("<C></U/40>Cdk Perl 5 Extension<!U!40>",
"<C></32>Written by Mike Glover<!32>",
"<C></16>December 1995<!16>", "",
"<C></8>$CONTINUE<!8>");
my $label = new Cdk::Label ('Mesg' => \@mesg, 'Shadow' => "TRUE");
$label->draw();
$label->wait();
}
elsif ($menuSelection =~ "Quit")
{
# Add a message to the scrolling window.
$swindow->addline ('Info' => "<C>Goodbye...");
sleep 2;
# Exit.
Cdk::end();
exit (1);
}
# Add the chosen item to the scrolling window.
my $item = $menulist[$submenu]->[0] . "->" . $menuSelection;
$swindow->addline ('Info' => "$menuItemCount : $item");
$menuItemCount++;
}
##############################################################################
#
# This demonstrates the Cdk label widget.
#
sub labelDemo
{
my @mesg = @_;
# Create the label.
my $label = new Cdk::Label ('Mesg' => \@mesg);
# Draw the label and wait.
$label->draw();
$label->wait();
}
##############################################################################
#
# This demostrates the Cdk viewer widget.
#
sub viewerDemo
{
# Use the file selector widget to get a filename.
my $fselect = new Cdk::Fselect ('Height' => 20, 'Width' => 50,
'Dattrib' => "</16/B>",
'Lattrib' => "</39>",
'Fattrib' => "</40>");
my $fname = $fselect->activate ();
# Popup a file viewer.
my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
'Height' => 20,
'Width' => 78);
# Load in the file.
my @info = qx (cat $fname); chomp (@info);
# Set the contents of the viewer.
$viewer->set ('Title' => "<R></29>Viewing filename:<!29></30>$fname<!30>",
'Info' => \@info,
'Interp' => "TRUE");
# Activate the viewer.
$viewer->activate();
}
##############################################################################
#
# This demonstrates the Cdk entry widget.
#
sub entryDemo
{
my $entry = new Cdk::Entry ('Label' => "Enter a new pause prompt: ",
'Max' => 125,
'Width' => 30);
$CONTINUE = $entry->activate ();
# Pop up a message stating what we got.
my @mesg = ("<C>The new pause prompt is now set to",
"<C>what is below this message",
"<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This demonstrates the Cdk itemlist widget.
#
sub itemlistDemo
{
# Declare locals.
my $row;
# Create the list.
my @months = ("<C>January", "<C>Feburary", "<C>March", "<C>April",
"<C>May", "<C>June", "<C></2>July<!2>", "<C>August",
"<C>September", "<C></32>October<!32>", "<C>November",
"<C></18>December<!18>");
# Get the current date info.
my $info = qx (date +"%d,%m,%Y"); chomp $info;
my ($currentDay, $currentMonth, $currentYear) = split (/,/, $info);
$currentMonth--;
# Create n itemlist to get the month.
my $monthList = new Cdk::Itemlist ('Label' => '</R>Pick a month',
'Default' => $currentMonth,
'List' => \@months);
# Get the month name.
my $choice = $monthList->activate() + 1;
undef $monthList;
# Create a scale to get the year.
my $yearScale = new Cdk::Scale ('Label' => '</R>Pick a year',
'Width' => 5,
'Low' => "1900",
'High' => "2200");
# Set the limits of the years to select from.
$yearScale->set ('Low' => 1900,
'High' => '2200',
'Value' => "$currentYear");
# Get the year.
my $year = $yearScale->activate();
undef $yearScale;
# Get the day
my $dayScale = new Cdk::Scale ('Label' => '</R>Pick a day',
'Width' => 3,
'Low' => 1,
'High' => 31);
# Set the limits of the days to select from.
$dayScale->set ('Low' => 1,
'High' => '31',
'Value' => "$currentDay");
# Get the day.
my $day = $dayScale->activate();
undef $dayScale;
# Create the calander.
my @myCal = ();
foreach $row (`cal $choice $year`)
{
# Strip off the trailing white space
$row =~ s/\s+$/ /;
# Find todays date and highlight.
$row =~ s/ $day / <\/R>$day<!R> /;
push (@myCal, " $row");
}
# Center the title of the cal.
$myCal[0] =~ s/^\s+/<C><\/U>/;
$myCal[0] =~ s/\s+$/<!U>/;
# Colorize the day line.
$myCal[1] =~ s/^/<\/40>/;
$myCal[1] =~ s/$/<!40>/;
# Pop it up on the screen.
push (@myCal, "<C>$CONTINUE");
labelDemo (@myCal);
}
##############################################################################
#
# This demonstrates the Cdk Template widget.
#
sub templateDemo
{
# Create the template widget.
my $birthday = new Cdk::Template ('Label' => 'Enter in your birthday',
'Plate' => '##/##/####',
'Overlay' => '</5>DD<!5>-</15>MM<!15>-</20>YYYY<!20>');
# Get the birthday.
my $bday = $birthday->activate();
# Get the mixed value from the template.
my $bday2 = $birthday->mix();
# Display the results.
my @mesg = ("<C>Birthday without plate mixing: </U>$bday<!U>",
"<C>Birthday with plate mixing: </U>$bday2<!U>",
"<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This demonstrates the Cdk multiple line entry widget.
#
sub mentryDemo
{
# Create the mentry widget.
my $mentry = new Cdk::Mentry ('Label' => "Enter Anything:",
'Fwidth' => 20,
'Lrows' => 10,
'Prows' => 5);
# Activate the mentry widget.
my $info = $mentry->activate ();
# Display the results.
my @mesg = ("<C>You just typed:",
"<C>$info", "",
"<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This demonstrates the Cdk matrix widget.
#
sub matrixDemo
{
my @coltitles = ("Item Name", "Base Price", "% Markup");
my @rowtitles = ("Item 1", "Item 2", "Item 3");
my @colwidths = (10, 6, 6);
my @coltypes = ("VIEWONLY", "VIEWONLY", "INT");
my @matrixValues = ( ["Flabberit", "10.99", ""],
["Whatzit", "102.99", ""],
["Albatros", "99.99", ""]);
my (@newlist, $x);
# Create the matrix widget.
my $matrix = new Cdk::Matrix ('Rowtitles' => \@rowtitles,
'Coltitles' => \@coltitles,
'Colwidths' => \@colwidths,
'Coltypes' => \@coltypes,
'Boxmatrix' => "TRUE",
'Boxcell' => "TRUE",
'Shadow' => "TRUE",
'Vrows' => 3,
'Vcols' => $#coltitles+1);
# Set the values of the matrix.
$matrix->set ( 'Values' => \@matrixValues );
# Activate the matrix.
my ($rows, $cols, $info) = $matrix->activate ();
# Take the information from the matrix and redisplay it.
push (@newlist, "</U>Name Base Percent Price");
for ($x=0; $x < $rows; $x++)
{
if ($info->[$x][2] ne "")
{
my $name = $info->[$x][0];
my $base = $info->[$x][1];
my $perc = $info->[$x][2];
my $price = $base + ($base * $perc) / 100;
push (@newlist, sprintf ("%-10s %4.2f %4.2f %4.2f", $name, $base, $perc, $price));
}
}
# Create the file viewer.
my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
'Height' => 8,
'Width' => 60);
# Set the contents of the viewer.
$viewer->set ('Title' => "Adjusted Price List",
'Info' => \@newlist);
# Activate the viewer.
$viewer->activate();
}
##############################################################################
#
# This demonstrates the Cdk Dialog widget.
#
sub dialogDemo
{
my @mesg = ("<C></U>Cheesy Unix Command Interface<!U>",
"<C>Select a command from the buttons.");
# Create the buutons for the dialog box.
my @buttons = ("date", "pwd", "whoami", "ls -l");
# Create the dialog widget.
my $dialog = new Cdk::Dialog ('Mesg' => \@mesg, 'Buttons' => \@buttons);
# Activate the dialog box.
my $pick = $dialog->activate ();
# Check what we want to run.
if ($buttons[$pick] =~ "ls -l")
{
# Get the directory listing.
my @info = qx (ls -l ${HOME}); chomp (@info);
# Create the file viewer.
my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
'Height' => 15,
'Width' => 60);
# Set the contents of the viewer.
$viewer->set ('Title' => "<C>Listing $HOME", 'Info' => \@info);
$viewer->activate();
}
else
{
# We want to tun anything but ls -l
my $result = qx ($buttons[$pick]); chomp $result;
# Display the result.
my @mesg = ("<C>The command </R>$buttons[$pick]<!R> produced the following:",
"<C>$result",
"<C>$CONTINUE");
labelDemo ( @mesg );
}
}
##############################################################################
#
# This demonstrates the Cdk Scrolling widget.
#
sub scrollDemo
{
my ($x, @items);
# Create an itemlist widget to determine if the user wants numbers or not.
my $boolean = new Cdk::Itemlist ('Label' => 'Do You Want Numbers?:',
'Default' => 0,
'List' => ["No", "Yes"]);
# Create a scale widget for the number of elements.
my $size = new Cdk::Scale ('Label' => 'How Many Items?',
'Width' => 3,
'Low' => 10,
'High' => 100);
# Create an entry field for the title of the scrolling list.
my $entry = new Cdk::Entry ('Label' => 'Title: ',
'Max' => 100,
'Min' => 2,
'Width' => 20);
# Get whether they want numbers or not.
my $nums = $boolean->activate ();
# Get the number of elements.
my $count = $size->activate ();
# Get the title of the scrolling list.
my $title = $entry->activate ();
# Create the item list
for ($x=1; $x <= $count ; $x++)
{
push (@items, "This is item #</U>$x");
}
# Create the scrolling list.
my $scrollDemo = new Cdk::Scroll ('Title' => "$title",
'List' => \@items,
'Numbers' => $nums,
'Height' => 14,
'Width' => 20);
# Activate the scrolling list.
my $selection = $scrollDemo->activate ();
# Spit out the results.
my @mesg = ("<C>You selected",
"<C>$items[$selection]",
"<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This demonstrates the Cdk Selection widget.
#
sub selectionDemo
{
my ($x, @result);
# Create the list of commands to choose from.
my @commands = qw(date whoami pwd hostname uname);
# Create the selection scrolling list.
my $select = new Cdk::Selection ('Title' => "<C></B>Select Commands<!B>",
'List' => \@commands,
'Choices' => ["</24>Yep<!24>", "</16>Nope<!16>"],
'Height' => 8,
'Width' => 20);
# Activate the selection widget.
my @info = $select->activate ();
# Create the result message.
@result = ("<L>Here are the results from the commands you selected:");
for ($x=0; $x <= $#info; $x++)
{
if ($info[$x] eq 0)
{
my $tmp = qx ($commands[$x]); chomp $tmp;
my $fmt = sprintf ("</40>%10s<!40></16>...<!16></48>%-30s<!48>", $commands[$x], $tmp);
push (@result, $fmt);
}
}
push (@result, "<C>$CONTINUE");
# Spit the results out.
labelDemo (@result);
}
##############################################################################
#
# This demonstrates the Cdk Radio widget.
#
sub radioDemo
{
# Create the radio list
my @colors = ("</B/8>White",
"</B/16>Red",
"</B/24>Green",
"</B/32>Yellow",
"</B/40>Blue",
"</B/48>Purple",
"</B/56>Cyan");
# Create the radio widget.
my $radio = new Cdk::Radio ('Title' => "Pick A Color",
'List' => \@colors,
'Highlight' => "A_REVERSE",
'Height' => 7,
'Width' => 10);
# Activate the radio list.
my $color = $radio->activate ();
# Display the results.
my @mesg = ("<C>You Selected",
"<C> $colors[$color]",
"<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This demonstrates the Cdk Histogram widget.
#
sub histogramDemo
{
my ($x);
# Create the histogram label.
my $histLabel = "Time In Seconds This Demo Has Run :";
# Create the histogram widget.
my $hist = new Cdk::Histogram ('Label' => $histLabel,
'Orient' => "HORIZONTAL",
'Height' => 5,
'Width' => 20);
# Take the current time - the start time of this script.
my $diff = time - $;
# Redraw the histogram every second.
for ($x=0; $x < 5; $x++)
{
# Set the values of the histogram.
$hist->set ('Low' => 1,
'High' => $diff + 25,
'Value' => $diff+$x,
'Statstype' => "REAL",
'Statspos' => "CENTER");
# Redraw the histogram.
$hist->draw();
# Sleep for a sec.
sleep (1);
}
}
##############################################################################
#
# This demonstrates the Cdk Marquee widget.
#
sub marqueeDemo
{
# Create an entry widget to get the user's message.
my $entry = new Cdk::Entry ('Label' => 'Enter a Message: ',
'Max' => 100,
'Min' => 2,
'Width' => 20);
# Activate the widget to get the message.
my $message = $entry->activate ();
# Create the widget to get the number times to repeat the message.
my $rvalue = new Cdk::Scale ('Label' => 'Repeat Value:',
'Width' => 4,
'Low' => 1,
'High' => 20);
# Get the repeat value from the user.
my $repeat = $rvalue->activate();
# Create the widget to get the delay.
my $dvalue = new Cdk::Scale ('Label' => 'Delay Value:',
'Width' => 4,
'Low' => 1,
'High' => 20);
# Get the delay value.
my $delay = $dvalue->activate() * 10;
# Create the widget to get the width of the marquee widget.
my $mWidth = new Cdk::Scale ('Label' => 'Marquee Width:',
'Width' => 4,
'Low' => length($message),
'High' => 50);
# Get the width of the marquee widget.
my $width = $mWidth->activate();
# Create the marquee widget.
my $marquee = new Cdk::Marquee ('Width' => $width);
# Activate the marquee widget.
$marquee->activate ('Mesg' => $message,
'Delay' => $delay,
'Repeat' => $repeat);
}
##############################################################################
#
# This demonstrates the Cdk Graph widget.
#
sub graphDemo
{
# Create the graph.
my $graph = new Cdk::Graph ('Title' => "<C>Camel Count",
'Xtitle' => "<C>Quantity",
'Ytitle' => "<C>Months",
'Height' => 17,
'Width' => 20);
# Set the graph values.
my @numberList = qw (10 12 14 16 17 22 31);
my $graphChars = "ooooooo";
$graph->set ('Values' => \@numberList,
'Plottype' => "PLOT",
'Graphchars' => $graphChars);
# Draw the graph.
$graph->draw();
# Prompt the user.
my @mesg = ("When done looking at your Camels", "<C>$CONTINUE");
my $label = new Cdk::Label ('Mesg' => \@mesg, 'Xpos' => "BOTTOM");
$label->draw();
$label->wait();
}
##############################################################################
#
# This demonstrates the Cdk Scale widget.
#
sub scaleDemo
{
# Create the scale widget.
my $scale = new Cdk::Scale ('Label' => 'Pick a number:',
'Width' => 4,
'Low' => 10,
'High' => 100);
# Activate the widget.
my $num = $scale->activate();
# Display the results.
my @mesg = ("<C>You chose $num.", "<C>$CONTINUE");
labelDemo (@mesg);
}
##############################################################################
#
# This is the help menu option under help.
#
sub help
{
my $firstlist = 0;
my $secondlist = 0;
my ($helpfile, $topic, $helpviewer);
my $helpdir = $ENV{'CDKHELPDIR'} || "./help";
my @helpfiles1 = ("general.help",
"concepts.help",
"callbacks.help",
"display.help",
"special.help",
"charfile.help",
"colors.help",
"debug.help",
"future.help",
"bugs.help");
my @helpfiles2 = ("dialog.help",
"entry.help",
"fselect.help",
"graph.help",
"histogram.help",
"itemlist.help",
"label.help",
"marquee.help",
"matrix.help",
"menu.help",
"mentry.help",
"radio.help",
"scale.help",
"scroll.help",
"swindow.help",
"selection.help",
"template.help",
"viewer.help");
my @conceptList = ("</40>General Information About Cdk<!40>",
"</40>Cdk Concepts <!40>",
"</40>Using Cdk's Callback feature <!40>",
"</40>Cdk Display Types <!40>",
"</40>Special Display Attributes <!40>",
"</40>Special Character Formats <!40>",
"</40>Predefined Colors <!40>",
"</40>Debugging Cdk Code <!40>",
"</40>The Future of Cdk <!40>",
"</40>Known Bugs <!40>",
"</40>Cdk Widget Help List <!40>",
"</40>Exit Help <!40>");
my @widgetList = ("</29>Dialog Widget <!29>",
"</29>Entry Field Widget <!29>",
"</29>File Selector Widget <!29>",
"</29>Graph Widget <!29>",
"</29>Histogram Widget <!29>",
"</29>Item List Widget <!29>",
"</29>Label Widget <!29>",
"</29>Marquee Widget <!29>",
"</29>Matrix Widget <!29>",
"</29>Menu Widget <!29>",
"</29>Multiple Line Entry Widget <!29>",
"</29>Radio List Widget <!29>",
"</29>Scale Widget <!29>",
"</29>Scrolling List Widget <!29>",
"</29>Scrolling Window Widget <!29>",
"</29>Selection List Widget <!29>",
"</29>Template Widget <!29>",
"</29>Viewer Widget <!29>",
"</40>Back To Top Menu <!40>");
# Keep doing this until we are told to leave.
for (;;)
{
# Redraw the screen.
Cdk::refreshCdkScreen();
# Set some vars
$firstlist = 0;
$secondlist = 0;
# Create the scrolling list ...
my $helplist = new Cdk::Scroll ('Title' => "<C></U/B/29>Pick A Topic",
'List' => \@conceptList,
'Numbers' => "TRUE",
'Height' => 15,
'Width' => 40);
my $firstlist = $helplist->activate();
# Exit if we have to .
return if ($firstlist == $#conceptList);
# Did we ask for the widget help list?
if ($firstlist == $#conceptList - 1)
{
# We need to pop up the widget help list.
undef $helplist;
my $widgethelp = new Cdk::Scroll ('Title' => "<C></U/26>Pick A Widget",
'List' => \@widgetList,
'Numbers' => "TRUE",
'Height' => 13,
'Width' => 40);
my $secondlist = $widgethelp->activate();
# Create the help filename.
$helpfile = "${helpdir}/$helpfiles2[$secondlist]";
$topic = "$widgetList[$secondlist]";
undef $widgethelp;
}
else
{
# Create the help filename
$helpfile = "${helpdir}/$helpfiles1[$firstlist]";
$topic = "$conceptList[$firstlist]";
}
# Make sure the user didn't ask for exit.
if ($secondlist != $#widgetList)
{
# Check if the file exists.
if (! -f $helpfile)
{
my @error = (
"<C></16>Can not seem to find the help file on the topic </U>$topic<!U><!16>",
"<C></16>Try setting the CDKHELPDIR environment variable<!16>",
"<C></16>or check if the help file '$helpfile' exists<!16>", "",
"<C>$CONTINUE");
labelDemo (@error);
}
else
{
# Display the file.
my @info = ();
undef $helpviewer;
my $helpviewer = new Cdk::Viewer ('Buttons' => ["OK"],
'Height' => 20,
'Width' => 78);
chop (@info = `cat $helpfile`);
$helpviewer->set ('Title' => "<C></18>Help: </U>$topic<!18U>",
'Info' => \@info);
$helpviewer->activate();
}
}
}
}
#
# This is the callback function for the menu.
#
sub menuCallback
{
my $menu = shift;
# Call the help function.
main::help();
# Refresh the screen.
Cdk::refreshCdkScreen();
}