Debian Codegraph @

demos/bday

raw
1 #!/usr/bin/perl -w
2 # $Id: bday,v 1.7 2013/07/17 18:38:10 tom Exp $
3
4 #
5 # Purpose:
6 # To demonstrate the Perl5 Cdk Calendar Widget
7
8 use strict;
9
10 # Set some global variables.
11 my %birthdays = ();
12 my %appointments = ();
13 my %anniversay = ();
14
15 # Initialize Cdk.
16 use Cdk;
17 Cdk::init();
18
19 # Create the calendar object.
20 my $calendar = new Cdk::Calendar(
21 'Dattrib' => "</32/B>",
22 'Mattrib' => "</5/B>",
23 'Yattrib' => "</24/B>",
24 'Highlight' => "</R>"
25 );
26
27 # Create the scrolling window.
28 my $swindow = new Cdk::Swindow(
29 'Title' => "<C></B/5>Date Information",
30 'Lines' => 300,
31 'Height' => 4,
32 'Width' => 50,
33 'Ypos' => "BOTTOM"
34 );
35
36 # Set the key binding for the calendar widget.
37 $calendar->bind( 'Key' => "m", 'Function' => sub { setMarkerCB($calendar); } );
38
39 # Set the post-process function for the calendar widget.
40 $calendar->postProcess( 'Function' => sub { checkDatePP($calendar); } );
41
42 # Draw the scrolling window.
43 $swindow->draw();
44
45 # Let the user play.
46 for ( ; ; ) {
47
48 # Activate the object.
49 my ( $day, $month, $year ) = $calendar->activate();
50 last if not defined $day;
51 last if not defined $month;
52 last if not defined $year;
53 my $msg = sprintf "day %2d, month %2d, year %4d", $day, $month, $year;
54 $swindow->addline( 'Info' => $msg );
55 }
56
57 # Exit Cdk.
58 Cdk::end();
59
60 #
61 # This checks if the current date has a marker set on it.
62 #
63 sub checkDatePP {
64 my $calendar = shift;
65 }
66
67 #
68 # This allows the user to create a marker.
69 #
70 sub setMarkerCB {
71 my $calendar = shift;
72 my @mesg = ("<C></B/5>What type of a marker is it?");
73 my @buttons =
74 ( "</B/3>Birthday", "</B/5>Anniversary", "</B/30>Appointment" );
75
76 # Get the current date the marker is at.
77 my ( $day, $month, $year ) = $calendar->getDate();
78
79 # Ask the user what type of marker to add.
80 my $dialog = new Cdk::Dialog( 'Message' => \@mesg, 'Buttons' => \@buttons );
81 my $choice = $dialog->activate();
82 undef $dialog;
83
84 # If they hit escape, tell them...
85 if ( !defined $choice ) {
86 popupLabel( ["Escape Hit. No marker set."] );
87 $calendar->draw();
88 return 1;
89 }
90
91 # Check the choice.
92 if ( $choice == 0 ) {
93 addBirthdayMarker( $day, $month, $year );
94 }
95 elsif ( $choice == 1 ) {
96 addAnniversaryMarker( $day, $month, $year );
97 }
98 elsif ( $choice == 2 ) {
99 addAppointmentMarker( $day, $month, $year );
100 }
101 return 1;
102 }
103
104 #
105 #
106 #
107 sub addBirthdayMarker {
108 my ( $day, $month, $year ) = @_;
109 }
110
111 #
112 #
113 #
114 sub addAnniversaryMarker {
115 my ( $day, $month, $year ) = @_;
116 }
117
118 #
119 #
120 #
121 sub addAppointmentMarker {
122 my ( $day, $month, $year ) = @_;
123 }