lib/App/SeismicUnixGui/misc/redisplay.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 74 CC 4 SCAR 13.9
CC
4
Cov
0%
labels
6.0
values
6.0
checkbuttons
6.0
CRAP 4.0
1 package App::SeismicUnixGui::misc::redisplay;
2  
3 use Moose;
4 our $VERSION = '0.0.1';
5  
6 my ( $first, $last, $all );
7 my $true = 1;
8 my $false = 0;
9  
10 =head2 anonymous hashes to common variables
11  
12 =cut
13  
14 my $entries = {
15 _max_entry_num => '',
16 _first_entry_num => '',
17 _final_entry_num => '',
18 _prev_final_entry_num => '',
19 _changed_index => '',
20 };
21  
22 my $LSU = {
23 _ref_labels_w => '',
24 _ref_values_w => '',
25 _ref_param_value_button_variable => '',
26 _ref_param_value_button => '',
27 _entry_array_ref => '',
28 _file => '',
29 };
30  
31 =head2 sub file
32  
33 $LSU->{_file}= $hash_ref;
34 print("redisp my name is $LSU->{_file} in\n");
35  
36  
37 =cut
38  
39 sub file {
40 my ( $self, $hash_ref ) = @_;
41 }
42  
43 =head2 sub range
44  
45 #foreach my $key(sort keys %$entries){
46 # my $values = $entries->{$key};
47 # print("parameter $key has value of $entries->{$key} \n\n");
48 # }
49 #print("redisp self is $self hash ref is $ref_hash\n\n");
50 #print("redisp final: $entries->{_final_entry_num}\n");
51 #print("redisp prev final: $entries->{_prev_final_entry_num}\n");
52 #print("redisp max $entries->{_max_entry_num}\n");
53  
54 =cut
55  
56 sub range {
57 my ( $self, $ref_hash ) = @_;
58 $entries = $ref_hash;
59 $first = ( $entries->{_first_entry_num} ) - 1;
60 $last = $entries->{_final_entry_num};
61 $all = $entries->{_max_entry_num};
62 }
63  
64 =head2 sub
65  
66 print("ref label redisplay @$ref_label_array, refframe2 $ref_frame\n");
67 note this is an LABEL widget
68 DB
69 print("1. redisplay, labels, text is @{$label_array_ref}[$i]\n");
70 print("redisplay, labels, i is $i\n");
71 print("2. redisplay, labels, text is @{$LSU->{_label_array_ref}}[$i]\n");
72  
73 =cut
74  
75 sub labels {
76 my ( $self, $label_array_ref, $ref_label_w ) = @_;
77  
78 if ($label_array_ref) {
79 $LSU->{_label_array_ref} = $label_array_ref;
80 for ( my $i = $first ; $i < $last ; $i++ ) {
81 @$ref_label_w[$i]->configure( -text => @$label_array_ref[$i], );
82 }
83 return ();
84 }
85 }
86  
87 =head2 sub values
88  
89 i/p: 2 array references
90 o/p: array reference
91  
92 N.B. This is an ENTRY widget
93 textvariables must be a reference in order
94 for -validatecommand to work. BEWARE!
95  
96 DB
97 print("redisplay, values, i is $i\n");
98 print("redisplay, values, entry is @{$LSU->{_entry_array_ref}}[$i]\n");
99  
100 =cut
101  
102 sub values {
103 my ( $self, $entry_array_ref, $ref_entry_w ) = @_;
104 if ($entry_array_ref) {
105 $LSU->{_entry_array_ref} = $entry_array_ref;
106  
107 for ( my $i = $first ; $i < $last ; $i++ ) {
108 @$ref_entry_w[$i]->configure(
109 -textvariable => \@{ $LSU->{_entry_array_ref} }[$i],
110 -validate => 'focusout',
111 -validatecommand => [ \&new_entry, $i ],
112 -invalidcommand => \&error_check,
113 );
114 }
115 }
116 }
117  
118 =head2 sub collect_new_values
119  
120  
121 =cut
122  
123 sub collect_new_entry_values {
124  
125 return ( \@{ $LSU->{_entry_array_ref} } );
126  
127 }
128  
129 =head2 sub new_entry
130  
131 When original value of Entry widget (package create, sub valuesc)
132 is modified, test the new value
133 Now can test for integers or decimal values as follows:
134  
135 if (($test =~ /^-?\d+/) || ($test =~ /^-?\d+\.\d+/)) {
136 print ("Error: Entered an integer (First check)\n");
137 print ("or a decimal (2nd check)\n");
138  
139 TODO multiple values
140  
141 NB.
142 Dereference one scalar reference
143 within an array of references
144 First ascertain values are not blank
145 as during initialization of GUI.
146  
147 DB
148 print("redisplay,new_entry,new_entry_index is $index\n");
149 print("redisplay,new_entry,new_entry is @{$LSU->{_entry_array_ref}}[$index]\n");
150  
151  
152 =cut
153  
154 sub new_entry {
155 my ($index) = @_;
156 $entries->{_index} = $index;
157  
158 #print("redisplay,new_entry,new_entry_index is $index\n");
159 #print("redisplay,new_entry,new_entry is @{$LSU->{_entry_array_ref}}[$index]\n");
160 return ($true);
161 }
162  
163 =head2 sub error_check
164  
165 When entry values are not
166 decimals or numbers
167 used if new_entry returns a "$false" = 0
168 must return 1
169  
170 =cut
171  
172 sub error_check {
173 my $entry_value_ref = $entries->{_index};
174  
175 #print("Index is $$entry_value_ref\n");
176 return ($true);
177 }
178  
179 =head2 sub
180  
181 my $on = 'on';
182  
183 redisplay will require another input array of
184 on and off buttons
185  
186 =cut
187  
188 sub checkbuttons {
189 my ( $self, $ref_button, $ref_variable ) = @_;
190 my $i;
191  
192 if ( defined($ref_button) ) {
193 for ( $i = $first ; $i < $last ; $i++ ) {
194 @$ref_button[$i]->configure(
195 -background => 'red',
196 -activebackground => 'red',
197 -variable => \@$ref_variable[$i],
198 );
199 }
200 return ();
201 }
202 }
203 1;