post_menu(MENU * menu) { T((T_CALLED("post_menu(%p)"), (void *)menu)); if (!menu) RETURN(E_BAD_ARGUMENT); if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); if (menu->status & _POSTED) RETURN(E_POSTED); if (menu->items && *(menu->items)) { int y; int h = 1 + menu->spc_rows * (menu->rows - 1); WINDOW *win = Get_Menu_Window(menu); int maxy = getmaxy(win); if ((menu->win = newpad(h, menu->width))) { y = (maxy >= h) ? h : maxy; if (y >= menu->height) y = menu->height; if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0))) RETURN(E_SYSTEM_ERROR); } else RETURN(E_SYSTEM_ERROR); if (menu->status & _LINK_NEEDED) _nc_Link_Items(menu); } else RETURN(E_NOT_CONNECTED); menu->status |= _POSTED; if (!(menu->opt & O_ONEVALUE)) { ITEM **items; for (items = menu->items; *items; items++) { (*items)->value = FALSE; } } _nc_Draw_Menu(menu); Call_Hook(menu, menuinit); Call_Hook(menu, iteminit); _nc_Show_Menu(menu); RETURN(E_OK); }
int main(int argc, char *argv[]) { WINDOW *p, *s1, *s2, *s3; FILE *f; int ch; initscr(); refresh(); /* create a new pad */ p = newpad(200, WIDE + 1); if( p == NULL ) bomb("Unable to create new pad\n"); /* create three subpads */ s1 = subpad(p, TALL, WIDE + 1, 0, 0); if( s1 == NULL ) bomb("Unable to create subpad 1\n"); s2 = subpad(p, TALL, WIDE + 1, TALL, 0); if( s2 == NULL ) bomb("Unable to create subpad 2\n"); s3 = subpad(p, TALL, WIDE + 1, 2 * TALL, 0); if( s3 == NULL ) bomb("Unable to create subpad 3\n"); /* open the file */ f = fopen(FILENAME, "r"); if( f == NULL ) bomb("Unable to open the file\n"); /* display the file's contents on the pad */ while( (ch = fgetc(f)) != EOF) waddch(p, ch); fclose(f); /* display the pad's contents on the screen */ prefresh(s1, 0, 0, 0, 0, TALL - 1, WIDE); prefresh(s2, 0, 0, 0, WIDE + SPACER, TALL - 1, WIDE * 2 + SPACER); prefresh(s3, 0, 0, 0, WIDE * 2 + SPACER * 2, TALL - 1, WIDE * 3 + SPACER * 2); wgetch(p); endwin(); return 0; }
void padTest(WINDOW *dummy) { WINDOW *pad, *spad; pad = newpad(50, 100); wattron(pad, A_REVERSE); mvwaddstr(pad, 5, 2, "This is a new pad"); wattrset(pad, 0); mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:except now"); mvwaddstr(pad, 11, 1, "This line should not appear.It will now"); wmove(pad, 10, 1); wclrtoeol(pad); mvwaddstr(pad, 10, 1, " Press any key to continue"); prefresh(pad, 0, 0, 0, 0, 10, 45); keypad(pad, TRUE); raw(); wgetch(pad); spad = subpad(pad, 12, 25, 7, 52); mvwaddstr(spad, 2, 2, "This is a new subpad"); box(spad, 0, 0); prefresh(pad, 0, 0, 0, 0, 15, 75); keypad(pad, TRUE); raw(); wgetch(pad); mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad"); mvwaddstr(pad, 40, 1, " Press any key to continue"); prefresh(pad, 30, 0, 0, 0, 10, 45); keypad(pad, TRUE); raw(); wgetch(pad); delwin(pad); }
WRAP_API WINDOW * wrap_subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx) { return subpad(orig, nlines, ncols, begy, begx); }
WINDOW *resize_window(WINDOW *win, int nlines, int ncols) { WINDOW *new_; int i, save_cury, save_curx, new_begy, new_begx; PDC_LOG(("resize_window() - called: nlines %d ncols %d\n", nlines, ncols)); if (!win) return (WINDOW *)NULL; if (win->_flags & _SUBPAD) { if ( !(new_ = subpad(win->_parent, nlines, ncols, win->_begy, win->_begx)) ) return (WINDOW *)NULL; } else if (win->_flags & _SUBWIN) { if ( !(new_ = subwin(win->_parent, nlines, ncols, win->_begy, win->_begx)) ) return (WINDOW *)NULL; } else { if (win == SP->slk_winptr) { new_begy = SP->lines - SP->slklines; new_begx = 0; } else { new_begy = win->_begy; new_begx = win->_begx; } if ( !(new_ = PDC_makenew(nlines, ncols, new_begy, new_begx)) ) return (WINDOW *)NULL; } save_curx = min(win->_curx, (new_->_maxx - 1)); save_cury = min(win->_cury, (new_->_maxy - 1)); if (!(win->_flags & (_SUBPAD|_SUBWIN))) { if ( !(new_ = PDC_makelines(new_)) ) return (WINDOW *)NULL; werase(new_); copywin(win, new_, 0, 0, 0, 0, min(win->_maxy, new_->_maxy) - 1, min(win->_maxx, new_->_maxx) - 1, FALSE); for (i = 0; i < win->_maxy && win->_y[i]; i++) if (win->_y[i]) free(win->_y[i]); } new_->_flags = win->_flags; new_->_attrs = win->_attrs; new_->_clear = win->_clear; new_->_leaveit = win->_leaveit; new_->_scroll = win->_scroll; new_->_nodelay = win->_nodelay; new_->_delayms = win->_delayms; new_->_use_keypad = win->_use_keypad; new_->_tmarg = (win->_tmarg > new_->_maxy - 1) ? 0 : win->_tmarg; new_->_bmarg = (win->_bmarg == win->_maxy - 1) ? new_->_maxy - 1 : min(win->_bmarg, (new_->_maxy - 1)); new_->_parent = win->_parent; new_->_immed = win->_immed; new_->_sync = win->_sync; new_->_bkgd = win->_bkgd; new_->_curx = save_curx; new_->_cury = save_cury; free(win->_firstch); free(win->_lastch); free(win->_y); *win = *new_; free(new_); return win; }