ListBrowser/Entry.pm

filter: Statementstmt 28.9% 40 / 138 Branchbran 11.4% 8 / 70 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 36.6% 11 / 30 Podpod 8.3% 2 / 24 totaltotal 20.6% 61 / 295 CC 45 SCAR 30.1
CC
45
Cov
21%
select
56.0
anchor
42.0
inindicator
42.0
CRAP 20.4
« ListBrowser/SideColumn.pm ↑ Summary ListBrowser/BaseItem.pm »
1 package Tk::ListBrowser::Entry;
2  
3 =head1 NAME
4  
5 Tk::ListBrowser::Item - List entry holding object.
6  
7 =cut
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use vars qw ($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 require Tk::ListBrowser::SelectXPM;
14 1 ▶use Math::Round qw(round);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 $VERSION = 0.17;
17  
18 1 ▶use base qw(Tk::ListBrowser::Item);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 =head1 SYNOPSIS
21  
22 my $entry = $listbrowser->add($entryname, @options);
23  
24 my $entry = $listbrowser->get($entryname);
25  
26 =head1 DESCRIPTION
27  
28 Inherits L<Tk::ListBrowser::Item>.
29  
30 This module creates an object that holds all information of every entry.
31  
32 You can use the same options as it's ancestors. You can also use
33 the -hidden option, if you want an entry to remain hidden upon addition.
34  
35  
36 =head1 METHODS
37  
38 =over 4
39  
40 =cut
41  
42 4 ▶sub new {
Subroutine new: called CC=4 SCAR=14.1
Pod undocumented
43 4 my $class = shift;
44
45 4 my $self = $class->SUPER::new(@_);
46  
47 4 $self->anchored(0);
48 4 ▶ $self->drawrect(0) unless $self->configSet('-drawrect');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->configSet("-drawrect") 4 0 4
49 4 ▶ $self->hidden(0) unless defined $self->hidden;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->hidden 4 0 4
50 4 ▶ $self->priority(0) unless defined $self->priority;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->priority 4 0 4
51 4 $self->opened(1);
52 4 $self->{ANCHOR} = 0;
53 4 $self->{SELECTED} = 0;
54
55 4 return $self
56 }
57  
58 0 ▶sub anchor {
Subroutine anchor: not called CC=6 SCAR=37.4
Pod undocumented
59 0 my ($self, $flag) = @_;
60 0 ▶ return unless $self->ismapped;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ismapped 0 0 0
61 0 my $c = $self->Subwidget('Canvas');
62 0 ▶ $flag = 1 unless defined $flag;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 0 0
63 0 $self->{ANCHOR} = $flag;
64 0 ▶ if ($flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag) { } 0 0 0
65 0 ▶ $self->refreshSingle($self->name) if $self->ismapped
Branch: 1 branch
BranchTrueFalseTotal
if $self->ismapped 0 0 0
66 } else {
67 0 ▶ $self->deleteAnchor if $self->ismapped
Branch: 1 branch
BranchTrueFalseTotal
if $self->ismapped 0 0 0
68 }
69 return $self->{ANCHOR}
70 0 }
71  
72 4 ▶sub anchored { return $_[0]->{ANCHOR} }
Subroutine anchored: called CC=1 SCAR=0.0
Pod undocumented
73  
74 0 ▶sub canchor {
Subroutine canchor: not called CC=2 SCAR=17.9
Pod undocumented
75 0 my $self = shift;
76 0 ▶ $self->{CANCHOR} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
77 return $self->{CANCHOR}
78 0 }
79  
80 0 ▶sub cguideH {
Subroutine cguideH: not called CC=2 SCAR=17.9
Pod undocumented
81 0 my $self = shift;
82 0 ▶ $self->{CGUIDEH} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
83 return $self->{CGUIDEH}
84 0 }
85  
86 0 ▶sub cguideV {
Subroutine cguideV: not called CC=2 SCAR=17.9
Pod undocumented
87 0 my $self = shift;
88 0 ▶ $self->{CGUIDEV} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
89 return $self->{CGUIDEV}
90 0 }
91  
92 0 ▶sub cimage {
Subroutine cimage: not called CC=2 SCAR=17.9
Pod undocumented
93 0 my $self = shift;
94 0 ▶ $self->{CIMAGE} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
95 return $self->{CIMAGE}
96 0 }
97  
98 0 ▶sub cindicator {
Subroutine cindicator: not called CC=2 SCAR=17.9
Pod undocumented
99 0 my $self = shift;
100 0 ▶ $self->{CINDICATOR} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
101 return $self->{CINDICATOR}
102 0 }
103  
104 0 ▶sub clear {
Subroutine clear: not called CC=5 SCAR=34.0
Pod documented
105 0 my $self = shift;
106 0 my $c = $self->Subwidget('Canvas');
107 0 for ($self->canchor, $self->cguideH, $self->cguideV, $self->cindicator) {
108 0 ▶ $c->delete($_) if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 0 0 0
109 }
110  
111 0 my @columns = $self->columnList;
112 0 my $name = $self->name;
113 0 for (@columns) {
114 0 my $i = $self->itemGet($name, $_);
115 0 ▶ $i->clear if defined $i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $i 0 0 0
116 }
117  
118 0 $self->canchor(undef);
119 0 $self->cguideH(undef);
120 0 $self->cguideV(undef);
121 0 $self->cindicator(undef);
122 0 $self->SUPER::clear;
123 }
124  
125 0 ▶sub clickregion {
Subroutine clickregion: not called CC=2 SCAR=17.9
Pod undocumented
126 0 my $self = shift;
127 0 my @coords = $self->region;
128 0 ▶ $coords[2] = 3000 if $self->listMode;
Branch: 1 branch
BranchTrueFalseTotal
if $self->listMode 0 0 0
129 0 return @coords;
130 }
131  
132 0 ▶sub ctext {
Subroutine ctext: not called CC=2 SCAR=17.9
Pod undocumented
133 0 my $self = shift;
134 0 ▶ $self->{CTEXT} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
135 return $self->{CTEXT}
136 0 }
137  
138 0 ▶sub deleteAnchor {
Subroutine deleteAnchor: not called CC=2 SCAR=17.9
Pod undocumented
139 0 my $self = shift;
140 0 my $r = $self->canchor;
141 0 ▶ return unless defined $r;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $r 0 0 0
142
143 0 my $c = $self->Subwidget('Canvas');
144 0 $c->delete($r);
145 0 $self->canchor(undef);
146 }
147  
148 0 ▶sub deleteSelect {
Subroutine deleteSelect: not called CC=1 SCAR=6.9
Pod undocumented
149 0 my $self = shift;
150 0 $self->deleteRect;
151 }
152  
153 0 ▶sub drawAnchor {
Subroutine drawAnchor: not called CC=2 SCAR=17.9
Pod undocumented
154 0 my ($self, $force) = @_;
155 0 ▶ return unless $self->ismapped;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ismapped 0 0 0
156
157 0 my @coords = $self->elementCoords;
158 0 $self->deleteAnchor;
159 0 my $c = $self->Subwidget('Canvas');
160 0 my $a = $c->createRectangle(@coords,
161 -fill => undef,
162 -dash => [3, 2],
163 -tags => ['anchor'],
164 );
165 0 $self->canchor($a);
166 }
167  
168 0 ▶sub hasChildren {
Subroutine hasChildren: not called CC=1 SCAR=6.9
Pod undocumented
169 0 my $self = shift;
170 0 my @c = $self->infoChildren($self->name);
171 0 my $ch = @c;
172 0 return $ch
173 }
174  
175 8 ▶sub hidden {
Subroutine hidden: called CC=2 SCAR=6.9
Pod undocumented
176 8 my $self = shift;
177 8 ▶ $self->{HIDDEN} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 4 4 8
178 return $self->{HIDDEN}
179 8 }
180  
181 0 ▶sub inindicator {
Subroutine inindicator: not called CC=6 SCAR=37.4
Pod undocumented
182 0 my ($self, $x, $y) = @_;
183 0 my $i = $self->cindicator;
184 0 ▶ return '' unless defined $i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $i 0 0 0
185 0 my $c = $self->Subwidget('Canvas');
186 0 my @coords = $c->coords($i);
187 0 ▶ return 1 if ($coords[0] > $x) and ($coords[2] < $x) and ($coords[1] > $y) and ($coords[3] < $y);
Branch: 1 branch
BranchTrueFalseTotal
if $coords[0] > $x and $coords[2] < $x and $coords[1] > $y and $coords[3] < $y 0 0 0
Condition0%0/9
$coords[0] > $x and $coords[2] < $x and $coords[1] > $y and $coords[3] < $y
!ll&&!rl&&r
000
$coords[0] > $x and $coords[2] < $x and $coords[1] > $y
!ll&&!rl&&r
000
$coords[0] > $x and $coords[2] < $x
!ll&&!rl&&r
000
MC/DC0%0/4
$coords[0] > $x and $coords[2] < $x and $coords[1] > $y and $coords[3] < $y
$coords[0] > $x $coords[2] < $x $coords[1] > $y $coords[3] < $y
Truth table0%0/5
A and B and C and D
A= $coords[0] > $xB= $coords[2] < $xC= $coords[1] > $yD= $coords[3] < $y
ABCDresult
0XXX0
10XX0
110X0
11100
11111
188 0 return ''
189 }
190  
191 0 ▶sub inregion {
Subroutine inregion: not called CC=5 SCAR=34.0
Pod documented
192 0 my ($self, $x, $y) = @_;
193 0 my ($cx, $cy, $cdx, $cdy) = $self->clickregion;
194 0 ▶ return '' unless $x >= $cx;
Branch: 1 branch
BranchTrueFalseTotal
unless $x >= $cx 0 0 0
195 0 ▶ return '' unless $x <= $cdx;
Branch: 1 branch
BranchTrueFalseTotal
unless $x <= $cdx 0 0 0
196 0 ▶ return '' unless $y >= $cy;
Branch: 1 branch
BranchTrueFalseTotal
unless $y >= $cy 0 0 0
197 0 ▶ return '' unless $y <= $cdy;
Branch: 1 branch
BranchTrueFalseTotal
unless $y <= $cdy 0 0 0
198 0 return 1
199 }
200  
201 0 ▶sub noshow {
Subroutine noshow: not called CC=2 SCAR=17.9
Pod undocumented
202 0 my $self = shift;
203 0 ▶ return (($self->hidden) or (not $self->openedparent))
Condition0%0/3
$self->hidden || !$self->openedparent
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->hidden || !$self->openedparent
$self->hidden !$self->openedparent
Truth table0%0/3
A || not(B)
A= $self->hiddenB= !$self->openedparent
ABresult
1X1
011
000
204 }
205  
206 4 ▶sub opened {
Subroutine opened: called CC=2 SCAR=7.1
Pod undocumented
207 4 my $self = shift;
208 4 ▶ $self->{OPENED} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 4 0 4
209 return $self->{OPENED}
210 4 }
211  
212 0 ▶sub openedparent {
Subroutine openedparent: not called CC=5 SCAR=34.0
Pod undocumented
213 0 my $self = shift;
214 0 my $name = $self->name;
215 0 ▶ return 1 unless $self->hierarchy;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->hierarchy 0 0 0
216 0 my $p = $self->infoParent($name);
217 0 my $r = '';
218 0 ▶ if (defined $p) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) { } 0 0 0
219 0 my $parent = $self->get($p);
220 0 ▶ if (($parent->openedparent) and ($parent->opened)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->openedparent and $parent->opened) 0 0 0
Condition0%0/3
$parent->openedparent and $parent->opened
!ll&&!rl&&r
000
MC/DC0%0/2
$parent->openedparent and $parent->opened
$parent->openedparent $parent->opened
Truth table0%0/3
A and B
A= $parent->openedparentB= $parent->opened
ABresult
0X0
100
111
221 0 $r = 1
222 }
223 } else {
224 #is root always open
225 0 $r = 1
226 }
227 0 return $r
228 }
229  
230 8 ▶sub priority {
Subroutine priority: called CC=2 SCAR=6.9
Pod undocumented
231 8 my $self = shift;
232 8 ▶ $self->{PRIORITY} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 4 4 8
233 return $self->{PRIORITY}
234 8 }
235  
236 0 ▶sub select {
Subroutine select: not called CC=7 SCAR=40.3
Pod undocumented
237 0 my ($self, $flag) = @_;
238 0 ▶ $flag = 1 unless defined $flag;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 0 0
239 0 ▶ return if $flag and $self->selected;
Branch: 1 branch
BranchTrueFalseTotal
if $flag and $self->selected 0 0 0
Condition0%0/3
$flag and $self->selected
!ll&&!rl&&r
000
MC/DC0%0/2
$flag and $self->selected
$flag $self->selected
Truth table0%0/3
A and B
A= $flagB= $self->selected
ABresult
0X0
100
111
240 0 ▶ return if (not $flag) and (not $self->selected);
Branch: 1 branch
BranchTrueFalseTotal
unless $flag or $self->selected 0 0 0
Condition0%0/3
$flag or $self->selected
l!l&&r!l&&!r
000
MC/DC0%0/2
$flag or $self->selected
$flag $self->selected
Truth table0%0/3
A or B
A= $flagB= $self->selected
ABresult
1X1
011
000
241 0 $self->{SELECTED} = $flag;
242 0 ▶ $self->refreshSingle($self->name) if $self->ismapped;
Branch: 1 branch
BranchTrueFalseTotal
if $self->ismapped 0 0 0
243 }
244  
245 0 ▶sub selected { return $_[0]->{SELECTED} }
Subroutine selected: not called CC=1 SCAR=6.9
Pod undocumented
246  
247  
248 =back
249  
250 =head1 LICENSE
251  
252 Same as Perl.
253  
254 =head1 AUTHOR
255  
256 Hans Jeuken (hanje at cpan dot org)
257  
258 =head1 BUGS AND CAVEATS
259  
260 If you find any bugs, please report them here: L<https://github.com/haje61/Tk-ListBrowser/issues>.
261  
262 =head1 SEE ALSO
263  
264 =over 4
265  
266 =item L<Tk::ListBrowser::BaseItem>
267  
268 =back
269  
« ListBrowser/SideColumn.pm ↑ Summary ListBrowser/BaseItem.pm »