ARGSUSED*/ * Add a menu item to the beginning of the menu list. This list is reversed * later. */
(window, glyph, identifier, ch, gch, attr, str, itemflags)
| 743 | * later. |
| 744 | */ |
| 745 | void |
| 746 | Gem_add_menu(window, glyph, identifier, ch, gch, attr, str, itemflags) |
| 747 | winid window; /* window to use, must be of type NHW_MENU */ |
| 748 | int glyph; /* glyph to display with item (unused) */ |
| 749 | const anything *identifier; /* what to return if selected */ |
| 750 | char ch; /* keyboard accelerator (0 = pick our own) */ |
| 751 | char gch; /* group accelerator (0 = no group) */ |
| 752 | int attr; /* attribute for string (like Gem_putstr()) */ |
| 753 | const char *str; /* menu string */ |
| 754 | unsigned int itemflags; /* itemflags such as marked as selected */ |
| 755 | { |
| 756 | boolean preselected = ((itemflags & MENU_ITEMFLAGS_SELECTED) != 0); |
| 757 | Gem_menu_item *G_item; |
| 758 | const char *newstr; |
| 759 | char buf[QBUFSZ]; |
| 760 | |
| 761 | if (str == (const char *) 0) |
| 762 | return; |
| 763 | |
| 764 | if (window == WIN_ERR) /* MAR -- test existence */ |
| 765 | panic(winpanicstr, window); |
| 766 | |
| 767 | if (identifier->a_void) |
| 768 | Sprintf(buf, "%c - %s", ch ? ch : '?', str); |
| 769 | else |
| 770 | Sprintf(buf, "%s", str); |
| 771 | newstr = buf; |
| 772 | |
| 773 | G_item = (Gem_menu_item *) alloc(sizeof(Gem_menu_item)); |
| 774 | G_item->Gmi_identifier = (long) identifier->a_void; |
| 775 | G_item->Gmi_glyph = glyph != NO_GLYPH ? glyph2tile[glyph] : NO_GLYPH; |
| 776 | G_item->Gmi_count = -1L; |
| 777 | G_item->Gmi_selected = preselected ? 1 : 0; |
| 778 | G_item->Gmi_accelerator = ch; |
| 779 | G_item->Gmi_groupacc = gch; |
| 780 | G_item->Gmi_itemflags = itemflags; |
| 781 | G_item->Gmi_attr = attr; |
| 782 | G_item->Gmi_str = copy_of(newstr); |
| 783 | mar_add_menu(window, G_item); |
| 784 | } |
| 785 | |
| 786 | /* |
| 787 | * End a menu in this window, window must a type NHW_MENU. |
no test coverage detected