blib/lib/Gtk2/Ex/MindMapView/HotSpot/Grip/EllipseRound.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 63 CC 2 SCAR 9.8
CC
2
Cov
0%
hotspot_adjust_event_handler
6.0
new
2.0
hotspot_get_image
2.0
CRAP 2.7
1 package Gtk2::Ex::MindMapView::HotSpot::Grip::EllipseRound;
2  
3 our $VERSION = '0.000001';
4  
5 use warnings;
6 use strict;
7 use Carp;
8  
9 use Gtk2::Ex::MindMapView::ArgUtils;
10  
11 use Glib ':constants';
12  
13 use Gnome2::Canvas;
14  
15 use base 'Gtk2::Ex::MindMapView::HotSpot::Grip';
16  
17 sub new
18 {
19 my ($class, @attributes) = @_;
20  
21 my $self = $class->SUPER::new(@attributes);
22  
23 my %attributes = @attributes;
24  
25 args_valid(\%attributes, qw(item side enabled radius
26 fill_color_gdk outline_color_gdk hotspot_color_gdk));
27  
28 arg_default($self, 'enabled', FALSE);
29  
30 arg_default($self, 'radius', 3);
31  
32 arg_default($self, 'fill_color_gdk', Gtk2::Gdk::Color->parse('white'));
33  
34 arg_default($self, 'outline_color_gdk', Gtk2::Gdk::Color->parse('gray'));
35  
36 arg_default($self, 'hotspot_color_gdk', Gtk2::Gdk::Color->parse('orange'));
37  
38 $self->{image} = $self->hotspot_get_image();
39  
40 return $self;
41 }
42  
43  
44 # $self->hotspot_adjust_event_handler($item);
45  
46 sub hotspot_adjust_event_handler
47 {
48 my ($self, $item) = @_;
49  
50 my $offset = 1;
51  
52 my ($x, $y, $width, $height) = $self->{item}->get(qw(x y width height));
53  
54 my ($top, $left, $bottom, $right) = $self->{item}->get_insets();
55  
56 if ($self->{side} eq 'left')
57 {
58 _set_point($self, $x + $left, $y + $height - $bottom);
59 }
60 else
61 {
62 _set_point($self, $x + $width - $right, $y + $height - $bottom);
63 }
64 }
65  
66  
67 # my $image = $self->hotspot_get_image();
68  
69 sub hotspot_get_image
70 {
71 my $self = shift(@_);
72  
73 return Gnome2::Canvas::Item->new($self->{item}, 'Gnome2::Canvas::Ellipse',
74 fill_color_gdk=>$self->{fill_color_gdk},
75 outline_color_gdk=>$self->{outline_color_gdk});
76 }
77  
78  
79 sub _set_point
80 {
81 my ($self, $x, $y) = @_;
82  
83 my $radius = $self->{radius};
84  
85 $self->{image}->set(x1=>$x - $radius, y1=>$y - $radius,
86 x2=>$x + $radius, y2=>$y + $radius);
87 }
88  
89  
90  
91 1; # Magic true value required at end of module
92 __END__