line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# Curses::UI::Window |
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::Window; |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
34
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
229
|
|
16
|
6
|
|
|
6
|
|
28
|
use Curses; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
18302
|
|
17
|
6
|
|
|
6
|
|
58
|
use Curses::UI::Container; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
315
|
|
18
|
6
|
|
|
6
|
|
33
|
use Curses::UI::Common; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
679
|
|
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
2116
|
use vars qw( |
21
|
|
|
|
|
|
|
$VERSION |
22
|
|
|
|
|
|
|
@ISA |
23
|
6
|
|
|
6
|
|
32
|
); |
|
6
|
|
|
|
|
10
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$VERSION = '1.10'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
@ISA = qw( |
28
|
|
|
|
|
|
|
Curses::UI::Container |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new () |
32
|
|
|
|
|
|
|
{ |
33
|
13
|
|
|
13
|
1
|
21
|
my $class = shift; |
34
|
|
|
|
|
|
|
|
35
|
13
|
|
|
|
|
69
|
my %userargs = @_; |
36
|
13
|
|
|
|
|
43
|
keys_to_lowercase(\%userargs); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Create the window. |
39
|
13
|
|
|
|
|
120
|
my $this = $class->SUPER::new( |
40
|
|
|
|
|
|
|
-width => undef, |
41
|
|
|
|
|
|
|
-height => undef, |
42
|
|
|
|
|
|
|
-x => 0, |
43
|
|
|
|
|
|
|
-y => 0, |
44
|
|
|
|
|
|
|
-centered => 0, # Center the window in the display? |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
%userargs, |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
-nocursor => 1, # This widget does not use a cursor |
49
|
|
|
|
|
|
|
-assubwin => 1, # Always constructed as a subwindow |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
13
|
|
|
|
|
78
|
return $this; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub layout () |
56
|
|
|
|
|
|
|
{ |
57
|
13
|
|
|
13
|
1
|
21
|
my $this = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Compute the coordinates of the Window if |
60
|
|
|
|
|
|
|
# it has to be centered. |
61
|
13
|
50
|
|
|
|
104
|
if ($this->{-centered}) |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
# The maximum available space on the screen. |
64
|
0
|
|
|
|
|
0
|
my $avail_width = $ENV{COLS}; |
65
|
0
|
|
|
|
|
0
|
my $avail_height = $ENV{LINES}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Compute the coordinates for the widget. |
68
|
0
|
|
0
|
|
|
0
|
my $w = $this->{-width} || 1; |
69
|
0
|
|
0
|
|
|
0
|
my $h = $this->{-height} || 1; |
70
|
0
|
|
|
|
|
0
|
my $x = int(($avail_width - $w) / 2); |
71
|
0
|
|
|
|
|
0
|
my $y = int(($avail_height - $h) / 2); |
72
|
0
|
0
|
|
|
|
0
|
$x = 0 if $x < 0; |
73
|
0
|
0
|
|
|
|
0
|
$y = 0 if $y < 0; |
74
|
0
|
|
|
|
|
0
|
$this->{-x} = $x; |
75
|
0
|
|
|
|
|
0
|
$this->{-y} = $y; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
13
|
100
|
|
|
|
67
|
$this->SUPER::layout or return; |
79
|
|
|
|
|
|
|
|
80
|
9
|
|
|
|
|
18
|
return $this; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Curses::UI::Window - Create and manipulate Window widgets |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 CLASS HIERARCHY |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Curses::UI::Widget |
95
|
|
|
|
|
|
|
| |
96
|
|
|
|
|
|
|
+----Curses::UI::Container |
97
|
|
|
|
|
|
|
| |
98
|
|
|
|
|
|
|
+----Curses::UI::Window |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use Curses::UI; |
104
|
|
|
|
|
|
|
my $cui = new Curses::UI; |
105
|
|
|
|
|
|
|
my $win = $cui->add( |
106
|
|
|
|
|
|
|
'window_id', 'Window', |
107
|
|
|
|
|
|
|
%options, |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Curses::UI::Window is a window widget. It can be added to |
114
|
|
|
|
|
|
|
a Curses::UI instance. After that the window can be filled |
115
|
|
|
|
|
|
|
with other widgets to create an application window. For |
116
|
|
|
|
|
|
|
information on how to fill the window with widgets, see |
117
|
|
|
|
|
|
|
L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 STANDARD OPTIONS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
B<-parent>, B<-x>, B<-y>, B<-width>, B<-height>, |
124
|
|
|
|
|
|
|
B<-pad>, B<-padleft>, B<-padright>, B<-padtop>, B<-padbottom>, |
125
|
|
|
|
|
|
|
B<-ipad>, B<-ipadleft>, B<-ipadright>, B<-ipadtop>, B<-ipadbottom>, |
126
|
|
|
|
|
|
|
B<-title>, B<-titlefullwidth>, B<-titlereverse>, B<-onfocus>, |
127
|
|
|
|
|
|
|
B<-onblur> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
For an explanation of these standard options, see |
130
|
|
|
|
|
|
|
L. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 WIDGET-SPECIFIC OPTIONS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * B<-centered> < BOOLEAN > |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
A window can automatically be drawn in the center of the screen. |
141
|
|
|
|
|
|
|
To enable this option use a true value and to disable it use a |
142
|
|
|
|
|
|
|
false value. The default is not to center a window. Example: |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$cui->add('mywindow', 'Window', -centered => 1); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 METHODS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * B ( OPTIONS ) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * B ( ) |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * B ( BOOLEAN ) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * B ( ) |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * B ( CODEREF ) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * B ( CODEREF ) |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * B ( ) |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
These are standard methods. See L |
169
|
|
|
|
|
|
|
for an explanation of these. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * B ( ) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
If this method is called, the window will get modal focus. This means |
174
|
|
|
|
|
|
|
that all events will be sent to this window. By calling the |
175
|
|
|
|
|
|
|
B method, the window will loose its focus. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * B ( ) |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This method will have the window loose its focus (using this method |
180
|
|
|
|
|
|
|
you can also let a modal focused window loose its focus). |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 SEE ALSO |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L, |
188
|
|
|
|
|
|
|
L, |
189
|
|
|
|
|
|
|
L |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Copyright (c) 2001-2002 Maurice Makaay. All rights reserved. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de) |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This package is free software and is provided "as is" without express |
201
|
|
|
|
|
|
|
or implied warranty. It may be used, redistributed and/or modified |
202
|
|
|
|
|
|
|
under the same terms as perl itself. |
203
|
|
|
|
|
|
|
|