lib/TUI/Dialogs/Button.pm

filter: Statementstmt 27.0% 83 / 307 Branchbran 0.0% 0 / 122 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 50.0% 21 / 42 Podpod 73.3% 11 / 15 totaltotal 21.6% 115 / 532 CC 74 SCAR 53.7
CC
74
Cov
18%
handleEvent
698.5
__ANON__
210.0
drawState
182.0
CRAP 214.7
« lib/TUI/Views/Frame.pm ↑ Summary lib/TUI/Help/HelpViewer.pm »
1 package TUI::Dialogs::Button;
2 # ABSTRACT: Pushbutton control for dialogs
3
4 38 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 38 our $VERSION = '2.000003';
9 38 $VERSION =~ tr/_//d;
10 38 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 38 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 38 our @EXPORT = qw(
14 TButton
15 new_TButton
16 );
17
18 38 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 38 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 38 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 :is
22 :types
23 38 );
24
25 38 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
26 :bfXXXX
27 :cmXXXX
28 cpButton
29 38 );
30 38 ▶use TUI::Dialogs::Util qw( hotKey );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 38 ▶use TUI::Drivers::Const qw( :evXXXX );
Subroutine BEGIN: called CC=1 SCAR=0.0
32 38 ▶use TUI::Drivers::Event;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 38 ▶use TUI::Drivers::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
34 cstrlen
35 getAltCode
36 38 );
37 38 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 38 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
39 cmDefault
40 cmCommandSetChanged
41 :ofXXXX
42 phPostProcess
43 :sfXXXX
44 38 );
45 38 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 38 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 38 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 38 ▶use TUI::Views::Util qw( message );
Subroutine BEGIN: called CC=1 SCAR=0.0
49
50 sub TButton() { __PACKAGE__ }
51 sub name() { 'TButton' }
52 0 ▶sub new_TButton { __PACKAGE__->from(@_) }
Subroutine new_TButton: not called CC=1 SCAR=6.9
Pod documented
53
54 38 extends TView;
55
56 # declare global variables
57 38 our $shadows = "\xDC\xDB\xDF";
58 38 our $markers = "[]";
59
60 # import global variables
61 38 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
62 $showMarkers
63 $specialChars
64 38 );
65 {
66 38 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
67 38 *showMarkers = \${ TView . '::showMarkers' };
68 38 *specialChars = \${ TView . '::specialChars' };
69 }
70
71 # public attributes
72 0 ▶has title => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
73
74 # protected attributes
75 0 ▶has command => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
76 0 ▶has flags => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
77 38 has amDefault => ( is => 'ro', default => false );
78
79 # predeclare private methods
80 my (
81 38 $drawTitle,
82 $pressButton,
83 $getActiveRect,
84 );
85
86 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
87 0 state $sig = signature(
88 method => 1,
89 named => [
90 bounds => Object,
91 title => Str, { alias => 'aTitle' },
92 command => PositiveOrZeroInt, { alias => 'aCommand' },
93 flags => PositiveOrZeroInt, { alias => 'aFlags' },
94 ],
95 caller_level => +1,
96 );
97 0 my ( $class, $args ) = $sig->( @_ );
98 0 return { %$args };
99 }
100
101 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=4 SCAR=30.0
Pod documented
102 0 my ( $self, $args ) = @_;
103 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
104 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
105 0 $self->{amDefault} = ( $self->{flags} & bfDefault ) != 0;
106 $self->{options} |=
107 0 ofSelectable | ofFirstClick | ofPreProcess | ofPostProcess;
108 0 $self->{eventMask} |= evBroadcast;
109 $self->{state} |= sfDisabled
110 0 ▶ unless TView->commandEnabled( $self->{command} );
Branch: 1 branch
BranchTrueFalseTotal
unless "TUI::Views::View"->commandEnabled($self->{"command"}) 0 0 0
111 0 return;
112 }
113
114 0 ▶sub from { # $obj ($bounds, $aTitle, $aCommand, $aFlags)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
115 0 state $sig = signature(
116 method => 1,
117 pos => [Object, Str, PositiveOrZeroInt, PositiveOrZeroInt],
118 );
119 0 my ( $class, @args ) = $sig->( @_ );
120 0 return $class->new( bounds => $args[0], title => $args[1],
121 command => $args[2], flags => $args[3] );
122 }
123
124 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod documented
125 0 my ( $self, $in_global_destruction ) = @_;
126 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
127 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
128 0 $self->{title} = undef;
129 0 return;
130 }
131
132 0 ▶sub draw { # void ()
Subroutine draw: not called CC=1 SCAR=6.9
Pod documented
133 0 state $sig = signature(
134 method => Object,
135 pos => [],
136 );
137 0 my ( $self ) = $sig->( @_ );
138 0 $self->drawState( false );
139 0 return;
140 }
141
142 0 ▶sub drawState { # void ($down)
Subroutine drawState: not called CC=13 SCAR=52.0
Pod documented
143 0 state $sig = signature(
144 method => Object,
145 pos => [Bool],
146 );
147 0 my ( $self, $down ) = $sig->( @_ );
148
149 0 my ( $cButton, $cShadow );
150 0 my $ch;
151 0 my $i;
152 0 my $b = TDrawBuffer->new();
153
154 0 ▶ if ( $self->{state} & sfDisabled ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'state'} & 256) { } 0 0 0
155 0 $cButton = $self->getColor( 0x0404 );
156 }
157 else {
158 0 $cButton = $self->getColor( 0x0501 );
159 0 ▶ if ( $self->{state} & sfActive ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"} & 16) 0 0 0
160 0 ▶ if ( $self->{state} & sfSelected ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'state'} & 32) { } 0 0 0
elsif ($self->{'amDefault'}) { } 0 0 0
161 0 $cButton = $self->getColor( 0x0703 );
162 }
163 elsif ( $self->{amDefault} ) {
164 0 $cButton = $self->getColor( 0x0602 );
165 }
166 }
167 } #/ else [ if ( $self->{state} ...)]
168
169 0 $cShadow = $self->getColor( 8 );
170
171 0 my $s = $self->{size}{x} - 1;
172 0 my $T = int( $self->{size}{y} / 2 ) - 1;
173
174 0 ▶ for ( my $y = 0 ; $y <= $self->{size}{y} - 2 ; $y++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $self->{"size"}{"y"} - 2) 0 0 0
175 0 $b->moveChar( 0, ' ', $cButton, $self->{size}{x} );
176 0 $b->putAttribute( 0, $cShadow );
177 0 ▶ if ( $down ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($down) { } 0 0 0
178 0 $b->putAttribute( 1, $cShadow );
179 0 $ch = ' ';
180 0 $i = 2;
181 }
182 else {
183 0 $b->putAttribute( $s, $cShadow );
184 0 ▶ if ( $showMarkers ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($TUI::Dialogs::Button::showMarkers) { } 0 0 0
185 0 $ch = ' ';
186 }
187 else {
188 0 ▶ if ( $y == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y == 0) { } 0 0 0
189 0 $b->putChar( $s, substr( $shadows, 0, 1 ) );
190 }
191 else {
192 0 $b->putChar( $s, substr( $shadows, 1, 1 ) );
193 }
194 0 $ch = substr( $shadows, 2, 1 );
195 }
196 0 $i = 1;
197 } #/ else [ if ( $down ) ]
198
199 0 ▶ if ( $y == $T && defined $self->{title} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y == $T and defined $self->{"title"}) 0 0 0
Condition0%0/3
$y == $T and defined $self->{"title"}
!ll&&!rl&&r
000
MC/DC0%0/2
$y == $T and defined $self->{"title"}
$y == $T defined $self->{"title"}
Truth table0%0/3
A and B
A= $y == $TB= defined $self->{"title"}
ABresult
0X0
100
111
200 0 $self->$drawTitle( $b, $s, $i, $cButton, $down );
201 }
202
203 0 ▶ if ( $showMarkers && !$down ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($TUI::Dialogs::Button::showMarkers and not $down) 0 0 0
Condition0%0/3
$TUI::Dialogs::Button::showMarkers and not $down
!ll&&!rl&&r
000
MC/DC0%0/2
$TUI::Dialogs::Button::showMarkers and not $down
$TUI::Dialogs::Button::showMarkers not $down
Truth table0%0/3
A and not(B)
A= $TUI::Dialogs::Button::showMarkersB= not $down
ABresult
0X0
100
111
204 0 $b->putChar( 1, substr( $markers, 0, 1 ) );
205 0 $b->putChar( $s - 1, substr( $markers, 1, 1 ) );
206 }
207
208 0 $self->writeLine( 0, $y, $self->{size}{x}, 1, $b );
209 } #/ for ( my $y = 0 ; $y <=...)
210
211 0 $b->moveChar( 0, ' ', $cShadow, 2 );
212 0 $b->moveChar( 2, $ch, $cShadow, $s - 1 );
213
214 0 $self->writeLine( 0, $self->{size}{y} - 1, $self->{size}{x}, 1, $b );
215 0 return;
216 } #/ sub drawState
217
218 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
219 0 state $sig = signature(
220 method => Object,
221 pos => [],
222 );
223 0 my ( $self ) = $sig->( @_ );
224 0 state $palette = TPalette->new(
225 data => cpButton,
226 size => length( cpButton ),
227 );
228 0 return $palette->clone();
229 }
230
231 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=27 SCAR=65.5
Pod documented
232 38 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
233 0 state $sig = signature(
234 method => Object,
235 pos => [Object],
236 );
237 0 my ( $self, $event ) = $sig->( @_ );
238
239 0 my $mouse;
240 my $clickRect;
241
242 0 $clickRect = $self->getExtent();
243 0 $clickRect->{a}{x}++;
244 0 $clickRect->{b}{x}--;
245 0 $clickRect->{b}{y}--;
246
247 0 ▶ if ( $event->{what} == evMouseDown ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"what"} == 1) 0 0 0
248 0 $mouse = $self->makeLocal( $event->{mouse}{where} );
249 0 ▶ if ( !$clickRect->contains( $mouse ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($clickRect->contains($mouse)) 0 0 0
250 0 $self->clearEvent( $event );
251 }
252 }
253 0 ▶ if ( $self->{flags} & bfGrabFocus ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flags"} & 8) 0 0 0
254 0 $self->SUPER::handleEvent( $event );
255 }
256
257 0 my $c = hotKey( $self->{title} );
258 0 SWITCH: for ( $event->{what} ) {
259 0 ▶ evMouseDown == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
1 == $_ and 0 0 0
260 0 ▶ if ( ( $self->{state} & sfDisabled ) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"state"} & 256) == 0) 0 0 0
261 0 $clickRect->{b}{x}++;
262 0 my $down = false;
263 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$self->mouseEvent($event, 4) and do { do { $mouse = $self->makeLocal($event->{"mouse"}{"where"}); if (!$down != !$clickRect->contains($mouse)) { $down = !$down; $self->drawState($down); } } } 0 0 0
264 0 $mouse = $self->makeLocal( $event->{mouse}{where} );
265 0 ▶ if ( !$down != !$clickRect->contains( $mouse ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!$down != !$clickRect->contains($mouse)) 0 0 0
266 0 $down = !$down;
267 0 $self->drawState( $down );
268 }
269 } while ( $self->mouseEvent( $event, evMouseMove ) );
270 0 ▶ if ( $down ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($down) 0 0 0
271 0 $self->press();
272 0 $self->drawState( false );
273 }
274 } #/ if ( ( $self->{state} ...))
275 0 $self->clearEvent( $event );
276 0 last;
277 };
278
279 0 ▶ evKeyDown == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
16 == $_ and do { if ($event->{"keyDown"}{"keyCode"} == &getAltCode($c) or $self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c or $self->{"state"} & 64 and $event->{"keyDown"}{"charScan"}{"charCode"} eq " ") { $self->press; $self->clearEvent($event); } ; last } 0 0 0
280 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"keyDown"}{"keyCode"} == &getAltCode($c) or $self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c or $self->{"state"} & 64 and $event->{"keyDown"}{"charScan"}{"charCode"} eq " ") 0 0 0
Condition0%0/15
$event->{"keyDown"}{"keyCode"} == &getAltCode($c) or $self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c or $self->{"state"} & 64 and $event->{"keyDown"}{"charScan"}{"charCode"} eq " "
l!l&&r!l&&!r
000
$event->{"keyDown"}{"keyCode"} == &getAltCode($c) or $self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
l!l&&r!l&&!r
000
$self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
!ll&&!rl&&r
000
$self->{"owner"}{"phase"} == 2 and $c
!ll&&!rl&&r
000
$self->{"state"} & 64 and $event->{"keyDown"}{"charScan"}{"charCode"} eq " "
!ll&&!rl&&r
000
MC/DC0%0/6
$event->{"keyDown"}{"keyCode"} == &getAltCode($c) or $self->{"owner"}{"phase"} == 2 and $c and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c or $self->{"state"} & 64 and $event->{"keyDown"}{"charScan"}{"charCode"} eq " "
$event->{"keyDown"}{"keyCode"} == &getAltCode($c) $self->{"owner"}{"phase"} == 2 $c uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c $self->{"state"} & 64 $event->{"keyDown"}{"charScan"}{"charCode"} eq " "
Truth table0%0/11
A or B and C and D or E and F
A= $event->{"keyDown"}{"keyCode"} == &getAltCode($c)B= $self->{"owner"}{"phase"} == 2C= $cD= uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $cE= $self->{"state"} & 64F= $event->{"keyDown"}{"charScan"}{"charCode"} eq " "
ABCDEFresult
1XXXXX1
0111XX1
00XX111
010X111
0110111
00XX0X0
00XX100
010X0X0
010X100
01100X0
0110100
281 $event->{keyDown}{keyCode} == getAltCode( $c )
282 || ( $self->{owner}{phase} == phPostProcess
283 && $c
284 && uc( $event->{keyDown}{charScan}{charCode} ) eq $c )
285 || ( ( $self->{state} & sfFocused )
286 && $event->{keyDown}{charScan}{charCode} eq ' ' )
287 )
288 {
289 0 $self->press();
290 0 $self->clearEvent( $event );
291 } #/ if ( $event->{keyDown}...)
292 0 last;
293 };
294
295 0 ▶ evBroadcast == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
512 == $_ and 0 0 0
296 0 local $_;
297 0 SWITCH: for ( $event->{message}{command} ) {
298 0 ▶ cmDefault == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
14 == $_ and do { if ($self->{"amDefault"} and not $self->{"state"} & 256) { $self->press; $self->clearEvent($event); } ; last } 0 0 0
299 0 ▶ if ( $self->{amDefault} && !( $self->{state} & sfDisabled ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"amDefault"} and not $self->{"state"} & 256) 0 0 0
Condition0%0/3
$self->{"amDefault"} and not $self->{"state"} & 256
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"amDefault"} and not $self->{"state"} & 256
$self->{"amDefault"} not $self->{"state"} & 256
Truth table0%0/3
A and not(B)
A= $self->{"amDefault"}B= not $self->{"state"} & 256
ABresult
0X0
100
111
300 0 $self->press();
301 0 $self->clearEvent( $event );
302 }
303 0 last;
304 };
305
306 cmGrabDefault == $_ ||
307 0 ▶ cmReleaseDefault == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
61 == $_ || 62 == $_ and do { if ($self->{"flags"} & 1) { $self->{"amDefault"} = $event->{"message"}{"command"} == 62; $self->drawView; } ; last } 0 0 0
Condition0%0/3
61 == $_ or 62 == $_
l!l&&r!l&&!r
000
MC/DC0%0/2
61 == $_ or 62 == $_
61 == $_ 62 == $_
Truth table0%0/3
A or B
A= 61 == $_B= 62 == $_
ABresult
1X1
011
000
308 0 ▶ if ( $self->{flags} & bfDefault ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flags"} & 1) 0 0 0
309 0 $self->{amDefault} = $event->{message}{command} == cmReleaseDefault;
310 0 $self->drawView();
311 }
312 0 last;
313 };
314
315 0 ▶ cmCommandSetChanged == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
52 == $_ and 0 0 0
316 $self->setState(
317 sfDisabled,
318 0 ▶ !TView->commandEnabled( $self->{command} ) ? true : false
Branch: 1 branch
BranchTrueFalseTotal
!'TUI::Views::View'->commandEnabled($self->{'command'}) ? : 0 0 0
319 );
320 0 $self->drawView();
321 0 last;
322 };
323 } #/ SWITCH: for ( $event->{message}...)
324 0 last;
325 };
326
327 } #/ SWITCH: for ( $event->{what} )
328 0 return;
329 } #/ sub handleEvent
330
331 0 ▶sub makeDefault { # void ($enable)
Subroutine makeDefault: not called CC=3 SCAR=24.8
Pod documented
332 0 state $sig = signature(
333 method => Object,
334 pos => [Bool],
335 );
336 0 my ( $self, $enable ) = $sig->( @_ );
337
338 0 ▶ if ( ( $self->{flags} & bfDefault ) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"flags"} & 1) == 0) 0 0 0
339 message(
340 $self->{owner},
341 0 ▶ evBroadcast,
Branch: 1 branch
BranchTrueFalseTotal
$enable ? : 0 0 0
342 $enable ? cmGrabDefault : cmReleaseDefault,
343 $self
344 );
345 0 $self->{amDefault} = $enable;
346 0 $self->drawView();
347 } #/ if ( ( $self->{flags} ...))
348 0 return;
349 } #/ sub makeDefault
350
351 0 ▶sub press { # void ()
Subroutine press: not called CC=2 SCAR=17.9
Pod documented
352 0 state $sig = signature(
353 method => Object,
354 pos => [],
355 );
356 0 my ( $self ) = $sig->( @_ );
357
358 0 message( $self->{owner}, evBroadcast, cmRecordHistory, undef );
359
360 0 ▶ if ( $self->{flags} & bfBroadcast ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'flags'} & 4) { } 0 0 0
361 0 message( $self->{owner}, evBroadcast, $self->{command}, $self );
362 }
363 else {
364 0 my $e = TEvent->new();
365 0 $e->{what} = evCommand;
366 0 $e->{message}{command} = $self->{command};
367 0 $e->{message}{infoPtr} = $self;
368 0 $self->putEvent( $e );
369 }
370 0 return;
371 } #/ sub press
372
373 0 ▶sub setState { # void ($aState, $enable)
Subroutine setState: not called CC=4 SCAR=30.0
Pod documented
374 0 state $sig = signature(
375 method => Object,
376 pos => [PositiveOrZeroInt, Bool],
377 );
378 0 my ( $self, $aState, $enable ) = $sig->( @_ );
379
380 0 $self->SUPER::setState( $aState, $enable );
381 0 ▶ if ( $aState & ( sfSelected | sfActive ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aState & 48) 0 0 0
382 0 ▶ if ( !$enable ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($enable) 0 0 0
383 # BUG FIX - EFW - Thu 10/19/95
384 0 $self->{state} &= ~sfFocused;
385 0 $self->makeDefault( false );
386 }
387 0 $self->drawView();
388 }
389
390 0 ▶ if ( $aState & sfFocused ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aState & 64) 0 0 0
391 0 $self->makeDefault( $enable );
392 }
393 0 return;
394 } #/ sub setState
395
396 0 ▶$drawTitle = sub { # void ($b, $s, $i, $cButton, $down)
Subroutine __ANON__: not called CC=14 SCAR=53.5
397 0 my ( $self, $b, $s, $i, $cButton, $down ) = @_;
398 0 ▶ assert ( @_ == 6 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 0 0
399 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
400 0 ▶ assert ( is_ArrayLike $b );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ArrayLike($b) 0 0 0
401 0 ▶ assert ( is_Int $s );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($s) 0 0 0
402 0 ▶ assert ( is_Int $i );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($i) 0 0 0
403 0 ▶ assert ( is_PositiveOrZeroInt $cButton );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_PositiveOrZeroInt($cButton) 0 0 0
404 0 ▶ assert ( is_Bool $down );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($down) 0 0 0
405
406 0 my ( $l, $scOff );
407 0 ▶ if ( $self->{flags} & bfLeftJust ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'flags'} & 2) { } 0 0 0
408 0 $l = 1;
409 }
410 else {
411 0 my $len = cstrlen( $self->{title} );
412 0 $l = int( ( $s - $len - 1 ) / 2 );
413 0 ▶ $l = 1 if $l < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $l < 1 0 0 0
414 }
415
416 0 $b->moveCStr( $i + $l, $self->{title}, $cButton );
417
418 0 ▶ if ( $showMarkers && !$down ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($TUI::Dialogs::Button::showMarkers and not $down) 0 0 0
Condition0%0/3
$TUI::Dialogs::Button::showMarkers and not $down
!ll&&!rl&&r
000
MC/DC0%0/2
$TUI::Dialogs::Button::showMarkers and not $down
$TUI::Dialogs::Button::showMarkers not $down
Truth table0%0/3
A and not(B)
A= $TUI::Dialogs::Button::showMarkersB= not $down
ABresult
0X0
100
111
419 0 ▶ if ( $self->{state} & sfSelected ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'state'} & 32) { } 0 0 0
elsif ($self->{'amDefault'}) { } 0 0 0
420 0 $scOff = 0;
421 }
422 elsif ( $self->{amDefault} ) {
423 0 $scOff = 2;
424 }
425 else {
426 0 $scOff = 4;
427 }
428 0 $b->putChar( 0, $specialChars->[$scOff] );
429 0 $b->putChar( $s, $specialChars->[$scOff + 1] );
430 } #/ if ( $self->{showMarkers...})
431 0 return;
432 38 }; #/ sub drawTitle
433
434 0 ▶$pressButton = sub { # void ($event)
Subroutine __ANON__: not called CC=4 SCAR=30.0
435 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
436 0 ▶ assert ( is_Object $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($_[0]) 0 0 0
437 0 ▶ assert ( is_Object $_[1] );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($_[1]) 0 0 0
438 0 ...;
439 38 };
440
441 0 ▶$getActiveRect = sub { # $rect ()
Subroutine __ANON__: not called CC=3 SCAR=24.8
442 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
443 0 ▶ assert ( is_Object $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($_[0]) 0 0 0
444 0 ...;
445 38 };
446
447 0 ▶sub write :method { # void ($os)
Subroutine write: not called CC=2 SCAR=17.9
Pod undocumented
448 0 state $sig = signature(
449 method => Object,
450 pos => [Object],
451 );
452 0 my ( $self, $os ) = $sig->( @_ );
453 0 $self->SUPER::write( $os );
454 $os->put(
455 $self->{title},
456 $self->{command},
457 $self->{flags},
458 0 ▶ $self->{amDefault} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$self->{'amDefault'} ? : 0 0 0
459 );
460 0 return;
461 }
462
463 0 ▶sub read :method { # $self ($is)
Subroutine read: not called CC=3 SCAR=24.8
Pod undocumented
464 0 state $sig = signature(
465 method => Object,
466 pos => [Object],
467 );
468 0 my ( $self, $is ) = $sig->( @_ );
469 0 $self->SUPER::read( $is );
470 0 $self->{title} = $is->get();
471 0 $self->{command} = $is->get();
472 0 $self->{flags} = $is->get();
473 0 ▶ $self->{amDefault} = $is->get() ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$is->get ? : 0 0 0
474 0 ▶ if ( TView->commandEnabled( $self->{command} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('TUI::Views::View'->commandEnabled($self->{'command'})) { } 0 0 0
475 0 $self->{state} &= ~sfDisabled;
476 }
477 else {
478 0 $self->{state} |= sfDisabled;
479 }
480 0 return $self;
481 }
482
483 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
484 0 my ( $class ) = @_;
485 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
486 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
487 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
488 0 return $class->new(
489 bounds => TRect->new(),
490 title => '',
491 command => 0,
492 flags => 0,
493 );
494 }
495
496 38 1
497
498 __END__
« lib/TUI/Views/Frame.pm ↑ Summary lib/TUI/Help/HelpViewer.pm »