/* * If we have help-line text, e.g., from "--hline", draw it between the other * decorations at the bottom of the dialog window. */ void dlg_draw_helpline(WINDOW *win, bool decorations) { int cur_x, cur_y; int bottom; if (dialog_vars.help_line != 0 && dialog_vars.help_line[0] != 0 && (bottom = getmaxy(win) - 1) > 0) { chtype attr = A_NORMAL; int cols = dlg_count_columns(dialog_vars.help_line); int other = decorations ? (ON_LEFT + ON_RIGHT) : 0; int avail = (getmaxx(win) - other - 2); int limit = dlg_count_real_columns(dialog_vars.help_line) + 2; if (limit < avail) { getyx(win, cur_y, cur_x); other = decorations ? ON_LEFT : 0; (void) wmove(win, bottom, other + (avail - limit) / 2); waddch(win, '['); dlg_print_text(win, dialog_vars.help_line, cols, &attr); waddch(win, ']'); wmove(win, cur_y, cur_x); } } }
/* * Print list item */ static void print_item(WINDOW *win, char **items, int status, int choice, int selected) { int i; chtype attr = A_NORMAL; const int *indx; int limit; /* Clear 'residue' of last item */ wattrset(win, menubox_attr); (void) wmove(win, choice, 0); for (i = 0; i < list_width; i++) (void) waddch(win, ' '); (void) wmove(win, choice, check_x); wattrset(win, selected ? check_selected_attr : check_attr); (void) wprintw(win, (checkflag == FLAG_CHECK) ? "[%c]" : "(%c)", status ? 'X' : ' '); wattrset(win, menubox_attr); (void) waddch(win, ' '); if (strlen(ItemName(0)) != 0) { indx = dlg_index_wchars(ItemName(0)); limit = dlg_count_wchars(ItemName(0)); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); (void) waddnstr(win, ItemName(0), indx[1]); if ((int) strlen(ItemName(0)) > indx[1]) { limit = dlg_limit_columns(ItemName(0), (item_x - check_x - 6), 1); if (limit > 1) { wattrset(win, selected ? tag_selected_attr : tag_attr); (void) waddnstr(win, ItemName(0) + indx[1], indx[limit] - indx[1]); } } } if (strlen(ItemText(0)) != 0) { indx = dlg_index_wchars(ItemText(0)); limit = dlg_limit_columns(ItemText(0), (getmaxx(win) - item_x - 1), 0); if (limit > 0) { (void) wmove(win, choice, item_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, ItemText(0), indx[limit], &attr); } } if (selected) { dlg_item_help(ItemHelp(0)); } }
static void print_partedit_item(WINDOW *partitions, struct partedit_item *items, int item, int nscroll, int selected) { chtype attr = A_NORMAL; char sizetext[16]; int y = item - nscroll + 1; wattrset(partitions, selected ? item_selected_attr : item_attr); wmove(partitions, y, MARGIN + items[item].indentation*2); dlg_print_text(partitions, items[item].name, 10, &attr); wmove(partitions, y, 17); wattrset(partitions, item_attr); humanize_number(sizetext, 7, items[item].size, "B", HN_AUTOSCALE, HN_DECIMAL); dlg_print_text(partitions, sizetext, 8, &attr); wmove(partitions, y, 25); dlg_print_text(partitions, items[item].type, 15, &attr); wmove(partitions, y, 40); if (items[item].mountpoint != NULL) dlg_print_text(partitions, items[item].mountpoint, 8, &attr); }
/* * Print menu item */ static void print_item(WINDOW *win, char **items, int choice, int selected) { int n; int my_width = menu_width; int my_x = item_x; int my_y = ItemToRow(choice); chtype attr = A_NORMAL; if (items == 0) return; /* Clear 'residue' of last item and mark current current item */ if (dialog_vars.input_menu) { wattrset(win, selected ? item_selected_attr : item_attr); for (n = my_y - 1; n < my_y + INPUT_ROWS - 1; n++) { wmove(win, n, 0); wprintw(win, "%*s", my_width, " "); } } else { wattrset(win, menubox_attr); wmove(win, my_y, 0); wprintw(win, "%*s", my_width, " "); } print_tag(win, items, choice, selected); /* Draw the input field box (only for inputmenu) */ (void) wmove(win, my_y, my_x); if (dialog_vars.input_menu) { my_width -= 1; draw_box(win, my_y - 1, my_x, INPUT_ROWS, my_width - my_x - tag_x, selected ? item_selected_attr : item_attr, selected ? item_selected_attr : item_attr); my_width -= 1; ++my_x; } /* print actual item */ wmove(win, my_y, my_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, ItemText(0), my_width - my_x, &attr); if (selected) { dlg_item_help(ItemHelp(0)); } }
/* * Print list item. The 'selected' parameter is true if 'choice' is the * current item. That one is colored differently from the other items. */ static void print_item(WINDOW *win, DIALOG_LISTITEM * item, const char *states, int choice, int selected) { chtype save = dlg_get_attrs(win); int i; chtype attr = A_NORMAL; const int *cols; const int *indx; int limit; /* Clear 'residue' of last item */ wattrset(win, menubox_attr); (void) wmove(win, choice, 0); for (i = 0; i < list_width; i++) (void) waddch(win, ' '); (void) wmove(win, choice, check_x); wattrset(win, selected ? check_selected_attr : check_attr); (void) wprintw(win, (checkflag == FLAG_CHECK) ? "[%c]" : "(%c)", states[item->state]); wattrset(win, menubox_attr); (void) waddch(win, ' '); if (strlen(item->name) != 0) { indx = dlg_index_wchars(item->name); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); (void) waddnstr(win, item->name, indx[1]); if ((int) strlen(item->name) > indx[1]) { limit = dlg_limit_columns(item->name, (item_x - check_x - 6), 1); if (limit > 1) { wattrset(win, selected ? tag_selected_attr : tag_attr); (void) waddnstr(win, item->name + indx[1], indx[limit] - indx[1]); } } } if (strlen(item->text) != 0) { cols = dlg_index_columns(item->text); limit = dlg_limit_columns(item->text, (getmaxx(win) - item_x + 1), 0); if (limit > 0) { (void) wmove(win, choice, item_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, item->text, cols[limit], &attr); } } if (selected) { dlg_item_help(item->help); } wattrset(win, save); }