Alt-Tickit-Widgets-ObjectPad
view release on metacpan or search on metacpan
Build.PL
Changes
examples/demo-border.pl
examples/demo-button.pl
examples/demo-checkbutton.pl
examples/demo-entry.pl
examples/demo-frame.pl
examples/demo-gridbox.pl
examples/demo-hbox.pl
examples/demo-hsplit.pl
examples/demo-radiobutton.pl
examples/demo-spinner.pl
examples/demo-vbox.pl
examples/demo-vsplit.pl
examples/focus.pl
examples/hello-world.pl
examples/HelloWorldWidget-1.pm
t/10static.t
t/11entry-model.t
t/12entry-input.t
t/13entry-scroll.t
t/20button.t
t/21radiobutton.t
t/22checkbutton.t
t/23fill.t
t/24spinner.t
t/30box.t
t/31frame.t
t/32border.t
t/33hbox.t
t/33vbox.t
t/34gridbox.t
t/35hsplit.t
t/35vsplit.t
t/99pod.t
examples/demo-frame.pl view on Meta::CPAN
use Tickit;
use Tickit::Widgets qw( Static VBox Frame );
my $vbox = Tickit::Widget::VBox->new( spacing => 1 );
my $fg = 1;
foreach my $linetype ( qw( ascii single double thick solid_inside solid_outside ) ) {
$vbox->add( Tickit::Widget::Frame->new(
style => {
linetype => $linetype,
frame_fg => $fg++,
},
child => Tickit::Widget::Static->new( text => $linetype, align => 0.5 )
) );
}
$vbox->add( Tickit::Widget::Frame->new(
style => {
linetype_top => "double",
linetype_bottom => "double",
linetype_left => "single",
examples/focus.pl view on Meta::CPAN
Tickit::Style->load_style( <<'EOF' );
Entry:focus {
bg: "blue";
b: 1;
}
Frame {
linetype: "single";
}
Frame:focus-child {
frame-fg: "red";
}
CheckButton:focus {
check-bg: "blue";
}
RadioButton:focus {
tick-bg: "blue";
}
EOF
lib/Tickit/Widget/Frame.pm view on Meta::CPAN
use Tickit::WidgetRole::Alignable name => "title_align";
use Carp;
use Tickit::Pen;
use Tickit::Utils qw( textwidth substrwidth );
use Tickit::RenderBuffer qw( LINE_SINGLE LINE_DOUBLE LINE_THICK CAP_START CAP_END );
=head1 NAME
C<Tickit::Widget::Frame> - draw a frame around another widget
=head1 SYNOPSIS
use Tickit;
use Tickit::Widget::Frame;
use Tickit::Widget::Static;
my $hello = Tickit::Widget::Static->new(
text => "Hello, world",
align => "centre",
valign => "middle",
);
my $frame = Tickit::Widget::Frame->new(
child => $hello,
style => { linetype => "single" },
);
Tickit->new( root => $frame )->run;
=head1 DESCRIPTION
This container widget draws a frame around a single child widget.
=head1 STYLE
The default style pen is used as the widget pen. The following style pen
prefixes are also used:
=over 4
=item frame => PEN
The pen used to render the frame lines
=back
The following style keys are used:
=over 4
=item linetype => STRING
Controls the type of line characters used to draw the frame. Must be one of
the following names:
ascii single double thick solid_inside solid_outside
The C<ascii> linetype is default, and uses only the C<-|+> ASCII characters.
Other linetypes use Unicode box-drawing characters. These may not be supported
by all terminals or fonts.
=item linetype_top => STRING
=item linetype_bottom => STRING
=item linetype_left => STRING
=item linetype_right => STRING
Overrides the C<linetype> attribute for each side of the frame specifically.
If two line-drawing styles meet at corners they should be drawn correctly if
C<Tickit::RenderBuffer> can combine the line segments, but in other
circumstances the corners are drawn as extensions of the top or bottom line,
and the left and right lines do not meet it.
Any edge's linetype may be set to C<none> to cause that edge not to have a
line at all; no extra space will be consumed on that side.
=back
lib/Tickit/Widget/Frame.pm view on Meta::CPAN
linetype => "ascii";
style_redraw_keys qw( linetype linetype_top linetype_bottom linetype_left linetype_right );
use constant WIDGET_PEN_FROM_STYLE => 1;
=head1 CONSTRUCTOR
=cut
=head2 $frame = Tickit::Widget::Frame->new( %args )
Constructs a new C<Tickit::Widget::Static> object.
Takes the following named arguments in addition to those taken by the base
L<Tickit::SingleChildWidget> constructor:
=over 8
=item title => STRING
lib/Tickit/Widget/Frame.pm view on Meta::CPAN
ascii => [ '-', '-', '|', '|', '+', '+', '+', '+' ],
solid_inside => [ map chr, 0x2584, 0x2580, 0x2590, 0x258C, 0x2597, 0x2596, 0x259D, 0x2598 ],
solid_outside => [ map chr, 0x2580, 0x2584, 0x258C, 0x2590, 0x259B, 0x259C, 0x2599, 0x259F ],
);
my %LINESTYLES = (
single => LINE_SINGLE,
double => LINE_DOUBLE,
thick => LINE_THICK,
);
=head2 $title = $frame->title
=cut
method title
{
return $_title;
}
=head2 $frame->set_title( $title )
Accessor for the C<title> property, a string written in the top of the
frame.
=cut
method set_title
{
( $_title ) = @_;
$self->redraw;
}
=head2 $title_align = $frame->title_align
=head2 $frame->set_title_align( $title_align )
Accessor for the C<title_align> property. Gives a vlaue in the range C<0.0> to
C<1.0> to align the title in the top of the frame.
See also L<Tickit::WidgetRole::Alignable>.
=cut
## This should come from Tickit::ContainerWidget
method children_changed { $self->reshape }
method reshape
{
lib/Tickit/Widget/Frame.pm view on Meta::CPAN
if( $child->window ) {
$child->set_window( undef );
}
}
}
method render_to_rb
{
my ( $rb, $rect ) = @_;
$rb->setpen( $self->get_style_pen( "frame" ) );
my $cols = $self->window->cols;
my $lines = $self->window->lines;
my $right = $cols - 1;
my $bottom = $lines - 1;
my $linetype = $self->get_style_values( "linetype" );
my $linetype_top = $self->get_style_values( "linetype_top" ) // $linetype;
lib/Tickit/Widget/Frame.pm view on Meta::CPAN
}
}
}
=head1 TODO
=over 4
=item *
Specific pen for title. Layered on top of frame pen.
=item *
Caption at the bottom of the frame as well. Identical to title.
=item *
Consider if it's useful to provide accessors to apply extra padding inside the
frame, surrounding the child window.
=back
=head1 AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
=cut
0x55AA;
t/31frame.t view on Meta::CPAN
$widget->set_title_align( "right" );
flush_tickit;
is_display( [ [TEXT("+".("-"x71)." Title +")],
[TEXT("|Widget".(" "x72)."|")],
( [TEXT("|"), BLANK(78), TEXT("|")] ) x 22,
[TEXT("+".("-"x78)."+")] ],
'Display with right-aligned title' );
$widget->set_style( frame_fg => "red" );
flush_tickit;
is_display( [ [TEXT("+".("-"x71)." Title +",fg=>1)],
[TEXT("|",fg=>1), TEXT("Widget".(" "x72)), TEXT("|",fg=>1)],
( [TEXT("|",fg=>1), BLANK(78), TEXT("|",fg=>1)] ) x 22,
[TEXT("+".("-"x78)."+",fg=>1)] ],
'Display with correct pen' );
$static->set_text( "New text" );
flush_tickit;
is_display( [ [TEXT("+".("-"x71)." Title +",fg=>1)],
[TEXT("|",fg=>1), TEXT("New text".(" "x70)), TEXT("|",fg=>1)],
( [TEXT("|",fg=>1), BLANK(78), TEXT("|",fg=>1)] ) x 22,
[TEXT("+".("-"x78)."+",fg=>1)] ],
'Display after $static->set_text' );
$widget->set_title( undef );
$widget->set_style( frame_fg => undef );
# Mixed linetypes
{
$widget->set_style(
linetype_top => "double",
linetype_bottom => "double",
linetype_left => "single",
linetype_right => "single",
);
flush_tickit;
( run in 0.471 second using v1.01-cache-2.11-cpan-df04353d9ac )