File: Box.pm

package info (click to toggle)
libcircle-be-perl 0.173320-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 388 kB
  • sloc: perl: 6,042; makefile: 2; sh: 1
file content (48 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#  You may distribute under the terms of the GNU General Public License
#
#  (C) Paul Evans, 2008-2010 -- leonerd@leonerd.org.uk

package Circle::Widget::Box;

use strict;
use warnings;
use base qw( Circle::Widget );

our $VERSION = '0.173320';

use Carp;

sub new
{
   my $class = shift;
   my %args = @_;

   my $self = $class->SUPER::new( @_ );

   $self->set_prop_orientation( $args{orientation} );

   return $self;
}

sub add
{
   my $self = shift;
   my ( $child, %opts ) = @_;

   $opts{child} = $child;
   $self->push_prop_children( \%opts );
}

sub add_spacer
{
   my $self = shift;
   my ( %opts ) = @_;

   # TODO: For now, only allow one spacer, and it must be in expand mode
   croak "Already have one spacer, can't add another" if grep { !$_->{child} } @{ $self->get_prop_children };
   croak "Spacer must be in expand mode" if !$opts{expand};

   $self->push_prop_children( \%opts );
}

0x55AA;