home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNCREAT0 -- Allocate and create a menu structure.
- *
- * Synopsis pmenu = mncreat0 (height, width,
- * textattr, hilattr, proattr, longattr,
- * signature);
- *
- * BMENU *pmenu Pointer to newly-created BMENU
- * structure, or NIL if failure.
- * int height Number of rows in data area.
- * int width Number of columns in data area.
- * int textattr Default attribute in data area.
- * int hilattr Attribute of highlight bar.
- * int proattr Attribute of "protected" items.
- * int longattr Attribute of long descriptions (if any).
- * unsigned signature
- * Signature word expected by calling
- * function.
- *
- * Description This function allocates space for a menu structure and
- * fills it with default values. This includes a call
- * to WNCREATE.
- *
- * An error occurs if the menu dimensions exceed maximum
- * screen dimensions or if the memory allocation fails.
- *
- * This function is invoked by the mncreate() macro, which
- * provides the signature value. The same signature value
- * is provided to MNVALMN0 by the mnvalmnu() macro. By
- * using these macros, all menu functions provide signature
- * values for comparison. In this way incompatible
- * versions of BMENU.H can be detected at run time.
- *
- * Use MNDSTROY to discard the BMENU structure and
- * related internal data structures.
- *
- * Returns presult Pointer to newly-created BMENU
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_ILL_DIM Invalid dimensions.
- * WN_NO_MEMORY Insufficient memory.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
- #include <bmenu.h>
-
- BMENU *mncreat0 (height, width, textattr, hilattr, proattr, longattr,
- signature)
- int height, width, textattr, hilattr, proattr, longattr;
- unsigned signature;
- {
- BMENU *pmenu;
- int err;
-
- /* Attempt to allocate space for BMENU structure. */
- if ((pmenu = utalloc (BMENU)) == NIL)
- wnreterr (WN_NO_MEMORY);
-
- /* Set pointers to NIL, stuff in given values. */
- pmenu->pitems = NIL;
- pmenu->pkeys = NIL;
- pmenu->hilattr = hilattr;
- pmenu->proattr = proattr;
- pmenu->longattr = longattr;
-
- /* Create this menu's window. */
- if ((pmenu->pwin = wncreate (height, width, textattr)) == NIL)
- {
- free (pmenu);
- return (NIL);
- }
-
- /* Create signature. */
- pmenu->signature = signature;
-
- /* Create default key bindings list for this menu. */
- if (mndefkey (pmenu) == NIL)
- {
- err = b_wnerr;
- mndlkeys (pmenu);
- wndstroy (pmenu->pwin);
- pmenu->signature = BMENU_DEAD;
- free (pmenu);
- wnreterr (err);
- }
-
- pmenu->pwin->options.cur_track = 0; /* Disable cursor tracking. */
-
- /* Turn the window cursor off (so our highlight bar */
- /* looks good). */
- wnsetopt (pmenu->pwin, WN_CUR_OFF, 1);
-
- return (pmenu);
- }