line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UI::Various::Window; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Author, Copyright and License: see end of file |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UI::Various::Window - general top-level window widget of L |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use UI::Various; |
12
|
|
|
|
|
|
|
my $main = UI::Various::main(); |
13
|
|
|
|
|
|
|
my $window = $main->window(); |
14
|
|
|
|
|
|
|
$window->add(UI::Various::Text->new(text => 'Hello World!')); |
15
|
|
|
|
|
|
|
... |
16
|
|
|
|
|
|
|
$main->mainloop(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ABSTRACT |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This module defines the general (main) window object of an application using |
21
|
|
|
|
|
|
|
L. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Besides the common attributes inherited from C and |
26
|
|
|
|
|
|
|
C the C widget knows the following |
27
|
|
|
|
|
|
|
additional attributes: |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 Attributes |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
######################################################################### |
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
9
|
|
90
|
use v5.14; |
|
9
|
|
|
|
|
23
|
|
38
|
9
|
|
|
9
|
|
40
|
use strictures; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
36
|
|
39
|
9
|
|
|
9
|
|
1261
|
no indirect 'fatal'; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
49
|
|
40
|
9
|
|
|
9
|
|
456
|
no multidimensional; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
82
|
|
41
|
9
|
|
|
9
|
|
280
|
use warnings 'once'; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
528
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
44
|
|
|
|
|
|
|
|
45
|
9
|
|
|
9
|
|
56
|
use UI::Various::core; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
94
|
|
46
|
9
|
|
|
9
|
|
371
|
use UI::Various::toplevel; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
511
|
|
47
|
9
|
|
|
9
|
|
138
|
BEGIN { require 'UI/Various/' . UI::Various::core::using() . '/Window.pm'; } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
require Exporter; |
50
|
|
|
|
|
|
|
our @ISA = qw(UI::Various::toplevel); |
51
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
######################################################################### |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item title [rw, fixed, optional] |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
an optional title string for the window as string or variable reference |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub title($;$) |
62
|
|
|
|
|
|
|
{ |
63
|
31
|
|
|
31
|
1
|
86
|
return access('title', undef, @_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
######################################################################### |
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# internal constants and data: |
69
|
|
|
|
|
|
|
|
70
|
9
|
|
|
|
|
536
|
use constant ALLOWED_PARAMETERS => |
71
|
9
|
|
|
9
|
|
50
|
(UI::Various::widget::COMMON_PARAMETERS, qw(title)); |
|
9
|
|
|
|
|
16
|
|
72
|
9
|
|
|
9
|
|
43
|
use constant DEFAULT_ATTRIBUTES => (title => ''); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
1742
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
######################################################################### |
75
|
|
|
|
|
|
|
######################################################################### |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Besides the accessors (attributes) described above and the attributes and |
82
|
|
|
|
|
|
|
methods of L, L and |
83
|
|
|
|
|
|
|
L, the following additional methods are provided by |
84
|
|
|
|
|
|
|
the C class itself: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
######################################################################### |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 B - constructor |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
see L
|
93
|
|
|
|
|
|
|
constructor for UI elements> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub new($;\[@$]) |
100
|
|
|
|
|
|
|
{ |
101
|
11
|
|
|
11
|
1
|
1882
|
debug(2, __PACKAGE__, '::new'); |
102
|
11
|
|
|
|
|
99
|
my $self = construct({ DEFAULT_ATTRIBUTES }, |
103
|
|
|
|
|
|
|
'^(?:' . join('|', ALLOWED_PARAMETERS) . ')$', |
104
|
|
|
|
|
|
|
@_); |
105
|
|
|
|
|
|
|
# Get "Window Manager" singleton even if it is not yet existing: |
106
|
11
|
|
|
|
|
72
|
local $_ = UI::Various::Main->new(); |
107
|
11
|
|
|
|
|
67
|
$_->add($self); |
108
|
11
|
|
|
|
|
34
|
return $self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
######################################################################### |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 B - remove window from application |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$window->destroy(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head3 description: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
C removes the window and all its UI elements from the application |
120
|
|
|
|
|
|
|
(and its L), hopefully |
121
|
|
|
|
|
|
|
freeing all memory used by the UI. (This may vary depending on the |
122
|
|
|
|
|
|
|
underlying UI package used.) If the window was the last one of the |
123
|
|
|
|
|
|
|
application, this also causes the C
|
124
|
|
|
|
|
|
|
- main event loop of an application>> to be finished. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Note that a window can not be reused again after destruction as it's broken |
127
|
|
|
|
|
|
|
down into its components to get rid of circular dependencies that may block |
128
|
|
|
|
|
|
|
clean-up of memory. If you want to open the same window again, you have to |
129
|
|
|
|
|
|
|
recreate it. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub destroy($) |
136
|
1
|
|
|
1
|
1
|
4
|
{ fatal('specified_implementation_missing'); } |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
######################################################################### |
141
|
|
|
|
|
|
|
######################################################################### |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SEE ALSO |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright (C) Thomas Dorner. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
152
|
|
|
|
|
|
|
under the same terms as Perl itself. See LICENSE file for more details. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Thomas Dorner Edorner (at) cpan (dot) orgE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |