slt,j'ai cette erreur dans mon programme en VC++ erreur
1>------ Rebuild All started: Project: test4, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
1>d:\documents and settings\ayoub\mes documents\visual studio 2010\Projects\test4\Debug\test4.exe : fatal error LNK1120: 1 unresolved externals
======== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
comment fixer cette erreur de liker??
//A GRAPHICS PROJECT BY JAGAT SASTRY P. & CHARITH CHOWDARY K.P.//
//2ND YEAR COMPUTER ENGINEERING//
//NITK SURATHKAL//
//NOTE TO USERS: CHANGE THE BGI DIRECTORY TO THAT OF YOURS(LINE 2926)//
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include
#define MIN_X 83
#define MAX_X 629
#define MIN_Y 35
#define MAX_Y 409
#define MAX_BUTTONS 27
#define MAX_COLPAT 28
int check_mouse_on(int,int,int,int);
void quit();
void end_about();
void init_button(int,int,int,int,int,char*,int);
void init_color_button(int,int,int,int,int,int);
void draw_button_border(int );
void undraw_button_border(int no);
void draw_color_button_border(int,int);
void disp_coord();
void getxy();
void topic();
void ffill(int x,int y,int backColor,int fill_color);
void DDA_line(int,int,int,int,int);
void algoellipse(int,int,float,float);
void plotellipsepoints(int,int,int,int);
int over(int,int,int,int);
void unmark();
void translate();
void rotate();
void scale();
char* readline(char*);
void about();
void create_box(int,int,int,int,int,int,int);
void new_file();
void save();
void load();
void dark();
void light();
void invert();
void blackwhite();
void ShowStatus(char*);
void ClearStatus();
void beep();
void Line_ico(int x1, int y1);
void Rectangle_ico(int x1, int y1);
void Circle_ico(int x1, int y1);
void Spiral_ico(int x1,int y1);
void Brush_ico(int x1, int y1);
void Erase_ico(int x1, int y1);
void Bucket_ico(int x,int y);
void Cube_ico(int x, int y);
void Sphere_ico(int x1, int y1);
void Mark_ico(int x1, int y1);
void Clip_ico(int x1, int y1);
void Alphabet_ico(int x, int y);
void Ellipse_ico(int x1,int y1);
void Del_ico(int x1,int y1);
int button,x,y;
int LeftButtonPressed;
int RightButtonPressed;
int precolflag;
int prevx,prevy;
int mousex,mousey;
int Current_Color=BLACK; /*/ to Store the current color */
int Current_Pattern=EMPTY_FILL;/*/ to store the current Pattern*/
int Current_Button=5;/*/ to store the current button pressed*/
int Prev_Button=4;/*/ to store the previous button */
int saved=0;
char FileName[40]="Untitled";
int previ=Current_Button;
union REGS i,o;
char buffer1[40000];
struct
{
int top,left,bottom,right;
}marker;
int marked=0; /*/ to store whether marked or not*/
int initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
void startmouse(int x,int y)
{
i.x.ax=4;
i.x.cx=x;
i.x.dx=y;
int86(0x33,&i,&o);
}
void getxy()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,®s,®s);
prevx=mousex;
prevy=mousey;
if(regs.x.bx&1)
LeftButtonPressed=1;
else
LeftButtonPressed=0;
if(regs.x.bx&2)
RightButtonPressed=1;
else
RightButtonPressed=0;
mousex=regs.x.cx;
mousey=regs.x.dx;
}
void cut()
{
ShowStatus("do not cut large areas");
if(marked)
{
unmark();
//int height=marker.bottom-marker.top;
//int length=marker.right-marker.left;
//int area=imagesize(marker.left,marker.top,marker.right,marker.bottom);
//buffer1=(int*)malloc(sizeof(int)*(height*length+20));
//buffer1[0]=length;
//buffer1[1]=height;
int i,j,k=0;
for(i=marker.top;i<marker.bottom;i++)
for(j=marker.left;j<marker.right;j++)
buffer1[k++]=getpixel(j,i);
hidemouseptr();
for(i=marker.left;i<marker.right;i++)
for(j=marker.top;j<marker.bottom;j++)
{
putpixel(i,j,WHITE);
}
showmouseptr();
}
}
//int *buffer;
void copy()
{
ShowStatus("do not copy large areas");
if(marked)
{
unmark();
int height=marker.bottom-marker.top;
int length=marker.right-marker.left;
//int area=imagesize(marker.left,marker.top,marker.right,marker.bottom);
//buffer1=(int*)malloc(sizeof(int)*(height*length+20));
buffer1[0]=length;
buffer1[1]=height;
int i,j,k=0;
for(i=marker.top;i<marker.bottom;i++)
for(j=marker.left;j<marker.right;j++)
buffer1[k++]=getpixel(j,i);
}
}
void paste(int x1,int y1)
{
int i,j,xt,yt,k=0;
//int height=buffer1[1];
//int length=buffer1[0];
//printf("hello");
hidemouseptr();
int h=marker.bottom-marker.top;
int l=marker.right-marker.left;
for(i=y1;i<y1+h;i++)
for(j=x1;j<x1+l;j++)
{
if(j>MIN_X && j<MAX_X && i>MIN_Y && i<MAX_Y)
putpixel(j,i,buffer1[k++]);
}
showmouseptr();
//free(buffer1);
}
void callpaste()
{
delay(500);
LeftButtonPressed=0;
while(1)
{
getxy();
if(LeftButtonPressed)
{
//printf("hi");
if(mousex<MIN_X || mousex>MAX_X || mousey<MIN_Y || mousey>MAX_Y)
return ;
paste(mousex,mousey);
return ;
}
else if(RightButtonPressed)
return;
}
}
void getmousepos(int *button,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
if(o.x.bx&1)
LeftButtonPressed=1;
else
LeftButtonPressed=0;
if(o.x.bx&2)
RightButtonPressed=1;
else
RightButtonPressed=0;
prevx=mousex;
prevy=mousey;
mousex=o.x.cx;
mousey=o.x.dx;
*x=o.x.cx;
*y=o.x.dx;
}
int buttclicked()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,®s,®s);
return regs.x.bx;
}
void wheremouse(int *x,int*y)
{
union REGS regs;
regs.x.ax=3;
int86(0x33,®s,®s);
*x=regs.x.cx;
*y=regs.x.dx;
}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
}
/* This if the description of the tooolbar button */
typedef struct button_desc
{
int xmin,ymin,xmax,ymax;
int button_no;
char* desc;
int popup;
}tool_but;
tool_but buttons[MAX_BUTTONS];
/* This is the description of the color button */
typedef struct color_button
{
int xmin,ymin,xmax,ymax;
int color;
int colflag;
}color_but;
color_but colorbuttons[28];
void freehand()
{
setcolor(Current_Color);
if(prevx<MIN_X+2||prevx>MAX_X-2||prevy>MAX_Y-2||prevy<MIN_Y+2)
return;
while(LeftButtonPressed)
{
disp_coord();
line(mousex,mousey,prevx,prevy);
getxy();
}
}
void erase()
{
int i,j;
while(LeftButtonPressed)
{
disp_coord();
for(i=mousex;i<mousex+10&&i<=MAX_X-2;++i)
for(j=mousey;j<mousey+10&&j<=MAX_Y-2;++j)
putpixel(i,j,WHITE);
getmousepos(&button,&x,&y);
}
}
void drawline()
{
int color=15-Current_Color;
int x,y;
setcolor(color);
setwritemode(XOR_PUT);
x=mousex;
y=mousey;
if(x<MIN_X+2||x>MAX_X-2||y>MAX_Y-2||y<MIN_Y+2)
return;
while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
line(x,y,prevx,prevy);
line(x,y,mousex,mousey);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
line(x,y,mousex,mousey);
}
void drawrectangle()
{
int color=15-Current_Color;
int x,y;
setcolor(color);
setwritemode(XOR_PUT);
x=mousex;
y=mousey;
while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
rectangle(x,y,prevx,prevy);
rectangle(x,y,mousex,mousey);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
if(Current_Pattern==EMPTY_FILL)
rectangle(x,y,mousex,mousey);
else
{
setfillstyle(Current_Pattern,Current_Color);
bar(x,y,mousex,mousey);
}
}
void drawtext()
{
int size=0,max_char,i=0;
char ch;
char str[68]; /*/ ( (MAX_X-2)-(MIN_X+2) )/8 ,8 being width & height of a char*/
char blank[68]; /*/ to write blank*/
max_char=(MAX_X-2-mousex)/8;
if((MAX_Y-2-mousey<9) || (max_char<1))
{
ShowStatus(" Not Enough Space to Write ");
beep();
ClearStatus();
return;
}
ShowStatus("Press <Enter> or <Esc> to exit");
fflush(stdin);
str[0]='\0';
ch=getch();
while(ch!=13 && ch!=27)
{
if (ch==8)
{
if(size<1)
beep();
else
{
setcolor(WHITE);
strcpy(blank,"");
for(i=0;i<size;++i)
blank[i]='غ';
blank[size]='\0';
outtextxy(mousex,mousey,blank);
setcolor(Current_Color);
size--;
str[size]='\0';
outtextxy(mousex,mousey,str);
}
}
else if(size==max_char)
{
beep();
}
else
{
size++;
setcolor(WHITE);
strcpy(blank,"");
for(i=0;i<size;++i)
blank[i]='غ';
blank[size]='\0';
outtextxy(mousex,mousey,blank);
str[size-1]=ch;
setcolor(Current_Color);
str[size]='\0';
outtextxy(mousex,mousey,str);
}
ch=getch();
}
ClearStatus();
}
struct node1
{
int x,y;
struct node1* next;
};
struct node1 *last1,*root1,*p1;
void insert(int x,int y)
{
struct node1 *new1;
new1=(struct node1*)malloc(sizeof(struct node1));
new1->x=x;
new1->y=y;
new1->next=NULL;
last1->next=new1;
last1=new1;
return;
}
void Bucket()
{
int x,y,bgcolor;
while(LeftButtonPressed)
{
disp_coord();
getxy();
}
setwritemode(COPY_PUT);
x=mousex;
y=mousey;
bgcolor=getpixel(x,y);
ffill(x,y,bgcolor,Current_Color);
}
void ffill(int x,int y,int backColor,int fill_color)
{
if(backColor==fill_color)
return;
last1=root1=(struct node1*)malloc(sizeof(struct node1));
root1->x=x;
root1->y=y;
root1->next=NULL;
while(root1!=NULL)
{
if(x<MAX_X&&y<MAX_Y&&x>MIN_X&&y>MIN_Y)
putpixel(x,y,fill_color);
if(getpixel(x,y-1)==backColor)
{
if(x<MAX_X&&y-1<MAX_Y&&x>MIN_X&&y-1>MIN_Y)
{
putpixel(x,y-1,fill_color);
insert(x,y-1);
}
}
if(getpixel(x+1,y)==backColor)
{
if(x+1<MAX_X&&y<MAX_Y&&x+1>MIN_X&&y>MIN_Y)
{
putpixel(x+1,y,fill_color);
insert(x+1,y);
}
}
if(getpixel(x,y+1)==backColor)
{
if(x<MAX_X&&y+1<MAX_Y&&x>MIN_X&&y+1>MIN_Y)
{
putpixel(x,y+1,fill_color);
insert(x,y+1);
}
}
if(getpixel(x-1,y)==backColor)
{
if(x-1<MAX_X&&y<MAX_Y&&x-1>MIN_X&&y>MIN_Y)
{
putpixel(x-1,y,fill_color);
insert(x-1,y);
}
}
p1=root1;
root1=root1->next;
free(p1);
x=root1->x;
y=root1->y;
}
}
void beep()
{
sound(7);
delay(1000);
nosound();
}
void ShowStatus(char* str)
{
int color=getcolor();
int i;
ClearStatus();
setcolor(BLACK);
outtextxy(12,464,str);
setcolor(color);
}
void Cube()
{
int color=15-Current_Color;
int temp,x,y,mousex1,mousey1;
restrictmouseptr((MIN_X+5),(MIN_Y+5),(MAX_X-30),(MAX_Y-30));
setcolor(color);
setwritemode(XOR_PUT);
x=mousex;
y=mousey;
while(LeftButtonPressed)
{
disp_coord();
getxy();
}
setwritemode(COPY_PUT);
mousex1=mousex;
mousey1=mousey;
if(mousex1<x || mousey1<y)
{
temp=x;
x=mousex1;
mousex1=temp;
temp=y;
y=mousey1;
mousey1=temp;
}
if(mousex1-x>1 && mousey1-y>1)
{
if(Current_Pattern==EMPTY_FILL)
{
setcolor(Current_Color);
rectangle(x,y,mousex1,mousey1);
rectangle(x+25, y+25, mousex1+25, mousey1+25);
line(x,y,x+25,y+25);
line(mousex1,mousey1,mousex1+25,mousey1+25);
line(x,mousey1,x+25,mousey1+25);
line(mousex1,y,mousex1+25,y+25);
}
else
{
setfillstyle(Current_Pattern,Current_Color);
bar(x,y,mousex1,mousey1);
bar(x+25, y+25, mousex1+25, mousey1+25);
setcolor(BLACK);
rectangle(x,y,mousex1,mousey1);
rectangle(x+25, y+25, mousex1+25, mousey1+25);
line(x,y,x+25,y+25);
line(mousex1,mousey1,mousex1+25,mousey1+25);
line(x,mousey1,x+25,mousey1+25);
line(mousex1,y,mousex1+25,y+25);
floodfill(mousex1+5,y+10,BLACK);
floodfill(x+10,mousey1+5,BLACK);
floodfill(mousex1+2,mousey1,BLACK);
}
}
restrictmouseptr(0,0,640,480);
}
void drawellipse()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx,rady;
x1 = mousex;
y1 = mousey;
radx=rady=1;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
algoellipse(xmid,ymid,radx,rady);
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
rady = abs((y2 - y1)/2);
if (radx < 1)
radx = 1;
if (rady < 1)
rady = 1;
color = 15 - Current_Color;
setcolor(color);
algoellipse(xmid,ymid,radx,rady);
//delay(50);
//algoellipse(xmid,ymid,radx,rady);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
rady = abs((y2 - y1)/2);
if(Current_Pattern==EMPTY_FILL)
algoellipse(xmid,ymid,radx,rady);
else
{
setfillstyle(Current_Pattern,Current_Color);
fillellipse(xmid,ymid,radx,rady);
}
}
void algoellipse(int xcen,int ycen,float radx,float rady)
{
float p,px,py,x,y,ry,rx,tworx,twory;
ry = rady * rady;
rx = radx * radx;
twory = 2 * ry;
tworx = 2 * rx;
x = 0;
y = rady;
plotellipsepoints(xcen,ycen,x,y);
p = (ry - rx*rady + (0.25 * rx));
px = 0;
py = tworx * y;
while (px < py)
{ x++;
px = px + twory;
if (p >= 0)
{ y--;
py = py - tworx;
}
if (p < 0)
p = p + ry + px;
else
p = p + ry + px - py;
plotellipsepoints(xcen,ycen,x,y);
}
p = (ry * (x + 0.5) * (x + 0.5) + rx * (y-1) * (y-1) - rx * ry);
while (y > 0)
{ y--;
py = py - tworx;
if (p <= 0)
{ x++;
px = px + twory;
}
if (p > 0)
p = p + rx - py;
else
p = p + rx - py + px;
plotellipsepoints(xcen,ycen,x,y);
}
}
void plotellipsepoints(int xcen,int ycen,int x,int y)
{
if (xcen+x >= MIN_X && xcen+x <= MAX_X && ycen+y >= MIN_Y && ycen+y <= MAX_Y)
line(xcen+x,ycen+y,xcen+x,ycen+y);
if (xcen-x >= MIN_X && xcen-x <= MAX_X && ycen+y >= MIN_Y && ycen+y <= MAX_Y)
line(xcen-x,ycen+y,xcen-x,ycen+y);
if (xcen+x >= MIN_X && xcen+x <= MAX_X && ycen-y >= MIN_Y && ycen-y <= MAX_Y)
line(xcen+x,ycen-y,xcen+x,ycen-y);
if (xcen-x >= MIN_X && xcen-x <= MAX_X && ycen-y >= MIN_Y && ycen-y <= MAX_Y)
line(xcen-x,ycen-y,xcen-x,ycen-y);
}
void algospiral(int xcen,int ycen,float radx,float rady)
{
float rx=5,ry=5;
while(rx<radx || ry<rady)
{
ellipse( xcen, ycen, 90, 270, rx, ry );
rx += 5;
ry += 5;
ycen -= 5;
ellipse( xcen, ycen, 270, 90, rx, ry );
rx += 5;
ry += 5;
ycen += 5;
}
}
void drawspiral()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx;
x1 = mousex;
y1 = mousey;
radx=1;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if (radx < 1)
radx = 1;
color = 15 - Current_Color;
setcolor(color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
algoellipse(xmid,ymid,radx,radx);
delay(20);
getxy();
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
algoellipse(xmid,ymid,radx,radx);
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
/*circle(xmid,ymid,radx);*/
algospiral(xmid,ymid,radx,radx);
}
void drawcircle()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx;
x1 = mousex;
y1 = mousey;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if (radx < 1)
radx = 1;
color = 15 - Current_Color;
setcolor(color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
algoellipse(xmid,ymid,radx,radx);
/* circle(xmid,ymid,radx); */
delay(20);
getxy();
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
algoellipse(xmid,ymid,radx,radx);
/* circle(xmid,ymid,radx); */
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if(Current_Pattern==EMPTY_FILL)
{
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
/*circle(xmid,ymid,radx);*/
algoellipse(xmid,ymid,radx,radx);
}
else
{
setfillstyle(Current_Pattern,Current_Color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
fillellipse(xmid,ymid,radx,radx);
}
}
void sphere()
{
int i,r;
int px,py;
int ex,ey;
setcolor(Current_Color);
if(over(40,50,MAX_X-60,MAX_Y-65)==0)return;
{
wheremouse(&mousex,&mousey);
px=mousex;py=mousey;
setwritemode(XOR_PUT);
if(over(40,50,MAX_X-60,MAX_Y-65)==0)return;
if(buttclicked()==1)
while(1)
{
hidemouseptr();
line(px,py,px,mousey);/* pxpy mxpy */
line(px,py,mousex,py);/* pxmy mxmy */
line(mousex,mousey,px,mousey);
line(mousex,mousey,mousex,py);
showmouseptr();
if(buttclicked()!=1)break;
wheremouse(&mousex,&mousey);
if(over(40,50,MAX_X-60,MAX_Y-65)==0)
while(over(40,50,MAX_X-60,MAX_Y-65)==0);
if(buttclicked()!=1)break;
hidemouseptr();
line(px,py,px,mousey);
line(px,py,mousex,py);
line(mousex,mousey,px,mousey);
line(mousex,mousey,mousex,py);
showmouseptr();
}
hidemouseptr();
setcolor(WHITE);
setwritemode(COPY_PUT);
setcolor(Current_Color);
ex= (px+mousex)/2;
ey=(py+mousey)/2 ;
ellipse( ex , ey , 0,360, abs((px-mousex)/2) ,abs((py-mousey)/2));
r=abs( (py-mousey)/2);
for(i=4;i<= r;i+=5)
{
ellipse( ex , ey , 0,360, abs((px-mousex)/2) ,i);
}
r= abs( (px-mousex)/2);
for(i=4;i<=r;i+=5)
{
ellipse( ex , ey , 0,360, i,abs((py-mousey)/2));
}
showmouseptr();
}
}
int over(int x,int y,int w,int h)
{
int x1,y1;
x1=x+w;
y1=y+h;
wheremouse(&mousex,&mousey);
if( (mousex>x) && (mousex<x1) && (mousey>y) && (mousey <y1) )
return 1;
else
return 0;
}
void clip()
{
int i,j;
if(!marked) return;
unmark();
for(j=MIN_Y+2;j<=MAX_Y-2;++j)
{
for(i=MIN_X+2;i<=MAX_X-2;++i)
{
if( (i>=marker.left&&i<=marker.right) &&( j>=marker.top && j<=marker.bottom ) )
{
}
else
putpixel(i,j,WHITE);
}
}
}
void mark()
{
int color=15-BLACK;
int x,y;
if(marked)
unmark();
setcolor(color);
setwritemode(XOR_PUT);
x=mousex;
y=mousey;
prevx=x;
prevy=y;
setlinestyle(DOTTED_LINE,1,1);
while(LeftButtonPressed)
{ getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
rectangle(x,y,prevx,prevy);
rectangle(x,y,mousex,mousey);
}
}
setlinestyle(SOLID_LINE,1,1);
if(x<mousex)
{
marker.left=x;
marker.right=mousex;
if(y<mousey)
{
marker.top=y;
marker.bottom=mousey;
}
else
{
marker.top=mousey;
marker.bottom=y;
}
}
else
{
marker.left=mousex;
marker.right=x;
if(y<mousey)
{
marker.top=y;
marker.bottom=mousey;
}
else
{
marker.top=mousey;
marker.bottom=y;
}
}
marked=1;
setwritemode(COPY_PUT);
}
void unmark()
{
int color=15-BLACK;
setcolor(color);
setwritemode(XOR_PUT);
setlinestyle(DOTTED_LINE,1,1);
rectangle(marker.left,marker.top,marker.right,marker.bottom);
setlinestyle(SOLID_LINE,1,1);
setwritemode(COPY_PUT);
marked=0;
}
void extclip()
{
if(marked)
{
unmark();
setfillstyle(SOLID_FILL,WHITE);
bar(marker.left,marker.top,marker.right,marker.bottom);
}
}
void flip()
{
int col;
int y1,y2;
int color1,color2;
for(col=MIN_X+2;col<=MAX_X-2;++col)
{
y1=MIN_Y+2;
y2=MAX_Y-2;
while(y1<y2)
{
color1=getpixel(col,y1);
color2=getpixel(col,y2);
putpixel(col,y2,color1);
putpixel(col,y1,color2);
y1++;
y2--;
}
}
}
void mirror()
{
int row;
int x1,x2;
int color1,color2;
for(row=MIN_Y+2;row<=MAX_Y-2;++row)
{
x1=MIN_X+2;
x2=MAX_X-2;
while(x1<x2)
{
color1=getpixel(x1,row);
color2=getpixel(x2,row);
putpixel(x2,row,color1);
putpixel(x1,row,color2);
x1++;
x2--;
}
}
}
void Diagram()
{
restrictmouseptr(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2);
hidemouseptr();
switch(Current_Button)
{
case 1: erase(); break;
case 2: drawline(); break;
case 3: drawrectangle();break;
case 4: drawcircle();break;
case 5: drawspiral();break;
case 6: freehand(); break;
case 7: Cube(); break;
case 8: Bucket(); break;
case 9: drawellipse();break;
case 10: mark(); break;
case 11: clip(); break;
case 12: drawtext(); break;
case 13: sphere(); break;
case 14: extclip(); break;
case 15: translate(); break;
case 16: rotate(); break;
case 17: scale(); break;
case 18: dark(); break;
case 19: light(); break;
case 20: invert(); break;
case 21: blackwhite(); break;
}
showmouseptr();
restrictmouseptr(0,0,639,479);
}
/* This is for initialization of the whole layout */
void init()
{
int x1=5,y1=35,x2=38,y2=MAX_Y+28,ywidth=30,xwidth=30;
int butt=1,i,j;
init_button(butt,x1,y1,xwidth,ywidth,"Eraser",0);
draw_button_border(butt);
Erase_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Line",0);
draw_button_border(butt);
Line_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"Rectangle",0);
draw_button_border(butt);
Rectangle_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Circle",0);
draw_button_border(butt);
Circle_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"Spiral",0);
draw_button_border(butt);
Spiral_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Pencil",0);
draw_button_border(butt);
Brush_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"Cuboid",0);
draw_button_border(butt);
Cube_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Fill",0);
draw_button_border(butt);
Bucket_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"Ellipse Drawing Tool",0);
draw_button_border(butt);
Ellipse_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Selection Tool",0);
draw_button_border(butt);
Mark_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"Clipping (Works with Mark)",0);
draw_button_border(butt);
Clip_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Text",0);
draw_button_border(butt);
//printf("%d",butt);
Alphabet_ico(x2,y1);
butt++;
y1=y1+ywidth;
init_button(butt,x1,y1,xwidth,ywidth,"3D Ellipse Drawing Tool",0);
draw_button_border(butt);
Sphere_ico(x1,y1);
butt++;
init_button(butt,x2,y1,xwidth,ywidth,"Exterior Clipping(Works with Mark)",0);
draw_button_border(butt);
Del_ico(x2,y1);
butt++;
init_button(butt,260,414,50,20,"Translation(Works with Mark)",0);
draw_button_border(butt);
outtextxy(262,418,"Trans");
butt++;
init_button(butt,320,414,50,20,"Rotation(Works with Mark)",0);
draw_button_border(butt);
outtextxy(322,418,"Rotat");
butt++;
init_button(butt,380,414,50,20,"Scaling(Works with Mark)",0);
draw_button_border(butt);
outtextxy(382,418,"Scale");
butt++;
init_button(butt,260,436,50,20,"Darkening Contrast Effect",0);
draw_button_border(butt);
outtextxy(262,438,"Darken");
butt++;
init_button(butt,320,436,50,20,"Brighten up the Image",0);
draw_button_border(butt);
outtextxy(322,438,"Light");
butt++;
init_button(butt,380,436,50,20,"Invert the Colours",0);
draw_button_border(butt);
outtextxy(382,438,"Invert");
butt++;
init_button(butt,440,414,50,20,"Convert to Black & White",0);
draw_button_border(butt);
outtextxy(442,418,"B & W");
butt++;
x1=MIN_X+5;
init_button(butt,x1,17,80,20,"FILE handling options",0);
draw_button_border(butt);
outtextxy(x1+15,23,"FILE");
x1=x1+83;
butt++;
init_button(butt,x1,17,80,20,"EDITING options",0);
//printf("%d",butt);
draw_button_border(butt);
outtextxy(x1+15,23,"EDIT");
x1=x1+83;
butt++;
init_button(butt,x1,17,80,20,"FORMATING tools",0);
draw_button_border(butt);
outtextxy(x1+15,23,"FORMAT");
x1=x1+83;
butt++;
init_button(butt,x1,17,80,20,"NEED HELP? click on this",0);
draw_button_border(butt);
outtextxy(x1+15,23,"HELP");
x1=x1+80;
butt++;
butt=0;
x1=MIN_X+8;
y1=MAX_Y+9;
xwidth=19;ywidth=15;
for(i=0;i<8;i++)
{
init_color_button(butt,x1,y1,xwidth,ywidth,1);
draw_color_button_border(butt,1);
butt++;
init_color_button(butt,x1,y2,xwidth,ywidth,1);
draw_color_button_border(butt,1);
butt++;
x1=x1+xwidth;
}
butt=0;
x1=25;
y1=290;
for(i=0;i<6;i++)
{
x2=x1+xwidth+2;
init_color_button(butt,x1,y1,xwidth,ywidth,0);
draw_color_button_border(butt,0);
butt++;
init_color_button(butt,x2,y1,xwidth,ywidth,0);
draw_color_button_border(butt,0);
butt++;
y1=y1+ywidth+5;
}
/* This is for the small Window which shows the color */
setfillstyle(Current_Pattern,Current_Color);
bar(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(BLACK);
rectangle(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(Current_Color);
}
void init_color_button(int color,int xmin,int ymin,int xwidth,int ywidth,int colflag)
{
int xgap=4;
if (colflag)
{
colorbuttons[color].xmin=xmin;
colorbuttons[color].xmax=xmin+xwidth-xgap;
colorbuttons[color].ymin=ymin;
colorbuttons[color].ymax=ymin+ywidth;
colorbuttons[color].color=color;
colorbuttons[color].colflag=colflag;
}
else
{
colorbuttons[color+16].xmin=xmin;
colorbuttons[color+16].xmax=xmin+xwidth-xgap;
colorbuttons[color+16].ymin=ymin;
colorbuttons[color+16].ymax=ymin+ywidth;
colorbuttons[color+16].color=color;
colorbuttons[color+16].colflag=colflag;
}
}
void draw_color_button_border(int no,int colflag)
{
int color=getcolor();
setcolor(BLACK);
if (colflag)
{
line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmax,colorbuttons[no].ymin);
line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmin,colorbuttons[no].ymax);
line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmax,colorbuttons[no].ymin);
line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmin,colorbuttons[no].ymax);
setfillstyle(1,no);
floodfill(colorbuttons[no].xmin+1,colorbuttons[no].ymin+1,BLACK);
}
else
{
line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16].xmax,colorbuttons[no+16].ymin);
line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16].xmin,colorbuttons[no+16].ymax);
line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16].xmax,colorbuttons[no+16].ymin);
line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16].xmin,colorbuttons[no+16].ymax);
setfillstyle(no,WHITE);
floodfill(colorbuttons[no+16].xmin+1,colorbuttons[no+16].ymin+1,BLACK);
}
setcolor(color);
}
void init_button(int no,int xmin,int ymin,int xwidth,int ywidth,char* desc,int popno)
{
int ygap=4;
buttons[no].xmin=xmin;
buttons[no].ymin=ymin;
buttons[no].xmax=xmin+xwidth;
buttons[no].ymax=ymin+ywidth-ygap;
buttons[no].desc=(char *) malloc(strlen(desc)+1);
if(buttons[no].desc==NULL)
{
cleardevice();
printf("\n No MEMORY ");
}
strcpy(buttons[no].desc,desc);
buttons[no].popup = popno;
}
void draw_button_border(int no)
{
int color=getcolor();
hidemouseptr();
setcolor(LIGHTGREEN);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax);
setcolor(BLACK);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax);
setcolor(color);
showmouseptr();
}
void undraw_button_border(int no)
{
int i,j;
int color=getcolor();
hidemouseptr();
setcolor(BLACK);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax);
setcolor(LIGHTGRAY);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax);
setcolor(color);
showmouseptr();
}
void Line_ico(int x1, int y1)
{
line(8+x1, 5+y1, 22+x1, 19+y1);
}
void Rectangle_ico(int x1, int y1)
{
rectangle(8+x1, 5+y1, 22+x1, 19+y1);
}
void Circle_ico(int x1, int y1)
{
circle(15+x1, 12+y1, 8);
}
void Spiral_ico(int x1, int y1)
{
int xrad=3,yrad=1;
int i;
x1=15+x1;
y1=14+y1;
for( i = 1; i <=4; ++i )
{
ellipse( x1, y1, 90, 270, xrad, yrad );
xrad += 1;
yrad += 1;
y1 -= 1;
ellipse( x1, y1, 270, 90, xrad, yrad );
xrad += 1;
yrad += 1;
y1 += 1;
}
}
void Brush_ico(int x1, int y1)
{
setcolor(BLACK);
setlinestyle(0, 1, 3);
line(19+x1, 21+y1, 10+x1, 9+y1);
setlinestyle(0, 1, 1);
line(11+x1, 9+y1, 11+x1, 6+y1);
line(11+x1, 6+y1, 6+x1, 4+y1);
line(6+x1, 4+y1, 7+x1, 9+y1);
line(7+x1, 9+y1, 11+x1, 9+y1);
}
void Fill_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(10+x1, 11+y1, 16+x1, 19+y1);
line(16+x1, 19+y1, 25+x1, 12+y1);
line(25+x1, 12+y1, 20+x1, 5+y1);
line(10+x1, 11+y1, 24+x1, 11+y1);
setfillstyle(1, RED);
floodfill( 12+x1, 12+y1, BLACK);
setcolor(RED);
line(10+x1, 11+y1, 8+x1, 14+y1);
line(8+x1, 14+y1, 8+x1, 16+y1);
}
void Cube_ico(int x, int y)
{
rectangle(8+x, 5+y, 24+x, 17+y);
rectangle(5+x, 9+y, 21+x, 21+y);
line(5+x, 9+y, 8+x, 5+y);
line(21+x, 21+y, 24+x, 17+y);
line(21+x, 9+y, 24+x, 5+y);
line(5+x, 21+y, 8+x, 17+y);
}
void Erase_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(14+x1, 20+y1, 25+x1, 7+y1);
line(25+x1, 7+y1, 23+x1, 4+y1);
line(23+x1, 4+y1, 12+x1, 17+y1);
line(12+x1, 17+y1, 14+x1, 20+y1);
line(14+x1, 20+y1, 5+x1, 20+y1);
line(5+x1, 20+y1, 5+x1, 17+y1);
line(5+x1, 17+y1, 12+x1, 17+y1);
line(5+x1, 17+y1, 16+x1, 4+y1);
line(16+x1, 4+y1, 23+x1, 4+y1);
setfillstyle(1, WHITE);
floodfill(14+x1, 18+y1, BLACK);
setfillstyle(1, WHITE);
floodfill(16+x1, 5+y1, BLACK);
}
void Clip_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setfillstyle(1, WHITE);
floodfill(15+x1, 12+y1, BLACK);
setfillstyle(1,BLACK);
bar(12+x1, 10+y1, 23+x1, 17+y1);
}
void Del_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(WHITE);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setfillstyle(1, BLACK);
floodfill(15+x1, 12+y1, WHITE);
setfillstyle(1,WHITE);
bar(12+x1, 10+y1, 23+x1, 17+y1);
}
void Bucket_ico(int x, int y)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(7+x, 8+y, 11+x, 20+y);
line(11+x, 20+y, 21+x, 16+y);
line(21+x, 16+y, 17+x, 4+y);
line(7+x, 8+y, 17+x, 4+y);
line(17+x, 4+y, 7+x, 8+y);
line(3+x, 12+y, 7+x, 8+y);
line(3+x, 12+y, 5+x, 15+y);
line(5+x, 15+y, 7+x, 8+y);
setfillstyle(1, BLUE);
floodfill(10+x, 9+y, BLACK);
setfillstyle(1, YELLOW);
floodfill(5+x, 13+y, BLACK);
}
void Ellipse_ico(int x1,int y1)
{
ellipse(15+x1, 13+y1, 0, 360, 8, 6);
}
void Alphabet_ico(int x, int y)
{
setcolor(BLACK);
setlinestyle(0, 1, 3);
line(8+x, 20+y, 18+x, 4+y);
line(18+x, 4+y, 18+x, 20+y);
setlinestyle(0, 1, 1);
line(12+x, 14+y, 19+x, 14+y);
line(6+x, 20+y, 12+x, 20+y);
line(15+x, 20+y, 21+x, 20+y);
}
void Mark_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
setlinestyle(3, 1, 1);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setlinestyle(0, 1, 1);
}
void Sphere_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
circle(x1+15,y1+13,8);
ellipse(x1+15,y1+13,0,360,4,8);
ellipse(x1+15,y1+13,0,360,8,4);
}
void start_up()
{
setfillstyle(1,CYAN);
floodfill(200, 200, 1);
/* FOR
MAIN WINDOW */
setcolor(15);
line(0, 0, 639, 0);
line(0, 0+1, 639-1, 0+1);
line(0, 0, 0, 479-1);
line(0+1, 0, 0+1, 479-2);
setcolor(8);
line(639, 0+1, 639, 479);
line(639-1, 0+2, 639-1, 479-1);
line(639, 479, 0, 479);
line(639, 479-1, 0+1, 479-1);
/* for drawing window */
setcolor(WHITE);
rectangle(MIN_X, MIN_Y, MAX_X, MAX_Y);
setfillstyle(1, WHITE);
floodfill(300, 300, WHITE);
setcolor(8);
line(MIN_X, MIN_Y, MAX_X, MIN_Y);
line(MIN_X, MIN_Y+1, MAX_X-1, MIN_Y+1);
line(MIN_X, MIN_Y, MIN_X, MAX_Y-1);
line(MIN_X+1, MIN_Y, MIN_X+1, MAX_Y-2);
setcolor(8);
line(MAX_X, MIN_Y+1, MAX_X, MAX_Y);
line(MAX_X-1, MIN_Y+2, MAX_X-1, MAX_Y-1);
line(MAX_X, MAX_Y, MIN_X, MAX_Y);
line(MAX_X, MAX_Y-1, MIN_X+1, MAX_Y-1);
/* for status bar */
setcolor(8);
line(10, 460, 629, 460);
line(10, 460, 10, 479 - 5-1);
setcolor(15);
line(629, 460 , 629, 479 - 5);
line(629, 479 - 5, 10, 479 - 5);
/*/ For color*/
setcolor(15);
line(MIN_X, MAX_Y+4, 251, MAX_Y+4);
line(MIN_X, MAX_Y+4, MIN_X,MAX_Y+47);
setcolor(0);
line(251, MAX_Y+47 , MIN_X, MAX_Y+47);
line(251, MAX_Y+47, 251, MAX_Y+4);
/*/ For the Menu bar */
setcolor(15);
line(MIN_X,15,MAX_X,15);
line(MIN_X,15,MIN_X,34);
setcolor(0);
line(MAX_X,34,MAX_X,15);
line(MAX_X,34,MIN_X,34);
/* For the pattern pallete */
setcolor(15);
line(15,285,15,410);
line(15,285,70,285);
setcolor(0);
line(70,410,70,285);
line(70,410,15,410);
}
void disp_filename()
{
char name[60];
int xpos;
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(3,5,630,15);
strcpy(name,"MY PAINTING CANVAS- ");
strcat(name,FileName);
xpos=200;
setcolor(LIGHTRED);
outtextxy(xpos,8,name);
setfillstyle(SOLID_FILL,BLUE);
bar(614,6,628,17);
rectangle(617,6,629,17);
setcolor(WHITE);
outtextxy(620,8,"X");
}
void highlight(int x1,int y1,int x2,int y2,int bgcolor,int flcolor)
{
int i,j;
hidemouseptr();
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
{
if(getpixel(i,j)==bgcolor)
putpixel(i,j,flcolor);
}
showmouseptr();
}
void showeditmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(15);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*5,buff1);
//setcolor(RED);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
//floodfill(x1+1,y1+ywidth+1,RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+25,y1+ywidth+5,"cut");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+25,y1+ywidth*2+5,"copy");
rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
outtextxy(x1+25,y1+ywidth*3+5,"paste");
rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
outtextxy(x1+25,y1+ywidth*4+5,"clear");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;
int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+5*ywidth )
{
if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
ShowStatus("warning: do not cut large areas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
ShowStatus("warning: do not copy large areas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
else if(y<y1+4*ywidth)
{
if(fileflag!=3)
{
ShowStatus("paste the cut/copied part of the image");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+3*ywidth,x1+xwidth,y1+4*ywidth,CYAN,BLUE);
fileflag=3;
}
}
else if(y<y1+5*ywidth)
{
if(fileflag!=4)
{
ShowStatus("clear the canvas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+4*ywidth,x1+xwidth,y1+5*ywidth,CYAN,BLUE);
fileflag=4;
}
}
}
}hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(15);
showmouseptr();
ShowStatus(" ");
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*5))
{
switch(fileflag)
{
case 1:
cut();//call cut function
break;
case 2:
copy();//call copy function
break;
case 3:
callpaste();//call paste function
break;
case 4:
setfillstyle(SOLID_FILL,WHITE);
hidemouseptr();
bar(MIN_X,MIN_Y,MAX_X,MAX_Y); //call clear function
showmouseptr();
break;
}
//delay(500);
showmouseptr();
}
//delay(300);
free(buff1);
}
void showfilemenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(14);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*5,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+25,y1+ywidth+5,"New");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+25,y1+ywidth*2+5,"Open");
rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
outtextxy(x1+25,y1+ywidth*3+5,"Save");
rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
outtextxy(x1+25,y1+ywidth*4+5,"Quit");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;
int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+5*ywidth )
{
if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
else if(y<y1+4*ywidth)
{
if(fileflag!=3)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+3*ywidth,x1+xwidth,y1+4*ywidth,CYAN,BLUE);
fileflag=3;
}
}
else if(y<y1+5*ywidth)
{
if(fileflag!=4)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+4*ywidth,x1+xwidth,y1+5*ywidth,CYAN,BLUE);
fileflag=4;
}
}
}
}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(14);
showmouseptr();
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*5))
{
switch(fileflag)
{
case 1:
new_file();
//call new function
break;
case 2:
load();
//call open function
break;
case 3:
save();
//call save function
break;
case 4:
quit();
break;
}
}
free(buff1);
}
void showformatmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(16);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth*3,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*3,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+5,y1+ywidth+5,"Flip(hor)");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+5,y1+ywidth*2+5,"Flip(ver)");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;
int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+3*ywidth )
{
if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
}
}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
showmouseptr();
//draw_button_border(16);
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*3))
{
delay(1000);
hidemouseptr();
switch(fileflag)
{
case 1:
//call fliphorizontally function
mirror();
break;
case 2:
//call flipvertically function
flip();
break;
}
showmouseptr();
}
free(buff1);
}
void showhelpmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(17);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*3,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+2,y1+ywidth+5,"About");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+1,y1+ywidth*2+5,"Topics");
//rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
//outtextxy(x1+25,y1+ywidth*3+5,"Save");
//rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
//outtextxy(x1+25,y1+ywidth*4+5,"Quit");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;
int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+3*ywidth )
{
if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
}
}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(17);
showmouseptr();
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*3))
{
switch(fileflag)
{
case 1:
about();
//call about function
break;
case 2:
topic();
//call help function
break;
}
}
free(buff1);
}
void disp_coord()
{
char xy[25];
int color;
if(prevx!=mousex||prevy!=mousey)
if( (mousex>MIN_X+1)&&(mousex<MAX_X-1)&&(mousey>MIN_Y+1)&&(mousey<MAX_Y-1))
{
sprintf(xy," x:%d y:%d",mousex-MIN_X-2,mousey-MIN_Y-2);
color=getcolor();
setcolor(CYAN);
outtextxy(520,22,"غغغغغغغغغغغغ" );/* ALT 219*/
//outtextxy(475,464,"Hello");
setcolor(BLACK);
outtextxy(520,22,xy);
setcolor(color);
}
}
/*void getxy()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,®s,®s);
prevx=mousex;
prevy=mousey;
mousex=regs.x.cx;
mousey=regs.x.dx;
} */
int check_if_color()
{
int i=0;
for(i=0;i<MAX_COLPAT;i++)
{
if(check_mouse_on(colorbuttons[i].xmin,colorbuttons[i].ymin,colorbuttons[i].xmax,colorbuttons[i].ymax))
{
if(colorbuttons[i].colflag)
{
Current_Color=colorbuttons[i].color;
}
else
Current_Pattern=colorbuttons[i].color;
if (Current_Pattern==EMPTY_FILL)
Afficher la suite