- Timestamp:
- 30/11/11 12:02:47 (6 months ago)
- Files:
-
- 1 modified
-
trunk/WINDOW/AW_preset.cxx (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WINDOW/AW_preset.cxx
r8262 r8263 513 513 return GBT_write_int(gbd, AW_COLOR_GROUP_ENTRY, color_group); 514 514 } 515 516 struct gc_props { 517 bool hidden; 518 bool select_font; 519 bool select_color; 520 521 bool fixed_fonts_only; 522 bool append_same_line; 523 524 gc_props() 525 : hidden(false), 526 select_font(true), 527 select_color(true), 528 fixed_fonts_only(false), 529 append_same_line(false) 530 {} 531 532 private: 533 bool parse_char(char c) { 534 switch (c) { 535 case '#': fixed_fonts_only = true; break; 536 case '+': append_same_line = true; break; 537 538 case '=': select_color = false; break; 539 case '-': { 540 if (select_font) select_font = false; 541 else hidden = true; // two '-' means 'hidden' 542 break; 543 } 544 545 default : return false; 546 } 547 return true; 548 } 549 550 void correct() { 551 if (!select_font && !select_color) hidden = true; 552 if (append_same_line && select_font) append_same_line = false; 553 } 554 public: 555 556 int parse_decl(const char *decl) { 557 // returns number of (interpreted) prefix characters 558 int offset = 0; 559 while (decl[offset]) { 560 if (!parse_char(decl[offset])) break; 561 offset++; 562 } 563 correct(); 564 return offset; 565 } 566 }; 515 567 516 568 AW_gc_manager AW_manage_GC(AW_window *aww, … … 574 626 gcmgrfirst = gcmgrlast = new aw_gc_manager(mcbs->window_awar_name, 0); 575 627 576 const char * old_font_base_name = "default";628 const char *last_font_base_name = "default"; 577 629 578 630 char background[50]; … … 596 648 597 649 while (id) { 598 bool flag_fixed_fonts_only = false; 599 bool flag_no_fonts = false; 600 650 gc_props gcp; 601 651 AW_MGC_awar_cb_struct *acbs = 0; 602 652 { … … 656 706 } 657 707 658 int offset = 0; 659 while (1) { 660 switch (id_copy[offset]) { 661 case '#': flag_fixed_fonts_only = true; offset++; continue; 662 case '-': flag_no_fonts = true; offset++; continue; 663 case '=': 664 case '+': offset++; continue; // just skip over here, handled only in aw_insert_gcs() 665 default: break; 666 } 667 break; 668 } 669 708 gcp.parse_decl(id_copy); 670 709 freenull(id_copy); 671 710 } 672 711 673 if (flag_fixed_fonts_only) def_font = AW_DEFAULT_FIXED_FONT; 674 else def_font = AW_DEFAULT_NORMAL_FONT; 712 def_font = gcp.fixed_fonts_only ? AW_DEFAULT_FIXED_FONT : AW_DEFAULT_NORMAL_FONT; 675 713 676 714 if ((area != AW_GCM_DATA_AREA) || !first) { … … 694 732 aw_gc_color_changed_cb(aw_root, acbs, -1); 695 733 696 if (flag_no_fonts) acbs->fontbasename = old_font_base_name;697 else old_font_base_name = acbs->fontbasename = acbs->colorbasename;734 acbs->fontbasename = gcp.select_font ? acbs->colorbasename : last_font_base_name; 735 last_font_base_name = acbs->fontbasename; 698 736 699 737 { … … 703 741 AW_awar *font_size_awar = aw_root->awar_int(awar_name, DEF_FONTSIZE, aw_def); 704 742 705 if ( !flag_no_fonts) {743 if (gcp.select_font) { 706 744 font_awar->add_callback(aw_font_changed_cb, (AW_CL)acbs); 707 745 gcmgr2->set_font_change_parameter(acbs); … … 772 810 for (gcmgr = gcmgr->get_next(); gcmgr; gcmgr = gcmgr->get_next()) { 773 811 const char *id = gcmgr->get_field(); 774 775 bool flag_fixed_fonts_only = false; 776 bool flag_no_color_selector = false; 777 bool flag_append_in_same_line = false; 778 bool flag_no_fonts = false; 779 bool flag_hide_this_gc = false; 780 781 while (1) { 782 switch (id[0]) { 783 case '#': flag_fixed_fonts_only = true; id++; continue; 784 case '=': flag_no_color_selector = true; id++; continue; 785 case '+': flag_append_in_same_line = true; id++; continue; 786 case '-': { 787 if (flag_no_fonts) flag_hide_this_gc = true; // if gc definition contains -- the gc is completely hidden 788 else flag_no_fonts = true; 789 id++; 790 continue; 791 } 792 default: break; 793 } 794 break; 795 } 812 gc_props gcp; 813 814 id += gcp.parse_decl(id); 796 815 797 816 char *fontbasename = GBS_string_2_key(id); … … 809 828 } 810 829 811 if (! flag_hide_this_gc) {830 if (!gcp.hidden) { 812 831 sprintf(awar_name, AWP_COLORNAME_TEMPLATE, window_awar_name, fontbasename); 813 832 aws->label_length(15); … … 823 842 } 824 843 825 if ( !flag_no_color_selector) {844 if (gcp.select_color) { 826 845 aws->button_length(5); 827 846 AW_preset_create_color_chooser(aws, awar_name, id); … … 829 848 aws->create_input_field(awar_name, 7); 830 849 831 if ( !flag_no_fonts) {850 if (gcp.select_font) { 832 851 sprintf(awar_name, AWP_FONTNAME_TEMPLATE, window_awar_name, fontbasename); 833 852 … … 841 860 font_string = AW_font_2_ascii((AW_font) font_nr); 842 861 if (!font_string) break; 843 if ( flag_fixed_fonts_only && AW_font_2_xfig((AW_font) font_nr) >= 0) continue;862 if (gcp.fixed_fonts_only && AW_font_2_xfig((AW_font) font_nr) >= 0) continue; 844 863 aws->insert_option(font_string, 0, (int) font_nr); 845 864 } … … 858 877 aw_init_font_sizes(aw_root, acs, true); // does update_option_menu 859 878 } 860 if (! flag_append_in_same_line) aws->at_newline();879 if (!gcp.append_same_line) aws->at_newline(); 861 880 } 862 881 free(fontbasename);
