📄 frame.h
字号:
{
pt=GetAt(MainHead,i);
if(strcmp(pt->Begin,Begin)==0)
{
padd=(TRAIN*)malloc(sizeof(TRAIN));
memcpy(padd,pt,sizeof(TRAIN));
if(findcount==0)
{
FindHead=CreatList((*padd));
FindLast=FindHead;
}
else
{
ptrain=AddTail(FindLast,*padd);
FindLast=ptrain;
}
findcount++;
}
}
if(findcount>0)
{
if(findcount>13) showcount=13;
else showcount=findcount;
TrainListShowData(3,306,FindHead,
NowIndexInList2,showcount,
GIRD_TEXTCOLOR2);
}
GoThroughList(1,FindHead);
UpdateStaticsData(451,280,1);
if(tab)
selcolor=SLEEP_COLOR;
else
selcolor=ACTIVE_COLOR;
SetTrainListSelBar(3,293,447,selcolor,Index2,13);
SetTrainListScrollBar(438,306,447,306+13*13,
NowIndexInList2+13,findcount);
}
}
void Delete()
{
int nowposition;
int showcount;
int temp;
//int yoffset=Index1*13;
if(!tab) return;
if(totalcount>0)
{
nowposition=Index1+NowIndexInList1;
if(MessageBox(200,160,400,240,
"Delete","Are you sure?",RED,0)==1)
{
DeleteAt(&MainHead,nowposition);
Modified=1;
totalcount--;
GoThroughList(0,MainHead);
UpdateStaticsData(451,29,0);
if(NowIndexInList1>0)
{
temp=totalcount-NowIndexInList1;
if(temp<17)
NowIndexInList1--;
showcount=17;
}
else
{
if(totalcount>17) showcount=17;
else
{
showcount=totalcount;
ClearGirdText(3,42,447,17);
if((Index1+1)>=totalcount)
{
if(Index1==0);
else Index1--;
}
}
}
SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
SetTrainListScrollBar(438,55,447,55+17*13,
NowIndexInList1+17,totalcount);
TrainListShowData(3,55,MainHead,
NowIndexInList1,showcount,
GIRD_TEXTCOLOR1);
}
}
}
void Modify()
{
int nowindex;
TRAIN *ptrain;
int yoffset=Index1*13;
int showcount;
if(!tab) return;
if(totalcount>0)
{
nowindex=Index1+NowIndexInList1;
ptrain=GetAt(MainHead,nowindex);
strcpy(tempTrainNumber,ptrain->TrainNumber);
strcpy(tempKind,ptrain->Kind);
strcpy(tempBeginHour,ptrain->BeginHour);
strcpy(tempBeginMinute,ptrain->BeginMinute);
strcpy(tempBegin,ptrain->Begin);
strcpy(tempEndHour,ptrain->EndHour);
strcpy(tempEndMinute,ptrain->EndMinute);
strcpy(tempEnd,ptrain->End);
strcpy(tempCost,ptrain->Cost);
if(GroupBars(3,42+13+yoffset,447-10)==1)
{
strcpy(ptrain->TrainNumber,tempTrainNumber);
strcpy(ptrain->Kind,tempKind);
strcpy(ptrain->BeginHour,tempBeginHour);
strcpy(ptrain->BeginMinute,tempBeginMinute);
strcpy(ptrain->Begin,tempBegin);
strcpy(ptrain->EndHour,tempEndHour);
strcpy(ptrain->EndMinute,tempEndMinute);
strcpy(ptrain->End,tempEnd);
strcpy(ptrain->Cost,tempCost);
Modified=1;
}
if(totalcount<17)
showcount=totalcount;
else
showcount=17;
setfillstyle(SOLID_FILL,GIRD_BACKCOLOR);
bar(3,42+13+yoffset,447-10,42+13+yoffset+12);
SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
TrainListShowData(3,55,MainHead,
NowIndexInList1,showcount,
GIRD_TEXTCOLOR1);
}
}
void Exit()
{
DeleteAll(&MainHead);
DeleteAll(&FindHead);
closegraph();
exit(0);
}
void ClearGirdText(int x1,int y1,int x2,int CountPerPage)
{
setfillstyle(SOLID_FILL,GIRD_BACKCOLOR);
bar(x1,y1+13,x2-10,y1+CountPerPage*13+1+12);
}
void Save()
{
if(strlen(FileName)==0) SaveAsBox();
else
{
if(totalcount!=0) SaveList(MainHead,FileName);
}
Modified=0;
}
void New(int Load)
{
int i,k;
if(Modified)
{
if(MessageBox(200,160,400,240,
"New","Save current file?",RED,0)==1)
SaveAsBox();
}
for(i=0;i<2;i++)
for(k=0;k<5;k++)
statisticsdata[i][k]=0;
DeleteAll(&MainHead);
DeleteAll(&FindHead);
totalcount=0;
findcount=0;
Modified=0;
tab=1;
Index1=0;
Index2=0;
NowIndexInList1=0;
NowIndexInList2=0;
DrawCaptain(0,29,450,
FRAME_COLOR,ACTIVE_COLOR,
"Main list",1);
DrawCaptain(451,29,639,
FRAME_COLOR,ACTIVE_COLOR,
"Main statistics",1);
DrawCaptain(0,280,450,
FRAME_COLOR,SLEEP_COLOR,
"Find list",0);
DrawCaptain(451,280,639,
FRAME_COLOR,SLEEP_COLOR,
"Find statistics",0);
ClearGirdText(3,42,447,17);
SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
SetTrainListScrollBar(438,55,447,55+17*13,
NowIndexInList1+17,totalcount);
ClearGirdText(3,293,447,13);
SetTrainListSelBar(3,293,447,SLEEP_COLOR,Index2,13);
SetTrainListScrollBar(438,306,447,306+13*13,
NowIndexInList2+13,findcount);
if(!Load) ClearStr(FileName,20);
GoThroughList(1,FindHead);
UpdateStaticsData(451,280,1);
GoThroughList(0,MainHead);
UpdateStaticsData(451,29,0);
}
int MessageBox(int x1,int y1,int x2,int y2,
char *title,char *text,int textcolor,
int onlyOK) //height should
//long than 70.the value of height should be think careful
{
void *pimage;
unsigned int ImageSize;
ImageSize=imagesize(x1,y1,x2,y2);
pimage=malloc(ImageSize);
getimage(x1,y1,x2,y2,pimage);
DrawWindow(x1,y1,x2,y2,
FRAME_COLOR,ACTIVE_COLOR,
title,1,1,1);
setcolor(textcolor);
outtextxy(x1+20,y1+30,text);
setcolor(MENUTEXT_COLOR);
if(!onlyOK)
{
outtextxy(x1+10,y1+50,"<Enter> for YES.");
outtextxy(x1+10,y1+60,"< ESC > for NO.");
}
else
{
outtextxy(x1+40,y2-30,"<Enter> for OK.");
}
while(KeyboardMessage[1]!=CTRL_KEY_ESC)
{
PostKeybrdMessage();
if(KeyboardMessage[1]==CTRL_KEY_ENTER)
{
putimage(x1,y1,pimage,COPY_PUT);
free(pimage);
return 1;
}
}
putimage(x1,y1,pimage,COPY_PUT);
free(pimage);
return 0;
}
void LoadBox()
{
void *imagebuf;
int ImageSize;
int showcount;
ImageSize=imagesize(200,160,410,240);
imagebuf=malloc(ImageSize);
getimage(200,160,410,240,imagebuf);
DrawWindow(200,160,410,240,
FRAME_COLOR,ACTIVE_COLOR,
"Open...",1,
1,1);
DrawEdgeTwo(250,189,405,200);
setcolor(MENUTEXT_COLOR);
outtextxy(210,190,"Name:");
outtextxy(210,210,"<Enter> for YES.");
outtextxy(210,220,"< ESC > for CANCEL.");
if(EditBar(251,190,EDITBACK_COLOR,EDITTEXT_COLOR,FileName,20,0)==1)
{
putimage(200,160,imagebuf,COPY_PUT);
free(imagebuf);
New(1);
if((MainHead=LoadList(FileName))==NULL)
{
MessageBox(210,160,410,240,"Error",
"Can't find the file.",RED,1);
ClearStr(FileName,20);
return;
}
totalcount=GetCount(MainHead);
MainLast=GetAt(MainHead,totalcount-1);
if(totalcount<=17) showcount=totalcount;
else showcount=17;
GoThroughList(0,MainHead);
UpdateStaticsData(451,29,0);
TrainListShowData(3,55,MainHead,
NowIndexInList1,showcount,
GIRD_TEXTCOLOR1);
SetTrainListScrollBar(438,55,447,55+17*13,
NowIndexInList1+17,totalcount);
return;
}
putimage(200,160,imagebuf,COPY_PUT);
free(imagebuf);
return;
}
void SaveAsBox()
{
void *imagebuf;
int ImageSize;
ClearStr(FileName,20);
ImageSize=imagesize(200,160,410,240);
imagebuf=malloc(ImageSize);
getimage(200,160,410,240,imagebuf);
DrawWindow(200,160,410,240,
FRAME_COLOR,ACTIVE_COLOR,
"Save as...",1,
1,1);
DrawEdgeTwo(250,189,405,200);
setcolor(MENUTEXT_COLOR);
outtextxy(210,190,"Name:");
outtextxy(210,210,"<Enter> for YES.");
outtextxy(210,220,"< ESC > for CANCEL.");
if(EditBar(251,190,EDITBACK_COLOR,EDITTEXT_COLOR,FileName,20,0)==1)
{
if(totalcount!=0) SaveList(MainHead,FileName);
Modified=0;
}
putimage(200,160,imagebuf,COPY_PUT);
free(imagebuf);
}
void AddItem()
{
int offsety;
int AddPosition;
int showcount;
TRAIN *ptrain;
if(!tab) return;
DrawListGird(3,42,447,17);
ClearStr(tempTrainNumber,6);
ClearStr(tempKind,6);
ClearStr(tempBeginHour,3);
ClearStr(tempBeginMinute,3);
ClearStr(tempBegin,11);
ClearStr(tempEndHour,3);
ClearStr(tempEndMinute,3);
ClearStr(tempEnd,11);
ClearStr(tempCost,5);
if(totalcount>=16)
{
Index1=16;
NowIndexInList1=totalcount-16;
TrainListShowData(3,55,MainHead,
NowIndexInList1,16,
GIRD_TEXTCOLOR1);
}
else Index1=totalcount;
SetTrainListScrollBar(438,55,447,55+17*13,
NowIndexInList1+17,totalcount);
offsety=Index1*13;
while(GroupBars(3,42+13+offsety,447-10)!=0)
{
Modified=1;
if(Index1<16);// {Index1++;}
else { NowIndexInList1++;}
strcpy(atrain.TrainNumber,tempTrainNumber);
strcpy(atrain.Kind,tempKind);
strcpy(atrain.BeginHour,tempBeginHour);
strcpy(atrain.BeginMinute,tempBeginMinute);
strcpy(atrain.Begin,tempBegin);
strcpy(atrain.EndHour,tempEndHour);
strcpy(atrain.EndMinute,tempEndMinute);
strcpy(atrain.End,tempEnd);
strcpy(atrain.Cost,tempCost);
if(totalcount==0)
{
MainHead=CreatList(atrain);
MainLast=MainHead;
}
else
{
ptrain=AddTail(MainLast,atrain);
MainLast=ptrain;
}
totalcount++;
if(totalcount<17) {showcount=totalcount;}
else
{
showcount=16;
}
GoThroughList(0,MainHead);
UpdateStaticsData(451,29,0);
setfillstyle(SOLID_FILL,GIRD_BACKCOLOR);
bar(3,42+13+offsety,447-10,42+13+offsety+12);
//DrawListGird(3,42,447,17);
TrainListShowData(3,55,MainHead,
NowIndexInList1,showcount,
GIRD_TEXTCOLOR1);
SetTrainListScrollBar(438,55,447,55+17*13,
NowIndexInList1+17,totalcount);
ClearStr(tempTrainNumber,6);
ClearStr(tempKind,6);
ClearStr(tempBeginHour,3);
ClearStr(tempBeginMinute,3);
ClearStr(tempBegin,11);
ClearStr(tempEndHour,3);
ClearStr(tempEndMinute,3);
ClearStr(tempEnd,11);
ClearStr(tempCost,5);
if(totalcount>=16) Index1=16;
else Index1=totalcount;
offsety=Index1*13;
}
if(totalcount<17)
{
showcount=totalcount;
if(Index1==0);
else Index1--;
}
else
{
showcount=17;
NowIndexInList1--;
}
setfillstyle(SOLID_FILL,GIRD_BACKCOLOR);
bar(3,42+13+offsety,447-10,42+13+offsety+12);
//DrawListGird(3,42,447,17);
SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
TrainListShowData(3,55,MainHead,
NowIndexInList1,showcount,
GIRD_TEXTCOLOR1);
}
int GroupBars(int x1,int y1,int x2)
{
int k=0;
char tempT[6];
char tempK[6];
char tempBH[3];
char tempBM[3];
char tempB[11];
char tempEH[3];
char tempEM[3];
char tempE[11];
char tempC[5];
strcpy(tempT,tempTrainNumber);
strcpy(tempK,tempKind);
strcpy(tempBH,tempBeginHour);
strcpy(tempBM,tempBeginMinute);
strcpy(tempB,tempBegin);
strcpy(tempEH,tempEndHour);
strcpy(tempEM,tempEndMinute);
strcpy(tempE,tempEnd);
strcpy(tempC,tempCost);
setfillstyle(SOLID_FILL,EDITBACK_COLOR);
//DrawBox(x1,y1,x2,y1+13,EDITBACK_COLOR);
bar(x1,y1,x2-1,y1+13);
EditBar(x1+2,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempT,6,1);
EditBar(x1+55,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempK,6,1);
EditBar(x1+106,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempBH,3,1);
setcolor(EDITTEXT_COLOR);
outtextxy(x1+124,y1+2,":");
EditBar(x1+131,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempBM,3,1);
EditBar(x1+154,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempB,11,1);
EditBar(x1+252,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempEH,3,1);
setcolor(EDITTEXT_COLOR);
outtextxy(x1+269,y1+2,":");
EditBar(x1+276,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempEM,3,1);
EditBar(x1+298,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempE,11,1);
EditBar(x1+396,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempC,5,1);
DrawListGird(3,42,447,17);
if(EditBar(x1+2,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempT,6,0)
==0) goto end;
if(EditBar(x1+55,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempK,6,0)
==0) goto end;
if(EditBar(x1+106,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempBH,3,0)
==0) goto end;
if(EditBar(x1+131,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempBM,3,0)
==0) goto end;
if(EditBar(x1+154,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempB,11,0)
==0) goto end;
if(EditBar(x1+252,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempEH,3,0)
==0) goto end;
if(EditBar(x1+276,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempEM,3,0)
==0) goto end;
if(EditBar(x1+298,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempE,11,0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -