home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ncurses-1.9.9e-bin.lha / include / menu.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  9KB  |  219 lines

  1.  
  2. /***************************************************************************
  3. *                            COPYRIGHT NOTICE                              *
  4. ****************************************************************************
  5. *                ncurses is copyright (C) 1992-1995                        *
  6. *                          Zeyd M. Ben-Halim                               *
  7. *                          zmbenhal@netcom.com                             *
  8. *                          Eric S. Raymond                                 *
  9. *                          esr@snark.thyrsus.com                           *
  10. *                                                                          *
  11. *        Permission is hereby granted to reproduce and distribute ncurses  *
  12. *        by any means and for any fee, whether alone or as part of a       *
  13. *        larger distribution, in source or in binary form, PROVIDED        *
  14. *        this notice is included with any such distribution, and is not    *
  15. *        removed from any of its header files. Mention of ncurses in any   *
  16. *        applications linked with it is highly appreciated.                *
  17. *                                                                          *
  18. *        ncurses comes AS IS with no warranty, implied or expressed.       *
  19. *                                                                          *
  20. ***************************************************************************/
  21.  
  22. #ifndef ETI_MENU
  23. #define ETI_MENU
  24.  
  25. #include <curses.h>
  26. #include <eti.h>
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. typedef int Menu_Options;
  33. typedef int Item_Options;
  34.  
  35. /* Menu options: */
  36. #define O_ONEVALUE      (0x01)
  37. #define O_SHOWDESC      (0x02)
  38. #define O_ROWMAJOR      (0x04)
  39. #define O_IGNORECASE    (0x08)
  40. #define O_SHOWMATCH     (0x10)
  41. #define O_NONCYCLIC     (0x20)
  42.  
  43. /* Item options: */
  44. #define O_SELECTABLE    (0x01)
  45.  
  46. typedef struct
  47. {
  48.   char*          str;
  49.   unsigned short length;
  50. } TEXT;
  51.  
  52. typedef struct tagITEM 
  53. {
  54.   TEXT           name;        /* name of menu item                         */
  55.   TEXT           description; /* description of item, optional in display  */ 
  56.   struct tagMENU *imenu;      /* Pointer to parent menu                    */
  57.   void           *userptr;    /* Pointer to user defined per item data     */ 
  58.   Item_Options   opt;         /* Item options                              */ 
  59.   short          index;       /* Item number if connected to a menu        */
  60.   short          y;           /* y and x location of item in menu          */
  61.   short          x;
  62.   bool           value;       /* Selection value                           */
  63.                              
  64.   struct tagITEM *left;       /* neighbour items                           */
  65.   struct tagITEM *right;
  66.   struct tagITEM *up;
  67.   struct tagITEM *down;
  68.  
  69. } ITEM;
  70.  
  71. typedef void (*Menu_Hook)(struct tagMENU *);
  72.  
  73. typedef struct tagMENU 
  74. {
  75.   short          height;                /* Nr. of chars high               */
  76.   short          width;                 /* Nr. of chars wide               */
  77.   short          rows;                  /* Nr. of items high               */
  78.   short          cols;                  /* Nr. of items wide               */
  79.   short          frows;                 /* Nr. of formatted items high     */
  80.   short          fcols;                 /* Nr. of formatted items wide     */
  81.   short          namelen;               /* Max. name length                */
  82.   short          desclen;               /* Max. description length         */
  83.   short          marklen;               /* Length of mark, if any          */
  84.   short          itemlen;               /* Length of one item              */
  85.   char          *pattern;               /* Buffer to store match chars     */
  86.   short          pindex;                /* Index into pattern buffer       */
  87.   WINDOW        *win;                   /* Window containing menu          */
  88.   WINDOW        *sub;                   /* Subwindow for menu display      */
  89.   WINDOW        *userwin;               /* User's window                   */
  90.   WINDOW        *usersub;               /* User's subwindow                */
  91.   ITEM          **items;                /* array of items                  */ 
  92.   short          nitems;                /* Nr. of items in menu            */
  93.   ITEM          *curitem;               /* Current item                    */
  94.   short          toprow;                /* Top row of menu                 */
  95.   chtype         fore;                  /* Selection attribute             */
  96.   chtype         back;                  /* Nonselection attribute          */
  97.   chtype         grey;                  /* Inactive attribute              */
  98.   unsigned char  pad;                   /* Pad character                   */
  99.  
  100.   Menu_Hook      menuinit;              /* User hooks                      */
  101.   Menu_Hook      menuterm;
  102.   Menu_Hook      iteminit;
  103.   Menu_Hook      itemterm;
  104.  
  105.   void          *userptr;               /* Pointer to menus user data      */
  106.   char          *mark;                  /* Pointer to marker string        */
  107.  
  108.   Menu_Options   opt;                   /* Menu options                    */
  109.   unsigned short status;                /* Internal state of menu          */
  110.  
  111. } MENU;
  112.  
  113.  
  114. /* Define keys */
  115.  
  116. #define REQ_LEFT_ITEM           (KEY_MAX + 1)
  117. #define REQ_RIGHT_ITEM          (KEY_MAX + 2)
  118. #define REQ_UP_ITEM             (KEY_MAX + 3)
  119. #define REQ_DOWN_ITEM           (KEY_MAX + 4)
  120. #define REQ_SCR_ULINE           (KEY_MAX + 5)
  121. #define REQ_SCR_DLINE           (KEY_MAX + 6)
  122. #define REQ_SCR_DPAGE           (KEY_MAX + 7)
  123. #define REQ_SCR_UPAGE           (KEY_MAX + 8)
  124. #define REQ_FIRST_ITEM          (KEY_MAX + 9)
  125. #define REQ_LAST_ITEM           (KEY_MAX + 10)
  126. #define REQ_NEXT_ITEM           (KEY_MAX + 11)
  127. #define REQ_PREV_ITEM           (KEY_MAX + 12)
  128. #define REQ_TOGGLE_ITEM         (KEY_MAX + 13)
  129. #define REQ_CLEAR_PATTERN       (KEY_MAX + 14)
  130. #define REQ_BACK_PATTERN        (KEY_MAX + 15)
  131. #define REQ_NEXT_MATCH          (KEY_MAX + 16)
  132. #define REQ_PREV_MATCH          (KEY_MAX + 17)
  133. #define MAX_MENU_COMMAND        (KEY_MAX + 17)
  134.  
  135. /*
  136.  * Some AT&T code expects MAX_COMMAND to be out-of-band not
  137.  * just for meny commands but for forms ones as well.
  138.  */
  139. #define MAX_COMMAND             (KEY_MAX + 128)
  140.  
  141. /* --------- prototypes for libmenu functions ----------------------------- */
  142.  
  143. extern ITEM     **menu_items(const MENU *),
  144.                 *current_item(const MENU *),
  145.                 *new_item(char *,char *);
  146.  
  147. extern MENU     *new_menu(ITEM **);
  148.  
  149. extern Item_Options  item_opts(const ITEM *);
  150. extern Menu_Options  menu_opts(const MENU *);
  151.  
  152. Menu_Hook       item_init(const MENU *),
  153.                 item_term(const MENU *),
  154.                 menu_init(const MENU *),
  155.                 menu_term(const MENU *);
  156.  
  157. extern WINDOW   *menu_sub(const MENU *),
  158.                 *menu_win(const MENU *);
  159.  
  160. extern char     *item_description(const ITEM *),
  161.                 *item_name(const ITEM *),
  162.                 *menu_mark(const MENU *),
  163.                 *menu_pattern(const MENU *);
  164.  
  165. extern char     *item_userptr(const ITEM *),
  166.                 *menu_userptr(const MENU *);
  167.   
  168. extern chtype   menu_back(const MENU *),
  169.                 menu_fore(const MENU *),
  170.                 menu_grey(const MENU *);
  171.  
  172. extern int      free_item(ITEM *),
  173.                 free_menu(MENU *),
  174.                 item_count(const MENU *),
  175.                 item_index(const ITEM *),
  176.                 item_opts_off(ITEM *,Item_Options),
  177.                 item_opts_on(ITEM *,Item_Options),
  178.                 menu_driver(MENU *,int),
  179.                 menu_opts_off(MENU *,Menu_Options),
  180.                 menu_opts_on(MENU *,Menu_Options),
  181.                 menu_pad(const MENU *),
  182.                 pos_menu_cursor(const MENU *),
  183.                 post_menu(MENU *),
  184.                 scale_menu(const MENU *,int *,int *),
  185.                 set_current_item(MENU *menu,ITEM *item),
  186.                 set_item_init(MENU *,void(*)(MENU *)),
  187.                 set_item_opts(ITEM *,Item_Options),
  188.                 set_item_term(MENU *,void(*)(MENU *)),
  189.                 set_item_userptr(ITEM *, char *),
  190.                 set_item_value(ITEM *,bool),
  191.                 set_menu_back(MENU *,chtype),
  192.                 set_menu_fore(MENU *,chtype),
  193.                 set_menu_format(MENU *,int,int),
  194.                 set_menu_grey(MENU *,chtype),
  195.                 set_menu_init(MENU *,void(*)(MENU *)),
  196.                 set_menu_items(MENU *,ITEM **),
  197.                 set_menu_mark(MENU *, char *),
  198.                 set_menu_opts(MENU *,Menu_Options),
  199.                 set_menu_pad(MENU *,int),
  200.                 set_menu_pattern(MENU *,const char *),
  201.                 set_menu_sub(MENU *,WINDOW *),
  202.                 set_menu_term(MENU *,void(*)(MENU *)),
  203.                 set_menu_userptr(MENU *,char *),
  204.                 set_menu_win(MENU *,WINDOW *),
  205.                 set_top_row(MENU *,int),
  206.                 top_row(const MENU *),
  207.                 unpost_menu(MENU *);
  208.  
  209. extern bool     item_value(const ITEM *),
  210.                 item_visible(const ITEM *);
  211.  
  212. void            menu_format(const MENU *,int *,int *);
  213.  
  214. #ifdef __cplusplus
  215.   }
  216. #endif
  217.  
  218. #endif /* ETI_MENU */
  219.