line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tk::StatusBar; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24234
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(Tk::Frame); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
842
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Tk::widgets qw(Frame Label ProgressBar); |
9
|
|
|
|
|
|
|
use Carp; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Construct Tk::Widget 'StatusBar'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use vars qw($VERSION); |
14
|
|
|
|
|
|
|
$VERSION = 0.04; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub ClassInit { |
18
|
|
|
|
|
|
|
my ($class, $mw) = @_; |
19
|
|
|
|
|
|
|
$class->SUPER::ClassInit($mw); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $ResizeButtonImage = << 'end-of-pixmap'; |
22
|
|
|
|
|
|
|
/* XPM */ |
23
|
|
|
|
|
|
|
static char * Icon_xpm[] = { |
24
|
|
|
|
|
|
|
"13 14 3 1", |
25
|
|
|
|
|
|
|
" c none", |
26
|
|
|
|
|
|
|
"X c #888888", |
27
|
|
|
|
|
|
|
"A c #FFFFFF", |
28
|
|
|
|
|
|
|
" ", |
29
|
|
|
|
|
|
|
" ", |
30
|
|
|
|
|
|
|
" A", |
31
|
|
|
|
|
|
|
" AX", |
32
|
|
|
|
|
|
|
" AXX", |
33
|
|
|
|
|
|
|
" AXX ", |
34
|
|
|
|
|
|
|
" AXX A", |
35
|
|
|
|
|
|
|
" AXX AX", |
36
|
|
|
|
|
|
|
" AXX AXX", |
37
|
|
|
|
|
|
|
" AXX AXX ", |
38
|
|
|
|
|
|
|
" AXX AXX A", |
39
|
|
|
|
|
|
|
" AXX AXX AX", |
40
|
|
|
|
|
|
|
" AXX AXX AXX", |
41
|
|
|
|
|
|
|
" AXX AXX AXX ", |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
end-of-pixmap |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$mw->Pixmap('ResizeButtonImage', -data => $ResizeButtonImage); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub Populate { |
49
|
|
|
|
|
|
|
my ($self, $args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->SUPER::Populate($args); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# add a spacer frame |
54
|
|
|
|
|
|
|
$self->Frame()->pack(-pady => 1); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# add the resize button |
57
|
|
|
|
|
|
|
$self->{ResizeButton} = $self->Label( |
58
|
|
|
|
|
|
|
-image => 'ResizeButtonImage', |
59
|
|
|
|
|
|
|
-relief => 'flat', |
60
|
|
|
|
|
|
|
-cursor => ($^O =~ /^(MSWin32|DOS)$/ ? 'size_nw_se' : 'bottom_right_corner'), |
61
|
|
|
|
|
|
|
)->pack( |
62
|
|
|
|
|
|
|
-side => 'right', |
63
|
|
|
|
|
|
|
-anchor => 'se', |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# bind events to the resize button |
67
|
|
|
|
|
|
|
$self->{ResizeButton}->bind("", [\&_Mark, $self]); |
68
|
|
|
|
|
|
|
$self->{ResizeButton}->bind('' => [\&_Resize, $self]); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# hidden until show() is called |
71
|
|
|
|
|
|
|
$self->{HIDDEN} = 1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# now show the statusbar |
74
|
|
|
|
|
|
|
$self->show(); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _Mark { |
78
|
|
|
|
|
|
|
$_[1]->{markx} = $_[1]->pointerx; |
79
|
|
|
|
|
|
|
$_[1]->{marky} = $_[1]->pointery; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _Resize { |
83
|
|
|
|
|
|
|
my $self = $_[1]; |
84
|
|
|
|
|
|
|
my ($w, $h) = split /[x+]/, $self->parent->geometry; |
85
|
|
|
|
|
|
|
$w += ($self->pointerx - $self->{markx}); |
86
|
|
|
|
|
|
|
$h += ($self->pointery - $self->{marky}); |
87
|
|
|
|
|
|
|
$self->_Mark($self); |
88
|
|
|
|
|
|
|
$self->parent->geometry($w . 'x' . $h) if ($w > 0 && $h > 0); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub addLabel { |
92
|
|
|
|
|
|
|
my ($self, %args) = @_; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $width = delete $args{-width}; |
95
|
|
|
|
|
|
|
my $side = delete $args{-side} || 'left'; |
96
|
|
|
|
|
|
|
my $relief = delete $args{-relief} || 'sunken'; |
97
|
|
|
|
|
|
|
my $borderwidth = delete $args{-borderwidth} || 1; |
98
|
|
|
|
|
|
|
my $anchor = delete $args{-anchor} || 'w'; |
99
|
|
|
|
|
|
|
my $expand = delete $args{-expand} || 1; |
100
|
|
|
|
|
|
|
my $command = delete $args{-command}; |
101
|
|
|
|
|
|
|
my $event = delete $args{-event} || ''; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
if ($command && ref($command) ne 'CODE') { |
104
|
|
|
|
|
|
|
croak "-command must be a code reference"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $n = $self->Label( |
108
|
|
|
|
|
|
|
-relief => $relief, |
109
|
|
|
|
|
|
|
-borderwidth => $borderwidth, |
110
|
|
|
|
|
|
|
-anchor => $anchor, |
111
|
|
|
|
|
|
|
%args, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
if (! $width) { |
115
|
|
|
|
|
|
|
$n->pack( |
116
|
|
|
|
|
|
|
-side => $side, |
117
|
|
|
|
|
|
|
-expand => $expand, |
118
|
|
|
|
|
|
|
-fill => 'x', |
119
|
|
|
|
|
|
|
-padx => 1, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
|
|
|
|
|
|
$n->configure(-width => $width); |
124
|
|
|
|
|
|
|
$n->pack( |
125
|
|
|
|
|
|
|
-side => $side, |
126
|
|
|
|
|
|
|
-padx => 1, |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
if ($command && $event) { |
131
|
|
|
|
|
|
|
eval {$n->bind($event, $command)}; |
132
|
|
|
|
|
|
|
croak "bad event type, keysym, or command" if $@; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return $n; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub addProgressBar { |
139
|
|
|
|
|
|
|
my ($self, %args) = @_; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $length = $args{-length}; |
142
|
|
|
|
|
|
|
my $borderwidth = delete $args{-borderwidth} || 1; |
143
|
|
|
|
|
|
|
my $expand = delete $args{-expand} || 1; |
144
|
|
|
|
|
|
|
my $relief = delete $args{-borderwidth} || 'sunken'; |
145
|
|
|
|
|
|
|
my $side = delete $args{-side} || 'left'; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $n = $self->ProgressBar( |
148
|
|
|
|
|
|
|
-borderwidth => $borderwidth, |
149
|
|
|
|
|
|
|
-width => 17, |
150
|
|
|
|
|
|
|
-troughcolor => 'systembuttonface', |
151
|
|
|
|
|
|
|
%args, |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
$n->configure(-length => $length) if $length; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
if (! $length) { |
157
|
|
|
|
|
|
|
$n->pack( |
158
|
|
|
|
|
|
|
-side => $side, |
159
|
|
|
|
|
|
|
-expand => $expand, |
160
|
|
|
|
|
|
|
-fill => 'x', |
161
|
|
|
|
|
|
|
-padx => 1, |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else { |
165
|
|
|
|
|
|
|
$n->pack( |
166
|
|
|
|
|
|
|
-side => $side, |
167
|
|
|
|
|
|
|
-padx => 1, |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
return $n; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub hide { |
175
|
|
|
|
|
|
|
my $self = shift; |
176
|
|
|
|
|
|
|
if (! $self->{HIDDEN}) { |
177
|
|
|
|
|
|
|
$self->packForget; |
178
|
|
|
|
|
|
|
$self->{HIDDEN} = 1; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub show { |
183
|
|
|
|
|
|
|
my $self = shift; |
184
|
|
|
|
|
|
|
if ($self->{HIDDEN}) { |
185
|
|
|
|
|
|
|
my %args = ( |
186
|
|
|
|
|
|
|
-side => 'bottom', |
187
|
|
|
|
|
|
|
-fill => 'x', |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
if ($self->parent->packSlaves) { |
191
|
|
|
|
|
|
|
($args{-before}) = $self->parent->packSlaves; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$self->pack(%args); |
195
|
|
|
|
|
|
|
$self->{HIDDEN} = 0; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |
202
|
|
|
|
|
|
|
__END__ |