File: dialog

package info (click to toggle)
libcdk-perl 4.9.10-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 884 kB
  • ctags: 411
  • sloc: perl: 6,419; makefile: 33; sh: 27
file content (62 lines) | stat: -rwxr-xr-x 1,254 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w
# $Id: dialog,v 1.3 2002/07/24 10:04:33 tom Exp $

#
# Purpose:
#	To demonstrate the Perl5 Cdk Dialog Widget.

#
# Initialize Cdk.
#
use Cdk;
Cdk::init();

# Create the dialog buttons.
my @buttons = ("</3>Button 0<!3>",
		"</4>Button 1<!4>",
		"</5>Button 2<!5>",
		"</6>Button 3<!6>");

# Create the dialog message.
my @mesg = ("<C></2>This should be centered<!2>",
		"<L></7>This should be on the left.<!7>",
		"<R></3>This should be on the right.<!3>");

# Create the dialog object.
my $dialog = new Cdk::Dialog ('Message' => \@mesg,
				'Buttons' => \@buttons,
				'Xpos' => "CENTER",
				'Ypos' => "CENTER",
				'Highlight' => "A_REVERSE");

# Create a key binding.
$dialog->bind ('Key' => '?', 'Function' => sub {main::callback();});

# Activate the object.
my $button = $dialog->activate();

# Check the results.
if (!defined $button)
{
   popupLabel (["<C>Escape hit. No button selected."]);
}
else
{
   popupLabel (["<C>You selected button $button"]);
}

# Exit Cdk.
Cdk::end();

#
# This is the callback function to the dialog widget.
#
sub callback
{
   my $label = new Cdk::Label ('Message' => ["<C>This is the",
						"<C>callback to the",
						"<C>dialog widget."]);
   $label->draw();
   $label->wait();
   return 1;
}