89 lines
2.1 KiB
C++
89 lines
2.1 KiB
C++
#include <curses.h>
|
|
#include <menu.h>
|
|
#include <clocale>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include "gameske_funkce.h"
|
|
|
|
#define CTRLD 4
|
|
|
|
const char* choices[] = {"paradox", "kompromis", "Stereotyp", "Žena"};
|
|
const char* date[] = {"2023-10-01", "2023-10-02", "2023-10-03", "2023-10-04"};
|
|
const char* choices2[] = {"PRINT", "EDIT", "DELETE", "Žena"};
|
|
|
|
void menu() {
|
|
ITEM** my_items;
|
|
int c;
|
|
MENU* my_menu;
|
|
WINDOW* my_menu_win;
|
|
int n_choices, i;
|
|
|
|
/* Initialize curses */
|
|
setlocale(LC_ALL, "");
|
|
initscr();
|
|
start_color();
|
|
cbreak();
|
|
noecho();
|
|
keypad(stdscr, TRUE);
|
|
init_pair(1, COLOR_RED, COLOR_BLACK);
|
|
|
|
/* Create items */
|
|
n_choices = ARRAY_SIZE(choices);
|
|
my_items = new ITEM*[ARRAY_SIZE(choices)];
|
|
for (i = 0; i < n_choices; ++i)
|
|
my_items[i] = new_item(choices[i], date[i]);
|
|
|
|
/* Crate menu */
|
|
my_menu = new_menu(my_items);
|
|
|
|
/* Create the window to be associated with the menu */
|
|
my_menu_win = newwin(10, 40, 4, 4);
|
|
keypad(my_menu_win, TRUE);
|
|
|
|
/* Set main window and sub window */
|
|
set_menu_win(my_menu, my_menu_win);
|
|
set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));
|
|
|
|
/* Set menu mark to the string " * " */
|
|
set_menu_mark(my_menu, " * ");
|
|
|
|
/* Print a border around the main window and print a title */
|
|
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 the menu */
|
|
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;
|
|
case 10:
|
|
|
|
refresh();
|
|
break;
|
|
case ':':
|
|
spawncmd();
|
|
}
|
|
wrefresh(my_menu_win);
|
|
}
|
|
|
|
/* Unpost and free all the memory taken up */
|
|
unpost_menu(my_menu);
|
|
free_menu(my_menu);
|
|
for (i = 0; i < n_choices; ++i)
|
|
free_item(my_items[i]);
|
|
delete[] my_items;
|
|
endwin();
|
|
}
|