view release on metacpan or search on metacpan
		  a language module of your own, please send it to 
		  me. I'll then include it in the distribution.
                - Changed all year 2001 occurrances in the Changelog
		  to 2002. Thanks to Mark Overmeer (mr. Mail::Box) for
		  noticing that I was one year off ;-)
                - Made sure that upon deleting a widget from a
                  container, its subwindows are deleted.
                - Created calendar dialog (request made by Ravi Pina).
		  Also added a little demo to demo-widgets for this
		  new dialog type. The dialog is accessable via
		  Curses::UI ($cui->calendardialog).
		- Changed the unpacking of mouse events a little
		  (thanks to William Setzer for the hint on
		  unpack("sx2i3l", $MEVENT) instead of
		  unpack("i5", $MEVENT)). 
Version 0.70
============
2002-01-31      - After a lot of hacking on the resize code
                  documentation of each Curses::UI class.
                - All focusable objects now have the following 
                  event callbacks:
                  -onfocus / onFocus()
                  -onblur  / onBlur()
                - The Curses::UI::Calendar widget now fully
                  supports the years 0 - 9999, including the
                  transition from the Julian to the Gregorian
                  calendar (september 1752). This beats the
                  use of timelocal/localtime (which would 
                  currently only support 1900 - 2038 IIRC).
                - Added intellidraw() method to Curses::UI::Widget.
                  If this method is called, the widget is redrawn, but
                  only if it's visible (not hidden and in topwindow)
                  and if intellidraw is enabled (-intellidraw data 
                  member has a true value).
                  This routine can be used to be able to redraw 
                  - Curses::UI::Listbox (+ descendants)
                  - Curses::UI::Checkbox
                  - Curses::UI::Popupbox
                  - Curses::UI::Progressbar
                  - Curses::UI::TextEditor (+ descendants)
                  - Curses::UI::SearchEntry
                - Added a little example application to demonstrate
                  the new intellidraw feature: examples/demo-intellidraw 
2002-01-15:     - Changed the displaying of the calendar widget
                  a little. The topbar showing a date is only 
                  highlighted if the cursor is on the selected date.
	
                - Renamed some widgets (now we still can). I think
                  there are too many capitals in them...
                  - Curses::UI::ListBox renamed to
                    Curses::UI::Listbox
                  - Curses::UI::CheckBox renamed to
                    Curses::UI::Checkbox
                  - Curses::UI::MenuBar renamed to
