void drawRectangle() { int b, sx, sy, ex, ey, px, py; int c=cur_color; int x1=0,y1=0,x2=0,y2=0; setdrawmode(XOR_MODE); getmousepos(&b, &sx, &sy); set_color(15-c); ex = px = sx, ey = py = sy; if(b==1) hidemouseptr(); while(b == 1) { getmousepos(&b, &ex, &ey); if(px != ex || py != ey) { drawRect(sx, sy, px, py); drawRect(sx, sy, ex, ey); px = ex, py = ey; x1=sx;y1=sy; x2=ex;y2=ey; } } set_color(c); setdrawmode(COPY_MODE); array_line_entry(x1,y1,x2,y1); array_line_entry(x1,y1,x1,y2); array_line_entry(x2,y1,x2,y2); array_line_entry(x1,y2,x2,y2); drawRect(x1, y1, x2, y2); showmouseptr(); }
void drawSpiral() { int b, sx, sy, ex, ey, px, py; int c=cur_color; float r; setdrawmode(XOR_MODE); getmousepos(&b,&sx,&sy); set_color(15-c); ex = px = sx;ey = py = sy; if(b==1) hidemouseptr(); while(b == 1) { if(px != ex || py != ey) { set_color(cur_color); spiral((px+sx)/2, (py+sy)/2, r); px = ex; py = ey; r = (sx<px)?(px-sx)/2:(sx-px)/2; spiral((px+sx)/2, (py+sy)/2, r); } getmousepos(&b,&ex,&ey); } set_color(c); setdrawmode(COPY_MODE); r = (sx<px)?(px-sx)/2:(sx-px)/2; spiral((px+sx)/2, (py+sy)/2, r); showmouseptr(); }
void drawEllipse() { int b, sx, sy, ex, ey, px, py; int c=cur_color; float r1=0,r2=0; setdrawmode(XOR_MODE); getmousepos(&b,&sx,&sy); set_color(15-c); ex = px = sx;ey = py = sy; if(b==1) hidemouseptr(); while(b == 1) { getmousepos(&b,&ex,&ey); if(px != ex || py != ey) { bellipse((px+sx)/2, (py+sy)/2, r1, r2); px = ex;py = ey; r1 = (sx<px)?(px-sx)/2:(sx-px)/2; r2 = (sy<py)?(py-sy)/2:(sy-py)/2; bellipse((px+sx)/2, (py+sy)/2, r1, r2); } } r1 = (sx<px)?(px-sx)/2:(sx-px)/2; r2 = (sy<py)?(py-sy)/2:(sy-py)/2; set_color(c); setdrawmode(COPY_MODE); bellipse((px+sx)/2, (py+sy)/2,r1, r2); showmouseptr(); }
void user_poly() { int inix,iniy,curx1,cury1,curx2,cury2; int mousex,mousey,button; getmousepos(&button,&mousex,&mousey); inix=mousex; iniy=mousey; curx1=inix; cury1=iniy; for(;button!=2;getmousepos(&button,&mousex,&mousey)) { if(button==1) { curx2=mousex; cury2=mousey; //printf("%d %d\n",mousex,mousey); hidemouseptr(); array_line_entry(curx1,cury1,curx2,cury2); bresline(curx1,cury1,curx2,cury2,1); showmouseptr(); curx1=curx2; cury1=cury2; delay(200); } } hidemouseptr(); array_line_entry(curx1,cury1,inix,iniy); bresline(curx1,cury1,inix,iniy,1); showmouseptr(); }
void monitor_color(int n) { getmousepos(&button,&mousex,&mousey); for(;mousey<20;getmousepos(&button,&mousex,&mousey)) { if(mousex>20&&(mousex/20)<=n&&button==1) { cur_color=(mousex/20)%16; cur_pat=0; setfillstyle(1,cur_color); bar(500,3,600,17); setcolor(BLACK); rectangle(500,3,600,17); button_hover((2+(mousex/20)*20),2,(18+(mousex/20)*20),18); } else if(mousex>20&&(mousex/20)<=19&&button==1) { cur_pat=(mousex/20)-16; button_hover((2+(mousex/20)*20),2,(18+(mousex/20)*20),18); } else if(mousex<20&&button==1) { cur_panel=0; button_hover(2,2,18,18); top_panel_default(); top_panel_buttons(tool_but_num,0,1); start(); } } }
void drawThickLine(int op) { int b, sx, sy, ex, ey, px, py; int c=cur_color; int x1=-1,y1=-1,x2=-1,y2=-1; setdrawmode(XOR_MODE); getmousepos(&b,&sx,&sy); set_color(15-c); ex = px = sx; ey = py = sy; if(b==1) hidemouseptr(); while(b==1) { getmousepos(&b, &ex, &ey); if(px != ex || py != ey) { thickline(sx, sy, px, py,op); thickline(sx, sy, ex, ey,op); px = ex; py = ey; x1=sx;y1=sy; x2=ex;y2=ey; } } set_color(c); setdrawmode(COPY_MODE); thickline(x1, y1, x2, y2,op); showmouseptr(); }
void drawSpray() { int b,sx,sy; getmousepos(&b,&sx,&sy); if(b==1) hidemouseptr(); while(b==1) { getmousepos(&b,&sx,&sy); spray(sx,sy,cur_color); } showmouseptr(); }
void edge::onclick() { setfillstyle(SOLID_FILL,YELLOW); setcolor(RED); hidemouseptr(); bar(101,460,199,478); char *a="edge"; outtextxy(120,463,a); showmouseptr(); setfillstyle(SOLID_FILL,RED); while(flag==1) { getmousepos(); if(button==1&&x<639&&x>0&&y<459&&y>0&&edgenum<30) //if you click on workspace { a1=x; b1=y; while(flag==1) // waits for second click { getmousepos(); if(button==1&&x!=a1&&y!=b1) { a2=x; b2=y; break; } //takes second point when you click } // while end edgenum++; hidemouseptr(); givemid(a1,b1,a2,b2); //gives centers of two points if(givemid(a1,b1,a2,b2)==1&&edge::checkedge(x1,y1,x2,y2)==1) //condition false if you click outside the points { edge::display(x1,y1,x2,y2); //displays an edge } x1=y1=x2=y2=0; showmouseptr(); break; } //if end } // while end setfillstyle(SOLID_FILL,1); setcolor(15); hidemouseptr(); bar(101,460,199,478); outtextxy(120,463,a); showmouseptr(); setfillstyle(SOLID_FILL,RED); }
void shakil:: mixed() { tm=0;ne2=0; cleardevice(); showmouseptr(); settextstyle(1,0,1); show(); while(1) {getmousepos(&button,&x,&y); if((button & 1)==1) {cal(); resu(); show(); if(x>=470&&x<=520) {if(y>=370&&y<=390) {ne2=10; break; } if(y>=270&&y<=290) {save1(); } } } if(result==10) {settextstyle(1,0,10); outtextxy(50,100,"YOU WIN"); delay(1000); getch(); break; } } hidemouseptr(); result=0; cleardevice(); showmouseptr(); }
void main() { int gd=DETECT,gm,x,y,button,i; randomize(); for(i=0;i<20;i++) {n[i]=20;} for(i=0;i<20;i++) {n1[i]=20;} initgraph(&gd,&gm," "); sound(2350); outtextxy(250,150,"WELCOME TO PUZZLSE "); sleep(1); nosound();cleardevice(); setbkcolor(GREEN); mouse(); rectangle(200,200,300,230); rectangle(400,200,450,230); outtextxy(203,203,"START");outtextxy(403,203,"EXIT"); while(flag==0) { getmousepos(&button,&x,&y); if(button==1&&x>200&&x<300&&y>200&&y<230) {delay(500);hidemouseptr();number();} if(button==1&&x>400&&x<450&&y>200&&y<230)exit(0); } }
void rem_account() { cleardevice(); outer_function_screen("REMOVE ACCOUNT"); draw_button(220,225,425,255,1,"Remove Account"); draw_button(220,285,425,315,1," EXIT"); showmouseptr(); while(1) { getmousepos(&button,&corx,&cory); if((button&1)==1) { if((corx>220&&corx<425)&&(cory>225&&cory<255)) { hidemouseptr(); rm_menu(); return; } if((corx>220&&corx<425)&&(cory>285&&cory<315)) { hidemouseptr(); showadminmenu(); exit(0); } } } }
int changepassword() { cleardevice(); outer_function_screen("CHANGE PASSWORD"); draw_button(225,225,395,255,1,"Administrator"); draw_button(225,285,395,315,1,"Customer"); draw_button(225,345,395,375,1,"Exit"); showmouseptr(); while(1) { showmouseptr(); getmousepos(&button,&corx,&cory); if((button&1)==1) { if((corx>225&&corx<395)&&(cory>225&&cory<255)) { hidemouseptr(); return(ch_pass(0)); } if((corx>225&&corx<395)&&(cory>285&&cory<315)) { hidemouseptr(); return(ch_pass(1)); } if((corx>225&&corx<395)&&(cory>345&&cory<375)) { hidemouseptr(); closegraph(); exit(0); } } } }
void user_save() { int a,b,w,px,i=-1; char filename[60],ch; restrictmouseptr(0,0,xmax,20); hidemouseptr(); a=textwidth("Enter File Name"); setfillstyle(1,BLUE); bar(0,0,xmax,20); setcolor(BLACK); outtextxy(10,5,"Enter File Name:"); setfillstyle(1,WHITE); bar((a+10),2,(a+410),18); setfillstyle(1,CYAN); a=textwidth("No"); bar((xmax-10-a),2,(xmax-10),18); b=a+10+textwidth("Save"); bar((xmax-10-b),2,(xmax-20-a),18); setcolor(BLACK); outtextxy((xmax-9-b),3,"Save"); outtextxy((xmax-9-a),3,"No"); px=textwidth("Enter File Name")+10; while(1) { ch=get_filename(px,4); if(ch==13||ch==27) break; w=textwidth("A"); px+=w; filename[++i]=ch; } filename[++i]='\0'; showmouseptr(); for(;;) { getmousepos(&button,&mousex,&mousey); if(mousex>(xmax-10-a)&&mousex<(xmax-10)&&button==1) //deny loading/saving { button_hover((xmax-10-a),2,(xmax-10),18); hidemouseptr(); initmouse(); top_panel_default(); top_panel_buttons(tool_but_num,0,1); showmouseptr(); break; } else if(mousex>(xmax-10-b)&&mousex<(xmax-20-a)&&button==1) //confirm loading/saving { button_hover((xmax-10-b),2,(xmax-20-a),18); save_bitmap(filename); hidemouseptr(); initmouse(); top_panel_default(); top_panel_buttons(tool_but_num,0,1); showmouseptr(); break; } } }
void enter() { while(1) { if(successfullogin==1) break; show_close_button(); showmouseptr(); getmousepos(&button,&x,&y); if((button&1)==1) { corx=x; cory=y; if((corx>170&&corx<280)&&(cory>250&&cory<290)) { setcolor(WHITE); line(170,290,280,290); line(280,250,280,290); setcolor(DARKGRAY); line(170,250,280,250); line(170,250,170,290); delay(125); hidemouseptr(); resetloginform(); login(); } else if((corx>310&&corx<430)&&(cory>250&&cory<290)) { hidemouseptr(); setcolor(WHITE); line(310,290,430,290); line(430,250,430,290); setcolor(DARKGRAY); line(310,250,430,250); line(310,250,310,290); delay(125); f1=fopen("admin","r"); rewind(f1); fread(&admin,sizeof(admin),1,f1); if((strcmp(admin.loginid,loginid)==0) && (strcmp(admin.password,password)==0)) { successfullogin=1; return; } else { show_err("Wrong LoginID or Password"); resetloginform(); login(); } } else if((corx>618&&corx<630)&&(cory>8&&cory<20)) { show_exit_message(); delay(500); exit(0); } } } }
void main() { int gd=DETECT,gm,maxx,maxy,x,y,button,prevx,prevy; initgraph(&gd,&gm,"d:\\tc\\bgi"); printf("Freehand drawing with the mouse"); maxx=getmaxx(); maxy=getmaxy(); rectangle(0,0,maxx,maxy); setviewport(1,1,maxx-1,maxy-1,1); if(initmouse()==0) { closegraph(); restorecrtmode(); printf("Mouse driver not loaded"); exit(1); } restrictmouseptr(1,1,maxx-1,maxy-1); showmouseptr(); while(!kbhit()) { getmousepos(&button,&x,&y); if((button & 1)==1) { hidemouseptr(); prevx=x; prevy=y; while((button & 1)==1) { line(prevx,prevy,x,y); prevx=x; prevy=y; getmousepos(&button,&x,&y); } showmouseptr(); } } }
void drawCircle(int op) { int button,x,y,x1,x2,y1,y2,prevx2,prevy2; float r; int c=cur_color; setdrawmode(XOR_MODE); getmousepos(&button,&x,&y); set_color(15-c); if(button==1) { setdrawmode(XOR_MODE); hidemouseptr(); getmousepos(&button,&x,&y); x1=x;y1=y; x2=x;y2=y; r=(pow((x1-x2),2))+(pow((y1-y2),2)); r=pow(r,0.5); r=r/2.0; bcircle((x1+x2)/2,(y1+y2)/2,r,op); while(button==1) { prevx2=x2;prevy2=y2; getmousepos(&button,&x,&y); x2=x;y2=y; if(prevx2!=x2||prevy2!=y2) { r=(pow((x1-prevx2),2))+(pow((y1-prevy2),2)); r=pow(r,0.5); r=r/2.0; bcircle((x1+prevx2)/2,(y1+prevy2)/2,r,op); r=(pow((x1-x2),2))+(pow((y1-y2),2)); r=pow(r,0.5); r=r/2.0; bcircle((x1+x2)/2,(y1+y2)/2,r,op); } } set_color(c); setdrawmode(COPY_MODE); bcircle((x1+x2)/2,(y1+y2)/2,r,op); showmouseptr(); } }
void brush(int op) { int b,sx,sy,prec; prec=cur_color; if(op==2) set_color(WHITE); getmousepos(&b,&sx,&sy); if(b==1) hidemouseptr(); while(b==1) { getmousepos(&b,&sx,&sy); plotbrush(sx,sy,cur_color); } set_color(prec); showmouseptr(); }
void user_pickcolor() { int button,mousex,mousey; getmousepos(&button,&mousex,&mousey); cur_color=getpixel(mousex,mousey); setfillstyle(1,cur_color); bar(500,3,600,17); setcolor(BLACK); rectangle(500,3,600,17); hover_text(cur_tool); }
void pencil() { int x,y,button,prevx,prevy; getmousepos(&button,&x,&y); if(button==1) { hidemouseptr(); prevx=x; prevy=y; while(button==1) { if(!((abs(prevx-x))<=5&&(abs(prevy-y))<=5)) {bresline(prevx,prevy,x,y,1); prevx=x; prevy=y;} getmousepos(&button,&x,&y); } showmouseptr(); } }
void main() { int gdriver = DETECT, gmode; initgraph(&gdriver, &gmode, "\\tc\\bgi"); cleardevice(); king("ch1"); int Mstatus = initmouse(); int button,m,n; if(Mstatus == 0 ) outtextxy(50,50, "Mouse Support Not Available"); settextstyle(2,0,4); while(1) { showmouseptr(); getmousepos(&button,&m,&n); if(m>245 && m<325 && n>220 && n<232) { setcolor(RED); outtextxy(250,220,"PLAYER vs PLAYER"); } else { setcolor(WHITE); outtextxy(250,220,"PLAYER vs PLAYER"); if(m>245 && m<325 && n>240 && n<252) { setcolor(RED); outtextxy(250,240,"CHESS PUZZLES"); } else { setcolor(WHITE); outtextxy(250,240,"CHESS PUZZLES"); if(m>245 && m<325 && n>260 && n<272) { setcolor(RED); outtextxy(250,260,"BACK"); } else { setcolor(WHITE); outtextxy(250,260,"BACK"); }}} if(button == 1) { if(m>245 && m<325 && n>220 && n<232) { hidemouseptr(); video(450,150); createnewfile(); spawnl(P_WAIT,"load.exe", NULL); // load spawnl(P_WAIT,"chess.exe", NULL); // player vs player cleardevice(); king("ch1"); } if(m>245 && m<325 && n>240 && n<252) { hidemouseptr(); video(450,150); spawnl(P_WAIT,"menu6.exe", NULL); } // chess puzzles menu // exit(0); } if(m>245 && m<325 && n>260 && n<272) { hidemouseptr(); video(450,150); // spawnl(P_WAIT,"g:\\exe\\menu1.exe", NULL); // back to main menu break; }}}}
//------------------------------------------------------------ void Control() { do { _1.button_effect();_2.button_effect();_3.button_effect(); _4.button_effect();_5.button_effect();_6.button_effect(); _7.button_effect();_8.button_effect();_9.button_effect(); _ER.button_effect();_1.higlt(curr); restrictmouse(); showmouse(); get_mouse(); getmousepos(); wait_mouse(); hide_mouse(); } while(1); }
void main() { int gd=DETECT,gm,maxx,maxy,x,y,button; initgraph(&gd,&gm,"C:\\TC"); maxx=getmaxx(); maxy=getmaxy(); rectangle(0,56,maxx,maxy); setviewport(1,57,maxx-1,maxy-1,1); gotoxy(26,1); printf("MOUSE DEMONSTRATION PROGRAM"); if(initmouse()==0) { closegraph(); restorecrtmode(); printf("\nMouseDriver not loaded"); exit(0); } restrictmouseptr(1,57,maxx-1,maxy-1); showmouseptr(); gotoxy(1,2); printf("Left Button"); gotoxy(15,2); printf("Right Button"); gotoxy(55,3); printf("Press Any Key to Exit..."); while(!kbhit()) { getmousepos(&button,&x,&y); gotoxy(5,3); (button & 1)==1? printf("DOWN") : printf("UP "); gotoxy(20,3); (button & 2)==2? printf("DOWN") : printf("UP "); gotoxy(65,2); printf("x=%03d y=%03d",x,y); } }
void main() { int gd=DETECT,gm,maxx,maxy,x,y,button; initgraph(&gd,&gm,"c:\\tc\\bgi"); maxx=getmaxx(); maxy=getmaxy(); rectangle(0,56,maxx,maxy); setviewport(1,57,maxx-1,maxy-1,1); gotoxy(26,1); printf("Mouse Demonstration Program!"); if(initmouse()==0) { closegraph(); restorecrtmode(); printf("Mouse driver not loaded"); exit(1); } restrictmouseptr(1,57,maxx-1,maxy-1); showmouseptr(); gotoxy(1,2); printf("Left Button"); gotoxy(15,2); printf("Right Button"); gotoxy(55,3); printf("Press any key to exit"); while(!kbhit()) { getmousepos(&button,&x,&y); gotoxy(5,3); (button&1)==1 ? printf("DOWN"):printf("UP"); gotoxy(20,3); (button&2)==2 ? printf("DOWN"):printf("UP"); gotoxy(65,2); printf("X=%03d y=%03d",x,y); } }
int user_new() { int a,b; restrictmouseptr(0,0,xmax,20); hidemouseptr(); a=textwidth("This Action will erase current drawing, Continue?")+10; setfillstyle(1,BLUE); bar(0,0,xmax,20); settextstyle(0,0,1); setcolor(BLACK); outtextxy(10,5,"This Action will erase current drawing, Continue?"); setfillstyle(1,CYAN); bar((a+18),1,(a+18+textwidth("Ya")+2),18); outtextxy((a+20),5,"Ya"); b=a+textwidth("Ya")+10; bar((b+18),1,(b+18+textwidth("Na")+2),18); outtextxy((b+20),5,"Na"); showmouseptr(); for(;;) { getmousepos(&button,&mousex,&mousey); if(mousex>(a+20)&&mousex<b+10&&button==1) //new confirm { hidemouseptr(); initmouse(); draw_canvas_default(); top_panel_default(); top_panel_buttons(tool_but_num,0,1); showmouseptr(); arrcnt=-1; return 1; } else if(mousex>b+20&&mousex<(b+36)&&button==1) //deny new { hidemouseptr(); initmouse(); top_panel_default(); top_panel_buttons(tool_but_num,0,1); showmouseptr(); return 0; } } }
int check_next_button() { showmouseptr(); while(1) { getmousepos(&button,&x,&y); if((button&1)==1) { if(((x>400)&&(x<465))&&((y>410)&&(y<440))) { hidemouseptr(); return 0; } if(((x>475)&&(x<540))&&((y>410)&&(y<440))) { hidemouseptr(); return 1; } } } }
void top_message(char *message) { top_panel_default(); restrictmouseptr(0,0,xmax,20); hidemouseptr(); setcolor(BLACK); outtextxy(10,3,message); showmouseptr(); for(;;) { getmousepos(&button,&mousex,&mousey); if(mousex>619&&button==1) { hidemouseptr(); button_hover((xmax-13),4,(xmax-4),11); initmouse(); showmouseptr(); return; } } }
void main() {int gd=DETECT,gm; initgraph(&gd,&gm,"e:\\tc\\bgi"); int button,x,y; restrictmouseptr(55,445,585,445); //55,445,585,455 xx: int yy; shakil ob; ob.life(); ob.get(); ob.bo1(); ob.pic(); while(1) { getmousepos(&button,&x,&y); ob.calcu(x,y); ob.show(); int a=ob.oo+ob.mn; if(a>=25) a=25; delay(40-a); if((button & 2)==2) {goto xy; } if((button & 1)==1) ob.free(); if(ob.li==0) {outtextxy(30,300,"IF YOU WANT TO PLAY AGAIN PRESS 1 OR OTHED"); scanf("%d",&yy); if(yy==1) goto xx; else goto xy; } } xy: closegraph(); }
void node::onclick() { setfillstyle(SOLID_FILL,YELLOW); setcolor(RED); hidemouseptr(); bar(1,460,99,478); char *a="node"; outtextxy(20,463,a); showmouseptr(); setfillstyle(SOLID_FILL,RED); while(flag==1) { getmousepos(); if(button==1&&x<639&&x>0&&y<459&&y>0&&nodenum<30&&(node::check(x,y)==1)) //if you click on workspace { nodenum++; n[nodenum].id=nodenum; // n[nodenum].name n[nodenum].x=x; n[nodenum].y=y; hidemouseptr(); node::display(x,y,nodenum); // a node will be displayed showmouseptr(); break; } if(nodenum>=30||(button==1&&(node::check(x,y)==0)))//if node is present { break; } } setfillstyle(SOLID_FILL,1); setcolor(15); hidemouseptr(); bar(1,460,99,478); outtextxy(20,463,a); showmouseptr(); setfillstyle(SOLID_FILL,RED); }
void main() { // VARIABLE DECLARATIONS int i=0,j=0,a,front=-1,rear=-1; char ch,ch1; int item; // FUNCTION PROTOTYPE DECLARATIONS void show(); void slidebar(int *rear,int *front); void showqueuesize(); void slidebar(); void cpoiters(); void drawq(); void moveptrs(int *rear,int *front); void insertq(int *rear,char c); void deleteq(int *front); void qdelete(int q[],int rear,int front); void hidequeueinfo(); void shownumbers(int x1,int y1,int x2,int y2); int initmouse(); void getmousepos(int *button,int *x,int *y); void showmouseptr(); void restrictmouseptr(int a,int b,int c,int d); void exitbutton(int x1,int y1,int x2,int y2,int e_x,int e_y,int xit_x,int xit_y); void zoomin(); // CHECKING THE GRAPHICS DRIVER int gd=DETECT,gm,maxx,maxy,x,y,button; initgraph(&gd,&gm,"c:\\TC"); // GET THE MAXIMUM X AND Y CO ORDINATES maxx=getmaxx(); maxy=getmaxy(); // DRAW THE BORDER FOR THE WINDOW rectangle(0,0,maxx,maxy); // SET THE AREA WITHIN THE SCREEN WHERE GRAPHICAL O/P DISPLAYED setviewport(1,1,maxx-1,maxy-1,1); // WRITE THE HEADDING gotoxy(150,1); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); setcolor(WHITE); setbkcolor(216); settextjustify(0,2); outtextxy(220,2," LINEAR QUEUE "); setcolor(RED); settextstyle(8,HORIZ_DIR,3); outtextxy(40,35,"DEVELOPED IN 'C' : IT'S A KVSM PRODUCT"); settextstyle(0,HORIZ_DIR,0); // INITIALIZE MOUSE,IF IT DOESN'T GET INITIALIZED CLOSE GRAPHICS MODE if (initmouse()==0) { closegraph(); restorecrtmode(); printf("\nMouse Driver not installed"); exit(1); } // IF MOUSE DRIVER INITIALISED THEN // RESTRICT THE MOUSE POINTER WITHIN THE COORDINATES GIVEN GIVEN BELOW restrictmouseptr(1,57,maxx-1,maxy-1); // SHOW THE MOUSE POINTER showmouseptr(); // SET THE TEXT COLOR TO WHITE setcolor(WHITE); line(0,70,getmaxx(),70); line(0,400,getmaxx(),400); setcolor(14); outtextxy(65,115,"QUEUE OPERATIONS QUEUE STATUS"); outtextxy(140,440,"Press the Key that is Highlighted or use Mouse."); setcolor(CYAN); line(65,125,190,125); line(368,125,464,125); // CALL THE SHOW FUNCTION TO DRAW THE VARIOUS BUTTONS show(); // DRAW THE QUEUE drawq(); // DRAW THE POINTERS THAT IS FRONT AND REAR moveptrs(&rear,&front); // SET THE LABEL M THAT WILL BE USED LATER FOR UNCONDITIONAL JUMP m: // GO ON CHECKING WHETHER A KEY IS PRESSED OR NOT while (i==0) { if (kbhit()) { ch=getche(); // CHECK IF THE KEY PRESSED IS E OR e switch(ch) { case 'e': case 'E': { // CALL THE FUNCTION THAT WILL BE FOR EXIT zoomin(); } reset: case 'R': case 'r': { // CALL THE RESET QUEUE FUNCTION hidequeueinfo(); // CALL THE PROGRESSBAR slidebar(&rear,&front); // AGAIN DRAW THE QUEUE drawq(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } queueinfo: case 'A' : case 'a': { // CALL THE FUNCTION TO GIVE INFORMATION ABOUT QUEUE hidequeueinfo(); showqueuesize(); goto m; } delet: case 'D': case 'd': { // CALL THE DELETE QUEUE OPERATIONS hidequeueinfo(); deleteq(&front); // CHECK IF QUEUE IS EMPTY, IF SO PRINT THE MESSAGE if(rear==-1 || front==5 ||rear<front) { // CLEAR THE INFO, THERE IN INFORMATION PART hidequeueinfo(); // DISPLAY THE TEXT IN THE INFORMATION PART outtextxy(200,430,"Queue is empty, you can't delete"); } else { front=front+1; moveptrs(&rear,&front); } goto m; } ins: case 'I': case 'i': { // HERE IS THE OPERATIONS FOR INSERTING AN ELEMENT hidequeueinfo(); if(rear==4) { hidequeueinfo(); outtextxy(200,430,"Queue is full, you can't insert"); goto m; } // SHOWS THE NUMBERS AND CANCEL BUTTON shownumbers(20,430,60,470); // CHECK FOR WHAT KEY PRESSED n: while(j==0) { if (kbhit()) { ch1=getche(); if(front==-1) { front=front+1; } switch(ch1) { cancel: case 'C': case 'c': { hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } zero: case '0': { insertq(&rear,'0'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } one: case '1': { insertq(&rear,'1'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } two: case '2': { insertq(&rear,'2'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } three: case '3': { insertq(&rear,'3'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } four: case '4': { insertq(&rear,'4'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } five: case '5': { insertq(&rear,'5'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } six: case '6': { insertq(&rear,'6'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } seven: case '7': { insertq(&rear,'7'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } eight: case '8': { insertq(&rear,'8'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } nine: case '9': { insertq(&rear,'9'); rear=rear+1; moveptrs(&rear,&front); hidequeueinfo(); restrictmouseptr(1,57,maxx-1,maxy-1); goto m; } default : hidequeueinfo(); outtextxy(200,430,"Invalid Key Pressed ! Press a valid key"); delay(550); hidequeueinfo(); shownumbers(20,430,60,470); goto n; } } else { //write code here to press the 0-----9 and cancel getmousepos(&button,&x,&y); if((button & 1)==1) { if(front==-1) { front=front+1; } } if( (x>500 && x<getmaxx()-10 && y>445 && y<470) && (button & 1)==1) { goto cancel; } if( (x>20 && x<60 && y>430 && y<470) && (button & 1)==1) { goto zero; } if( (x>60 && x<100 && y>430 && y<470) && (button & 1)==1) { goto one; } if( (x>100 && x<140 && y>430 && y<470) && (button & 1)==1) { goto two; } if( (x>140 && x<180 && y>430 && y<470) && (button & 1)==1) { goto three; } if( (x>180 && x<220 && y>430 && y<470) && (button & 1)==1) { goto four; } if( (x>220 && x<260 && y>430 && y<470) && (button & 1)==1) { goto five; } if( (x>260 && x<300 && y>430 && y<470) && (button & 1)==1) { goto six; } if( (x>300 && x<340 && y>430 && y<470) && (button & 1)==1) { goto seven; } if( (x>340 && x<380 && y>430 && y<470) && (button & 1)==1) { goto eight; } if( (x>380 && x<420 && y>430 && y<470) && (button & 1)==1) { goto nine; } } } } default : hidequeueinfo(); outtextxy(220,420,"Please Press a Valid Key"); goto m; } } // ELSE CONDITION FOR THE IF AFTER THE FIRST WHILE else { getmousepos(&button,&x,&y); if( (x>50 && x<200 && y<370 && y>350) && (button & 1)==1) { //exit button click zoomin(); } if( (x>50 && x<200 && y>150 && y<170) && (button & 1)==1) { //clicked the queueinfo button goto queueinfo; } if( (x>50 && x<200 && y>200 && y<220) && (button & 1)==1) { //clicked the insert button goto ins; } if( (x>50 && x<200 && y>250 && y<270) && (button & 1)==1) { //clicked the delete button delay(500); goto delet; } if( (x>50 && x<200 && y>300 && y<320) && (button & 1)==1) { //clicked the reset button goto reset; } } } getche(); }
//--------------------------------------------------------------- void wait_mouse() { // quit via menu if(code==44) { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(240,265,"YES");delay(200); closegraph();exit(0); } if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(357,265,"NO");delay(200); code = 0; Message_Box(); } return; } // quit via corner button if(o.x.cx>=613 && o.x.dx>=7 && o.x.cx<=638 && o.x.dx<=27) { code = 44; // quit fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); settextstyle(0,0,1); setcolor(WHITE); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"EXIT ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); return; } /////////////////////////////////////////// if(code == 47) // load a game from file { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(235,265,"OPEN"); delay(200); load(); Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); code = 0; fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); } //-------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(343,265,"CANCEL");delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } /////////////////////////////////////////// if(code == 48) // save a game to file { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(245,265,"OK"); delay(200); save(); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); } //-------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(343,265,"CANCEL"); delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } /////////////////////////////////////////// ////////////////////////////////////////// if(code == 42) // resign { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(240,265,"YES"); delay(200); Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); for(int i=0;i<9;i++) for(int j=0;j<9;j++) { arr[i][j] = puzz[i][j]; } Message_Box(); for( i=0;i<9;i++) for( j=0;j<9;j++) { arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0; } code = 0; puz_typ = 0; frame(5,31,260,90,BLUE,BLUE,BLUE); frame(45,31,105,70,BLUE,BLUE,BLUE); menubar(); return; } //------------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(357,265,"NO"); delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } if(menu_bar_effect()) { return; } if( o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=85 && men_stat == 4 && puz_typ != 0) { men_stat = 0; if( o.x.dx<=42 ) { if(code != 41) // pause { code = 41;fill_maze(); } else if(code == 41) // resume { code = 0; fill_maze(); while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } } else if( o.x.dx<=55 ) // Resign(); { if(code != 41) // not pause { code = 42; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"RESIGN ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); } } else if( o.x.dx<=72 ) // Hint { if(code != 41) { char *an; int i,j,curr,flag=1; settextstyle(6,0,4); for(i=0;i<9;i++) for(j=0;j<9;j++) if(arr[i][j] != puzz[i][j]) { flag = 0; break; } if(flag == 0 && cnt != 81) { while(1) { i = abs(rand() % 9),j = abs(rand() % 9); if(stat[i][j]==0 && (arr[i][j]==0 || arr[i][j]!=puzz[i][j] )) break; } curr = puzz[i][j]; stat[i][j] = arr[i][j] = hnt[i][j] = curr; cnt++; switch(curr) { case 1: an="1"; break; case 2: an="2"; break; case 3: an="3"; break; case 4: an="4"; break; case 5: an="5"; break; case 6: an="6"; break; case 7: an="7"; break; case 8: an="8"; break; case 9: an="9"; break; case 10: an=" "; break; } int l=((i*40)+150); int t=((j*40)+100); setcolor(BLACK); for(int k=l+4;k<l+40-4;k++) line(k,t+4,k,t+40-4); setcolor(YELLOW); outtextxy((i*40)+165 ,(j*40)+95 ,an); }}} else if( o.x.dx<=85 ) // Submit { Usr_Submit(); } while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } /////////////////////////////////////////////////////////////////////////// if( o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=60 && men_stat == 3 && puz_typ != 0) // reset { men_stat = 0; if(o.x.dx<=42) // reset { for(int i=0; i<9 ; i++) for(int j=0; j<9 ; j++) { if( stat[i][j] == 0 && arr[i][j] != 0 ) { arr[i][j] = 0; } } code = 41;fill_maze(); code = 0;fill_maze(); } else if( o.x.dx<=55 ) // Timer { } while(o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } ////////////////////////////////////////////////////////////////////////// else if( o.x.cx>=5 && o.x.dx>=27 && o.x.cx<=66 && o.x.dx<=70 && men_stat == 1) { men_stat = 0; if( o.x.dx<=42 ) // save game to a file { if( puz_typ <= 0) { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"SAVE GAME"); setcolor(BLACK); outtextxy(230,231," NO GAME TO SAVE"); delay(900); Message_Box(); } else { code = 48; File_name[0] = '\0'; nam_siz = 0; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"SAVE GAME"); setcolor(BLACK); outtextxy(203,211,"ENTER THE FILE NAME : "); frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(245,265,"OK"); outtextxy(343,265,"CANCEL"); } } else if( o.x.dx>=42 && o.x.dx<=55 ) // load { code = 47; // load File_name[0] = '\0'; nam_siz = 0; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(260,190,"OPEN A FILE"); setcolor(BLACK); outtextxy(203,211,"ENTER THE FILE NAME : "); frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(235,265,"OPEN"); outtextxy(343,265,"CANCEL"); } else if( o.x.dx<=72 ) { code = 44; // quit fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"EXIT ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); } } // new puzzle :- else if( o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70 && men_stat == 2) { men_stat = 0; for(int i=0;i<9;i++) for(int j=0;j<9;j++) arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0; cnt = 0; Message_Box(); // clears the board if( o.x.dx<=42 ) puz_typ = 1; // EASY else if(o.x.dx<=55) puz_typ = 2; // MEDIUM else if(o.x.dx<=72) puz_typ = 3; // HARD generate_puzzle(puz_typ); fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); return; } // help else if( o.x.cx>=175 && o.x.dx>=31 && o.x.cx<=250 && o.x.dx<=60 && men_stat == 5) { men_stat = 0; if( o.x.dx<=42 ) // about { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"ABOUT"); setcolor(BLACK); outtextxy(203,211,"Puzzle Sudoku ver. 1.3"); outtextxy(203,235,"For more details contact"); outtextxy(203,256," [email protected] "); delay(3000); } else if( o.x.dx<=55 ) // credit { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"CREDITS"); setcolor(BLACK); outtextxy(203,211," Made by : "); outtextxy(203,225," Tejas. A. Patil "); outtextxy(203,236," SE I.T MIT , Pune "); outtextxy(203,249,"I am thankful to my "); outtextxy(203,260,"Parents , Teachers and"); outtextxy(203,271,"Friends for their support"); outtextxy(203,282," and help."); delay(3000); } Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); frame(45,31,105,70,BLUE,BLUE,BLUE); menubar(); } // board if(o.x.cx>=150 && o.x.dx>=100 && o.x.cx<=510 && o.x.dx<=460) { int xr = (o.x.cx-150)/40, yr = (o.x.dx-100)/40; if(code > 40 ) return; if(puz_typ == 0 ) return; if(curr != 10 && arr[xr][yr] != 0) Number_Pad(arr[xr][yr]-1); if(stat[xr][yr] != 0 ) return; if(cnt == 81 && curr != 10) return; else { char *an; settextstyle(6,0,4); setcolor(LIGHTCYAN); switch(curr) { case 1: an="1"; break; case 2: an="2"; break; case 3: an="3"; break; case 4: an="4"; break; case 5: an="5"; break; case 6: an="6"; break; case 7: an="7"; break; case 8: an="8"; break; case 9: an="9"; break; case 10: an=" "; break; } do { if(curr != 10 && arr[xr][yr] == 0 && cnt != 81) { outtextxy((xr*40)+165, (yr*40)+95, an); } else if (curr == 10) { int l=((xr*40)+150); int t=((yr*40)+100); setcolor(BLACK); for(int k=l+4;k<l+40-4;k++) line(k,t+4,k,t+40-4); setcolor(WHITE); } restrictmouse(); showmouse(); getmousepos(); } while(o.x.cx>=((xr*40)+150) && o.x.dx>=((yr*40)+100) && o.x.cx<=((xr*40)+190) && o.x.dx<=((yr*40)+140) ); if(curr != 10 && arr[xr][yr] == 0 && cnt != 81) cnt++; else if(curr == 10 && arr[xr][yr] != 0) cnt--; arr[xr][yr] = (curr%10); } } if(o.x.cx>=40 && o.x.dx>=130 && o.x.cx<=70 && o.x.dx<=430 && code < 40 && puz_typ != 0) { int p = (o.x.dx-130)/30; Number_Pad(p); } if(men_stat != 0) { men_stat = 0; frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } }