blib/lib/Gtk2/Ex/MindMapView/BorderFactory.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 86 CC 8 SCAR 31.5
CC
8
Cov
0%
create_border
56.0
new
6.0
BEGIN
2.0
CRAP 23.4
1 package Gtk2::Ex::MindMapView::BorderFactory;
2  
3 our $VERSION = '0.000001';
4  
5 use warnings;
6 use strict;
7 use Carp;
8  
9 use Gtk2::Ex::MindMapView::Border::Ellipse;
10 use Gtk2::Ex::MindMapView::Border::Rectangle;
11 use Gtk2::Ex::MindMapView::Border::RoundedRect;
12  
13 use Gtk2::Ex::MindMapView::ArgUtils;
14  
15 use List::Util;
16  
17 use Glib ':constants';
18  
19 sub new
20 {
21 my $class = shift(@_);
22  
23 my @attributes = @_;
24  
25 my $self = {};
26  
27 bless $self, $class;
28  
29 my %attributes = @attributes;
30  
31 args_valid(\%attributes, qw(view fill_color_gdk outline_color_gdk));
32  
33 args_required(\%attributes, qw(view));
34  
35 args_store($self, \%attributes);
36  
37 if (!($self->{view}->isa('Gtk2::Ex::MindMapView')))
38 {
39 carp "Invalid Gtk2::Ex::MindMapView argument.\n";
40 }
41  
42 arg_default($self, "fill_color_gdk", Gtk2::Gdk::Color->parse('white'));
43  
44 arg_default($self, "outline_color_gdk", Gtk2::Gdk::Color->parse('gray'));
45  
46 return $self;
47 }
48  
49  
50 sub create_border
51 {
52 my ($self, @attributes) = @_;
53  
54 my %attributes = @attributes;
55  
56 args_valid(\%attributes, qw(type content fill_color_gdk outline_color_gdk));
57  
58 args_required(\%attributes, qw(type content));
59  
60 my $content = $attributes{content};
61  
62 if (!$content->isa('Gtk2::Ex::MindMapView::Content'))
63 {
64 croak "Invalid content. 'content' parameter must be a 'Gtk2::Ex::MindMapView::Content'.\n";
65 }
66  
67 my $type = $attributes{type};
68  
69 my $fill_color_gdk = (defined $attributes{fill_color_gdk}) ?
70 $attributes{fill_color_gdk} : $self->{fill_color_gdk};
71  
72 my $outline_color_gdk = (defined $attributes{outline_color_gdk}) ?
73 $attributes{outline_color_gdk} : $self->{outline_color_gdk};
74  
75 if ($type eq 'Gtk2::Ex::MindMapView::Border::Ellipse')
76 {
77 return Gtk2::Ex::MindMapView::Border::Ellipse->new(
78 group=>$self->{view}->root,
79 content=>$content,
80 fill_color_gdk=>$fill_color_gdk,
81 outline_color_gdk=>$outline_color_gdk);
82 }
83  
84 if ($type eq 'Gtk2::Ex::MindMapView::Border::RoundedRect')
85 {
86 return Gtk2::Ex::MindMapView::Border::RoundedRect->new(
87 group=>$self->{view}->root,
88 content=>$content,
89 fill_color_gdk=>$fill_color_gdk,
90 outline_color_gdk=>$outline_color_gdk);
91 }
92  
93  
94 if ($type eq 'Gtk2::Ex::MindMapView::Border::Rectangle')
95 {
96 return Gtk2::Ex::MindMapView::Border::Rectangle->new(
97 group=>$self->{view}->root,
98 content=>$content,
99 fill_color_gdk=>$fill_color_gdk,
100 outline_color_gdk=>$outline_color_gdk);
101 }
102  
103 croak "Unexpected border type: $type\n";
104 }
105  
106  
107 1; # Magic true value required at end of module
108 __END__