brad@bradley.bradley.edu (Bradley E. Smith) (04/03/91)
Now I now this isn't the greatest program --- please no comments, just helpful suggestions. If you run this program the menu works but returns trash....but if you quit the program the menu sends what one would think....what am I missing.....to quit put the mouse in the upper left window and touch the middle button. The right button does the menu. Bradley Smith Network & Technical Services @ Bradley University, Peoria, IL brad@bradley.edu --- 309-677-2337 ----------cut here, no shar------------- #include <mgr/term.h> #include <signal.h> #define TRUE 1 #define X_RES 10 #define Y_RES 8 #define CMD_MENU 1 #define MAIN_MENU 2 #define FILE_MENU 3 #define DIR_MENU 4 #define STR_BUTTON1 "\0331\r" /* string for button 1 */ #define STR_BUTTON2 "\0332\r" #define STR_ACTIVATE "\033a\r" #define STR_RESHAPE "\033r\r" #define STR_MOVE "\033m\r" #define STR_DESTROY "\033d\r" struct menu_entry main_menu[] = { "Commands =>", "", "Item 1(ls)", "ls\r", "Item 2(date)", "date\r", "Item 3(who)", "who\r", "Item 4(df)", "df\r", "Quit", "quit", }; struct menu_entry cmd_menu[] = { "ls", "1", "pwd","2", }; int orig_x, orig_y, orig_width, orig_height; int host_x, host_y, host_border; char host_name[32]; int mouse_x, mouse_y; main() { int ten_percent; char buf[128], buf2[128]; long t; char *ctime(); m_setup(M_FLUSH); m_push(P_POSITION|P_WINDOW|P_FLAGS|P_EVENT|P_CURSOR); m_ttyset(); m_setnoecho(); m_setraw(); get_param(host_name, &host_x, &host_y, &host_border); menu_load(MAIN_MENU,MENU_SIZE(main_menu), (struct menu_entry *) &main_menu[0]); menu_load(CMD_MENU,MENU_SIZE(cmd_menu), (struct menu_entry *) &cmd_menu[0]); m_selectmenu2(MAIN_MENU); m_linkmenu(MAIN_MENU,0,1,0); m_linkmenu(MAIN_MENU,1,CMD_MENU,0); m_clear(); m_shapewindow(0, 0, host_x, host_y); make_graphics_window(); make_status_window(); make_w_window(); m_font(3); /* m_textregion(105,0,844,100); /* */ m_setevent(BUTTON_1, STR_BUTTON1); m_setevent(BUTTON_2, STR_BUTTON2); for(;;) { #if 0 if(!m_gets(buf)) exit_clean(); #else gets(buf); #endif printf("strlen=%d:%c,%c,%c,%c:%s", strlen(buf),buf[0], buf[1], buf[2], buf[3],buf); if(buf[0] == '\033') { switch(buf[1]) { case '1': get_mouse(&mouse_x, &mouse_y); whereis_mouse(1); break; case '2': get_mouse(&mouse_x, &mouse_y); whereis_mouse(2); break; default: printf("default:%s", buf); } } } } whereis_mouse(i) int i; { if(mouse_x < 100) { /* in command window */ if(mouse_y < 100) { m_printstr("\r\nW1"); if(i==2) exit_clean(); } else if(mouse_y < 200) m_printstr("\r\nW2"); else if(mouse_y < 300) m_printstr("\r\nW3"); else if(mouse_y < 400) m_printstr("\r\nW4"); else if(mouse_y < 500) m_printstr("\r\nW5"); else if(mouse_y < 600) m_printstr("\r\nW6"); else if(mouse_y < 700) m_printstr("\r\nW7"); else if(mouse_y < 800) m_printstr("\r\nW8"); else if(mouse_y < 900) m_printstr("\r\nW9"); else m_printstr("\r\nW10"); } /* is the boarder really 5 wide? */ else if((mouse_y > 105) &&(mouse_x < 945)) { /* in graphics window */ m_printstr("\r\nGRAPHICS WINDOW"); } else if((mouse_y < 100) && (mouse_x < 999)) { /* status window */ m_printstr("\r\nSTATUS WINDOW"); } else { /* not known yet */ m_printstr("\r\nUNKNOWN WINDOW"); } m_flush(); } exit_clean() { int i; /* m_nomenu2(); /* */ m_textreset(); m_font(0); m_ttyreset(); m_popall(); #if 0 printf("'%s': %d(x), %d(y), %d(border)\n", host_name, host_x, host_y, host_border); printf("graphics_x=%d,graphics_y=%d,graphics_w=%d,graphics_h=%d\n", graphics_x,graphics_y,graphics_w,graphics_h); printf("graphics_win = %d\n", graphics_win); printf("status_x=%d,status_y=%d,status_w=%d,status_h=%d\n", status_x,status_y,status_w,status_h); printf("status_win = %d\n", status_win); #endif fflush(stdin); fflush(stdout); exit(0); } make_graphics_window() { m_go(100,100); m_draw(950,100); m_draw(950,950); m_draw(100,950); m_draw(100,100); } make_status_window() { m_go(100,100); m_draw(100,0); m_go(999,100); m_draw(950,100); } make_w_window() { m_go(0,100); m_draw(100,100); m_go(0,200); m_draw(100,200); m_go(0,300); m_draw(100,300); m_go(0,400); m_draw(100,400); m_go(0,500); m_draw(100,500); m_go(0,600); m_draw(100,600); m_go(0,700); m_draw(100,700); m_go(0,800); m_draw(100,800); m_go(0,900); m_draw(100,900); m_draw(100,999); } -- Bradley Smith Network & Technical Services @ Bradley University, Peoria, IL brad@bradley.edu --- 309-677-2337