blib/lib/Curses/UI/Widget.pm

filter: Statementstmt 41.2% 209 / 507 Branchbran 28.1% 85 / 302 Conditioncond 25.0% 29 / 116 MC/DCmcdc 2.8% 2 / 70 Subroutinesub 44.7% 30 / 67 Podpod 57.1% 32 / 56 totaltotal 34.6% 387 / 1118 CC 206 SCAR 58.8
CC
206
Cov
35%
draw_scrollbars
1722.0
draw
429.4
layout
239.1
CRAP 359.0
« blib/lib/Curses/UI/Notebook.pm ↑ Summary lib/Curses/UI/Common.pm »
1 # ----------------------------------------------------------------------
2 # Curses::UI::Widget
3 #
4 # (c) 2001-2002 by Maurice Makaay. All rights reserved.
5 # This file is part of Curses::UI. Curses::UI is free software.
6 # You can redistribute it and/or modify it under the same terms
7 # as perl itself.
8 #
9 # Currently maintained by Marcus Thiesen
10 # e-mail: marcus@cpan.thiesenweb.de
11 # ----------------------------------------------------------------------
12  
13 package Curses::UI::Widget;
14  
15 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 8 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 ▶use Term::ReadKey;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶use Curses;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use Curses::UI::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 8 require Exporter;
21  
22 8 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
23 $VERSION
24 @ISA
25 @EXPORT
26 8 );
27  
28 8 $VERSION = '1.12';
29  
30 8 @ISA = qw(
31 Curses::UI::Common
32 Exporter
33 );
34  
35 8 @EXPORT = qw(
36 height_by_windowscrheight
37 width_by_windowscrwidth
38 process_padding
39 loose_focus
40 lose_focus
41 );
42  
43 sub new ()
44 19 ▶{
Subroutine new: called CC=11 SCAR=26.5
Pod documented
45 19 my $class = shift;
46  
47 19 my %userargs = @_;
48 19 keys_to_lowercase(\%userargs);
49  
50 19 my %args = (
51 -parent => undef, # the parent object
52 -x => 0, # horizontal position (rel. to -parent)
53 -y => 0, # vertical position (rel. to -parent)
54 -width => undef, # horizontal size
55 -height => undef, # vertical size
56 -border => 0, # add a border?
57 -sbborder => 0, # add square bracket border?
58 -nocursor => 0, # Show a cursor?
59 -titlefullwidth => 0, # full width for title?
60 -titlereverse => 1, # reverse chars for title?
61 -title => undef, # A title to add to the widget (only for
62 # -border = 1)
63 # padding outside widget
64 -pad => undef, # all over padding
65 -padright => undef, # free space on the right side
66 -padleft => undef, # free space on the left side
67 -padtop => undef, # free space above
68 -padbottom => undef, # free space below
69  
70 # padding inside widget
71 -ipad => undef, # all over padding
72 -ipadright => undef, # free space on the right side
73 -ipadleft => undef, # free space on the left side
74 -ipadtop => undef, # free space above
75 -ipadbottom => undef, # free space below
76  
77 # scrollbars
78 -vscrollbar => 0, # vert. scrollbar (top/bottom)
79 -vscrolllen => 0, # total number of rows
80 -vscrollpos => 0, # current row position
81 -hscrollbar => 0, # hor. scrollbar (left/right)
82 -hscrolllen => 0, # total number of columns
83 -hscrollpos => 0, # current column position
84  
85 -onfocus => undef, # onFocus event handler
86 -onblur => undef, # onBlur event handler
87 -intellidraw => 1, # Support intellidraw()?
88 -focusable => 1, # This widget can get focus
89 -htmltext => 1, # Recognize HTML tags in drawn text
90  
91 #user data
92 -userdata => undef, #user internal data
93  
94 #color
95 # Border
96 -bfg => -1,
97 -bbg => -1,
98 # Scrollbar
99 -sfg => -1,
100 -sbg => -1,
101 # Titlebar
102 -tfg => -1,
103 -tbg => -1,
104  
105 %userargs,
106
107 -focus => 0, # has the widget focus?
108 );
109  
110 # Allow the value -1 for using the full width and/or
111 # height for the widget.
112 $args{-width} = undef
113 19 ▶ if defined $args{-width} and $args{-width} == -1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"-width"} and $args{"-width"} == -1 0 19 19
Condition66%2/3
defined $args{"-width"} and $args{"-width"} == -1
!ll&&!rl&&r
1270
MC/DC0%0/2
defined $args{"-width"} and $args{"-width"} == -1
defined $args{"-width"} $args{"-width"} == -1
Truth table66%2/3
A and B
A= defined $args{"-width"}B= $args{"-width"} == -1
ABresult
0X0
100
111
114 $args{-height} = undef
115 19 ▶ if defined $args{-height} and $args{-height} == -1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"-height"} and $args{"-height"} == -1 0 19 19
Condition66%2/3
defined $args{"-height"} and $args{"-height"} == -1
!ll&&!rl&&r
1180
MC/DC0%0/2
defined $args{"-height"} and $args{"-height"} == -1
defined $args{"-height"} $args{"-height"} == -1
Truth table66%2/3
A and B
A= defined $args{"-height"}B= $args{"-height"} == -1
ABresult
0X0
100
111
116  
117 &Curses::UI::fatalerror(
118 "Missing or illegal parameter: -parent\n"
119 . "while creating " . caller() . "object"
120 19 ▶ ) unless defined $args{-parent} and ref $args{-parent};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"-parent"} and ref $args{"-parent"} 0 19 19
Condition33%1/3
defined $args{"-parent"} and ref $args{"-parent"}
!ll&&!rl&&r
0019
MC/DC0%0/2
defined $args{"-parent"} and ref $args{"-parent"}
defined $args{"-parent"} ref $args{"-parent"}
Truth table33%1/3
A and B
A= defined $args{"-parent"}B= ref $args{"-parent"}
ABresult
0X0
100
111
121
122 # Allow a square bracket border only if
123 # a normal border (-border) is disabled.
124 19 ▶ $args{-sbborder} = 0 if $args{-sbborder} and $args{-border};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-sbborder"} and $args{"-border"} 0 19 19
Condition66%2/3
$args{"-sbborder"} and $args{"-border"}
!ll&&!rl&&r
1810
MC/DC0%0/2
$args{"-sbborder"} and $args{"-border"}
$args{"-sbborder"} $args{"-border"}
Truth table66%2/3
A and B
A= $args{"-sbborder"}B= $args{"-border"}
ABresult
0X0
100
111
125
126 # Bless you! (so we can call the layout function).
127 19 my $this = bless \%args, $class;
128  
129 19 $this->layout;
130  
131 19 ▶ if ($Curses::UI::ncurses_mouse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::ncurses_mouse) 19 0 19
132 $this->set_mouse_binding(\&mouse_button1, BUTTON1_CLICKED())
133 19 ▶ unless $this->{-mousebindings}->{BUTTON1_CLICKED()};
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"-mousebindings"}{BUTTON1_CLICKED()} 19 0 19
134 }
135  
136 19 return $this;
137 }
138  
139 sub DESTROY()
140 0 ▶{
Subroutine DESTROY: not called CC=1 SCAR=6.9
141 0 my $this = shift;
142 0 $this->delete_subwindows();
143 }
144  
145 sub userdata
146 0 ▶{
Subroutine userdata: not called CC=2 SCAR=17.9
Pod documented
147 0 my $this = shift;
148 0 ▶ if (defined $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
149 {
150 0 $this->{-userdata} = $_[0];
151 }
152 0 return $this->{-userdata};
153 }
154  
155 3 ▶sub focusable(;$) {
Subroutine focusable: called CC=4 SCAR=14.8
Pod documented
156 3 my $this = shift;
157 3 my $focusable = shift;
158  
159 3 ▶ if (defined $focusable)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $focusable) 1 2 3
160 {
161 1 $this->accessor('-focusable', $focusable);
162  
163 # Let the parent find another widget to focus
164 # if this widget is not focusable anymore.
165 1 ▶ if ($this->{-focus} and not $focusable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-focus"} and not $focusable) 0 1 1
Condition33%1/3
$this->{"-focus"} and not $focusable
!ll&&!rl&&r
100
MC/DC0%0/2
$this->{"-focus"} and not $focusable
$this->{"-focus"} not $focusable
Truth table33%1/3
A and not(B)
A= $this->{"-focus"}B= not $focusable
ABresult
0X0
100
111
166 0 $this->parent->focus($this);
167 }
168 }
169  
170 3 return $this->{-focusable};
171 }
172  
173 sub layout()
174 18 ▶{
Subroutine layout: called CC=49 SCAR=54.8
Pod documented
175 18 cbreak();
176
177 18 my $this = shift;
178  
179 18 ▶ return if $Curses::UI::screen_too_small;
Branch: 1 branch
BranchTrueFalseTotal
if $Curses::UI::screen_too_small 4 14 18
180  
181 14 $this->process_padding;
182
183 # -------------------------------------------------------
184 # Compute the space that we have for the widget.
185 # -------------------------------------------------------
186  
187 14 $this->{-parentdata} = $this->{-parent}->windowparameters;
188  
189 14 foreach (qw(x y)) {
190 0 ▶ if (not defined $this->{"-$_"}) {$this->{"-$_"} = 0}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $$this{"-$_"}) 0 28 28
191 28 ▶ if ($this->{"-$_"} >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$this{"-$_"} >= 0) { } 28 0 28
192 28 $this->{"-real$_"} = $this->{"-$_"};
193 } else {
194 0 ▶ my $pv = ($_ eq 'x' ? '-w' : '-h');
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'x' ? : 0 0 0
195 $this->{"-real$_"} = $this->{-parentdata}->{$pv}
196 0 + $this->{"-$_"} + 1;
197 }
198 }
199  
200 14 my $w = $this->{-parentdata}->{-w};
201 14 my $h = $this->{-parentdata}->{-h};
202  
203 14 my $cor_h = $this->{-y};
204 14 ▶ $cor_h = abs($this->{-y}+1) if $cor_h < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cor_h < 0 0 14 14
205 14 my $cor_w = $this->{-x};
206 14 ▶ $cor_w = abs($this->{-x}+1) if $cor_w < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cor_w < 0 0 14 14
207
208 14 my $avail_h = $h - $cor_h;
209 14 my $avail_w = $w - $cor_w;
210
211 # Compute horizontal widget size and adjust if neccessary.
212 my $min_w = ($this->{-border} ? 2 : 0)
213 + ($this->{-sbborder} ? 2 : 0)
214 + (defined $this->{-vscrollbar} ? 1 : 0)
215 + $this->{-padleft}
216 14 ▶ + $this->{-padright};
Branch: 3 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-sbborder'} ? : 0 14 14
defined $this->{'-vscrollbar'} ? : 14 0 14
217 14 ▶ my $width = (defined $this->{-width} ? $this->{-width} : $avail_w);
Branch: 1 branch
BranchTrueFalseTotal
defined $this->{'-width'} ? : 3 11 14
218 14 ▶ $width = $min_w if $width < $min_w;
Branch: 1 branch
BranchTrueFalseTotal
if $width < $min_w 0 14 14
219 14 ▶ $width = $avail_w if $width > $avail_w;
Branch: 1 branch
BranchTrueFalseTotal
if $width > $avail_w 0 14 14
220  
221 # Compute vertical widget size and adjust if neccessary.
222 my $min_h = ($this->{-border} ? 2 : 0)
223 + ($this->{-hscrollbar} ? 1 : 0)
224 + (defined $this->{-hscrollbar} ? 1 : 0)
225 + $this->{-padtop}
226 14 ▶ + $this->{-padbottom};
Branch: 3 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-hscrollbar'} ? : 0 14 14
defined $this->{'-hscrollbar'} ? : 14 0 14
227 14 ▶ my $height = (defined $this->{-height} ? $this->{-height} : $avail_h);
Branch: 1 branch
BranchTrueFalseTotal
defined $this->{'-height'} ? : 5 9 14
228 14 ▶ $height = $min_h if $height < $min_h;
Branch: 1 branch
BranchTrueFalseTotal
if $height < $min_h 0 14 14
229 14 ▶ $height = $avail_h if $height > $avail_h;
Branch: 1 branch
BranchTrueFalseTotal
if $height > $avail_h 0 14 14
230  
231 # Check if the widget fits in the window.
232 14 ▶ if ($width > $avail_w or $height > $avail_h or
Branch: 1 branch
BranchTrueFalseTotal
if ($width > $avail_w or $height > $avail_h or $width == 0 or $height == 0) 0 14 14
Condition33%3/9
$width > $avail_w or $height > $avail_h or $width == 0 or $height == 0
l!l&&r!l&&!r
0014
$width > $avail_w or $height > $avail_h or $width == 0
l!l&&r!l&&!r
0014
$width > $avail_w or $height > $avail_h
l!l&&r!l&&!r
0014
MC/DC0%0/4
$width > $avail_w or $height > $avail_h or $width == 0 or $height == 0
$width > $avail_w $height > $avail_h $width == 0 $height == 0
Truth table20%1/5
A or B or C or D
A= $width > $avail_wB= $height > $avail_hC= $width == 0D= $height == 0
ABCDresult
1XXX1
01XX1
001X1
00011
00000
233 $width == 0 or
234 $height == 0) {
235 0 $Curses::UI::screen_too_small++;
236 0 return $this;
237 }
238  
239 14 $this->{-w} = $width;
240 14 $this->{-h} = $height;
241  
242 0 ▶ if ($this->{-x} < 0) { $this->{-realx} -= $width }
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-x"} < 0) 0 14 14
243 0 ▶ if ($this->{-y} < 0) { $this->{-realy} -= $height }
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-y"} < 0) 0 14 14
244
245 # Take care of padding for the border.
246 14 $this->{-bw} = $width - $this->{-padleft} - $this->{-padright};
247 14 $this->{-bh} = $height - $this->{-padtop} - $this->{-padbottom};
248 14 $this->{-bx} = $this->{-realx} + $this->{-padleft};
249 14 $this->{-by} = $this->{-realy} + $this->{-padtop};
250  
251 # -------------------------------------------------------
252 # Create a window for the widget border, if a border
253 # and/or scrollbars are wanted.
254 # -------------------------------------------------------
255  
256 14 ▶ if ($this->{-border} or
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-border"} or $this->{"-sbborder"} or $this->{"-vscrollbar"} or $this->{"-hscrollbar"}) 0 14 14
Condition33%3/9
$this->{"-border"} or $this->{"-sbborder"} or $this->{"-vscrollbar"} or $this->{"-hscrollbar"}
l!l&&r!l&&!r
0014
$this->{"-border"} or $this->{"-sbborder"} or $this->{"-vscrollbar"}
l!l&&r!l&&!r
0014
$this->{"-border"} or $this->{"-sbborder"}
l!l&&r!l&&!r
0014
MC/DC0%0/4
$this->{"-border"} or $this->{"-sbborder"} or $this->{"-vscrollbar"} or $this->{"-hscrollbar"}
$this->{"-border"} $this->{"-sbborder"} $this->{"-vscrollbar"} $this->{"-hscrollbar"}
Truth table20%1/5
A or B or C or D
A= $this->{"-border"}B= $this->{"-sbborder"}C= $this->{"-vscrollbar"}D= $this->{"-hscrollbar"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
257 $this->{-sbborder} or
258 $this->{-vscrollbar} or
259 $this->{-hscrollbar})
260 {
261 my @args = ($this->{-bh}, $this->{-bw},
262 0 $this->{-by}, $this->{-bx});
263  
264 $this->{-borderscr} =
265 0 $this->{-parent}->{-canvasscr}->derwin(@args);
266  
267 0 ▶ unless (defined $this->{-borderscr})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->{"-borderscr"}) 0 0 0
268 {
269 0 $Curses::UI::screen_too_small++;
270 0 return $this;
271 }
272 }
273  
274 # -------------------------------------------------------
275 # Create canvas screen region
276 # -------------------------------------------------------
277  
278 $this->{-sh} = $this->{-bh}
279 - $this->{-ipadtop}
280 - $this->{-ipadbottom}
281 - ($this->{-border}? 2 : 0)
282 14 ▶ - (not $this->{-border} and $this->{-hscrollbar} ? 1 : 0);
Branch: 2 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-hscrollbar'} ? : 0 14 14
Condition33%1/3
!$this->{'-border'} && ($this->{'-hscrollbar'} ? 1 : 0)
!ll&&!rl&&r
0140
MC/DC0%0/2
!$this->{'-border'} && ($this->{'-hscrollbar'} ? 1 : 0)
!$this->{'-border'} ($this->{'-hscrollbar'} ? 1 : 0)
Truth table33%1/3
not(A) && B
A= !$this->{'-border'}B= ($this->{'-hscrollbar'} ? 1 : 0)
ABresult
0X0
100
111
283  
284 $this->{-sw} = $this->{-bw}
285 - $this->{-ipadleft}
286 - $this->{-ipadright}
287 - ($this->{-border}? 2 : 0)
288 - ($this->{-sbborder}? 2 : 0)
289 14 ▶ - (not $this->{-border} and $this->{-vscrollbar} ? 1 : 0);
Branch: 3 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-sbborder'} ? : 0 14 14
$this->{'-vscrollbar'} ? : 0 14 14
Condition33%1/3
!$this->{'-border'} && ($this->{'-vscrollbar'} ? 1 : 0)
!ll&&!rl&&r
0140
MC/DC0%0/2
!$this->{'-border'} && ($this->{'-vscrollbar'} ? 1 : 0)
!$this->{'-border'} ($this->{'-vscrollbar'} ? 1 : 0)
Truth table33%1/3
not(A) && B
A= !$this->{'-border'}B= ($this->{'-vscrollbar'} ? 1 : 0)
ABresult
0X0
100
111
290  
291 $this->{-sy} = $this->{-by}
292 + $this->{-ipadtop}
293 + ($this->{-border}?1:0)
294 + (not $this->{-border} and
295 14 ▶ $this->{-hscrollbar} eq 'top' ? 1 : 0);
Branch: 2 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-hscrollbar'} eq 'top' ? : 0 14 14
Condition33%1/3
!$this->{'-border'} && ($this->{'-hscrollbar'} eq 'top' ? 1 : 0)
!ll&&!rl&&r
0140
MC/DC0%0/2
!$this->{'-border'} && ($this->{'-hscrollbar'} eq 'top' ? 1 : 0)
!$this->{'-border'} ($this->{'-hscrollbar'} eq 'top' ? 1 : 0)
Truth table33%1/3
not(A) && B
A= !$this->{'-border'}B= ($this->{'-hscrollbar'} eq 'top' ? 1 : 0)
ABresult
0X0
100
111
296  
297 $this->{-sx} = $this->{-bx}
298 + $this->{-ipadleft}
299 + ($this->{-border}?1:0)
300 + ($this->{-sbborder}?1:0)
301 + (not $this->{-border} and
302 14 ▶ $this->{-vscrollbar} eq 'left' ? 1 : 0);
Branch: 3 branches
BranchTrueFalseTotal
$this->{'-border'} ? : 0 14 14
$this->{'-sbborder'} ? : 0 14 14
$this->{'-vscrollbar'} eq 'left' ? : 0 14 14
Condition33%1/3
!$this->{'-border'} && ($this->{'-vscrollbar'} eq 'left' ? 1 : 0)
!ll&&!rl&&r
0140
MC/DC0%0/2
!$this->{'-border'} && ($this->{'-vscrollbar'} eq 'left' ? 1 : 0)
!$this->{'-border'} ($this->{'-vscrollbar'} eq 'left' ? 1 : 0)
Truth table33%1/3
not(A) && B
A= !$this->{'-border'}B= ($this->{'-vscrollbar'} eq 'left' ? 1 : 0)
ABresult
0X0
100
111
303  
304 # Check if there is room left for the screen.
305 14 ▶ if ($this->{-sw} <= 0 or $this->{-sh} <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-sw"} <= 0 or $this->{"-sh"} <= 0) 0 14 14
Condition33%1/3
$this->{"-sw"} <= 0 or $this->{"-sh"} <= 0
l!l&&r!l&&!r
0014
MC/DC0%0/2
$this->{"-sw"} <= 0 or $this->{"-sh"} <= 0
$this->{"-sw"} <= 0 $this->{"-sh"} <= 0
Truth table33%1/3
A or B
A= $this->{"-sw"} <= 0B= $this->{"-sh"} <= 0
ABresult
1X1
011
000
306 0 $Curses::UI::screen_too_small++;
307 0 return $this;
308 }
309  
310 # Create a window for the data.
311 my @args = ($this->{-sh}, $this->{-sw},
312 14 $this->{-sy}, $this->{-sx});
313  
314 $this->{-canvasscr} =
315 14 $this->{-parent}->{-canvasscr}->derwin(@args);
316
317 14 ▶ unless (defined $this->{-canvasscr})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->{"-canvasscr"}) 0 14 14
318 {
319 0 $Curses::UI::screen_too_small++;
320 0 return $this;
321 }
322  
323 14 ▶ unless (defined $this->{-borderscr})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->{"-borderscr"}) 14 0 14
324 {
325 14 $this->{-bw} = $this->{-sw};
326 14 $this->{-bh} = $this->{-sh};
327 14 $this->{-bx} = $this->{-sx};
328 14 $this->{-by} = $this->{-sy};
329 }
330  
331 14 return $this;
332 }
333  
334  
335 sub process_padding($;)
336 16 ▶{
Subroutine process_padding: called CC=8 SCAR=23.9
Pod undocumented
337 16 my $this = shift;
338  
339 # Process the padding arguments.
340 16 foreach my $type ('-pad','-ipad') {
341 32 ▶ if (defined $this->{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{$type}) 0 32 32
342 0 foreach my $side ('right','left','top','bottom') {
343 $this->{$type . $side} = $this->{$type}
344 0 ▶ unless defined $this->{$type . $side};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$this{$type . $side} 0 0 0
345 }
346 }
347 }
348 16 foreach my $type ('-pad','-ipad') {
349 32 foreach my $side ('right','left','top','bottom') {
350 $this->{$type . $side} = 0
351 128 ▶ unless defined $this->{$type . $side};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$this{$type . $side} 92 36 128
352 }
353 }
354 }
355  
356 sub width_by_windowscrwidth($@)
357 0 ▶{
Subroutine width_by_windowscrwidth: not called CC=12 SCAR=50.5
Pod documented
358 0 ▶ my $width = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
359 0 ▶ $width = shift if ref $width; # make $this->width... possible.
Branch: 1 branch
BranchTrueFalseTotal
if ref $width 0 0 0
360 0 my %args = @_;
361
362 0 ▶ $width += 2 if $args{-border}; # border
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-border"} 0 0 0
363 0 ▶ $width += 2 if $args{-sbborder}; # sbborder
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-sbborder"} 0 0 0
364 $width += 1 if (not $args{-border} and # scrollbar and no border
365 not $args{-sbborder} and
366 0 ▶ $args{-vscrollbar});
Branch: 1 branch
BranchTrueFalseTotal
if not $args{"-border"} || $args{"-sbborder"} and $args{"-vscrollbar"} 0 0 0
Condition0%0/6
not $args{"-border"} || $args{"-sbborder"} and $args{"-vscrollbar"}
!ll&&!rl&&r
000
$args{'-border'} || $args{'-sbborder'}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $args{"-border"} || $args{"-sbborder"} and $args{"-vscrollbar"}
$args{'-border'} $args{'-sbborder'} $args{"-vscrollbar"}
Truth table0%0/4
not(A || B) and C
A= $args{'-border'}B= $args{'-sbborder'}C= $args{"-vscrollbar"}
ABCresult
1XX0
01X0
0000
0011
367  
368 0 foreach my $t ("-ipad", "-pad") # internal + external padding
369 {
370 0 ▶ if ($args{$t}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{$t}) { } 0 0 0
371 0 $width += 2*$args{$t};
372 } else {
373 0 ▶ $width += $args{$t . "left"} if defined $args{$t . "left"};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{$t . 'left'} 0 0 0
374 0 ▶ $width += $args{$t . "right"} if defined $args{$t . "right"};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{$t . 'right'} 0 0 0
375 }
376 }
377 0 return $width;
378 }
379  
380 sub height_by_windowscrheight($@)
381 1 ▶{
Subroutine height_by_windowscrheight: called CC=10 SCAR=26.8
Pod documented
382 1 ▶ my $height = shift || 0;
Condition50%1/2
shift() || 0
l!l
10
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
383 1 ▶ $height = shift if ref $height; # make $this->height... possible.
Branch: 1 branch
BranchTrueFalseTotal
if ref $height 0 1 1
384 1 my %args = @_;
385
386 1 ▶ $height += 2 if $args{-border}; # border
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-border"} 0 1 1
387 1 ▶ $height += 1 if (not $args{-border} and $args{-hscrollbar});
Branch: 1 branch
BranchTrueFalseTotal
if not $args{"-border"} and $args{"-hscrollbar"} 0 1 1
Condition33%1/3
not $args{"-border"} and $args{"-hscrollbar"}
!ll&&!rl&&r
010
MC/DC0%0/2
not $args{"-border"} and $args{"-hscrollbar"}
not $args{"-border"} $args{"-hscrollbar"}
Truth table33%1/3
not(A) and B
A= not $args{"-border"}B= $args{"-hscrollbar"}
ABresult
0X0
100
111
388 1 foreach my $t ("-ipad", "-pad") # internal + external padding
389 {
390 2 ▶ if ($args{$t})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{$t}) { } 0 2 2
391 {
392 0 $height += 2*$args{$t};
393 } else {
394 2 ▶ $height += $args{$t . "top"} if defined $args{$t . "top"};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{$t . 'top'} 0 2 2
395 2 ▶ $height += $args{$t . "bottom"} if defined $args{$t . "bottom"};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{$t . 'bottom'} 0 2 2
396 }
397 }
398 1 return $height;
399 }
400  
401 0 ▶sub width { shift->{-w} }
Subroutine width: not called CC=1 SCAR=6.9
Pod documented
402 0 ▶sub height { shift->{-h} }
Subroutine height: not called CC=1 SCAR=6.9
Pod documented
403 0 ▶sub borderwidth { shift->{-bw} }
Subroutine borderwidth: not called CC=1 SCAR=6.9
Pod documented
404 0 ▶sub borderheight { shift->{-bh} }
Subroutine borderheight: not called CC=1 SCAR=6.9
Pod documented
405 15 ▶sub canvaswidth { shift->{-sw} }
Subroutine canvaswidth: called CC=1 SCAR=0.0
Pod documented
406 17 ▶sub canvasheight { shift->{-sh} }
Subroutine canvasheight: called CC=1 SCAR=0.0
Pod documented
407  
408 sub title ($;)
409 0 ▶{
Subroutine title: not called CC=2 SCAR=17.9
Pod documented
410 0 my $this = shift;
411 0 my $title = shift;
412  
413 0 ▶ if (defined $title)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $title) 0 0 0
414 {
415 0 $this->{-title} = $title;
416 0 $this->intellidraw;
417 }
418  
419 return $this->{-title}
420 0 }
421  
422 sub windowparameters()
423 16 ▶{
Subroutine windowparameters: called CC=2 SCAR=7.0
Pod undocumented
424 16 my $this = shift;
425 16 my $scr = shift;
426  
427 16 ▶ $scr = "-canvasscr" unless defined $scr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scr 16 0 16
428 16 my $s = $this->{$scr};
429 16 my ($x,$y,$w,$h);
430  
431 16 $s->getbegyx($y, $x);
432 16 $s->getmaxyx($h, $w);
433  
434 return {
435 16 -w => $w,
436 -h => $h,
437 -x => $x,
438 -y => $y,
439 };
440 }
441  
442 #
443 # Actually, the focus is not loose but the widget should
444 # lose the focus:
445  
446 sub lose_focus()
447 0 ▶{
Subroutine lose_focus: not called CC=1 SCAR=6.9
Pod documented
448 0 my $this = shift;
449 0 $this->loose_focus(@_);
450 }
451  
452  
453 sub loose_focus()
454 0 ▶{
Subroutine loose_focus: not called CC=5 SCAR=34.0
Pod undocumented
455 0 my $this = shift;
456 0 my $key = shift;
457
458 # The focus change will draw $this anyhow and this
459 # will reset the schedule if somewhere in the middle of
460 # a binding routine loose_focus() is called (else
461 # first the focus would shift and after that $this
462 # would be redrawn).
463 #
464 0 $this->schedule_draw(0);
465  
466 0 ▶ if ($this->{-has_modal_focus}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'-has_modal_focus'}) { } 0 0 0
467 0 $this->{-has_modal_focus} = 0;
468 } else {
469 0 my $parent = $this->parent;
470  
471 # If $this is not focused anymore, then it most probably
472 # has shifted focus itself using a callback routine.
473 # In that case, do not go to the next or previous object,
474 # but honour the current focus_path.
475 #
476 0 ▶ if ($this->root->focus_path(-1) ne $this) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->root->focus_path(-1) ne $this) 0 0 0
477 0 return $this;
478 }
479  
480 0 ▶ if (defined $key and $key eq KEY_BTAB()) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key and $key eq KEY_BTAB()) { } 0 0 0
Condition0%0/3
defined $key and $key eq KEY_BTAB()
!ll&&!rl&&r
000
MC/DC0%0/2
defined $key and $key eq KEY_BTAB()
defined $key $key eq KEY_BTAB()
Truth table0%0/3
A and B
A= defined $keyB= $key eq KEY_BTAB()
ABresult
0X0
100
111
481 0 $this->parent->focus_prev();
482 } else {
483 0 $this->parent->focus_next();
484 }
485 }
486  
487 0 return $this;
488 }
489  
490 sub focus()
491 3 ▶{
Subroutine focus: called CC=3 SCAR=11.0
Pod documented
492 3 my $this = shift;
493  
494 # Let the parent focus this object.
495 3 my $parent = $this->parent;
496 3 ▶ $parent->focus($this) if defined $parent;
Branch: 1 branch
BranchTrueFalseTotal
if defined $parent 2 1 3
497  
498 3 ▶ $this->draw(1) if ($this->root->overlapping);
Branch: 1 branch
BranchTrueFalseTotal
if $this->root->overlapping 3 0 3
499 3 return $this;
500 }
501  
502 sub modalfocus ()
503 0 ▶{
Subroutine modalfocus: not called CC=2 SCAR=17.9
Pod documented
504 0 my $this = shift;
505  
506 # "Fake" focus for this object.
507 0 $this->{-has_modal_focus} = 1;
508 0 $this->focus;
509 0 $this->draw;
510  
511 # Event loop ((too?) much like Curses::UI->mainloop)
512 0 ▶ while ( $this->{-has_modal_focus} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-has_modal_focus"}) 0 0 0
513 0 $this->root->do_one_event($this);
514 }
515  
516 0 $this->{-focus} = 0;
517 0 $this->{-has_modal_focus} = 0;
518  
519 0 return $this;
520 }
521  
522  
523 sub draw(;$)
524 17 ▶{
Subroutine draw: called CC=28 SCAR=60.6
Pod documented
525 17 my $this = shift;
526 17 ▶ my $no_doupdate = shift || 0;
Condition50%1/2
shift() || 0
l!l
170
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
527  
528 # Return immediately if this object is hidden of if
529 # the screen is currently too small.
530 17 ▶ return if $Curses::UI::screen_too_small;
Branch: 1 branch
BranchTrueFalseTotal
if $Curses::UI::screen_too_small 0 17 17
531 17 ▶ return if $this->hidden;
Branch: 1 branch
BranchTrueFalseTotal
if $this->hidden 0 17 17
532  
533 17 eval { curs_set(0) }; # not available on every system.
534  
535 # Clear the contents of the window.
536 my $scr = defined $this->{-borderscr}
537 ? $this->{-borderscr}
538 17 ▶ : $this->{-canvasscr};
Branch: 1 branch
BranchTrueFalseTotal
defined $this->{'-borderscr'} ? : 0 17 17
539 17 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 17 17
540 0 my $co = $Curses::UI::color_object;
541 0 my $pair = $co->get_color_pair( $this->{-fg}, $this->{-bg} );
542 0 ▶ $scr->bkgdset(COLOR_PAIR($pair) | 32) if (defined $scr and $pair);
Branch: 1 branch
BranchTrueFalseTotal
if defined $scr and $pair 0 0 0
Condition0%0/3
defined $scr and $pair
!ll&&!rl&&r
000
MC/DC0%0/2
defined $scr and $pair
defined $scr $pair
Truth table0%0/3
A and B
A= defined $scrB= $pair
ABresult
0X0
100
111
543 }
544 17 ▶ return unless defined $scr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scr 0 17 17
545 17 $scr->erase;
546 17 $scr->noutrefresh();
547  
548 # Do borderstuff?
549 17 ▶ if (defined $this->{-borderscr})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{"-borderscr"}) 0 17 17
550 {
551  
552 0 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 0 0
553 0 my $co = $Curses::UI::color_object;
554 my $pair = $co->get_color_pair(
555 $this->{-bfg},
556 0 $this->{-bbg} );
557  
558 0 $this->{-borderscr}->attron(COLOR_PAIR($pair));
559 }
560  
561 # Draw a border if needed.
562 0 ▶ if ($this->{-sbborder}) # Square bracket ([,]) border
Branch: 2 branches
BranchTrueFalseTotal
if ($this->{'-sbborder'}) { } 0 0 0
elsif ($this->{'-border'}) { } 0 0 0
563 {
564 0 ▶ $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
565 0 my $offset = 1;
566 0 ▶ $offset++ if $this->{-vscrollbar};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-vscrollbar"} 0 0 0
567 0 for my $y (0 .. $this->{-sh}-1)
568 {
569 0 my $rel_y = $y + $this->{-sy} - $this->{-by};
570 0 $this->{-borderscr}->addstr($rel_y, 0, '[');
571 0 $this->{-borderscr}->addstr($rel_y, $this->{-bw}-$offset, ']');
572 }
573 0 ▶ $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
574 }
575 elsif ($this->{-border}) # Normal border
576 {
577 0 ▶ $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
578 0 ▶ if ($this->root->compat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->root->compat) { } 0 0 0
579 $this->{-borderscr}->border(
580 0 '|','|','-','-',
581 '+','+','+','+'
582 );
583 } else {
584 0 $this->{-borderscr}->box(ACS_VLINE, ACS_HLINE);
585 }
586 0 ▶ $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
587
588 # Draw a title if needed.
589 0 ▶ if (defined $this->{-title})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{"-title"}) 0 0 0
590 {
591 0 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 0 0
592 0 my $co = $Curses::UI::color_object;
593 my $pair = $co->get_color_pair(
594 $this->{-tfg},
595 0 $this->{-tbg} );
596  
597 0 $this->{-borderscr}->attron(COLOR_PAIR($pair));
598 }
599  
600 $this->{-borderscr}->attron(A_REVERSE)
601 0 ▶ if $this->{-titlereverse};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-titlereverse"} 0 0 0
602 0 ▶ if ($this->{-titlefullwidth}
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-titlefullwidth"} and $this->{"-titlereverse"}) 0 0 0
Condition0%0/3
$this->{"-titlefullwidth"} and $this->{"-titlereverse"}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-titlefullwidth"} and $this->{"-titlereverse"}
$this->{"-titlefullwidth"} $this->{"-titlereverse"}
Truth table0%0/3
A and B
A= $this->{"-titlefullwidth"}B= $this->{"-titlereverse"}
ABresult
0X0
100
111
603 and $this->{-titlereverse}) {
604 0 $this->{-borderscr}->attron(A_BOLD);
605 0 $this->{-borderscr}->addstr(0, 1, " "x($this->{-bw}-2));
606 0 $this->{-borderscr}->attroff(A_BOLD);
607 }
608 0 my $t = $this->{-title};
609 0 my $l = $this->{-bw}-4;
610 0 ▶ if ($l < length($t))
Branch: 1 branch
BranchTrueFalseTotal
if ($l < length $t) 0 0 0
611 {
612 0 ▶ $t = substr($t, 0, $l) if $l < length($t);
Branch: 1 branch
BranchTrueFalseTotal
if $l < length $t 0 0 0
613 0 $t =~ s/.$/\$/;
614 }
615 0 $this->{-borderscr}->attron(A_BOLD);
616 0 $this->{-borderscr}->addstr(0, 1, " $t ");
617 0 $this->{-borderscr}->attroff(A_REVERSE);
618 0 $this->{-borderscr}->attroff(A_BOLD);
619 }
620 }
621
622 0 $this->draw_scrollbars();
623 0 $this->{-borderscr}->noutrefresh();
624 }
625  
626 17 ▶ doupdate() unless $no_doupdate;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_doupdate 0 17 17
627 17 return $this;
628 }
629  
630 sub draw_scrollbars()
631 0 ▶{
Subroutine draw_scrollbars: not called CC=41 SCAR=74.5
Pod undocumented
632 0 my $this = shift;
633  
634 0 ▶ return $this unless defined $this->{-borderscr};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{"-borderscr"} 0 0 0
635  
636 0 ▶ if ($this->{-vscrollbar} and defined $this->{-vscrolllen})
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-vscrollbar"} and defined $this->{"-vscrolllen"}) 0 0 0
Condition0%0/3
$this->{"-vscrollbar"} and defined $this->{"-vscrolllen"}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-vscrollbar"} and defined $this->{"-vscrolllen"}
$this->{"-vscrollbar"} defined $this->{"-vscrolllen"}
Truth table0%0/3
A and B
A= $this->{"-vscrollbar"}B= defined $this->{"-vscrolllen"}
ABresult
0X0
100
111
637 {
638  
639 # Compute the drawing range for the scrollbar.
640 0 ▶ my $xpos = $this->{-vscrollbar} eq 'left'
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-vscrollbar'} eq 'left' ? : 0 0 0
641 ? 0
642 : $this->borderwidth-1;
643  
644 0 my $ypos_min = $this->{-sy}-$this->{-by};
645 0 my $ypos_max = $ypos_min + $this->canvasheight - 1;
646 0 my $scrlen = $ypos_max - $ypos_min + 1;
647 my $actlen = $this->{-vscrolllen}
648 0 ▶ ? int($scrlen * ($scrlen/($this->{-vscrolllen}))+0.5)
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-vscrolllen'} ? : 0 0 0
649 : 0;
650 0 ▶ $actlen = 1 if not $actlen and $this->{-vscrolllen};
Branch: 1 branch
BranchTrueFalseTotal
if not $actlen and $this->{"-vscrolllen"} 0 0 0
Condition0%0/3
not $actlen and $this->{"-vscrolllen"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $actlen and $this->{"-vscrolllen"}
not $actlen $this->{"-vscrolllen"}
Truth table0%0/3
not(A) and B
A= not $actlenB= $this->{"-vscrolllen"}
ABresult
0X0
100
111
651 my $actpos = ($this->{-vscrolllen} and $this->{-vscrollpos})
652 0 ▶ ? int($scrlen*($this->{-vscrollpos}/$this->{-vscrolllen}))
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-vscrolllen'} && $this->{'-vscrollpos'} ? : 0 0 0
Condition0%0/3
$this->{"-vscrolllen"} and $this->{"-vscrollpos"}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-vscrolllen"} and $this->{"-vscrollpos"}
$this->{"-vscrolllen"} $this->{"-vscrollpos"}
Truth table0%0/3
A and B
A= $this->{"-vscrolllen"}B= $this->{"-vscrollpos"}
ABresult
0X0
100
111
653 + $ypos_min + 1
654 : $ypos_min;
655  
656 # Only let the marker be at the end if the
657 # scrollpos is too.
658 0 ▶ if ($this->{-vscrollpos}+$scrlen >= $this->{-vscrolllen}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'-vscrollpos'} + $scrlen >= $this->{'-vscrolllen'}) { } 0 0 0
659 0 $actpos = $scrlen - $actlen + $ypos_min;
660 } else {
661 0 ▶ if ($actpos + $actlen >= $scrlen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actpos + $actlen >= $scrlen) 0 0 0
662 0 $actpos--;
663 }
664 }
665
666 # Only let the marker be at the beginning if the
667 # scrollpos is too.
668 0 ▶ if ($this->{-vscrollpos} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'-vscrollpos'} == 0) { } 0 0 0
669 0 $actpos = $ypos_min;
670 } else {
671 0 ▶ if ($this->{-vscrollpos} and $actpos <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-vscrollpos"} and $actpos <= 0) 0 0 0
Condition0%0/3
$this->{"-vscrollpos"} and $actpos <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-vscrollpos"} and $actpos <= 0
$this->{"-vscrollpos"} $actpos <= 0
Truth table0%0/3
A and B
A= $this->{"-vscrollpos"}B= $actpos <= 0
ABresult
0X0
100
111
672 0 $actpos = $ypos_min+1;
673 }
674 }
675
676 # Draw the base of the scrollbar, in case
677 # there is no border.
678 0 ▶ $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
679 0 $this->{-borderscr}->move($ypos_min, $xpos);
680 0 $this->{-borderscr}->vline(ACS_VLINE,$scrlen);
681 0 ▶ if ($this->root->compat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->root->compat) { } 0 0 0
682 0 $this->{-borderscr}->vline('|',$scrlen);
683 } else {
684 0 $this->{-borderscr}->vline(ACS_VLINE,$scrlen);
685 }
686 0 ▶ $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
687  
688 0 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 0 0
689 0 my $co = $Curses::UI::color_object;
690 my $pair = $co->get_color_pair(
691 $this->{-sfg},
692 0 $this->{-sbg} );
693  
694 0 $this->{-borderscr}->attron(COLOR_PAIR($pair));
695 }
696  
697 # Should an active region be drawn?
698 0 my $scroll_active = ($this->{-vscrolllen} > $scrlen);
699 # Draw scrollbar base, in case there is
700 # Draw active region.
701 0 ▶ if ($scroll_active)
Branch: 1 branch
BranchTrueFalseTotal
if ($scroll_active) 0 0 0
702 {
703 0 $this->{-borderscr}->attron(A_REVERSE);
704 0 for my $i (0 .. $actlen-1) {
705 0 $this->{-borderscr}->addch($i+$actpos,$xpos," ");
706 }
707 0 $this->{-borderscr}->attroff(A_REVERSE);
708 }
709  
710 0 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 0 0
711 0 my $co = $Curses::UI::color_object;
712 my $pair = $co->get_color_pair(
713 $this->{-bfg},
714 0 $this->{-bbg} );
715  
716 0 $this->{-borderscr}->attron(COLOR_PAIR($pair));
717 }
718  
719 }
720
721 0 ▶ if ($this->{-hscrollbar} and defined $this->{-hscrolllen})
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-hscrollbar"} and defined $this->{"-hscrolllen"}) 0 0 0
Condition0%0/3
$this->{"-hscrollbar"} and defined $this->{"-hscrolllen"}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-hscrollbar"} and defined $this->{"-hscrolllen"}
$this->{"-hscrollbar"} defined $this->{"-hscrolllen"}
Truth table0%0/3
A and B
A= $this->{"-hscrollbar"}B= defined $this->{"-hscrolllen"}
ABresult
0X0
100
111
722 {
723 # Compute the drawing range for the scrollbar.
724 0 ▶ my $ypos = $this->{-hscrollbar} eq 'top'
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-hscrollbar'} eq 'top' ? : 0 0 0
725 ? 0
726 : $this->borderheight-1;
727  
728 0 my $xpos_min = $this->{-sx}-$this->{-bx};
729 0 my $xpos_max = $xpos_min + $this->canvaswidth - 1;
730 0 my $scrlen = $xpos_max - $xpos_min + 1;
731 my $actlen = $this->{-hscrolllen}
732 0 ▶ ? int($scrlen * ($scrlen/($this->{-hscrolllen}))+0.5)
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-hscrolllen'} ? : 0 0 0
733 : 0;
734 0 ▶ $actlen = 1 if not $actlen and $this->{-hscrolllen};
Branch: 1 branch
BranchTrueFalseTotal
if not $actlen and $this->{"-hscrolllen"} 0 0 0
Condition0%0/3
not $actlen and $this->{"-hscrolllen"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $actlen and $this->{"-hscrolllen"}
not $actlen $this->{"-hscrolllen"}
Truth table0%0/3
not(A) and B
A= not $actlenB= $this->{"-hscrolllen"}
ABresult
0X0
100
111
735 my $actpos = ($this->{-hscrolllen} and $this->{-hscrollpos})
736 0 ▶ ? int($scrlen*($this->{-hscrollpos}/$this->{-hscrolllen}))
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-hscrolllen'} && $this->{'-hscrollpos'} ? : 0 0 0
Condition0%0/3
$this->{"-hscrolllen"} and $this->{"-hscrollpos"}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-hscrolllen"} and $this->{"-hscrollpos"}
$this->{"-hscrolllen"} $this->{"-hscrollpos"}
Truth table0%0/3
A and B
A= $this->{"-hscrolllen"}B= $this->{"-hscrollpos"}
ABresult
0X0
100
111
737 + $xpos_min + 1
738 : $xpos_min;
739  
740 # Only let the marker be at the end if the
741 # scrollpos is too.
742 0 ▶ if ($this->{-hscrollpos}+$scrlen >= $this->{-hscrolllen}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'-hscrollpos'} + $scrlen >= $this->{'-hscrolllen'}) { } 0 0 0
743 0 $actpos = $scrlen - $actlen + $xpos_min;
744 } else {
745 0 ▶ if ($actpos + $actlen >= $scrlen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actpos + $actlen >= $scrlen) 0 0 0
746 0 $actpos--;
747 }
748 }
749
750 # Only let the marker be at the beginning if the
751 # scrollpos is too.
752 0 ▶ if ($this->{-hscrollpos} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'-hscrollpos'} == 0) { } 0 0 0
753 0 $actpos = $xpos_min;
754 } else {
755 0 ▶ if ($this->{-hscrollpos} and $actpos <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-hscrollpos"} and $actpos <= 0) 0 0 0
Condition0%0/3
$this->{"-hscrollpos"} and $actpos <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"-hscrollpos"} and $actpos <= 0
$this->{"-hscrollpos"} $actpos <= 0
Truth table0%0/3
A and B
A= $this->{"-hscrollpos"}B= $actpos <= 0
ABresult
0X0
100
111
756 0 $actpos = $xpos_min+1;
757 }
758 }
759
760 # Draw the base of the scrollbar, in case
761 # there is no border.
762 0 ▶ $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
763 0 $this->{-borderscr}->move($ypos, $xpos_min);
764 0 ▶ if ($this->root->compat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->root->compat) { } 0 0 0
765 0 $this->{-borderscr}->hline('-',$scrlen);
766 } else {
767 0 $this->{-borderscr}->hline(ACS_HLINE,$scrlen);
768 }
769 0 ▶ $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"-focus"} 0 0 0
770  
771 # Should an active region be drawn?
772  
773 0 ▶ if ($Curses::UI::color_support) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Curses::UI::color_support) 0 0 0
774 0 my $co = $Curses::UI::color_object;
775 my $pair = $co->get_color_pair(
776 $this->{-sfg},
777 0 $this->{-sbg} );
778  
779 0 $this->{-borderscr}->attron(COLOR_PAIR($pair));
780 }
781  
782 0 my $scroll_active = ($this->{-hscrolllen} > $scrlen);
783 # Draw active region.
784 0 ▶ if ($scroll_active)
Branch: 1 branch
BranchTrueFalseTotal
if ($scroll_active) 0 0 0
785 {
786 0 $this->{-borderscr}->attron(A_REVERSE);
787 0 for my $i (0 .. $actlen-1) {
788 0 $this->{-borderscr}->addch($ypos, $i+$actpos," ");
789 }
790 0 $this->{-borderscr}->attroff(A_REVERSE);
791 }
792 }
793
794 0 return $this;
795 }
796  
797 0 ▶sub beep_on() { my $this = shift; $this->{-nobeep} = 0; return $this }
Subroutine beep_on: not called CC=1 SCAR=6.9
Pod documented
798 0 ▶sub beep_off() { my $this = shift; $this->{-nobeep} = 1; return $this }
Subroutine beep_off: not called CC=1 SCAR=6.9
Pod documented
799 sub dobeep()
800 0 ▶{
Subroutine dobeep: not called CC=2 SCAR=17.9
Pod documented
801 0 my $this = shift;
802 0 ▶ beep() unless $this->{-nobeep};
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"-nobeep"} 0 0 0
803 0 return $this;
804 }
805  
806  
807 # TODO: work out hiding of objects.
808 20 ▶sub hidden() { shift()->{-hidden} }
Subroutine hidden: called CC=1 SCAR=0.0
Pod undocumented
809 0 ▶sub hide() { shift()->{-hidden} = 1 }
Subroutine hide: not called CC=1 SCAR=6.9
Pod undocumented
810 0 ▶sub show() { shift()->{-hidden} = 0 }
Subroutine show: not called CC=1 SCAR=6.9
Pod undocumented
811  
812 sub intellidraw(;$)
813 2 ▶{
Subroutine intellidraw: called CC=4 SCAR=16.4
Pod documented
814 2 my $this = shift;
815  
816 2 ▶ if ( $this->{-intellidraw} and
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"-intellidraw"} and not $this->hidden and $this->in_topwindow) 2 0 2
Condition33%2/6
$this->{"-intellidraw"} and not $this->hidden and $this->in_topwindow
!ll&&!rl&&r
002
$this->{"-intellidraw"} and not $this->hidden
!ll&&!rl&&r
002
MC/DC0%0/3
$this->{"-intellidraw"} and not $this->hidden and $this->in_topwindow
$this->{"-intellidraw"} not $this->hidden $this->in_topwindow
Truth table25%1/4
A and not(B) and C
A= $this->{"-intellidraw"}B= not $this->hiddenC= $this->in_topwindow
ABCresult
0XX0
10X0
1100
1111
817 not $this->hidden and
818 $this->in_topwindow ) {
819 2 $this->draw(1);
820 }
821  
822 2 return $this;
823 }
824  
825 sub delete_subwindows()
826 4 ▶{
Subroutine delete_subwindows: called CC=3 SCAR=11.0
Pod undocumented
827 4 my $this = shift;
828 4 delete $this->{-scr};
829 4 foreach my $win (qw(-borderscr -canvasscr))
830 {
831 8 ▶ if (defined $this->{$win})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{$win}) 2 6 8
832 {
833 2 $this->{$win}->delwin;
834 2 delete $this->{$win};
835 }
836 }
837 }
838  
839 sub parentwindow()
840 4 ▶{
Subroutine parentwindow: called CC=3 SCAR=11.0
Pod documented
841 4 my $object = shift;
842  
843 4 ▶ until (not defined $object or
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $object or $object->isa("Curses::UI::Window")) 4 4 8
Condition66%2/3
not defined $object or $object->isa("Curses::UI::Window")
l!l&&r!l&&!r
044
MC/DC50%1/2
not defined $object or $object->isa("Curses::UI::Window")
not defined $object $object->isa("Curses::UI::Window")
Truth table66%2/3
not(A) or B
A= not defined $objectB= $object->isa("Curses::UI::Window")
ABresult
1X1
011
000
844 $object->isa('Curses::UI::Window')) {
845 4 $object = $object->parent
846 }
847  
848 4 return $object;
849 }
850  
851 sub in_topwindow()
852 3 ▶{
Subroutine in_topwindow: called CC=6 SCAR=18.8
Pod documented
853 3 my $this = shift;
854  
855 # Get the parent window of this widget.
856 3 my $win = $this->parentwindow();
857 3 ▶ return unless defined $win;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $win 0 3 3
858  
859 # A modal window should always be the topwindow.
860 3 ▶ return 1 if $win->{-has_modal_focus};
Branch: 1 branch
BranchTrueFalseTotal
if $win->{"-has_modal_focus"} 0 3 3
861  
862 # Get the current focus path (the list of objects
863 # from the Curses::UI root up which currently
864 # have the focus). Strip non Window object from
865 # it, to find the topmost window.
866 3 my @path = $this->root->focus_path;
867 3 ▶ while (defined $path[-1] and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $path[-1] and not $path[-1]->isa("Curses::UI::Window")) 3 3 6
Condition66%2/3
defined $path[-1] and not $path[-1]->isa("Curses::UI::Window")
!ll&&!rl&&r
033
MC/DC50%1/2
defined $path[-1] and not $path[-1]->isa("Curses::UI::Window")
defined $path[-1] not $path[-1]->isa("Curses::UI::Window")
Truth table66%2/3
A and not(B)
A= defined $path[-1]B= not $path[-1]->isa("Curses::UI::Window")
ABresult
0X0
100
111
868 not $path[-1]->isa('Curses::UI::Window')) {
869 3 pop @path;
870 }
871  
872 # Check if the parent window is on top.
873 3 ▶ return (@path and ($win eq $path[-1]));
Condition33%1/3
@path && $win eq $path[-1]
!ll&&!rl&&r
003
MC/DC0%0/2
@path && $win eq $path[-1]
@path $win eq $path[-1]
Truth table33%1/3
A && B
A= @pathB= $win eq $path[-1]
ABresult
0X0
100
111
874 }
875  
876 # ----------------------------------------------------------------------
877 # Binding
878 # ----------------------------------------------------------------------
879  
880 sub clear_binding($;)
881 0 ▶{
Subroutine clear_binding: not called CC=4 SCAR=30.0
Pod documented
882 0 my $this = shift;
883 0 my $binding = shift;
884 0 my @delete = ();
885 0 ▶ while (my ($k,$v) = each %{$this->{-bindings}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$this{"-bindings"};}) 0 0 0
886 0 ▶ push @delete, $k if $v eq $binding;
Branch: 1 branch
BranchTrueFalseTotal
if $v eq $binding 0 0 0
887 }
888 0 foreach (@delete) {
889 0 delete $this->{-bindings}->{$_};
890 }
891 0 return $this;
892 }
893  
894 sub set_routine($$;)
895 22 ▶{
Subroutine set_routine: called CC=1 SCAR=0.0
Pod documented
896 22 my $this = shift;
897 22 my $binding = shift;
898 22 my $routine = shift;
899 22 $this->{-routines}->{$binding} = $routine;
900 22 return $this;
901 }
902  
903 sub set_binding($@)
904 1 ▶{
Subroutine set_binding: called CC=4 SCAR=15.2
Pod documented
905 1 my $this = shift;
906 1 my $routine = shift;
907 1 my @keys = @_;
908  
909 # Create a routine entry if the routine that was
910 # passed is a code reference instead of a
911 # routine name.
912 1 ▶ if (ref $routine eq 'CODE')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $routine eq "CODE") 0 1 1
913 {
914 0 my $name = "__routine_$routine";
915 0 $this->set_routine($name, $routine);
916 0 $routine = $name;
917 }
918  
919 $this->root->fatalerror("set_binding(): $routine: no such routine")
920 1 ▶ unless defined $this->{-routines}->{$routine};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{"-routines"}{$routine} 0 1 1
921  
922 1 foreach my $key (@keys) {
923 1 $this->{-bindings}->{$key} = $routine;
924 }
925  
926 1 return $this;
927 }
928  
929 sub set_mouse_binding($@)
930 24 ▶{
Subroutine set_mouse_binding: called CC=4 SCAR=13.9
Pod undocumented
931 24 my $this = shift;
932 24 my $routine = shift;
933 24 my @mouse_events = @_;
934  
935 # Create a routine entry if the routine that was
936 # passed is a code reference instead of a
937 # routine name.
938 24 ▶ if (ref $routine eq 'CODE')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $routine eq "CODE") 21 3 24
939 {
940 21 my $name = "__routine_$routine";
941 21 $this->set_routine($name, $routine);
942 21 $routine = $name;
943 }
944  
945 $this->root->fatalerror("set_binding(): $routine: no such routine")
946 24 ▶ unless defined $this->{-routines}->{$routine};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{"-routines"}{$routine} 0 24 24
947  
948 24 foreach my $mouse_event (@mouse_events) {
949 24 $this->{-mousebindings}->{$mouse_event} = $routine;
950 }
951  
952 24 return $this;
953 }
954  
955 8 ▶sub schedule_draw(;$) { shift()->accessor('-schedule_draw', shift()) }
Subroutine schedule_draw: called CC=1 SCAR=0.0
Pod undocumented
956  
957 sub process_bindings($;$@)
958 0 ▶{
Subroutine process_bindings: not called CC=7 SCAR=40.3
Pod documented
959 0 my $this = shift;
960 0 my $key = shift;
961 0 ▶ my $is_mouse_event = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
962 0 my @extra = @_;
963
964 # Reset draw schedule.
965 0 $this->schedule_draw(0);
966  
967 # Find the binding to use.
968 0 my $binding;
969 0 ▶ if ($is_mouse_event)
Branch: 1 branch
BranchTrueFalseTotal
if ($is_mouse_event) { } 0 0 0
970 {
971 0 $binding = $this->{-mousebindings}->{$key->{-bstate}};
972 0 ▶ if (not defined $binding) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $binding) 0 0 0
973 # Check for default routine.
974 0 $binding = $this->{-mousebindings}->{''};
975 }
976 } else {
977 0 $binding = $this->{-bindings}->{$key};
978 0 ▶ if (not defined $binding) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $binding) 0 0 0
979 # Check for default routine.
980 0 $binding = $this->{-bindings}->{''};
981 }
982 }
983  
984 0 ▶ if (defined $binding) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $binding) { } 0 0 0
985 0 my $return = $this->do_routine($binding, $key, @extra);
986 # Redraw if draw schedule is set.
987 0 ▶ $this->intellidraw if $this->schedule_draw;
Branch: 1 branch
BranchTrueFalseTotal
if $this->schedule_draw 0 0 0
988 0 return $return;
989 } else {
990 0 return 'DELEGATE';
991 }
992 }
993  
994 sub do_routine($;$)
995 0 ▶{
Subroutine do_routine: not called CC=3 SCAR=24.8
Pod undocumented
996 0 my $this = shift;
997 0 my $binding = shift;
998 0 my @arguments = @_;
999  
1000 # Find the routine to call.
1001 0 my $routine = $this->{-routines}->{$binding};
1002
1003 0 ▶ if (defined $routine)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $routine) { } 0 0 0
1004 {
1005 0 ▶ if (ref $routine eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $routine eq 'CODE') { } 0 0 0
1006 0 my $return = $routine->($this, @arguments);
1007 0 return $return;
1008 } else {
1009 0 return $routine;
1010 }
1011 } else {
1012 0 $this->root->fatalerror(
1013 "No routine defined for keybinding \"$binding\"!"
1014 );
1015 }
1016 }
1017  
1018 0 ▶sub onFocus($;$) { shift()->set_event('-onfocus', shift()) }
Subroutine onFocus: not called CC=1 SCAR=6.9
Pod documented
1019 0 ▶sub onBlur($;$) { shift()->set_event('-onblur', shift()) }
Subroutine onBlur: not called CC=1 SCAR=6.9
Pod documented
1020  
1021 sub event_onfocus()
1022 0 ▶{
Subroutine event_onfocus: not called CC=4 SCAR=30.0
Pod undocumented
1023 0 my $this = shift;
1024  
1025 # Let the parent find another widget to focus
1026 # if this widget is not focusable.
1027 0 ▶ unless ($this->focusable) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($this->focusable) 0 0 0
1028 0 return $this->parent->focus($this);
1029 }
1030  
1031 0 $this->{-focus} = 1;
1032  
1033 0 $this->run_event('-onfocus');
1034  
1035 # Set cursor mode
1036 0 ▶ my $show_cursor = $this->{-nocursor} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$this->{'-nocursor'} ? : 0 0 0
1037 0 $this->root->cursor_mode($show_cursor);
1038  
1039 0 ▶ $this->draw(1) if (not $this->root->overlapping);
Branch: 1 branch
BranchTrueFalseTotal
unless $this->root->overlapping 0 0 0
1040  
1041 0 return $this;
1042 }
1043  
1044 sub event_onblur()
1045 0 ▶{
Subroutine event_onblur: not called CC=2 SCAR=17.9
Pod undocumented
1046 0 my $this = shift;
1047 0 $this->{-focus} = 0;
1048 0 $this->run_event('-onblur');
1049 0 ▶ $this->draw(1) if (not $this->root->overlapping);
Branch: 1 branch
BranchTrueFalseTotal
unless $this->root->overlapping 0 0 0
1050 0 return $this;
1051 }
1052  
1053 sub event_keypress($;)
1054 0 ▶{
Subroutine event_keypress: not called CC=1 SCAR=6.9
Pod undocumented
1055 0 my $this = shift;
1056 0 my $key = shift;
1057 0 $this->process_bindings($key);
1058 }
1059  
1060 sub event_mouse($;)
1061 0 ▶{
Subroutine event_mouse: not called CC=1 SCAR=6.9
Pod undocumented
1062 0 my $this = shift;
1063 0 my $MEVENT = shift;
1064  
1065 0 my $winp = $this->windowparameters;
1066 0 my $abs_x = $MEVENT->{-x} - $winp->{-x};
1067 0 my $abs_y = $MEVENT->{-y} - $winp->{-y};
1068  
1069 0 $this->process_bindings($MEVENT, 1, $abs_x, $abs_y);
1070 }
1071  
1072 sub mouse_button1($$$$;)
1073 0 ▶{
Subroutine mouse_button1: not called CC=3 SCAR=24.8
Pod undocumented
1074 0 my $this = shift;
1075 0 my $event = shift;
1076 0 my $x = shift;
1077 0 my $y = shift;
1078  
1079 0 ▶ $this->focus() if not $this->{-focus} and $this->focusable;
Branch: 1 branch
BranchTrueFalseTotal
if not $this->{"-focus"} and $this->focusable 0 0 0
Condition0%0/3
not $this->{"-focus"} and $this->focusable
!ll&&!rl&&r
000
MC/DC0%0/2
not $this->{"-focus"} and $this->focusable
not $this->{"-focus"} $this->focusable
Truth table0%0/3
not(A) and B
A= not $this->{"-focus"}B= $this->focusable
ABresult
0X0
100
111
1080 }
1081  
1082 # ----------------------------------------------------------------------
1083 # Event handling
1084 # ----------------------------------------------------------------------
1085  
1086 sub clear_event($;)
1087 0 ▶{
Subroutine clear_event: not called CC=1 SCAR=6.9
Pod documented
1088 0 my $this = shift;
1089 0 my $event = shift;
1090 0 $this->set_event($event, undef);
1091 0 return $this;
1092 }
1093  
1094 sub set_event($;$)
1095 1 ▶{
Subroutine set_event: called CC=3 SCAR=11.8
Pod documented
1096 1 my $this = shift;
1097 1 my $event = shift;
1098 1 my $callback = shift;
1099  
1100 1 ▶ if (defined $callback)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $callback) { } 1 0 1
1101 {
1102 1 ▶ if (ref $callback eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $callback eq 'CODE') { } 1 0 1
1103 1 $this->{$event} = $callback;
1104 } else {
1105 0 $this->root->fatalerror(
1106 "$event callback for $this "
1107 . "($callback) is no CODE reference"
1108 );
1109 }
1110 } else {
1111 0 $this->{$event} = undef;
1112 }
1113 1 return $this;
1114 }
1115  
1116 sub run_event($;)
1117 6 ▶{
Subroutine run_event: called CC=3 SCAR=11.1
Pod documented
1118 6 my $this = shift;
1119 6 my $event = shift;
1120
1121 6 my $callback = $this->{$event};
1122 6 ▶ if (defined $callback) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $callback) 5 1 6
1123 5 ▶ if (ref $callback eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $callback eq 'CODE') { } 5 0 5
1124 5 return $callback->($this);
1125 } else {
1126 0 $this->root->fatalerror(
1127 "$event callback for $this "
1128 . "($callback) is no CODE reference"
1129 );
1130 }
1131 }
1132 1 return;
1133 }
1134  
1135 ###
1136 ### Color attribute functions
1137 ###
1138  
1139 0 ▶sub set_color_fg{
Subroutine set_color_fg: not called CC=1 SCAR=6.9
Pod undocumented
1140 0 my $this = shift;
1141 0 $this->{-fg} = shift;
1142 0 $this->intellidraw;
1143 }
1144  
1145 0 ▶sub set_color_bg{
Subroutine set_color_bg: not called CC=1 SCAR=6.9
Pod undocumented
1146 0 my $this = shift;
1147 0 $this->{-bg} = shift;
1148 0 $this->intellidraw;
1149 }
1150  
1151 0 ▶sub set_color_tfg{
Subroutine set_color_tfg: not called CC=1 SCAR=6.9
Pod undocumented
1152 0 my $this = shift;
1153 0 $this->{-tfg} = shift;
1154 0 $this->intellidraw;
1155 }
1156  
1157 0 ▶sub set_color_tbg{
Subroutine set_color_tbg: not called CC=1 SCAR=6.9
Pod undocumented
1158 0 my $this = shift;
1159 0 $this->{-tbg} = shift;
1160 0 $this->intellidraw;
1161 }
1162  
1163 0 ▶sub set_color_bfg{
Subroutine set_color_bfg: not called CC=1 SCAR=6.9
Pod undocumented
1164 0 my $this = shift;
1165 0 $this->{-bfg} = shift;
1166 0 $this->intellidraw;
1167 }
1168  
1169 0 ▶sub set_color_bbg{
Subroutine set_color_bbg: not called CC=1 SCAR=6.9
Pod undocumented
1170 0 my $this = shift;
1171 0 $this->{-bbg} = shift;
1172 0 $this->intellidraw;
1173 }
1174  
1175 0 ▶sub set_color_sfg{
Subroutine set_color_sfg: not called CC=1 SCAR=6.9
Pod undocumented
1176 0 my $this = shift;
1177 0 $this->{-sfg} = shift;
1178 0 $this->intellidraw;
1179 }
1180  
1181 0 ▶sub set_color_sbg{
Subroutine set_color_sbg: not called CC=1 SCAR=6.9
Pod undocumented
1182 0 my $this = shift;
1183 0 $this->{-sbg} = shift;
1184 0 $this->intellidraw;
1185 }
1186  
1187 package Curses::UI::ContainerWidget;
1188  
1189 # Not special at all. This class is especially used as a flag for
1190 # container based widgets, so that we can detect these using
1191 # $object->isa('Curses::UI::ContainerWidget').
1192  
1193 8 ▶use Curses::UI::Container;
Subroutine BEGIN: called CC=1 SCAR=0.0
1194 8 ▶use Curses::UI::Widget;
Subroutine BEGIN: called CC=1 SCAR=0.0
1195 8 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
1196 @ISA
1197 $VERSION
1198 8 );
1199  
1200 8 $VERSION = '1.10';
1201  
1202 8 @ISA = qw(
1203 Curses::UI::Container
1204 Curses::UI::Widget
1205 );
1206  
1207 0 ▶sub new () { shift()->SUPER::new(@_) };
Subroutine new: not called CC=1 SCAR=6.9
1208  
1209 8 1;
1210  
1211  
1212 =pod
1213  
1214 =head1 NAME
1215  
1216 Curses::UI::Widget - The base class for all widgets
1217  
1218 =head1 CLASS HIERARCHY
1219  
1220 Curses::UI::Widget - base class
1221  
1222  
1223  
1224 =head1 SYNOPSIS
1225  
1226 This class is not used directly by somebody who is building an application
1227 using Curses::UI. It's a base class that is expanded by the Curses::UI widgets.
1228 See WIDGET STRUCTURE below for a basic widget framework.
1229  
1230 use Curses::UI::Widget;
1231 my $widget = new Curses::UI::Widget(
1232 -width => 15,
1233 -height => 5,
1234 -border => 1,
1235 );
1236  
1237  
1238  
1239  
1240 =head1 STANDARD OPTIONS
1241  
1242 The standard options for (most) widgets are the options that are enabled
1243 by this class. So this class doesn't really have standard options.
1244  
1245  
1246  
1247  
1248  
1249 =head1 WIDGET-SPECIFIC OPTIONS
1250  
1251 =head2 GENERAL:
1252  
1253 =over 4
1254  
1255 =item * B<-parent> < OBJECTREF >
1256  
1257 This option specifies parent of the object. This parent is
1258 the object (Curses::UI, Window, Widget(descendant), etc.)
1259 in which the widget is drawn.
1260  
1261 =item * B<-intellidraw> < BOOLEAN >
1262  
1263 If BOOLEAN has a true value (which is the default), the
1264 B<intellidraw> method (see below) will be suported. This
1265 option is mainly used in widget building.
1266  
1267 =item * B<-userdata> < SCALAR >
1268  
1269 This option specifies a user data that can be retrieved with
1270 the B<userdata>() method. It is useful to store application's
1271 internal data that otherwise would not be accessible in callbacks.
1272  
1273 =item * B<-border> < BOOLEAN >
1274  
1275 Each widget can be drawn with or without a border. To enable
1276 the border use a true value and to disable it use a
1277 false value for BOOLEAN. The default is not to use a border.
1278  
1279 =item * B<-sbborder> < BOOLEAN >
1280  
1281 If no border is used, a square bracket border may be used.
1282 This is a border which is constructed from '[' and ']'
1283 characters. This type of border is especially useful for
1284 single line widgets (like text entries and popup boxes).
1285 A square bracket border can only be enabled if -border
1286 is false. The default is not to use a square bracket border.
1287  
1288 =back
1289  
1290  
1291  
1292 =head2 POSITIONING:
1293  
1294 +---------------------------------------------------+
1295 | parent ^ |
1296 | | |
1297 | y |
1298 | | |
1299 | v |
1300 | ^ |
1301 | | |
1302 | padtop |
1303 | | |
1304 | v |
1305 | +- TITLE -------+ |
1306 | | widget ^ | |
1307 | | | | |
1308 | | | | |
1309 |<--x--><--padleft-->|<----width---->|<--padright-->|
1310 | | | | |
1311 | | | | |
1312 | | height | |
1313 | | v | |
1314 | +---------------+ |
1315 | ^ |
1316 | | |
1317 | padbottom |
1318 | | |
1319 | v |
1320 +---------------------------------------------------+
1321  
1322  
1323 =over 4
1324  
1325 =item * B<-x> < VALUE >
1326  
1327 The x-position of the widget, relative to the parent. The default
1328 is 0.
1329  
1330 =item * B<-y> < VALUE >
1331  
1332 The y-position of the widget, relative to the parent. The default
1333 is 0.
1334  
1335 =item * B<-width> < VALUE >
1336  
1337 The width of the widget. If the width is undefined or -1,
1338 the maximum available width will be used. By default the widget
1339 will use the maximum available width.
1340  
1341 =item * B<-height> < VALUE >
1342  
1343 The height of the widget. If the height is undefined or -1,
1344 the maximum available height will be used. By default the widget
1345 will use the maximum available height.
1346  
1347 =back
1348  
1349  
1350  
1351 =head2 PADDING:
1352  
1353 =over 4
1354  
1355 =item * B<-pad> < VALUE >
1356  
1357 =item * B<-padtop> < VALUE >
1358  
1359 =item * B<-padbottom> < VALUE >
1360  
1361 =item * B<-padleft> < VALUE >
1362  
1363 =item * B<-padright> < VALUE >
1364  
1365 With -pad you can specify the default padding outside the widget
1366 (the default value for -pad is 0). Using one of the -pad... options
1367 that have a direction in them, you can override the default
1368 padding.
1369  
1370 =item * B<-ipad> < VALUE >
1371  
1372 =item * B<-ipadtop> < VALUE >
1373  
1374 =item * B<-ipadbottom> < VALUE >
1375  
1376 =item * B<-ipadleft> < VALUE >
1377  
1378 =item * B<-ipadright> < VALUE >
1379  
1380 These are almost the same as the -pad... options, except these options
1381 specify the padding _inside_ the widget. Normally the available
1382 effective drawing area for a widget will be the complete area
1383 if no border is used or else the area within the border.
1384  
1385 =back
1386  
1387  
1388  
1389 =head2 TITLE:
1390  
1391 Remark:
1392  
1393 A title is drawn in the border of a widget. So a title will only
1394 be available if -border is true.
1395  
1396 =over 4
1397  
1398 =item * B<-title> < TEXT >
1399  
1400 Set the title of the widget to TEXT. If the text is longer then the
1401 available width, it will be clipped.
1402  
1403 =item * B<-titlereverse> < BOOLEAN >
1404  
1405 The title can be drawn in normal or in reverse type. If -titlereverse
1406 is true, the text will be drawn in reverse type. The default is to
1407 use reverse type.
1408  
1409 =item * B<-titlefullwidth> < BOOLEAN >
1410  
1411 If -titlereverse is true, the title can be stretched to fill the
1412 complete width of the widget by giving -titlefullwidth a true value.
1413 By default this option is disabled.
1414  
1415 =back
1416  
1417  
1418  
1419 =head2 SCROLLBARS:
1420  
1421 Remark:
1422  
1423 Since the user of a Curses::UI program has no real control over
1424 the so called "scrollbars", they aren't really scrollbars. A
1425 better name would be something like "document location indicators".
1426 But since they look so much like scrollbars I decided I could get
1427 away with this naming convention.
1428  
1429 =over 4
1430  
1431 =item * B<-vscrollbar> < VALUE >
1432  
1433 VALUE can be 'left', 'right', another true value or false.
1434  
1435 If -vscrollbar has a true value, a vertical scrollbar will
1436 be drawn by the widget. If this true value happens to be "left",
1437 the scrollbar will be drawn on the left side of the widget. In
1438 all other cases it will be drawn on the right side. The default
1439 is not to draw a vertical scrollbar.
1440  
1441 For widget programmers: To control the scrollbar, the widget
1442 data -vscrolllen (the total length of the content of the widget)
1443 and -vscrollpos (the current position in the document) should
1444 be set. If Curses::UI::Widget::draw is called, the scrollbar
1445 will be drawn.
1446  
1447 =item * B<-hscrollbar> < VALUE >
1448  
1449 VALUE can be 'top', 'bottom', another true value or false.
1450  
1451 If -hscrollbar has a true value, a horizontal scrollbar will
1452 be drawn by the widget. If this true value happens to be "top",
1453 the scrollbar will be drawn at the top of the widget. In
1454 all other cases it will be drawn at the bottom. The default
1455 is not to draw a horizontal scrollbar.
1456  
1457 For widget programmers: To control the scrollbar, the widget
1458 data -hscrolllen (the maximum width of the content of the widget)
1459 and -hscrollpos (the current horizontal position in the document)
1460 should be set. If Curses::UI::Widget::draw is called,
1461 the scrollbar will be drawn.
1462  
1463 =back
1464  
1465  
1466  
1467 =head2 EVENTS
1468  
1469 =over 4
1470  
1471 =item * B<-onfocus> < CODEREF >
1472  
1473 This sets the onFocus event handler for the widget.
1474 If the widget gets the focus, the code in CODEREF will
1475 be executed. It will get the widget reference as its
1476 argument.
1477  
1478 =item * B<-onblur> < CODEREF >
1479  
1480 This sets the onBlur event handler for the widget.
1481 If the widget loses the focus, the code in CODEREF will
1482 be executed. It will get the widget reference as its
1483 argument.
1484  
1485  
1486 =back
1487  
1488  
1489 =head1 METHODS
1490  
1491 =over 4
1492  
1493 =item * B<new> ( OPTIONS )
1494  
1495 Create a new Curses::UI::Widget instance using the options in HASH.
1496  
1497 =item * B<layout> ( )
1498  
1499 Layout the widget. Compute the size the widget needs and see
1500 if it fits. Create the curses windows that are needed for
1501 the widget (the border and the effective drawing area).
1502  
1503 =item * B<draw> ( BOOLEAN )
1504  
1505 Draw the Curses::UI::Widget. If BOOLEAN is true, the screen
1506 will not update after drawing. By default this argument is
1507 false, so the screen will update after drawing the widget.
1508  
1509 =item * B<intellidraw> ( )
1510  
1511 If the widget is visible (it is not hidden and it is in the
1512 window that is currently on top) and if intellidraw is not
1513 disabled for it (B<-intellidraw> has a true value) it is drawn
1514 and the curses routine doupdate() will be called to update
1515 the screen.
1516  
1517 This is useful if you change something in a widget and want
1518 it to update its state. If you simply call draw() and
1519 doupdate() yourself, then the widget will also be drawn if
1520 it is on a window that is currently not on top. This would
1521 result in the widget being drawn right through the contents
1522 of the window that is currently on top.
1523  
1524 =item * B<focus> ( )
1525  
1526 Give focus to the widget. In Curses::UI::Widget, this method
1527 immediately returns, so the widget will not get focused.
1528 A derived class that needs focus, must override this method.
1529  
1530 =item * B<focusable> ( [BOOLEAN] )
1531  
1532 If BOOLEAN is set to a true value the widget will be focusable,
1533 false will make it unfocusable. If not argument is given,
1534 it will return the current state.
1535  
1536 =item * B<lose_focus> ( )
1537  
1538 This method makes the current widget lose it's focus.
1539 It returns the current widget.
1540  
1541 =item * B<modalfocus> ( )
1542  
1543 Gives the widget a modal focus, i.e. no other widget can be active
1544 till this widget is removed.
1545  
1546 =item * B<title> ( TEXT )
1547  
1548 Change the title that is shown in the border of the widget
1549 to TEXT.
1550  
1551 =item * B<width> ( )
1552  
1553 =item * B<height> ( )
1554  
1555 These methods return the total width and height of the widget.
1556 This is the space that the widget itself uses plus the space that
1557 is used by the outside padding.
1558  
1559 =item * B<borderwidth> ( )
1560  
1561 =item * B<borderheight> ( )
1562  
1563 These methods return the width and the height of the border of the
1564 widget.
1565  
1566 =item * B<canvaswidth> ( )
1567  
1568 =item * B<canvasheight> ( )
1569  
1570 These methods return the with and the height of the effective
1571 drawing area of the widget. This is the area where the
1572 draw() method of a widget may draw the contents of the widget
1573 (BTW: the curses window that is associated to this drawing
1574 area is $this->{-canvasscr}).
1575  
1576 =item * B<width_by_windowscrwidth> ( NEEDWIDTH, OPTIONS )
1577  
1578 =item * B<height_by_windowscrheight> ( NEEDHEIGHT, OPTIONS )
1579  
1580 These methods are exported by this module. These can be used
1581 in child classes to easily compute the total width/height the widget
1582 needs in relation to the needed width/height of the effective drawing
1583 area ($this->{-canvasscr}). The OPTIONS contains the options that
1584 will be used to create the widget. So if we want a widget that
1585 has a drawing area height of 1 and that has a border, the -height
1586 option can be computed using something like:
1587  
1588 my $height = height_by_windowscrheight(1, -border => 1);
1589  
1590 =item * B<generic_focus> ( BLOCKTIME, CTRLKEYS, CURSOR, PRECALLBACK )
1591  
1592 For most widgets the B<generic_focus> method will be enough to
1593 handle focusing. This method will do the following:
1594  
1595 It starts a loop for reading keyboard input from the user.
1596 At the start of this loop the PRECALLBACK is called. This callback
1597 can for example be used for layouting the widget. Then, the widget
1598 is drawn.
1599  
1600 Now a key is read or if the DO_KEY:<key> construction was used,
1601 the <key> will be used as if it was read from the keyboard (you
1602 can find more on this construction below). If the DO_KEY:<key>
1603 construction was not used, a key is read using the B<get_key>
1604 method which is in L<Curses::UI::Common|Curses::UI::Common>.
1605 The arguments BLOCKTIME, CTRLKEYS and CURSOR are passed to
1606 B<get_key>.
1607  
1608 Now the key is checked. If the value of the key is -1, B<get_key>
1609 did not read a key at all. In that case, the program will go back
1610 to the start of the loop.
1611  
1612 As soon as a key is read, this key will be handed to the
1613 B<process_bindings> method (see below). The returnvalue of this
1614 method (called RETURN from now on) will be used to determine
1615 what to do next. We have the following cases:
1616  
1617 * B<RETURN matches DO_KEY:<key>>
1618  
1619 The <key> is extracted from RETURN. The loop is restarted and
1620 <key> will be used as if it was entered using the keyboard.
1621  
1622 * B<RETURN is a CODE reference>
1623  
1624 RETURN will be returned to the caller of B<generic_focus>.
1625 This will have the widget lose its focus. The caller then can
1626 execute the code.
1627  
1628 * B<RETURN is a SCALAR value>
1629  
1630 RETURN will be returned to the caller of B<generic_focus>.
1631 This will have the widget lose its focus.
1632  
1633 * B<anything else>
1634  
1635 The widget will keep its focus. The loop will be restarted all
1636 over again. So, if you are writing a binding routine for a widget,
1637 you can have the focus to stay at the widget by returning the
1638 widget instance itself. Example:
1639  
1640 sub myroutine() {
1641 my $this = shift;
1642 .... do your thing ....
1643 return $this;
1644 }
1645  
1646  
1647 =item * B<process_bindings> ( KEY )
1648  
1649 KEY -> maps via binding to -> ROUTINE -> maps to -> VALUE
1650  
1651 This method will try to find out if there is a binding defined
1652 for the KEY. If no binding is found, the method will return
1653 the widget object itself.
1654 If a binding is found, the method will check if there is
1655 an corresponding ROUTINE. If the ROUTINE can be found it
1656 will check if it's VALUE is a code reference. If it is, the
1657 code will be executed and the returnvalue of this code will
1658 be returned. Else the VALUE will directly be returned.
1659  
1660 =item * B<clear_binding> ( ROUTINE )
1661  
1662 Clear all keybindings for routine ROUTINE.
1663  
1664 =item * B<set_routine> ( ROUTINE, VALUE )
1665  
1666 Set the routine ROUTINE to the VALUE. The VALUE may either be a
1667 scalar value or a code reference. If B<process_bindings> (see above)
1668 sees a scalar value, it will return this value. If it sees a
1669 coderef, it will execute the code and return the returnvalue of
1670 this code.
1671  
1672 =item * B<set_binding> ( ROUTINE, KEYLIST )
1673  
1674 Bind the keys in the list KEYLIST to the ROUTINE. If you use an
1675 empty string for a key, then this routine will become the default
1676 routine (in case no other keybinding could be found). This
1677 is for example used in the TextEditor widget.
1678  
1679 =item * B<set_event> ( EVENT, [CODEREF] )
1680  
1681 This routine will set the callback for event EVENT to
1682 CODEREF. If CODEREF is omitted or undefined, the event will
1683 be cleared.
1684  
1685 =item * B<clear_event> ( EVENT )
1686  
1687 This will clear the callback for event EVENT.
1688  
1689 =item * B<run_event> ( EVENT )
1690  
1691 This routine will check if a callback for the event EVENT
1692 is set and if is a code reference. If this is the case,
1693 it will run the code and return its return value.
1694  
1695 =item * B<onFocus> ( CODEREF )
1696  
1697 This method can be used to set the B<-onfocus> event handler
1698 (see above) after initialization of the widget.
1699  
1700 =item * B<onBlur> ( CODEREF )
1701  
1702 This method can be used to set the B<-onblur> event handler
1703 (see above) after initialization of the widget.
1704  
1705 =item * B<parentwindow> ( )
1706  
1707 Returns this parent window for the widget or undef if
1708 no parent window can be found (this should not happen).
1709  
1710 =item * B<in_topwindow> ( )
1711  
1712 Returns true if the widget is in the window that is
1713 currently on top.
1714  
1715 =item * B<userdata> ( [ SCALAR ] )
1716  
1717 This method will return the user internal data stored in this widget.
1718 If a SCALAR parameter is specified it will also set the current user
1719 data to it.
1720  
1721 =item * B<beep_on> ( )
1722  
1723 This sets the data member $this->{B<-nobeep>} of the class instance
1724 to a false value.
1725  
1726 =item * B<beep_off> ( )
1727  
1728 This sets the data member $this->{B<-nobeep>} of the class instance
1729 to a true value.
1730  
1731 =item * B<dobeep> ( )
1732  
1733 This will call the curses beep() routine, but only if B<-nobeep>
1734 is false.
1735  
1736 =back
1737  
1738  
1739 =head1 WIDGET STRUCTURE
1740  
1741 Here's a basic framework for creating a new widget. You do not have
1742 to follow this framework. As long as your widget has the methods
1743 new(), layout(), draw() and focus(), it can be used in Curses::UI.
1744  
1745 package Curses::UI::YourWidget
1746  
1747 use Curses;
1748 use Curses::UI::Widget;
1749 use Curses::UI::Common; # some common widget routines
1750  
1751 use vars qw($VERSION @ISA);
1752 $VERSION = '0.01';
1753 @ISA = qw(Curses::UI::Widget Curses::UI::Common);
1754  
1755 # For a widget that can get focus, you should define
1756 # the routines that are used to control the widget.
1757 # Each routine has a name. This name is used in
1758 # the definition of the bindings.
1759 # The value can be a string or a subroutine reference.
1760 # A string will make the widget return from focus.
1761 #
1762 my %routines = (
1763 'return' => 'LOSE_FOCUS',
1764 'key-a' => \&key_a,
1765 'key-other' => \&other_key
1766 );
1767  
1768 # Using the bindings, the routines can be binded to key-
1769 # presses. If the keypress is an empty string, this means
1770 # that this is the default binding. If the key is not
1771 # handled by any other binding, it's handled by this
1772 # default binding.
1773 #
1774 my %bindings = (
1775 KEY_DOWN() => 'return', # down arrow will make the
1776 # widget lose it's focus
1777 'a' => 'key-a', # a-key will trigger key_a()
1778 '' => 'key-other' # any other key will trigger other_key()
1779 );
1780  
1781 # The creation of the widget. When doing it this way,
1782 # it's easy to make optional and forced arguments
1783 # possible. A forced argument could for example be
1784 # -border => 1, which would mean that the widget
1785 # always has a border, which can't be disabled by the
1786 # programmer. The arguments can of course be used
1787 # for storing the current state of the widget.
1788 #
1789 sub new () {
1790 my $class = shift;
1791 my %args = (
1792 -optional_argument_1 => "default value 1",
1793 -optional_argument_2 => "default value 2",
1794 ....etc....
1795 @_,
1796 -forced_argument_1 => "forced value 1",
1797 -forced_argument_2 => "forced value 2",
1798 ....etc....
1799 -bindings => {%bindings},
1800 -routines => {%routines},
1801 );
1802  
1803 # Create the widget and do the layout of it.
1804 my $this = $class->SUPER::new( %args );
1805 $this->layout;
1806  
1807 return $this;
1808 }
1809  
1810 # Each widget should have a layout() routine. Here,
1811 # the widget itself and it's contents can be layouted.
1812 # In case of a very simple widget, this will only mean
1813 # that the Widget has to be layouted (in which case the
1814 # routine could be left out, since it's in the base
1815 # class already). In other cases you will have to add
1816 # your own layout code. This routine is very important,
1817 # since it will enable the resizeability of the widget!
1818 #
1819 sub layout () {
1820 my $this = shift;
1821  
1822 $this->SUPER::layout;
1823 return $this if $Curses::UI::screen_too_small;
1824  
1825 ....your own layout stuff....
1826  
1827 # If you decide that the widget does not fit on the
1828 # screen, then set $Curses::UI::screen_too_small
1829 # to a true value and return.
1830 if ( ....the widget does not fit.... ) {
1831 $Curses::UI::screen_too_small++;
1832 return $this;
1833 }
1834  
1835 return $this;
1836 }
1837  
1838 # The widget is drawn by the draw() routine. The
1839 # $no_update part is used to disable screen flickering
1840 # if a lot of widgets have to be drawn at once (for
1841 # example on resizing or redrawing). The curses window
1842 # which you can use for drawing the widget's contents
1843 # is $this->{-canvasscr}.
1844 #
1845 sub draw(;$) {
1846 my $this = shift;
1847 my $no_doupdate = shift || 0;
1848 return $this if $this->hidden;
1849 $this->SUPER::draw(1);
1850  
1851 ....your own draw stuff....
1852 $this->{-canvasscr}->addstr(0, 0, "Fixed string");
1853 ....your own draw stuff....
1854  
1855 $this->{-canvasscr}->noutrefresh;
1856 doupdate() unless $no_doupdate;
1857 return $this;
1858 }
1859  
1860 # Focus the widget. If you do not override this routine
1861 # from Curses::UI::Widget, the widget will not be
1862 # focusable. Mostly you will use the generic_focus() method.
1863 #
1864 sub focus()
1865 {
1866 my $this = shift;
1867 $this->show; # makes the widget visible if it was invisible
1868 return $this->generic_focus(
1869 undef, # delaytime, default = 2 (1/10 second).
1870 NO_CONTROLKEYS, # disable controlkeys like CTRL+C. To enable
1871 # them use CONTROLKEYS instead.
1872 CURSOR_INVISIBLE, # do not show the cursor (if supported). To
1873 # show the cursor use CURSOR_VISIBLE.
1874 \&pre_key_routine, # optional callback routine to execute
1875 # before a key is read. Mostly unused.
1876 );
1877 }
1878  
1879 ....your own widget handling routines....
1880  
1881  
1882  
1883  
1884 =head1 SEE ALSO
1885  
1886 L<Curses::UI|Curses::UI>
1887  
1888  
1889  
1890  
1891  
1892  
1893 =head1 AUTHOR
1894  
1895 Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
1896  
1897 Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
1898  
1899  
1900 This package is free software and is provided "as is" without express
1901 or implied warranty. It may be used, redistributed and/or modified
1902 under the same terms as perl itself.
1903  
« blib/lib/Curses/UI/Notebook.pm ↑ Summary lib/Curses/UI/Common.pm »