| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tk::ObjectHandler; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
######################################################################## |
|
4
|
|
|
|
|
|
|
# # |
|
5
|
|
|
|
|
|
|
# Tk::ObjectHandler, by Simon Parsons # |
|
6
|
|
|
|
|
|
|
# # |
|
7
|
|
|
|
|
|
|
# This perl module is distributed under the terms of the GNU # |
|
8
|
|
|
|
|
|
|
# Public Licence and the Perl Artistic Licence. # |
|
9
|
|
|
|
|
|
|
# # |
|
10
|
|
|
|
|
|
|
# Copyright (C) Simon Parsons, 2002 # |
|
11
|
|
|
|
|
|
|
######################################################################## |
|
12
|
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
1509
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
80
|
|
|
14
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION $AUTOLOAD); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
120
|
|
|
15
|
2
|
|
|
2
|
|
58065
|
use Text::Wrap qw($columns wrap); |
|
|
2
|
|
|
|
|
8626
|
|
|
|
2
|
|
|
|
|
320
|
|
|
16
|
2
|
|
|
2
|
|
2144
|
use Tk; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Carp qw(carp croak); |
|
18
|
|
|
|
|
|
|
$VERSION = '0.3'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use vars qw($AUTOLOAD); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
|
23
|
|
|
|
|
|
|
my $class = shift; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$class = ref($class) || $class; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $self = { |
|
28
|
|
|
|
|
|
|
'_OBJECT' => new MainWindow(@_), |
|
29
|
|
|
|
|
|
|
'_COMMENT' => '', |
|
30
|
|
|
|
|
|
|
'_CAN_LOOP' => 1, |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
bless $self, $class; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return $self; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub Loop { |
|
39
|
|
|
|
|
|
|
my $self = shift; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
if($self->{'_CAN_LOOP'} == 1) { |
|
42
|
|
|
|
|
|
|
MainLoop; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub add_widget { |
|
47
|
|
|
|
|
|
|
my $self = shift; |
|
48
|
|
|
|
|
|
|
my $type = shift; |
|
49
|
|
|
|
|
|
|
my $name = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $class = ref($self) or croak '$self os not a valid object'; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return undef if(exists $self->{'_WIDGETS'}->{$name}); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$self->{'_WIDGETS'}->{$name} = { |
|
56
|
|
|
|
|
|
|
'_OBJECT' => $self->_make($type, @_), |
|
57
|
|
|
|
|
|
|
'_COMMENT' => '', |
|
58
|
|
|
|
|
|
|
'_CAN_LOOP' => 0, |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
bless $self->{'_WIDGETS'}->{$name}, $class; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self->{'_WIDGETS'}->{$name}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub comment { |
|
67
|
|
|
|
|
|
|
my $self = shift; |
|
68
|
|
|
|
|
|
|
my $comment = shift || undef; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->{'_COMMENT'} = $comment if(defined $comment); |
|
71
|
|
|
|
|
|
|
$self->{'_COMMENT'} =~ s/\s+/ /g; |
|
72
|
|
|
|
|
|
|
return $self->{'_COMMENT'} || ''; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub getobj { |
|
76
|
|
|
|
|
|
|
return $_[0]->{'_OBJECT'}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Syntax (class, type', {args} |
|
80
|
|
|
|
|
|
|
sub _make { |
|
81
|
|
|
|
|
|
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
my $type = shift; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
eval "require Tk::$type;"; |
|
85
|
|
|
|
|
|
|
require "Tk/$type.pm" unless($@); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
if($_[0] and substr($_[0],0,1) ne '-') { |
|
88
|
|
|
|
|
|
|
eval "require Tk::$_[0];"; |
|
89
|
|
|
|
|
|
|
require "Tk/$_[0].pm" unless($@); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$type = $self->{'_OBJECT'}->$type(@_); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
return $type; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub report { |
|
98
|
|
|
|
|
|
|
my $self = shift; |
|
99
|
|
|
|
|
|
|
my $tab = shift || 0; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $result = ''; |
|
102
|
|
|
|
|
|
|
my $count = 0; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
if($tab+0 == 0) { |
|
105
|
|
|
|
|
|
|
$result = "Structural layout of $0\n\n"; |
|
106
|
|
|
|
|
|
|
$result .= _make_entry($tab, ref($self->getobj), $self->{'_COMMENT'}); |
|
107
|
|
|
|
|
|
|
} else { |
|
108
|
|
|
|
|
|
|
$result = ''; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
foreach (keys(%{$self->{'_WIDGETS'}})) { |
|
112
|
|
|
|
|
|
|
$result .= _make_entry($tab, "$_ - " . ref($self->{'_WIDGETS'}->{$_}->getobj), $self->{'_WIDGETS'}->{$_}->{'_COMMENT'}); |
|
113
|
|
|
|
|
|
|
$result .= $self->{'_WIDGETS'}->{$_}->report($tab + 1); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
$result .= "\n" if(keys(%{$self->{'_WIDGETS'}})); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
return $result; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _make_entry { |
|
122
|
|
|
|
|
|
|
my $tab = shift || 0; |
|
123
|
|
|
|
|
|
|
my $message_text = shift || ' '; |
|
124
|
|
|
|
|
|
|
my $comments = shift || ' '; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$columns = 39; # for wrap |
|
127
|
|
|
|
|
|
|
my @list = split(/\n/, wrap("", "", $message_text)); |
|
128
|
|
|
|
|
|
|
my @list2 = split(/\n/, wrap("", "", $comments)); |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $big = $#list > $#list2 ? $#list : $#list2; |
|
131
|
|
|
|
|
|
|
my $line = ''; |
|
132
|
|
|
|
|
|
|
for(my $i = 0; $i <= $big; $i++) { |
|
133
|
|
|
|
|
|
|
if(defined $list[$i]) { |
|
134
|
|
|
|
|
|
|
$line .= join('', " " x $tab, $list[$i], " " x (40 - $tab - length($list[$i]))); |
|
135
|
|
|
|
|
|
|
if(defined $list2[$i]) { |
|
136
|
|
|
|
|
|
|
$line .= $list2[$i]; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
} else { |
|
139
|
|
|
|
|
|
|
$line .= join('', " " x 40, $list2[$i]); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
$line .= "\n"; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
return $line; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub DESTROY { |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
152
|
|
|
|
|
|
|
my $self = shift; |
|
153
|
|
|
|
|
|
|
my $type = ref($self) or croak '$self is not an object'; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $name = $AUTOLOAD; |
|
156
|
|
|
|
|
|
|
$name =~ s/.*:://; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
if(exists $self->{'_WIDGETS'}->{$name}) { |
|
159
|
|
|
|
|
|
|
return $self->{'_WIDGETS'}->{$name}; |
|
160
|
|
|
|
|
|
|
} else { |
|
161
|
|
|
|
|
|
|
return $self->{'_OBJECT'}->$name(@_); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
|
170
|
|
|
|
|
|
|
__END__ |