Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ncurses.h>
- #include <stdlib.h>
- #define COUNT 4
- char opcje[COUNT][20] = {
- "PODUKTY",
- "ADRES",
- "TELEFONY",
- "WYJSCIE"
- };
- char opcje1[3][20] = {
- "Skutery",
- "Motory",
- "Quady"
- };
- int wybor = 0;
- void wyswietl(){
- int i;
- for(i=0; i<COUNT; i++) {
- if(i == wybor)
- attron(COLOR_PAIR(1));
- mvprintw(i, 0, "%s", opcje[i]);
- if(i == wybor)
- attroff(COLOR_PAIR(1));
- }
- }
- int main()
- {
- WINDOW*podmenu;
- WINDOW*adres;
- WINDOW*telefony;
- WINDOW*wyjscie;
- int klawisz;
- int klawisz1;
- int c;
- initscr();
- start_color();
- init_pair(1, COLOR_RED, COLOR_BLACK);
- keypad(stdscr, TRUE);
- noecho();
- curs_set(0);
- do
- {
- if(c == KEY_DOWN){
- wybor++;
- wybor%=COUNT;
- }
- if(c == KEY_UP){
- wybor+=COUNT-1;
- wybor%=COUNT;
- }
- if(c == 10){ //10 oznacza enter
- move(LINES-5, 3);
- mvprintw(LINES-5, 3, "Wybrano pozycje nr:%d", wybor+1);
- refresh();
- }
- if(wybor == COUNT-1 && c == 10)
- {
- wyjscie=newwin(5, 30, 5, 30);
- box(wyjscie, 0, 0);
- mvwprintw(wyjscie, 0, 10, "WYJSCIE");
- mvwprintw(wyjscie, 1, 2, "Czy na pewno chcesz wyjsc?");
- mvwprintw(wyjscie, 2, 2, "Tak[t]");
- mvwprintw(wyjscie, 3, 2, "Nie[n]");
- wrefresh(wyjscie);
- // wgetch(wyjscie);
- klawisz=wgetch(wyjscie);
- if(klawisz=='t')
- {
- endwin();
- exit(0);
- }
- else if(klawisz=='n')
- {
- wclear(wyjscie);
- wrefresh(wyjscie);
- delwin(wyjscie);
- }
- }
- // clear();
- if(wybor == 0 && c == 10)
- {
- podmenu=newwin(5, 30, 5, 30);
- box(podmenu, 0, 0);
- keypad(podmenu, TRUE);
- int wybor1 = 0;
- void wyswietl1(){
- int j;
- for(j=0; j<3; j++) {
- if(j == wybor1)
- wattron(podmenu, COLOR_PAIR(1));
- mvwprintw(podmenu, j+1, 2, "%s", opcje1[j]);
- if(j == wybor1)
- wattroff(podmenu, COLOR_PAIR(1));
- }
- }
- mvwprintw(podmenu, 0, 10, "PRODUKTY" );
- wrefresh(podmenu);
- // wgetch(podmenu);
- // klawisz1=getch();
- if(klawisz1 == KEY_DOWN) {
- wybor1++;
- wybor1%=3;
- }
- if(klawisz1 == KEY_UP) {
- wybor1+=2;
- wybor1%=3;
- }
- wyswietl1(podmenu);
- wrefresh(podmenu);
- wgetch(podmenu);
- // wclear(podmenu);
- }
- if(wybor == 1 && c == 10)
- {
- adres=newwin(4, 25, 4, 25);
- box(adres, 0, 0);
- mvwprintw(adres, 0, 10, "ADRES");
- mvwprintw(adres, 1, 2, "ul. Stolarska 13");
- mvwprintw(adres, 2, 2, "Sosnowiec");
- wrefresh(adres);
- wgetch(adres);
- wclear(adres);
- wrefresh(adres);
- }
- if(wybor == 2 && c == 10)
- {
- telefony=newwin(5, 30, 5, 30);
- box(telefony, 0, 0);
- mvwprintw(telefony, 0, 10, "TELEFONY");
- mvwprintw(telefony, 1, 2, "Biuro obs³ugi: 555 55 55");
- mvwprintw(telefony, 2, 2, "Sekretariat: 333 33 33");
- mvwprintw(telefony, 3, 2, "Sklep: 777 77 77");
- wrefresh(telefony);
- wgetch(telefony);
- wclear(telefony);
- wrefresh(telefony);
- }
- wyswietl();
- } while((c = wgetch(stdscr)) != 'q');
- endwin();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement