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

filter: Statementstmt 0.0% 0 / 59 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 / 76 CC 2 SCAR 9.8
CC
2
Cov
0%
_get_path_def
6.0
new
2.0
hotspot_adjust_event_handler
2.0
CRAP 2.7
1 package Gtk2::Ex::MindMapView::HotSpot::Grip::RightAngle;
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
26 fill_color_gdk outline_color_gdk hotspot_color_gdk));
27  
28 arg_default($self, 'enabled', FALSE);
29  
30 arg_default($self, 'fill_color_gdk', Gtk2::Gdk::Color->parse('white'));
31  
32 arg_default($self, 'outline_color_gdk', Gtk2::Gdk::Color->parse('gray'));
33  
34 arg_default($self, 'hotspot_color_gdk', Gtk2::Gdk::Color->parse('orange'));
35  
36 $self->{image} = $self->hotspot_get_image();
37  
38 return $self;
39 }
40  
41  
42 # $self->hotspot_adjust_event_handler($item);
43  
44 sub hotspot_adjust_event_handler
45 {
46 my ($self, $item) = @_;
47  
48 # FIXME: Item is not defined...
49  
50 $self->{image}->set_path_def(_get_path_def($self));
51  
52 $self->{image}->request_update();
53 }
54  
55  
56 # my $image = $self->hotspot_get_image();
57  
58 sub hotspot_get_image
59 {
60 my $self = shift(@_);
61  
62 my $image = Gnome2::Canvas::Item->new($self->{item}, 'Gnome2::Canvas::Shape',
63 fill_color_gdk=>$self->{fill_color_gdk},
64 outline_color_gdk=>$self->{outline_color_gdk});
65  
66 $image->set_path_def(_get_path_def($self));
67  
68 return $image;
69 }
70  
71  
72 sub _get_path_def
73 {
74 my $self = shift(@_);
75  
76 my $offset = 2;
77  
78 my $h = 10;
79  
80 my ($x, $y, $height, $width) = $self->{item}->get(qw(x y height width));
81  
82 my @p = ();
83  
84 if ($self->{side} eq 'left')
85 {
86 my $x0 = $x + $offset;
87  
88 my $y0 = $y + $height - $offset;
89  
90 @p = ($x0,$y0, $x0,$y0-$h, $x0+$h,$y0);
91 }
92 else # $self->{side} eq 'right'
93 {
94 my $x0 = $x + $width - $offset;
95  
96 my $y0 = $y + $height - $offset;
97  
98 @p = ($x0,$y0-$h, $x0-$h,$y0, $x0,$y0);
99 }
100  
101 my $pathdef = Gnome2::Canvas::PathDef->new();
102  
103 $pathdef->moveto ($p[0], $p[1]);
104  
105 $pathdef->lineto ($p[2], $p[3]);
106  
107 $pathdef->lineto ($p[4], $p[5]);
108  
109 $pathdef->lineto ($p[0], $p[1]);
110  
111 $pathdef->closepath_current;
112  
113 return $pathdef;
114 }
115  
116  
117  
118 1; # Magic true value required at end of module
119 __END__