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

📄 frame.h

📁 一个数据结构的大作业
💻 H
📖 第 1 页 / 共 3 页
字号:
    ==0) goto end;
 if(EditBar(x1+396,y1+2,EDITBACK_COLOR,EDITTEXT_COLOR,tempC,5,0)
    ==0) goto end;
 strcpy(tempTrainNumber,tempT);
 strcpy(tempKind,tempK);
 strcpy(tempBeginHour,tempBH);
 strcpy(tempBeginMinute,tempBM);
 strcpy(tempBegin,tempB);
 strcpy(tempEndHour,tempEH);
 strcpy(tempEndMinute,tempEM);
 strcpy(tempEnd,tempE);
 strcpy(tempCost,tempC);
 k=1;
end:
 return k;
}
void DrawCaptain(int x1,int y1,int x2,//height is same
		 int color,int textcolor,
		 char *text,int is3dtext)
{
 int i;
 int drawlinex;
 int drawliney=y1+3;
 int textlength;
 DrawBox(x1,y1,x2,y1+12,color);
 if(is3dtext)
 {
  setcolor(0);
  outtextxy(x1+8,y1+4,text);
  setcolor(textcolor);
  outtextxy(x1+6,y1+2,text);
 }
 else
 {
  setcolor(textcolor);
  outtextxy(x1+7,y1+3,text);
 }
 textlength=strlen(text);
 textlength*=8;
 drawlinex=x1+textlength+9;
 for(i=0;i<2;i++)
 {
  setcolor(15);
  line(drawlinex,drawliney,x2-3,drawliney);
  setcolor(0);
  line(drawlinex,drawliney+1,x2-3,drawliney+1);
  drawliney+=4;
 }
}
void DrawWindow(int x1,int y1,int x2,int y2,
		int color,int textcolor,
		char *captain,int is3dtext,
		int borderwidth,int issolid)
{
 setfillstyle(SOLID_FILL,color);
 if(!issolid)
 {
  bar(x1,y1,x2,y1+borderwidth);
  bar(x1,y1,x1+borderwidth,y2);
  bar(x1,y2-borderwidth,x2,y2);
  bar(x2-borderwidth,y1,x2,y2);
 }
 else
  bar(x1,y1,x2,y2);
 DrawEdgeOne(x1,y1,x2,y2);
 DrawCaptain(x1,y1,x2,color,textcolor,captain,is3dtext);
}

void DrawTrainList(int x1,int y1,int x2,//height is ruled
		   int SelBarColor,
		   int CountPerPage)    //width
//|Number52|Type52|Begin44|From  |End44|To  |Cost36| 228 is ruled
//448-228=220 so From is 110 To is 110. allow to input 11 letters.
{
 int i;
 int textx=x1-2,texty=y1+2;
 int liney=y1+26;
 setfillstyle(SOLID_FILL,FRAME_COLOR);
 bar(x1,y1,x2,y1+12);
 for(i=0;i<7;i++)
 {
  setcolor(0);
  outtextxy(textx+5,texty,ColumnText[i]);
  textx+=ColumnWidth[i];
  if(i==6) break;
  line(textx,texty-2,textx,texty+10);
  setcolor(GIRD_COLOR);
  line(textx,texty+12,textx,y1+CountPerPage*13+1+12);
  setcolor(15);
  line(textx+1,texty-2,textx+1,texty+10);
 }
 setcolor(GIRD_COLOR);
 rectangle(x1,y1+13,x2-10,y1+CountPerPage*13+1+12);
 DrawTrainListScrollBar(x2-9,y1+13,x2,y1+CountPerPage*13+1+12);
 SetTrainListScrollBar(x2-9,y1+13,x2,y1+CountPerPage*13+1+12,
		       CountPerPage,totalcount);
 setcolor(GIRD_COLOR);
 for(i=0;i<CountPerPage;i++)
 {
  line(x1,liney,x2-10,liney);
  liney+=13;
 }
 setcolor(SelBarColor);
 rectangle(x1,y1+13,x2-10,y1+26);
}
void SetTrainListScrollBar(int x1,int y1,int x2,int y2,
			   int NowPosition,int Count)//Position and Count
			   //is begin from 1.
{
 int   drawy;
 float persent;
 if(NowPosition>Count) { persent=1;}
 else { persent=(float)NowPosition/(float)Count;}
 drawy=y1+4+(int)((y2-y1-13)*persent); //y1+4+(y2-4-4-5)*persent
 setfillstyle(SOLID_FILL,FRAME_COLOR);
 bar(x1+5,y1+4,x1+7,y2-4);

 setcolor(0);
 line(x1+7,drawy,x1+7,drawy+4);
 line(x1+6,drawy+1,x1+6,drawy+3);
 line(x1+5,drawy+2,x1+5,drawy+2);
}
void DrawListGird(int x1,int y1,int x2,int CountPerPage)
{
 int i;
 int textx=x1-2,texty=y1+2;
 int liney=y1+26;
 setcolor(GIRD_COLOR);//gird color.
 for(i=0;i<7;i++)
 {
  textx+=ColumnWidth[i];
  if(i==6) break;
  line(textx,texty+12,textx,y1+CountPerPage*13+1+12);
 }
 rectangle(x1,y1+13,x2-10,y1+CountPerPage*13+1+12);
 for(i=0;i<CountPerPage;i++)
 {
  line(x1,liney,x2-10,liney);
  liney+=13;
 }
}
void SetTrainListSelBar(int x1,int y1,int x2,
			int SelectColor,
			int NowSelect,int CountPerPage)
			//NowSelect begin from 0.
			//countperpage begin from 1.
{
 int offsety;
 if(NowSelect==CountPerPage) return;
 if(NowSelect==-1) return;
 DrawListGird(x1,y1,x2,CountPerPage);
 setcolor(SelectColor);
 offsety=NowSelect*13;
 rectangle(x1,y1+13+offsety,x2-10,y1+26+offsety);
}
void BarText(int x1,int y1,int x2,int y2,
	     int backcolor,int textcolor,
	     char *text)
{
 setfillstyle(SOLID_FILL,backcolor);
 bar(x1,y1,x2,y2);
 setcolor(textcolor);
 outtextxy(x1+1,y1+3,text);
}
void DrawTrainListScrollBar(int x1,int y1,int x2,int y2)
{
 setfillstyle(SOLID_FILL,FRAME_COLOR);
 bar(x1+1,y1+1,x2-1,y2-1);
 DrawEdgeTwo(x1,y1,x2,y2);
 setcolor(MENUTEXT_COLOR);
 line(x1+2,y1+3,x1+6,y1+3);
 line(x1+4,y1+3,x1+4,y2-3);
 line(x1+2,y2-3,x1+6,y2-3);
}

