« lib/App/SeismicUnixGui/misc/help.pm
↑ Summary
lib/App/SeismicUnixGui/misc/oop_declare_data_in.pm »
| 1 | package App::SeismicUnixGui::misc::color_listbox; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | =head2 SYNOPSIS | ||
| 5 | PERL PROGRAM NAME: color_listbox | ||
| 6 | AUTHOR: Juan Lorenzo | ||
| 7 | DATE: December 19, 2020 | ||
| 8 | DESCRIPTION | ||
| 9 | Basic class with color_listbox attributes | ||
| 10 | BASED ON: | ||
| 11 | =cut | ||
| 12 | |||
| 13 | =head2 USE | ||
| 14 | =head3 NOTES | ||
| 15 | =head4 Examples | ||
| 16 | =head2 CHANGES and their DATES | ||
| 17 | =cut | ||
| 18 | |||
| 19 | =head2 Notes from bash | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | use Moose; | ||
| 24 | #use namespace::autoclean; # best-practices hygiene | ||
| 25 | our $VERSION = '0.0.1'; | ||
| 26 | |||
| 27 | =head2 Import modules | ||
| 28 | =cut | ||
| 29 | |||
| 30 | extends 'App::SeismicUnixGui::misc::gui_history' => { -version => 0.0.2 }; | ||
| 31 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 32 | use aliased 'App::SeismicUnixGui::misc::gui_history'; | ||
| 33 | use aliased 'App::SeismicUnixGui::messages::message_director'; | ||
| 34 | |||
| 35 | =head2 Instantiation | ||
| 36 | =cut | ||
| 37 | |||
| 38 | my $get = L_SU_global_constants->new(); | ||
| 39 | my $gui_history = gui_history->new(); | ||
| 40 | my $message_director = message_director->new(); | ||
| 41 | |||
| 42 | =head2 Declare Special Variables | ||
| 43 | =cut | ||
| 44 | |||
| 45 | my $var = $get->var(); | ||
| 46 | my $empty_string = $var->{_empty_string}; | ||
| 47 | my $color_default = $var->{_color_default}; #grey | ||
| 48 | my $reservation_color_default = $var->{_reservation_color_default}; | ||
| 49 | my $false = $var->{_false}; | ||
| 50 | my $no = $var->{_no}; | ||
| 51 | my $true = $var->{_true}; | ||
| 52 | |||
| 53 | =head2 Defaults | ||
| 54 | =cut | ||
| 55 | |||
| 56 | my $availability_start = $false; | ||
| 57 | my $color_start = $color_default; | ||
| 58 | my $my_dialog_box_cancel_default = $no; | ||
| 59 | my $my_dialog_box_click_default = $no; | ||
| 60 | my $my_dialog_box_ok_default = $no; | ||
| 61 | my $my_dialog_box_click_start = $no; | ||
| 62 | my $my_dialog_cancel_click_start = $no; | ||
| 63 | my $my_dialog_ok_click_start = $no; | ||
| 64 | my $flow_listbox_color_start = $color_default; | ||
| 65 | my $flow_listbox_color2check_start = $color_default; | ||
| 66 | my $next_available_occupied_start = $false; | ||
| 67 | my $next_available_vacancy_start = $false; | ||
| 68 | my $next_available_flow_listbox_color_start = $color_default; | ||
| 69 | my $occupied_start = $false; | ||
| 70 | my $flow_listbox_color_reservation_start = $reservation_color_default; | ||
| 71 | my $prior_available_flow_listbox_color_start = $color_default; | ||
| 72 | my $vacant_start = $true; | ||
| 73 | my $yes = $var->{_yes}; | ||
| 74 | |||
| 75 | # initialization only | ||
| 76 | # must be populated fromt the outside via set_hash_ref | ||
| 77 | my $color_listbox_href = $gui_history->get_defaults(); | ||
| 78 | |||
| 79 | =head2 private anonymous array | ||
| 80 | =cut | ||
| 81 | |||
| 82 | my $color_listbox = { | ||
| 83 | _is_flow_listbox_color_available => '', | ||
| 84 | _is_flow_listbox_blue_w => '', | ||
| 85 | _is_flow_listbox_green_w => '', | ||
| 86 | _is_flow_listbox_grey_w => '', | ||
| 87 | _is_flow_listbox_pink_w => '', | ||
| 88 | |||
| 89 | # _is_next_available_flow_listbox_blue => '', | ||
| 90 | _is_next_available_flow_listbox_color => '', | ||
| 91 | |||
| 92 | # _is_next_available_flow_listbox_green => '', | ||
| 93 | # _is_next_available_flow_listbox_grey => '', | ||
| 94 | # _is_next_available_flow_listbox_pink => '', | ||
| 95 | _my_dialog_cancel_click => $my_dialog_box_cancel_default, | ||
| 96 | _my_dialog_box_click => $my_dialog_box_click_default, | ||
| 97 | _my_dialog_ok_click => $my_dialog_box_ok_default, | ||
| 98 | _this_package => '', | ||
| 99 | }; | ||
| 100 | |||
| 101 | sub BUILD { | ||
| 102 | my ($this_package_address) = @_; | ||
| 103 | |||
| 104 | $color_listbox->{_this_package} = $this_package_address; | ||
| 105 | |||
| 106 | } | ||
| 107 | |||
| 108 | #print("2. color_listbox, color_listbox->{_my_dialog_box_click}=$color_listbox->{_my_dialog_box_click}\n"); | ||
| 109 | |||
| 110 | =head2 private anonymous hashes | ||
| 111 | containing history | ||
| 112 | =cut | ||
| 113 | |||
| 114 | =head2 initialize arrays | ||
| 115 | =cut | ||
| 116 | |||
| 117 | =head2 sub _default_flow_listbox_color_availability_aref | ||
| 118 | Initialize array of listbox availability across an array | ||
| 119 | of colored listboxes | ||
| 120 | indicators show whether listbox may be available. | ||
| 121 | =cut | ||
| 122 | |||
| 123 | sub _default_flow_listbox_color_availability_aref { | ||
| 124 | |||
| 125 | my ($self) = @_; | ||
| 126 | |||
| 127 | my @availability_listbox_color = ( | ||
| 128 | $availability_start, | ||
| 129 | $availability_start, | ||
| 130 | $availability_start, | ||
| 131 | $availability_start | ||
| 132 | ); | ||
| 133 | |||
| 134 | my $flow_listbox_color_availability_aref = \@availability_listbox_color; | ||
| 135 | return ($flow_listbox_color_availability_aref); | ||
| 136 | |||
| 137 | } | ||
| 138 | |||
| 139 | =head2 sub default_next_available_occupied_listbox_aref | ||
| 140 | Initialize array of next_available occupied-flow-listbox-array | ||
| 141 | indicators that indicate which listbox will next be | ||
| 142 | used | ||
| 143 | =cut | ||
| 144 | |||
| 145 | sub _default_next_available_occupied_listbox_aref { | ||
| 146 | |||
| 147 | my ($self) = @_; | ||
| 148 | |||
| 149 | my @next_available_occupied_listbox = ( | ||
| 150 | $next_available_occupied_start, | ||
| 151 | $next_available_occupied_start, | ||
| 152 | $next_available_occupied_start, | ||
| 153 | $next_available_occupied_start | ||
| 154 | ); | ||
| 155 | |||
| 156 | my $flow_listbox_next_available_occupancy_aref = \@next_available_occupied_listbox; | ||
| 157 | return ($flow_listbox_next_available_occupancy_aref); | ||
| 158 | |||
| 159 | } | ||
| 160 | |||
| 161 | =head2 sub default_occupied_listbox_aref | ||
| 162 | Initialize array of occupied-flow-listbox-array | ||
| 163 | indicators | ||
| 164 | =cut | ||
| 165 | |||
| 166 | sub _default_occupied_listbox_aref { | ||
| 167 | |||
| 168 | my ($self) = @_; | ||
| 169 | |||
| 170 | my @occupied_listbox = ( | ||
| 171 | $occupied_start, | ||
| 172 | $occupied_start, | ||
| 173 | $occupied_start, | ||
| 174 | $occupied_start | ||
| 175 | ); | ||
| 176 | |||
| 177 | my $flow_listbox_occupancy_aref = \@occupied_listbox; | ||
| 178 | return ($flow_listbox_occupancy_aref); | ||
| 179 | |||
| 180 | } | ||
| 181 | |||
| 182 | =head2 sub default_next_available_vacancy_listbox_aref | ||
| 183 | Initialize array of next_available vacant-flow-listbox-array | ||
| 184 | indicators that indicate which listbox will next be | ||
| 185 | used | ||
| 186 | =cut | ||
| 187 | |||
| 188 | sub _default_next_available_vacancy_listbox_aref { | ||
| 189 | |||
| 190 | my ($self) = @_; | ||
| 191 | |||
| 192 | my @next_available_vacancy_listbox = ( | ||
| 193 | $next_available_vacancy_start, | ||
| 194 | $next_available_vacancy_start, | ||
| 195 | $next_available_vacancy_start, | ||
| 196 | $next_available_vacancy_start | ||
| 197 | ); | ||
| 198 | |||
| 199 | my $flow_listbox_next_available_vacancy_aref = \@next_available_vacancy_listbox; | ||
| 200 | return ($flow_listbox_next_available_vacancy_aref); | ||
| 201 | |||
| 202 | } | ||
| 203 | |||
| 204 | =head2 sub _default_vacant_listbox_aref | ||
| 205 | Initialize array of empty-flow-listbox-array | ||
| 206 | indicators | ||
| 207 | =cut | ||
| 208 | |||
| 209 | sub _default_vacant_listbox_aref { | ||
| 210 | |||
| 211 | my ($self) = @_; | ||
| 212 | |||
| 213 | my @vacant_listbox = ( | ||
| 214 | $vacant_start, | ||
| 215 | $vacant_start, | ||
| 216 | $vacant_start, | ||
| 217 | $vacant_start | ||
| 218 | ); | ||
| 219 | |||
| 220 | my $flow_listbox_vacancy_aref = \@vacant_listbox; | ||
| 221 | return ($flow_listbox_vacancy_aref); | ||
| 222 | |||
| 223 | } | ||
| 224 | |||
| 225 | =head2 Declare attributes | ||
| 226 | Check hat empty flows are marked vacant. | ||
| 227 | Mark occupied and vacant flows as available | ||
| 228 | for occupation or reoccupation, (potentially) | ||
| 229 | =cut | ||
| 230 | |||
| 231 | has 'flow_listbox_color_availability_aref' => ( | ||
| 232 | default => \&_default_flow_listbox_color_availability_aref, | ||
| 233 | is => 'ro', | ||
| 234 | isa => 'ArrayRef', | ||
| 235 | reader => 'get_flow_listbox_color_availability_aref', | ||
| 236 | writer => 'set_flow_listbox_color_availability_aref', | ||
| 237 | trigger => \&_update_flow_listbox_color_availability_aref, | ||
| 238 | |||
| 239 | ); | ||
| 240 | |||
| 241 | has 'flow_listbox_color2check' => ( | ||
| 242 | default => $flow_listbox_color2check_start, | ||
| 243 | is => 'rw', | ||
| 244 | isa => 'Str', | ||
| 245 | writer => 'set_flow_listbox_color2check', | ||
| 246 | trigger => \&_flow_listbox_color2check, | ||
| 247 | ); | ||
| 248 | |||
| 249 | has 'flow_listbox_color' => ( | ||
| 250 | default => $flow_listbox_color_start, | ||
| 251 | is => 'rw', | ||
| 252 | isa => 'Str', | ||
| 253 | reader => 'get_flow_listbox_color', | ||
| 254 | writer => 'set_flow_listbox_color', | ||
| 255 | predicate => 'has_flow_listbox_color', | ||
| 256 | trigger => \&_update_flow_listbox_color, | ||
| 257 | ); | ||
| 258 | |||
| 259 | has 'flow_listbox_next_available_occupancyNvacancy_aref' => ( | ||
| 260 | default => \&_default_next_available_occupied_listbox_aref, | ||
| 261 | is => 'ro', | ||
| 262 | isa => 'ArrayRef', | ||
| 263 | reader => 'get_flow_listbox_next_available_occupancyNvacancy_aref', | ||
| 264 | writer => 'set_flow_listbox_next_available_occupancyNvacancy_aref', | ||
| 265 | predicate => 'has_flow_listbox_next_available_occupancyNvacancy_aref', | ||
| 266 | trigger => \&_update_flow_listbox_next_available_occupancyNvacancy_aref, | ||
| 267 | ); | ||
| 268 | |||
| 269 | has 'flow_listbox_occupancy_aref' => ( | ||
| 270 | default => \&_default_occupied_listbox_aref, | ||
| 271 | is => 'ro', | ||
| 272 | isa => 'ArrayRef', | ||
| 273 | reader => 'get_flow_listbox_occupancy_aref', | ||
| 274 | writer => 'set_flow_listbox_occupancy_aref', | ||
| 275 | predicate => 'has_flow_listbox_occupancy_aref', | ||
| 276 | |||
| 277 | # trigger method is not in use | ||
| 278 | ); | ||
| 279 | |||
| 280 | has 'flow_listbox_vacancy_color' => ( | ||
| 281 | default => $color_start, | ||
| 282 | is => 'ro', | ||
| 283 | isa => 'Str', | ||
| 284 | reader => 'get_flow_listbox_vacancy_color', | ||
| 285 | ); | ||
| 286 | |||
| 287 | has 'flow_listbox_vacancy_aref' => ( | ||
| 288 | default => \&_default_vacant_listbox_aref, | ||
| 289 | is => 'ro', | ||
| 290 | isa => 'ArrayRef', | ||
| 291 | reader => 'get_flow_listbox_vacancy_aref', | ||
| 292 | predicate => 'has_flow_listbox_vacancy_aref', | ||
| 293 | ); | ||
| 294 | |||
| 295 | has 'next_available_flow_listbox_color' => ( | ||
| 296 | default => $next_available_flow_listbox_color_start, | ||
| 297 | is => 'rw', | ||
| 298 | isa => 'Str', | ||
| 299 | reader => 'get_next_available_flow_listbox_color', | ||
| 300 | writer => 'set_next_available_flow_listbox_color', | ||
| 301 | trigger => \&_update_next_available_flow_listbox_color, | ||
| 302 | ); | ||
| 303 | has my_dialog_cancel_click => ( | ||
| 304 | default => $my_dialog_cancel_click_start, | ||
| 305 | is => 'rw', | ||
| 306 | isa => 'Str', | ||
| 307 | reader => 'get_my_dialog_cancel_click', | ||
| 308 | writer => 'set_my_dialog_cancel_click', | ||
| 309 | trigger => \&_update_my_dialog_cancel_click, | ||
| 310 | ); | ||
| 311 | has my_dialog_ok_click => ( | ||
| 312 | default => $my_dialog_ok_click_start, | ||
| 313 | is => 'rw', | ||
| 314 | isa => 'Str', | ||
| 315 | reader => 'get_my_dialog_ok_click', | ||
| 316 | writer => 'set_my_dialog_ok_click', | ||
| 317 | |||
| 318 | # trigger => \&_update_my_dialog_ok_click, | ||
| 319 | ); | ||
| 320 | |||
| 321 | has my_dialog_box_click => ( | ||
| 322 | default => $my_dialog_box_click_start, | ||
| 323 | is => 'rw', | ||
| 324 | isa => 'Str', | ||
| 325 | reader => 'get_my_dialog_box_click', | ||
| 326 | writer => 'set_my_dialog_box_click', | ||
| 327 | ); | ||
| 328 | |||
| 329 | has 'flow_listbox_color_reservation' => ( | ||
| 330 | default => $flow_listbox_color_reservation_start, | ||
| 331 | is => 'ro', | ||
| 332 | isa => 'Str', | ||
| 333 | reader => 'get_flow_listbox_color_reservation', | ||
| 334 | writer => 'set_flow_listbox_color_reservation', | ||
| 335 | trigger => \&_update_flow_listbox_color_reservation, | ||
| 336 | |||
| 337 | ); | ||
| 338 | |||
| 339 | has 'prior_available_flow_listbox_color' => ( | ||
| 340 | default => $prior_available_flow_listbox_color_start, | ||
| 341 | is => 'rw', | ||
| 342 | isa => 'Str', | ||
| 343 | reader => 'get_prior_available_flow_listbox_color', | ||
| 344 | writer => 'set_prior_available_flow_listbox_color', | ||
| 345 | trigger => \&_update_prior_available_flow_listbox_color, | ||
| 346 | ); | ||
| 347 | |||
| 348 | |||
| 349 | =head2 sub _flow_listbox_color2check | ||
| 350 | =cut | ||
| 351 | |||
| 352 | sub _flow_listbox_color2check { | ||
| 353 | my ( $color_listbox, $new_current_flow_listbox_color2check, $new_prior_flow_listbox_color2check ) = @_; | ||
| 354 | |||
| 355 | my $check = $new_current_flow_listbox_color2check; | ||
| 356 | |||
| 357 | # print("color_listbox, _flow_listbox_color2check, check=$check\n"); | ||
| 358 | |||
| 359 | if ( length $check | ||
| 360 | && length $color_listbox | ||
| 361 | && length $color_listbox->get_flow_listbox_occupancy_aref() | ||
| 362 | && length $color_listbox->get_flow_listbox_vacancy_aref() ) { | ||
| 363 | |||
| 364 | my @occupied_listbox = @{ $color_listbox->get_flow_listbox_occupancy_aref() }; | ||
| 365 | my @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 366 | |||
| 367 | # print(" color_listbox,_flow_listbox_color2check,occupied_listbox=@occupied_listbox \n"); | ||
| 368 | # print(" color_listbox,_flow_listbox_color2check,vacant_listbox=@vacant_listbox \n"); | ||
| 369 | |||
| 370 | if ( $check eq 'grey' | ||
| 371 | && $occupied_listbox[0] == $false | ||
| 372 | && $vacant_listbox[0] == $true ) { | ||
| 373 | |||
| 374 | # print("color_listbox, _flow_listbox_color2check, grey flow box is empty\n"); | ||
| 375 | # print( | ||
| 376 | # "color_listbox, _flow_listbox_color2check, occupied_listbox=$occupied_listbox[0], vacant_listbox=$vacant_listbox[0]\n" | ||
| 377 | # ); | ||
| 378 | # print( | ||
| 379 | # "color_listbox, _flow_listbox_color2check, color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n" | ||
| 380 | # ); | ||
| 381 | $color_listbox->{_is_flow_listbox_color_available} = $true; | ||
| 382 | |||
| 383 | } elsif ( $check eq 'pink' | ||
| 384 | && $occupied_listbox[1] == $false | ||
| 385 | && $vacant_listbox[1] == $true ) { | ||
| 386 | |||
| 387 | # print("color_listbox, _flow_listbox_color2check, pink flow box is empty\n"); | ||
| 388 | # print( | ||
| 389 | # "color_listbox, _flow_listbox_color2check, occupied_listbox=$occupied_listbox[1], vacant_listbox=$vacant_listbox[1]\n" | ||
| 390 | # ); | ||
| 391 | $color_listbox->{_is_flow_listbox_color_available} = $true; | ||
| 392 | |||
| 393 | # print("color_listbox, _flow_listbox_color2check,color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n"); | ||
| 394 | |||
| 395 | # print( | ||
| 396 | # "color_listbox, _flow_listbox_color2check, color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n" | ||
| 397 | # ); | ||
| 398 | |||
| 399 | } elsif ( $check eq 'green' | ||
| 400 | && $occupied_listbox[2] == $false | ||
| 401 | && $vacant_listbox[2] == $true ) { | ||
| 402 | |||
| 403 | # print("color_listbox, _flow_listbox_color2check, green flow box is empty\n"); | ||
| 404 | # print( | ||
| 405 | # "color_listbox, _flow_listbox_color2check, occupied_listbox=$occupied_listbox[2], vacant_listbox=$vacant_listbox[2]\n" | ||
| 406 | # ); | ||
| 407 | $color_listbox->{_is_flow_listbox_color_available} = $true; | ||
| 408 | |||
| 409 | } elsif ( $check eq 'blue' | ||
| 410 | && $occupied_listbox[3] == $false | ||
| 411 | && $vacant_listbox[3] == $true ) { | ||
| 412 | |||
| 413 | # print("color_listbox, _flow_listbox_color2check, blue flow box is empty\n"); | ||
| 414 | # print( | ||
| 415 | # "color_listbox, _flow_listbox_color2check, occupied_listbox=$occupied_listbox[3], vacant_listbox=$vacant_listbox[3]\n" | ||
| 416 | # ); | ||
| 417 | $color_listbox->{_is_flow_listbox_color_available} = $true; | ||
| 418 | |||
| 419 | } else { | ||
| 420 | |||
| 421 | # print("color_listbox, _flow_listbox_color2check, no flow box is available\n"); | ||
| 422 | $color_listbox->{_is_flow_listbox_color_available} = $false; | ||
| 423 | |||
| 424 | # print( | ||
| 425 | # "color_listbox, _flow_listbox_color2check, color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n" | ||
| 426 | # ); | ||
| 427 | } | ||
| 428 | |||
| 429 | my $result = $color_listbox->{_is_flow_listbox_color_available}; | ||
| 430 | &_set_flow_listbox_color_available($result); | ||
| 431 | |||
| 432 | # print("color_listbox, _flow_listbox_color2check, result =$result\n"); | ||
| 433 | return (); | ||
| 434 | |||
| 435 | } else { | ||
| 436 | |||
| 437 | # ans= NOT free | ||
| 438 | print("color_listbox, colored box is already occupied\n"); | ||
| 439 | |||
| 440 | #NADA | ||
| 441 | } | ||
| 442 | return (); | ||
| 443 | } | ||
| 444 | |||
| 445 | =head2 sub _get_message_box_ok_click | ||
| 446 | =cut | ||
| 447 | |||
| 448 | sub _get_message_box_ok_click { | ||
| 449 | |||
| 450 | my ($self) = @_; | ||
| 451 | my $message_box_ok_click = $color_listbox->{_message_box_ok_click}; | ||
| 452 | |||
| 453 | # print("color_listbox, _get_message_box_ok_click ,color_listbox->{_message_box_ok_click}\n"); | ||
| 454 | return ($message_box_ok_click); | ||
| 455 | |||
| 456 | } | ||
| 457 | |||
| 458 | =head2 sub _get_my_dialog_cancel_click | ||
| 459 | =cut | ||
| 460 | |||
| 461 | sub _get_my_dialog_cancel_click { | ||
| 462 | my ($self) = @_; | ||
| 463 | |||
| 464 | my $cancel_click = $color_listbox->{_my_dialog_cancel_click}; | ||
| 465 | return ($cancel_click); | ||
| 466 | } | ||
| 467 | |||
| 468 | =head2 sub _get_my_dialog_box_click | ||
| 469 | =cut | ||
| 470 | |||
| 471 | sub _get_my_dialog_box_click { | ||
| 472 | my ($self) = @_; | ||
| 473 | |||
| 474 | my $response = $color_listbox->{_my_dialog_box_click}; | ||
| 475 | |||
| 476 | # print("color_listbox,_get_my_dialog_box_click, color_listbox->{_my_dialog_box_click} = $color_listbox->{_my_dialog_box_click}\n"); | ||
| 477 | return ($response); | ||
| 478 | |||
| 479 | } | ||
| 480 | |||
| 481 | =head2 sub _get_my_dialog_ok_click | ||
| 482 | =cut | ||
| 483 | |||
| 484 | sub _get_my_dialog_ok_click { | ||
| 485 | my ($self) = @_; | ||
| 486 | |||
| 487 | my $response = $color_listbox->{_my_dialog_ok_click}; | ||
| 488 | |||
| 489 | # print("color_listbox,_get_my_dialog_ok_click, color_listbox->{_my_dialog_ok_click} = $color_listbox->{_my_dialog_ok_click}\n"); | ||
| 490 | return ($response); | ||
| 491 | |||
| 492 | } | ||
| 493 | |||
| 494 | =head2 sub _hide_dialog_box | ||
| 495 | =cut | ||
| 496 | |||
| 497 | sub _hide_dialog_box { | ||
| 498 | my ($self) = @_; | ||
| 499 | |||
| 500 | my $my_dialog_box = $color_listbox_href->{_my_dialog_box_w}; | ||
| 501 | $my_dialog_box->grabRelease; | ||
| 502 | $my_dialog_box->withdraw; | ||
| 503 | } | ||
| 504 | |||
| 505 | =head2 sub _set_flow_listbox_color_available | ||
| 506 | Mark the listbox color in use | ||
| 507 | =cut | ||
| 508 | |||
| 509 | sub _set_flow_listbox_color_available { | ||
| 510 | |||
| 511 | my ($ans) = @_; | ||
| 512 | |||
| 513 | if ( length $ans ) { | ||
| 514 | |||
| 515 | $color_listbox->{_is_flow_listbox_color_available} = $ans; | ||
| 516 | |||
| 517 | # print("color_listbox, _set_flow_listbox_color_available=\$color_listbox->{_is_flow_listbox_color_available}\n"); | ||
| 518 | |||
| 519 | } else { | ||
| 520 | print("color_listbox, _set_flow_listbox_color_available, unexpected result\n"); | ||
| 521 | } | ||
| 522 | |||
| 523 | return (); | ||
| 524 | } | ||
| 525 | |||
| 526 | =head2 sub _set_message_box_ok_click | ||
| 527 | =cut | ||
| 528 | |||
| 529 | sub _set_message_box_ok_click { | ||
| 530 | my ($self) = @_; | ||
| 531 | |||
| 532 | $color_listbox->{_message_box_ok_click} = $yes; | ||
| 533 | |||
| 534 | # print("color_listbox,_set_message_box_ok_click ,color_listbox->{_message_box_ok_click} = $yes \n"); | ||
| 535 | } | ||
| 536 | |||
| 537 | =head2 sub _set_my_dialog_box_click | ||
| 538 | =cut | ||
| 539 | |||
| 540 | sub _set_my_dialog_box_click { | ||
| 541 | my ($ans) = @_; | ||
| 542 | my $self = shift; | ||
| 543 | $color_listbox->{_my_dialog_box_click} = $ans; | ||
| 544 | $color_listbox->{_this_package}->set_my_dialog_box_click($ans); | ||
| 545 | |||
| 546 | # print("color_listbox,_set_my_dialog_box_click ,color_listbox->{_my_dialog_box_click} = $ans \n"); | ||
| 547 | } | ||
| 548 | |||
| 549 | =head2 sub _set_my_dialog_ok_click | ||
| 550 | =cut | ||
| 551 | |||
| 552 | sub _set_my_dialog_ok_click { | ||
| 553 | my ($ans) = @_; | ||
| 554 | |||
| 555 | $color_listbox->{_my_dialog_ok_click} = $ans; | ||
| 556 | ( $color_listbox->{_this_package} )->set_my_dialog_ok_click($ans); | ||
| 557 | |||
| 558 | # print("color_listbox,_set_my_dialog_ok_click ,color_listbox->{_my_dialog_ok_click} = $ans \n"); | ||
| 559 | } | ||
| 560 | |||
| 561 | =head2 sub _set_my_dialog_cancel_click | ||
| 562 | =cut | ||
| 563 | |||
| 564 | sub _set_my_dialog_cancel_click { | ||
| 565 | my ($ans) = @_; | ||
| 566 | |||
| 567 | $color_listbox->{_my_dialog_cancel_click} = $ans; | ||
| 568 | ( $color_listbox->{_this_package} )->set_my_dialog_cancel_click($ans); | ||
| 569 | |||
| 570 | # print("color_listbox,_set_message_box_cancel_click ,color_listbox->{_my_dialog_cancel_click} = $ans \n"); | ||
| 571 | } | ||
| 572 | |||
| 573 | =head2 sub _set_shared_wait1 | ||
| 574 | =cut | ||
| 575 | |||
| 576 | sub _set_shared_wait1 { | ||
| 577 | |||
| 578 | my ($self) = @_; | ||
| 579 | |||
| 580 | # my $ok_click = &_get_my_dialog_ok_click(); | ||
| 581 | |||
| 582 | &_set_my_dialog_ok_click('yes'); | ||
| 583 | &_set_my_dialog_box_click('yes'); | ||
| 584 | |||
| 585 | my $ok_click = &_get_my_dialog_ok_click(); | ||
| 586 | |||
| 587 | # print("ok,=$ok_click\n"); | ||
| 588 | |||
| 589 | my $my_dialog_box = $color_listbox_href->{_my_dialog_box_w}; | ||
| 590 | |||
| 591 | # my $ok_button = $color_listbox_href->{_my_dialog_ok_button}; | ||
| 592 | # print("color_list_set_shared_wait,ok_click=$ok_click \n"); | ||
| 593 | &_hide_dialog_box($my_dialog_box); | ||
| 594 | |||
| 595 | return (); | ||
| 596 | } | ||
| 597 | |||
| 598 | =head2 sub _set_shared_wait2 | ||
| 599 | =cut | ||
| 600 | |||
| 601 | sub _set_shared_wait2 { | ||
| 602 | |||
| 603 | my ($self) = @_; | ||
| 604 | |||
| 605 | &_set_my_dialog_cancel_click('yes'); | ||
| 606 | &_set_my_dialog_box_click('yes'); | ||
| 607 | |||
| 608 | my $cancel_click = &_get_my_dialog_cancel_click(); | ||
| 609 | my $my_dialog_box = $color_listbox_href->{_my_dialog_box_w}; | ||
| 610 | |||
| 611 | # print("color_listbox_set_shared_wait2,cancel_click=$cancel_click \n"); | ||
| 612 | &_hide_dialog_box($my_dialog_box); | ||
| 613 | |||
| 614 | return (); | ||
| 615 | } | ||
| 616 | |||
| 617 | =head2 sub set_flow_listbox_availability | ||
| 618 | Update which listboxes (colors) are possibly available | ||
| 619 | for re-occupancy | ||
| 620 | Also make sure that occupied listboxes are not empty | ||
| 621 | =cut | ||
| 622 | |||
| 623 | sub set_flow_listbox_availability { | ||
| 624 | |||
| 625 | my ($self) = @_; | ||
| 626 | |||
| 627 | my @listbox_colors = ( "grey", "pink", "green", "blue" ); | ||
| 628 | my $number_of_listboxes = scalar @listbox_colors; | ||
| 629 | my @number_of_programs; | ||
| 630 | my @listbox_color_w; | ||
| 631 | |||
| 632 | # all color listboxes are potentially available !! | ||
| 633 | my @listbox_availability = ( 1, 1, 1, 1 ); | ||
| 634 | $color_listbox->{flow_listbox_color_availability_aref} = \@listbox_availability; | ||
| 635 | |||
| 636 | my $color_listbox = $color_listbox->{_this_package}; | ||
| 637 | my @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 638 | my @occupied_listbox = @{ $color_listbox->get_flow_listbox_occupancy_aref() }; | ||
| 639 | $color_listbox->{flow_listbox_color_availability_aref} = \@listbox_availability; | ||
| 640 | |||
| 641 | $listbox_color_w[0] = $color_listbox_href->{_flow_listbox_grey_w}; | ||
| 642 | $listbox_color_w[1] = $color_listbox_href->{_flow_listbox_pink_w}; | ||
| 643 | $listbox_color_w[2] = $color_listbox_href->{_flow_listbox_green_w}; | ||
| 644 | $listbox_color_w[3] = $color_listbox_href->{_flow_listbox_blue_w}; | ||
| 645 | |||
| 646 | # print("color_listbox,listbox_color_w= @listbox_color_w\n"); # widgets | ||
| 647 | #print("color_listbox, number_of_listboxes = $number_of_listboxes\n"); # widgets | ||
| 648 | |||
| 649 | for ( my $i = 0; $i < $number_of_listboxes; $i++ ) { | ||
| 650 | |||
| 651 | $number_of_programs[$i] = ( $listbox_color_w[0] )->size(); | ||
| 652 | |||
| 653 | if ( $number_of_programs[$i] == 0 ) { | ||
| 654 | |||
| 655 | $occupied_listbox[$i] = $false; | ||
| 656 | $vacant_listbox[$i] = $true; | ||
| 657 | |||
| 658 | } elsif ( $number_of_programs[$i] > 0 ) { | ||
| 659 | |||
| 660 | $occupied_listbox[$i] = $true; | ||
| 661 | $vacant_listbox[$i] = $false; | ||
| 662 | |||
| 663 | } else { | ||
| 664 | print("color_listbox,listbox_color_w, unexpected result\n"); | ||
| 665 | } | ||
| 666 | |||
| 667 | } | ||
| 668 | |||
| 669 | print("color_listbox, _set_flow_listbox_availability, occupied = @occupied_listbox\n"); | ||
| 670 | print("color_listbox, _set_flow_listbox_availability, vacant = @vacant_listbox\n"); | ||
| 671 | |||
| 672 | return (); | ||
| 673 | |||
| 674 | } | ||
| 675 | |||
| 676 | #=head2 sub _update_flow_listbox_color_availability_aref | ||
| 677 | # | ||
| 678 | #Update which listboxes (colors) are possibly available | ||
| 679 | #for re-occupancy | ||
| 680 | #Also make sure that occupied listboxes are not empty | ||
| 681 | # | ||
| 682 | #=cut | ||
| 683 | # | ||
| 684 | #sub _update_flow_listbox_color_availability_aref { | ||
| 685 | # | ||
| 686 | # my ( | ||
| 687 | # $color_listbox, $new_current_flow_listbox_availability_aref, | ||
| 688 | # $new_prior_flow_listbox_availability_aref | ||
| 689 | # ) = @_; | ||
| 690 | # | ||
| 691 | # my @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 692 | # my @occupied_listbox= @{ $color_listbox->get_flow_listbox_occupancy_aref() }; | ||
| 693 | # | ||
| 694 | # # all color listboxes are potentially available !! | ||
| 695 | # my @array = [1,1,1,1]; | ||
| 696 | # $color_listbox->{flow_listbox_color_availability_aref} = \@array; | ||
| 697 | # | ||
| 698 | # print("color_listbox,_update_flow_listbox_color_availability_aref=$new_current_flow_listbox_availability_aref=@{$new_current_flow_listbox_availability_aref}\n"); | ||
| 699 | # | ||
| 700 | # my $length = scalar @vacant_listbox; | ||
| 701 | # | ||
| 702 | # print("1. color_listbox,_update_flow_listbox_color_availability_aref\n"); | ||
| 703 | # $gui_history->view(); | ||
| 704 | # | ||
| 705 | # if ( @vacant_listbox ) { | ||
| 706 | # | ||
| 707 | ## for ( my $i = 0; $i < $length; $i++ ) { | ||
| 708 | ## | ||
| 709 | ## $vacant_listbox[$i] = abs( @{$new_current_flow_listbox_availability_aref}[$i] - 1 ); | ||
| 710 | ## | ||
| 711 | ## } | ||
| 712 | # | ||
| 713 | ## _update_flow_listbox_vacancy_color($color_listbox); | ||
| 714 | # | ||
| 715 | # print("color_listbox,_update_flow_listbox_availabilityNvacancy_aref vacant_listbox=@vacant_listbox\n"); | ||
| 716 | # # print("color_listbox,_update_flow_listbox_availabilityNvacancy_aref vacant_listbox, new_current_flow_listbox_availability_aref =@{$new_current_flow_listbox_availability_aref}\n"); | ||
| 717 | # | ||
| 718 | # } else { | ||
| 719 | # print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref, missing vacant listbox,\n"); | ||
| 720 | # } | ||
| 721 | # | ||
| 722 | # return (); | ||
| 723 | # | ||
| 724 | #} | ||
| 725 | |||
| 726 | =head2 sub _update_flow_listbox_color | ||
| 727 | Mark the listbox color in use | ||
| 728 | =cut | ||
| 729 | |||
| 730 | sub _update_flow_listbox_color { | ||
| 731 | |||
| 732 | my ( $color_listbox, $new_current_flow_listbox_color, $new_prior_flow_listbox_color ) = @_; | ||
| 733 | |||
| 734 | if ( length $new_current_flow_listbox_color ) { | ||
| 735 | |||
| 736 | if ( $new_current_flow_listbox_color eq 'grey' | ||
| 737 | or $new_current_flow_listbox_color eq '' ) { | ||
| 738 | |||
| 739 | $color_listbox->{_is_flow_listbox_grey_w} = $true; | ||
| 740 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 741 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 742 | |||
| 743 | # print("1. color_listbox, _update_flow_listbox_color\n"); | ||
| 744 | |||
| 745 | } elsif ( $new_current_flow_listbox_color eq 'pink' ) { | ||
| 746 | |||
| 747 | $color_listbox->{_is_flow_listbox_pink_w} = $true; | ||
| 748 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 749 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 750 | |||
| 751 | # print("2. color_listbox, _update_flow_listbox_color\n"); | ||
| 752 | |||
| 753 | } elsif ( $new_current_flow_listbox_color eq 'green' ) { | ||
| 754 | |||
| 755 | # print("3. color_listbox, _update_flow_listbox_color\n"); | ||
| 756 | $color_listbox->{_is_flow_listbox_green_w} = $true; | ||
| 757 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 758 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 759 | |||
| 760 | } elsif ( $new_current_flow_listbox_color eq 'blue' ) { | ||
| 761 | |||
| 762 | # print("4. color_listbox, _update_flow_listbox_color\n"); | ||
| 763 | $color_listbox->{_is_flow_listbox_blue_w} = $true; | ||
| 764 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 765 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 766 | |||
| 767 | } else { | ||
| 768 | print("color_listbox,_set_flow_listbox, missing color \n"); | ||
| 769 | } | ||
| 770 | } | ||
| 771 | return (); | ||
| 772 | } | ||
| 773 | |||
| 774 | =head2 sub _update_flow_listbox_color_reservation | ||
| 775 | Reserve a potential listbox color for later use | ||
| 776 | =cut | ||
| 777 | |||
| 778 | sub _update_flow_listbox_color_reservation { | ||
| 779 | |||
| 780 | my ( $color_listbox, $new_current_flow_listbox_color_reservation, $new_prior_flow_listbox_color_reservation ) = @_; | ||
| 781 | |||
| 782 | if ( length $new_current_flow_listbox_color_reservation ) { | ||
| 783 | |||
| 784 | if ( $new_current_flow_listbox_color_reservation eq 'grey' | ||
| 785 | or $new_current_flow_listbox_color_reservation eq '' ) { | ||
| 786 | |||
| 787 | $color_listbox->{_is_flow_listbox_grey_w} = $true; | ||
| 788 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 789 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 790 | |||
| 791 | # print("1. color_listbox, _update_flow_listbox_color_reservation\n"); | ||
| 792 | |||
| 793 | } elsif ( $new_current_flow_listbox_color_reservation eq 'pink' ) { | ||
| 794 | |||
| 795 | $color_listbox->{_is_flow_listbox_pink_w} = $true; | ||
| 796 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 797 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 798 | |||
| 799 | # print("2. color_listbox, _update_flow_listbox_color_reservation\n"); | ||
| 800 | |||
| 801 | } elsif ( $new_current_flow_listbox_color_reservation eq 'green' ) { | ||
| 802 | |||
| 803 | # print("3. color_listbox, _update_flow_listbox_color_reservation\n"); | ||
| 804 | $color_listbox->{_is_flow_listbox_green_w} = $true; | ||
| 805 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 806 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 807 | |||
| 808 | } elsif ( $new_current_flow_listbox_color_reservation eq 'blue' ) { | ||
| 809 | |||
| 810 | # print("4. color_listbox, _update_flow_listbox_color_reservation\n"); | ||
| 811 | $color_listbox->{_is_flow_listbox_blue_w} = $true; | ||
| 812 | _update_flow_listbox_occupancyNvacancy_aref($color_listbox); | ||
| 813 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 814 | |||
| 815 | } else { | ||
| 816 | print("color_listbox,_set_flow_listbox, missing color \n"); | ||
| 817 | } | ||
| 818 | } | ||
| 819 | return (); | ||
| 820 | } | ||
| 821 | |||
| 822 | =head2 sub _update_flow_listbox_next_available_occupancyNvacancy_aref | ||
| 823 | Update which listboxes (colors) are in use (occupancy) | ||
| 824 | and which are not (vacancies) | ||
| 825 | =cut | ||
| 826 | |||
| 827 | sub _update_flow_listbox_next_available_occupancyNvacancy_aref { | ||
| 828 | |||
| 829 | my ( | ||
| 830 | $color_listbox, $new_current_flow_listbox_next_available_occupancy_aref, | ||
| 831 | $new_prior_flow_listbox_next_available_occupancy_aref | ||
| 832 | ) = @_; | ||
| 833 | |||
| 834 | my @vacant_listbox; | ||
| 835 | |||
| 836 | $color_listbox->{flow_listbox_occupancy_aref} = $new_current_flow_listbox_next_available_occupancy_aref; | ||
| 837 | @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 838 | my $length = scalar @vacant_listbox; | ||
| 839 | |||
| 840 | if (@vacant_listbox) { | ||
| 841 | |||
| 842 | for ( my $i = 0; $i < $length; $i++ ) { | ||
| 843 | |||
| 844 | $vacant_listbox[$i] = abs( @{$new_current_flow_listbox_next_available_occupancy_aref}[$i] - 1 ); | ||
| 845 | |||
| 846 | } | ||
| 847 | |||
| 848 | _update_flow_listbox_vacancy_color($color_listbox); | ||
| 849 | |||
| 850 | # print("color_listbox,_update_flow_listbox_next_available_occupancyNvacancy_aref vacant_listbox=@vacant_listbox\n"); | ||
| 851 | # print("color_listbox,_update_flow_listbox_next_available_occupancyNvacancy_aref vacant_listbox, new_current_flow_listbox_next_available_occupancy_aref =@{$new_current_flow_listbox_next_available_occupancy_aref}\n"); | ||
| 852 | |||
| 853 | } else { | ||
| 854 | print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref, missing vacant listbox,\n"); | ||
| 855 | } | ||
| 856 | |||
| 857 | return (); | ||
| 858 | |||
| 859 | } | ||
| 860 | |||
| 861 | =head2 sub _update_flow_listbox_occupancyNvacancy_aref | ||
| 862 | =cut | ||
| 863 | |||
| 864 | sub _update_flow_listbox_occupancyNvacancy_aref { | ||
| 865 | |||
| 866 | my ($color_listbox) = @_; | ||
| 867 | |||
| 868 | # print("1. color_listbox,_update_flow_listbox_occupancyNvacancy_aref\n"); | ||
| 869 | my @occupied_listbox = @{ $color_listbox->get_flow_listbox_occupancy_aref() }; | ||
| 870 | my @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 871 | |||
| 872 | if (@occupied_listbox) { | ||
| 873 | |||
| 874 | if ( $color_listbox->get_flow_listbox_color() eq 'grey' | ||
| 875 | or $color_listbox->get_flow_listbox_color() eq '' ) { | ||
| 876 | |||
| 877 | $occupied_listbox[0] = $true; | ||
| 878 | $vacant_listbox[0] = $false; | ||
| 879 | |||
| 880 | # print("1. color_listbox,_update_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 881 | |||
| 882 | } elsif ( $color_listbox->get_flow_listbox_color() eq 'pink' ) { | ||
| 883 | |||
| 884 | $occupied_listbox[1] = $true; | ||
| 885 | $vacant_listbox[1] = $false; | ||
| 886 | |||
| 887 | # print("2. color_listbox,_update_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 888 | |||
| 889 | } elsif ( $color_listbox->get_flow_listbox_color() eq 'green' ) { | ||
| 890 | |||
| 891 | # print("3. color_listbox,_update_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 892 | $occupied_listbox[2] = $true; | ||
| 893 | $vacant_listbox[2] = $false; | ||
| 894 | |||
| 895 | } elsif ( $color_listbox->get_flow_listbox_color() eq 'blue' ) { | ||
| 896 | |||
| 897 | # print("L_SU,_set_flow_listbox, color:$color\n"); | ||
| 898 | $occupied_listbox[3] = $true; | ||
| 899 | $vacant_listbox[3] = $false; | ||
| 900 | |||
| 901 | } elsif ( $color_listbox->get_flow_listbox_color() eq 'neutral' ) { | ||
| 902 | |||
| 903 | # CASE perl flow selection when none of the listboxes are occupied | ||
| 904 | # default to grey listbox | ||
| 905 | $occupied_listbox[0] = $true; | ||
| 906 | $vacant_listbox[0] = $false; | ||
| 907 | |||
| 908 | } else { | ||
| 909 | print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref,:bad flow color \n"); | ||
| 910 | } | ||
| 911 | |||
| 912 | $color_listbox->{flow_listbox_occupancy_aref} = \@occupied_listbox; | ||
| 913 | $color_listbox->{flow_listbox_vacancy_aref} = \@vacant_listbox; | ||
| 914 | |||
| 915 | # my @ans = @{ $color_listbox->get_flow_listbox_occupancy_aref }; | ||
| 916 | # print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref,color_listbox->flow_listbox_occupancy_aref=...@ans...\n"); | ||
| 917 | # @ans = @{ $color_listbox->get_flow_listbox_vacancy_aref }; | ||
| 918 | # print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref,color_listbox->flow_listbox_vacancy_aref=...@ans...\n"); | ||
| 919 | |||
| 920 | } else { | ||
| 921 | print("color_listbox,_update_flow_listbox_occupancyNvacancy_aref, missing flow color, NADA\n"); | ||
| 922 | } | ||
| 923 | |||
| 924 | return (); | ||
| 925 | |||
| 926 | } | ||
| 927 | |||
| 928 | =head2 sub _update_flow_listbox_vacancy_color | ||
| 929 | Mark the next vacant color | ||
| 930 | =cut | ||
| 931 | |||
| 932 | sub _update_flow_listbox_vacancy_color { | ||
| 933 | |||
| 934 | my ($color_listbox) = @_; | ||
| 935 | my $color; | ||
| 936 | |||
| 937 | if ($color_listbox) { | ||
| 938 | |||
| 939 | my @occupied_listbox = @{ $color_listbox->{flow_listbox_occupancy_aref} }; | ||
| 940 | my @vacant_listbox = @{ $color_listbox->{flow_listbox_vacancy_aref} }; | ||
| 941 | |||
| 942 | if ( $occupied_listbox[0] == $false ) { | ||
| 943 | |||
| 944 | $color = 'grey'; | ||
| 945 | |||
| 946 | # print("color_listbox, _update_flow_listbox_vacancy_color, color=$color\n"); | ||
| 947 | |||
| 948 | } elsif ( $occupied_listbox[1] == $false ) { | ||
| 949 | |||
| 950 | $color = 'pink'; | ||
| 951 | |||
| 952 | # print("color_listbox, _update_flow_listbox_vacancy_color, color=$color\n"); | ||
| 953 | |||
| 954 | } elsif ( $occupied_listbox[2] == $false ) { | ||
| 955 | |||
| 956 | $color = 'green'; | ||
| 957 | |||
| 958 | # print("color_listbox, _update_flow_listbox_vacancy_color, color=$color\n"); | ||
| 959 | |||
| 960 | } elsif ( $occupied_listbox[3] == $false ) { | ||
| 961 | |||
| 962 | $color = 'blue'; | ||
| 963 | |||
| 964 | # print("color_listbox, _update_flow_listbox_vacancy_color, color=$color\n"); | ||
| 965 | |||
| 966 | } else { | ||
| 967 | |||
| 968 | # print("color_listbox, _update_flow_listbox_vacancy_color, All boxes are empty\n"); | ||
| 969 | $color = 'grey'; | ||
| 970 | |||
| 971 | # print("color_listbox, _update_flow_listbox_vacancy_color,default listbox opened = $color \n"); | ||
| 972 | } | ||
| 973 | |||
| 974 | } else { | ||
| 975 | |||
| 976 | # print("color_listbox, _update_flow_listbox_vacancy_color, unexpected error\n"); | ||
| 977 | $color = 'grey'; | ||
| 978 | |||
| 979 | # print("color_listbox, _update_flow_listbox_vacancy_color, color=$color\n"); | ||
| 980 | } | ||
| 981 | |||
| 982 | $color_listbox->{flow_listbox_vacancy_color} = $color; | ||
| 983 | |||
| 984 | # print("color_listbox, _update_flow_listbox_vacancy_color , next vacant color = $color \n"); | ||
| 985 | |||
| 986 | return (); | ||
| 987 | } | ||
| 988 | |||
| 989 | =head2 sub _update_flow_listbox_vacancy_aref | ||
| 990 | Mark the listbox color in use | ||
| 991 | =cut | ||
| 992 | |||
| 993 | sub _update_flow_listbox_vacancy_aref { | ||
| 994 | |||
| 995 | my ( $color_listbox, $new_current_flow_listbox_vacancy_aref, $new_prior_flow_listbox_vacancy_aref ) = @_; | ||
| 996 | |||
| 997 | # print("trigger on vacancy\n"); | ||
| 998 | |||
| 999 | if ( length $new_current_flow_listbox_vacancy_aref ) { | ||
| 1000 | |||
| 1001 | my $occupied_listbox_aref = $color_listbox->get_flow_listbox_occupancy_aref(); | ||
| 1002 | my $vacant_listbox_aref = $color_listbox->get_flow_listbox_vacancy_aref(); | ||
| 1003 | |||
| 1004 | my @occupied_listbox = @{$occupied_listbox_aref}; | ||
| 1005 | my @vacant_listbox = @{$vacant_listbox_aref}; | ||
| 1006 | |||
| 1007 | print("1. _update_flow_listbox_vacancy_aref , occupied_listbox=@occupied_listbox\n"); | ||
| 1008 | print("2. _update_flow_listbox_vacancy_aref , vacant_listbox= @vacant_listbox \n"); | ||
| 1009 | |||
| 1010 | if ( $new_current_flow_listbox_vacancy_aref eq 'grey' | ||
| 1011 | or $new_current_flow_listbox_vacancy_aref eq '' ) { | ||
| 1012 | |||
| 1013 | $occupied_listbox[0] = $true; | ||
| 1014 | $vacant_listbox[0] = $false; | ||
| 1015 | |||
| 1016 | # print("1. L_SU,_set_flow_listbox, color:$color \n"); | ||
| 1017 | |||
| 1018 | } elsif ( $new_current_flow_listbox_vacancy_aref eq 'pink' ) { | ||
| 1019 | |||
| 1020 | $occupied_listbox[1] = $true; | ||
| 1021 | $vacant_listbox[1] = $false; | ||
| 1022 | |||
| 1023 | # print("L_SU,_set_flow_listbox, color:$color\n"); | ||
| 1024 | |||
| 1025 | } elsif ( $new_current_flow_listbox_vacancy_aref eq 'green' ) { | ||
| 1026 | |||
| 1027 | # print("L_SU,_set_flow_listbox, color:$color\n"); | ||
| 1028 | $occupied_listbox[2] = $true; | ||
| 1029 | $vacant_listbox[2] = $false; | ||
| 1030 | |||
| 1031 | } elsif ( $new_current_flow_listbox_vacancy_aref eq 'blue' ) { | ||
| 1032 | |||
| 1033 | # print("L_SU,_set_flow_listbox, color:$color\n"); | ||
| 1034 | $occupied_listbox[3] = $true; | ||
| 1035 | $vacant_listbox[3] = $false; | ||
| 1036 | |||
| 1037 | # CASE perl flow selection when none of the listboxes are occupied | ||
| 1038 | # default to gray listbox | ||
| 1039 | } elsif ( $new_current_flow_listbox_vacancy_aref eq 'neutral' ) { | ||
| 1040 | |||
| 1041 | $occupied_listbox[0] = $true; | ||
| 1042 | |||
| 1043 | } else { | ||
| 1044 | print("color_listbox,_update_flow_listbox_vacancy_aref ,:bad flow color \n"); | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | $color_listbox->set_flow_listbox_occupancy_aref( \@occupied_listbox ); | ||
| 1048 | my @ans = @{ $color_listbox->get_flow_listbox_occupancy_aref }; | ||
| 1049 | print("3.color_listbox,_update_flow_listbox_vacancy_aref , color_listbox->flow_listbox_occupied @ans \n"); | ||
| 1050 | |||
| 1051 | $color_listbox->set_flow_listbox_vacancy_aref( \@vacant_listbox ); | ||
| 1052 | my @ans2 = @{ $color_listbox->get_flow_listbox_vacancy_aref }; | ||
| 1053 | print("4. .color_listbox,_update_flow_listbox_vacancy_aref ,color_listbox->flow_listbox_vacancy= @ans2 \n"); | ||
| 1054 | |||
| 1055 | } else { | ||
| 1056 | print("color_listbox,_update_flow_listbox_vacancy_aref , missing flow color, NADA\n"); | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | return (); | ||
| 1060 | |||
| 1061 | } | ||
| 1062 | |||
| 1063 | =head2 sub _update_next_available_flow_listbox_color | ||
| 1064 | Mark the next_available listbox color to use | ||
| 1065 | Mark next available color listbox vacant | ||
| 1066 | Give preference to the next_available listbox | ||
| 1067 | =cut | ||
| 1068 | |||
| 1069 | sub _update_next_available_flow_listbox_color { | ||
| 1070 | |||
| 1071 | my ( $color_listbox, $new_current_next_available_flow_listbox_color, $new_prior_next_available_flow_listbox_color ) | ||
| 1072 | = @_; | ||
| 1073 | |||
| 1074 | # print( "color_listbox,_update_next_available_flow_listbox_color,new_current_next_available_flow_listbox_color=$new_current_next_available_flow_listbox_color, new_prior_next_available_flow_listbox_color=$new_prior_next_available_flow_listbox_color\n" ); | ||
| 1075 | |||
| 1076 | my $color; | ||
| 1077 | |||
| 1078 | if ( $new_current_next_available_flow_listbox_color eq 'grey' ) { | ||
| 1079 | |||
| 1080 | $color = 'grey'; | ||
| 1081 | $color_listbox->{next_available_flow_listbox_color} = $color; | ||
| 1082 | |||
| 1083 | # print("1. color_listbox,_update_next_available_flow_listbox_color, color:$color \n"); | ||
| 1084 | |||
| 1085 | } elsif ( $new_current_next_available_flow_listbox_color eq 'pink' ) { | ||
| 1086 | |||
| 1087 | $color = 'pink'; | ||
| 1088 | $color_listbox->{next_available_flow_listbox_color} = $color; | ||
| 1089 | |||
| 1090 | # print("2. color_listbox,_update_next_available_flow_listbox_color, color:$color\n"); | ||
| 1091 | |||
| 1092 | } elsif ( $new_current_next_available_flow_listbox_color eq 'green' ) { | ||
| 1093 | |||
| 1094 | # print("3. color_listbox,_update_next_available_flow_listbox_color, color: green\n"); | ||
| 1095 | |||
| 1096 | $color = 'green'; | ||
| 1097 | $color_listbox->{next_available_flow_listbox_color} = $color; | ||
| 1098 | |||
| 1099 | } elsif ( $new_current_next_available_flow_listbox_color eq 'blue' ) { | ||
| 1100 | |||
| 1101 | # print("4. color_listbox,_update_next_available_flow_listbox_color, color:blue\n"); | ||
| 1102 | $color = 'blue'; | ||
| 1103 | $color_listbox->{next_available_flow_listbox_color} = $color; | ||
| 1104 | |||
| 1105 | } else { | ||
| 1106 | print("color_listbox,_update_next_available_flow_listbox_color, missing color \n"); | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | return (); | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | =head2 sub _update_my_dialog_ok_click | ||
| 1113 | Get the user's answer to | ||
| 1114 | my dialog is yes or no | ||
| 1115 | =cut | ||
| 1116 | |||
| 1117 | sub _update_my_dialog_ok_click { | ||
| 1118 | |||
| 1119 | my ( $self, $new_current_my_dialog_ok_click, $new_prior_my_dialog_ok_click ) = @_; | ||
| 1120 | |||
| 1121 | # print("color_listbox, _update_my_dialog_ok_click,new_prior_my_dialog_ok_click=$new_prior_my_dialog_ok_click\n"); | ||
| 1122 | # print("color_listbox, _update_my_dialog_ok_click,new_current_my_dialog_ok_click=$new_current_my_dialog_ok_click\n"); | ||
| 1123 | |||
| 1124 | if ( length $new_current_my_dialog_ok_click ) { | ||
| 1125 | $color_listbox->{_my_dialog_ok_click} = $my_dialog_ok_click_start; | ||
| 1126 | |||
| 1127 | } else { | ||
| 1128 | print("color_listbox,update_my_dialog_ok_click, unexpected values \n"); | ||
| 1129 | } | ||
| 1130 | return (); | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | =head2 sub _update_my_dialog_cancel_click | ||
| 1134 | Get the user's answer to | ||
| 1135 | my dialog is yes or no | ||
| 1136 | =cut | ||
| 1137 | |||
| 1138 | sub _update_my_dialog_cancel_click { | ||
| 1139 | |||
| 1140 | my ( $self, $new_current_my_dialog_cancel_click, $new_prior_my_dialog_cancel_click ) = @_; | ||
| 1141 | |||
| 1142 | # print("color_listbox, _update_my_dialog_cancel_click,new_prior_my_dialog_cancel_click=$new_prior_my_dialog_cancel_click\n" | ||
| 1143 | # ); | ||
| 1144 | # print("color_listbox, _update_my_dialog_cancel_click,new_current_my_dialog_cancel_click=$new_current_my_dialog_cancel_click\n" | ||
| 1145 | # ); | ||
| 1146 | |||
| 1147 | # print("color_listbox, update_my_dialog_cancel_click\n"); | ||
| 1148 | |||
| 1149 | if ( length( $color_listbox->{_my_dialog_cancel_click} ) ) { | ||
| 1150 | |||
| 1151 | $color_listbox->{_my_dialog_cancel_click} = $my_dialog_cancel_click_start; | ||
| 1152 | |||
| 1153 | } else { | ||
| 1154 | print("color_listbox,get_my_dialog_cancel, unexpected values \n"); | ||
| 1155 | } | ||
| 1156 | return (); | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | =head2 sub _update2prior_flow_listbox_vacancy_color | ||
| 1160 | Unmark the past vacant color | ||
| 1161 | =cut | ||
| 1162 | |||
| 1163 | sub _update2prior_flow_listbox_vacancy_color { | ||
| 1164 | |||
| 1165 | my ( $color_listbox, $prior_color ) = @_; | ||
| 1166 | |||
| 1167 | if ($color_listbox) { | ||
| 1168 | |||
| 1169 | my @occupied_listbox = @{ $color_listbox->{flow_listbox_occupancy_aref} }; | ||
| 1170 | my @vacant_listbox = @{ $color_listbox->{flow_listbox_vacancy_aref} }; | ||
| 1171 | |||
| 1172 | if ( $prior_color eq 'blue' ) { | ||
| 1173 | |||
| 1174 | $vacant_listbox[3] = $true; | ||
| 1175 | |||
| 1176 | } elsif ( $prior_color eq 'green' ) { | ||
| 1177 | |||
| 1178 | $vacant_listbox[2] = $true; | ||
| 1179 | |||
| 1180 | } elsif ( $prior_color eq 'pink' ) { | ||
| 1181 | |||
| 1182 | $vacant_listbox[1] = $true; | ||
| 1183 | # print("color_listbox, _update2prior_flow_listbox_vacancy_color, after update $prior_color is available\n"); | ||
| 1184 | |||
| 1185 | } elsif ( $prior_color eq 'grey' ) { | ||
| 1186 | |||
| 1187 | $vacant_listbox[0] = $true; | ||
| 1188 | |||
| 1189 | } else { | ||
| 1190 | print("color_listbox, _update2prior_flow_listbox_vacancy_color, All boxes are empty\n"); | ||
| 1191 | $vacant_listbox[0] = $true; | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | } else { | ||
| 1195 | print("color_listbox, _update2prior_flow_listbox_vacancy_color, unexpected error\n"); | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | $color_listbox->{flow_listbox_vacancy_color} = $prior_color; | ||
| 1199 | # print("color_listbox, _update2prior_flow_listbox_vacancy_color, after update $prior_color is available\n"); | ||
| 1200 | |||
| 1201 | return (); | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | =head2 sub _update2prior_flow_listbox_occupancyNvacancy_aref | ||
| 1205 | =cut | ||
| 1206 | |||
| 1207 | sub _update2prior_flow_listbox_occupancyNvacancy_aref { | ||
| 1208 | |||
| 1209 | my ( $color_listbox, $prior_color ) = @_; | ||
| 1210 | |||
| 1211 | # print("1. color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref\n"); | ||
| 1212 | my @occupied_listbox = @{ $color_listbox->get_flow_listbox_occupancy_aref() }; | ||
| 1213 | my @vacant_listbox = @{ $color_listbox->get_flow_listbox_vacancy_aref() }; | ||
| 1214 | |||
| 1215 | if (@occupied_listbox) { | ||
| 1216 | |||
| 1217 | if ( $prior_color eq 'grey' | ||
| 1218 | or $prior_color eq '' ) { | ||
| 1219 | |||
| 1220 | $occupied_listbox[0] = $false; | ||
| 1221 | $vacant_listbox[0] = $true; | ||
| 1222 | |||
| 1223 | # print("1. color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 1224 | |||
| 1225 | } elsif ( $prior_color eq 'pink' ) { | ||
| 1226 | |||
| 1227 | $occupied_listbox[1] = $false; | ||
| 1228 | $vacant_listbox[1] = $true; | ||
| 1229 | |||
| 1230 | # print("2. color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 1231 | |||
| 1232 | } elsif ( $prior_color eq 'green' ) { | ||
| 1233 | |||
| 1234 | # print("3. color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref color:\n"); | ||
| 1235 | $occupied_listbox[2] = $false; | ||
| 1236 | $vacant_listbox[2] = $true; | ||
| 1237 | |||
| 1238 | } elsif ( $prior_color eq 'blue' ) { | ||
| 1239 | |||
| 1240 | # print("L_SU,_set_flow_listbox, color:$color\n"); | ||
| 1241 | $occupied_listbox[3] = $false; | ||
| 1242 | $vacant_listbox[3] = $true; | ||
| 1243 | |||
| 1244 | } elsif ( $prior_color eq 'neutral' ) { | ||
| 1245 | |||
| 1246 | # CASE perl flow selection when none of the listboxes are occupied | ||
| 1247 | # default to grey listbox | ||
| 1248 | $occupied_listbox[0] = $false; | ||
| 1249 | $vacant_listbox[0] = $true; | ||
| 1250 | |||
| 1251 | } else { | ||
| 1252 | print("color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref,:bad flow color \n"); | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | $color_listbox->{flow_listbox_occupancy_aref} = \@occupied_listbox; | ||
| 1256 | $color_listbox->{flow_listbox_vacancy_aref} = \@vacant_listbox; | ||
| 1257 | |||
| 1258 | my @ans = @{ $color_listbox->get_flow_listbox_occupancy_aref }; | ||
| 1259 | # print( | ||
| 1260 | # "color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref,color_listbox->flow_listbox_occupancy_aref=...@ans...\n" | ||
| 1261 | # ); | ||
| 1262 | @ans = @{ $color_listbox->get_flow_listbox_vacancy_aref }; | ||
| 1263 | # print( | ||
| 1264 | # "color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref,color_listbox->flow_listbox_vacancy_aref=...@ans...\n" | ||
| 1265 | # ); | ||
| 1266 | |||
| 1267 | } else { | ||
| 1268 | print("color_listbox,_update2prior_flow_listbox_occupancyNvacancy_aref, missing flow color, NADA\n"); | ||
| 1269 | } | ||
| 1270 | |||
| 1271 | return (); | ||
| 1272 | |||
| 1273 | } | ||
| 1274 | |||
| 1275 | =head2 sub _update_prior_available_flow_listbox_color | ||
| 1276 | Return to the previously available listbox color | ||
| 1277 | Mark previously available vacant color listbox | ||
| 1278 | Give preference to the previously available listbox | ||
| 1279 | =cut | ||
| 1280 | |||
| 1281 | sub _update_prior_available_flow_listbox_color { | ||
| 1282 | |||
| 1283 | my ( | ||
| 1284 | $color_listbox, $new_current_prior_available_flow_listbox_color, | ||
| 1285 | $new_prior_prior_available_flow_listbox_color | ||
| 1286 | ) = @_; | ||
| 1287 | |||
| 1288 | # print( "color_listbox,_update_prior_available_flow_listbox_color,new_current_prior_available_flow_listbox_color=$new_current_prior_available_flow_listbox_color, new_prior_prior_available_flow_listbox_color=$new_prior_prior_available_flow_listbox_color\n" ); | ||
| 1289 | |||
| 1290 | my $color; | ||
| 1291 | |||
| 1292 | if ( $new_prior_prior_available_flow_listbox_color eq 'grey' ) { | ||
| 1293 | |||
| 1294 | $color = 'grey'; | ||
| 1295 | $color_listbox->{_is_flow_listbox_grey_w} = $false; | ||
| 1296 | _update2prior_flow_listbox_occupancyNvacancy_aref( $color_listbox, $color ); | ||
| 1297 | _update2prior_flow_listbox_vacancy_color( $color_listbox, $color ); | ||
| 1298 | |||
| 1299 | # print("1. color_listbox,_update_prior_available_flow_listbox_color, color:$color \n"); | ||
| 1300 | |||
| 1301 | } elsif ( $new_prior_prior_available_flow_listbox_color eq 'pink' ) { | ||
| 1302 | |||
| 1303 | $color = 'pink'; | ||
| 1304 | # $color_listbox->{_is_flow_listbox_pink_w} = $false; | ||
| 1305 | $color_listbox->{prior_available_flow_listbox_color} = $color; | ||
| 1306 | |||
| 1307 | # print("2. color_listbox,_update_prior_available_flow_listbox_color, color:$color\n"); | ||
| 1308 | |||
| 1309 | } elsif ( $new_prior_prior_available_flow_listbox_color eq 'green' ) { | ||
| 1310 | |||
| 1311 | # print("3. color_listbox,_update_prior_available_flow_listbox_color, color: green\n"); | ||
| 1312 | |||
| 1313 | $color = 'green'; | ||
| 1314 | # $color_listbox->{_is_flow_listbox_green_w} = $false; | ||
| 1315 | $color_listbox->{prior_available_flow_listbox_color} = $color; | ||
| 1316 | |||
| 1317 | } elsif ( $new_prior_prior_available_flow_listbox_color eq 'blue' ) { | ||
| 1318 | |||
| 1319 | # print("4. color_listbox,_update_prior_available_flow_listbox_color, color:blue\n"); | ||
| 1320 | # $color_listbox->{_is_flow_listbox_blue_w} = $false; | ||
| 1321 | $color = 'blue'; | ||
| 1322 | $color_listbox->{prior_available_flow_listbox_color} = $color; | ||
| 1323 | |||
| 1324 | } else { | ||
| 1325 | print("color_listbox,_update_prior_available_flow_listbox_color, missing color \n"); | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | return (); | ||
| 1329 | } | ||
| 1330 | |||
| 1331 | =head2 sub initialize_my_dialogs | ||
| 1332 | Create widgets that show messages | ||
| 1333 | Show warnings or errors in a message box | ||
| 1334 | Message box is defined in main where it is | ||
| 1335 | also made invisible (withdraw) | ||
| 1336 | Here we turn on the message box (deiconify, raise) | ||
| 1337 | The message does not release the program | ||
| 1338 | until OK or CANCEL is clicked and wait variable changes from yes | ||
| 1339 | to no. | ||
| 1340 | Widgets belong to the MainWindow that is created | ||
| 1341 | first in L_SUVx.x.pl | ||
| 1342 | =cut | ||
| 1343 | |||
| 1344 | sub initialize_my_dialogs { | ||
| 1345 | |||
| 1346 | my ( $self, $ok_button, $label, $cancel_button, $top_level ) = @_; | ||
| 1347 | |||
| 1348 | if ( length $ok_button | ||
| 1349 | && length $label | ||
| 1350 | && $cancel_button | ||
| 1351 | && $top_level ) { | ||
| 1352 | |||
| 1353 | $ok_button->configure( | ||
| 1354 | -command => [ \&_set_shared_wait1 ], | ||
| 1355 | ); | ||
| 1356 | |||
| 1357 | $cancel_button->configure( | ||
| 1358 | -command => [ \&_set_shared_wait2 ], | ||
| 1359 | ); | ||
| 1360 | |||
| 1361 | } else { | ||
| 1362 | print("color_listbox, initialize_my_dialogs, missing widgets \n"); | ||
| 1363 | } | ||
| 1364 | return (); | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | =head2 sub initialize_messages | ||
| 1368 | Create widgets that show messages | ||
| 1369 | Show warnings or errors in a message box | ||
| 1370 | Message box is defined in main where it is | ||
| 1371 | also made invisible (withdraw) | ||
| 1372 | Here we turn on the message box (deiconify, raise) | ||
| 1373 | The message does not release the program | ||
| 1374 | until OK is clicked and wait variable changes from no | ||
| 1375 | to yes. | ||
| 1376 | Widgets belong to the MainWindow that is created | ||
| 1377 | first in L_SUVx.x.pl | ||
| 1378 | =cut | ||
| 1379 | |||
| 1380 | sub initialize_messages { | ||
| 1381 | |||
| 1382 | my ($self) = @_; | ||
| 1383 | |||
| 1384 | my $wait = 'no'; | ||
| 1385 | |||
| 1386 | $color_listbox_href->{_message_ok_button}->configure( | ||
| 1387 | -command => sub { | ||
| 1388 | print("color_listbox,initialize_messages1. wait = $wait\n"); | ||
| 1389 | &_set_message_box_ok_click(); | ||
| 1390 | $wait = &_get_message_box_ok_click(); | ||
| 1391 | print("color_listbox, initialize_messages, 3. wait = $wait\n"); | ||
| 1392 | print("color_listbox,i nitialize_messages, 4. wait = $wait\n"); | ||
| 1393 | $color_listbox_href->{_message_box_w}->grabRelease; | ||
| 1394 | $color_listbox_href->{_message_box_w}->withdraw; | ||
| 1395 | }, | ||
| 1396 | ); | ||
| 1397 | |||
| 1398 | # stop code until user EITHER clicks ok () or cancel and | ||
| 1399 | # variable changes | ||
| 1400 | # Otherwise, upper class program races ahead | ||
| 1401 | # initializes fine, but is first implemented next time | ||
| 1402 | ( $color_listbox_href->{_message_box_w} )->waitVariable( \$wait ); | ||
| 1403 | |||
| 1404 | return (); | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | =head2 sub is_flow_listbox_color_available | ||
| 1408 | Check wether a listbox of a certain color | ||
| 1409 | is already occupied | ||
| 1410 | =cut | ||
| 1411 | |||
| 1412 | sub is_flow_listbox_color_available { | ||
| 1413 | my ($self) = @_; | ||
| 1414 | |||
| 1415 | # print("color_listbox, is_flow_listbox_color_available, color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n" | ||
| 1416 | # ); | ||
| 1417 | |||
| 1418 | if ( length $color_listbox->{_is_flow_listbox_color_available} ) { | ||
| 1419 | |||
| 1420 | my $response = $color_listbox->{_is_flow_listbox_color_available}; | ||
| 1421 | return ($response); | ||
| 1422 | |||
| 1423 | } else { | ||
| 1424 | |||
| 1425 | # print( | ||
| 1426 | # "color_listbox, is_flow_listbox_color_available, color_listbox->{_is_flow_listbox_color_available}=$color_listbox->{_is_flow_listbox_color_available}\n" | ||
| 1427 | # ); | ||
| 1428 | print("color_listbox, is_flow_listbox_color_available, unexpected result\n"); | ||
| 1429 | return (); | ||
| 1430 | } | ||
| 1431 | } | ||
| 1432 | |||
| 1433 | sub is_vacant_listbox { | ||
| 1434 | |||
| 1435 | my ( $self, $color ) = @_; | ||
| 1436 | |||
| 1437 | # print("1 color_listbox, is_vacant_listbox, currently, color to test for occupation= $color \n"); | ||
| 1438 | |||
| 1439 | my @vacant_listbox = @{ $self->get_flow_listbox_vacancy_aref() }; | ||
| 1440 | |||
| 1441 | if ( scalar(@vacant_listbox) ) { | ||
| 1442 | if ( $vacant_listbox[0] == $false | ||
| 1443 | && $color eq 'grey' ) { | ||
| 1444 | |||
| 1445 | # print("1 color_listbox, is_vacant_listbox, grey is already occupied \n"); | ||
| 1446 | return ($false); | ||
| 1447 | |||
| 1448 | } elsif ( $vacant_listbox[1] == $false | ||
| 1449 | && $color eq 'pink' ) { | ||
| 1450 | |||
| 1451 | # print("1 color_listbox, is_vacant_listbox, pink is already occupied \n"); | ||
| 1452 | return ($false); | ||
| 1453 | |||
| 1454 | } elsif ( $vacant_listbox[2] == $false | ||
| 1455 | && $color eq 'green' ) { | ||
| 1456 | |||
| 1457 | # print("1 color_listbox, is_vacant_listbox, green is already occupied \n"); | ||
| 1458 | return ($false); | ||
| 1459 | |||
| 1460 | } elsif ( $vacant_listbox[3] == $false | ||
| 1461 | && $color eq 'blue' ) { | ||
| 1462 | |||
| 1463 | # print("1 color_listbox, is_vacant_listbox, blue is already occupied \n"); | ||
| 1464 | return ($false); | ||
| 1465 | |||
| 1466 | } else { | ||
| 1467 | |||
| 1468 | # print("color_listbox, _is_vacant_listbox, $color listbox seems vacant\n"); | ||
| 1469 | return ($true); | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | } else { | ||
| 1473 | print("color_listbox, is_vacant_listbox, difficult to say\n"); | ||
| 1474 | return (); | ||
| 1475 | } | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | =head2 sub messages | ||
| 1479 | Show warnings or errors in a message box | ||
| 1480 | Message box is defined in main where it is | ||
| 1481 | also made invisible (withdraw) | ||
| 1482 | Here we turn on the message box (deiconify, raise) | ||
| 1483 | The message does not release the program | ||
| 1484 | until OK is clicked and wait variable changes from no | ||
| 1485 | to yes. | ||
| 1486 | =cut | ||
| 1487 | |||
| 1488 | sub messages { | ||
| 1489 | |||
| 1490 | my ( $self, $run_name, $number ) = @_; | ||
| 1491 | |||
| 1492 | my $message = $message_director->color_listbox($number); | ||
| 1493 | |||
| 1494 | my $message_box = $color_listbox_href->{_message_box_w}; | ||
| 1495 | my $message_label = $color_listbox_href->{_message_label_w}; | ||
| 1496 | |||
| 1497 | $message_box->title($run_name); | ||
| 1498 | |||
| 1499 | $message_label->configure( | ||
| 1500 | -textvariable => \$message, | ||
| 1501 | ); | ||
| 1502 | |||
| 1503 | $message_box->deiconify(); | ||
| 1504 | $message_box->raise(); | ||
| 1505 | |||
| 1506 | return (); | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | =head2 sub my_dialogs | ||
| 1510 | Show warnings or errors in a message box | ||
| 1511 | Message box is defined in main where it is | ||
| 1512 | also made invisible (withdraw) | ||
| 1513 | Here we turn on the message box (deiconify, raise) | ||
| 1514 | The message does not release the program | ||
| 1515 | until OK or CANCEL is clicked and wait variable changes from yes | ||
| 1516 | to no. | ||
| 1517 | =cut | ||
| 1518 | |||
| 1519 | sub my_dialogs { | ||
| 1520 | |||
| 1521 | my ( $self, $run_name, $number ) = @_; | ||
| 1522 | |||
| 1523 | my $message = $message_director->color_listbox($number); | ||
| 1524 | |||
| 1525 | my $my_dialog_box = $color_listbox_href->{_my_dialog_box_w}; | ||
| 1526 | my $ok_button = $color_listbox_href->{_my_dialog_ok_button}; | ||
| 1527 | my $my_dialog_label = $color_listbox_href->{_my_dialog_label_w}; | ||
| 1528 | |||
| 1529 | # print("color_listbox,my_dialogs, my_dialog_box=$my_dialog_box\n"); | ||
| 1530 | |||
| 1531 | $my_dialog_box->title($run_name); | ||
| 1532 | |||
| 1533 | $my_dialog_label->configure( | ||
| 1534 | -textvariable => \$message, | ||
| 1535 | ); | ||
| 1536 | |||
| 1537 | my $click = &_get_my_dialog_box_click(); | ||
| 1538 | |||
| 1539 | # print("1. color_listbox, my_dialogs, shared wait start = $click\n"); | ||
| 1540 | |||
| 1541 | $my_dialog_box->deiconify(); | ||
| 1542 | $my_dialog_box->raise(); | ||
| 1543 | $my_dialog_box->grab(); | ||
| 1544 | |||
| 1545 | # $my_dialog_box->grabGlobal(); | ||
| 1546 | $click = &_get_my_dialog_box_click(); | ||
| 1547 | |||
| 1548 | # print("1. color_listbox, my_dialogs, shared wait start = $click\n"); | ||
| 1549 | # print("1A. color_listbox, my_dialogs, shared wait start = $color_listbox->{_my_dialog_box_click}\n"); | ||
| 1550 | |||
| 1551 | $ok_button->waitVariable( \$color_listbox->{_my_dialog_box_click} ); | ||
| 1552 | |||
| 1553 | my $ans_cancel = _get_my_dialog_cancel_click(); | ||
| 1554 | my $ans_ok = _get_my_dialog_ok_click(); | ||
| 1555 | |||
| 1556 | # print("cancel_wait = $ans_cancel\n"); | ||
| 1557 | # print("ok_wait = $ans_ok\n"); | ||
| 1558 | # print("3. run, made it past\n"); | ||
| 1559 | |||
| 1560 | return (); | ||
| 1561 | } | ||
| 1562 | |||
| 1563 | =head2 sub set_hash_ref | ||
| 1564 | |||
| 1565 | Imports external hash into a local | ||
| 1566 | hash via gui_history module | ||
| 1567 | hash | ||
| 1568 | Note that color_listbox_href is not altered | ||
| 1569 | A private hash (color_listbox) is available for truly private variables | ||
| 1570 | |||
| 1571 | =cut | ||
| 1572 | |||
| 1573 | sub set_hash_ref { | ||
| 1574 | my ( $self, $hash_ref ) = @_; | ||
| 1575 | |||
| 1576 | $gui_history->set_defaults($hash_ref); | ||
| 1577 | $color_listbox_href = $gui_history->get_defaults(); | ||
| 1578 | |||
| 1579 | return (); | ||
| 1580 | } | ||
| 1581 | |||
| 1582 | __PACKAGE__->meta->make_immutable; | ||
| 1583 | 1; |