1 /*
2    menuitem.h
3    Copyright (c) 1999-2002 Perry Rapp
4    "The MIT license"
5    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 */
9 /*
10  menuitem.h - declarations for menuset, dynmenu, brwsmenu, & all command constants
11   Created in 1999/03 private build of LifeLines
12   Added to repository during 3.0.6 development
13 */
14 
15 #ifndef _MENUITEM_H
16 #define _MENUITEM_H
17 
18 #define MAIN_SCREEN        1
19 #define ONE_PER_SCREEN     2
20 #define ONE_FAM_SCREEN     3
21 #define TWO_PER_SCREEN     4
22 #define TWO_FAM_SCREEN     5
23 #define LIST_SCREEN        7
24 #define AUX_SCREEN         8
25 /* must be at bottom of list */
26 #define MAX_SCREEN         8
27 
28 
29 /*
30   Each menu item has display text and selection character(s)
31   If Choices is 0 (as it is for all as of 2002.01), then the
32   first characters of Display up to whitespace are used for the
33   choice characters, eg, "f  Browse to fathers"
34   NB: The direct-to-child item is specially coded to use digits 1-9,
35   and does not use the Choices string.
36 */
37 typedef struct MenuItem_s {
38 	STRING Display;
39 	STRING Choices;
40 	INT Command;
41 	STRING LocalizedDisplay;
42 } MenuItem;
43 /*
44 A LongDisplay could be added (for, eg, status bar,
45 or for some type of extended command info display).
46 - Perry Rapp, 2001/02/10
47 */
48 /*
49 typedef struct MenuItemOption_struct {
50 	STRING Display1;
51 	STRING Display2;
52 	STRING Choices;
53 	INT Command;
54 } MenuItemOption;
55 */
56 
57 
58 /* special menu items added on the fly */
59 extern MenuItem g_MenuItemOther, g_MenuItemQuit;
60 /* this is for navigating top & bottom simultaneously
61 in tandem screens, and is not implemented in this version! */
62 extern MenuItem f_MenuItemSyncMoves;
63 
64 typedef struct tag_cmdarray * CMDARRAY;
65 
66 /* One set of menus */
67 /* This is the dynamically resizable menu system */
68 /* Currently used only by browse screens, not list screens or main menus */
69 /* need to move most of this into layout structure, & out of here, as it is only for curses */
70 struct tag_menuset {
71 	CMDARRAY Commands;
72 	MenuItem ** items;  /* array of pointers to items */
73 };
74 typedef struct tag_menuset *MENUSET;
75 
76 
77 
78 /* dynamically resizing & pageable menu */
79 struct tag_dynmenu {
80 	struct tag_menuset menuset;
81 	INT rows;      /* height of menu (at start) */
82 	INT cols;      /* (menu) columns in this menu (3 for big, 1 for list) */
83 	INT size;      /* total #items in this menu */
84 	INT page;      /* which page of menu currently displayed */
85 	INT pages;     /* # of pages total */
86 	INT pageitems; /* # of items per page */
87 	INT mincols;   /* minimum width in colums*/
88 	INT maxcols;   /* maximum width in columns */
89 	INT minrows;   /* minimum height */
90 	INT maxrows;   /* maximum height */
91 	INT hidden;    /* for hideable menus */
92 	INT dirty;     /* for repainting code */
93 	/* character coordinates of menu size & location */
94 	INT top;
95 	INT bottom;
96 	INT left;
97 	INT width;
98 	INT cur_y;     /* row for input cursor */
99 	INT cur_x;     /* col for input cursor */
100 };
101 typedef struct tag_dynmenu *DYNMENU;
102 
103 
104 /*
105 global array of menu information, produced by menuitem.c
106 and used by both screen.c and menuitem.c
107 */
108 
109 /* menuset.c */
110 void menuset_init(MENUSET menu, STRING title, MenuItem ** MenuItems, MenuItem ** extraItems);
111 INT menuset_check_cmd(MENUSET menuset, STRING str);
112 void menuset_clear(MENUSET menuset);
113 MenuItem ** menuset_get_items(MENUSET menuset);
114 
115 /* dynmenu.c */
116 void dynmenu_adjust_height(DYNMENU dynmenu, INT delta);
117 void dynmenu_adjust_menu_cols(DYNMENU dynmenu, INT delta);
118 void dynmenu_clear(DYNMENU dynmenu);
119 MENUSET dynmenu_get_menuset(DYNMENU dynmenu);
120 void dynmenu_init(DYNMENU dynmenu , STRING title, INT MenuRows, INT MenuCols
121 	, INT MinCols, INT MaxCols
122 	, INT MinRows, INT MaxRows
123 	, INT MenuTop, INT MenuLeft, INT MenuWidth
124 	, INT MenuSize, MenuItem ** MenuItems);
125 void dynmenu_next_page(DYNMENU dynmenu);
126 void dynmenu_toggle_menu(DYNMENU dynmenu);
127 
128 /* brwsmenu.c */
129 MENUSET get_screen_menuset(INT screen);
130 DYNMENU get_screen_dynmenu(INT screen);
131 STRING get_screen_title(INT screen);
132 void brwsmenu_initialize(INT screenheight, INT screenwidth);
133 
134 
135 void menuitem_initialize(INT cols);
136 void menuitem_terminate(void);
137 INT menuitem_check_cmd(INT screen, STRING cmd);
138 
139 enum {
140 	CMD_NONE /* unrecognized or unimplemented */
141 	, CMD_PARTIAL /* part of a multichar sequence */
142 	, CMD_QUIT, CMD_MENU_MORE, CMD_MENU_TOGGLE
143 	, CMD_MENU_GROW, CMD_MENU_SHRINK, CMD_MENU_MORECOLS, CMD_MENU_LESSCOLS
144 	, CMD_EDIT, CMD_PERSON, CMD_FATHER
145 	, CMD_MOTHER, CMD_SPOUSE, CMD_CHILDREN, CMD_UPSIB, CMD_DOWNSIB
146 	, CMD_FAMILY, CMD_PARENTS, CMD_BROWSE
147 	, CMD_TOP, CMD_BOTTOM, CMD_ADDASSPOUSE, CMD_ADDASCHILD
148 	, CMD_ADDSPOUSE, CMD_ADDCHILD, CMD_ADDFAMILY, CMD_PEDIGREE
149 	, CMD_SWAPFAMILIES, CMD_SWAPCHILDREN, CMD_SWAPTOPBOTTOM
150 	, CMD_REORDERCHILD
151 	, CMD_NEWPERSON, CMD_NEWFAMILY, CMD_TANDEM
152 	, CMD_REMOVEASSPOUSE, CMD_REMOVEASCHILD, CMD_REMOVESPOUSE, CMD_REMOVECHILD
153 	, CMD_SOURCES, CMD_NOTES, CMD_POINTERS
154 /*	, CMD_SHOWSOURCES, CMD_HIDESOURCES*/
155 	, CMD_SCROLL_UP, CMD_SCROLL_DOWN, CMD_DEPTH_UP, CMD_DEPTH_DOWN
156 	, CMD_NEXT, CMD_PREV, CMD_BROWSE_ZIP_INDI, CMD_BROWSE_ZIP_ANY
157 	, CMD_ADVANCED
158 	, CMD_SCROLL_TOP_UP, CMD_SCROLL_TOP_DOWN
159 	, CMD_SCROLL_BOTTOM_UP , CMD_SCROLL_BOTTOM_DOWN
160 	, CMD_SCROLL_BOTH_UP, CMD_SCROLL_BOTH_DOWN
161 	, CMD_MODE_GEDCOM, CMD_MODE_GEDCOMX, CMD_MODE_GEDCOMT
162 	, CMD_MODE_ANCESTORS , CMD_MODE_DESCENDANTS
163 	, CMD_MODE_NORMAL, CMD_MODE_CYCLE
164 	, CMD_MODE_PEDIGREE
165 	, CMD_TANDEM_CHILDREN, CMD_TANDEM_FATHERS, CMD_TANDEM_MOTHERS
166 	, CMD_TANDEM_SPOUSES, CMD_TANDEM_FAMILIES, CMD_TANDEM_PARENTS
167 	, CMD_TOGGLE_CHILDNUMS, CMD_TOGGLE_PEDTYPE
168 	, CMD_BROWSE_INDI, CMD_BROWSE_FAM
169 	/* reserve range for direct to children */
170 	, CMD_CHILD_DIRECT0, CMD_CHILD_DIRECT9=CMD_CHILD_DIRECT0+9
171 	, CMD_JUMP_HOOK
172 	, CMD_COPY_TOP_TO_BOTTOM, CMD_MERGE_BOTTOM_TO_TOP
173 	, CMD_BOTH_FATHERS, CMD_BOTH_MOTHERS
174 	, CMD_VHISTORY_BACK, CMD_VHISTORY_FWD, CMD_VHISTORY_LIST, CMD_VHISTORY_CLEAR
175 	, CMD_CHISTORY_BACK, CMD_CHISTORY_FWD, CMD_CHISTORY_LIST, CMD_CHISTORY_CLEAR
176 	, CMD_ADD_SOUR, CMD_ADD_EVEN, CMD_ADD_OTHR
177 	/* for hardware keys */
178 	, CMD_KY_UP=500, CMD_KY_DN
179 	, CMD_KY_SHPGUP, CMD_KY_SHPGDN, CMD_KY_PGUP, CMD_KY_PGDN
180 	, CMD_KY_HOME, CMD_KY_END
181 	, CMD_KY_ENTER
182 };
183 
184 
185 
186 #endif /* _MENUITEM_H */
187