void ClearStr(char str[],int count)
{
 int i;
 for(i=0;i<count;i++)
  str[i]='\0';
}
void TrainListShowData(int x,int y,
		       TRAIN *head,/*int totalcount, */
		       int BeginIndex,int ShowCount,
		       int textcolor)  //Index begin from 0.
				       //count begin from 1.
{
  int i;
  int m=x;
  char destination[6];
  TRAIN *ptemp;
  ptemp=GetAt(head,BeginIndex);
  for(i=0;i<ShowCount;i++)
  {
   //ptemp=GetAt(head,BeginIndex);
   BarText(x+5,y+1,x+ColumnWidth[0]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   ptemp->TrainNumber);
   x+=ColumnWidth[0];
   BarText(x+1,y+1,x+ColumnWidth[1]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   ptemp->Kind);
   x+=ColumnWidth[1];
   ClearStr(destination,6);
   if(strlen(ptemp->BeginHour)==1)
   {
    strcpy(destination," ");
    strcat(destination,ptemp->BeginHour);
   }
   else
   {
    strcpy(destination,ptemp->BeginHour);
   }
   strcat(destination,":");
   strcat(destination,ptemp->BeginMinute);
   BarText(x,y+1,x+ColumnWidth[2]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   destination);
   x+=ColumnWidth[2];
   BarText(x+1,y+1,x+ColumnWidth[3]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   ptemp->Begin);
   x+=ColumnWidth[3];
   ClearStr(destination,6);
   if(strlen(ptemp->EndHour)==1)
   {
    strcpy(destination," ");
    strcat(destination,ptemp->EndHour);
   }
   else strcpy(destination,ptemp->EndHour);
   strcat(destination,":");
   strcat(destination,ptemp->EndMinute);
   BarText(x,y+1,x+ColumnWidth[4]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   destination);
   x+=ColumnWidth[4];
   BarText(x+1,y+1,x+ColumnWidth[5]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   ptemp->End);
   x+=ColumnWidth[5];
   BarText(x+1,y+1,x+ColumnWidth[6]-3,y+12,
	   GIRD_BACKCOLOR,textcolor,
	   ptemp->Cost);
   x=m;
   y+=13;
   BeginIndex++;
   ptemp=ptemp->NextTrain;
  }
}

