/*
  listing 2 - menu.h
*/

/* screen dimensions*/
#define MAX_ROWS 24
#define MAX_COLUMNS 80

/* keystroke codes and color */
#ifdef HPUX
#define UP_ARROW 	3
#define DOWN_ARROW	2
#define LEFT_ARROW 	4
#define RIGHT_ARROW 	5
#define RETURN		10
#define ESCAPE		27
#endif
#ifdef SUN
#define UP_ARROW 	65
#define DOWN_ARROW	66
#define LEFT_ARROW 	68
#define RIGHT_ARROW 	67
#define RETURN		10
#define ESCAPE		27
#endif
#ifdef VMS
#define UP_ARROW 	274 
#define DOWN_ARROW	275
#define LEFT_ARROW 	276
#define RIGHT_ARROW 	277
#define RETURN		13
#define ESCAPE		291 /* F11 */
#endif
#ifdef BCC
#define MAINCOLOR 	(F_RED | B_BLACK)
#define DIALOGCOLOR	(F_CYAN | B_BLACK)
#define UP_ARROW 	56
#define DOWN_ARROW	50
#define LEFT_ARROW 	52
#define RIGHT_ARROW 	54
#define	RETURN		10
#define ESCAPE		27
#endif

/* macros for portability */
#ifndef VMS
#define BEGX _begx
#define BEGY _begy
#define MAXX _maxx
#else
#define BEGX _beg_x
#define BEGY _beg_y
#define MAXX _max_x
#endif

/* box characters */

#ifdef BCC
#define SINGLE_SIDE   -77 /* single bar */
#define SINGLE_ACROSS -60
#define DOUBLE_SIDE   -70 /* double bar */
#define DOUBLE_ACROSS -51
#else
#define SINGLE_SIDE   '|'
#define SINGLE_ACROSS '-'
#define DOUBLE_SIDE   '"'
#define DOUBLE_ACROSS '='
#endif

#define TCHOICES 3

/* menubar structure */
typedef struct mbar {
	char string[80];
	char letter;
	int pos;
}MENUBAR;

/* pulldown menu choices */
typedef struct choices {
	char string[20];
	char letter;
	int (*funcptr)();
} CHOICES;

/* pulldown menu structure */
typedef struct pmenu {
	int num;
	int maxlength;
	CHOICES *ptr;
} PULLDOWN;

/* prototypes */
WINDOW *topbar(WINDOW *);
WINDOW *pulldown(int,int,int,int);
WINDOW *popup(int,int,int,int);
void move_window(WINDOW *win,int y, int x);
void print_string(WINDOW *,int, int, char *);
void erase_window(WINDOW *);
void delete_window(WINDOW *);
void refresh_window(WINDOW *);
int to_dialogue(char *);
void clear_dialogue(void);
void touch_window(WINDOW *);
char *strmenu(int, MENUBAR *, int);
char menu_choice(char *);
int clean_up(void);
void repaint(void);
char do_pulldown(int,PULLDOWN *, MENUBAR *);
void set_stdscr(void);
void execute_command(int, int, PULLDOWN *);
char do_menubar(WINDOW *, MENUBAR *);
void strtoupper(char *);
void strtolower(char *);
void set_stdscr(void);
char get_keystroke(void);
