| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 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 |
#include <ncurses_cfg.h> |
| 45 |
|
| 46 |
#ifdef __cplusplus |
| 47 |
extern "C" { |
| 48 |
#endif |
| 49 |
|
| 50 |
typedef int Menu_Options; |
| 51 |
typedef int Item_Options; |
| 52 |
|
| 53 |
|
| 54 |
#define O_ONEVALUE (0x01) |
| 55 |
#define O_SHOWDESC (0x02) |
| 56 |
#define O_ROWMAJOR (0x04) |
| 57 |
#define O_IGNORECASE (0x08) |
| 58 |
#define O_SHOWMATCH (0x10) |
| 59 |
#define O_NONCYCLIC (0x20) |
| 60 |
|
| 61 |
|
| 62 |
#define O_SELECTABLE (0x01) |
| 63 |
|
| 64 |
typedef struct |
| 65 |
{ |
| 66 |
const char* str; |
| 67 |
unsigned short length; |
| 68 |
} TEXT; |
| 69 |
|
| 70 |
typedef struct tagITEM |
| 71 |
{ |
| 72 |
TEXT name; |
| 73 |
TEXT description; |
| 74 |
struct tagMENU *imenu; |
| 75 |
void *userptr; |
| 76 |
Item_Options opt; |
| 77 |
short index; |
| 78 |
short y; |
| 79 |
short x; |
| 80 |
bool value; |
| 81 |
|
| 82 |
struct tagITEM *left; |
| 83 |
struct tagITEM *right; |
| 84 |
struct tagITEM *up; |
| 85 |
struct tagITEM *down; |
| 86 |
|
| 87 |
} ITEM; |
| 88 |
|
| 89 |
typedef void (*Menu_Hook)(struct tagMENU *); |
| 90 |
|
| 91 |
typedef struct tagMENU |
| 92 |
{ |
| 93 |
short height; |
| 94 |
short width; |
| 95 |
short rows; |
| 96 |
short cols; |
| 97 |
short frows; |
| 98 |
short fcols; |
| 99 |
short arows; |
| 100 |
short namelen; |
| 101 |
short desclen; |
| 102 |
short marklen; |
| 103 |
short itemlen; |
| 104 |
short spc_desc; |
| 105 |
short spc_cols; |
| 106 |
short spc_rows; |
| 107 |
char *pattern; |
| 108 |
short pindex; |
| 109 |
WINDOW *win; |
| 110 |
WINDOW *sub; |
| 111 |
WINDOW *userwin; |
| 112 |
WINDOW *usersub; |
| 113 |
ITEM **items; |
| 114 |
short nitems; |
| 115 |
ITEM *curitem; |
| 116 |
short toprow; |
| 117 |
chtype fore; |
| 118 |
chtype back; |
| 119 |
chtype grey; |
| 120 |
unsigned char pad; |
| 121 |
|
| 122 |
Menu_Hook menuinit; |
| 123 |
Menu_Hook menuterm; |
| 124 |
Menu_Hook iteminit; |
| 125 |
Menu_Hook itemterm; |
| 126 |
|
| 127 |
void *userptr; |
| 128 |
char *mark; |
| 129 |
|
| 130 |
Menu_Options opt; |
| 131 |
unsigned short status; |
| 132 |
|
| 133 |
} MENU; |
| 134 |
|
| 135 |
|
| 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 |
|
| 160 |
|
| 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 |
|
| 174 |
extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *); |
| 175 |
extern NCURSES_EXPORT(ITEM *) current_item (const MENU *); |
| 176 |
extern NCURSES_EXPORT(ITEM *) new_item (const char *,const char *); |
| 177 |
|
| 178 |
extern NCURSES_EXPORT(MENU *) new_menu (ITEM **); |
| 179 |
|
| 180 |
extern NCURSES_EXPORT(Item_Options) item_opts (const ITEM *); |
| 181 |
extern NCURSES_EXPORT(Menu_Options) menu_opts (const MENU *); |
| 182 |
|
| 183 |
extern NCURSES_EXPORT(Menu_Hook) item_init (const MENU *); |
| 184 |
extern NCURSES_EXPORT(Menu_Hook) item_term (const MENU *); |
| 185 |
extern NCURSES_EXPORT(Menu_Hook) menu_init (const MENU *); |
| 186 |
extern NCURSES_EXPORT(Menu_Hook) menu_term (const MENU *); |
| 187 |
|
| 188 |
extern NCURSES_EXPORT(WINDOW *) menu_sub (const MENU *); |
| 189 |
extern NCURSES_EXPORT(WINDOW *) menu_win (const MENU *); |
| 190 |
|
| 191 |
extern NCURSES_EXPORT(const char *) item_description (const ITEM *); |
| 192 |
extern NCURSES_EXPORT(const char *) item_name (const ITEM *); |
| 193 |
extern NCURSES_EXPORT(const char *) menu_mark (const MENU *); |
| 194 |
extern NCURSES_EXPORT(const char *) menu_request_name (int); |
| 195 |
|
| 196 |
extern NCURSES_EXPORT(char *) menu_pattern (const MENU *); |
| 197 |
|
| 198 |
extern NCURSES_EXPORT(void *) menu_userptr (const MENU *); |
| 199 |
extern NCURSES_EXPORT(void *) item_userptr (const ITEM *); |
| 200 |
|
| 201 |
extern NCURSES_EXPORT(chtype) menu_back (const MENU *); |
| 202 |
extern NCURSES_EXPORT(chtype) menu_fore (const MENU *); |
| 203 |
extern NCURSES_EXPORT(chtype) menu_grey (const MENU *); |
| 204 |
|
| 205 |
extern NCURSES_EXPORT(int) free_item (ITEM *); |
| 206 |
extern NCURSES_EXPORT(int) free_menu (MENU *); |
| 207 |
extern NCURSES_EXPORT(int) item_count (const MENU *); |
| 208 |
extern NCURSES_EXPORT(int) item_index (const ITEM *); |
| 209 |
extern NCURSES_EXPORT(int) item_opts_off (ITEM *,Item_Options); |
| 210 |
extern NCURSES_EXPORT(int) item_opts_on (ITEM *,Item_Options); |
| 211 |
extern NCURSES_EXPORT(int) menu_driver (MENU *,int); |
| 212 |
extern NCURSES_EXPORT(int) menu_opts_off (MENU *,Menu_Options); |
| 213 |
extern NCURSES_EXPORT(int) menu_opts_on (MENU *,Menu_Options); |
| 214 |
extern NCURSES_EXPORT(int) menu_pad (const MENU *); |
| 215 |
extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *); |
| 216 |
extern NCURSES_EXPORT(int) post_menu (MENU *); |
| 217 |
extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *); |
| 218 |
extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item); |
| 219 |
extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook); |
| 220 |
extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options); |
| 221 |
extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook); |
| 222 |
extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *); |
| 223 |
extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool); |
| 224 |
extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype); |
| 225 |
extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype); |
| 226 |
extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int); |
| 227 |
extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype); |
| 228 |
extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook); |
| 229 |
extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **); |
| 230 |
extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *); |
| 231 |
extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options); |
| 232 |
extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int); |
| 233 |
extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *); |
| 234 |
extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *); |
| 235 |
extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook); |
| 236 |
extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *); |
| 237 |
extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *); |
| 238 |
extern NCURSES_EXPORT(int) set_top_row (MENU *,int); |
| 239 |
extern NCURSES_EXPORT(int) top_row (const MENU *); |
| 240 |
extern NCURSES_EXPORT(int) unpost_menu (MENU *); |
| 241 |
extern NCURSES_EXPORT(int) menu_request_by_name (const char *); |
| 242 |
extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int); |
| 243 |
extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *); |
| 244 |
|
| 245 |
extern NCURSES_EXPORT(bool) item_value (const ITEM *); |
| 246 |
extern NCURSES_EXPORT(bool) item_visible (const ITEM *); |
| 247 |
|
| 248 |
extern NCURSES_EXPORT(void) menu_format (const MENU *,int *,int *); |
| 249 |
|
| 250 |
#if NCURSES_SP_FUNCS |
| 251 |
extern NCURSES_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN*, ITEM **); |
| 252 |
#endif |
| 253 |
|
| 254 |
#ifdef __cplusplus |
| 255 |
} |
| 256 |
#endif |
| 257 |
|
| 258 |
#endif |