| 1 | # You may distribute under the terms of either the GNU General Public License | ||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||
| 3 | # | ||
| 4 | # (C) Paul Evans, 2011-2023 -- leonerd@leonerd.org.uk | ||
| 5 | |||
| 6 | use v5.20; | ||
| 7 | use warnings; | ||
| 8 | use Object::Pad 0.807; | ||
| 9 | |||
| 10 | package Tickit::SingleChildWidget 0.59; | ||
| 11 | class Tickit::SingleChildWidget; | ||
| 12 | |||
| 13 | inherit Tickit::ContainerWidget; | ||
| 14 | |||
| 15 | apply Tickit::WidgetRole::SingleChildContainer; | ||
| 16 | |||
| 17 | use Carp; | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | C<Tickit::SingleChildWidget> - abstract base class for widgets that contain a | ||
| 22 | single other widget | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | TODO | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | This subclass of L<Tickit::ContainerWidget> acts as an abstract base class for | ||
| 31 | widgets that contain exactly one other widget. It enforces that only one child | ||
| 32 | widget may be contained at any one time, and provides a convenient accessor to | ||
| 33 | obtain it. | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | =head1 CONSTRUCTOR | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | =head2 new | ||
| 42 | |||
| 43 | $widget = Tickit::SingleChildWidget->new( %args ); | ||
| 44 | |||
| 45 | Constructs a new C<Tickit::SingleChildWidget> object. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | ADJUST :params ( :$child = undef ) | ||
| 50 | { | ||
| 51 | if( $child ) { | ||
| 52 | croak "The 'child' constructor argument to ${\ref $self} is no longer recognised; use ->set_child instead"; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | =head1 AUTHOR | ||
| 57 | |||
| 58 | Paul Evans <leonerd@leonerd.org.uk> | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | 0x55AA; |