slideshow.c

来自「Brew Slideshow Application Source Code」· C语言 代码 · 共 103 行

C
103
字号
#include "slideshow.h"
#include "slideshow.bid"int AEEClsCreateInstance(AEECLSID ClsId, IShell * pIShell, IModule * po, void ** ppObj){   *ppObj = NULL;		   if(ClsId == AEECLSID_SLIDESHOW_BID )
   {	  if(AEEApplet_New(sizeof(myapp_t), ClsId, pIShell,po,(IApplet**)ppObj,		 (AEEHANDLER)Slideshow_HandleEvent, (PFNFREEAPPDATA)Slideshow_CleanUp)		 == TRUE)	  {		 return (AEE_SUCCESS);	  }   }	
   return (EFAILED);}static boolean Slideshow_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam){ 	myapp_t * pApp = (myapp_t*)pi;	AEEApplet * pMe = &pApp->a;	switch (eCode) 	{	case EVT_APP_START: 

		//get info about the handset (resolution, etc.)
		ISHELL_GetDeviceInfo(pMe->m_pIShell, &pApp->di);

		 //clear whole screen
        IDISPLAY_ClearScreen (pMe->m_pIDisplay); 

		//load our images
		pApp->pImages[0] = ISHELL_LoadImage(pMe->m_pIShell, "circle1.bmp");
		pApp->pImages[1] = ISHELL_LoadImage(pMe->m_pIShell, "square1.bmp");

		pApp->nImage = 0;

		//draw the first image
		IIMAGE_Draw(pApp->pImages[pApp->nImage], 0, 0);
		IDISPLAY_Update(pMe->m_pIDisplay);

		//Set the timer...let's go!
		ISHELL_SetTimer(pApp->a.m_pIShell, DISPLAY_DELAY, (PFNNOTIFY)Slideshow_Timer, pApp);

		return(TRUE);		break;			case EVT_APP_SUSPEND:

		//If we've paused the applet for some reason, kill the timer
		ISHELL_CancelTimer(pApp->a.m_pIShell, NULL, NULL);
		return(TRUE);		break;			case EVT_APP_RESUME:

		//When the applet is re-activated, redraw and start the timer
		IDISPLAY_ClearScreen (pMe->m_pIDisplay); 
		IIMAGE_Draw(pApp->pImages[pApp->nImage], 0, 0);
		IDISPLAY_Update(pMe->m_pIDisplay);
		ISHELL_SetTimer(pApp->a.m_pIShell, DISPLAY_DELAY, (PFNNOTIFY)Slideshow_Timer, pApp);

		return(TRUE);		break;   }   return FALSE;}
void Slideshow_CleanUp(myapp_t* pApp)
{
	//delete our loaded BMPs

	int i;

	for (i = 0; i < MAX_IMAGES; i++)
	{
		IIMAGE_Release(pApp->pImages[i]);
	}
}
void Slideshow_Timer(myapp_t * pApp)
{
	//Toggle between the two images, draw image, and start
	//timer again for next image.

	AEEApplet * pMe = &pApp->a;

	++pApp->nImage;
	
	if (pApp->nImage >= MAX_IMAGES)
		pApp->nImage = 0;


	IIMAGE_Draw(pApp->pImages[pApp->nImage], 0, 0);
	IDISPLAY_Update(pMe->m_pIDisplay);

	ISHELL_SetTimer(pApp->a.m_pIShell, DISPLAY_DELAY, (PFNNOTIFY)Slideshow_Timer, pApp);
}

⌨️ 快捷键说明

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