home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * BMENU.H Header file for Turbo C TOOLS Menu Functions
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
-
- #ifndef DEF_BMENU /* Prevent redefinition. */
-
- #define DEF_BMENU 1 /* Prevent second reading of */
- /* these definitions. */
- #include <bkeybrd.h>
- #include <bwindow.h>
-
- /* Error constants specific to MENU operations. */
- #define MN_BAD_MENU 100 /* Menu failed test by MNVALMNU. */
- #define MN_NONE_SELECT 101 /* No selectable item on menu. */
- #define MN_KEY_CONFLICT 102 /* A key not bound to a location */
- /* already exists with the given */
- /* character and key codes. */
- #define MN_NO_ITEM 103 /* No item exists at the given */
- /* coordinates. */
- #define MN_BAD_KEY 104 /* Invalid keymap entry encountered.*/
- #define MN_BAD_ITEM 105 /* Invalid item encountered. */
- #define MN_NO_EXIT 106 /* No enabled key has either the */
- /* transmit or abort bit set. */
-
- #define MN_READ_AB 110 /* User pressed a key with MN_ABORT */
- /* action associated with it. */
- #define MN_UNKNOWN_AB 111 /* User pressed a key unknown to */
- /* the menu, and MN_UNKNOWN_TRANSMIT*/
- /* was an option passed to a menu */
- /* reader function. */
- #define MN_NO_MOU_EVENT 120 /* No matching mouse event found. */
- #define MN_MOU_CONFLICT 121 /* Cannot add an existing mouse */
- /* event. */
- #define MN_BAD_MOUSE 122 /* Invalid mouse node. */
- #define MN_XMIT_NOBAR 130 /* Transmit without highlight bar. */
-
-
- #define MN_KEY_SIGN 0x0123 /* Arbitrary signature words. */
- #define MN_ITEM_SIGN 0x0320
- #define MN_MOU_SIGN 0x4567
-
- #define MN_DEAD_KEY 0xffef /* Arbitrary "deleted" signature */
- #define MN_DEAD_ITEM 0x0000 /* words for same. */
- #define MN_DEAD_MOUSE 0x6745
-
-
- /* Constants for use with MNKEY (the "howchange" argument). */
- #define MN_ADD 0
- #define MN_CHANGE 1
- #define MN_DELETE 2
-
- /* Constants for use with MNKEY (the "action" argument). */
- #define MN_NOMOVE 0x000
- #define MN_UP 0x001
- #define MN_DOWN 0x002
- #define MN_RIGHT 0x003
- #define MN_LEFT 0x004
- #define MN_NEXT 0x005
- #define MN_PREVIOUS 0x006
- #define MN_FIRST 0x007
- #define MN_LAST 0x008
- #define MN_SELECT 0x009
- #define MN_PGUP 0x00a
- #define MN_PGDN 0x00b
- #define MN_PGRIGHT 0x00c
- #define MN_PGLEFT 0x00d
-
- #define MN_TRANSMIT 0x010
- #define MN_BEEP 0x020
- #define MN_TEMP_DISABLE 0x040
- #define MN_DISABLE 0x080
- #define MN_ABORT 0x100
-
- #define MN_KBIGNORE 0x200 /* Also duplicated below. */
- #define MN_HIDE_BAR 0x800 /* Also duplicated below. */
- #define MN_SHOW_BAR 0x1000 /* Also duplicated below. */
-
- #define MN_NOWRAP 0x0400
-
- #define MN_MOVE_MASK 0x00f
- #define MNMOVE(action) ((action) & MN_MOVE_MASK)
-
- #define MN_INVALID_ACTION 0x4f3
-
-
- /* Constants for use with adding/changing of items. */
- #define MN_PROTECT 0x0001
- #define MN_NOPROTECT 0x0000
- #define MN_CHAR_ATTR 0x0002
- #define MN_CHARS_ONLY 0x0000
-
-
- /* Constants for use with MNREAD (the "option" value). */
- #define MN_REMOVE 0x01
- #define MN_DESTROY 0x03
- #define MN_KEEP_HIGHLIGHT 0x04
- #define MN_ALL_TRANSMIT 0x08
- #define MN_UNKNOWN_BEEP 0x10
- #define MN_UNKNOWN_TRANSMIT 0x20
- #define MN_KEEP_DESCRIPTION 0x40
- #define MN_HOLD_BEEP 0x80
-
- #define MN_KBIGNORE 0x200 /* Also duplicated above. */
- #define MN_KBDISCARD 0x400 /* Internal use only. */
- #define MN_HIDE_BAR 0x800 /* Also duplicated above. */
- #define MN_SHOW_BAR 0x1000 /* Also duplicated above. */
- #define MN_PREV_BAR 0x2000
- #define MN_USE_DESCRIPTION 0x4000
-
-
- /* Constants for use with MNATR, MNHILITE. */
- #define MN_UNHIGHLIGHT 0x00
- #define MN_HIGHLIGHT 0x01
-
- /* Menu mouse styles. */
- #define MN_MOU_CLICK 1
- #define MN_MOU_DRAG 2
- #define MN_MOU_ALT_DRAG 3
-
-
- /* Definitive signature for signature field in BMENU structure. */
- #define BMENU_SIGN 0xf001
- #define BMENU_DEAD 0
-
- /* Mouse events in addition to those defined in BMOUSE.H. */
- #define MN_OUT_MENU 0x0100
- #define MN_ITEMS 0x0200
- #define MN_OFF_ITEMS 0x0400
-
-
- /* User macros. */
-
- #define mncreate(height,width,textattr,hilattr,proattr,longattr) \
- (mncreat0((height),(width),(textattr),(hilattr), \
- (proattr),(longattr),(BMENU_SIGN)))
-
- #define mndsplay(pmenu,pwhere,pbord) \
- (mnvdisp((pmenu),(pwhere), \
- wndata_h((pmenu)->pwin),wndata_w((pmenu)->pwin), \
- 0,0,(pbord)))
-
- #define mnlread(pmenu,srow,scol,prow,pcol,pch,pscan,option) \
- (mnread((pmenu),(srow),(scol),(prow),(pcol),(pch),(pscan), \
- (option) | MN_USE_DESCRIPTION))
-
-
- /* Internal Macros. */
- #define mnvalidm(pmenu) \
- { \
- if (mnvalmnu (pmenu) == NIL) \
- wnreterr (MN_BAD_MENU); \
- }
-
- #define mntrunc(pmenu, length, col) \
- (((length + col) > pmenu->pwin->img.dim.w) \
- ? (pmenu->pwin->img.dim.w - col) \
- : (length))
-
- #define mnvalmnu(pmenu) (mnvalmn0((pmenu),(BMENU_SIGN)))
-
- /* Definitions of data types. */
-
- /* BITEM -- data structure for an item in a menu. */
- typedef struct bitem
- {
- unsigned signature; /* Characteristic signature. */
- int row, col; /* Coordinates (relative to window) */
- /* of menu item text. */
- int lrow, lcol; /* Row and column at which to put */
- /* long description. */
- int attr; /* Attribute of this item. */
- int len; /* Length of ASCII text of menu */
- /* item. */
- int llen; /* Length of ASCII text of menu */
- /* description. */
- int option; /* Bitwise OR-ing of: */
- /* MN_PROTECT (protected item) */
- /* MN_NOPROTECT (unprotected item)*/
- char *plstring; /* Long description of item. Used */
- /* by "Lotus" menu functions. */
- char *pcharattr; /* Pointer to mixed character/ */
- /* attribute item string. */
- struct bitem *next; /* Pointer to next item */
- } BITEM; /* specification in linked list. */
-
-
- /* BKEYMAP -- data structure for a key associated */
- /* with a menu. */
- typedef struct bkeymap
- {
- unsigned signature; /* Characteristic signature. */
- int ch; /* Character and scan code with */
- int scan; /* which the following action is to */
- /* be associated with. */
- /* */
- int row, col; /* The row and column this keycode */
- /* is associated with. */
- /* */
- int action; /* The action which should be taken */
- /* when (ch,scan) is received by */
- /* MNREAD: */
- /* */
- /* The bitwise OR-ing of the */
- /* following: */
- /* MN_TRANSMIT, MN_BEEP, */
- /* MN_SELECT, MN_DISABLE, */
- /* and MN_ABORT, */
- /* */
- /* OR-ed with only one of: */
- /* */
- /* MN_UP, MN_DOWN, MN_RIGHT, */
- /* MN_LEFT, MN_NEXT, */
- /* MN_PREVIOUS, MN_FIRST, */
- /* MN_LAST, or MN_NOMOVE. */
- /* */
- struct bkeymap *next; /* Pointer to next key in keymap. */
- } BKEYMAP;
-
-
- /* BKEYTAB -- data structure for a default key table*/
- /* entry. */
- typedef struct bkeytab
- {
- int ch; /* Character and scan code with */
- int scan; /* which the following action is to */
- /* be associated with. */
- /* */
- int action; /* The action which should be taken */
- /* when (ch,scan) is received by */
- /* MNREAD: (see above). */
- } BKEYTAB;
-
- typedef struct bmnmouse_node /* BMNMOUSE: Menu mouse event. */
- {
- unsigned signature;
- unsigned long event;
- unsigned long ignore;
- int action;
- struct bmnmouse_node *pnext;
- struct bmnmouse_node *pprev;
- } BMNMOUSE;
-
-
- /* BMENU -- Data structure which governs behavior */
- /* and appearance of a menu. */
- typedef struct
- {
- unsigned signature; /* Characteristic signature. */
- /* */
- BWINDOW *pwin; /* The window we use. */
- /* */
- BITEM *pitems; /* The items to display in the */
- /* window. */
- /* */
- BKEYMAP *pkeys; /* The key definitions used. */
- /* */
- int hilattr; /* Highlight bar attributes. */
- int proattr; /* Protected attributes. */
- int longattr; /* Description attributes. */
- BMNMOUSE *pmouse; /* List of mouse events. */
- BITEM *pbar_item; /* Currently highlighted item, or */
- /* NIL if none. */
- BITEM *pbar_prev; /* Previously highlighted item if */
- /* pbar_item is NIL. */
-
- struct /* Internal items. */
- { /* */
- unsigned desc_shown: 1; /* Lotus description shown. */
- unsigned _dummy :15; /* Pad to word boundary. */
- } internals;
- } BMENU;
-
-
- /* Most recent mouse menu event. */
- extern unsigned long b_mnmoevent; /* Event, or OL if none. */
- extern unsigned b_mnmovert; /* Row and column where event took*/
- extern unsigned b_mnmohoriz; /* place, or 0xffff if none. */
-
- /* Pointer to current default key map. */
- extern BKEYTAB *b_mnkeytab;
-
- /* Original default key map. */
- extern BKEYTAB b_mndefkey [];
-
-
- /* Function declarations -- User functions. */
- BMENU *cdecl mnvdisp(BMENU *, /* Display a menu. Necessary */
- const WHERE *,int,int,int,int,/* before using MNREAD. */
- const BORDER *); /* */
- /* */
- int cdecl mndstroy (BMENU *); /* Release menu data structures, */
- /* undisplay if necessary. */
- /* */
- BMENU *cdecl mnitem (BMENU *, /* Add/Change/Delete item in menu. */
- int, int, int, /* */
- const char *); /* */
- /* */
- BMENU *cdecl mnitmkey (BMENU *, /* Add item and key bindings for */
- int, int, int, /* that item to menu. */
- const char *, /* */
- const char *, int); /* */
- /* */
- BMENU *cdecl mnkey (BMENU *, /* Add a key binding to a menu. */
- int, int, int, /* */
- int, int, int);/* */
- /* */
- BMENU *cdecl mnlitem (BMENU *, /* Add/Change/Delete item in */
- int, int, int, /* "Lotus"-style menu. */
- const char *, /* */
- int, int, /* */
- const char *); /* */
- /* */
- BMENU *cdecl mnlitkey (BMENU *, /* Add "Lotus" item and key */
- int, int, int, /* bindings for that item to menu. */
- const char *, /* */
- int, int, /* */
- const char *, /* */
- const char *, int); /* */
- /* */
- BMENU *cdecl mnmstyle(BMENU *, /* Install a mouse style. */
- int,unsigned); /* */
- /* */
- BMENU *cdecl mnmouse(BMENU *, /* Add, change, or delete a menu */
- unsigned long,unsigned long,/* mouse event. */
- int,int); /* */
- /* */
- BMENU *cdecl mnhilite(BMENU *, /* Move or remove highlight bar */
- int,int,int); /* or item description. */
- /* */
- int cdecl mnread (BMENU *, int, /* Request user input from a menu. */
- int, int *, /* */
- int *, int *, /* */
- int *, int); /* */
-
-
- /* Function declarations -- Internal functions. */
- BMENU *cdecl mnatr (BMENU *, /* Change attributes on an item in */
- const BITEM *, int); /* a menu. */
- /* */
- BMENU *cdecl mncreat0 (int, /* Create menu data structures, */
- int, int, int, /* set up default key bindings and */
- int, int, unsigned); /* attributes. */
- /* */
- BMENU *cdecl mndefkey (BMENU *);/* Set up default keys for a menu. */
- /* Internal function -- redefine if */
- /* you want different default key */
- /* bindings. */
- /* */
- BMENU *cdecl mndisabl (BMENU *);/* Disable all keys which are bound */
- /* to locations for which no items */
- /* exist -- disable unbound keys. */
- /* */
- int cdecl mndlitms (BMENU *); /* Delete all items from a menu */
- /* item list data structure. */
- /* */
- int cdecl mndlkeys (BMENU *); /* Delete all keys from a menu key */
- /* list data structure. */
- /* */
- BITEM *cdecl mnfindsl (BMENU *, /* Find the first selectable item */
- BITEM *, /* in a menu, given starting */
- int, int, /* coordinates and menu item. */
- int *); /* */
- /* */
- BMENU *cdecl mnhilit0(BMENU *, /* Move or remove highlight bar */
- BITEM *,int); /* or item description. */
- /* */
- BITEM *cdecl mnmchitm (BMENU *, /* Match a menu item to a (row,col) */
- BITEM *, /* specification. */
- int, int, /* */
- int, int *); /* */
- /* */
- const BKEYMAP *cdecl mnmchkey ( /* Match a menu keymap entry to a */
- const BMENU *, /* (ch,scan) specification. */
- const BKEYMAP *, /* */
- int, int, /* */
- int *); /* */
- /* */
- BMENU *cdecl mnvalmn0 (BMENU *, /* Validate a menu data structure. */
- unsigned); /* */
-
- #endif /* Ends "#ifndef DEF_BMENU" */