/* GRAPHICAL C++ */
/* DEVELOPED BY DEBASIS BHATTACHARJEE */
#include<gcppfunc.h>
int bkcolor=7;
int butcolor=7;
int l=120,t=100,r=500,b=400;
int hide=0;
class Frame
{
private:
int capcolor,labcolor;
int capyes,capcolyes,labcolyes;
int left,top;
char labcap[800];
public:
Show(int l,int t,int r,int b,char cap[40])
{
setcolor(15);
rectangle(l+1,t+1,r+1,b+1);
setcolor(8);
rectangle(l,t,r,b);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
int size=strlen(cap)*8;
setfillstyle(SOLID_FILL,7);
bar(l+10,t-5,l+size+15,t+5);
setcolor(0);
outtextxy(l+13,t-5,cap);
}
Show(int l,int t,int r,int b)
{
int size;
setcolor(15);
rectangle(l+1,t+1,r+1,b+1);
setcolor(8);
rectangle(l,t,r,b);
if(capyes==-1)
{
settextstyle(SMALL_FONT,HORIZ_DIR,4);
size=textwidth(labcap);
if(labcolyes==-1)
setfillstyle(SOLID_FILL,labcolor);
else
setfillstyle(SOLID_FILL,7);
bar(l+10,t-5,l+size+15,t+5);
if(capcolyes==-1)
setcolor(capcolor);
else
setcolor(0);
outtextxy(l+13,t-5,labcap);
}
else
{
settextstyle(SMALL_FONT,HORIZ_DIR,4);
size=textwidth("GCPPFrame");
if(labcolyes==-1)
setfillstyle(SOLID_FILL,labcolor);
else
setfillstyle(SOLID_FILL,7);
bar(l+10,t-5,l+size+15,t+5);
if(capcolyes==-1)
setcolor(capcolor);
else
setcolor(0);
outtextxy(l+13,t-5,"GCPPFrame");
}
}
void Caption(char cap[800])
{
strcpy(labcap,cap);
capyes=-1;
}
void Fontcolor(int color)
{
capcolor=color;
capcolyes=-1;
}
void Backcolor(int bkcolor)
{
labcolor=bkcolor;
labcolyes=-1;
}
};
class Label
{
private:
int backcolor,backcolyes;
int fontcolor,fontcolyes;
int capyes;
int left,top;
char *labcap;
int len;
public:
void Show(int l,int t,char *cap)
{
settextstyle(SMALL_FONT,HORIZ_DIR,4);
int length=textwidth(cap);
length=length+10;
len=length;
setfillstyle(SOLID_FILL,7);
bar(l,t,l+length,t+15);
setcolor(0);
outtextxy(l+5,t+2,cap);
left=l;
top=t;
}
void Show(int l,int t)
{
int length;
settextstyle(SMALL_FONT,HORIZ_DIR,4);
if(capyes==1)
{
length=textwidth(labcap);
length=length+10;
len=length;
if(backcolyes==-1)
setfillstyle(SOLID_FILL,backcolor);
else
setfillstyle(SOLID_FILL,7);
bar(l,t,l+length,t+15);
if(fontcolyes==-1)
setcolor(fontcolor);
else
setcolor(0);
outtextxy(l+5,t+2,labcap);
}
else
{
length=textwidth("GCPPLabel");
length=length+10;
len=length;
if(backcolyes==-1)
setfillstyle(SOLID_FILL,backcolor);
else
setfillstyle(SOLID_FILL,7);
bar(l,t,l+length,t+15);
if(fontcolyes==-1)
setcolor(fontcolor);
else
setcolor(0);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
outtextxy(l+5,t+2,"GCPPLabel");
}
left=l;
top=t;
}
void Caption(char cap[40])
{
strcpy(labcap,cap);
capyes=1;
}
void Backcolor(int bkcolor)
{
backcolor=bkcolor;
backcolyes=-1;
}
void Fontcolor(int color)
{
fontcolor=color;
fontcolyes=-1;
}
Getrightpos()
{
return len;
}
};
class CheckBox
{
private:
int capyes;
int left,top;
char *labcap;
public:
void Show(int l,int t)
{
setfillstyle(1,15);
bar(l,t,l+11,t+10);
buttonclick(l,t,l+11,t+10);
setcolor(8);
rectangle(l-1,t-1,l+10,t+9);
left=l,top=t;
}
int Check()
{
int check=0;
int val=3;
showmouse();
while(1)
{
getmouse(button,x,y);
if((x>=left)&&(x<left+12)&&(y>=top)&&(y<top+12)&&(button==1))
val=1;
if((x>=left)&&(x<left+12)&&(y>=top)&&(y<top+12)&&(button==2))
val=0;
if(val==1)
{
hidemouse();
setcolor(0);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
check=1;
break;
}
if(val==0)
{
hidemouse();
setcolor(15);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
check=0;
break;
}
}
showmouse();
return check;
}
int Keypress()
{
static int check=0;
int val=3;
int in,checktake=0,counttake=0;
static int count=0;
while(1)
{
in=getch();
if(in==32)
{
switch(count)
{
case 0:
val=1;
count=1;
break;
case 1:
val=0;
count=0;
break;
}
}
if(in==13||in==9)
{
checktake=check;
counttake=count;
check=0;
count=0;
return checktake+2;
break;
}
if(val==1)
{
setcolor(0);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
check=1;
break;
}
if(val==0)
{
setcolor(15);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
check=0;
break;
}
}
}
void Checked()
{
setcolor(0);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
}
void UnChecked()
{
setcolor(15);
setlinestyle(SOLID_LINE,0,3);
line(left+2,top+4,left+4,top+6);
line(left+5,top+6,left+8,top+3);
setlinestyle(SOLID_LINE,0,1);
}
void Selection(int color)
{
select_with_color(left-2,top-2,left+11+2,top+10+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,left+11+2,top+10+2,color);
}
};
class GeneralCombo
{
private:
int textyes;
char* combo_text;
public:
void Text(char* comtext)
{
combo_text=comtext;
textyes=1;
}
int Show(char *list[],int l,int t,int row)
{
int s=1,st=1;static int ii,count;
int size=0,buttonleft=0;
int ret;
char *greater;
char *select;
if(textyes==1)
select=combo_text;
else
select=list[0];
for ( int i = 0 ; i < row ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s+30;
buttonleft=size;
size=size/8;
if(count!=1)
textarea(select,l,t,size);
int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.
mybutton(mr-16,mt+1,mr-2,mb-1);
for(int j=0;j<=2;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
showmouse();
while(!kbhit())
{
getmouse(button,x,y); //Get Mouse
if((x>ml)&&(x<mr)&&(y>mt)&&(y<mb)&&(button==1))
{
delay(200);
ret=mymenu(ml-2,mt+18,list,6,size-1);
for(ii=1;ii<=row;ii++)
{
if(ii==ret)
{
select=list[ii-1];
count=1;
}
}
textarea(select,l,t,size);
return ret;
}
}
}
};
class TextBox
{
private:
int left,top,r,character,set_focus_used_yes;
int length;
char text[80];
public:
void Show(int x1,int y1,int len)
{
char str[40];
setfillstyle(1,15);
int right;
right=x1+(8*len);
bar(x1,y1,right,y1+15);
buttonclick(x1,y1,right,y1+15);
left=x1,top=y1;
character=len;
r=right;
length=right;
}
char* GetInput()
{
char str[80];
moveto(left+2,top);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
isigraph(str,character);
strcpy(text,str);
return (str);
}
void Text(char *text)
{
int width;
width=textwidth(text);
width=width+left;
if(width>r)
{
setfillstyle(1,15);
bar(left,top,width+4,top+15);
buttonclick(left,top,width+4,top+15);
moveto(left+2,top);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
setcolor(1);
outtext(text);
r=width+4;
}
else
{
moveto(left+2,top);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
setcolor(1);
outtext(text);
}
}
char* Text(void)
{
return text;
}
char* Password(char *pass)
{
char str[80];
moveto(left+2,top);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
getpassword(str,pass,character);
return (str);
}
void Clear()
{
setfillstyle(1,15);
bar(left,top,r,top+15);
buttonclick(left,top,r,top+15);
}
Getrightpos()
{
return length;
}
void Selection(int color)
{
select_with_color(left-2,top-2,length+2,top+15+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,length+2,top+15+2,color);
}
};
class CommandButton
{
private:
float capyes;
char* caption;
int left,top,right,bottom;
int length;
public:
void Show(int l,int t)
{
int width;
setfillstyle(SOLID_FILL,butcolor);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
if(capyes==0)
{
width=(strlen(caption)*8)+5;
length=width+l;
}
else
{
width=(strlen("GCPPCommand")*8)+5;
length=width+l;
}
int height=60;
int r=l+width;
int b=t+25;
bar(l,t,r,b);
setcolor(15);
line(l+1,t,r,t);
line(l+1,t+1,l+1,b-1);
setcolor(8);
line(l+1,b-1,r,b-1);
line(r,t,r,b-1);
setcolor(0);
line(l,b,r+1,b);
line(r+1,t+1,r+1,b);
if(capyes==0)
outtextxy(l+10,t+7,caption);
else
outtextxy(l+10,t+7,"GCPPCommand");
left=l,top=t,right=r,bottom=b;
}
void Show(int l,int t,char *cap)
{
int width;
setfillstyle(SOLID_FILL,butcolor);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
width=(strlen(cap)*8)+5;
length=width+l;
int height=60;
int r=l+width;
int b=t+25;
bar(l,t,r,b);
setcolor(15);
line(l+1,t,r,t);
line(l+1,t+1,l+1,b-1);
setcolor(8);
line(l+1,b-1,r,b-1);
line(r,t,r,b-1);
setcolor(0);
line(l,b,r+1,b);
line(r+1,t+1,r+1,b);
outtextxy(l+10,t+7,cap);
left=l,top=t,right=r,bottom=b;
}
int Click()
{
showmouse();
while(!kbhit())
{
getmouse(button,x,y);
if((x>left)&&(x<right)&&(y>top)&&(y<bottom)&&(button==1))
{
hidemouse();
buttonclick(left,top,right,bottom);
showmouse();
delay(50);
hidemouse();
buttoneffect(left,top,right,bottom);
showmouse();
delay(200);
return 1;
}
}
}
Keypress()
{
while(1)
{
int in;
in=inkey();
if(in==13)
{
buttonclick(left,top,right,bottom);
delay(50);
buttoneffect(left,top,right,bottom);
return 1;
break;
}
if(in==27||in==9)
{
return -1;
break;
}
}
}
void Caption(char* cap)
{
strcpy(caption,cap);
capyes=0;
}
Getrightpos()
{
return length;
}
void Selection(int color)
{
select_with_color(left-2,top-2,length+4,bottom+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,length+4,bottom+2,color);
}
};
class Form
{
private:
int backcolor,backcolyes;
int barcolor,barcolyes;
int capcolor,capcolyes;
int left,top,right,buttom;
int appearance;
char fn[80],*caption;
int capyes;
int closebutyes;
public:
void Show(int l,int t,int r,int b,char* cap,char file[80])
{
back(l,t,r+2,b+2,0,file);
setfillstyle(SOLID_FILL,7);
bar(l,t,r,b);
setfillstyle(SOLID_FILL,1);
bar(l+3,t+3,r-3,t+23);
setcolor(15);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
outtextxy(l+8,t+8,cap);
setcolor(15);
line(l+1,t,r,t);
line(l+1,t+1,l+1,b-1);
setcolor(8);
line(l+1,b-1,r,b-1);
line(r,t,r,b-1);
setcolor(0);
line(l,b,r+1,b);
line(r+1,t+1,r+1,b);
buttonon(r-20,t+5,r-5,t+20,"X",3);
left=l,top=t,right=r,buttom=b;
strcpy(fn,file);
}
void Show(int l,int t,int r,int b,char file[80])
{
back(l,t,r+2,b+2,0,file);
if(backcolyes==0)
setfillstyle(SOLID_FILL,backcolor);
else
setfillstyle(SOLID_FILL,7);
bar(l,t,r,b);
if(barcolyes==0)
setfillstyle(SOLID_FILL,barcolor);
else
setfillstyle(SOLID_FILL,1);
bar(l+3,t+3,r-3,t+23);
if(capcolyes==0)
setcolor(capcolor);
else
setcolor(15);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
if(capyes==-1)
outtextxy(l+8,t+8,caption);
else
outtextxy(l+8,t+8,"GCPPForm");
setcolor(15);
line(l+1,t,r,t);
line(l+1,t+1,l+1,b-1);
setcolor(8);
line(l+1,b-1,r,b-1);
line(r,t,r,b-1);
setcolor(0);
line(l,b,r+1,b);
line(r+1,t+1,r+1,b);
if(closebutyes!=0)
buttonon(r-20,t+5,r-5,t+20,"X",3);
left=l,top=t,right=r,buttom=b;
strcpy(fn,file);
}
int FormSelect()
{
int val=3;
showmouse();
while(1)
{
getmouse(button,x,y);
if((x>=left)&&(x<=right)&&(y>=top)&&(y<=buttom)&&(button==1))
{
val=1;
break;
}
else
{
val=0;
break;
}
}
return val;
}
Clickclose()
{
showmouse();
while(!kbhit())
{
getmouse(button,x,y);
if((x>right-20)&&(x<right-5)&&(y>top+5)&&(y<top+20)&&(button==1))
{
hidemouse();
back(left,top,right+2,buttom+2,1,fn);
showmouse();
return 1;
break;
}
else
{
return -1;
break;
}
}
}
Keypressclose()
{
int in;
in=getscan();
while(1)
{
if(in==107)
{
back(left,top,right+2,buttom+2,1,fn);
return 1;
break;
}
else
{
return -1;
break;
}
}
}
void Hide()
{
back(left,top,right+2,buttom,1,fn);
}
void Caption(char* cap)
{
strcpy(caption,cap);
capyes=-1;
}
void Backcolor(int bkcolor)
{
backcolor=bkcolor;
backcolyes=0;
}
void Barcolor(int brcolor)
{
barcolor=brcolor;
barcolyes=0;
}
void Capcolor(int color)
{
capcolor=color;
capcolyes=0;
}
void Appearance(int app)
{
if(app==0)
appearance=0;
if(app>1)
MsgBox("Invalid property value. Please enter 0 for flat or 1 for 3D form","Error calling Appearance",CRITICAL);
}
void CloseButton(int onoff)
{
if(onoff==0)
closebutyes=0;
if(onoff==1)
closebutyes=1;
}
};
class ListBox
{
private:
int l,t,r,b,btop,bbottom,length;
int row;
public:
void List(int left,int top,char*list[],int rows)
{
int h=((rows*15)+10);
int s=1,size;
settextstyle(2,0,4);
for ( int i = 0 ; i < rows ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
length=w;
setfillstyle(1,15);
bar(left,top,left+w,top+h);
buttonclick(left,top,left+w,top+h);
settextstyle(2,HORIZ_DIR,4);
setcolor(0);
for(int a=0;a<rows;a++)
outtextxy(left+3,(top+2+(a*15)),list[a]);
l=left,t=top,r=left+w,b=top+h;
btop=t;bbottom=btop+15;
row=rows;
}
void ShowForKey(int left,int top,char*list[],int rows)
{
int h=((rows*15)+10);
int s=1,size;
settextstyle(2,0,4);
for ( int i = 0 ; i < rows ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
length=w;
setfillstyle(1,15);
bar(left,top,left+w,top+h);
buttonclick(left,top,left+w,top+h);
settextstyle(2,HORIZ_DIR,4);
setcolor(0);
for(int a=0;a<rows;a++)
outtextxy(left+3,(top+2+(a*15)),list[a]);
l=left,t=top,r=left+w,b=top+h;
btop=t;bbottom=btop+15;
row=rows;
invertcolors(l+2,t+2,r-3,t+15);
}
int Show(int xc1,int yc1,char *list[],int rows)
{
hidemouse();
int h=((rows*15)+10);
int s=1,size;
settextstyle(2,0,4);
for ( int i = 0 ; i < rows ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
length=w;
setfillstyle(1,15);
bar(xc1,yc1,xc1+w,yc1+h);
buttonclick(xc1,yc1,xc1+w,yc1+h);
settextstyle(2,HORIZ_DIR,4);
setcolor(0);
for(int a=0;a<rows;a++)
outtextxy(xc1+3,(yc1+2+(a*15)),list[a]);
showmouse();
getmouse(button,x,y);
int lc=1,fnc=0,over=-1;
delay(50);
while(lc==1)
{
getmouse(button,x,y);
for(int b=0;b<rows;b++)
{
if(button==1)
{
if((x>xc1+w)||(x<xc1)||(y>yc1+h)||(y<yc1))
{
fnc=0;lc=0;
}
else if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
{
fnc=b+1;lc=0;
}
}
if(button==0)
{
if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
{
if((b!=over)||(over==-1))
{
if(over!=-1)
{
invertcolors(xc1+2,yc1+(15*over)+1,xc1+w-2,yc1+(15*over)+13);
}
invertcolors(xc1+2,yc1+(15*b)+1,xc1+w-2,yc1+(15*b)+13);over=b;
}
over=b;
}
}
}
}
hidemouse();
showmouse();
return(fnc);
}
int Keypress()
{
static int counter=0;
static int scrollup=0;
static int scrolldown=0;
int scrolltime=row;
while(1)
{
int in,ret;
in=inkey();
if(in==72)
{
if(scrollup>0)
{
scrollup--;
invertcolors(l+2,btop+2,r-3,bbottom);
btop=btop-15;
bbottom=bbottom-15;
invertcolors(l+2,btop+2,r-3,bbottom);
scrolldown=scrollup;
counter=scrollup;
return scrollup+1;
}
}
if(in==80)
{
if(scrolldown<scrolltime-1)
{
scrolldown++;
counter++;
invertcolors(l+2,btop+2,r-3,bbottom);
btop=btop+15;
bbottom=bbottom+15;
invertcolors(l+2,btop+2,r-3,bbottom);
scrollup=counter;
ret=scrolldown+1;
counter=scrolldown;
return ret;
}
}
if(in==13)
{
counter=0;
scrolldown=0;
scrollup=0;
return -1;
break;
}
}
counter=0;
scrolldown=0;
}
Getrightpos()
{
return length;
}
};
class HorizScrollBar
{
private:
int left,top,right,bottom;
int bleft,bright;
int scrolltime,scount;
public:
int Show(int l,int t,int r,int scroll)
{
setfillstyle(1,15);
bar(l,t,r,t+20);
setfillstyle(9,7);
bar(l,t,r,t+20);
/* Left button */
mybutton(l,t,l+15,t+20);
int b=t+20;
int ll,lt,lr,lb;
ll=l+9,lt=t+6,lr=l+9,lb=b-6;
for(int i=0;i<=4;i++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll-1,lr=lr-1;
lt=lt+1,lb=lb-1;
}
/* Right button */
int topoflowerbutton;
topoflowerbutton=r-15;
mybutton(r-15,t,r,b);
ll=r-9,lt=t+6,lr=r-9,lb=b-6;
for(int j=0;j<=4;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr+1;
lt=lt+1,lb=lb-1;
}
static int barleft,barright;
b=t+20;
topoflowerbutton=r-15;
barleft=l+16;
barright=((topoflowerbutton-1)-(scroll*5));
back(barleft,t,barright,b,0);
mybutton(barleft,t,barright,b);
bleft=barleft,bright=barright;
left=l,top=t,right=r,bottom=b;
scrolltime=scroll;
}
int Click()
{
static int counter=0;
static int scrollleft=0;
static int scrollright=0;
showmouse();
while(!kbhit())
{
getmousepos(&button,&x,&y);
if((x>left)&&(x<left+15)&&(y>top)&&(y<bottom))
{
if((button & 1)==1)
{
if(scrollleft>0)
{
scrollleft--;
hidemouse();
back(bleft,top,bright,bottom,1);
showmouse();
bleft=bleft-5;
bright=bright-5;
hidemouse();
back(bleft,top,bright,bottom,0);
mybutton(bleft,top,bright,bottom);
showmouse();
delay(200);
scrollright=scrollleft;
counter=scrollleft;
return scrollleft;
}
}
}
if((x>right-15)&&(x<right)&&(y>top)&&(y<bottom))
{
if((button & 1)==1)
{
if(scrollright<scrolltime)
{
scrollright++;
counter++;
hidemouse();
back(bleft,top,bright,bottom,1);
showmouse();
bleft=bleft+5;
bright=bright+5;
hidemouse();
back(bleft,top,bright,bottom,0);
mybutton(bleft,top,bright,bottom);
showmouse();
delay(200);
scrollleft=counter;
return scrollright;
}
}
}
}
}
int Keypress()
{
static int counter=0;
static int scrollleft=0;
static int scrollright=0;
while(1)
{
int in;
in=inkey();
if(in==75)
{
if(scrollleft>0)
{
scrollleft--;
back(bleft,top,bright,bottom,1);
bleft=bleft-5;
bright=bright-5;
back(bleft,top,bright,bottom,0);
mybutton(bleft,top,bright,bottom);
scrollright=scrollleft;
counter=scrollleft;
return scrollleft;
}
}
if(in==77)
{
if(scrollright<scrolltime)
{
scrollright++;
counter++;
back(bleft,top,bright,bottom,1);
bleft=bleft+5;
bright=bright+5;
back(bleft,top,bright,bottom,0);
mybutton(bleft,top,bright,bottom);
scrollleft=counter;
return scrollright;
}
}
if(in==13)
{
return -1;
break;
}
}
}
void Selection(int color)
{
select_with_color(left-2,top-2,right+2,bottom+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,right+2,bottom+2,color);
}
};
class VertScrollBar
{
private:
int left,top,right,bottom;
int btop,bbottom;
int scrolltime,scount;
int diff;
public:
int Show(int l,int t,int b,int scroll)
{
setfillstyle(1,15);
bar(l,t,l+20,b);
setfillstyle(9,7);
bar(l,t,l+20,b);
/* Upper button */
mybutton(l,t,l+20,t+15);
int ll,lt,lr,lb,r=l+20;
ll=l+6,lt=t+9,lr=r-6,lb=lt;
for(int i=0;i<=4;i++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt-1,lb=lb-1;
}
/* Lower button */
int topoflowerbutton;
topoflowerbutton=b-15;
mybutton(l,b-15,r,b);
ll=l+6,lt=b-10,lr=r-6,lb=lt;
for(int j=0;j<=4;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
static int bartop,barbottom;
r=l+20;
topoflowerbutton=b-15;
bartop=t+16;
barbottom=((topoflowerbutton-1)-(scroll*5));
int diffbar;
diffbar=barbottom-bartop;
if(diffbar>=5)
{
back(l,bartop,r,barbottom,0);
mybutton(l,bartop,r,barbottom);
btop=bartop,bbottom=barbottom;
}
diff=diffbar;
left=l,top=t,right=r,bottom=b;
scrolltime=scroll;
}
int Click()
{
static int counter=0;
static int scrollup=0;
static int scrolldown=0;
showmouse();
while(!kbhit())
{
getmousepos(&button,&x,&y);
if((x>left)&&(x<right)&&(y>top)&&(y<top+15))
{
if((button & 1)==1)
{
if(scrollup>0&&diff>=5)
{
scrollup--;
hidemouse();
back(left,btop,right,bbottom,1);
showmouse();
btop=btop-5;
bbottom=bbottom-5;
hidemouse();
back(left,btop,right,bbottom,0);
mybutton(left,btop,right,bbottom);
showmouse();
delay(200);
scrolldown=scrollup;
counter=scrollup;
return scrollup;
}
if(scrollup>0&&diff<5)
{
scrollup--;
btop=btop-5;
bbottom=bbottom-5;
delay(200);
scrolldown=scrollup;
counter=scrollup;
return scrollup;
}
}
}
if((x>left)&&(x<right)&&(y>bottom-15)&&(y<bottom))
{
if((button & 1)==1)
{
if(scrolldown<scrolltime&&diff>=5)
{
scrolldown++;
counter++;
hidemouse();
back(left,btop,right,bbottom,1);
showmouse();
btop=btop+5;
bbottom=bbottom+5;
hidemouse();
back(left,btop,right,bbottom,0);
mybutton(left,btop,right,bbottom);
showmouse();
delay(200);
scrollup=counter;
return scrolldown;
}
if(scrolldown<scrolltime&&diff<5)
{
scrolldown++;
counter++;
btop=btop+5;
bbottom=bbottom+5;
delay(200);
scrollup=counter;
return scrolldown;
}
}
}
}
}
int Keypress()
{
static int counter=0;
static int scrollup=0;
static int scrolldown=0;
while(1)
{
int in;
in=inkey();
if(in==72)
{
if(scrollup>0&&diff>=5)
{
scrollup--;
back(left,btop,right,bbottom,1);
btop=btop-5;
bbottom=bbottom-5;
back(left,btop,right,bbottom,0);
mybutton(left,btop,right,bbottom);
scrolldown=scrollup;
counter=scrollup;
return scrollup;
}
if(scrollup>0&&diff<5)
{
scrollup--;
btop=btop-5;
bbottom=bbottom-5;
scrolldown=scrollup;
counter=scrollup;
return scrollup;
}
}
if(in==80)
{
if(scrolldown<scrolltime&&diff>=5)
{
scrolldown++;
counter++;
back(left,btop,right,bbottom,1);
btop=btop+5;
bbottom=bbottom+5;
back(left,btop,right,bbottom,0);
mybutton(left,btop,right,bbottom);
scrollup=counter;
return scrolldown;
}
if(scrolldown<scrolltime&&diff<5)
{
scrolldown++;
counter++;
btop=btop+5;
bbottom=bbottom+5;
scrollup=counter;
return scrolldown;
}
}
if(in==13)
{
return -1;
break;
}
}
}
void Selection(int color)
{
select_with_color(left-2,top-2,right+2,bottom+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,right+2,bottom+2,color);
}
};
class PopupMenu
{
private:
int l,t,r,b,btop,bbottom,length;
int row;
public:
void Show(int left,int top,char*list[],int rows)
{
int h=((rows*15)+10);
int s=1,size;
settextstyle(2,0,4);
for ( int i = 0 ; i < rows ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
length=w;
back(left,top,left+w+30,top+h,0);
setfillstyle(1,7);
bar(left,top,left+w,top+h);
buttoneffect(left,top,left+w,top+h);
settextstyle(2,HORIZ_DIR,4);
setcolor(0);
for(int a=0;a<rows;a++)
outtextxy(left+3,(top+2+(a*15)),list[a]);
l=left,t=top,r=left+w,b=top+h;
btop=t;bbottom=btop+15;
row=rows;
invertcolors(l+2,t+2,r-3,t+15);
}
int Click()
{
hidemouse();
invertcolors(l+2,t+2,r-3,t+15);
int h=((row*15)+10);
int s=1,size;
settextstyle(2,0,4);
for ( int i = 0 ; i < row ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
length=w;
//back(l,t,l+w,t+h,0);
showmouse();
getmouse(button,x,y);
int lc=1,fnc=0,over=-1;
delay(50);
while(lc==1)
{
getmouse(button,x,y);
for(int b=0;b<row;b++)
{
if(button==1)
{
if((x>l+w)||(x<l)||(y>t+h)||(y<t))
{
fnc=0;lc=0;
}
else if((y>(t+(15*b)))&&(y<(t+(15*b)+15)))
{
fnc=b+1;lc=0;
}
}
if(button==0)
{
if((y>(t+(15*b)))&&(y<(t+(15*b)+15)))
{
if((b!=over)||(over==-1))
{
if(over!=-1)
{
invertcolors(l+2,t+(15*over)+1,l+w-2,t+(15*over)+13);
}
invertcolors(l+2,t+(15*b)+1,l+w-2,t+(15*b)+13);over=b;
}
over=b;
}
}
}
}
hidemouse();
back(l,t,l+w+30,t+h,1);
delay(100);
showmouse();
return(fnc);
}
int Keypress()
{
static int counter=0;
static int scrollup=0;
static int scrolldown=0;
int scrolltime=row;
int h=((row*15)+10);
int s=1,size;
int retval=1;
settextstyle(2,0,4);
for ( int i = 0 ; i < row ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s;
int w=size;
//length=w;
while(1)
{
int in,ret;
in=getscan();
if(in==72)
{
if(scrollup>0)
{
scrollup--;
invertcolors(l+2,btop+2,r-3,bbottom);
btop=btop-15;
bbottom=bbottom-15;
invertcolors(l+2,btop+2,r-3,bbottom);
scrolldown=scrollup;
counter=scrollup;
retval=scrollup+1;
//return scrollup+1;
}
}
if(in==80)
{
if(scrolldown<scrolltime-1)
{
scrolldown++;
counter++;
invertcolors(l+2,btop+2,r-3,bbottom);
btop=btop+15;
bbottom=bbottom+15;
invertcolors(l+2,btop+2,r-3,bbottom);
scrollup=counter;
ret=scrolldown+1;
counter=scrolldown;
retval=ret;
//return ret;
}
}
if(in==28)
{
counter=0;
scrolldown=0;
scrollup=0;
back(l,t,l+length+30,t+h,1);
return retval;
break;
}
if(in==1)
{
counter=0;
scrolldown=0;
scrollup=0;
back(l,t,l+length+30,t+h,1);
return 0;
break;
}
}
counter=0;
scrolldown=0;
}
Getrightpos()
{
return length;
}
};
class ComboBox
{
private:
int l,t,r,b,btop,bbottom,length;
int row;
int textyes;
char* combo_text;
public:
void Text(char* comtext)
{
combo_text=comtext;
textyes=1;
}
int KShow(int left,int top,char *list[],int rows)
{
ComboMenu combolist;
int s=1,st=1;static int ii,count;
int size=0,buttonleft=0;
char *select;
int takeret;
if(textyes==1)
select=combo_text;
else
select=list[0];
settextstyle(2,0,4);
for ( int i = 0 ; i < rows ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s+30;
buttonleft=size;
size=size/8;
if(count!=1)
textarea(select,left,top,size);
int ml=left,mt=top,mr=left+buttonleft-6,mb=top+14;
int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.
mybutton(mr-16,mt+1,mr-2,mb-1);
for(int j=0;j<=2;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
l=left,t=top,r=left+size;
btop=t;bbottom=btop+15;
row=rows;
while(1)
{
int in,ret=1;
in=getch();
if(in==13)
{
combolist.Show(left,top+18,list,rows);
while(1)
{
takeret=ret;
ret=combolist.Keypress(list);
if(ret==-1)
{
select=list[takeret-1];
textarea(select,left,top,size);
int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.
mybutton(mr-16,mt+1,mr-2,mb-1);
for(int j=0;j<=2;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
break;
}
}
break;
}
}
return takeret;
}
int MShow(int l,int t,char *list[],int row)
{
int s=1,st=1;static int ii,count;
int size=0,buttonleft=0;
int ret;
char *greater;
char *select;
if(textyes==1)
select=combo_text;
else
select=list[0];
for ( int i = 0 ; i < row ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
size=s+30;
buttonleft=size;
size=size/8;
if(count!=1)
textarea(select,l,t,size);
int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.
mybutton(mr-16,mt+1,mr-2,mb-1);
for(int j=0;j<=2;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
showmouse();
while(!kbhit())
{
getmouse(button,x,y); //Get Mouse
if((x>ml)&&(x<mr)&&(y>mt)&&(y<mb)&&(button==1))
{
delay(200);
ret=mymenu(ml-2,mt+18,list,6,size-1);
for(ii=1;ii<=row;ii++)
{
if(ii==ret)
{
select=list[ii-1];
count=1;
}
}
textarea(select,l,t,size);
int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.
mybutton(mr-16,mt+1,mr-2,mb-1);
for(int j=0;j<=2;j++)
{
setcolor(0);
line(ll,lt,lr,lb);
ll=ll+1,lr=lr-1;
lt=lt+1,lb=lb+1;
}
return ret;
}
}
}
};
class IconButton
{
private:
float capyes;
char* caption;
int left,top,right,bottom;
int length;
public:
void Show(int l,int t,char fn[100])
{
int width;
settextstyle(2,0,4);
int length;
int lengthdiff,minus,devide;
if(capyes==0)
{
width=(textwidth(caption));
length=width+20;
}
else
{
width=(textwidth("GCPPCommand"));
length=width+20;
}
if(length<=50)
{
mybutton(l,t,l+50,t+50);
load_icon(fn,l+5,t+5);
left=l,top=t,right=l+50,bottom=t+50;
}
if(length>50)
{
lengthdiff=((l+length)-l);
minus=length-40;
devide=minus/2;
mybutton(l,t,l+length,t+50);
load_icon(fn,l+devide,t+5);
left=l,top=t,right=l+length,bottom=t+50;
}
setfillstyle(SOLID_FILL,butcolor);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
setcolor(0);
if(capyes==0)
outtextxy(l+10,t+37,caption);
else
outtextxy(l+10,t+37,"GCPPCommand");
}
void Show(int l,int t,char *cap,char fn[100])
{
int width;
settextstyle(2,0,4);
int length;
int lengthdiff,minus,devide;
length=textwidth(cap)+10;
if(length<=50)
{
mybutton(l,t,l+50,t+50);
load_icon(fn,l+5,t+5);
left=l,top=t,right=l+50,bottom=t+50;
}
if(length>50)
{
lengthdiff=((l+length)-l);
minus=length-40;
devide=minus/2;
mybutton(l,t,l+length,t+50);
load_icon(fn,l+devide,t+5);
left=l,top=t,right=l+length,bottom=t+50;
}
setcolor(0);
settextstyle(2,0,4);
outtextxy(l+5,t+37,cap);
}
Click()
{
showmouse();
while(!kbhit())
{
getmouse(button,x,y);
if((x>left)&&(x<right)&&(y>top)&&(y<bottom)&&(button==1))
{
hidemouse();
buttonclick(left,top,right,bottom);
showmouse();
delay(50);
hidemouse();
buttoneffect(left,top,right,bottom);
showmouse();
delay(200);
return 1;
}
}
}
Keypress()
{
while(1)
{
int in;
in=inkey();
if(in==13)
{
buttonclick(left,top,right,bottom);
delay(50);
buttoneffect(left,top,right,bottom);
return 1;
break;
}
if(in==27||in==9)
{
return -1;
break;
}
}
}
void Caption(char* cap)
{
strcpy(caption,cap);
capyes=0;
}
Getrightpos()
{
return length;
}
void Selection(int color)
{
select_with_color(left-2,top-2,right+2,bottom+2,color);
}
void Deselection(int color)
{
deselect_with_color(left-2,top-2,right+2,bottom+2,color);
}
};
class ScrollList
{
private:
int l,t,r,b,gr,disp;
public:
VertScrollBar vert1;
Show(int left,int top,char *list[],int totalline,int displine)
{
int s=1,width,height;
int ghurbe,vertscroll;
int row,col;
ghurbe=totalline-displine;
if(ghurbe>0)
vertscroll=ghurbe;
else
vertscroll=0;
settextstyle(2,0,4);
row=left-8+10;
col=top-8+5;
for ( int i = 0 ; i < totalline ; i++ )
{
if ( strlen ( list[i] ) > s )
{
s = strlen ( list[i] ) ;
s=s;
}
}
s=s*8;
width=s;
height=displine*10;
setfillstyle(1,15);
bar(left-10,top-10,left+width+30,top+height+10);
buttonclick(left-10,top-10,left+width+30,top+height+10);
vert1.Show(left+width+8,top-9,top+height+8,vertscroll);
for(i=0;i<displine;i++)
{
setcolor(0);
outtextxy(row,col,list[i]);
col+=10;
}
l=left-8,t=top-8,r=left+width+5,b=top+height+5;
gr=vertscroll;
disp=displine;
}
Clear()
{
setfillstyle(1,15);
bar(l,t,r,b);
}
Keypress(char *list[])
{
int first=0,ret,i;
int row=l+10,col=t+5;
settextstyle(2,0,4);
while(1)
{
ret=vert1.Keypress();
if((ret<=gr||ret>=0)&&ret!=-1)
{
first=ret;
setfillstyle(1,15);
bar(l,t,r,b);
setcolor(0);
for(i=first;i<first+disp;i++)
{
outtextxy(row,col,list[i]);
col+=10;
}
col=t;
}
if(ret==-1)
return 0;
}
}
Click(char *list[])
{
int first=0,ret,i;
int row=l+10,col=t+5;
settextstyle(2,0,4);
showmouse();
while(!kbhit())
{
ret=vert1.Click();
if((ret<=gr||ret>=0)&&ret!=-1)
{
first=ret;
setfillstyle(1,15);
bar(l,t,r,b);
setcolor(0);
for(i=first;i<first+disp;i++)
{
outtextxy(row,col,list[i]);
col+=10;
}
col=t;
}
if(ret==-1)
return 0;
}
}
};
class Menu
{
private:
int pl,pt,pr,pb,item;
public:
int Show(int l,int t,char *list[],int row)
{
int s=1,st=1;static int ii,count;
int size=0,buttonleft=0;
int length=0,total_text_size=0;
int left=l;
int stat_left=l;
pl=l,pt=t;
item=row;
settextstyle(SMALL_FONT,HORIZ_DIR,4);
for ( int i = 0 ; i < row ; i++ )
{
length=strlen ( list[i] );
size=size+length;
}
total_text_size=size*8;
setfillstyle(1,7);
bar(l,t,l+total_text_size,t+15);
int temp=0;
setcolor(0);
for ( i = 0 ; i < row ; i++ )
{
outtextxy(left+4,t+2,list[i]);
length=strlen ( list[i] );
size=length*8;
temp=size;
left=temp+left;
size=0;length=0;
}
}
Keypress(char* list[])
{
int in;
int tl,ttl,ttl2;
int count=0,lasttake=0;
int len,len2,len3;
int lastright,lastleft;
int i;
tl=pl;
while(1)
{
in=getscan();
if(in==28)
{
if(count==0)
{
len2=strlen(list[item-1])*8;
buttonpush(ttl,pt,ttl+len2,pt+15,0);
}
len2=strlen(list[count-1])*8;
buttonpush(ttl,pt,ttl+len2,pt+15,0);
return lasttake;
break;
}
if(in==1)
{
if(count==0)
{
len2=strlen(list[item-1])*8;
buttonpush(ttl,pt,ttl+len2,pt+15,0);
}
len2=strlen(list[count-1])*8;
buttonpush(ttl,pt,ttl+len2,pt+15,0);
return 0;
break;
}
lastright=pl;
lastleft=pl;
if(in==77&&count>=0&&count<item)
{
len=strlen(list[count])*8;
if(count==0)
{
for(i=0;i<item;i++)
{
len2=strlen(list[i])*8;
lastright=lastright+len2;
}
for(i=0;i<item-1;i++)
{
len2=strlen(list[i])*8;
lastleft=lastleft+len2;
}
buttonpush(lastleft,pt,lastright,pt+15,0);
}
if(count>0)
{
len2=strlen(list[count-1])*8;
buttonpush(ttl,pt,ttl+len2,pt+15,0);
}
buttonpush(tl,pt,tl+len,pt+15,1);
ttl=tl;
tl=tl+len;
count++;
lasttake=count;
if(count==item)
{
lasttake=count;
count=0;
tl=pl;
}
}
}
}
};