comparison gui/skin/skin.c @ 33058:b8374f9dc87b

Replace macro by function. The check whether a command is forbidden within a specific window is now performed by function in_window().
author ib
date Tue, 29 Mar 2011 11:17:01 +0000
parents 0d6b33bc311e
children 492520edebad
comparison
equal deleted inserted replaced
33057:0d6b33bc311e 33058:b8374f9dc87b
78 } 78 }
79 79
80 return 1; 80 return 1;
81 } 81 }
82 82
83 #define CHECK(name) \ 83 static int in_window(char *name)
84 { \ 84 {
85 if (!strcmp(currWinName, name)) \ 85 if (strcmp(currWinName, name) == 0) {
86 { \ 86 skin_error(MSGTR_SKIN_ERROR_IN_WINDOW, name);
87 skin_error(MSGTR_SKIN_ERROR_IN_WINDOW, name); \ 87 return 1;
88 return 1; \ 88 }
89 } \ 89
90 } 90 return 0;
91 }
91 92
92 int skinBPRead(char *fname, txSample *bf) 93 int skinBPRead(char *fname, txSample *bf)
93 { 94 {
94 int i = bpRead(fname, bf); 95 int i = bpRead(fname, bf);
95 96
337 static int cmd_background(char *in) 338 static int cmd_background(char *in)
338 { 339 {
339 if (!window_cmd("background")) 340 if (!window_cmd("background"))
340 return 1; 341 return 1;
341 342
342 CHECK("menu"); 343 if (in_window("main"))
343 CHECK("main"); 344 return 1;
345 if (in_window("menu"))
346 return 1;
344 347
345 currWin->R = cutItemToInt(in, ',', 0); 348 currWin->R = cutItemToInt(in, ',', 0);
346 currWin->G = cutItemToInt(in, ',', 1); 349 currWin->G = cutItemToInt(in, ',', 1);
347 currWin->B = cutItemToInt(in, ',', 2); 350 currWin->B = cutItemToInt(in, ',', 2);
348 351
360 char msg[32]; 363 char msg[32];
361 364
362 if (!window_cmd("button")) 365 if (!window_cmd("button"))
363 return 1; 366 return 1;
364 367
365 CHECK("sub"); 368 if (in_window("sub"))
366 CHECK("menu"); 369 return 1;
370 if (in_window("menu"))
371 return 1;
367 372
368 cutItem(in, fname, ',', 0); 373 cutItem(in, fname, ',', 0);
369 x = cutItemToInt(in, ',', 1); 374 x = cutItemToInt(in, ',', 1);
370 y = cutItemToInt(in, ',', 2); 375 y = cutItemToInt(in, ',', 2);
371 sx = cutItemToInt(in, ',', 3); 376 sx = cutItemToInt(in, ',', 3);
418 unsigned char tmp[512]; 423 unsigned char tmp[512];
419 424
420 if (!window_cmd("selected")) 425 if (!window_cmd("selected"))
421 return 1; 426 return 1;
422 427
423 CHECK("main"); 428 if (in_window("main"))
424 CHECK("sub"); 429 return 1;
425 CHECK("playbar"); 430 if (in_window("sub"))
431 return 1;
432 if (in_window("playbar"))
433 return 1;
426 434
427 cutItem(in, fname, ',', 0); 435 cutItem(in, fname, ',', 0);
428 436
429 skin->menuSelected.type = itBase; 437 skin->menuSelected.type = itBase;
430 438
451 unsigned char tmp[64]; 459 unsigned char tmp[64];
452 460
453 if (!window_cmd("menu")) 461 if (!window_cmd("menu"))
454 return 1; 462 return 1;
455 463
456 CHECK("main"); 464 if (in_window("main"))
457 CHECK("sub"); 465 return 1;
458 CHECK("playbar"); 466 if (in_window("sub"))
467 return 1;
468 if (in_window("playbar"))
469 return 1;
459 470
460 x = cutItemToInt(in, ',', 0); 471 x = cutItemToInt(in, ',', 0);
461 y = cutItemToInt(in, ',', 1); 472 y = cutItemToInt(in, ',', 1);
462 sx = cutItemToInt(in, ',', 2); 473 sx = cutItemToInt(in, ',', 2);
463 sy = cutItemToInt(in, ',', 3); 474 sy = cutItemToInt(in, ',', 3);
493 wItem *item; 504 wItem *item;
494 505
495 if (!window_cmd("h/v potmeter")) 506 if (!window_cmd("h/v potmeter"))
496 return 1; 507 return 1;
497 508
498 CHECK("sub"); 509 if (in_window("sub"))
499 CHECK("menu"); 510 return 1;
511 if (in_window("menu"))
512 return 1;
500 513
501 cutItem(in, pfname, ',', 0); 514 cutItem(in, pfname, ',', 0);
502 pwidth = cutItemToInt(in, ',', 1); 515 pwidth = cutItemToInt(in, ',', 1);
503 pheight = cutItemToInt(in, ',', 2); 516 pheight = cutItemToInt(in, ',', 2);
504 cutItem(in, phfname, ',', 3); 517 cutItem(in, phfname, ',', 3);
582 wItem *item; 595 wItem *item;
583 596
584 if (!window_cmd("potmeter")) 597 if (!window_cmd("potmeter"))
585 return 1; 598 return 1;
586 599
587 CHECK("sub"); 600 if (in_window("sub"))
588 CHECK("menu"); 601 return 1;
602 if (in_window("menu"))
603 return 1;
589 604
590 cutItem(in, phfname, ',', 0); 605 cutItem(in, phfname, ',', 0);
591 ph = cutItemToInt(in, ',', 1); 606 ph = cutItemToInt(in, ',', 1);
592 d = cutItemToInt(in, ',', 2); 607 d = cutItemToInt(in, ',', 2);
593 x = cutItemToInt(in, ',', 3); 608 x = cutItemToInt(in, ',', 3);
634 wItem *item; 649 wItem *item;
635 650
636 if (!window_cmd("font")) 651 if (!window_cmd("font"))
637 return 1; 652 return 1;
638 653
639 CHECK("sub"); 654 if (in_window("sub"))
640 CHECK("menu"); 655 return 1;
656 if (in_window("menu"))
657 return 1;
641 658
642 cutItem(in, name, ',', 0); 659 cutItem(in, name, ',', 0);
643 660
644 (*currWinItemIdx)++; 661 (*currWinItemIdx)++;
645 item = &currWinItems[*currWinItemIdx]; 662 item = &currWinItems[*currWinItemIdx];
678 wItem *item; 695 wItem *item;
679 696
680 if (!window_cmd("slabel")) 697 if (!window_cmd("slabel"))
681 return 1; 698 return 1;
682 699
683 CHECK("sub"); 700 if (in_window("sub"))
684 CHECK("menu"); 701 return 1;
702 if (in_window("menu"))
703 return 1;
685 704
686 x = cutItemToInt(in, ',', 0); 705 x = cutItemToInt(in, ',', 0);
687 y = cutItemToInt(in, ',', 1); 706 y = cutItemToInt(in, ',', 1);
688 cutItem(in, sid, ',', 2); 707 cutItem(in, sid, ',', 2);
689 cutItem(in, tmp, ',', 3); 708 cutItem(in, tmp, ',', 3);
728 wItem *item; 747 wItem *item;
729 748
730 if (!window_cmd("dlabel")) 749 if (!window_cmd("dlabel"))
731 return 1; 750 return 1;
732 751
733 CHECK("sub"); 752 if (in_window("sub"))
734 CHECK("menu"); 753 return 1;
754 if (in_window("menu"))
755 return 1;
735 756
736 x = cutItemToInt(in, ',', 0); 757 x = cutItemToInt(in, ',', 0);
737 y = cutItemToInt(in, ',', 1); 758 y = cutItemToInt(in, ',', 1);
738 sx = cutItemToInt(in, ',', 2); 759 sx = cutItemToInt(in, ',', 2);
739 a = cutItemToInt(in, ',', 3); 760 a = cutItemToInt(in, ',', 3);
779 char tmp[512]; 800 char tmp[512];
780 801
781 if (!window_cmd("decoration")) 802 if (!window_cmd("decoration"))
782 return 1; 803 return 1;
783 804
784 CHECK("sub"); 805 if (in_window("sub"))
785 CHECK("menu"); 806 return 1;
786 CHECK("playbar"); 807 if (in_window("playbar"))
808 return 1;
809 if (in_window("menu"))
810 return 1;
787 811
788 cutItem(strlower(in), tmp, ',', 0); 812 cutItem(strlower(in), tmp, ',', 0);
789 813
790 if (strcmp(tmp, "enable") != 0 && strcmp(tmp, "disable") != 0) { 814 if (strcmp(tmp, "enable") != 0 && strcmp(tmp, "disable") != 0) {
791 skin_error(MSGTR_SKIN_UnknownParameter, tmp); 815 skin_error(MSGTR_SKIN_UnknownParameter, tmp);