77范文网 - 专业文章范例文档资料分享平台

电子万年历代码

来源:网络收集 时间:2019-01-07 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

//====================================================================================

//文 件 名:Calendar_Interface.c //功能描述: 月历界面

//维护记录: 2007年6月17日

//====================================================================================

#include \#include \

DATE Calendar_Date[31]; CALENDAR *pCalendar;

//============================================================= //语法格式:INT8 Calendar_Month(INT16 Year, INT16 Month) //实现功能:(内部函数)对指定月中的每天进行计算,填充Calendar_Date数组 //参数: Year: 年 // Month: 月 //返回值: 无

//============================================================= INT8 Calendar_Month(INT16 Year, INT16 Month) { INT8 Ret; INT16 i; Ret = Date_GetMonthDays(Year, Month); for(i=1; i<=Ret; i++) { if(Date_Generate(Year, Month, i, &Calendar_Date[i-1])!=0) break; } if(i<=Ret) Ret = -1; return Ret; }

//=============================================================

//语法格式:void Calendar_Show(CALENDAR *pCalendarWindow, INT16 Year, INT16 Month) //实现功能:显示月历

//参数: pCalendarWindow: 月历配置结构体 // Year: 年 // Month: 月 //返回值: 无

//============================================================= void Calendar_Show(CALENDAR *pCalendarWindow, INT16 Year, INT16 Month)

{ INT16 Tempx, Tempy, TempColor, i; INT8 Days; INT8 TempStr[20]; STR_WINDOW wCalendar; STR_FONT FontCn12 = {12, 12, RES_HZK12}; STR_FONT FontAsc24 = {12, 24, RES_ASC24}; CLOCK Now; INT8 *T_WeekdayStr[] = { \日\一\二\三\四\五\六\ }; pCalendar = pCalendarWindow; Days = Calendar_Month(Year, Month); TFT_CreateWindow(&wCalendar, 0, 0, 319, 239, 0); TFT_LoadAsciiFont(&wCalendar, &FontAsc24); TFT_LoadChineseFont(&wCalendar, &FontCn12); TFT_PutBitMap(&wCalendar, 0, 0, pCalendar->BGImage); // 背景图片 TFT_SetChineseFont(&wCalendar, 0); // 题头 TFT_SetAsciiFont(&wCalendar, 0); TFT_SetColor(&wCalendar, pCalendar->HeadColor); TFT_SetBGColor(&wCalendar, 0); TFT_SetTextPos(&wCalendar, 20, 0); TFT_Print(&wCalendar, \年%d月\ TFT_SetTextPos(&wCalendar, 120, 0); TFT_Print(&wCalendar, \农历%s年(%s年)\Calendar_Date[0].GanZhiYearStr, Calendar_Date[0].AnimalStr); TFT_SetColor(&wCalendar, pCalendar->TableHeadColor); // 星期 for(i=0; i<7; i++) { Tempx = ((7-pCalendar->FirstWeekDay+i)%7)*40 + 12; TFT_SetTextPos(&wCalendar, Tempx, 24); TFT_Print(&wCalendar, \ } Tempy = 41; TFT_SetAsciiFont(&wCalendar, 1); TFT_SetChineseFont(&wCalendar, 1); for(i=0; i

Clock_Get(&Now); if(Year==Now.Year && Month==Now.Mon && i==Now.Day-1) // 今日 { Tempx = ((7-pCalendar->FirstWeekDay+Calendar_Date[i].Weekday)%7)*40+1; TFT_SetColor(&wCalendar, pCalendar->TodayColor); TFT_Rectangle(&wCalendar, Tempx, Tempy, Tempx+38, Tempy+38, PAINT_SOLID); } TempColor = pCalendar->CommonColor; if( Calendar_Date[i].Weekday==0 || Calendar_Date[i].Weekday==6) TempColor = pCalendar->WeekendColor; if( (Month==1 && i==0) // 元旦、五一、十一、春节 || (Month==5 && i==0) || (Month==10 && i==0) || (Calendar_Date[i].LunarMonth==1 && Calendar_Date[i].LunarDay==1) ) { TempColor = pCalendar->WeekendColor; } if(i<9) // 一位数 Tempx = ((7-pCalendar->FirstWeekDay+Calendar_Date[i].Weekday)%7)*40 + 14; else // 两位数 Tempx = ((7-pCalendar->FirstWeekDay+Calendar_Date[i].Weekday)%7)*40 + 8; TFT_SetTextPos(&wCalendar, Tempx, Tempy); TFT_SetColor(&wCalendar, TempColor); TFT_Print(&wCalendar, \ TempColor = pCalendar->LunarColor; if((Calendar_Date[i].Fu&0x00FF)==1) // 伏 { strcpy(TempStr, Calendar_Date[i].FuStr); TempStr[4] = '\\0'; TempColor = pCalendar->SpecialColor; } if((Calendar_Date[i].Jiu&0x00FF)==1) // 九 { strcpy(TempStr, Calendar_Date[i].JiuStr); TempStr[4] = '\\0'; TempColor = pCalendar->SpecialColor; } if(Calendar_Date[i].SolarTerm!=-1) // 节气 {

TempColor = pCalendar->SpecialColor; strcpy(TempStr, Calendar_Date[i].SolarTermStr); } if(Calendar_Date[i].LunarFestivalStr[0]!='\\0') // 农历节日 { TempColor = pCalendar->SpecialColor; strcpy(TempStr, Calendar_Date[i].LunarFestivalStr); } if(Calendar_Date[i].FestivalStr[0]!='\\0') // 公历节日 { TempColor = pCalendar->SpecialColor; strcpy(TempStr, Calendar_Date[i].FestivalStr); } if(TempColor==pCalendar->LunarColor) // 普通农历 { if(Calendar_Date[i].LunarDay==1) // 初一显示月号 { strcpy(TempStr, Calendar_Date[i].LunarMonthStr); if(strlen(TempStr)<=4) strcat(TempStr, \月\ } else strcpy(TempStr, Calendar_Date[i].LunarDayStr); } if(strlen(TempStr)==4) // 两个字 Tempx = (7-pCalendar->FirstWeekDay+Calendar_Date[i].Weekday)%7*40 + 8; else // 三个字 Tempx = (7-pCalendar->FirstWeekDay+Calendar_Date[i].Weekday)%7*40 + 2; TFT_SetColor(&wCalendar, TempColor); TFT_SetTextPos(&wCalendar, Tempx, Tempy+24); TFT_Print(&wCalendar, TempStr); if(Calendar_Date[i].Weekday==(pCalendar->FirstWeekDay+6)%7) // 换行 { Tempy += 40; if(Tempy>=240) Tempy = 41; } } }

