?? frame.c
字號:
void drawbutton(int left,int top,int right,int bottom,char *caption,int charstyle,int charsize,int textcolor,int bkcolor,int border,int bordercolor)
{
int text_x,text_y,i;
text_x=left+(right-left-(charsize)*strlen(caption)*8)/2;
text_y=(bottom+top)/2;
setcolor(bordercolor);
setfillstyle(0,bkcolor);
settextstyle(charstyle,HORIZ_DIR,charsize);
// setusercharsize(3,7,3,7);
for(i=0;i<border;i++)rectangle(left+i,top+i,right-i,bottom-i); //draw border
floodfill((left+right)/2,(top+bottom)/2,bordercolor);//fill ths inside of this button
setcolor(textcolor);
outtextxy(text_x,text_y,caption);//show caption
}
void showinfo(char* info)//show information
{
setfillstyle(1,7);
settextstyle(0,HORIZ_DIR,1);
bar(15,435,625,460);
setcolor(15);
outtextxy(20,445,info);
}
void showcaption(char * caption)
{
int text_x;
text_x=160+(620-160-strlen(caption)*8)/2;
setfillstyle(0,7);
bar(170,45,610,58);
settextstyle(0,HORIZ_DIR,1);
setcolor(15);
outtextxy(text_x,50,caption);
}
void drawframe(void)
{
setbkcolor(1);
clearviewport();
setcolor(3);
rectangle(10,10,630,470);
line(160,20,160,430);
outtextxy(50,50,"M-E-N-U");
setcolor(14);
line(20,60,150,60);
line(180,60,600,60);
//draw seven buttons below
drawbutton(15,80,155,110,"Input/Modify Data",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,130,155,160,"Ave of Everyone",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,180,155,210,"Ave of Each Sub",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,230,155,260,"Top of Each Sub",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,280,155,310,"Sort of Each Sub",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,330,155,360,"Who Is fail ",0,1,YELLOW,CYAN,2,GREEN);
drawbutton(15,380,155,410,"Exit",0,1,YELLOW,CYAN,2,GREEN);
showinfo("Note: press DOWN UP to choose,ENTER to do it");
}
void fillblank(int x,int y,char * string,int textcolor,int bkcolor)//show string in blank(x,y)
{
int text_x,text_y,i,j,k;
int size=strlen(string),line;
char str[10];
//if size>=10 ,the string can't show in one line
if(size%9==0)line=size/9;
else line=size/9+1;
if(line==1)text_x=165+x*75+(75-strlen(string)*8)/2;
else text_x=165+x*75+2;
setfillstyle(1,bkcolor);
setcolor(textcolor);
bar(166+x*75,72+y*32,164+x*75+75,70+y*32+32);
for(i=0;i<line;i++)
{
k=0;
for(j=i*9;(j<i*9+9)&&string[j];j++)str[k++]=string[j];
str[k]='\0';
text_y=71+y*32+(32/line)/2-4+i*(32/line);
outtextxy(text_x,text_y,str);
}
}
void drawchild_1(void)//show first child interface,
{
int i,j;
char score[10];
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<7;i++)
line(165+i*75,71,165+i*75,424);
for(i=0;i<12;i++)
line(165,71+i*32,615,71+i*32);
showinfo("Note: UP DOWN LEFT RIGHT---move ,0~9---input data ,F10---menu");
showcaption("Input students' score of each subject");
for(i=0;i<5;i++)//show names of subjects
fillblank(i+1,0,SUBJECTS[i],14,1);
for(i=0;i<10;i++)//show names of students
fillblank(0,i+1,STUDENTS[i],14,1);
for(i=0;i<10;i++)
for(j=0;j<5;j++)//show score
{
sprintf(score,"%d",SCORE[i][j]);
fillblank(j+1,i+1,score,15,1);
}
}
void drawchild_2(void)//show second child interface,
{
int i;
float ave[10];
char str[10];
showinfo("Note: press DOWN UP to choose,ENTER to do it");
showcaption("The average score of each student");
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<12;i++)
line(170,70+i*30,610,70+i*30);
line(330,70,330,400);
setcolor(14);
outtextxy(200,90,"Students' Name");
outtextxy(350,90,"Average Score");
setcolor(15);
ave_student(SCORE,ave);
for(i=0;i<10;i++)
{
sprintf(str,"%5.2f",ave[i]);
outtextxy(180,111+i*30,STUDENTS[i]);
outtextxy(370,111+i*30,str);
}
}
void drawchild_3(void)
{
int i;
float ave[5];
char str[10];
showinfo("Note: press DOWN UP to choose,ENTER to do it");
showcaption("The average of each subject");
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<7;i++)
line(170,70+i*30,610,70+i*30);
line(330,70,330,250);
setcolor(14);
outtextxy(200,90,"Subject");
outtextxy(350,90,"Average Score");
setcolor(15);
ave_subject(SCORE,ave);
for(i=0;i<5;i++)
{
sprintf(str,"%5.2f",ave[i]);
outtextxy(180,111+i*30,SUBJECTS[i]);
outtextxy(370,111+i*30,str);
}
}
void drawchild_4(void)
{
int i;
int top_index[5];
showinfo("Note: press DOWN UP to choose,ENTER to do it");
showcaption("The top of each subject");
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<7;i++)
line(170,70+i*30,610,70+i*30);
line(330,70,330,250);
setcolor(14);
outtextxy(200,90,"Subject");
outtextxy(350,90,"The Top's Name");
setcolor(15);
top_subject(SCORE,top_index);
for(i=0;i<5;i++)
{
outtextxy(180,111+i*30,SUBJECTS[i]);
outtextxy(370,111+i*30,STUDENTS[top_index[i]]);
}
}
void drawchild_5(void)
{
int i,j;
int index[5];
float total[5];
char str[10];
showinfo("Note: press DOWN UP to choose,ENTER to do it");
showcaption("Sort of each subject (DES)");
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<7;i++)
line(170,70+i*30,610,70+i*30);
line(330,70,330,250);
setcolor(14);
outtextxy(200,90,"Subject");
outtextxy(350,90,"Total of subjects");
setcolor(15);
sort_subject(SCORE,total,index);
for(i=0;i<5;i++)
{
j=index[i];
sprintf(str,"%d.",j+1);
outtextxy(180,111+j*30,str);
outtextxy(200,111+j*30,SUBJECTS[i]);
sprintf(str,"%5.2f",total[i]);
outtextxy(370,111+j*30,str);
}
}
void drawchild_6(void)//show second child interface,
{
int i,j,len;
int name[10][5];
showinfo("Note: press DOWN UP to choose,ENTER to do it");
showcaption("The shutdent who is fail");
setcolor(3);
setfillstyle(0,7);
bar(165,71,615,425);
for(i=0;i<12;i++)
line(170,70+i*30,610,70+i*30);
line(330,70,330,400);
setcolor(14);
outtextxy(200,90,"Students' Name");
outtextxy(350,90,"The Subject Not Pass");
setcolor(15);
find_fail(SCORE,name);
for(i=0;i<10;i++)
{
len=0;
outtextxy(180,111+i*30,STUDENTS[i]);
for(j=0;j<5;j++)
{
if(name[i][j]==0)
{
outtextxy(335+len,111+i*30,SUBJECTS[j]);
len+=strlen(SUBJECTS[j])*8+8;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -