home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 301_01 / menu.h < prev    next >
C/C++ Source or Header  |  1989-12-30  |  4KB  |  121 lines

  1. typedef void fn();
  2.  
  3. /* check malloc's answer, if no memory then exit graphics before aborting */
  4.  
  5. void *g_malloc(int siz);
  6.  
  7.  
  8. extern struct submenu *rootmenu;
  9. extern long int the_key;        /* function key value */
  10. extern int keys_ptr;            /* key stack depth */
  11.  
  12. void get_stack_key();
  13. long int lkeyof(char ch);
  14.  
  15. /* define how to wait for keys */
  16. void wait_key(fn funct);
  17.  
  18.  
  19. struct submenu {
  20.     unsigned char direction;    /* HORIZONTAL, VERTICAL, INVISIBLE */
  21.     long int choicekey;    /* simple key to activate this submenu */
  22.     int lastchoice;    /* offset of last submenu of this menu that was used */
  23.     char *shortname;    /* name of this menu/function */
  24.     char *longname;
  25.     fn *funct;
  26.     struct submenu *next;    /* right pointer */
  27.     struct submenu *prev;    /* left pointer */
  28.     struct submenu *sub;    /* down pointer */
  29.     struct submenu *esc;    /* up pointer */
  30.     int belowx, belowy;    /* where longname would be put for submenu */
  31.     int sizex, sizey;    /* graphics size of shortname */
  32. };
  33.  
  34. void def_submenu(char choice, char *shortname, char *longname);
  35. void endef_submenu(char *matchshort); /* repeat shortname to match & debug */
  36. void def_entry(char choice, char *shortname, fn funct );
  37. void menu_fn(fn funct );
  38. void menu_horizontal();
  39. void menu_invisible();
  40.  
  41. void nofn();        /* default function does nothing */
  42.  
  43. #define MAXKEYS 500
  44.  
  45.  
  46.  
  47. /* This routine allows the user to define a function-key.
  48.    The keynum is "made up" by the user.
  49.    It is a value between 1 and MAXKEYS and is used to match a keyboard entry
  50.    to the key.
  51.  
  52.    The keyboard entry assigned to this function key is passed as an ASCII name.
  53.    The name for this keyboard entry is passed as keyname.  
  54.    Any value may be entered and the fkey may be
  55.    re-defined later and saved in a config. file.
  56.  
  57.    From now on, whenever keyname is typed on the keyboard, fkey will be 
  58.    returned as a value.  The name of fkey is fkeyname.
  59. */ 
  60. int def_fkey(int fkey, char *keyname, char *fkeyname);
  61.  
  62.  
  63. /* define a user defined key as being a 'hot' key.
  64.    Whenever the key is encountered by the decoding routine, the
  65.    given function will be executed.
  66. */
  67. void hot_key(int keynum, fn funct);
  68.  
  69. /* close down the graphics system 
  70.    print an error message
  71.    stop the program.
  72. */
  73. void g_failure(char *text);
  74.  
  75. void user_menus();    /* this is defined by the user */
  76.  
  77. /* function to initialize the graphics system for whatever hardware
  78.    the user's computer happens to have.
  79.    Used by restorescr() to 'undo' the effect of closegraph() from savescr();
  80.    Something like this should be called by the user before menu_init() to turn
  81.    on the graphics system.
  82. */
  83. void initgr();
  84. /* This is called after initgr() or some equivalent to it.
  85.    This must be called before *ANYTHING* else may be called. 
  86. */
  87. void menu_init();
  88.  
  89.  
  90.  
  91. void menu_run();        /* how to run the menu system */
  92.  
  93.  
  94. /* save and restore graphics screen */
  95. void savescr();
  96. void restorescr();
  97. void initgr();
  98.  
  99. /* Get a key from the stack.
  100.    Check to see if it is a hot key, if so do it's routine.
  101.    Save key value in global location.
  102. */
  103. void call_for_key(struct submenu *cursor);
  104.  
  105.  
  106. /* routine to print a text in a box
  107.    The text will have BOX_X-1 pixels between it and the horiz. walls.
  108.    The text will have BOX_Y-1 pixels between it and the vert. walls.
  109.    The text will be white pixels on a black background.
  110. */
  111. void boxtext(int x, int y, char *data);
  112.  
  113.  
  114. /* 1=key available
  115.    0=no key pending
  116. */
  117. int keyready();
  118.  
  119.  
  120.  
  121.