int set_menu_sub(MENU *m, WINDOW *sub) { if (m) { if (Posted(m)) { return (E_POSTED); } UserSub(m) = sub; /* Since window size has changed go recalculate sizes */ _scale(m); } else { UserSub(Dfl_Menu) = sub; } return (E_OK); }
int free_menu(MENU *m) { if (!m) { return (E_BAD_ARGUMENT); } if (Posted(m)) { return (E_POSTED); } if (Items(m)) { _disconnect(m); } free(m); return (E_OK); }
void _show(MENU *m) { int r, c; WINDOW *us; if (Posted(m) || Indriver(m)) { (void) mvderwin(Sub(m), Top(m), 0); us = US(m); getmaxyx(us, r, c); r = min(Height(m), r); c = min(Width(m), c); (void) copywin(Sub(m), us, 0, 0, 0, 0, r-1, c-1, FALSE); _position_cursor(m); } }
int set_menu_grey(MENU *m, chtype attr) { /*LINTED [E_CONST_PROMOTED_UNSIGNED_LONG]*/ if (InvalidAttr(attr)) { return (E_BAD_ARGUMENT); } if (m) { Grey(m) = attr; if (Posted(m)) { _draw(m); /* Redraw the menu */ _show(m); /* Redisplay menu */ } } else { Grey(Dfl_Menu) = attr; } return (E_OK); }
int set_menu_format(MENU *m, int rows, int cols) { if (rows < 0 || cols < 0) { return (E_BAD_ARGUMENT); } if (m) { if (Posted(m)) { return (E_POSTED); } if (rows == 0) { rows = FRows(m); } if (cols == 0) { cols = FCols(m); } /* The pattern buffer is allocated after items have been */ /* connected */ if (Pattern(m)) { IthPattern(m, 0) = '\0'; Pindex(m) = 0; } FRows(m) = rows; FCols(m) = cols; Cols(m) = min(cols, Nitems(m)); Rows(m) = (Nitems(m)-1) / cols + 1; Height(m) = min(rows, Rows(m)); Top(m) = 0; Current(m) = IthItem(m, 0); SetLink(m); _scale(m); } else { if (rows > 0) { FRows(Dfl_Menu) = rows; } if (cols > 0) { FCols(Dfl_Menu) = cols; } } return (E_OK); }
int set_menu_opts(MENU *m, int opt) { ITEM **ip; if (m) { if (Posted(m)) { return (E_POSTED); } /* Check to see if the ROWMAJOR option is changing. If so, */ /* set top and current to 0. */ if ((opt & O_ROWMAJOR) != RowMajor(m)) { Top(m) = 0; Current(m) = IthItem(m, 0); (void) set_menu_format(m, FRows(m), FCols(m)); } /* if O_NONCYCLIC option changed, set bit to re-link items */ if ((opt & O_NONCYCLIC) != (Mopt(m) & O_NONCYCLIC)) { SetLink(m); } Mopt(m) = opt; if (OneValue(m) && Items(m)) { for (ip = Items(m); *ip; ip++) { /* Unset values if selection not allowed. */ Value(*ip) = FALSE; } } _scale(m); /* Redo sizing information */ } else { Mopt(Dfl_Menu) = opt; } return (E_OK); }