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
|
#!/usr/bin/perl -w
# $Id: dialog,v 1.4 2013/07/14 22:36:43 tom Exp $
#
# Purpose:
# To demonstrate the Perl5 Cdk Dialog Widget.
use strict;
#
# 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;
}
|