26 static int list_width, check_x, item_x;
34 char *list_item =
malloc(list_width + 1);
37 list_item[list_width - item_x] =
'\0';
40 wattrset(win,
dlg.menubox.atr);
41 wmove(win, choice, 0);
42 for (i = 0; i < list_width; i++)
45 wmove(win, choice, check_x);
46 wattrset(win, selected ?
dlg.check_selected.atr
51 wattrset(win, selected ?
dlg.tag_selected.atr :
dlg.tag.atr);
52 mvwaddch(win, choice, item_x, list_item[0]);
53 wattrset(win, selected ?
dlg.item_selected.atr :
dlg.item.atr);
54 waddstr(win, list_item + 1);
56 wmove(win, choice, check_x + 1);
65 static void print_arrows(
WINDOW * win,
int choice,
int item_no,
int scroll,
71 wattrset(win,
dlg.uarrow.atr);
75 wattrset(win,
dlg.menubox.atr);
85 if ((height < item_no) && (scroll + choice < item_no - 1)) {
86 wattrset(win,
dlg.darrow.atr);
90 wattrset(win,
dlg.menubox_border.atr);
101 static void print_buttons(
WINDOW * dialog,
int height,
int width,
int selected)
103 int x = width / 2 - 11;
106 print_button(dialog, gettext(
"Select"), y, x, selected == 0);
107 print_button(dialog, gettext(
" Help "), y, x + 14, selected == 1);
109 wmove(dialog, y, x + 1 + 14 * selected);
118 int width,
int list_height)
120 int i,
x,
y, box_x, box_y;
121 int key = 0,
button = 0, choice = 0, scroll = 0, max_choice;
135 if (getmaxy(stdscr) < (height + 6))
137 if (getmaxx(stdscr) < (width + 6))
148 dialog = newwin(height, width, y, x);
149 keypad(dialog,
TRUE);
151 draw_box(dialog, 0, 0, height, width,
152 dlg.dialog.atr,
dlg.border.atr);
153 wattrset(dialog,
dlg.border.atr);
154 mvwaddch(dialog, height - 3, 0,
ACS_LTEE);
155 for (i = 0; i < width - 2; i++)
157 wattrset(dialog,
dlg.dialog.atr);
162 wattrset(dialog,
dlg.dialog.atr);
165 list_width = width - 6;
166 box_y = height - list_height - 5;
167 box_x = (width - list_width) / 2 - 1;
170 list = subwin(dialog, list_height, list_width, y + box_y + 1,
176 draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
177 dlg.menubox_border.atr,
dlg.menubox.atr);
183 check_x =
MIN(check_x, list_width);
185 check_x = (list_width - check_x) / 2;
186 item_x = check_x + 4;
188 if (choice >= list_height) {
189 scroll = choice - list_height + 1;
194 for (i = 0; i < max_choice; i++) {
199 print_arrows(dialog, choice,
item_count(), scroll,
200 box_y, box_x + check_x + 5, list_height);
202 print_buttons(dialog, height, width, 0);
204 wnoutrefresh(dialog);
209 key = wgetch(dialog);
211 for (i = 0; i < max_choice; i++) {
218 key ==
'+' || key ==
'-') {
219 if (key ==
KEY_UP || key ==
'-') {
224 if (list_height > 1) {
228 scrollok(list,
TRUE);
230 scrollok(list,
FALSE);
236 scroll, box_y, box_x + check_x + 5, list_height);
238 wnoutrefresh(dialog);
244 }
else if (key ==
KEY_DOWN || key ==
'+') {
245 if (choice == max_choice - 1) {
249 if (list_height > 1) {
255 scrollok(list,
TRUE);
257 scrollok(list,
FALSE);
264 scroll, box_y, box_x + check_x + 5, list_height);
266 wnoutrefresh(dialog);
281 wnoutrefresh(dialog);
309 print_buttons(dialog, height, width,
button);