Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site amiga.amiga.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!amiga!jimm From: jimm@amiga.UUCP (Jim Mackraz) Newsgroups: net.micro.amiga Subject: Re: Request for info. on Amiga Menus Message-ID: <752@amiga.amiga.UUCP> Date: Wed, 26-Feb-86 06:10:14 EST Article-I.D.: amiga.752 Posted: Wed Feb 26 06:10:14 1986 Date-Received: Fri, 28-Feb-86 21:38:29 EST References: <468@tekigm2.UUCP> Reply-To: jimm@homer.UUCP (Jim Mackraz) Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030 Lines: 46 Keywords: MenuItems,Menus 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