The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Curses::UI::Number - Create and manipulate number widgets.

CLASS HIERARCHY

 Curses::UI::Widget
    |
    +----Curses::UI::Label
            |
            +----Curses::UI::Number

SYNOPSIS

 use Curses::UI;

 my $win = $cui->add('window_id', 'Window');
 my $number = $win->add(
         'mynum', 'Curses::UI::Number',
         -num => 5,
 );
 $number->draw;

DESCRIPTION

Curses::UI::Number is a widget that shows a number in graphic form.

STANDARD OPTIONS

-parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop, -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom, -title, -titlefullwidth, -titlereverse, -onfocus, -onblur.

For an explanation of these standard options, see Curses::UI::Widget.

REMOVED OPTIONS

-text.

WIDGET-SPECIFIC OPTIONS

  • -num < NUMBER >

     Number.
     Default value is undef.
  • -char < CHARACTER >

     Character for Curses::UI::Number drawing.
     Default value is '█'.

STANDARD METHODS

layout, draw, intellidraw, focus, onFocus, onBlur.

For an explanation of these standard methods, see Curses::UI::Widget.

WIDGET-SPECIFIC METHODS

  • new(%parameters)

     Constructor.
     Create widget with volume in graphic form, defined by -volume number.
     Returns object.
  • num([$number])

     Get or set number.
     Returns number (0 - 9).

EXAMPLE1

 use strict;
 use warnings;

 use Curses::UI;

 # Object.
 my $cui = Curses::UI->new;
 
 # Main window.
 my $win = $cui->add('window_id', 'Window');
 
 # Add volume.
 $win->add(
         undef, 'Curses::UI::Number',
         '-num' => 5,
 );
 
 # Binding for quit.
 $win->set_binding(\&exit, "\cQ", "\cC");
 
 # Loop.
 $cui->mainloop;

 # Output like:
 # ██████
 # ██
 # ██████
 #     ██
 # ██████

EXAMPLE2

 use strict;
 use warnings;

 use Curses::UI;

 # Object.
 my $cui = Curses::UI->new(
         -color_support => 1,
 );
 
 # Main window.
 my $win = $cui->add('window_id', 'Window');

 # Add number.
 my $num = $win->add(
         undef, 'Curses::UI::Number',
         '-border' => 1,
         '-num' => 0,
 );
 
 # Binding for quit.
 $win->set_binding(\&exit, "\cQ", "\cC");

 # Time.
 $cui->set_timer(
         'timer',
         sub {
                 my $act = $num->num;
                 $act += 1;
                 if ($act > 9) {
                         $act = 0;
                 }
                 $num->num($act);
                 return;
         },
         1,
 );
 
 # Loop.
 $cui->mainloop;

 # Output like:
 # ┌──────┐
 # │██████│
 # │██  ██│
 # │██████│
 # │██  ██│
 # │██████│
 # └──────┘

DEPENDENCIES

Curses::UI::Common, Curses::UI::Label, Curses::UI::Widget, Unicode::UTF8.

SEE ALSO

Task::Curses::UI

Install the Curses::UI modules.

REPOSITORY

https://github.com/michal-josef-spacek/Curses-UI-Number

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2014-2015 Michal Josef Špaček

BSD 2-Clause License

DEDICATION

To Czech Perl Workshop 2014 and their organizers.

VERSION

0.07