CursesWidgets
view release on metacpan or search on metacpan
--Fixed a few bugs in how textwrap handled and returned trailing
newlines
--Changed LENGTH attribute to COLUMNS in applicable widgets
--Removed touchwin calls for more efficient refresh
--Newlines no longer count as a character space in textwrap
All Widgets:
--Removed undef colour keys
--Reworked to work with new Widgets.pm internals
Calendar:
--Added header colour selection support
--VALUE now holds the date the cursor is on in the current calendar
ComboBox:
--Fixed bug to allow a user not to select something from the list
ListBox:
--Entire widget is now underlined correctly in non-borderd mode
--VALUE now holds selected items instead of SELECTED
TextField & TextMemo:
--Fixed underline mode to correctly underline entire field, instead
of just text
--Added regex to accept only printable characters as part of the value
--Fixed bugs in cursor placement and scrolling
Widgets/Calendar.pm view on Meta::CPAN
=item Curses
=item Curses::Widgets
=back
=head1 DESCRIPTION
Curses::Widgets::Calendar provides simplified OO access to Curses-based
calendars. Each object maintains it's own state information.
=cut
#####################################################################
#
# Environment definitions
#
#####################################################################
package Curses::Widgets::Calendar;
Widgets/Calendar.pm view on Meta::CPAN
CAPTION undef Caption superimposed on border
CAPTIONCOL undef Foreground colour for caption text
INPUTFUNC \&scankey Function to use to scan for keystrokes
FOREGROUND undef Default foreground colour
BACKGROUND undef Default background colour
BORDER 1 Display a border around the field
BORDERCOL undef Foreground colour for border
FOCUSSWITCH "\t" Characters which signify end of input
HIGHLIGHT [] Days to highlight
HIGHLIGHTCOL undef Default highlighted data colour
HEADERCOL undef Default calendar header colour
MONTH (current) Month to display
VALUE 1 Day of the month where the cursor is
ONYEAR undef Callback function triggered by year
ONMONTH undef Callback function triggered by month
ONDAY undef Callback function triggered by day
Each of the ON* callback functions expect a subroutine reference that excepts
one argument: a handle to the calendar object itself. If more than one
trigger is called, it will be called in the order of day, month, and then
year.
=cut
sub _conf {
# Validates and initialises the new TextField object.
#
# Usage: $self->_conf(%conf);
Widgets/Calendar.pm view on Meta::CPAN
$err = 1 unless $self->SUPER::_conf(%conf);
return $err == 0 ? 1 : 0;
}
=head2 draw
$cal->draw($mwh, 1);
The draw method renders the calendar in its current state. This
requires a valid handle to a curses window in which it will render
itself. The optional second argument, if true, will cause the calendar's
selected day to be rendered in standout mode (inverse video).
=cut
sub _content {
my $self = shift;
my $dwh = shift;
my $conf = $self->{CONF};
my $pos = $$conf{VALUE};
my @date = split(/\//, $$conf{MONTH});
my @highlight = @{ $$conf{HIGHLIGHT} };
my ($i, @cal);
# Get the calendar lines and print them
@cal = _gen_cal(@date[1,0]);
$i = 0;
foreach (@cal) {
# Set the header colour (if defined)
unless ($i > 1 || ! exists $$conf{HEADERCOL}) {
$dwh->attrset(COLOR_PAIR(
select_colour(@$conf{qw(HEADERCOL BACKGROUND)})));
$dwh->attron(A_BOLD) if $$conf{HEADERCOL} eq 'yellow';
}
# Save the cursor position if it's on this line
$self->{COORD} = [$i, length($1)] if $cal[$i] =~ /^(.*\b)$pos\b/;
# Print the calendar line
$dwh->addstr($i, 0, $cal[$i]);
# Highlight the necessary dates
if (exists $$conf{HIGHLIGHTCOL}) {
until ($#highlight == -1 || $cal[$i] !~ /^(.*\b)$highlight[0]\b/) {
$dwh->chgat($i, length($1), length($highlight[0]), 0,
select_colour(@$conf{qw(HIGHLIGHTCOL BACKGROUND)}), 0);
shift @highlight;
}
}
Widgets/Calendar.pm view on Meta::CPAN
# Display the cursor
$dwh->chgat($y, $x, length($pos), A_STANDOUT,
select_colour($fg, $$conf{BACKGROUND}), 0);
# Restore the default settings
$self->_restore($dwh);
}
sub _gen_cal {
# Generates the calendar month output, and stuffs it into a
# LOL, which is returned by the method.
#
# Modified from code provided courtesy of Michael E. Schechter,
# <mschechter@earthlink.net>
#
# Usage: @lines = $self->_gen_cal($year, $month);
my @date = @_;
my (@lines, @tmp, $i, @out);
Widgets/Calendar.pm view on Meta::CPAN
&{$$conf{ONYEAR}}($self) if (defined $$conf{ONYEAR} &&
$trigger =~ /y/);
}
1;
=head1 HISTORY
=over
=item 1999/12/29 -- Original calendar widget in functional model
=item 2001/07/05 -- First incarnation in OO architecture
=back
=head1 AUTHOR/COPYRIGHT
(c) 2001 Arthur Corliss (corliss@digitalmages.com)
=cut
FOREGROUND => 'black',
BACKGROUND => 'white',
BORDER => 1,
CAPTION => 'Appointments',
CAPTIONCOL => 'blue',
HIGHLIGHT => [1, 5, 17, 26],
HIGHLIGHTCOL => 'green',
HEADERCOL => 'red',
});
$descriptions[7] = << '__EOF__';
Curses::Widgets::Calendar -- This calendar supports date highlighting and broad navigation capabilities.
Press <TAB> to move to the next widget (set).
__EOF__
$widgets[8] = Curses::Widgets::ComboBox->new({
Y => 3,
X => 62,
FOREGROUND => 'white',
BACKGROUND => 'red',
LISTITEMS => [qw(Mr. Mrs. Ms.)],
( run in 1.352 second using v1.01-cache-2.11-cpan-39bf76dae61 )