📄 schedatepage.c
字号:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Private function//////////////////////////////////////////////////////////////////////////int MyDate_Update( MyDate* pMyDate, int year, int month, int day ) {//Update the date //to do int retVal = FALSE; int daysOfMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; if ( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) { if ( 2 == month ) { daysOfMonth[month] ++ ; } } if ( 0 == month ) { month = 12 ; year -- ; } if ( day > daysOfMonth[month] ) { day = day - daysOfMonth[month] ; month ++ ; if ( month > 12 ) { month = 1 ; year ++ ; } } if ( day <= 0 ) { month -- ; if ( 0 == month ) { month = 12 ; year -- ; } if ( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) { if ( 2 == month ) { daysOfMonth[month] ++ ; } } day = day + daysOfMonth[month] ; } if ( pMyDate->m_cursorDate.m_month != month ) { MyDate_SignEvtOfAMonth( pMyDate, ( uint16 )year, ( uint16 )month, pMyDate->m_signFlag ) ; } { pMyDate->m_cursorDate.m_year = year ; pMyDate->m_cursorDate.m_month = month ; pMyDate->m_cursorDate.m_day = day ; return ( TRUE ) ; } return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_DrawYearMonth( MyDate* pMyDate, AEERect* pRect, uint16 year, uint16 month ){//to do int retVal = FALSE; AECHAR buffer[10] = { 0 }; AECHAR monthBuffer[5] = { ' ','/',' ','\0' }; WWRITELONG( buffer, year ) ; WSTRCAT( buffer, monthBuffer ) ; WWRITELONG( monthBuffer, month ) ; WSTRCAT( buffer, monthBuffer ) ; IDISPLAY_DrawText(pMyDate->m_pIDisplay, //AEE_FONT_BOLD, AEE_FONT_LARGE, buffer, -1, 0, 0, pRect, IDF_ALIGN_LEFT |IDF_ALIGN_MIDDLE | IDF_TEXT_TRANSPARENT ) ;//MIDDLE);//BOTTOM return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_DrawLunar( MyDate* pMyDate, AEERect* pRect ){//to do int retVal = FALSE; return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_DrawWeek( MyDate* pMyDate, AEERect* pRect ) {//to do int retVal = FALSE; AECHAR buffer[10] = {0}; int i = 0; int fonWitdh = pRect->dx / 7 ; char sunday[] = "Su" ; char monday[] = "Mo"; char tuesday[] = "Tu"; char wednesday[] = "We"; char thursday[] = "Th"; char friday[] = "Fr"; char saturday[] = "Sa"; char* pWeek[7] = {sunday,monday,tuesday,wednesday,thursday,friday,saturday}; AEERect rect ; //IDISPLAY_FillRect ( pMyDate->m_pIDisplay, pRect, MAKE_RGB( 100,0,200 ) ); for(i=0;i<7;i++) { SETAEERECT( &rect, i * fonWitdh + pRect->x, pRect->y, fonWitdh, pRect->dy ) ; STRTOWSTR ( *(pWeek+i),buffer,10); IDISPLAY_DrawText(pMyDate->m_pIDisplay, AEE_FONT_BOLD , buffer, -1, 0, 0, &rect, IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE | IDF_TEXT_TRANSPARENT ); } return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_DrawDaysOfMonth( MyDate* pMyDate, AEERect* pRect, uint16 year, uint16 month, uint16 day ){ int retVal = FALSE; int i = 0 ; int j = 0 ; int count = 0 ; uint16 absYear = pMyDate->m_absoluteDate.m_year ; uint16 absMonth = pMyDate->m_absoluteDate.m_month ; uint16 absDay = pMyDate->m_absoluteDate.m_day ; int weekDay = 0 ; int daysOfMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; const int rowNum = 6 ; const int daysNumWeek = 7 ; const int rowHeight = pRect->dy / rowNum ; const int arrangeWidth = pRect->dx / daysNumWeek ; AEEFont font = AEE_FONT_NORMAL ; boolean flag[31] = { 0 } ; AECHAR buffer[5] = { 0 }; AEERect rect ; weekDay = MyDate_GetWeekDay( pMyDate, year, month, 1 ); if ( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) { if ( 2 == month ) { daysOfMonth[month] ++ ; } } while( count < daysOfMonth[month] ) { for( i = 0; i <= 5; i ++ ) { if ( 0 == i) j = weekDay ; else j = 0 ; for( ; ( j < daysNumWeek ) && ( count < daysOfMonth[month] ); j ++ ) { count ++ ; //Set color of the font if ( 0 == j || 6 == j) { IDISPLAY_SetColor( pMyDate->m_pIDisplay, CLR_USER_TEXT, MAKE_RGB( 180, 0, 0 ) ) ; } //Set font if( EVENT == pMyDate->m_signFlag[count] ) {//Draw event day font = AEE_FONT_BOLD ; } else font = AEE_FONT_LARGE ; //Set rect SETAEERECT( &rect, j * arrangeWidth, i * rowHeight + pRect->y, arrangeWidth, rowHeight ) ; if ( ( year == absYear ) && ( month == absMonth ) ) //&& ( day == absDay ) ) {//Draw absolute date rect if ( absDay == count ) { IDISPLAY_DrawRect( pMyDate->m_pIDisplay, &rect, MAKE_RGB( 200, 0, 0 ), MAKE_RGB( 150, 100, 0 ), IDF_RECT_FILL ) ; } } if ( day == count ) {//Draw move rect IDISPLAY_DrawRect( pMyDate->m_pIDisplay,&rect, MAKE_RGB( 200, 0, 100 ), MAKE_RGB( 150, 100, 0 ), IDF_RECT_FRAME ) ; } //Draw day WWRITELONG( buffer, count ); IDISPLAY_DrawText( pMyDate->m_pIDisplay, font, buffer, -1, 0, 0, &rect, IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE | IDF_TEXT_TRANSPARENT ); IDISPLAY_SetColor( pMyDate->m_pIDisplay, CLR_USER_TEXT, MAKE_RGB( 0, 0, 0 ) ) ; } } } return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_GetWeekDay( MyDate* pMyDate, uint16 year, uint16 month, uint16 day ){ //int retVal = FALSE ; int i = 0 ; int sumDays = 0 ; //int daysOfMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; int addDaysOfAYear[13] = { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 } ; int additionalDays = 0 ; int weekDay = 0 ; //1949/10/2 if ( year >= 1949 ) { for( i = 1949; i < year; i ++ ) { if( ( i % 4 == 0 && i % 100 != 0 ) || ( i % 400 == 0 ) ) { //if this year is leap year additionalDays ++ ; } } if( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) { //if ( ( month = 2 && day > 28 ) || ( month > 3 ) ) if( month > 2 ) { additionalDays ++ ; } } //Calculate the sumDays sumDays = ( year - 1949 ) * 365 + addDaysOfAYear[month] + day + additionalDays - addDaysOfAYear[10] - 2 ; weekDay = sumDays % 7 ; } else { for( i = 1949; i > year; i -- ) { if( ( i % 4 == 0 && i % 100 != 0 ) || ( i % 400 == 0 ) ) { //if this year is leap year additionalDays ++ ; } } if( ( i % 4 == 0 && i % 100 != 0 ) || ( i % 400 == 0 ) ) { //if this year is leap year if( month <=2 ) additionalDays ++ ; } //Calculate the sumDays //to do sumDays = ( 1949 - year ) * 365 + addDaysOfAYear[10] + 2 + additionalDays - addDaysOfAYear[month] - day ; weekDay = 7-(sumDays % 7) ; } //Calculate the weekDay //weekDay = sumDays % 7 ; if ( weekDay < 0 ) { weekDay = weekDay + 7; } return weekDay; //return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_SetBackground( MyDate* pMyDate, const char * pszImageFile ){ int retVal = FALSE; IImage *pImage ; //pImage = ISHELL_LoadResImage( pMyDate->a.m_pIShell, IMAGE_RES_FILE, IDI_OBJECT_5001 ); //IIMAGE_Draw(pImage, 0,0); pImage=ISHELL_LoadImage( pMyDate->m_pIShell,pszImageFile ); //pImage=ISHELL_LoadImage(pMyDate->m_pIShell,"feng.jpg"); //pImage=ISHELL_LoadImage(pMyDate->m_pIShell,"nv.jpg"); //IIMAGE_GetInfo(pMe->m_pimage,&imageInfo); //IIMAGE_SetDrawSize ( pImage, 100, 120) ; IIMAGE_Draw( pImage, 0, 0 ) ; //IGRAPHICS_Update(pMe->m_pGraph); NO NO //IDISPLAY_Update(pMyDate->m_pIDisplay); IIMAGE_Release( pImage ) ; return retVal;}//////////////////////////////////////////////////////////////////////////int MyDate_SignEvtOfAMonth( MyDate* pMyDate, uint16 year, uint16 month, boolean flag[] ) { int retVal = FALSE; int i = 0 ; int j = 0 ; //char year[5] = { 0 } ; //char month[3] = { 0 } ; AECHAR day[5] = { 0 } ; char temp[5] = { 0 } ; AECHAR buffer[5] = { 0 } ; AECHAR buffer2[5] = { 0 } ; ScheNote scheNote ; DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, 0 ) ; for( i = 1; i<= pMyDate->m_pDataSorage->m_numOfNote; i ++ ) { //DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, i ) ; if ( ( scheNote.year == year ) && ( scheNote.month == month ) ) { flag[scheNote.day] = EVENT ; } DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, i ) ; } return retVal;}////////////////////////////////////////////////////////////////////////////int MyDate_SignEvtOfAMonth( MyDate* pMyDate, uint16 year, uint16 month, boolean flag[] ) //{// int retVal = FALSE;// int i = 0 ;// int j = 0 ;// //char year[5] = { 0 } ;// //char month[3] = { 0 } ;// AECHAR day[5] = { 0 } ;// char temp[5] = { 0 } ;// AECHAR buffer[5] = { 0 } ;// AECHAR buffer2[5] = { 0 } ;// ScheNote scheNote ;//// DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, 0 ) ;//// for( i = 1; i< pMyDate->m_pDataSorage->m_numOfNote; i ++ )// {// //DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, i ) ;// STRTOWSTR( scheNote.date, buffer, sizeof( buffer ) ) ; // WWRITELONG( buffer2, year ) ; // WSTRTOSTR( buffer, temp, sizeof( temp ) ) ;// // if ( 0 == WSTRCMP( buffer2, buffer ) )// {// STRTOWSTR( scheNote.date + 4, buffer, 5 ) ; // WWRITELONG( buffer2, month ) ; // WSTRTOSTR( buffer2, temp, sizeof( temp ) ) ;// if ( 0 == WSTRCMP( buffer2, buffer ) ) // {// STRTOWSTR( scheNote.date + 6, buffer, 5 ) ; // WSTRTOSTR( buffer, temp, sizeof( temp ) ) ;// //WWRITELONG( buffer2, day ) ;// for( j = 1; j <= 31; j ++)// {// WWRITELONG( day, j ) ;// if ( 0 == WSTRCMP( day, buffer ) )// {// flag[j] = EVENT ;// }// }// }// // }// DataStorage_ReadFile( pMyDate->m_pDataSorage, &scheNote, i ) ;//// }// // return retVal;//}/*==============================================================================================================//////////////////////////////////////////////////////////////////////////////////////////////////////////////////MyDate Control function definition End///////////////////////////////////////////////////////////////////////////////////////////////////////////////==============================================================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -