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

📄 schedatepage.c

📁 expense traker ,the study material
💻 C
📖 第 1 页 / 共 2 页
字号:
/********************************************************************	created:	2007/04/22	created:	22:4:2007   11:25	filename: 	ScheDatePage.c	file path:	e:\brew program\schedule	file base:	ScheDatePage	file ext:	c	author:		fhong		purpose:	*********************************************************************/#include "ScheDatePage.h "/*===============================================================================    Function    Definitions=============================================================================== */////////////////////////////////////////////////////////////////////////////Public function declaration //////////////////////////////////////////////////////////////////////////extern int	ScheDatePage_Init(IShell* pIShell,PageStateMgr* pPageStateMgr,BasePage** ppBasePage,uint32 nPageID){		int					retVal			= SUCCESS;			// The return value.	ScheDatePage*		pScheDatePage	= NULL;				// The page object.		// Input check.	//if( (NULL == pIShell) || (NULL == ppBasePage) ){}	// Create base class	retVal	= BasePage_Init( pIShell, pPageStateMgr, (BasePage**)&pScheDatePage, sizeof(ScheDatePage), nPageID );	//if( (SUCCESS != retVal) || (NULL == pScheDatePage) ){}		// Initializing m_pMyDate	MyDate_Init( pScheDatePage, &pScheDatePage->m_pMyDate  );	// Initializa local variable.	pScheDatePage->m_basePage.m_pfnPageDraw		= ScheDatePage_Draw;	pScheDatePage->m_basePage.m_pfnHandleEvent	= ScheDatePage_HandleEvent;	pScheDatePage->m_basePage.m_pfnRelease		= ScheDatePage_Release;	if( SUCCESS != retVal )	{		if( NULL != pScheDatePage )		{			BasePage_Release( (BasePage*)pScheDatePage );		}		pScheDatePage	= NULL;	}	*ppBasePage	= (BasePage*)pScheDatePage;	return retVal;}//////////////////////////////////////////////////////////////////////////extern int	ScheDatePage_HandleEvent(BasePage*	pBasePage,AEEEvent eCode,uint16 wParam,uint32	dwParam){	int					retVal			= SUCCESS;			// The return value.	// Input check.	//if( NULL == pBasePage ){}	ScheDatePage*		pScheDatePage	= (ScheDatePage*)pBasePage;	// The ScheDatePage object.		//AEERect				rect ;	switch( eCode )	{		case EVT_KEY:			switch(wParam)			{			    case AVK_SOFT1:					MEMSET( &pScheDatePage->m_basePage.m_pPageStateMgr->m_selDate,0,sizeof(pScheDatePage->m_basePage.m_pPageStateMgr->m_selDate) );					retVal = PageStateMgr_OpenNextPage( pScheDatePage->m_basePage.m_pPageStateMgr, SCHE_MENU_PAGE);						 break;                case AVK_SOFT2:					PageStateMgr_CloseCurrentPage( pScheDatePage->m_basePage.m_pPageStateMgr ) ;                    return NO_PICTURE ; 					//retVal = ISHELL_CloseApplet( pScheDatePage->m_basePage.m_pIShell, FALSE );					 break;				case AVK_SELECT:					 //to do										{						retVal = GetCursorDate(pScheDatePage);						retVal = PageStateMgr_OpenNextPage( pScheDatePage->m_basePage.m_pPageStateMgr, SCHE_VIEW_EVT_PAGE);											}					break; 				case AVK_1:					MyDate_GetWeekDay( pScheDatePage->m_pMyDate, 1940, 1, 6 ) ;			    default:					MyDate_HandleEvent( pScheDatePage->m_pMyDate, eCode, wParam, dwParam ) ;				//	SETAEERECT( &rect, 0, 0, 0, 0 ) ;					BasePage_BottomTip( &pScheDatePage->m_basePage, NULL, OPTION_BACK, 0 );                     break;			 }			 break;		default:					break;	}	return retVal;}//////////////////////////////////////////////////////////////////////////extern int	ScheDatePage_Draw(BasePage* pBasePage){	int					retVal			= SUCCESS;					// The return value.	// Input check.	//if( NULL == pBasePage )		{}		ScheDatePage*		pScheDatePage	= (ScheDatePage*)pBasePage; // The page object.		AEERect				rect;	JulianType			rJulianDate		= { 0 } ;						rect.x=0;						rect.y=14;						rect.dx=pScheDatePage->m_basePage.m_DeviceInfo.cxScreen;                  						rect.dy=pScheDatePage->m_basePage.m_DeviceInfo.cyScreen-25; 	         							pScheDatePage->m_basePage.m_backRGB		= MAKE_RGB( 255, 255, 255 ) ; 	pScheDatePage->m_basePage.m_selBackRGB	= MAKE_RGB( 50, 50, 50 ) ; 	IDISPLAY_ClearScreen( pScheDatePage->m_basePage.m_pIDisplay );		MyDate_Draw( pScheDatePage->m_pMyDate, &rect, NULL );	BasePage_BottomTip( &pScheDatePage->m_basePage, NULL, OPTION_BACK, 0 );		return retVal;	}//////////////////////////////////////////////////////////////////////////extern void	ScheDatePage_Release(BasePage* pBasePage){	ScheDatePage*		pScheDatePage	= (ScheDatePage*)pBasePage;			if ( NULL == pScheDatePage )	{		return ;	}	else	{		MyDate_Release( pScheDatePage->m_pMyDate ) ;	}	return ;}///////////////////////////////////////////////////////////////////////////*===============================================================================Private function definition=============================================================================== *///////////////////////////////////////////////////////////////////////////static	int		GetCursorDate(ScheDatePage *pMe){	int				retVal		= SUCCESS;		Date			date ;		char			strDate[10]	= {0};	AECHAR			dateBuffer[10]	= {0};	AECHAR			buffer[10]	= {0};	AECHAR			ch[2]		= {'0','\0'};	MyDate_GetCursorDate( pMe->m_pMyDate, &date ) ;	pMe->m_basePage.m_pPageStateMgr->m_selDate.m_year	= date.m_year ;	pMe->m_basePage.m_pPageStateMgr->m_selDate.m_month	= date.m_month ;	pMe->m_basePage.m_pPageStateMgr->m_selDate.m_day	= date.m_day ;	return  retVal;}///////////////////////////////////////////////////////////////////////////*===========================================================================================================/////////////////////////////////////////////////////////////////////////////////////////////////////////////// MyDate Control function definition/////////////////////////////////////////////////////////////////////////////////////////////////////////////============================================================================================================*/////////////////////////////////////////////////////////////////////////////Public function difinition//////////////////////////////////////////////////////////////////////////int		MyDate_Init( ScheDatePage* pMe, MyDate** ppMyDate  ){	int				retVal	=	FALSE;		// Input check	MyDate*			pMyDate	=	NULL;	JulianType		rJulianDate ;		// Malloc the memory for pMyDate	pMyDate	=  ( MyDate* )MALLOC( sizeof( MyDate ) );		// Initializing DeviceInfo	pMyDate->m_DeviceInfo	= pMe->m_basePage.m_DeviceInfo;	// Initializing IShell	pMyDate->m_pIShell		= pMe->m_basePage.m_pIShell;  	// Initializing IDisplay	pMyDate->m_pIDisplay	= pMe->m_basePage.m_pIDisplay ;	//retVal		=	ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_DISPLAY, ( void** )&pMyDate->m_pIDisplay );	GETJULIANDATE( 0, &rJulianDate ) ;	// Initializing m_absoluteDate and m_cursorDate	MyDate_SetDate( pMyDate, rJulianDate.wYear, rJulianDate.wMonth, rJulianDate.wDay ) ;	//MyDate_SetDate( pMyDate, rJulianDate.wYear, rJulianDate.wMonth, rJulianDate.wDay ) ;	DataStorage_Init( pMyDate->m_pIShell, &pMyDate->m_pDataSorage ) ;		*ppMyDate	=	pMyDate;	return		retVal;}//////////////////////////////////////////////////////////////////////////int		MyDate_Draw( MyDate* pMyDate, AEERect* pRect, IImage* pImage ){	int			retVal		=	FALSE;		uint16		year		=	pMyDate->m_cursorDate.m_year ;	uint16		month		=	pMyDate->m_cursorDate.m_month ;	uint16		day			=	pMyDate->m_cursorDate.m_day ;	AEERect		rect		=	{0};	IDISPLAY_ClearScreen( pMyDate->m_pIDisplay );		//Draw year and month	SETAEERECT( &rect, 0, 0, 128, 20 );	MyDate_DrawYearMonth( pMyDate, &rect, year, month ) ;//	//Draw lunar calendar//	SETAEERECT( &rect, pRect->x, pRect->y, pRect->dx, pRect->dy ) ;//	MyDate_DrawLunar( pMyDate, &rect ) ;	//Draw week	SETAEERECT( &rect, 0, 20, 128, 20 );	MyDate_DrawWeek( pMyDate, &rect ) ;		//Draw horizontal line	IDISPLAY_DrawHLine( pMyDate->m_pIDisplay, 0, 35, 128 ) ; 	//Draw all days of the specific month		SETAEERECT( &rect, 0, 40, 128, 100 );	MyDate_SignEvtOfAMonth(  pMyDate,  ( uint16 )year,  ( uint16 )month, pMyDate->m_signFlag ) ;	MyDate_DrawDaysOfMonth( pMyDate, &rect, year, month, day );	MEMSET( pMyDate->m_signFlag, 0, sizeof( pMyDate->m_signFlag ) ) ;		IDISPLAY_Update( pMyDate->m_pIDisplay );	return		retVal;}//////////////////////////////////////////////////////////////////////////int		MyDate_HandleEvent( MyDate* pMyDate, AEEEvent eCode, uint16 wParam, uint32 dwParam ){	int			retVal			=	FALSE;	int			daysOfMonth[13]	=	{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ;	int			year			=	pMyDate->m_cursorDate.m_year ;	int			month			=	pMyDate->m_cursorDate.m_month ;	int			day				=	pMyDate->m_cursorDate.m_day ;	if ( EVT_KEY == eCode )	{		switch( wParam )		{			case AVK_UP:			case AVK_2:				day -= 7 ; 				break;			case AVK_DOWN:			case AVK_8:				day += 7 ;															break;			case AVK_LEFT:			case AVK_4:                day -= 1 ;				break;			case AVK_RIGHT:			case AVK_6:                day += 1 ;				break;					case AVK_STAR:                month -= 1 ;				if ( 0 == month )				{					month = 12 ;					year -- ;				}				if ( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) 				{					if ( 2 == month ) 					{						daysOfMonth[month] ++ ;					}				}				if ( day > daysOfMonth[month] ) 				{					day = daysOfMonth[month];				}				break;			case AVK_POUND:                month += 1 ;				if ( month > 12 )				{					month = 1 ;					year ++ ;				}				if ( ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ) 				{					if ( 2 == month ) 					{						daysOfMonth[month] ++ ;					}				}				if ( day > daysOfMonth[month] ) 				{					day = daysOfMonth[month];				}				break;			case AVK_SOFT2:                				break;			default:												break;		}		}	MyDate_Update( pMyDate, year, month, day ) ;	MyDate_Draw( pMyDate, NULL, NULL ) ;	return		retVal;}//////////////////////////////////////////////////////////////////////////int		MyDate_GetCursorDate( MyDate* pMyDate, Date* pDate ){	int			retVal				=	FALSE ;	//Input check	if ( NULL != pMyDate && NULL != pDate ) 	{		pDate->m_year	= pMyDate->m_cursorDate.m_year ;		pDate->m_month	= pMyDate->m_cursorDate.m_month ;		pDate->m_day	= pMyDate->m_cursorDate.m_day ;		return   ( TRUE );	}	return		retVal;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////int		MyDate_SetDate( MyDate* pMyDate, uint16 year, uint16 month, uint16 day ){	//to do	int			retVal	=	FALSE;	int			daysOfMonth[13]		=	{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ;	//Check iput date		if ( year <= 0 )	{//Check year		return   retVal = FALSE ;	}	else	{		//Check month		if ( month <= 0 || month > 12 )		{			return   retVal = FALSE ;		}		else		{			//Check day			if ( day < 0 || day > daysOfMonth[month] )			{				return   retVal = FALSE ;			}			else			{				//Set absolute Date				pMyDate->m_absoluteDate.m_year		= year ;				pMyDate->m_absoluteDate.m_month		= month ;				pMyDate->m_absoluteDate.m_day		= day ;				//Set Date				pMyDate->m_cursorDate.m_year		= year ;				pMyDate->m_cursorDate.m_month		= month ;				pMyDate->m_cursorDate.m_day			= day ;					return		retVal = TRUE ;			}		}	}	return		retVal;}//////////////////////////////////////////////////////////////////////////int    MyDate_Release( MyDate* pMyDate ){//to do	int			retVal	 =	FALSE;	pMyDate->m_pIDisplay = NULL ;	pMyDate->m_pIShell   = NULL ;	DataStorage_Release( pMyDate->m_pDataSorage ) ;	FREEIF( pMyDate );		return		retVal;}

⌨️ 快捷键说明

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