📄 schedule.c
字号:
/**
* File Name : Schedule.c
* Created : 07/04/11
* Author : ZhongNingLin@neusoft.com
* Model : 05YOP
* Description : [[CN]] 此文件的职责是: [[CN]]
**/
#include "schedule.h"
#include "Calendar.h"
extern ScheDB_InitClassData(ScheDB** ppObj,Schedule* pAee);
extern SEventContent_InitNodeHead(NodeHead **nodeHead);
extern ScheEvtDB_FreeClassData(Schedule* pMe);
extern IWindow* CSelectDWin_New(Schedule * pOwner);
extern IWindow* CExamineEventWin_New(Schedule * pOwner);
extern IWindow* CCEventWin_New(Schedule * pOwner);
extern IWindow* CWeekWin_New(Schedule * pOwner);
extern IWindow* CEventTWin_New(Schedule * pOwner);
extern void SEventContent_FreeList(Schedule* pme);
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
#if defined(AEE_STATIC)
int Schedule_CreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj);
static int Schedule_Load(IShell *ps, void * pHelpers, IModule ** pMod);
//
// Constant Data...
//
static const AEEAppInfo gaiMediaPlayerApp = {
AEECLSID_SCHEDULE,
MEDIAPLAYER_RES_FILE,
IDS_TITLE,IDB_TNAIL,
IDB_TNAIL,0,0,0};
/*===========================================================================
PUBLIC FUNCTION DECLARATIONS
===========================================================================*/
PFNMODENTRY Schedule_GetModInfo(IShell * ps,
AEECLSID ** ppClasses,
AEEAppInfo ** pApps,
uint16 * pnApps,
uint16 * pwMinPriv)
{
*pApps = (AEEAppInfo *)&gaiMediaPlayerApp;
*pnApps = 1;
return((PFNMODENTRY)Schedule_Load);
}
/**************************************************************************
* Function Name : Schedule_Load
* Description : malloc resource.
* Input Parameters : int
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
static int Schedule_Load(IShell *ps, void * pHelpers, IModule ** pMod)
{
return(
AEEStaticMod_New((int16)(sizeof(AEEMod)),
ps,pHelpers,pMod,Schedule_CreateInstance,NULL));
}
#endif //AEE_STATIC
#if defined(AEE_STATIC)
int Schedule_CreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
#else
int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
#endif
{
*ppObj = NULL;
if( ClsId == AEECLSID_SCHEDULE )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(Schedule),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)Schedule_HandleEvent,
(PFNFREEAPPDATA)Schedule_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(Schedule_InitAppData((IApplet*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}// ClsId == AEECLSID_MEDIAPLAYER
return(EFAILED);
}
/**************************************************************************
* Function Name : Schedule_HandleEvent
* Description : FUNCTION SampleAppWizard_HandleEvent
* Input Parameters : Schedule* , AEEEvent , uint16 , uint32
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
static boolean Schedule_HandleEvent(Schedule* pme, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START: // Process Start event
{
Schedule_DrawSplash(pme);
return TRUE;
}
// App is told it is exiting
case EVT_APP_STOP:
case EVT_APP_SUSPEND:
case EVT_APP_RESUME:
case EVT_APP_MESSAGE:
return(TRUE);
case EVT_KEY: // Process key event
case EVT_COMMAND: // Process menu command event
case EVT_COPYRIGHT_END: // Copyright dialog ended
if (pme->m_pWin)
return IWINDOW_HandleEvent(pme->m_pWin, eCode, wParam, dwParam);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
/**************************************************************************
* Function Name : Schedule_InitAppData
* Description : called when your application is starting up
* Input Parameters : IApplet*
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
boolean Schedule_InitAppData(IApplet* po)
{
Schedule * pMe = (Schedule*)po;
int nAscent, nDescent;
JulianType rJulianDate;
ISHELL_GetDeviceInfo(pMe->a.m_pIShell, &pMe->DeviceInfo);
// initialize the struct
pMe->m_width = pMe->DeviceInfo.cxScreen;
pMe->m_height = pMe->DeviceInfo.cyScreen;
IDISPLAY_GetFontMetrics(pMe->a.m_pIDisplay, AEE_FONT_LARGE, &nAscent, &nDescent);
IDISPLAY_GetFontMetrics(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, &nAscent, &nDescent);
GETJULIANDATE( 0, &rJulianDate );
//ini the date
pMe->m_day = (uint8)rJulianDate.wDay;
pMe->m_month = (uint8)rJulianDate.wMonth;
pMe->m_year = rJulianDate.wYear;
CALLBACK_Init(&pMe->m_cbRedraw, (PFNNOTIFY)Schedule_RedrawNotify, pMe);
pMe->m_pHdrImage = ISHELL_LoadResImage(pMe->a.m_pIShell,SCHEDULE_RES_FILE, IDI_HEARDER);
SETAEERECT( &pMe->m_rectHdr, 0, 0, pMe->m_width, 20 );
pMe->eventType = NULL;
/*数据库分配空间*/
ScheDB_InitClassData(&pMe->m_pScheDB,pMe);
/*链表分配空间*/
SEventContent_InitNodeHead(&pMe->head);
/*initialize the main window*/
pMe->m_pWin =Calendar_New(pMe);// CMainWin_New(pMe);
if (!pMe->m_pWin)
return FALSE;
return TRUE;
}
/**************************************************************************
* Function Name : Schedule_DrawSplash
* Description : Draw the splash screen
* Input Parameters : Schedule*
* Output Parameters: None
* Return Value : None
* Date : 2007/04/11
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
void Schedule_DrawSplash(Schedule * pme)
{
// The following 'If statement' is entered only after the splash timer runs out...
if (pme->m_eActiveWin == APP_MAIN_WIN)
{
Schedule_SetWindow(pme, APP_MAIN_WIN, 0);
//cancle the timer
ISHELL_CancelTimer(pme->a.m_pIShell, (PFNNOTIFY)Schedule_DrawSplash, pme);
return;
}
// Draw the splash screen, set the timer.
// The timer callback calls this function and redraws the main window.
{
IImage * pi = ISHELL_LoadResImage(pme->a.m_pIShell, SCHEDULE_RES_FILE, IDB_LOGO);
if (pi)
{
AEERect rect;
IDISPLAY_ClearScreen(pme->a.m_pIDisplay);
SETAEERECT(&rect, 0, 0, pme->m_width, pme->m_height);
SH_DrawImage(pi, &rect, TRUE);
IDISPLAY_Update(pme->a.m_pIDisplay);
SH_RELEASEIF(pi);
}
// Set main window as active and start the timer.
pme->m_eActiveWin = APP_MAIN_WIN;
ISHELL_SetTimer(pme->a.m_pIShell, MP_SPLASH_TIMER,(PFNNOTIFY)Schedule_DrawSplash, pme);
}
}
// this function is called when your application is exiting
void Schedule_FreeAppData(IApplet* po)
{
Schedule * pme = (Schedule *)po;
SH_RELEASEIF(pme->m_pHdrImage);
Schedule_CancelRedraw(pme);
//ScheDB_EmptyEventDatabase( pme->m_pScheDB);
/*释放数据库*/
ScheEvtDB_FreeClassData(pme);
/*释放链表空间*/
SEventContent_FreeList(pme);
SH_RELEASEWIN(pme->m_pWin);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -