blib/lib/Gtk2/Ex/MindMapView/Content/Picture.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 90 CC 4 SCAR 17.2
CC
4
Cov
0%
new
20.0
content_get_image
2.0
content_set_x
2.0
CRAP 5.6
1 package Gtk2::Ex::MindMapView::Content::Picture;
2  
3 our $VERSION = '0.000001';
4  
5 use warnings;
6 use strict;
7 use Carp;
8  
9 use List::Util;
10  
11 use Gnome2::Canvas;
12  
13 use constant MAX_HEIGHT => 700; # Pixels
14 use constant MAX_WIDTH => 700; # Pixels
15  
16 use Gtk2::Ex::MindMapView::ArgUtils;
17 use Gtk2::Ex::MindMapView::Content;
18  
19 use base 'Gtk2::Ex::MindMapView::Content';
20  
21 sub new
22 {
23 my $class = shift(@_);
24  
25 my $self = $class->SUPER::new(@_);
26  
27 my %attributes = @_;
28  
29 args_valid(\%attributes, qw(group pixbuf x y width height));
30  
31 args_required(\%attributes, qw(group pixbuf));
32  
33 if (!$self->{pixbuf}->isa('Gtk2::Gdk::Pixbuf'))
34 {
35 croak "The pixbuf parameter must be a 'Gtk2::Gdk::Pixbuf'.\n";
36 }
37  
38 my $width = $self->{pixbuf}->get_width();
39  
40 if ($width > MAX_WIDTH)
41 {
42 croak "The picture is too wide to be displayed.\n";
43 }
44  
45 my $height = $self->{pixbuf}->get_height();
46  
47 if ($height > MAX_HEIGHT)
48 {
49 croak "The picture is too tall to be displayed.\n";
50 }
51  
52 $self->{width} = $width;
53  
54 $self->{height} = $height;
55  
56 $self->{min_width} = $width;
57  
58 $self->{min_height} = $height;
59  
60 $self->{image} = $self->content_get_image();
61  
62 return $self;
63 }
64  
65  
66 # my $image = $content->content_get_image();
67  
68 sub content_get_image
69 {
70 my $self = shift(@_);
71
72 return Gnome2::Canvas::Item->new($self->{group},
73 'Gnome2::Canvas::Pixbuf', pixbuf=>$self->{pixbuf});
74 }
75  
76  
77 # $self->content_set_x($value);
78  
79 sub content_set_x
80 {
81 my ($self, $value) = @_;
82  
83 $self->{image}->set(x=>$value);
84 }
85  
86  
87 # $self->content_set_y($value);
88  
89 sub content_set_y
90 {
91 my ($self, $value) = @_;
92  
93 $self->{image}->set(y=>$value);
94 }
95  
96  
97 # $self->content_set_width($value);
98  
99 sub content_set_width
100 {
101 my ($self, $value) = @_;
102  
103 # $self->{image}->set('width-set'=>$value);
104 }
105  
106  
107 # $self->content_set_height($value);
108  
109 sub content_set_height
110 {
111 my ($self, $value) = @_;
112  
113 # $self->{image}->set('height-set'=>$value);
114 }
115  
116  
117 # $self->content_set_param($param_name, $value);
118  
119 sub content_set_param
120 {
121 my ($self, $param_name, $value) = @_;
122  
123 # $self->{image}->set($param_name=>$value);
124 }
125  
126  
127  
128 1; # Magic true value required at end of module
129 __END__