CLASS HIERARCHY

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

SYNOPSIS

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

my $container = $win->add( 'mycontainer', 'Container' );

$container->add( 'contained', 'SomeWidget', ..... );

$container->focus();

DESCRIPTION

A container provides an easy way of managing multiple widgets in a single \*(L"form\*(R". A lot of Curses::UI functionality is built around containers. The main class Curses::UI itself is a container. A Curses::UI::Window is a container. Some of the widgets are implemented as containers.

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.

WIDGET-SPECIFIC OPTIONS

  • -releasefocus If this option is set, the widgets inside this Container will be part of the focus ordering of the parent widget. This means that when this Container gets the focus, its first widget will be focused. When the focus leaves the last widget inside the Container it will give the focus back to the parent instead of cycling back to the first widget in this Container. This option is useful to create a sub-class packed with common used widgets, making the reuse easier.

METHODS

  • new ( ) Create a new instance of the Curses::UI::Container class.

  • add ( \s-1ID\s0, \s-1CLASS\s0, \s-1OPTIONS\s0 ) This is the main method for this class. Using this method it is easy to add widgets to the container. The \s-1ID\s0 is an identifier that you want to use for the added widget. This may be any string you want. If you do not need an \s-1ID\s0, you may also us an undefined value. The container will automatically create an \s-1ID\s0 for you. The \s-1CLASS\s0 is the class which you want to add to the container. If \s-1CLASS\s0 does not contain '::' or \s-1CLASS\s0 matches 'Dialog::...' then 'Curses::UI' will be prepended to it. This way you do not have to specifiy the full class name for widgets that are in the Curses::UI hierarchy. It is not necessary to call \*(L"use \s-1CLASS\s0\*(R" yourself. The add method will call the usemodule method from Curses::UI to automatically load the module. The hash \s-1OPTIONS\s0 contains the options that you want to pass on to the new instance of \s-1CLASS\s0. Example: $container->add( 'myid', # ID 'Label', # CLASS -text => 'Hello, world!', # OPTIONS -x => 10, -y => 5, );

  • delete ( \s-1ID\s0 ) This method deletes the contained widget with the given \s-1ID\s0 from the container.

  • hasa ( \s-1CLASS\s0 ) This method returns true if the container contains one or more widgets of the class \s-1CLASS\s0.

  • layout ( ) Layout the Container and all its contained widgets.

  • draw ( \s-1BOOLEAN\s0 ) Draw the Container and all its contained widgets. If \s-1BOOLEAN\s0 is true, the screen will not update after drawing. By default this argument is false, so the screen will update after drawing the container.

  • intellidraw ( ) See Curses::UI::Widget for an explanation of this method.

  • focus ( ) If the container contains no widgets, this routine will return immediately. Else the container will get focus. If the container gets focus, one of the contained widgets will get the focus. The returnvalue of this widget determines what has to be done next. Here are the possible cases: * The returnvalue is \s-1LEAVE_CONTAINER\s0 As soon as a widget returns this value, the container will loose its focus and return the returnvalue and the last pressed key to the caller. * The returnvalue is \s-1STAY_AT_FOCUSPOSITION\s0 The container will not loose focus and the focus will stay at the same widget of the container. * Any other returnvalue The focus will go to the next widget in the container.

  • getobj ( \s-1ID\s0 ) This method returns the object reference of the contained widget with the given \s-1ID\s0.

  • getfocusobj ( ) This method returns the object reference of the contained widget which currently has the focus.

  • set_focusorder ( \s-1IDLIST\s0 ) Normally the order in which widgets get focused in a container is determined by the order in which they are added to the container. Use set_focusorder if you want a different focus order. \s-1IDLIST\s0 contains a list of id's.

  • set_draworder ( \s-1IDLIST\s0 ) Normally the order in which widgets are drawn in a container is determined by the order in which they are added to the container. Use set_draworder if you want a different draw order. \s-1IDLIST\s0 contains a list of id's.

  • loadmodule ( \s-1CLASS\s0 ) This will load the module for the \s-1CLASS\s0. If loading fails, the program will die.

  • onFocus ( \s-1CODEREF\s0 ) This method can be used to set the -onfocus event handler (see above) after initialization of the widget.

  • onBlur ( \s-1CODEREF\s0 ) This method can be used to set the -onblur event handler (see above) after initialization of the widget.

DEFAULT BINDINGS

Since interacting is not handled by the container itself, but by the contained widgets, this class does not have any key bindings.

RELATED TO Curses::UI::Container…

Curses::UI,

AUTHOR

Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.

Maintained by Marcus Thiesen ([email protected])

This package is free software and is provided \*(L"as is\*(R" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.