Curses::UI::Notebook - Create and manipulate notebook widgets.
Curses::UI::Widget | +----Curses::UI::Container | +----Curses::UI::Notebook
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;
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.]
-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.
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
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
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.
Constructs a new notebook object using options in the hash OPTIONS.
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.
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.
See Curses::UI::Widget for explanations of these methods.
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.
-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.
-on_delete call-back. This one is invoked when the page is deleted.
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.
Returns the currently active page in the notebook object.
Returns the first page in the notebook object.
Returns the last page in the notebook object.
Returns the previous page in the notebook object.
Returns the next page in the notebook object.
Makes the specified page in the notebook object active and returns it, redrawing the notebook object in the process.
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.
George A. Theall, <firstname.lastname@example.org>
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.