⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textbox.h

📁 这是一个人力资源管理软件。运行MAIN.CPP 进入“登陆信息”。 要进入员工管理页面请如下输入 empid - JOEL ,password - JOEL 进入管理人员界面: empid - ADM
💻 H
字号:

/*CLASS TEXTBOX*/
class textbox
{
int x,y,x1,y1;
int color;
char string[80];
int type;
public:
textbox(){x=NULL;y=NULL;x1=NULL;y1=NULL;color=WHITE;string[0]=NULL;textboxjump=0;type=0;}
void show(int);
void setpoints(int ,int,int,int);
void check(int,int);
inline int focus();
char* readstring();
int readnumber();
void setstring(char *d){strcpy(string,d);strupr(string);}
void setnumber(int a){char b[13];itoa(a,b,10);setstring(b);}
void settype(int a){ type=a;}
};
/*END*/

int textbox::readnumber()
{
int temp;
temp=atoi(string);
return temp;
}

/*READSTRING()*/
char* textbox::readstring()
{
int len=0;
len=strlen(string);
if(len==0){return NULL;}
else
{return string;
}
}
/*END*/

/*CHECK(INT,INT,INT)*/
void textbox::check(int k=0,int l=15)
{
while(focus()==TRUE || textboxjump==10)
{
mouse.getmousepos();

if(focus()==TRUE || textboxjump==10)
{
//printf("%d",globalx);
if((globalbut&1)==1 || textboxjump==10)
{
int tx,ty,ty1,s;
tx=x+3;
ty=y+3;
s=y1-y;
if(s==21)
{
ty1=y1-3;
}
else
{
ty1=y+18;
}
int len=strlen(string);
tx=tx+(len*9);
char temp;
settextstyle(DEFAULT_FONT,0,1);
textboxjump=10;
while(kbhit())
{
getch();
}
for(;;)
{
//do
/*{*/
int tempcolor=k;
while(!kbhit() || tempcolor!=k)
{
mouse.getmousepos();
if((globalbut&1)==1 && tempcolor==k && focus()!=TRUE){textboxjump=0;return;}
setcolor(tempcolor);
line(tx,ty,tx,ty1);
(tempcolor==k)?(tempcolor=l):(tempcolor=k);
delay(100);
}
temp=getch();
switch(temp)
{
case '\t':
case 13:return;

case '\b':if(len!=0)
	  {
	  if(len==20)
	  {tx=x+183;ty=y+3;//ty1=y1-3;
	  s=y1-y;
	  if(s==21)
	  {
	    ty1=y1-3;
	  }
	  else
	 {
	  ty1=y+18;
	 }
	 }

	 if(len==40)
	 {tx=x+183;ty=y+23;ty1=ty+18;}
	 if(len==60)
	 {tx=x+183;ty=y+43;ty1=ty+18;}
	  mouse.hidemouseptr();
	  tx-=9;
	  string[--len]=NULL;
	  setfillstyle(SOLID_FILL,l);
	  bar(tx,ty+5,tx+9,ty+15);
	  mouse.showmouseptr();
	  }
	  break;

default:
	 if(s==21)
	 {
		 if(len<12)
		{
		   mouse.hidemouseptr();
		   string[len]=temp;len++;
		   string[len]=NULL;
		   strupr(string);
		   setcolor(8);
		   char temp2[2];
		   if(type==0)
		  {
			temp2[0]=temp;
		  }
		  else
		 {
			 temp2[0]=4;
		 }
		 temp2[1]=NULL;
		 strupr(temp2);
		 outtextxy(tx,ty+5,temp2);
		 tx+=9;
		 mouse.showmouseptr();
		}
	 //break;
	 }

	 else
	 {
	  if(len<80)
	  {
	   if(len==20)
	   {tx=x+3;ty=ty+20;ty1=ty1+20;}
	   if(len==40)
	   {tx=x+3;ty=ty+20;ty1=ty1+20;}
	   if(len==60)
	   {tx=x+3;ty=ty+20;ty1=ty1+20;}
	   //if(len==80)
	   //{tx=x+3;ty+20;ty1=ty1+20;}
		mouse.hidemouseptr();
		string[len]=temp;len++;
		string[len]=NULL;
		strupr(string);
		setcolor(8);
		char temp2[2];
		if(type==0)
		{
			temp2[0]=temp;
		}
		else
	       {
			temp2[0]=4;
	       }
		temp2[1]=NULL;
		strupr(temp2);
		outtextxy(tx,ty+5,temp2);
		tx+=9;
		mouse.showmouseptr();
	 } }
	 break;




}
//}while(len<12);
}
}

return;
}}
}
//END

//FOCUS(INT,INT)
int textbox::focus()
{
if(globalx<=x1 && globalx>=x && globaly<=y1 && globaly>=y)
{
return TRUE;//if true return 0
}
else
{
return FALSE;//if false return 1
}
}
//END

//SETPOINTS()
void textbox::setpoints(int a,int b,int c=0,int d=0)
{
//int c,d;
if(c==0)
{
c=a+120;
}
if(d==0)
{
d=b+21;
}
x=a;
y=b;
x1=c;
y1=d;
}
//END

//SHOW()
void textbox::show(int k=15)
{
setfillstyle(SOLID_FILL,k);
bar(x,y,x1,y1);
setcolor(DARKGRAY);
line(x,y+1,x1+1,y+1);
line(x+1,y,x+1,y1+1);
setcolor(BLACK);
line(x,y,x1+1,y);
line(x,y,x,y1+1);

setcolor(LIGHTGRAY);
line(x,y1+2,x1+2,y1+2);
line(x1+2,y,x1+2,y1+2);
if(string!=NULL)
{
setcolor(DARKGRAY);
settextstyle(0,0,0);
int tx=x+3;
int ty=y+3;
//outtextxy(tx,ty+5,string);
int c=0;
int len=strlen(string);
setcolor(DARKGRAY);
while(c<len)
{
char temp[2];
temp[0]=string[c];
temp[1]=NULL;
outtextxy(tx,ty+5,temp);
tx+=9;
c++;
}

}
}
//END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -