lib/TUI/Gadgets/MouseDialog.pm

filter: Statementstmt 60.0% 69 / 115 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 20 / 25 Podpod 80.0% 4 / 5 totaltotal 59.2% 93 / 157 CC 8 SCAR 22.8
CC
8
Cov
54%
handleEvent
42.0
BUILD
12.0
new_TMouseDialog
2.0
CRAP 9.8
« lib/TUI/Gadgets/HeapView/Unix.pm ↑ Summary lib/TUI/toolkit/Types.pm »
1 package TUI::Gadgets::MouseDialog;
2 # ABSTRACT: dialog for configuring mouse options
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 4 our @EXPORT = qw(
14 TMouseDialog
15 new_TMouseDialog
16 );
17
18 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
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 is_Object
22 :types
23 4 );
24
25 4 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
26 bfDefault
27 bfNormal
28 4 );
29 4 ▶use TUI::Dialogs::Button;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 4 ▶use TUI::Dialogs::CheckBoxes;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 4 ▶use TUI::Dialogs::Dialog;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 4 ▶use TUI::Dialogs::Label;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 4 ▶use TUI::Dialogs::StrItem;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 4 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
35 evBroadcast
36 evCommand
37 4 );
38 4 ▶use TUI::Drivers::EventQueue;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 4 ▶use TUI::Gadgets::ClickTester;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 4 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 4 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
42 cmCancel
43 cmOK
44 cmScrollBarChanged
45 ofCentered
46 ofSelectable
47 4 );
48 4 ▶use TUI::Views::ScrollBar;
Subroutine BEGIN: called CC=1 SCAR=0.0
49
50 sub TMouseDialog() { __PACKAGE__ }
51 sub name() { 'TMouseDialog' }
52 0 ▶sub new_TMouseDialog { __PACKAGE__->from(@_) }
Subroutine new_TMouseDialog: not called CC=1 SCAR=6.9
Pod documented
53
54 4 extends TDialog;
55
56 # import global variables
57 4 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
58 $doubleDelay
59 4 );
60 {
61 4 *doubleDelay = \$TUI::Drivers::EventQueue::doubleDelay;
62 }
63
64 # private attributes
65 4 has mouseScrollBar => ( is => 'bare' );
66 4 has oldDelay => ( is => 'bare' );
67
68 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
69 0 state $sig = signature(
70 method => 1,
71 named => [],
72 caller_level => +1,
73 );
74 0 my ( $class ) = $sig->( @_ );
75 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
76 0 return $class->SUPER::BUILDARGS(
77 bounds => TRect->new( ax => 0, ay => 0, bx => 34, by => 12 ),
78 title => "Mouse options",
79 );
80 }
81
82 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
83 0 my ( $self, $args ) = @_;
84 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
85 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
86
87 0 my $r = TRect->new( ax => 3, ay => 4, bx => 30, by => 5 );
88
89 0 $self->{options} |= ofCentered;
90
91 0 $self->{mouseScrollBar} = TScrollBar->new( bounds => $r );
92 0 $self->{mouseScrollBar}->setParams( 1, 1, 20, 20, 1 );
93 0 $self->{mouseScrollBar}{options} |= ofSelectable;
94 0 $self->{mouseScrollBar}->setValue( $doubleDelay );
95 0 $self->insert( $self->{mouseScrollBar} );
96
97 0 $r = TRect->new( ax => 2, ay => 2, bx => 21, by => 3 );
98 $self->insert( TLabel->new(
99 bounds => $r,
100 text => "~M~ouse double click",
101 link => $self->{mouseScrollBar},
102 0 ));
103
104 0 $r = TRect->new( ax => 3, ay => 3, bx => 30, by => 4 );
105 0 $self->insert( TClickTester->new(
106 bounds => $r,
107 text => "Fast Medium Slow",
108 ));
109
110 0 $r = TRect->new( ax => 3, ay => 6, bx => 30, by => 7 );
111 0 $self->insert( TCheckBoxes->new(
112 bounds => $r,
113 strings => new_TSItem( "~R~everse mouse buttons", undef ),
114 ));
115 0 $self->{oldDelay} = $doubleDelay;
116
117 0 $r = TRect->new( ax => 9, ay => 9, bx => 19, by => 11 );
118 0 $self->insert( TButton->new(
119 bounds => $r,
120 title => "O~K~",
121 command => cmOK,
122 flags => bfDefault,
123 ));
124
125 0 $r = TRect->new( ax => 21, ay => 9, bx => 31, by => 11 );
126 0 $self->insert( TButton->new(
127 bounds => $r,
128 title => "Cancel",
129 command => cmCancel,
130 flags => bfNormal,
131 ));
132
133 0 $self->selectNext( false );
134 0 return;
135 }
136
137 0 ▶sub from { # $obj ()
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
138 0 state $sig = signature(
139 method => 1,
140 pos => [],
141 );
142 0 my ( $class) = $sig->( @_ );
143 0 return $class->new();
144 }
145
146 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=6 SCAR=37.4
Pod documented
147 0 state $sig = signature(
148 method => Object,
149 pos => [Object],
150 );
151 0 my ( $self, $event ) = $sig->( @_ );
152 0 $self->SUPER::handleEvent( $event );
153 0 SWITCH: for ( $event->{what} ) {
154 0 ▶ evCommand == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
256 == $_ and do { $TUI::Gadgets::MouseDialog::doubleDelay = $self->{"oldDelay"} if $event->{"message"}{"command"} == 11; last } 0 0 0
155 $doubleDelay = $self->{oldDelay}
156 0 ▶ if $event->{message}{command} == cmCancel;
Branch: 1 branch
BranchTrueFalseTotal
if $event->{"message"}{"command"} == 11 0 0 0
157 0 last;
158 };
159 0 ▶ evBroadcast == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
512 == $_ and do { if ($event->{"message"}{"command"} == 53) { $TUI::Gadgets::MouseDialog::doubleDelay = $self->{"mouseScrollBar"}{"value"}; $self->clearEvent($event); } ; last } 0 0 0
160 0 ▶ if ( $event->{message}{command} == cmScrollBarChanged ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"message"}{"command"} == 53) 0 0 0
161 0 $doubleDelay = $self->{mouseScrollBar}{value};
162 0 $self->clearEvent( $event );
163 }
164 0 last;
165 };
166 }
167 0 return;
168 } #/ sub handleEvent
169
170 4 1
171
172 __END__
« lib/TUI/Gadgets/HeapView/Unix.pm ↑ Summary lib/TUI/toolkit/Types.pm »