normc@tekigm2.UUCP (Norm Church) (02/25/86)
I am having difficulty understanding how to use the functions to turn_on and turn_off menu items from within an application program. On power up, I want some of my menu items to be "de-selected" and I can do this ok by not "enabling" them when I set up my menu structure definition. My problem is in understanding how to use the two routines provided that turn on or off a given menu item. I have tried this and have not been successful. Can anyone help me out with some sample code that shows how to turn the menu items back on when they were not enabled at the time of the menu structure definition? I would appreciate any help along this line. Regards, Norm Church
jimm@amiga.UUCP (Jim Mackraz) (02/26/86)
In article <468@tekigm2.UUCP> normc@tekigm2.UUCP (Norm Church) writes: > >I am having difficulty understanding how >to use the functions to turn_on and turn_off >menu items from within an application program. > > My problem is in understanding how to >use the two routines provided that turn on >or off a given menu item. The Intuition routines OnMenu() and OffMenu() are what you want to use; they take a parameter which is not obvious to all. The reference for this is the Intuition Reference Manual (its formal title), sections "Menu Numbers and Menu Selection Messages" and "How Menu Numbers Really Work." The parameter these functions take is the composite menu/item/sub number, which is pretty consistently referred to as the "menu number." This thing is what one finds in the code field of a MENUPICK IDCMP message, and in the NextSelect field of an item in case of a multiple select. There are three macros which decompose it into the ordinal number (i.e., position in the linked list) in the menu strip chain of menus (MENUNUM()), the item chain (ITEMNUM()), and the subitem chain (SUBNUM()). Note that MENUNUM() takes a component of a composite menu number; the naming might be confusing. Given that you know your menu item's position in the various linked list, almost all the macros you need to create a composite menu number to feed to these routines exist in intuition.h: SHIFTMENU(), SHIFTITEM(), and SHIFTSUB(). What you need to use is: comp_menu_num = (SHIFTMENU(ord_menu) | SHIFTITEM(ord_item) | SHIFTSUB(ord_sub)) where ord_* are ordinal numbers for menu, item, and subitem. Note that if you do not want to refer to a specific subitem, use ord_sub = NOSUB. Similarly, ord_item = NOITEM if you are trying to turn off a whole menu. For you mathematicians, the following identity probably defines about everything: X == SHIFTMENU(MENUNUM(X))|SHIFTITEM(ITEMNUM(X))|SHIFTSUB(SUBNUM(X)) let fly. jimm