| 1 | package TUI::Dialogs::MultiCheckBoxes; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Multi-state checkbox cluster control based on TCluster | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '2.000002'; | |||||||||||||||||||||||||||
| 9 | 4 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||
| 10 | 4 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 15 | TMultiCheckBoxes | ||||||||||||||||||||||||||||
| 16 | new_TMultiCheckBoxes | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | Maybe | ||||||||||||||||||||||||||||
| 22 | is_Object | ||||||||||||||||||||||||||||
| 23 | :types | ||||||||||||||||||||||||||||
| 24 | 4 | ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use TUI::Dialogs::Cluster; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub TMultiCheckBoxes() { __PACKAGE__ } | ||||||||||||||||||||||||||||
| 29 | sub name() { 'TMultiCheckBoxes' } | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub new_TMultiCheckBoxes { __PACKAGE__->from( @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
new_TMultiCheckBoxes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 4 | extends TCluster; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # private attributes | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | has selRange => ( is => 'bare', default => sub { die 'required' } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | has flags => ( is => 'bare', default => sub { die 'required' } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | has states => ( is => 'bare', default => sub { die 'required' } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 41 | method => 1, | ||||||||||||||||||||||||||||
| 42 | named => [ | ||||||||||||||||||||||||||||
| 43 | bounds => Object, | ||||||||||||||||||||||||||||
| 44 | strings => Maybe[HashLike], { alias => 'aStrings' }, | ||||||||||||||||||||||||||||
| 45 | selRange => Int, | ||||||||||||||||||||||||||||
| 46 | flags => PositiveOrZeroInt, | ||||||||||||||||||||||||||||
| 47 | states => Str, | ||||||||||||||||||||||||||||
| 48 | ], | ||||||||||||||||||||||||||||
| 49 | caller_level => +1, | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | 0 | my ( $class, $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 52 | 0 | return { %$args }; | |||||||||||||||||||||||||||
| 53 | } #/ sub BUILDARGS | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub from { # $obj ($bounds, $aStrings|undef, $aSelRange, $aFlags, $aStates) | ||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 57 | method => 1, | ||||||||||||||||||||||||||||
| 58 | pos => [Object, Maybe[HashLike], Int, PositiveOrZeroInt, Str], | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 61 | 0 | return $class->new( | |||||||||||||||||||||||||||
| 62 | bounds => $args[0], strings => $args[1], selRange => $args[2], | ||||||||||||||||||||||||||||
| 63 | flags => $args[3], states => $args[4] | ||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub DEMOLISH { # void ($in_global_destruction) | ||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 0 | my ( $self, $in_global_destruction ) = @_; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | $self->{states} = undef; | |||||||||||||||||||||||||||
| 72 | 0 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub dataSize { # $size () | ||||||||||||||||||||||||||
|
Subroutine
dataSize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 77 | method => Object, | ||||||||||||||||||||||||||||
| 78 | pos => [], | ||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||
| 80 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||
| 81 | 0 | return 1; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub draw { # void () | ||||||||||||||||||||||||||
|
Subroutine
draw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 86 | method => Object, | ||||||||||||||||||||||||||||
| 87 | pos => [], | ||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||
| 89 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 90 | 0 | $self->drawMultiBox( " [ ] ", $self->{states} ); | |||||||||||||||||||||||||||
| 91 | 0 | return; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub getData { # void (\@p) | ||||||||||||||||||||||||||
|
Subroutine
getData: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 96 | method => Object, | ||||||||||||||||||||||||||||
| 97 | pos => [ArrayLike], | ||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||
| 99 | 0 | my ( $self, $p ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 100 | 0 | $p->[0] = $self->{value}; | |||||||||||||||||||||||||||
| 101 | 0 | $self->drawView(); | |||||||||||||||||||||||||||
| 102 | 0 | return; | |||||||||||||||||||||||||||
| 103 | } #/ sub getData | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub multiMark { # $int ($item) | ||||||||||||||||||||||||||
|
Subroutine
multiMark: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 107 | method => Object, | ||||||||||||||||||||||||||||
| 108 | pos => [Int], | ||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||
| 110 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 111 | return ( | ||||||||||||||||||||||||||||
| 112 | $self->{value} & | ||||||||||||||||||||||||||||
| 113 | ( ( $self->{flags} & 0xff ) << ( $item * ( $self->{flags} >> 8 ) ) ) | ||||||||||||||||||||||||||||
| 114 | 0 | ) >> ( $item * ( $self->{flags} >> 8 ) ); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub press { # void ($item) | ||||||||||||||||||||||||||
|
Subroutine
press: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 118 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 119 | method => Object, | ||||||||||||||||||||||||||||
| 120 | pos => [Int], | ||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||
| 122 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 123 | 0 | my $flo = $self->{flags} & 0xff; | |||||||||||||||||||||||||||
| 124 | 0 | my $fhi = $self->{flags} >> 8; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | my $curState = | ||||||||||||||||||||||||||||
| 127 | 0 | ( $self->{value} & ( $flo << ( $item * $fhi ) ) ) >> ( $item * $fhi ); | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | $curState--; | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $curState >= $self->{selRange} || $curState < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$curState >= $self->{"selRange"} or $curState < 0
MC/DC0%0/2
$curState >= $self->{"selRange"} or $curState < 0
$curState >= $self->{"selRange"}
$curState < 0
Truth table0%0/3
A or B
A= $curState >= $self->{"selRange"}B= $curState < 0
| |||||||||||||||||||||||||||||
| 131 | 0 | $curState = $self->{selRange} - 1; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | $self->{value} = ( $self->{value} & ~( $flo << ( $item * $fhi ) ) ) | | |||||||||||||||||||||||||||
| 135 | ( $curState << ( $item * $fhi ) ); | ||||||||||||||||||||||||||||
| 136 | 0 | return; | |||||||||||||||||||||||||||
| 137 | } #/ sub press | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub setData { # void (\@p) | ||||||||||||||||||||||||||
|
Subroutine
setData: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 141 | method => Object, | ||||||||||||||||||||||||||||
| 142 | pos => [ArrayLike], | ||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||
| 144 | 0 | my ( $self, $p ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 145 | 0 | $self->{value} = 0+ $p->[0]; | |||||||||||||||||||||||||||
| 146 | 0 | $self->drawView(); | |||||||||||||||||||||||||||
| 147 | 0 | return; | |||||||||||||||||||||||||||
| 148 | } #/ sub setData | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 4 | 1 | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||