1Curses::UI::Container(3U)ser Contributed Perl DocumentatiCounrses::UI::Container(3)
2
3
4
6 Curses::UI::Container - Create and manipulate container widgets
7
9 Curses::UI::Widget
10 |
11 +----Curses::UI::Container
12
14 use Curses::UI;
15 my $cui = new Curses::UI;
16 my $win = $cui->add('window_id', 'Window');
17
18 my $container = $win->add(
19 'mycontainer', 'Container'
20 );
21
22 $container->add(
23 'contained', 'SomeWidget',
24 .....
25 );
26
27 $container->focus();
28
30 A container provides an easy way of managing multiple widgets in a
31 single "form". A lot of Curses::UI functionality is built around
32 containers. The main class Curses::UI itself is a container. A
33 Curses::UI::Window is a container. Some of the widgets are implemented
34 as containers.
35
37 -parent, -x, -y, -width, -height, -pad, -padleft, -padright, -padtop,
38 -padbottom, -ipad, -ipadleft, -ipadright, -ipadtop, -ipadbottom,
39 -title, -titlefullwidth, -titlereverse, -onfocus, -onblur
40
41 For an explanation of these standard options, see Curses::UI::Widget.
42
44 · -releasefocus
45
46 If this option is set, the widgets inside this Container will be
47 part of the focus ordering of the parent widget. This means that
48 when this Container gets the focus, its first widget will be
49 focused. When the focus leaves the last widget inside the
50 Container it will give the focus back to the parent instead of
51 cycling back to the first widget in this Container. This option is
52 useful to create a sub-class packed with common used widgets,
53 making the reuse easier.
54
56 · new ( )
57
58 Create a new instance of the Curses::UI::Container class.
59
60 · add ( ID, CLASS, OPTIONS )
61
62 This is the main method for this class. Using this method it is
63 easy to add widgets to the container.
64
65 The ID is an identifier that you want to use for the added widget.
66 This may be any string you want. If you do not need an ID, you may
67 also us an undefined value. The container will automatically create
68 an ID for you.
69
70 The CLASS is the class which you want to add to the container. If
71 CLASS does not contain '::' or CLASS matches 'Dialog::...' then
72 'Curses::UI' will be prepended to it. This way you do not have to
73 specifiy the full class name for widgets that are in the Curses::UI
74 hierarchy. It is not necessary to call "use CLASS" yourself. The
75 add method will call the usemodule method from Curses::UI to
76 automatically load the module.
77
78 The hash OPTIONS contains the options that you want to pass on to
79 the new instance of CLASS.
80
81 Example:
82
83 $container->add(
84 'myid', # ID
85 'Label', # CLASS
86 -text => 'Hello, world!', # OPTIONS
87 -x => 10,
88 -y => 5,
89 );
90
91 · delete ( ID )
92
93 This method deletes the contained widget with the given ID from the
94 container.
95
96 · hasa ( CLASS )
97
98 This method returns true if the container contains one or more
99 widgets of the class CLASS.
100
101 · layout ( )
102
103 Layout the Container and all its contained widgets.
104
105 · draw ( BOOLEAN )
106
107 Draw the Container and all its contained widgets.
108 If BOOLEAN is true, the screen will not update after drawing. By
109 default this argument is false, so the screen will update after
110 drawing the container.
111
112 · intellidraw ( )
113
114 See Curses::UI::Widget for an explanation of this method.
115
116 · focus ( )
117
118 If the container contains no widgets, this routine will return
119 immediately. Else the container will get focus.
120
121 If the container gets focus, one of the contained widgets will get
122 the focus. The returnvalue of this widget determines what has to be
123 done next. Here are the possible cases:
124
125 * The returnvalue is LEAVE_CONTAINER
126
127 As soon as a widget returns this value, the container
128 will loose its focus and return the returnvalue and the
129 last pressed key to the caller.
130
131 * The returnvalue is STAY_AT_FOCUSPOSITION
132
133 The container will not loose focus and the focus will stay
134 at the same widget of the container.
135
136 * Any other returnvalue
137
138 The focus will go to the next widget in the container.
139
140 · getobj ( ID )
141
142 This method returns the object reference of the contained widget
143 with the given ID.
144
145 · getfocusobj ( )
146
147 This method returns the object reference of the contained widget
148 which currently has the focus.
149
150 · set_focusorder ( IDLIST )
151
152 Normally the order in which widgets get focused in a container is
153 determined by the order in which they are added to the container.
154 Use set_focusorder if you want a different focus order. IDLIST
155 contains a list of id's.
156
157 · set_draworder ( IDLIST )
158
159 Normally the order in which widgets are drawn in a container is
160 determined by the order in which they are added to the container.
161 Use set_draworder if you want a different draw order. IDLIST
162 contains a list of id's.
163
164 · loadmodule ( CLASS )
165
166 This will load the module for the CLASS. If loading fails, the
167 program will die.
168
169 · onFocus ( CODEREF )
170
171 This method can be used to set the -onfocus event handler (see
172 above) after initialization of the widget.
173
174 · onBlur ( CODEREF )
175
176 This method can be used to set the -onblur event handler (see
177 above) after initialization of the widget.
178
180 Since interacting is not handled by the container itself, but by the
181 contained widgets, this class does not have any key bindings.
182
184 Curses::UI,
185
187 Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
188
189 Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
190
191 This package is free software and is provided "as is" without express
192 or implied warranty. It may be used, redistributed and/or modified
193 under the same terms as perl itself.
194
195
196
197perl v5.28.0 2011-09-01 Curses::UI::Container(3)