1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include <ncurses.h> int main() { // Initialize ncurses initscr(); cbreak(); // Permite citirea tastelor fără a aștepta apăsarea tastei Enter noecho(); // Nu afișează caracterele tastate pe ecran // Crearea fereastrei principale WINDOW *win = newwin(7, 19, 0, 0); box(win, 0, 0); // Afiseaza bordura ferestrei refresh(); // Afișează modificările // Crearea butoanelor WINDOW *button1 = derwin(win, 1, 4, 1, 1); WINDOW *button2 = derwin(win, 1, 4, 1, 6); WINDOW *button3 = derwin(win, 1, 4, 1, 11); WINDOW *button4 = derwin(win, 1, 4, 3, 1); WINDOW *button5 = derwin(win, 1, 4, 3, 6); WINDOW *button6 = derwin(win, 1, 4, 3, 11); WINDOW *button7 = derwin(win, 1, 4, 5, 1); WINDOW *button8 = derwin(win, 1, 4, 5, 6); WINDOW *button9 = derwin(win, 1, 4, 5, 11); WINDOW *button0 = derwin(win, 1, 9, 7, 1); // Setarea caracteristicilor butoanelor keypad(button1, TRUE); keypad(button2, TRUE); keypad(button3, TRUE); keypad(button4, TRUE); keypad(button5, TRUE); keypad(button6, TRUE); keypad(button7, TRUE); keypad(button8, TRUE); keypad(button9, TRUE); keypad(button0, TRUE); wprintw(button1, "1"); wprintw(button2, "2"); wprintw(button3, "3"); wprintw(button4, "4"); wprintw(button5, "5"); wprintw(button6, "6"); wprintw(button7, "7"); wprintw(button8, "8"); wprintw(button9, "9"); wprintw(button0, "0"); wrefresh(win); // Așteaptă apăsarea unei taste getch(); // Curățarea memoriei și închiderea ncurses delwin(button1); delwin(button2); delwin(button3); delwin(button4); delwin(button5); delwin(button6); delwin(button7); delwin(button8); delwin(button9); delwin(button0); delwin(win); endwin(); return 0; } |
The derwin() function is used to create a new window with these arguments : win is the parent window in which the subwindow will be created. 1 is the number of rows of the subwindow. 4 is the number of… Read More »