line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## $Source: FileEntry.pm $ $Revision: 1.4 $ |
2
|
|
|
|
|
|
|
### |
3
|
|
|
|
|
|
|
### Primitive FileEntry widget. POD after __END__ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Tk::FileEntry; |
6
|
1
|
|
|
1
|
|
611
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
114
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub printargs { |
9
|
0
|
0
|
|
0
|
|
|
print join('|', map { $_ = '(undef)' unless defined $_ } @_, "\n"); |
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Tk; |
13
|
|
|
|
|
|
|
require Tk::Widget; |
14
|
|
|
|
|
|
|
require Tk::Derived; |
15
|
|
|
|
|
|
|
require Tk::Frame; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
747
|
|
18
|
|
|
|
|
|
|
@ISA = qw(Tk::Derived Tk::Frame); |
19
|
|
|
|
|
|
|
$VERSION = substr q$Revision: 1.4 $, 10; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Construct Tk::Widget 'FileEntry'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $FILEBITMAP = undef; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub ClassInit { |
26
|
0
|
|
|
0
|
|
|
my ($class, $mw) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
return if defined $FILEBITMAP; # needed for several MainWindows |
29
|
0
|
|
|
|
|
|
$FILEBITMAP = __PACKAGE__ . '::OPENFOLDER'; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $bits = pack("b16"x10, |
32
|
|
|
|
|
|
|
"...111111.......", |
33
|
|
|
|
|
|
|
"..1......11.....", |
34
|
|
|
|
|
|
|
".1.........1....", |
35
|
|
|
|
|
|
|
".1..........1...", |
36
|
|
|
|
|
|
|
".1...11111111111", |
37
|
|
|
|
|
|
|
".1..1.1.1.1.1.1.", |
38
|
|
|
|
|
|
|
".1.1.1.1.1.1.1..", |
39
|
|
|
|
|
|
|
".11.1.1.1.1.1...", |
40
|
|
|
|
|
|
|
".1.1.1.1.1.1....", |
41
|
|
|
|
|
|
|
".1111111111.....", |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$mw->DefineBitmap($FILEBITMAP => 16,10, $bits); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub Populate { |
49
|
0
|
|
|
0
|
|
|
my ($w,$args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$w->SUPER::Populate($args); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
require Tk::Label; |
54
|
0
|
|
|
|
|
|
require Tk::Entry; |
55
|
0
|
|
|
|
|
|
require Tk::Button; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $l = $w->Label()->pack(-side=>'left'); |
58
|
0
|
|
|
|
|
|
my $e = $w->Entry()->pack(-side=>'left', -expand=>'yes', -fill=>'x'); |
59
|
0
|
|
|
|
|
|
my $b = $w->Button(-command=>[\&_selectfile, $w, $e],-takefocus=>0) |
60
|
|
|
|
|
|
|
->pack(-side=>'left',-fill=>'y'); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$e->bind('', [$w, '_invoke_command', $e]); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$w->Advertise('entry' => $e); |
65
|
0
|
|
|
|
|
|
$w->Advertise('button' => $b); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$w->ConfigSpecs( |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
-background => [qw(CHILDREN background Background), Tk::NORMAL_BG()], |
70
|
|
|
|
|
|
|
-foreground => [qw(CHILDREN foreground Foreground), Tk::BLACK() ], |
71
|
|
|
|
|
|
|
-state => [qw(CHILDREN state State normal) ], |
72
|
|
|
|
|
|
|
-label => [{-text => $l}, 'label', 'Label', 'File:'], |
73
|
|
|
|
|
|
|
-filebitmap => [{-bitmap => $b}, 'fileBitmap', 'FileBitmap', $FILEBITMAP,], |
74
|
|
|
|
|
|
|
-command => ['CALLBACK', undef, undef, undef], |
75
|
|
|
|
|
|
|
-variable => ['METHOD', undef, undef, undef], |
76
|
|
|
|
|
|
|
); |
77
|
0
|
|
|
|
|
|
$w; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _selectfile { |
82
|
0
|
|
|
0
|
|
|
my $w = shift; |
83
|
0
|
|
|
|
|
|
my $e = shift; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
unless (defined $w->{FSBOX}) { |
86
|
0
|
|
|
|
|
|
require Tk::FileSelect; |
87
|
0
|
|
|
|
|
|
$w->{FSBOX} = $w->FileSelect(); #-directory => '.'); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
my $file = $w->{FSBOX}->Show(); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
|
|
|
return unless defined $file && length $file; |
92
|
0
|
|
|
|
|
|
$e->delete(0,'end'); |
93
|
0
|
|
|
|
|
|
$e->insert('end',$file); |
94
|
0
|
|
|
|
|
|
$w->Callback(-command => $w, $file); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _invoke_command { |
98
|
0
|
|
|
0
|
|
|
my $w = shift; |
99
|
0
|
|
|
|
|
|
my $e = shift; |
100
|
0
|
|
|
|
|
|
my $file = $e->get(); |
101
|
0
|
0
|
0
|
|
|
|
return unless defined $file && length $file; |
102
|
0
|
|
|
|
|
|
$w->Callback(-command => $w, $e->get); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub variable { |
106
|
0
|
|
|
0
|
|
|
my $e = shift->Subwidget('entry'); |
107
|
0
|
|
|
|
|
|
my $v = shift; |
108
|
0
|
|
|
|
|
|
$e->configure(-textvariable => $v); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |