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