examples/demo-widgets view on Meta::CPAN
$w{7}->onFocus( sub{$cui->enable_timer  ('progressbar_demo')} );
$w{7}->onBlur(  sub{$cui->disable_timer ('progressbar_demo')} );
# ----------------------------------------------------------------------
# Calendar
# ----------------------------------------------------------------------
$w{8}->add(
    undef, 'Label',
    -text => "The calendar can be used to select a date, somewhere between\n"
           . "the years 0 and 9999. It honours the transition from the\n"
	   . "Julian- to the Gregorian calender in 1752."
);
$w{8}->add(
    undef, 'Label',
    -y => 5, -x => 27,
    -text => "Use your cursor keys (or <H>, <J>, <K> and <L>)\n"
           . "to walk through the calender. Press <ENTER>\n"
	   . "or <SPACE> to select a date. Press <SHIFT+J> to\n"
	   . "go one month forward and <SHIFT+K> to go one\n"
	   . "month backward. Press <SHIFT+L> or <N> to go one\n"
	   . "year forward and <SHIFT+H> or <P> to go one year\n"
	   . "backward. Press <T> to go to today's date. Press\n"
	   . "<C> to go to the currently selected date."
);
$w{8}->add(
    'calendarlabel', 'Label',
    -y => 14, -x => 27,
    -bold => 1,
    -width => -1,
    -text => 'Select a date please...'
);
$w{8}->add(
    'calendar', 'Calendar',
    -y => 4, -x => 0,
    -border => 1,
    -onchange => sub {
        my $cal = shift;
	my $label = $cal->parent->getobj('calendarlabel'); 
	$label->text("You selected the date: " . $cal->get);
    },
);
# ----------------------------------------------------------------------
# Dialog::Basic
# ----------------------------------------------------------------------
$w{9}->add(
    undef, 'Label',
examples/demo-widgets view on Meta::CPAN
    ]
);
# ----------------------------------------------------------------------
# Dialog::Calendar
# ----------------------------------------------------------------------
$w{14}->add(
    undef, 'Label',
    -text => "Curses::UI has a number of ready-to-use dialog windows.\n"
           . "The calendar dialog is one of them. Using this dialog\n"
	   . "it is possible to select a date."
);
$w{14}->add( undef,  'Label', -y => 7, -text => 'Date:' );
$w{14}->add( 
    'datelabel', 'Label', 
    -width => 10, 
    -y => 7, 
    -x => 6, 
    -text => 'none',
examples/demo-widgets view on Meta::CPAN
    -y => 7,    
    -x => 17,
    -buttons => [
         { 
	   -label => "< Set date >",
	   -onpress => sub { 
	       my $label = shift()->parent->getobj('datelabel');
	       my $date = $label->get;
	       print STDERR "$date\n";
	       $date = undef if $date eq 'none';
	       my $return = $cui->calendardialog(-date => $date);
	       $label->text($return) if defined $return;
	   }
         },{
	   -label => "< Clear date >",
	   -onpress => sub {
	       my $label = shift()->parent->getobj('datelabel');
	       $label->text('none');
	   }
	 }
    ]
lib/Curses/UI.pm view on Meta::CPAN
    $self->tempdialog('Dialog::Basic', %args);
}
sub question()
{
    my $self = shift;
    my %args = $self->process_args('-question', @_);
    $self->tempdialog('Dialog::Question', %args);
}
sub calendardialog()
{
    my $self = shift;
    my %args = $self->process_args('-title', @_);
    $self->tempdialog('Dialog::Calendar', %args);
}
sub filebrowser()
{
    my $self = shift;
    my %args = $self->process_args('-title', @_);
lib/Curses/UI/Calendar.pm view on Meta::CPAN
    return @month;
}
1;
=pod
=head1 NAME
Curses::UI::Calendar - Create and manipulate calendar widgets
=head1 CLASS HIERARCHY
 Curses::UI::Widget
    |
    +----Curses::UI::Calendar
=head1 SYNOPSIS
    use Curses::UI;
    my $cui = new Curses::UI;
    my $win = $cui->add('window_id', 'Window');
    my $calendar = $win->add(
        'mycalendar', 'Calendar',
    -date    => '2002-1-14'
    );
    $calendar->focus();
    my $date = $calendar->get();
=head1 DESCRIPTION
Curses::UI::Calendar is a widget that can be used to create 
a calendar in which the user can select a date. The calendar
widget looks like this:
  +----------------------+
  | mmm dd          yyyy | 
  +----------------------+
  | su mo tu we th fr sa |
  |                      |
  |       01 02 03 04 05 |
  | 06 07 08 09 10 11 12 |
  | 13 14 15 16 17 18 19 |
