| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tk::TabbedForm; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2683
|
use Tk; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Tk::TabFrame; |
|
5
|
|
|
|
|
|
|
use Tk::Frame; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use base qw (Tk::Derived Tk::Frame); |
|
8
|
|
|
|
|
|
|
use vars qw ($VERSION); |
|
9
|
|
|
|
|
|
|
use strict; |
|
10
|
|
|
|
|
|
|
use Carp; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Tk::Widget->Construct ('TabbedForm'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
*tabfont = \&Tk::TabbedForm::TabFont; |
|
17
|
|
|
|
|
|
|
*Field = \&Tk::TabbedForm::Item; |
|
18
|
|
|
|
|
|
|
*field = \&Tk::TabbedForm::Item; |
|
19
|
|
|
|
|
|
|
*item = \&Tk::TabbedForm::Item; |
|
20
|
|
|
|
|
|
|
*file = \&Tk::TabbedForm::File; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub Populate |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
my $this = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $l_TabWidget = $this->{m_TabWidget} = $this->Component |
|
27
|
|
|
|
|
|
|
( |
|
28
|
|
|
|
|
|
|
'TabFrame' => 'TabFrame', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$this->ConfigSpecs |
|
32
|
|
|
|
|
|
|
( |
|
33
|
|
|
|
|
|
|
'-TabFont' => ['METHOD', 'tabfont', 'TabFont', '-adobe-times-medium-r-normal--16-*-*-*-*-*-*-*'], |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$l_TabWidget->pack |
|
37
|
|
|
|
|
|
|
( |
|
38
|
|
|
|
|
|
|
'-fill' => 'both', |
|
39
|
|
|
|
|
|
|
'-expand' => 'true', |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return $this->SUPER::Populate (@_); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub Item |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
|
|
|
|
|
|
my ($this, $p_WidgetClass, @p_Parameters) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my %l_Hash = @p_Parameters; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $l_SectionName = delete $l_Hash {'-section'} || 'Undefined'; |
|
52
|
|
|
|
|
|
|
my $l_SectionFrame = $this->SectionFrame ($l_SectionName); |
|
53
|
|
|
|
|
|
|
my $l_Expression = delete $l_Hash {'-rule'} || delete $l_Hash {'-expression'}; |
|
54
|
|
|
|
|
|
|
my $l_ItemName = delete $l_Hash {'-name'} || 'Undefined_'.++$Tk::TabbedForm::g_Undefined; |
|
55
|
|
|
|
|
|
|
my $l_Set = delete $l_Hash {'-set'} || sub {$_[0]->delete ('0', 'end'); $_[0]->insert ('0', $_[1]);}; |
|
56
|
|
|
|
|
|
|
my $l_Get = delete $l_Hash {'-get'} || sub {$_[0]->get();}; |
|
57
|
|
|
|
|
|
|
my $l_Default = delete $l_Hash {'-default'}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $l_Label = $l_SectionFrame->Label |
|
60
|
|
|
|
|
|
|
( |
|
61
|
|
|
|
|
|
|
'-text' => $l_ItemName, |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $l_Widget = $l_SectionFrame->$p_WidgetClass |
|
65
|
|
|
|
|
|
|
( |
|
66
|
|
|
|
|
|
|
%l_Hash, |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$l_Label->grid |
|
70
|
|
|
|
|
|
|
( |
|
71
|
|
|
|
|
|
|
'-row' => ++$l_SectionFrame->{m_Row}, |
|
72
|
|
|
|
|
|
|
'-sticky' => 'nw', |
|
73
|
|
|
|
|
|
|
'-column' => 0, |
|
74
|
|
|
|
|
|
|
'-padx' => 2, |
|
75
|
|
|
|
|
|
|
'-pady' => 1, |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$l_Widget->grid |
|
79
|
|
|
|
|
|
|
( |
|
80
|
|
|
|
|
|
|
'-row' => $l_SectionFrame->{m_Row}, |
|
81
|
|
|
|
|
|
|
'-sticky' => 'nw', |
|
82
|
|
|
|
|
|
|
'-column' => 1, |
|
83
|
|
|
|
|
|
|
'-padx' => 2, |
|
84
|
|
|
|
|
|
|
'-pady' => 1, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Add field to list of fields |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
push (@{$this->{m_Fields}->{$l_SectionName}}, $l_ItemName); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Add widget to hash of field widgets |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$this->{'x_'.$l_ItemName} = $l_Widget; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$l_Widget->{m_Section} = $l_SectionName; |
|
96
|
|
|
|
|
|
|
$l_Widget->{m_Default} = $l_Default; |
|
97
|
|
|
|
|
|
|
$l_Widget->{m_Name} = $l_ItemName; |
|
98
|
|
|
|
|
|
|
$l_Widget->{m_Get} = $l_Get; |
|
99
|
|
|
|
|
|
|
$l_Widget->{m_Set} = $l_Set; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
if (defined ($l_Expression)) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
my $l_FinalExpression = (ref ($l_Expression) eq 'ARRAY' ? ${$l_Expression}[-1] : $l_Expression); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$l_Widget->bind |
|
106
|
|
|
|
|
|
|
( |
|
107
|
|
|
|
|
|
|
'' => sub {$this->TestExpression ($l_ItemName, $l_Expression);} |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$l_Widget->bind |
|
111
|
|
|
|
|
|
|
( |
|
112
|
|
|
|
|
|
|
'' => sub {$this->TestExpression ($l_ItemName, $l_FinalExpression, 1);} |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$this->SetItemValue ($l_ItemName); |
|
117
|
|
|
|
|
|
|
return $l_Widget; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub SectionFrame |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
|
|
|
|
|
|
my ($this, $p_SectionName) = @_; |
|
123
|
|
|
|
|
|
|
my $l_Frame = $this->{m_TabWidget}->{$p_SectionName}; |
|
124
|
|
|
|
|
|
|
my $l_SectionLabel = $p_SectionName; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return $l_Frame if (Exists ($l_Frame)); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$l_SectionLabel =~ s/^\_//; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$this->{m_Fields}->{$p_SectionName} = []; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$l_Frame = $this->{m_TabWidget}->{$p_SectionName} = $this->{m_TabWidget}->Frame |
|
133
|
|
|
|
|
|
|
( |
|
134
|
|
|
|
|
|
|
'-caption' => $l_SectionLabel, |
|
135
|
|
|
|
|
|
|
)->Frame |
|
136
|
|
|
|
|
|
|
( |
|
137
|
|
|
|
|
|
|
)->pack |
|
138
|
|
|
|
|
|
|
( |
|
139
|
|
|
|
|
|
|
'-anchor' => 'nw', |
|
140
|
|
|
|
|
|
|
'-padx' => 10, |
|
141
|
|
|
|
|
|
|
'-pady' => 10, |
|
142
|
|
|
|
|
|
|
'-expand' => 'true', |
|
143
|
|
|
|
|
|
|
'-fill' => 'x', |
|
144
|
|
|
|
|
|
|
); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
push (@{$this->{'m_TemporarySectionFrameList'}}, $l_Frame); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$l_Frame->{m_Row} = 0; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return $l_Frame; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#----------------------------- Item Value Retrieval ----------------------------------# |
|
154
|
|
|
|
|
|
|
sub GetItemDefault |
|
155
|
|
|
|
|
|
|
{ |
|
156
|
|
|
|
|
|
|
my ($this, $p_ItemName) = (shift, @_); |
|
157
|
|
|
|
|
|
|
my $l_Widget = $this->{'x_'.$p_ItemName}; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
return unless (Exists ($l_Widget)); |
|
160
|
|
|
|
|
|
|
return $l_Widget->{m_Default} unless (ref ($l_Widget->{m_Default}) eq 'CODE'); |
|
161
|
|
|
|
|
|
|
return &{$l_Widget->{m_Default}} ($l_Widget); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub GetItemValue |
|
165
|
|
|
|
|
|
|
{ |
|
166
|
|
|
|
|
|
|
my ($this, $p_ItemName) = (shift, @_); |
|
167
|
|
|
|
|
|
|
my $l_Widget = $this->{'x_'.$p_ItemName}; |
|
168
|
|
|
|
|
|
|
my $l_TextVariable; |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
return unless (Exists ($l_Widget)); |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
eval {$l_TextVariable = $l_Widget->cget ('-textvariable');}; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $l_Return = |
|
175
|
|
|
|
|
|
|
( |
|
176
|
|
|
|
|
|
|
ref ($l_TextVariable) eq 'SCALAR' ? ${$l_TextVariable} : |
|
177
|
|
|
|
|
|
|
( |
|
178
|
|
|
|
|
|
|
ref ($l_Widget->{m_Get}) eq 'CODE' ? &{$l_Widget->{m_Get}} ($l_Widget) : |
|
179
|
|
|
|
|
|
|
( |
|
180
|
|
|
|
|
|
|
ref ($l_Widget->{m_Get}) eq 'SCALAR' ? ${$l_Widget->{m_Get}} : |
|
181
|
|
|
|
|
|
|
( |
|
182
|
|
|
|
|
|
|
$l_Widget->{m_Get} |
|
183
|
|
|
|
|
|
|
) |
|
184
|
|
|
|
|
|
|
) |
|
185
|
|
|
|
|
|
|
) |
|
186
|
|
|
|
|
|
|
); |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
$l_Return =~ s/[\n\r]+//g; |
|
189
|
|
|
|
|
|
|
return $l_Return; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub GetItemValueHash |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
|
|
|
|
|
|
my $this = shift; |
|
195
|
|
|
|
|
|
|
my @l_Array = (); |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
foreach my $l_Section ($#_ > -1 ? @_ : $this->GetSectionNames()) |
|
198
|
|
|
|
|
|
|
{ |
|
199
|
|
|
|
|
|
|
foreach my $l_ItemName (@{$this->{m_Fields}->{$l_Section}}) |
|
200
|
|
|
|
|
|
|
{ |
|
201
|
|
|
|
|
|
|
push (@l_Array, $l_ItemName, $this->GetItemValue ($l_ItemName)); |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
return @l_Array; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub GetSectionNames |
|
209
|
|
|
|
|
|
|
{ |
|
210
|
|
|
|
|
|
|
return (sort (keys %{$_[0]->{m_Fields}})); |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub GetItemNames |
|
214
|
|
|
|
|
|
|
{ |
|
215
|
|
|
|
|
|
|
my $this = shift; |
|
216
|
|
|
|
|
|
|
my %l_Hash = $this->GetItemValueHash (@_); |
|
217
|
|
|
|
|
|
|
return (sort (keys %l_Hash)); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
#--------------------------------- Item Value Setting ----------------------------------# |
|
221
|
|
|
|
|
|
|
sub SetItemValue |
|
222
|
|
|
|
|
|
|
{ |
|
223
|
|
|
|
|
|
|
my ($this, $p_ItemName, $p_Value) = (shift, @_); |
|
224
|
|
|
|
|
|
|
my $l_Widget = $this->{'x_'.$p_ItemName}; |
|
225
|
|
|
|
|
|
|
my $l_TextVariable; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
return unless (Exists ($l_Widget)); |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
$p_Value = $this->GetItemDefault ($p_ItemName) unless defined ($p_Value); |
|
230
|
|
|
|
|
|
|
eval {$l_TextVariable = $l_Widget->cget ('-textvariable');}; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
if (ref ($l_TextVariable) eq 'SCALAR') |
|
233
|
|
|
|
|
|
|
{ |
|
234
|
|
|
|
|
|
|
return ${$l_TextVariable} = $p_Value; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
elsif (ref ($l_Widget->{m_Set}) eq 'CODE') |
|
237
|
|
|
|
|
|
|
{ |
|
238
|
|
|
|
|
|
|
return &{$l_Widget->{m_Set}} ($l_Widget, $p_Value); |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
elsif (ref ($l_Widget->{m_Get}) eq 'SCALAR') |
|
241
|
|
|
|
|
|
|
{ |
|
242
|
|
|
|
|
|
|
return ${$l_Widget->{m_Get}} = $p_Value; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub SetItemValueHash |
|
247
|
|
|
|
|
|
|
{ |
|
248
|
|
|
|
|
|
|
my $this = shift; $this->SetItemValue (shift, shift) while ($#_ > 0); |
|
249
|
|
|
|
|
|
|
} |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
#----------------------------- Field Value Qualification ----------------------------------# |
|
252
|
|
|
|
|
|
|
sub TestExpression |
|
253
|
|
|
|
|
|
|
{ |
|
254
|
|
|
|
|
|
|
my ($this, $p_ItemName, $p_Expression, $p_DontCorrect) = (shift, @_); |
|
255
|
|
|
|
|
|
|
my $l_Value = $this->GetItemValue ($p_ItemName); |
|
256
|
|
|
|
|
|
|
my $l_Widget = $this->{'x_'.$p_ItemName}; |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
return unless (Exists ($l_Widget) && defined ($l_Value)); |
|
259
|
|
|
|
|
|
|
return if ($this->MatchExpression ($l_Value, $p_Expression)); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
chop $l_Value until ($this->MatchExpression ($l_Value, $p_Expression)); |
|
262
|
|
|
|
|
|
|
$this->SetItemValue ($p_ItemName, $l_Value) unless ($p_DontCorrect); |
|
263
|
|
|
|
|
|
|
$l_Widget->focus(); |
|
264
|
|
|
|
|
|
|
$l_Widget->bell(); |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub MatchExpression |
|
268
|
|
|
|
|
|
|
{ |
|
269
|
|
|
|
|
|
|
my ($l_Return, $this, $p_Value, $p_Expression) = (0, shift, @_); |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
return 1 if ($p_Value eq ''); |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
foreach my $l_Expression (ref ($p_Expression) eq 'ARRAY' ? @{$p_Expression} : ($p_Expression)) |
|
274
|
|
|
|
|
|
|
{ |
|
275
|
|
|
|
|
|
|
$l_Return = 1 if ($p_Value =~ $l_Expression); |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
return $l_Return; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub TabFont |
|
282
|
|
|
|
|
|
|
{ |
|
283
|
|
|
|
|
|
|
return $_[0]->{m_TabWidget}->cget ('-font') unless (defined ($_[1])); |
|
284
|
|
|
|
|
|
|
$_[0]->{m_TabWidget}->configure ('-font' => $_[1]); |
|
285
|
|
|
|
|
|
|
return $_[1]; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
1; |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
__END__ |