lib/TUI/Gadgets/Calculator.pm

filter: Statementstmt 63.7% 51 / 80 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 15 / 20 Podpod 60.0% 3 / 5 totaltotal 60.0% 69 / 115 CC 7 SCAR 19.4
CC
7
Cov
57%
BUILD
20.0
build
20.0
new_TCalculator
2.0
CRAP 7.0
« lib/TUI/Gadgets/FileWindow.pm ↑ Summary lib/TUI/Dialogs/ListBox.pm »
1 package TUI::Gadgets::Calculator;
2 # ABSTRACT: dialog window of the calculator gadget
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 5 our @EXPORT = qw(
14 TCalculator
15 new_TCalculator
16 );
17
18 5 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
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 is_Object
23 is_Str
24 :types
25 5 );
26
27 5 ▶use TUI::Dialogs::Button;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
29 bfBroadcast
30 bfNormal
31 5 );
32 5 ▶use TUI::Dialogs::Dialog;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 ▶use TUI::Gadgets::CalcDisplay;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 5 ▶use TUI::Gadgets::Const qw( cmCalcButton );
Subroutine BEGIN: called CC=1 SCAR=0.0
35 5 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
37 ofFirstClick
38 ofSelectable
39 5 );
40
41 sub TCalculator() { __PACKAGE__ }
42 sub name() { 'TCalculator' }
43 0 ▶sub new_TCalculator { __PACKAGE__->from(@_) }
Subroutine new_TCalculator: not called CC=1 SCAR=6.9
Pod undocumented
44
45 5 extends TDialog;
46
47 # button captions, row by row
48 5 my @keyChar = (
49 "C", "\x1B", "%", "\xF1", # 0x1B is escape, 0xF1 is the +/- char
50 "7", "8", "9", "/",
51 "4", "5", "6", "*",
52 "1", "2", "3", "-",
53 "0", ".", "=", "+",
54 );
55
56 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
57 0 state $sig = signature(
58 method => 1,
59 named => [],
60 caller_level => +1,
61 );
62 0 my ( $class ) = $sig->( @_ );
63 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
64 0 return $class->SUPER::BUILDARGS(
65 bounds => TRect->new( ax => 5, ay => 3, bx => 29, by => 18 ),
66 title => "Calculator",
67 );
68 }
69
70 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=4 SCAR=30.0
Pod documented
71 0 my ( $self, $args ) = @_;
72 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
73 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
74
75 0 $self->{options} |= ofFirstClick;
76
77 0 for my $i ( 0 .. $#keyChar ) {
78 0 my $x = ( $i % 4 ) * 5 + 2;
79 0 my $y = int( $i / 4 ) * 2 + 4;
80 0 my $button = TButton->new(
81 bounds => TRect->new( ax => $x, ay => $y, bx => $x + 5, by => $y + 2 ),
82 title => $keyChar[$i],
83 command => cmCalcButton,
84 flags => bfNormal | bfBroadcast,
85 );
86 0 $button->{options} &= ~ofSelectable;
87 0 $self->insert( $button );
88 }
89
90 0 $self->insert( TCalcDisplay->new(
91 bounds => TRect->new( ax => 3, ay => 2, bx => 21, by => 3 ),
92 ));
93 }
94
95 0 ▶sub from { # $obj ()
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
96 0 state $sig = signature(
97 method => 1,
98 pos => [],
99 );
100 0 my ( $class ) = $sig->( @_ );
101 0 return $class->new();
102 }
103
104 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod documented
105 0 my ( $class ) = @_;
106 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
107 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
108 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
109 0 return $class->new();
110 }
111
112 5 1
113
114 __END__
« lib/TUI/Gadgets/FileWindow.pm ↑ Summary lib/TUI/Dialogs/ListBox.pm »