plucky (3) Curses::UI::Notebook.3pm.gz

Provided by: libcurses-ui-perl_0.9609-1.1_all bug

NAME

       Curses::UI::Notebook - Create and manipulate notebook widgets.

CLASS HIERARCHY

        Curses::UI::Widget
           |
           +----Curses::UI::Container
                   |
                   +----Curses::UI::Notebook

SYNOPSIS

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

           my $notebook = $win->add(undef, 'Notebook');
           my $page1 = $notebook->add_page('page 1');
           $page1->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #1.",
           );
           my $page2 = $notebook->add_page('page 2');
           $page2->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #2.",
           );
           my $page3 = $notebook->add_page('page 3', -on_activate => \&sub );
           $page3->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #3.",
           );
           $notebook->focus;
           $cui->mainloop;

DESCRIPTION

       This package implements a notebook widget similar to that found in Motif.  A notebook holds several
       windows, or pages, only one of which is visible at any given time; tabs at the top of the widget list the
       pages that are available.  In this way, a great deal of information can be fit into a relatively small
       screen area.  [Windows users might recognize this as a tabbed dialog.]

STANDARD OPTIONS

       -x, -y, -width, -height, -pad, -padleft, -padright, -padtop, -padbottom, -ipad, -ipadleft, -ipadright,
       -ipadtop, -ipadbottom, -border, -sbborder, -bg, -fg, -intellidraw, -onchange, -onblur.

       See Curses::UI::Widget for a discussion of each of these options.

       Note that -border is enabled and both -ipadleft and -ipadright are set to 1 by default when creating
       notebook objects.

WIDGET-SPECIFIC OPTIONS

-bindings < HASHREF >

           The keys in this hash reference are keystrokes and the values are routines to which they should be
           bound.  In the event a key is empty, the corresponding routine will become the default routine that
           process_bindings applies to unmatched keystrokes it receives.

           By default, the following mappings are used:

               KEY                 ROUTINE
               ------------------  ----------
               KEY_HOME, Ctrl-A    first_page
               KEY_END, Ctrl-E     last_page
               KEY_NPAGE, Ctrl-N   next_page
               KEY_PPAGE, Ctrl-P   prev_page

       •   -routines < HASHREF >

           The keys in this hash reference are routines and the values are either scalar values or code
           references.  process_bindings maps keystrokes to routines and then to either a scalar value, which it
           returns, or a code reference, which it executes.

           By default, the following mappings are used:

               ROUTINE         ACTION
               ----------      -------------------------
               first_page      make first page active
               last_page       make last page active
               next_page       make next page active
               prev_page       make previous page active

       •   -wraparound < BOOLEAN >

           If BOOLEAN has a true value, wraparound is enabled.  This means that advancing to the next page will
           cycle from the last back to the first page and similarly, advancing to the previous page will cycle
           from the first back to the last page.

           By default, it is true.

METHODS

new ( OPTIONS )

           Constructs a new notebook object using options in the hash OPTIONS.

       •   layout ( )

           Lays out the notebook object, makes sure it fits on the available screen, and creates the curses
           windows for the border / tab labels as well as the effective drawing area.

       •   draw ( BOOLEAN )

           Draws the notebook object along with the active page's window. If BOOLEAN is true, the screen is not
           updated after drawing.

           By default, BOOLEAN is true so the screen is updated.

       •   intellidraw ( )

       •   focus ( )

       •   onFocus ( CODEREF )

       •   onBlur ( CODEREF )

           See Curses::UI::Widget for explanations of these methods.

       •   add_page ( PAGE [ , -on_activate => sub_ref ] [, -on_delete => ] )

           Adds the specified page to the notebook object and creates an associated window object.  Returns the
           window object or undef on failure.

           Note: the add fails if the page would otherwise cause the tab window to overflow or is already part
           of the notebook object.

           The "-on_activate" parameter specifies an optional call-back that will be invoked when the page is
           activated. This call-back will be called with the notebook widget and page name as parameter.

           Likewise for "-on_delete" call-back. This one is invoked when the page is deleted.

       •   delete_page ( PAGE )

           Deletes the specified page from the notebook object and destroys its associated window object.  If
           the page was active, the first page is made active.

       •   active_page ( )

           Returns the currently active page in the notebook object.

       •   first_page ( )

           Returns the first page in the notebook object.

       •   last_page ( )

           Returns the last page in the notebook object.

       •   prev_page ( )

           Returns the previous page in the notebook object.

       •   next_page ( )

           Returns the next page in the notebook object.

       •   activate_page ( PAGE )

           Makes the specified page in the notebook object active and returns it, redrawing the notebook object
           in the process.

       •   mouse_button1 ( )

           Processes mouse button #1 clicks.  If the user left-clicks on one of the tabs, activate_page is
           called with the corresponding page to make it active; otherwise, the click is passed along to the
           active window.

SEE ALSO

       Curses::UI, Curses::UI::Container, Curses::UI::Widget

AUTHOR

       George A. Theall, <theall@tifaware.com>

       Copyright (c) 2004, George A. Theall. All rights reserved.

       This script is free software; you can redistribute it and/or modify it under the same terms as Perl
       itself.