SWF/Column.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 55 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Alzabo::Display::SWF::Column;
2  
3 use strict;
4 use warnings;
5  
6 use SWF qw(:ALL);
7 use Alzabo::Display::SWF::Util qw/rgb2ary button_shape/;
8 use Alzabo::Display::SWF::Text;
9 our $VERSION = '0.01';
10  
11 sub new {
12 my ($pkg, $name, $cfg) = @_;
13 my ( $fdb, $bfdb ) = map $cfg->{fdb_dir}.'/'.$_.'.fdb'
14 => $cfg->{column}{fdb}{up},
15 $cfg->{column}{fdb}{over};
16  
17 my @c_bg = rgb2ary( $cfg->{column}{color}{bg} );
18 my @c_up = rgb2ary( $cfg->{column}{color}{fg}{up} );
19 my @c_over = rgb2ary( $cfg->{column}{color}{fg}{over} );
20  
21 my $f = new SWF::Font $fdb;
22 my $fb = new SWF::Font $bfdb;
23  
24 my $t = new Alzabo::Display::SWF::Text $name, $f, @c_up;
25 my $tb = new Alzabo::Display::SWF::Text $name, $fb, @c_over;
26 my $w = $tb->getStringWidth($name);
27  
28 my $bs1 = button_shape($w, @c_bg);
29 my $bs2 = button_shape($w, @c_bg);
30  
31 my $b = new SWF::Button;
32 $b->addShape($bs1, SWF::Button::SWFBUTTON_HIT);
33 $b->addShape($bs1, SWF::Button::SWFBUTTON_UP);
34 $b->addShape($bs2, SWF::Button::SWFBUTTON_OVER);
35 $b->setAction(
36 new SWF::Action("nextFrame();"),
37 SWF::Button::SWFBUTTON_MOUSEOVER
38 );
39 $b->setAction(
40 new SWF::Action("play();"),
41 SWF::Button::SWFBUTTON_MOUSEOUT
42 );
43 my $v = new SWF::Sprite;
44 my $bi = $v->add($b);
45  
46 $bi->moveTo(-1, -11);
47 $bi->setName("button");
48 my $ti = $v->add($t);
49 $v->nextFrame;
50 $v->add(new SWF::Action("stop();"));
51 $v->nextFrame;
52 $v->remove($ti);
53 $v->add($tb);
54 $v->nextFrame;
55  
56 my $self = { sprite => $v, width => $w, dy => undef, displayItem => undef,
57 is_primary_key => undef, is_foreign_key => undef,
58 foreign_keys => [] };
59 bless $self, $pkg;
60 return $self;
61 }
62  
63 1;