lib/Curses/UI/Calendar.pm view on Meta::CPAN
* B<YYYY/M/D> (e.g. 2002/1/10 or 2002/01/10))
* B<YYYYMMDD> (e.g. 20020110)
* B<D-M-YYYY> (e.g. 10-1-2002 or 10/01/2002)
* B<D/M/YYYY> (e.g. 10/1/2002 or 10/01/2002)
=item * B<-onchange> < CODEREF >
This sets the onChange event handler for the calendar widget.
If a new date is selected, the code in CODEREF will be executed.
It will get the widget reference as its argument.
=item * B<-drawline> < CODEREF >
This option specifies whether or not a line should be drawn under
the calendar.
=back
=head1 METHODS
=over 4
lib/Curses/UI/Calendar.pm view on Meta::CPAN
=item * B<setdate> ( DATE, [BOOLEAN] )
Set the selected date of the widget to DATE. See B<-date> above for
the possible formats. The widget will redraw itself, unless BOOLEAN
has a true value.
=item * B<onChange> ( CODEREF )
This method can be used to set the B<-onchange> event handler
(see above) after initialization of the calendar. 
=back
=head1 DEFAULT BINDINGS
=over 4
lib/Curses/UI/Dialog/Calendar.pm view on Meta::CPAN
        -buttonalignment => 'right',
        -buttons         => [ 'ok', 'cancel' ],
        -bg              => $this->{-bg},
        -fg              => $this->{-fg},
    );
    # Let the window in which the buttons are loose focus
    # if a button is pressed.
    $buttons->set_routine( 'press-button', \&press_button_callback );
    my $calendar = $this->add(
        'calendar', 'Calendar',
        -border          => 0,
        -padbottom       => 1,
        -date            => $this->{-date},
        -bg              => $this->{-bg},
        -fg              => $this->{-fg},
    )->focus;    
    # Selecting a date may bring the focus to the OK button.
    $calendar->set_routine('date-select', sub{
        my $cal = shift;
	$cal->date_select;
	$cal->parent->getobj('buttons')->{-selected} = 0;
	$cal->loose_focus;
    });
    # Doubleclick on calendar may close the dialog.
    if ( $Curses::UI::ncurses_mouse ) {
	$calendar->set_mouse_binding(sub {
	    my $buttons = shift();
	    my @extra = @_;
	    my $this = $buttons->parent;
	    $buttons->do_routine('mouse-button', @extra);
	    $this->{-selected_date} = $this->getobj('calendar')->get;
	    $this->loose_focus;
	}, BUTTON1_DOUBLE_CLICKED());
    }
    # Escape should close the dialog, without setting a date.
    $this->set_binding(sub {
        my $this = shift;
	$this->{-selected_date} = undef;
	$this->loose_focus;
    }, CUI_ESCAPE());
    $this->layout();
    return bless $this, $class;
}
sub layout()
{
    my $this = shift;
        my $cal = $this->getobj('calendar');
        if ($cal) {
        $this->{-width} = width_by_windowscrwidth(
                    $this->getobj('calendar')->{-width}, %$this);
        $this->{-height} = height_by_windowscrheight(
                    $this->getobj('calendar')->{-height}, %$this);
    }
    $this->SUPER::layout() or return;
    return $this;
}
sub get()
{
    my $this = shift;
lib/Curses/UI/Dialog/Calendar.pm view on Meta::CPAN
}
sub press_button_callback()
{
    my $buttons = shift;
    my $this = $buttons->parent;
    my $ok_pressed = $buttons->get;
    if ($ok_pressed)
    {
        $this->{-selected_date} = $this->getobj('calendar')->get;
    } else {
        $this->{-selected_date} = undef;
    }
    $this->loose_focus;
}
1;
=pod
=head1 NAME
Curses::UI::Dialog::Calendar - Create and manipulate calendar dialogs
=head1 CLASS HIERARCHY
 Curses::UI::Widget
    |
    +----Curses::UI::Container
            |
            +----Curses::UI::Window
                    |
                    +----Curses::UI::Dialog::Calendar
lib/Curses/UI/Dialog/Calendar.pm view on Meta::CPAN
    # -------------
    my $dialog = $win->add(
        'mydialog', 'Dialog::Calendar'
    );
    $dialog->modalfocus;
    $win->delete('mydialog');
    my $date = $dialog->get();
    # The easy way (see Curses::UI documentation).
    # --------------------------------------------
    $date = $cui->calendardialog();
=head1 DESCRIPTION
Curses::UI::Dialog::Calendar is a calendar dialog. 
This type of dialog can be used to select a date.
See exampes/demo-widgets in the distribution for a short demo.
=head1 OPTIONS
=over 4
lib/Curses/UI/Dialog/Calendar.pm view on Meta::CPAN
=back
=head1 SPECIAL BINDINGS
=over 4
=item * B<escape>
This will invoke the cancel button, so the calendar dialog
returns without selecting any date.
=back
=head1 SEE ALSO
L<Curses::UI|Curses::UI>, 
L<Curses::UI::Container|Curses::UI::Container>,