The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tickit::Widget::Frame - draw a frame around another widget

SYNOPSIS

 use Tickit;
 use Tickit::Widget::Frame;
 use Tickit::Widget::Static;
 
 my $tickit = Tickit->new;
 
 my $hello = Tickit::Widget::Static->new(
    text   => "Hello, world",
    align  => "centre",
    valign => "middle",
 );

 my $frame = Tickit::Widget::Frame->new;

 $frame->add( $hello );
 
 $tickit->set_root_widget( $frame );
 
 $tickit->run;

DESCRIPTION

This container widget draws a frame around a single child widget.

CONSTRUCTOR

$frame = Tickit::Widget::Frame->new( %args )

Constructs a new Tickit::Widget::Static object.

Takes the following named arguments in addition to those taken by the base Tickit::SingleChildWidget constructor:

style => STRING

Optional. Defaults to ascii if unspecified.

title => STRING

Optional.

title_align => FLOAT|STRING

Optional. Defaults to 0.0 if unspecified.

For more details see the accessors below.

ACCESSORS

$style = $frame->style

$frame->style( $style )

Accessor for the style property, which controls the way the actual frame is drawn around the inner widget. Must be one of the following names:

 ascii single double thick solid_inside solid_outside

The ascii style is default, and uses only the -|+ ASCII characters. Other styles use Unicode box-drawing characters. These may not be supported by all terminals or fonts.

$frame_pen = $widget->frame_pen

Returns the current frame pen. Modifying an attribute of the returned object results in the widget being redrawn if the widget has a window associated.

$widget->set_frame_pen( $pen )

Set a new Tickit::Pen object. This is stored by reference; changes to the pen will be reflected in the rendered look of the frame. The same pen may be shared by more than one widget; updates will affect them all.

$title = $frame->title

$frame->title( $title )

Accessor for the title property, a string written in the top of the frame.

$title_align = $frame->title_align

$frame->set_title_align( $title_align )

Accessor for the title_align property. Gives a vlaue in the range 0.0 to 1.0 to align the title in the top of the frame.

See also Tickit::WidgetRole::Alignable.

TODO

  • Specific pen for title. Layered on top of frame pen.

  • Caption at the bottom of the frame as well. Identical to title.

  • Consider if it's useful to provide accessors to apply extra padding inside the frame, surrounding the child window.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>