Curses-UI

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

		  the dialog.

                - Removed screenheight tampering from 
		  Curses::UI::Widget->windowparameters() which was
		  used for automatically reserving space for the
		  menubar if the application had one. Now I 
		  have moved this responsibility to the user.
                  The user should use "-padtop => <value>" if a 
		  window should not overlap the menubar. This will
		  let Window centering be real Window centering. This
		  also makes it possible to create a "popup"
		  menubar by letting the main windows draw over
		  the menubar (the menubar will only be visible
		  if it gets the focus).

                - Widgets now can focus another widget using their
		  event callback routines. Before, the widget would
		  always go to the next or previous widget, but now
		  loose_focus() won't do this if the focus is not on 
		  the widget itself anymore. I'm not sure if it works
		  for all widgets already, but I needed it to be

Changes  view on Meta::CPAN

                - The buttonbox will handle the TAB key different
		  than before. Now it will cycle through the buttons.
		  If the last button is selected and TAB is pressed,
		  the total Buttonbox will loose focus. This is much
		  more like the behaviour that a user would expect. 

                - Fixed a layout bug in Dialog::Basic (if the buttonwidth
		  was larger than the messagewidth, a 'screen not large
		  enough' error would show).

                - Fixed a bug in FileBrowser.pm. The popupbox in the
		  FileBrowser window was still built for the old
		  event system. Now it has an -onchange event which
		  reloads the file list. Also, the focus will not
		  longer go to the buttons, but to the filelistbox
		  or the fileentry field if -editfilename is set
		  to a true value.

2002-01-26      - Reading keys is not done anymore using the halfdelay
                  function of curses. Now a select() call is used to
		  determine if there is input waiting.

Changes  view on Meta::CPAN

		  otherwise use die() (or one of its Carp friends).

                - Moved usemodule() from the Container package to
		  Curses::UI. This method now honours the %INC
		  hash, which means less on-the-fly loading of
		  modules will occur.

                - Made searching through listboxes and textviewers
		  possible in the new event system.

                - Fixed some -onchange event bugs in popupmenu.

till 2002-01-24 - The complete event structure is set upside-down.
                  By using this new event structure, timed routines
                  and mouse events are possibilities. Maybe even
                  integration with POE! :-) (but I haven't looked
                  into that enough to be sure). We also have a 
		  Tk-like mainloop() now.

                - Updated a lot of widgets to support the new event
                  structure (central mainloop in Curses::UI which

examples/demo-widgets  view on Meta::CPAN


# ----------------------------------------------------------------------
# Popupmenu
# ----------------------------------------------------------------------

$w{6}->add(
    undef, 'Label',
    -text => "The popmenu is much like a standard listbox. The difference is\n"
           . "that only the currently selected value is visible (or ---- if\n"
	   . "no value is yet selected). The list of possible values will be\n"
	   . "shown as a separate popup windows if requested.\n"
	   . "Press <ENTER> or <CURSOR-RIGHT> to open the popupbox and use\n"
	   . "those same keys to select a value (or use <CURSOR-LEFT> to close\n"
	   . "the popup listbox without selecting a value from it). Press\n"
	   . "</> in the popup for a 'less'-like search through the list."
);

$w{6}->add(
    undef, 'Popupmenu',
    -y          => 9,
    -values     => $values,
    -labels     => $labels,
    -width      => 20,
    -onchange   => sub {
        my $pm = shift;
	my $lbl = $pm->parent->getobj('popupmenulabel');
	my $val = $pm->get;
	$val = "<undef>" unless defined $val;
	my $lab = $pm->{-labels}->{$val};
	$val .= " (label = '$lab')" if defined $lab;
	$lbl->text($val);
	$lbl->draw;
    },
);

$w{6}->add(
    undef, 'Label', -y => 9, -x => 21,
    -text       => "--- selected --->"
);

$w{6}->add(
    'popupmenulabel', 'Label',
    -y => 9, -x => 39, -width => -1,
    -bold => 1,
    -text       => "none"
);

# ----------------------------------------------------------------------
# Progressbar
# ----------------------------------------------------------------------

$w{7}->add( 

lib/Curses/UI/Dialog/Filebrowser.pm  view on Meta::CPAN

save to. By default this option is set to false.

=item * B<-show_hidden> < BOOLEAN >

If BOOLEAN has a true value, hidden files (the filename
starts with a dot) will also be shown. By default this
option is set to false.

=item * B<-mask> < ARRAYREF >

If B<-mask> is defined, a filemask popupbox will be added
to the filebrowser dialog window. This popupbox will filter
the list of files that is displayed, using a regular expression
(case insensitive). The ARRAYREF contains a list of array 
references. Each array reference has two elements: a regexp and 
a description. Here's an example B<-mask>:

    my $mask = [
        [ '.',        'All files (*)'       ],
        [ '\.txt$',   'Text files (*.txt)'  ]
        [ 'howto',    'HOWTO documentation' ],
        [ 'core',     'Core files'          ],

lib/Curses/UI/Popupmenu.pm  view on Meta::CPAN

);

$VERSION = '1.10';

@ISA = qw(
    Curses::UI::Widget 
);

my %routines = (
    'loose-focus'    => \&loose_focus,
    'open-popup'     => \&open_popup,
    'select-next'    => \&select_next,
    'select-prev'    => \&select_prev,
    'mouse-button1'  => \&mouse_button1,
);

my %bindings = (
    CUI_TAB()        => 'loose-focus',
    KEY_BTAB()       => 'loose-focus',
    KEY_ENTER()      => 'open-popup',
    KEY_RIGHT()      => 'open-popup',
    "l"              => 'open-popup',
    CUI_SPACE()      => 'open-popup',
    KEY_DOWN()       => 'select-next',
    "j"              => 'select-next',
    KEY_UP()         => 'select-prev',
    "k"              => 'select-prev',
);

sub new ()
{
    my $class = shift;

lib/Curses/UI/Popupmenu.pm  view on Meta::CPAN

    $this->{-canvasscr}->move(0,$this->canvaswidth-1);
    $this->{-canvasscr}->attroff(A_DIM);
    $this->{-canvasscr}->attroff(A_REVERSE);

    $this->{-canvasscr}->noutrefresh;
    doupdate() unless $no_doupdate;;

    return $this;
}

sub open_popup()
{
    my $this = shift;
    my $pre_value = $this->get;

    my %listbox_options = %{$this->{-listbox}};
    foreach my $option (qw(
	-values -labels 
	-selected -wraparound
    )) {    
        $listbox_options{$option} = $this->{$option}
            if defined $this->{$option};
    }

    my $id = '__popupmenu_listbox_$this';
    my $listbox = $this->root->add(
	$id, 'PopupmenuListbox',
        -border         => 1,
        -vscrollbar     => 1,
        %listbox_options
    );

    $listbox->modalfocus;

    my $post_value = $listbox->get;

lib/Curses/UI/Popupmenu.pm  view on Meta::CPAN

sub mouse_button1($$$;)
{
    my $this  = shift;
    my $event = shift;
    my $x     = shift;
    my $y     = shift;

    unless ($this->{-focus}) {
        $this->focus;
    }
    $this->open_popup;
}


1;


=pod

=head1 NAME

Curses::UI::Popupmenu - Create and manipulate popupbox widgets

=head1 CLASS HIERARCHY

 Curses::UI::Widget
    |
    +----Curses::UI::Popupmenu


=head1 SYNOPSIS

    use Curses::UI;
    my $cui = new Curses::UI;
    my $win = $cui->add('window_id', 'Window');

    my $popupbox = $win->add(
        'mypopupbox', 'Popupmenu',
        -values    => [1, 2, 3],
        -labels    => { 1 => 'One', 
                        2 => 'Two', 
                        3 => 'Three' },
    );

    $popupbox->focus();
    my $value = $popupbox->get();


=head1 DESCRIPTION

Curses::UI::Popupmenu is a widget that can be used to create 
something very similar to a basic L<Curses::UI::Listbox|Curses::UI::Listbox>.
The difference is that the widget will show only the
currently selected value (or "-------" if no value is yet
selected). The list of possible values will be shown as a 
separate popup window if requested. 

Normally the widget will look something like this:

 [Current value ]

If the popup window is opened, it looks something like this:


 [Current value ]
 +--------------+
 |Other value   |
 |Current value | 
 |Third value   |
 +--------------+


lib/Curses/UI/Popupmenu.pm  view on Meta::CPAN

=item * B<-selected> < INDEX >

=item * B<-wraparound> < BOOLEAN >

These options are exactly the same as the options for
the Listbox widget. So for an explanation of these,
take a look at L<Curses::UI::Listbox|Curses::UI::Listbox>.

=item * B<-onchange> < CODEREF >

This sets the onChange event handler for the popupmenu widget.
If a new item is selected, the code in CODEREF will be executed.
It will get the widget reference as its argument.


=back




=head1 METHODS

lib/Curses/UI/Popupmenu.pm  view on Meta::CPAN

These are standard methods. See L<Curses::UI::Widget|Curses::UI::Widget> 
for an explanation of these.

=item * B<get> ( )

This method will return the currently selected value.

=item * B<onChange> ( CODEREF )

This method can be used to set the B<-onchange> event handler
(see above) after initialization of the popupmenu. 

=back




=head1 DEFAULT BINDINGS

There are bindings for the widget itself and bindings
for the popup listbox that can be opened by this widget.

=head2 The widget itself

=over 4

=item * <B<tab>>

Call the 'loose-focus' routine. This will have the widget 
loose its focus.

=item * <B<enter>>, <B<cursor-right>, <B<l>>, <B<space>>

Call the 'open-popup' routine. This will show the 
popup listbox and bring the focus to this listbox. See
B<The popup listbox> below for a description of the bindings 
for this listbox.

=item * <B<cursor-down>>, <B<j>>

Call the 'select-next' routine. This will select the 
item in the list that is after the currently selected
item (unless the last item is already selected). If 
no item is selected, the first item in the list will
get selected. 

=item * <B<cursor-up>>, <B<k>>

Call the 'select-prev' routine. This will select the 
item in the list that is before the currently selected
item (unless the first item is already selected). If 
no item is selected, the first item in the list will
get selected. 

=back 

=head2 The popup listbox

The bindings for the popup listbox are the same as the bindings
for the Listbox widget. So take a look at 
L<Curses::UI::Listbox|Curses::UI::Listbox> for a description
of these. The difference is that the 'loose-focus' and 'option-select'
routine will have the popup listbox to close. If the routine
'option-select' is called, the active item will get selected.


=head1 SEE ALSO

L<Curses::UI>, 
L<Curses::UI::Listbox>
L<Curses::UI::Widget>, 
L<Curses::UI::Common>

lib/Curses/UI/Widget.pm  view on Meta::CPAN


Each widget can be drawn with or without a border. To enable
the border use a true value and to disable it use a 
false value for BOOLEAN. The default is not to use a border.

=item * B<-sbborder> < BOOLEAN >

If no border is used, a square bracket border may be used.
This is a border which is constructed from '[' and ']' 
characters. This type of border is especially useful for 
single line widgets (like text entries and popup boxes).
A square bracket border can only be enabled if -border 
is false. The default is not to use a square bracket border.

=back



=head2 POSITIONING:

 +---------------------------------------------------+



( run in 1.404 second using v1.01-cache-2.11-cpan-364913b4093 )