int popup( char* menu[], char* keys, int count, int x, int y, int border ) /*弹出式菜单的显示*/ { register int i, len; int endx, endy, choice; unsigned int *p; if((x>24)||(x<0)||(y>79)||(y<0)) { printf("范围错"); return -2; } len = 0; for( i = 0; i < count; i++ ) if( strlen( menu[i]) > len ) len = strlen( menu[i] ); endy = len + 2 + y; endx = count + 1 + x; if((endx+1>24)||(endy+1>79)) { printf("菜单不匹配"); return -2; } p = (unsigned int *) malloc((endx-x+1)*(endy-y+1)); if( !p ) exit(1); save_video( x, endx + 1, y, endy+1, p ); if( border ) disp_box( y, x, endy, endx, YELLOW ); display_menu( menu, x + 1, y + 1, count ); choice = get_resp( x + 1, y, count, menu, keys ); restore_video( x, endx + 1, y, endy + 2, (unsigned char* ) p); free( p ); return choice; }
int yes_no_box::check() { int x=(x1+x2)/2; int y=(y1+y2)/2+50; get_button_press(0); if(mclick==1) { hide_mouse(); if(mx>=x-100 && mx<=x-60 && my>=y-10 && my<=y+10) { setcolor(BLACK); line(x-100,y-10,x-60,y-10); line(x-100,y-10,x-100,y+10); setcolor(WHITE); line(x-100,y+10,x-60,y+10); line(x-60,y-10,x-60,y+10); delay(100); setfillstyle(SOLID_FILL,WHITE); bar(x1,y1,x2,y2); restore_video(x1,y1,1); show_mouse(); return 1; } else if(mx>=x+60 && mx<=x+100 && my>=y-10 && my<=y+10) { setcolor(BLACK); line(x+60,y-10,x+100,y-10); line(x+60,y-10,x+60,y+10); setcolor(WHITE); line(x+60,y+10,x+100,y+10); line(x+100,y-10,x+100,y+10); delay(100); setfillstyle(SOLID_FILL,WHITE); bar(x1,y1,x2,y2); restore_video(x1,y1,1); show_mouse(); return 0; } } show_mouse(); return -1; }
int error_box::check() { get_button_press(0); if(mclick==1 && mx>=x1+100 && mx<=x1+140 && my>=y2-40 && my<=y2-20) { setcolor(BLACK); line(x1+100,y2-40,x1+140,y2-40); line(x1+100,y2-40,x1+100,y2-20); setcolor(WHITE); line(x1+100,y2-20,x1+140,y2-20); line(x1+140,y2-40,x1+140,y2-20); delay(100); hide_mouse(); setfillstyle(SOLID_FILL,WHITE); bar(x1,y1,x2,y2); show_mouse(); restore_video(x1,y1,1); delay(200); return 0; } return 1; }