Curses-Devkit
view release on metacpan or search on metacpan
demos/rolodex view on Meta::CPAN
#!../../../perl
#
# Initialize Cdk.
#
use Cdk;
Cdk::init();
# Declare global variables.
$GGroupInfoChanged = 0;
@GLineType = ("Voice", "Cell", "Pager",
"First FAX", "Second FAX", "Third FAX",
"First Data Line", "Second Data Line", "Third Data Line");
# Create the menu list items.
my $fMenu = ["</5/B>File", "</5/B>Open ", "</5/B>Save ", "</5/B>Save As", "</5/B>Quit "];
my $eMenu = ["</5/B>Groups", "</5/B>New ", "</5/B>Open ", "</5/B>Delete"];
my $pMenu = ["</5/B>Print", "</5/B>Print Rolodex"];
my $hMenu = ["</5/B>Help", "</5/B>About Rolodex ", "</5/B>Rolodex Statistics"];
my $menulist = [$fMenu, $eMenu, $pMenu, $hMenu];
my $menuloc = ["LEFT", "LEFT", "LEFT", "RIGHT"];
# Create the menu object.
my $menu = new Cdk::Menu ('Menulist' => $menulist, 'Menuloc' => $menuloc);
$menu->draw();
# Create the title.
my @title = ("<C></16/U>Cdk/Perl5 Rolodex", "<C></16>Written by Mike Glover");
my $rolodexTitle = new Cdk::Label ('Message' => \@title, 'Box' => "FALSE");
$rolodexTitle->draw("Box" => "FALSE");
# Load up the RC file.
my $filename = $ENV{"HOME"} . "/.rolorc";
my $dbmDir = $ENV{"HOME"} . "/.rolodex";
my %groupInfo = readRCFile ($filename);
my $groupCount = keys %groupInfo;
# Pop up a message stating how many groups were loaded.
if ($groupCount == 0)
{
my $groupMessage = ["</B>Empty rolodex RC file. No groups loaded.",
"<C></B>Press any key to continue."];
popupLabel ($groupMessage);
}
elsif ($groupCount == 1)
{
my $groupMessage = ["</B>There was 1 group loaded from the RC file.",
"<C></B>Press any key to continue."];
popupLabel ($groupMessage);
}
else
{
my $groupMessage = ["</B>There were $groupCount groups loaded from the RC file.",
"<C></B>Press any key to continue."];
popupLabel ($groupMessage);
}
# Start the main loop
for (;;)
{
# Activate the object.
my ($menuItem, $submenuItem) = $menu->activate();
# Make sure they didn't hit escape.
next if ! defined $menuItem;
# Determine which menuitem was selected.
if ($menuItem == 0)
{
if ($submenuItem == 1)
{
# Open a new RC file.
my $fselect = new Cdk::Fselect ('Label' => "Filename:",
'Height' => 20,
'Width' => 55);
my $file = $fselect->activate();
undef $fselect;
# Make sure they chose a file.
if (defined $file)
{
my %tmpGroup = readRCFile ($file);
# Check the results.
( run in 1.004 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )