#include #include #include #include #include "../include/windowsDeclaration.h" #include "../include/windowsBack.h" #include "../include/logic.h" #include "../include/globals.h" #define MAX_LEN 64 void example_window() { WINDOW *win; int height = LINES / 2 -2; int width = COLS / 2; int starty = LINES / 2; int startx = COLS / 2; win = create_newwin(height, width, starty, startx); mvwprintw(win, 1, 2, "Esempio Interfaccia"); char *opts[] = {"Opzione 1", "Opzione 2", "Opzione 3"}; mvwprintw(win, 3, 2, "Scegli dal menu:"); int menu_res = uiSelectMenu(win, 4, 4, opts, 3); char txt_buf[64] = "Testo base"; mvwprintw(win, 9, 2, "Inserisci testo:"); uiTextInput(win, 9, 19, txt_buf, 30); mvwprintw(win, 11, 2, "Attiva opzione:"); int switch_res = uiToggleSwitch(win, 11, 18, 0); mvwprintw(win, 13, 2, "Scelto: M=%d, T=%s, S=%d", menu_res, txt_buf, switch_res); wrefresh(win); wgetch(win); werase(win); destroy_win(win); } int runMainMenu(){ char *mainMenu[] = { "Segna vendita", "Vedi vendite", "Vedi prodotti", "Gestisci prodotti", "Opzioni", "Exit" }; int n_mainMenu = sizeof(mainMenu) / sizeof(char *); WINDOW *mainWin; int height = LINES / 2; int width = COLS / 2; int starty = 0; int startx = 0; mainWin = create_newwin(height, width, starty, startx); wwrap_print(mainWin, 1, 2, "Usa le FRECCETTE ed INVIO per scegliere un'opzione,\nin alternativa ci sono i movement di vim e SPAZIO."); refresh(); int choice = uiSelectMenu(mainWin, height / 2 - 3, width / 2 - 9, mainMenu, n_mainMenu); statusf("Avvio opzione '%s'", mainMenu[choice - 1]); clrtoeol(); refresh(); destroy_win(mainWin); return choice; } void runOptionsMenu(){ WINDOW *optionsWin; optionsWin = create_newwin(LINES/2, COLS/2, 0, COLS/2); char input[MAX_LEN + 1]; strcpy(input, productPricesFileLocation); mvwprintw(optionsWin, 1, 2, "Posizione file prodotti:"); uiTextInput(optionsWin, 2, 2, input, MAX_LEN); if (existsFile(input)) { statusf("Il file '%s' esiste e verra' utilizzato al posto di '%s'", input, productPricesFileLocation); strcpy(productPricesFileLocation, input); } else { warningf("Il file '%s' non esiste, utilizzo il vecchio file '%s'", input, productPricesFileLocation); } werase(optionsWin); destroy_win(optionsWin); }