1Curses::UI::Notebook(3)User Contributed Perl DocumentatioCnurses::UI::Notebook(3)
2
3
4
6 Curses::UI::Notebook - Create and manipulate notebook widgets.
7
9 Curses::UI::Widget
10 |
11 +----Curses::UI::Container
12 |
13 +----Curses::UI::Notebook
14
16 use Curses::UI;
17 my $cui = new Curses::UI;
18 my $win = $cui->add(undef, 'Window');
19
20 my $notebook = $win->add(undef, 'Notebook');
21 my $page1 = $notebook->add_page('page 1');
22 $page1->add(
23 undef, 'Label',
24 -x => 15,
25 -y => 6,
26 -text => "Page #1.",
27 );
28 my $page2 = $notebook->add_page('page 2');
29 $page2->add(
30 undef, 'Label',
31 -x => 15,
32 -y => 6,
33 -text => "Page #2.",
34 );
35 my $page3 = $notebook->add_page('page 3', -on_activate => \&sub );
36 $page3->add(
37 undef, 'Label',
38 -x => 15,
39 -y => 6,
40 -text => "Page #3.",
41 );
42 $notebook->focus;
43 $cui->mainloop;
44
46 This package implements a notebook widget similar to that found in
47 Motif. A notebook holds several windows, or pages, only one of which
48 is visible at any given time; tabs at the top of the widget list the
49 pages that are available. In this way, a great deal of information can
50 be fit into a relatively small screen area. [Windows users might
51 recognize this as a tabbed dialog.]
52
54 -x, -y, -width, -height, -pad, -padleft, -padright, -padtop,
55 -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom,
56 -border, -sbborder, -bg, -fg, -intellidraw, -onchange, -onblur.
57
58 See Curses::UI::Widget for a discussion of each of these options.
59
60 Note that -border is enabled and both -ipadleft and -ipadright are set
61 to 1 by default when creating notebook objects.
62
64 · -bindings < HASHREF >
65
66 The keys in this hash reference are keystrokes and the values are
67 routines to which they should be bound. In the event a key is
68 empty, the corresponding routine will become the default routine
69 that process_bindings applies to unmatched keystrokes it receives.
70
71 By default, the following mappings are used:
72
73 KEY ROUTINE
74 ------------------ ----------
75 KEY_HOME, Ctrl-A first_page
76 KEY_END, Ctrl-E last_page
77 KEY_NPAGE, Ctrl-N next_page
78 KEY_PPAGE, Ctrl-P prev_page
79
80 · -routines < HASHREF >
81
82 The keys in this hash reference are routines and the values are
83 either scalar values or code references. process_bindings maps
84 keystrokes to routines and then to either a scalar value, which it
85 returns, or a code reference, which it executes.
86
87 By default, the following mappings are used:
88
89 ROUTINE ACTION
90 ---------- -------------------------
91 first_page make first page active
92 last_page make last page active
93 next_page make next page active
94 prev_page make previous page active
95
96 · -wraparound < BOOLEAN >
97
98 If BOOLEAN has a true value, wraparound is enabled. This means
99 that advancing to the next page will cycle from the last back to
100 the first page and similarly, advancing to the previous page will
101 cycle from the first back to the last page.
102
103 By default, it is true.
104
106 · new ( OPTIONS )
107
108 Constructs a new notebook object using options in the hash OPTIONS.
109
110 · layout ( )
111
112 Lays out the notebook object, makes sure it fits on the available
113 screen, and creates the curses windows for the border / tab labels
114 as well as the effective drawing area.
115
116 · draw ( BOOLEAN )
117
118 Draws the notebook object along with the active page's window. If
119 BOOLEAN is true, the screen is not updated after drawing.
120
121 By default, BOOLEAN is true so the screen is updated.
122
123 · intellidraw ( )
124
125 · focus ( )
126
127 · onFocus ( CODEREF )
128
129 · onBlur ( CODEREF )
130
131 See Curses::UI::Widget for explanations of these methods.
132
133 · add_page ( PAGE [ , -on_activate => sub_ref ] [, -on_delete => ] )
134
135 Adds the specified page to the notebook object and creates an
136 associated window object. Returns the window object or undef on
137 failure.
138
139 Note: the add fails if the page would otherwise cause the tab
140 window to overflow or is already part of the notebook object.
141
142 The "-on_activate" parameter specifies an optional call-back that
143 will be invoked when the page is activated. This call-back will be
144 called with the notebook widget and page name as parameter.
145
146 Likewise for "-on_delete" call-back. This one is invoked when the
147 page is deleted.
148
149 · delete_page ( PAGE )
150
151 Deletes the specified page from the notebook object and destroys
152 its associated window object. If the page was active, the first
153 page is made active.
154
155 · active_page ( )
156
157 Returns the currently active page in the notebook object.
158
159 · first_page ( )
160
161 Returns the first page in the notebook object.
162
163 · last_page ( )
164
165 Returns the last page in the notebook object.
166
167 · prev_page ( )
168
169 Returns the previous page in the notebook object.
170
171 · next_page ( )
172
173 Returns the next page in the notebook object.
174
175 · activate_page ( PAGE )
176
177 Makes the specified page in the notebook object active and returns
178 it, redrawing the notebook object in the process.
179
180 · mouse_button1 ( )
181
182 Processes mouse button #1 clicks. If the user left-clicks on one
183 of the tabs, activate_page is called with the corresponding page to
184 make it active; otherwise, the click is passed along to the active
185 window.
186
188 Curses::UI, Curses::UI::Container, Curses::UI::Widget
189
191 George A. Theall, <theall@tifaware.com>
192
194 Copyright (c) 2004, George A. Theall. All rights reserved.
195
196 This script is free software; you can redistribute it and/or modify it
197 under the same terms as Perl itself.
198
199
200
201perl v5.32.0 2020-07-28 Curses::UI::Notebook(3)