Pvoice/Row.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 82 CC 2 SCAR 11.0
CC
2
Cov
0%
new
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 package AAC::Pvoice::Row;
2 use strict;
3 use warnings;
4
5 use Wx qw(:everything);
6 use Wx::Perl::Carp;
7 use AAC::Pvoice::Bitmap;
8 use base qw(Wx::Panel);
9
10 our $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $=~/(\d+)\.(\d+)/);
11 #----------------------------------------------------------------------
12 sub new
13 {
14 my $class = shift;
15 my ($parent,$maxitems,$items,
16 $wxPos,$wxSize, $itemmaxX, $itemmaxY,
17 $itemspacing, $background, $style,$name) = @_;
18 my $self = $class->SUPER::new( $parent,
19 Wx::NewId,
20 $wxPos || wxDefaultPosition,
21 $wxSize || wxDefaultSize,
22 $style || 0,
23 $name || '');
24
25 $self->{maxitems} = $maxitems;
26
27 my $sizer = Wx::GridSizer->new(1,0);
28 $self->{items} = [];
29 $self->{actions} = [];
30
31 my ($maxX, $maxY) = ($itemmaxX, $itemmaxY);
32
33 # Add the defined keys for this row
34 for (@$items)
35 {
36 if (not defined $_)
37 {
38 my $empty = Wx::BitmapButton->new( $self,
39 Wx::NewId,
40 wxNullBitmap,
41 wxDefaultPosition,
42 [$maxX, $maxY],
43 wxSUNKEN_BORDER);
44 $empty->SetBackgroundColour($background);
45 $sizer->Add($empty,0, wxALIGN_CENTRE|wxALL, $itemspacing);
46 next;
47 }
48 my ($id, $img, $sub) = @$_;
49 my $button = Wx::BitmapButton->new ($self, # parent
50 $id, # id
51 $img, # image
52 wxDefaultPosition, # position
53 [$maxX, $maxY],# size
54 wxSUNKEN_BORDER); # style
55 $button->SetBackgroundColour($background);
56 $sizer->Add($button, 0, wxALIGN_CENTRE|wxALL, $itemspacing);
57 push @{$self->{items}}, $button;
58 push @{$self->{actions}}, $sub;
59 push @{$self->{ids}}, $id;
60 }
61 my $totalitems = scalar(@$items);
62 $self->{totalitems} = scalar(@{$self->{items}});
63 for (0..($self->{maxitems} - $totalitems -1))
64 {
65 my $empty = Wx::BitmapButton->new( $self,
66 Wx::NewId,
67 wxNullBitmap,
68 wxDefaultPosition,
69 [$maxX, $maxY],
70 wxSUNKEN_BORDER);
71 $empty->SetBackgroundColour($background);
72 $sizer->Add($empty,0, wxALIGN_CENTRE|wxALL, $itemspacing);
73 }
74 $self->SetBackgroundColour($background);
75 $self->SetSizer($sizer);
76 $self->SetAutoLayout(1);
77 $sizer->Fit($self);
78 return $self;
79 }
80
81 1;
82
83 __END__