本文整理汇总了C++中post_menu函数的典型用法代码示例。如果您正苦于以下问题:C++ post_menu函数的具体用法?C++ post_menu怎么用?C++ post_menu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post_menu函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: menuvisual_create
MENUPAN*
menuvisual_create(void)
{
MENU *menu;
MENUPAN *menupan;
const char *choices[] = {
"Visualizza tabella",
NULL,
NULL,
};
const char *desc[] = {
"M-t",
NULL,
NULL,
};
menu=menu_create(choices, desc, 0);
menupan=menu_pan_create(menu, 1, 2*ISIZE+1, 2);
post_menu(menu);
return menupan;
}
示例2: menulpr_create
MENUPAN*
menulpr_create(void)
{
MENU *menu;
MENUPAN *menupan;
const char *choices[] = {
"Cambia path db",
SEP,
"Esci",
};
const char *desc[] = {
"M-p",
DSEP,
"M-x",
};
menu=menu_create(choices, desc, A_SIZE(choices));
menupan=menu_pan_create(menu, 1, 1, 0);
post_menu(menu);
return menupan;
}
示例3: display_menu
/* display current menu */
void display_menu() {
int rows, cols, begin_y, begin_x;
/* setup menu options */
menu_opts_off(menu_ptr, O_ROWMAJOR);
set_menu_fore(menu_ptr, COLOR_PAIR(MENU_PAIR) | A_STANDOUT);
set_menu_back(menu_ptr, COLOR_PAIR(MENU_PAIR) | A_DIM | A_NORMAL);
/* setup appropriate windows */
set_menu_win(menu_ptr, stdscr);
scale_menu(menu_ptr, &rows, &cols);
/* locate menu in the center */
getmaxyx(stdscr,LINES,COLS);
begin_y = (LINES-rows) / 2;
begin_x = (COLS-cols) / 2;
/* create main menu window */
sub_window = subwin(stdscr, rows, cols, begin_y, begin_x);
set_menu_sub(menu_ptr, sub_window);
/* display the menu */
post_menu(menu_ptr);
refresh();
}
示例4: menucerca_create
MENUPAN*
menucerca_create(void)
{
MENU *menu;
MENUPAN *menupan;
const char *choices[] = {
"Cerca per Orario",
"Cerca per Docente",
"Cerca per Aula",
"Cerca per Materia"
};
const char *desc[] = {
"M-o ",
"M-d ",
"M-a ",
NULL
};
menu=menu_create(choices, desc, A_SIZE(choices));
menupan=menu_pan_create(menu, 1, 3*ISIZE+1, 3);
post_menu(menu);
return menupan;
}
示例5: main
int main()
{
initscr();
start_color();
ITEM *menuitems[6];
MENU *menubar;
WINDOW *win,*sub_win;
int i,rows,cols;
//initcolor();
menuitems[0]=new_item("File","");
menuitems[1]=new_item("Edit","");
menuitems[2]=new_item("Options","");
menuitems[3]=new_item("Window","");
menuitems[4]=new_item("Help","");
menuitems[5]=NULL;
//menu_opts_off(menubar,O_ROWMAJOR);
menubar=new_menu(menuitems);
scale_menu(menubar,&rows,&cols);
win=newwin(rows+2,cols+2,2,5);
box(win,179,196);
sub_win=derwin(win,rows,cols,1,1);
set_menu_win(menubar,win);
set_menu_sub(menubar,sub_win);
post_menu(menubar);
wrefresh(win);
wgetch(sub_win);
unpost_menu(menubar);
free_menu(menubar);
for(i=0;i<6;i++)
free_item(menuitems[i]);
endwin();
}
示例6: menuhelp_create
MENUPAN*
menuhelp_create(void)
{
MENU *menu;
MENUPAN *menupan;
const char *choices[] = {
"Help",
SEP,
"About",
NULL,
};
const char *desc[] = {
"M-h",
DSEP,
NULL,
};
menu=menu_create(choices, desc, A_SIZE(choices));
menupan=menu_pan_create(menu, 1, 4*ISIZE+1, 4);
post_menu(menu);
return menupan;
}
示例7: workspace_create
MENU*
workspace_create(void)
{
MENU *menu;
const char *choices[] = {
"Lpr ",
"Edita ",
"Visualizza ",
"Cerca ",
"Help " ,
};
const char *desc[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
};
menu=menu_create(choices, desc, A_SIZE(choices));
set_menu_format(menu, 1, A_SIZE(choices));
set_menu_fore(menu, COLOR_PAIR(1) | A_REVERSE);
set_menu_back(menu, COLOR_PAIR(1));
post_menu(menu);
return menu;
}
示例8: menuedita_create
MENUPAN*
menuedita_create(void)
{
MENU *menu;
MENUPAN *menupan;
const char *choices[] = {
"Inserisci Record",
"Edita Record",
"Elimina Record",
};
const char *desc[] = {
"M-i",
"M-e",
"M-c ",
};
menu=menu_create(choices, desc, A_SIZE(choices));
menupan=menu_pan_create(menu, 1, ISIZE+1, 1);
post_menu(menu);
return menupan;
}
示例9: printMenus
void printMenus() {
int i;
MENU *fileMenu, *dirMenu;
// Create items
fileItems = malloc(numFiles * sizeof(ITEM *));
for (i = 0; i < numFiles; i++) {
fileItems[i] = new_item(fileEntries[i]->d_name, NULL);
if (fileItems[i] == NULL)
break;
}
fileItems[numFiles] = NULL;
dirItems = malloc(numDirs * sizeof(ITEM *));
for (i = 0; i < numDirs; i++) {
dirItems[i] = new_item(dirEntries[i]->d_name, NULL);
if (dirItems[i] == NULL)
break;
}
dirItems[numDirs] = NULL;
// Create menus
fileMenu = new_menu(fileItems);
dirMenu = new_menu(dirItems);
menus = malloc(2 * sizeof(MENU *));
menus[0] = fileMenu;
menus[1] = dirMenu;
if (fileMenu == NULL || dirMenu == NULL) {
fprintf(stderr, "Error creating menus\n");
}
// Associate windows and menus
set_menu_win(fileMenu, cursesWins[0]);
set_menu_sub(fileMenu, derwin(cursesWins[0], LINES / 2, (COLS / 2) - 6, 3, 1));
set_menu_format(fileMenu, (LINES / 2), 1);
set_menu_win(dirMenu, cursesWins[1]);
set_menu_sub(dirMenu, derwin(cursesWins[1], LINES / 2, (COLS / 2) - 6, 3, 1));
set_menu_format(dirMenu, (LINES / 2), 1);
post_menu(fileMenu);
wrefresh(cursesWins[0]);
post_menu(dirMenu);
wrefresh(cursesWins[1]);
}
示例10: show_chooser_win
void
show_chooser_win(MENU *dirmenu, size_t items, char *buf)
{
int c = 0;
size_t buflen, offset = 0;
char *tmp;
buflen = strlen(buf) - 1;
set_menu_fore(dirmenu, A_REVERSE);
returnval = set_menu_format(dirmenu, LINES, 1);
post_menu(dirmenu);
refresh();
while ((c = getch()) != 'q') {
switch(c) {
case 'j':
case KEY_DOWN:
menu_driver(dirmenu, REQ_DOWN_ITEM);
break;
case 'k':
case KEY_UP:
menu_driver(dirmenu, REQ_UP_ITEM);
break;
case KEY_NPAGE:
menu_driver(dirmenu, REQ_SCR_DPAGE);
break;
case KEY_PPAGE:
menu_driver(dirmenu, REQ_SCR_UPAGE);
break;
case KEY_END:
menu_driver(dirmenu, REQ_LAST_ITEM);
break;
case KEY_HOME:
menu_driver(dirmenu, REQ_FIRST_ITEM);
break;
case 10: /* Enter */
move(20, 0);
clrtoeol();
tmp = (char *)item_name(current_item(dirmenu));
offset = strlcpy(buf, tmp, MAX_CHOICESIZE);
if (offset >= MAX_CHOICESIZE)
goto toolong;
if (strlcpy(buf + offset,
item_description(current_item(dirmenu)),
MAX_CHOICESIZE - offset))
goto toolong;
pos_menu_cursor(dirmenu);
break;
}
}
toolong:
unpost_menu(dirmenu);
fprintf(stdout, "shit happens\n");
fprintf(stdout, "VALUE WAS: %d\n", returnval);
}
示例11: mainmenu
int mainmenu(int height, int width) {
int ret;
ITEM **menu_items;
MENU *main_menu;
int n_choices, i;
clean_main_menu();
build_main_menu(instance_path);
n_choices = menu_size;
menu_items = (ITEM **) calloc(n_choices + 1, sizeof (ITEM *));
for (i = 0; i < n_choices; ++i) {
menu_items[i] = new_item(menu_values[i], menu_values[i]);
set_item_userptr(menu_items[i], (void *) menu_selected);
}
menu_items[n_choices] = (ITEM *) NULL;
main_menu = new_menu((ITEM **) menu_items);
menu_opts_off(main_menu, O_SHOWDESC);
set_menu_sub(main_menu, derwin(stdscr, 10, 50, 6, 10));
post_menu(main_menu);
attron(A_BOLD);
mvprintw(0, 0, name);
mvprintw(0, width - strlen(vers), vers);
attroff(A_BOLD);
refresh();
pos_menu_cursor(main_menu);
while ((i = getch()) != KEY_F(4)) {
switch (i) {
case KEY_DOWN:
menu_driver(main_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(main_menu, REQ_UP_ITEM);
break;
case 10:
{
ITEM *cur;
int (*p)(char *);
cur = current_item(main_menu);
p = (int (*)(char *))item_userptr(cur);
ret = p((char *) item_name(cur));
pos_menu_cursor(main_menu);
goto menu_sel;
}
}
}
if (i == KEY_F(4)) {
ret = menu_size - 1;
}
menu_sel:
unpost_menu(main_menu);
free_menu(main_menu);
for (i = 0; i < n_choices; ++i)
free_item(menu_items[i]);
return ret;
}
示例12: main
int main(int argc, char const *argv[]) {
ITEM **my_items;
int c;
MENU *my_menu;
WINDOW *my_menu_win;
int n_choices, i;
initscr();
start_color();
cbreak();
noecho();
keypad(stdscr, TRUE);
init_pair(1, COLOR_RED, COLOR_BLACK);
n_choices = ARRAY_SIZE(choices);
my_items = (ITEM **) calloc(n_choices, sizeof(ITEM *));
for (i = 0; i < n_choices; ++i)
my_items[i] = new_item(choices[i], choices[i]);
my_menu = new_menu((ITEM **) my_items);
my_menu_win = newwin(10, 40, 4, 4);
keypad(my_menu_win, TRUE);
set_menu_win(my_menu, my_menu_win);
set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));
set_menu_mark(my_menu, " * ");
box(my_menu_win, 0, 0);
print_in_middle(my_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);
mvwaddch(my_menu_win, 2, 39, ACS_RTEE);
mvprintw(LINES - 2, 0, "F1 to exit");
refresh();
post_menu(my_menu);
wrefresh(my_menu_win);
while ((c = wgetch(my_menu_win)) != KEY_F(1)) {
switch (c) {
case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
}
wrefresh(my_menu_win);
}
unpost_menu(my_menu);
free_menu(my_menu);
for (i = 0; i < n_choices; ++i)
free_item(my_items[i]);
endwin();
return 0;
}
示例13: derwin
int generic_menu::get_choice()
{
if (choices.size() == return_values.size())
{
//create the menu and the item pointer vector
MENU* my_menu;
std::vector<ITEM*> my_items;
WINDOW* menu_win = derwin(screen, choices.size(), 30, ypos, xpos);
ITEM* cur = NULL;
for (int x = 0; x < choices.size(); x++)
{
//populate the items vector with the string data in choices
//c_str because ncurses is very old
my_items.push_back(new_item(choices.at(x).c_str(), NULL));
}
//pushback a null item for safety
my_items.push_back((ITEM*)NULL);
//create the menu and attach the items
my_menu = new_menu((ITEM**)my_items.data());
//print the desc and post the menu
mvwprintw(screen, LINES - 3, 0, "%s\n", desc.c_str());
//set_current_item(my_menu, lastItem);
set_menu_win(my_menu, menu_win);
keypad(menu_win, TRUE);
post_menu(my_menu);
touchwin(screen);
wrefresh(menu_win);
std::vector<int>::iterator return_iter = return_values.begin();
int c = 0;
while((c = wgetch(menu_win)) != '\n')
{
touchwin(screen);
wrefresh(menu_win);
switch(c)
{ case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
if (return_iter != return_values.end())
{
return_iter++;
}
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
if (return_iter != return_values.begin())
{
return_iter--;
}
break;
}
}
unpost_menu(my_menu);
for (int x = 0; x < my_items.size(); x++)
{
free_item(my_items[x]);
}
free_menu(my_menu);
return *return_iter;
}
}
示例14: displayMenu
void displayMenu(int y, int x, char title[],int numOfOpt, char *options[], void (*p[])(void)){
int i,c;
WINDOW *menuWindow;
MENU *myMenu;
ITEM **myOptions;
ITEM *currentOption;
initscr();
noecho();
cbreak();
keypad(stdscr,TRUE);
init_pair(1,COLOR_CYAN,COLOR_BLACK);
myOptions=(ITEM **)calloc(numOfOpt+1,sizeof(ITEM *));
for(i=0;i<numOfOpt;i++){
myOptions[i]=new_item(options[i]," ");
set_item_userptr(myOptions[i],p[i]);
}
myOptions[numOfOpt]=(ITEM *)NULL;
myMenu=new_menu(myOptions);
menuWindow = newwin(8,20,(LINES-y)/2,(COLS-x)/2);
keypad(menuWindow,TRUE);
set_menu_win(myMenu,menuWindow);
set_menu_sub(myMenu, derwin(menuWindow,y-4,x-2,3,1));
set_menu_format(myMenu,numOfOpt,1);
menu_opts_off(myMenu, O_SHOWDESC);
set_menu_mark(myMenu," * ");
post_menu(myMenu);
wrefresh(menuWindow);
while((c=wgetch(menuWindow))!=KEY_F(2)){
switch(c){
case KEY_UP:
menu_driver(myMenu,REQ_UP_ITEM);
break;
case KEY_DOWN:
menu_driver(myMenu,REQ_DOWN_ITEM);
break;
case 10:{
ITEM *temp;
temp=current_item(myMenu);
void(*pointer)(void);
pointer=item_userptr(temp);
pointer();
pos_menu_cursor(myMenu);
menu_driver(myMenu,REQ_DOWN_ITEM);
break;
}
wrefresh(menuWindow);
}
}
/*unpost_menu(myMenu);*/
/*for(i=0;i<numOfOpt;++i){*/
/*free_item(myOptions[i]);*/
/*}*/
/*free_menu(myMenu);*/
/*free(optionsNumbers);*/
}
示例15: main
int main()
{ ITEM **my_items;
int c;
MENU *my_menu;
int n_choices, i;
ITEM *cur_item;
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
n_choices = ARRAY_SIZE(choices);
my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
for(i = 0; i < n_choices; ++i)
my_items[i] = new_item(choices[i], choices[i]);
my_items[n_choices] = (ITEM *)NULL;
my_menu = new_menu((ITEM **)my_items);
post_menu(my_menu);
refresh();
while((c = getch()) != KEY_F(1))
{ switch(c)
{ case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
case 10: /* Enter */
cur_item = current_item(my_menu);
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "You have chosen %d item with name %s and description %s",
item_index(cur_item) + 1, item_name(cur_item),
item_description(cur_item));
refresh();
pos_menu_cursor(my_menu);
break;
}
}
free_item(my_items[0]);
free_item(my_items[1]);
free_menu(my_menu);
endwin();
}