Term::Stool::Widget
Term::Stool::WiUser(Contributed Perl DocumeTerm::Stool::Widget(t)



NAME
       Term::Stool::Widget - stool widget

DESCRIPTION
       This is the base class for all widgets in the Slang
       Toolkit.

FIELDS
       Objects of this class may have any number of fields. These
       fields can be read by calling the method with the same
       name as the fie;ds. If a parameter is passed into the
       method, the field is set.

       xoffset
           The x offset of the widget inside its container (if
           any).

       yoffset
           The y offset of the widget inside its container (if
           any).

       width
           The width of the widget.

       height
           The height of the widget.

       container
           The container the widget is inside, if any.

       active
           Set if the widget (or some widget inside it for con-
           tainers) is active. It is set to the actual widget
           that is active.

       activecolor
           The color of the object when it is active. A
           Term::Stool::Color object.

       inactivecolor
           The color of the object when it is inactive. A
           Term::Stool::Color object.

       disabledcolor
           The color of the widget when it is disabled. A
           Term::Stool::Color object.  This is optional. If not
           set, the object just uses the inactivecolor.

       can_focus
           Set if the widget can receive focus.

       disabled
           Set if the widget is disabled. This means it cannot
           focus, and it will be displayed greyed out.

       resize_hook
           This may be set to a subroutine reference. If so, that
           subroutine will be called as a method whenever the
           object is resized.

       keypress_hook
           This may be set to a subroutine reference. If so, that
           subroutine will be called as a method whever this
           object receives a keypress. It will be passed the
           result of SLkp_getkey(). If it handles the keypress,
           it should return a true value.

       activate_hook
           This may be set to a subroutine reference. If so, that
           subroutine will be called as a method whever this
           object becomes activated.

       deactivate_hook
           This may be set to a subroutine reference. If so, that
           subroutine will be called as a method whever this
           object becomes deactivated.

       hidden
           If this is set, the widget is not being displayed,
           because it is hidden for some reason. If set, the dis-
           play method should do nothing.

       align
           This field is a hint used by come containers to lay
           out widgets inside them. Typically set to "left" or
           "right".

METHODS
       new Returns a new object of this class. Optionally, you
           can pass in named parameters that specify the values
           of any fields in the class.

       init
           Called by method new() when an object is created. This
           method can be used to initialize the object without
           having to write a proper new() method.

       decorate_with
           All widgets can have some decorations -- simple wid-
           gets that are displayed at the same time and add to
           the UI experience. This method adds one or more deco-
           rations to a widget -- simply pass in the decoration
           objects.

           TODO: there is currently no way to remove a decora-
           tion, as I have not needed to do so yet. ;-)

       display
           Called when the widget is displayed. This is overrid-
           den in almost every derived class, and all it does in
           this base class is cause all decorations to be dis-
           played as well.

       keypress
           This method is called when the user presses a key and
           the widget is active.  It is passed the result of
           SLkp_getkey().

           First, it will try to deal with the keypress itself.
           (This stub method cannot deal with any.) If it deals
           with a keypress, it should return a true value.

           Failing that, it will ask its container to deal with
           the keypress, and return whatever its container
           returns.

       activate
           Make a widget be active, and then pass the word on to
           its container.

       deactivate
           Make a widget no longer be active, and redraw it. The
           container is not informed, because it is most likely
           going to remain active.

       resize
           This method is called whenever the layout of the
           screen needs to be changed. This method calls the
           function pointed to by the resize_hook field, if any.
           Typically, that function will look at the size of the
           widget's container, and change the element's position
           and size to fit.

       x   This returns the absolute x position of the widget,
           taking into account that it may be inside a container.

       y   This returns the absolute y position of the widget,
           taking into account that it may be inside a container.

       color
           Returns the color of the object, based on whether it
           is active or not, and whether it is disabled.

           If the widget does not define colors for these states,
           use whatever colors its container would use instead.

       AUTOLOAD
           Handles all fields, by creating accessor methods for
           them the first time they are accessed.

       DESTROY
           TODO: I doubt objects cleanly destroy yet, too many
           circular references.
                 Use weak refs?

AUTHOR
       Joey Hess <joey@kitenet.net>



2001-05-23                 perl v5.6.1     Term::Stool::Widget(t)