//============================================================= //语法格式:INT16 Calendar_GetKey(INT16 x, INT16 y)

//实现功能:判断坐标是否落在功能按钮上 //参数: x: x坐标 // y: y坐标 //返回值: 键值

//============================================================= INT16 Calendar_GetKey(INT16 x, INT16 y) { INT16 Tempx, Tempy; INT16 Ret=-1; Tempx = x; Tempy = y; if(Tempx>=0 && Tempx<280 && Tempy>=40 && Tempy<240) // 日历区域 { Ret = Tempx/40 + (Tempy-40)/40*7; } else if(Tempx>=283 && Tempx<=316 && Tempy>=4 && Tempy<=37) // 前一年 Ret = 100; else if(Tempx>=283 && Tempx<=316 && Tempy>=44 && Tempy<=77) // 后一年 Ret = 101; else if(Tempx>=283 && Tempx<=316 && Tempy>=91 && Tempy<=124)// 后一月 Ret = 102; else if(Tempx>=283 && Tempx<=316 && Tempy>=131 && Tempy<=164)// 后一月 Ret = 103; else if(Tempx>=283 && Tempx<=316 && Tempy>=196 && Tempy<=229)// 返回 Ret = 104; return Ret; }

//============================================================= //语法格式:INT16 Calendar_GetKey(INT16 x, INT16 y) //实现功能:判断坐标是否落在功能按钮上 //参数: x: x坐标 // y: y坐标 //返回值: 键值

//============================================================= void Calendar_ShowDay(CALENDAR *pCalendar, INT16 Key) { STR_WINDOW wDay, wFestival; INT16 x, y, Day, Temp; INT32 i; DATE *pDate; INT8 *T_WeekdayStr[] = {

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库电子万年历代码在线全文阅读。

电子万年历代码.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/407496.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: