line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ReportBox; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
654
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
823
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
7
|
|
|
|
|
|
|
require Tk::Toplevel; |
8
|
|
|
|
|
|
|
our @ISA = qw(Tk::Toplevel); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Tk::Widget->Construct('ReportBox'); |
11
|
|
|
|
|
|
|
sub Populate |
12
|
|
|
|
|
|
|
{ |
13
|
0
|
|
|
0
|
|
|
require Tk::Label; |
14
|
0
|
|
|
|
|
|
require Tk::Button; |
15
|
0
|
|
|
|
|
|
require Tk::Frame; |
16
|
0
|
|
|
|
|
|
require Tk::Entry; |
17
|
0
|
|
|
|
|
|
require Tk::Listbox; |
18
|
0
|
|
|
|
|
|
require Tk::FileSelect; |
19
|
0
|
|
|
|
|
|
my ($main, $args) = @_; |
20
|
0
|
|
|
|
|
|
my $text; |
21
|
0
|
|
|
|
|
|
my $file = $args->{'-file'}; |
22
|
0
|
|
|
|
|
|
my $mode = $args->{'-mode'}; |
23
|
0
|
|
|
|
|
|
my $headers = $args->{'-headers'}; |
24
|
0
|
0
|
|
|
|
|
$headers = 2 unless $headers; |
25
|
0
|
|
|
|
|
|
my $startdir = $args->{'-startdir'}; |
26
|
0
|
0
|
|
|
|
|
$startdir = './' unless $startdir; |
27
|
0
|
|
|
|
|
|
my $printstr = $args->{'-printstr'}; |
28
|
0
|
0
|
|
|
|
|
$printstr = "lp $file" unless $printstr; |
29
|
0
|
|
|
|
|
|
$main->SUPER::Populate($args); |
30
|
0
|
|
|
|
|
|
open (F,$file); |
31
|
0
|
0
|
|
|
|
|
$mode = 0 unless $mode; |
32
|
0
|
0
|
|
|
|
|
if ($mode) |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
|
|
|
$text = $main->Scrolled("Listbox", |
35
|
|
|
|
|
|
|
-font => 'Courier', |
36
|
|
|
|
|
|
|
-width => '80', |
37
|
|
|
|
|
|
|
-height => '20')->pack(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
|
|
|
$text = $main->Scrolled("Text", |
42
|
|
|
|
|
|
|
-font => 'Courier', |
43
|
|
|
|
|
|
|
-width => '80', |
44
|
|
|
|
|
|
|
-height => '20', |
45
|
|
|
|
|
|
|
)->pack(); |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
while () |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
0
|
|
|
|
|
chomp if $mode; |
50
|
0
|
|
|
|
|
|
$text->insert('end',$_); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
close (F); |
53
|
0
|
0
|
|
|
|
|
if ($mode == 0) |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
|
$text->configure(-state => 'disabled'); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
my $okbut = $main->Button |
58
|
|
|
|
|
|
|
( |
59
|
|
|
|
|
|
|
-text => 'OK', |
60
|
|
|
|
|
|
|
-command=>sub |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
|
|
$main->{'-button'} = 0; |
63
|
0
|
|
|
|
|
|
$main->withdraw; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
)->pack(-side => 'left'); |
66
|
0
|
0
|
|
|
|
|
if ($mode) |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
my $editbut = $main->Button |
69
|
|
|
|
|
|
|
( |
70
|
|
|
|
|
|
|
-text => 'Edit', |
71
|
|
|
|
|
|
|
-command=>sub |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
0
|
|
|
my $line; |
74
|
0
|
|
|
|
|
|
my @selected = $text->curselection(); |
75
|
0
|
0
|
0
|
|
|
|
if (@selected and $selected[0] > ($headers - 1)) |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
|
|
|
$main->{'-button'} = 1; |
78
|
0
|
|
|
|
|
|
$main->withdraw(); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
)->pack(-side => 'left'); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
my $printbut = $main->Button |
84
|
|
|
|
|
|
|
( |
85
|
|
|
|
|
|
|
-text => 'Print', |
86
|
|
|
|
|
|
|
-command=>sub |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
0
|
|
|
system("$printstr"); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
)->pack(-side => 'left'); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $savebut = $main->Button |
93
|
|
|
|
|
|
|
( |
94
|
|
|
|
|
|
|
-text => 'Save', |
95
|
|
|
|
|
|
|
-command=>sub |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
|
|
my $fref = $main->FileSelect(-directory => $startdir); |
98
|
0
|
|
|
|
|
|
my $newfile = $fref->Show; |
99
|
0
|
|
|
|
|
|
print "$newfile\n"; |
100
|
0
|
0
|
|
|
|
|
if ($newfile) |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
|
|
|
|
|
open (F, "$file"); |
103
|
0
|
|
|
|
|
|
open (F1, ">$newfile"); |
104
|
0
|
|
|
|
|
|
while () |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
|
|
|
print (F1 $_); |
107
|
|
|
|
|
|
|
} |
108
|
0
|
|
|
|
|
|
close F; |
109
|
0
|
|
|
|
|
|
close F1; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
0
|
|
|
|
|
|
)->pack(-side => 'left'); |
113
|
0
|
|
|
|
|
|
$main->ConfigSpecs( |
114
|
|
|
|
|
|
|
'-startdir' => ['PASSIVE'], |
115
|
|
|
|
|
|
|
'-printstr' => ['PASSIVE'], |
116
|
|
|
|
|
|
|
'-headers' => ['PASSIVE'], |
117
|
|
|
|
|
|
|
'-file' => ['PASSIVE'], |
118
|
|
|
|
|
|
|
'-button' => ['PASSIVE'], |
119
|
|
|
|
|
|
|
'-deliver' => ['METHOD'], |
120
|
|
|
|
|
|
|
'-mode' => ['PASSIVE'], |
121
|
|
|
|
|
|
|
DEFAULT => [$text]); |
122
|
0
|
|
|
|
|
|
$main->Advertise('list' => $text); |
123
|
|
|
|
|
|
|
}#end of sub populate |
124
|
|
|
|
|
|
|
sub deliver |
125
|
|
|
|
|
|
|
{ |
126
|
0
|
|
|
0
|
|
|
my ($main,$temp) = @_; |
127
|
0
|
|
|
|
|
|
$main->waitVariable(\$main->{'-button'}); |
128
|
0
|
0
|
|
|
|
|
if ($main->{'-button'}) |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
|
|
|
my $list = $main->Subwidget('list'); |
131
|
0
|
|
|
|
|
|
my @selected = $list->curselection(); |
132
|
0
|
|
|
|
|
|
return($list->get($selected[0])); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
|
return (0); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
__END__ |