1/**************************************************************************** 2 * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. * 3 * * 4 * Permission is hereby granted, free of charge, to any person obtaining a * 5 * copy of this software and associated documentation files (the * 6 * "Software"), to deal in the Software without restriction, including * 7 * without limitation the rights to use, copy, modify, merge, publish, * 8 * distribute, distribute with modifications, sublicense, and/or sell * 9 * copies of the Software, and to permit persons to whom the Software is * 10 * furnished to do so, subject to the following conditions: * 11 * * 12 * The above copyright notice and this permission notice shall be included * 13 * in all copies or substantial portions of the Software. * 14 * * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22 * * 23 * Except as contained in this notice, the name(s) of the above copyright * 24 * holders shall not be used in advertising or otherwise to promote the * 25 * sale, use or other dealings in this Software without prior written * 26 * authorization. * 27 ****************************************************************************/ 28 29/**************************************************************************** 30 * Author: Juergen Pfeifer, 1995,1997 * 31 ****************************************************************************/ 32 33/* $Id: menu.h,v 1.19 2007/02/24 17:32:13 tom Exp $ */ 34 35#ifndef ETI_MENU 36#define ETI_MENU 37 38#ifdef AMIGA 39#define TEXT TEXT_ncurses 40#endif 41 42#include <curses.h> 43#include <eti.h> 44 45#ifdef __cplusplus 46extern "C" { 47#endif 48 49typedef int Menu_Options; 50typedef int Item_Options; 51 52/* Menu options: */ 53#define O_ONEVALUE (0x01) 54#define O_SHOWDESC (0x02) 55#define O_ROWMAJOR (0x04) 56#define O_IGNORECASE (0x08) 57#define O_SHOWMATCH (0x10) 58#define O_NONCYCLIC (0x20) 59 60/* Item options: */ 61#define O_SELECTABLE (0x01) 62 63typedef struct 64{ 65 const char* str; 66 unsigned short length; 67} TEXT; 68 69typedef struct tagITEM 70{ 71 TEXT name; /* name of menu item */ 72 TEXT description; /* description of item, optional in display */ 73 struct tagMENU *imenu; /* Pointer to parent menu */ 74 void *userptr; /* Pointer to user defined per item data */ 75 Item_Options opt; /* Item options */ 76 short index; /* Item number if connected to a menu */ 77 short y; /* y and x location of item in menu */ 78 short x; 79 bool value; /* Selection value */ 80 81 struct tagITEM *left; /* neighbor items */ 82 struct tagITEM *right; 83 struct tagITEM *up; 84 struct tagITEM *down; 85 86} ITEM; 87 88typedef void (*Menu_Hook)(struct tagMENU *); 89 90typedef struct tagMENU 91{ 92 short height; /* Nr. of chars high */ 93 short width; /* Nr. of chars wide */ 94 short rows; /* Nr. of items high */ 95 short cols; /* Nr. of items wide */ 96 short frows; /* Nr. of formatted items high */ 97 short fcols; /* Nr. of formatted items wide */ 98 short arows; /* Nr. of items high (actual) */ 99 short namelen; /* Max. name length */ 100 short desclen; /* Max. description length */ 101 short marklen; /* Length of mark, if any */ 102 short itemlen; /* Length of one item */ 103 short spc_desc; /* Spacing for descriptor */ 104 short spc_cols; /* Spacing for columns */ 105 short spc_rows; /* Spacing for rows */ 106 char *pattern; /* Buffer to store match chars */ 107 short pindex; /* Index into pattern buffer */ 108 WINDOW *win; /* Window containing menu */ 109 WINDOW *sub; /* Subwindow for menu display */ 110 WINDOW *userwin; /* User's window */ 111 WINDOW *usersub; /* User's subwindow */ 112 ITEM **items; /* array of items */ 113 short nitems; /* Nr. of items in menu */ 114 ITEM *curitem; /* Current item */ 115 short toprow; /* Top row of menu */ 116 chtype fore; /* Selection attribute */ 117 chtype back; /* Nonselection attribute */ 118 chtype grey; /* Inactive attribute */ 119 unsigned char pad; /* Pad character */ 120 121 Menu_Hook menuinit; /* User hooks */ 122 Menu_Hook menuterm; 123 Menu_Hook iteminit; 124 Menu_Hook itemterm; 125 126 void *userptr; /* Pointer to menus user data */ 127 char *mark; /* Pointer to marker string */ 128 129 Menu_Options opt; /* Menu options */ 130 unsigned short status; /* Internal state of menu */ 131 132} MENU; 133 134 135/* Define keys */ 136 137#define REQ_LEFT_ITEM (KEY_MAX + 1) 138#define REQ_RIGHT_ITEM (KEY_MAX + 2) 139#define REQ_UP_ITEM (KEY_MAX + 3) 140#define REQ_DOWN_ITEM (KEY_MAX + 4) 141#define REQ_SCR_ULINE (KEY_MAX + 5) 142#define REQ_SCR_DLINE (KEY_MAX + 6) 143#define REQ_SCR_DPAGE (KEY_MAX + 7) 144#define REQ_SCR_UPAGE (KEY_MAX + 8) 145#define REQ_FIRST_ITEM (KEY_MAX + 9) 146#define REQ_LAST_ITEM (KEY_MAX + 10) 147#define REQ_NEXT_ITEM (KEY_MAX + 11) 148#define REQ_PREV_ITEM (KEY_MAX + 12) 149#define REQ_TOGGLE_ITEM (KEY_MAX + 13) 150#define REQ_CLEAR_PATTERN (KEY_MAX + 14) 151#define REQ_BACK_PATTERN (KEY_MAX + 15) 152#define REQ_NEXT_MATCH (KEY_MAX + 16) 153#define REQ_PREV_MATCH (KEY_MAX + 17) 154 155#define MIN_MENU_COMMAND (KEY_MAX + 1) 156#define MAX_MENU_COMMAND (KEY_MAX + 17) 157 158/* 159 * Some AT&T code expects MAX_COMMAND to be out-of-band not 160 * just for menu commands but for forms ones as well. 161 */ 162#if defined(MAX_COMMAND) 163# if (MAX_MENU_COMMAND > MAX_COMMAND) 164# error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND 165# elif (MAX_COMMAND != (KEY_MAX + 128)) 166# error Something is wrong -- MAX_COMMAND is already inconsistently defined. 167# endif 168#else 169# define MAX_COMMAND (KEY_MAX + 128) 170#endif 171 172 173/* --------- prototypes for libmenu functions ----------------------------- */ 174 175extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *); 176extern NCURSES_EXPORT(ITEM *) current_item (const MENU *); 177extern NCURSES_EXPORT(ITEM *) new_item (const char *,const char *); 178 179extern NCURSES_EXPORT(MENU *) new_menu (ITEM **); 180 181extern NCURSES_EXPORT(Item_Options) item_opts (const ITEM *); 182extern NCURSES_EXPORT(Menu_Options) menu_opts (const MENU *); 183 184extern NCURSES_EXPORT(Menu_Hook) item_init (const MENU *); 185extern NCURSES_EXPORT(Menu_Hook) item_term (const MENU *); 186extern NCURSES_EXPORT(Menu_Hook) menu_init (const MENU *); 187extern NCURSES_EXPORT(Menu_Hook) menu_term (const MENU *); 188 189extern NCURSES_EXPORT(WINDOW *) menu_sub (const MENU *); 190extern NCURSES_EXPORT(WINDOW *) menu_win (const MENU *); 191 192extern NCURSES_EXPORT(const char *) item_description (const ITEM *); 193extern NCURSES_EXPORT(const char *) item_name (const ITEM *); 194extern NCURSES_EXPORT(const char *) menu_mark (const MENU *); 195extern NCURSES_EXPORT(const char *) menu_request_name (int); 196 197extern NCURSES_EXPORT(char *) menu_pattern (const MENU *); 198 199extern NCURSES_EXPORT(void *) menu_userptr (const MENU *); 200extern NCURSES_EXPORT(void *) item_userptr (const ITEM *); 201 202extern NCURSES_EXPORT(chtype) menu_back (const MENU *); 203extern NCURSES_EXPORT(chtype) menu_fore (const MENU *); 204extern NCURSES_EXPORT(chtype) menu_grey (const MENU *); 205 206extern NCURSES_EXPORT(int) free_item (ITEM *); 207extern NCURSES_EXPORT(int) free_menu (MENU *); 208extern NCURSES_EXPORT(int) item_count (const MENU *); 209extern NCURSES_EXPORT(int) item_index (const ITEM *); 210extern NCURSES_EXPORT(int) item_opts_off (ITEM *,Item_Options); 211extern NCURSES_EXPORT(int) item_opts_on (ITEM *,Item_Options); 212extern NCURSES_EXPORT(int) menu_driver (MENU *,int); 213extern NCURSES_EXPORT(int) menu_opts_off (MENU *,Menu_Options); 214extern NCURSES_EXPORT(int) menu_opts_on (MENU *,Menu_Options); 215extern NCURSES_EXPORT(int) menu_pad (const MENU *); 216extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *); 217extern NCURSES_EXPORT(int) post_menu (MENU *); 218extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *); 219extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item); 220extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook); 221extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options); 222extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook); 223extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *); 224extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool); 225extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype); 226extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype); 227extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int); 228extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype); 229extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook); 230extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **); 231extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *); 232extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options); 233extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int); 234extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *); 235extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *); 236extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook); 237extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *); 238extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *); 239extern NCURSES_EXPORT(int) set_top_row (MENU *,int); 240extern NCURSES_EXPORT(int) top_row (const MENU *); 241extern NCURSES_EXPORT(int) unpost_menu (MENU *); 242extern NCURSES_EXPORT(int) menu_request_by_name (const char *); 243extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int); 244extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *); 245 246 247extern NCURSES_EXPORT(bool) item_value (const ITEM *); 248extern NCURSES_EXPORT(bool) item_visible (const ITEM *); 249 250extern NCURSES_EXPORT(void) menu_format (const MENU *,int *,int *); 251 252#ifdef __cplusplus 253 } 254#endif 255 256#endif /* ETI_MENU */ 257