void TwoListFunction()
{
 //static int Index1=0,Index2=0;
 //static int NowIndexInList1=0,NowIndexInList2=0;
 int title1color;
 int title2color;
 int is3dtext1;
 int is3dtext2;
 switch(KeyboardMessage[1])
 {
  case CTRL_KEY_TAB:
       {
	if(tab)
	{
	 title1color=SLEEP_COLOR;
	 title2color=ACTIVE_COLOR;
	 is3dtext1=0;
	 is3dtext2=1;
	 SetTrainListSelBar(3,42,447,SLEEP_COLOR,Index1,17);
	 SetTrainListSelBar(3,293,447,ACTIVE_COLOR,Index2,13);
	 tab--;
	}
	else
	{
	 title1color=ACTIVE_COLOR;
	 title2color=SLEEP_COLOR;
	 is3dtext1=1;
	 is3dtext2=0;
	 SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
	 SetTrainListSelBar(3,293,447,SLEEP_COLOR,Index2,13);
	 tab++;
	}
	DrawCaptain(0,29,450,
		    FRAME_COLOR,title1color,
		    "Main list",is3dtext1);
	DrawCaptain(451,29,639,
		    FRAME_COLOR,title1color,
		    "Main statistics",is3dtext1);
	DrawCaptain(0,280,450,
		    FRAME_COLOR,title2color,
		    "Find list",is3dtext2);
	DrawCaptain(451,280,639,
		    FRAME_COLOR,title2color,
		    "Find statistics",is3dtext2);
	break;
       }
  case CTRL_KEY_DOWN:
       {
	if(tab)
	{
	 if(totalcount<17)
	 {
	  if(Index1>=totalcount-1);
	  else
	  {
	   Index1++;
	   SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
	  }
	 }
	 else
	 {
	  if(Index1==16)
	  {
	   if((NowIndexInList1+17)<totalcount)
	   {
	    NowIndexInList1++;
	    TrainListShowData(3,55,
			      MainHead,
			      NowIndexInList1,17,GIRD_TEXTCOLOR1);
	    SetTrainListScrollBar(438,55,447,55+17*13,
				  NowIndexInList1+17,totalcount);
	   }
	  }
	  else
	  {
	   Index1++;
	   SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
	  }
	 }
	}
	else
	{
	 if(findcount<13)
	 {
	  if(Index2>=findcount-1);
	  else
	  {
	   Index2++;
	   SetTrainListSelBar(3,293,447,ACTIVE_COLOR,Index2,13);
	  }
	 }
	 else
	 {
	  if(Index2==12)
	  {
	   if((NowIndexInList2+13)<findcount)
	   {
	    NowIndexInList2++;
	    TrainListShowData(3,306,
			      FindHead,
			      NowIndexInList2,13,GIRD_TEXTCOLOR2);
	    SetTrainListScrollBar(438,306,447,306+13*13,
				  NowIndexInList2+13,findcount);
	   }
	  }
	  else
	  {
	   Index2++;
	   SetTrainListSelBar(3,293,447,ACTIVE_COLOR,Index2,13);
	  }
	 }
	}
	break;
       }
  case CTRL_KEY_UP:
       {
	if(tab)
	{
	 if(Index1==0)
	 {
	  if(NowIndexInList1!=0)
	  {
	   NowIndexInList1--;
	   TrainListShowData(3,55,
			     MainHead,
			     NowIndexInList1,17,GIRD_TEXTCOLOR1);
	   SetTrainListScrollBar(438,55,447,55+17*13,
				 NowIndexInList1+17,totalcount);
	  }
	 }
	 else
	 {
	  Index1--;
	  SetTrainListSelBar(3,42,447,ACTIVE_COLOR,Index1,17);
	 }
	}
	else
	{
	 if(Index2==0)
	 {
	  if(NowIndexInList2!=0)
	  {
	   NowIndexInList2--;
	   TrainListShowData(3,306,
			     FindHead,
			     NowIndexInList2,13,GIRD_TEXTCOLOR2);
	   SetTrainListScrollBar(438,306,447,306+13*13,
				 NowIndexInList2+13,findcount);
	  }
	 }
	 else
	 {
	  Index2--;
	  SetTrainListSelBar(3,293,447,ACTIVE_COLOR,Index2,13);
	 }
	}
	break;
       }
  case CTRL_KEY_PAGEDN:
       {
	if(tab)
	{
	 if((NowIndexInList1+34)<40)
	 {
	  /*NowIndexInList1+=17;
	  TrainListShowData(3,55,
			    trains,40,
			    NowIndexInList1,17,GIRD_TEXTCOLOR1);
	  SetTrainListScrollBar(438,55,447,55+17*13,
				NowIndexInList1+17,40);*/
	 }
	 else
	 {
	  if(NowIndexInList1!=23)
	  {
	   /*NowIndexInList1=23;
	   TrainListShowData(3,55,
			     trains,40,
			     NowIndexInList1,17,GIRD_TEXTCOLOR1);
	   SetTrainListScrollBar(438,55,447,55+17*13,
				 NowIndexInList1+17,40);*/
	  }
	 }
	}
	break;
       }
  case CTRL_KEY_PAGEUP:
       {
	if(tab)
	{
	 if((NowIndexInList1-17)>=0)
	 {
	  /*NowIndexInList1-=17;
	  TrainListShowData(3,55,
			   trains,40,
			   NowIndexInList1,17,GIRD_TEXTCOLOR1);
	  SetTrainListScrollBar(438,55,447,55+17*13,
				 NowIndexInList1+17,40);*/
	 }
	 else
	 {
	  if(NowIndexInList1!=0)
	  {
	   /*NowIndexInList1=0;
	   TrainListShowData(3,55,
			    trains,40,
			    NowIndexInList1,17,GIRD_TEXTCOLOR1);
	   SetTrainListScrollBar(438,55,447,55+17*13,
				 NowIndexInList1+17,40);*/
	  }
	 }
	}
	else
	{}
	break;
       }
 }
}
#endif




⌨️ 快捷键说明

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