📄 uianimat.c
字号:
/*-----------------------------------------------------------------------------
VTech Electronics Ltd. Copyright (c) 2000
File : Animation.c
Author : D.H. Shi
Created : 06-12-2000
Version : 1.00
Model : RealLife 48700
Module : RLS source file
Purpose : Display movie!
History :
----------------------------------------------------------------------------*/
#include "uiAnimat.h"
static const unsigned char BMPMASK[] = {0xC0,0x30,0x0C,0x03};
static BOOL _guiAnimation_Delete(HNDL hAnimation);
static STATUS _guiAnimation_Process(HNDL hAnimation);
static int _guiAnimation_Action(HNDL hAnimation , WORD Pen_Type, WORD x , WORD y);
static int _ShowOnePixelByCoor(HNDL hAnimation,WORD x,WORD y,const BYTE* pBitmap);
static BOOL _DrawBmpByStyle(HNDL hAnimation,const BYTE* pBitmap, WORD ShowStyle );
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : HNDL guiAnimation_Create() */
/* Purpose : Create Animation */
/* Speed : Alternation between display two bitmaps. */
/* Unit: ms */
/* frmNum : Frame number in every cycle display, >=0 */
/* rptNum : Repeat number.0:infinite, 1:once, 2:twice... */
/* pBitmaps : Bitmaps. */
/* Output : */
/* SUCCESS : HNDL */
/* FAIL : NULL */
/* Remarks : Please make sure this object is in its parent */
/* form. */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
DLL_EXP(HNDL) guiAnimation_Create(WORD left,WORD top,WORD right,WORD bottom,
WORD Speed, WORD frmNum, WORD rptNum,unsigned int *pBitmaps,WORD style)
{
TGuiAnimation *pAnimation;
guiEnterWCS() ;
pAnimation = (TGuiAnimation *)kernelMalloc(sizeof(TGuiAnimation)+2);
if(pAnimation == NULL)
{
guiExitWCS() ;
return NULL;
}
memset(pAnimation,0,sizeof(TGuiAnimation)+2);
pAnimation->base.handle = (HNDL)pAnimation;
pAnimation->base.actionFun = (PF_ACTION )_guiAnimation_Action;
pAnimation->base.delFun = (PF_DELETE)_guiAnimation_Delete;
pAnimation->base.showFun = (PF_SHOW)_guiAnimation_Process;
pAnimation->base.left = left;
pAnimation->base.top = top;
pAnimation->base.right = right;
pAnimation->base.bottom = bottom;
pAnimation->base.container = 0;
pAnimation->base.vportHandle = 0;
pAnimation->base.type = CONTROL_BITMAP;
pAnimation->base.checkFlag = GUI_CONTROL_CHECK_FLAG;
pAnimation->base.font = GUI_DEFAULT_FONT;
pAnimation->base.status = 0;
pAnimation->base.style = style;
pAnimation->pTimer = 0;
pAnimation->Speed = Speed;
pAnimation->rptNum = rptNum;
pAnimation->rptCnt = 0;
pAnimation->frmNum = frmNum;
pAnimation->frmCnt = 0;
if(pAnimation->base.style > 0)
pAnimation->frmNum = 1;
pAnimation->pBitmaps = (unsigned int*)kernelMalloc(sizeof(unsigned int)*pAnimation->frmNum+4);
if(pAnimation->pBitmaps == NULL)
{
kernelFree(pAnimation);
pAnimation = 0;
guiExitWCS() ;
return NULL;
}
memset(pAnimation->pBitmaps,0,sizeof(unsigned int)*pAnimation->frmNum);
if(pBitmaps)
memcpy(pAnimation->pBitmaps,pBitmaps,sizeof(unsigned int)*pAnimation->frmNum);
guiExitWCS() ;
return(pAnimation->base.handle);
}
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : BOOL _guiAnimation_Delete() */
/* Purpose : Free Animation */
/* Input : */
/* void : */
/* Output : HNDL */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
static BOOL _guiAnimation_Delete(HNDL hAnimation)
{
TGuiAnimation *pAnimation;
if (hAnimation == NULL)
return FALSE;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return 0;
}
if(pAnimation->pTimer)
gui_freeTimer((HNDL)pAnimation->pTimer);
kernelFree(pAnimation->pBitmaps);
pAnimation->pBitmaps = 0;
kernelFree(pAnimation);
pAnimation = 0;
guiExitWCS() ;
return TRUE;
}
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : STATUS _guiAnimation_Process() */
/* Purpose : Process Animation display */
/* Input : */
/* pAnimation : Address of Animation */
/* Output : */
/* SUCCESS : HNDL */
/* FAIL : NULL */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
static STATUS _guiAnimation_Process(HNDL hAnimation)
{
TGuiAnimation *pAnimation;
BYTE* pBitmap;
WORD width,height;
WORD sx,sy;
if(hAnimation == NULL)
return STATUS_ERR;
if(!guiControl_IsVisible(hAnimation))
return STATUS_ERR;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation->pTimer == 0 )
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation->frmCnt < pAnimation->frmNum)
{
pBitmap = (BYTE *)(*((unsigned int *)pAnimation->pBitmaps+pAnimation->frmCnt));
if(pBitmap == NULL)
{
guiExitWCS() ;
return STATUS_ERR;
}
}
else if(pAnimation->frmCnt >= pAnimation->frmNum)
{
pAnimation->rptCnt++;
pAnimation->frmCnt = 0;
if(pAnimation->rptNum != 0 && pAnimation->rptCnt>=pAnimation->rptNum)
{
if(pAnimation->pTimer != 0)
{
gui_freeTimer((HNDL)pAnimation->pTimer);
pAnimation->pTimer = 0;
guiExitWCS() ;
return STATUS_OK;
}
}
pBitmap = (BYTE *)(*((unsigned int *)pAnimation->pBitmaps + pAnimation->frmCnt));
if(pBitmap == NULL)
{
guiExitWCS() ;
return STATUS_ERR;
}
}
if(pAnimation->base.style == 0)
{
width = guiGetImageWidth( pBitmap);
height = guiGetImageHeight( pBitmap);
sx = getAlignCenter(0, pAnimation->base.right-pAnimation->base.left, width);
sy = getAlignCenter(0, pAnimation->base.bottom-pAnimation->base.top, height);
guiPutImage(hAnimation, sx, sy, sx+width,sy+height,pBitmap);
}
else
_DrawBmpByStyle(hAnimation,pBitmap, pAnimation->base.style);
pAnimation->frmCnt++;
guiExitWCS() ;
return STATUS_OK;
}
/*=====================================================================*/
DLL_EXP(STATUS) guiAnimation_TimeOutProcess(HNDL hAnimation,HNDL hTimeOutTimer)
{
TGuiAnimation *pAnimation;
if(hAnimation == 0 || hTimeOutTimer == 0)
return STATUS_ERR;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation == 0 || pAnimation->pTimer == 0)
{
guiExitWCS() ;
return STATUS_ERR;
}
if((HNDL)pAnimation->pTimer != hTimeOutTimer)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(STATUS_OK == _guiAnimation_Process(hAnimation))
{
guiExitWCS() ;
return STATUS_OK;
}
guiExitWCS() ;
return STATUS_ERR;
}
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : STATUS guiAnimation_Start() */
/* Purpose : Start Animation */
/* Input : */
/* pAnimation : Address of Animation */
/* Output : */
/* SUCCESS : HNDL */
/* FAIL : NULL */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
DLL_EXP(STATUS) guiAnimation_Start(HNDL hAnimation)
{
TGuiAnimation *pAnimation;
//BYTE *pBitmap;
HNDL hTEMP,hTEMP0;
if(hAnimation == 0)
return STATUS_ERR;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation->pTimer != 0)
{
guiEnterWCS() ;
return STATUS_OK; //Aready started.
}
if(pAnimation->pBitmaps == NULL)
{
guiEnterWCS() ;
return STATUS_ERR;
}
if(pAnimation->base.container)
{
hTEMP = pAnimation->base.container;
hTEMP0 = hTEMP;
}
else //if(pAnimation->base.vportHandle)
{
hTEMP = pAnimation->base.vportHandle;
hTEMP0 = ((TViewport *)hTEMP)->base.container;
}
hTEMP = (HNDL)((TWindow *)hTEMP0)->parent;
if(hTEMP !=0)
hTEMP0 = hTEMP;
pAnimation->pTimer = gui_allocateTimer() ;
gui_startTimer(pAnimation->pTimer, 0,pAnimation->Speed, hTEMP0) ;//
if(pAnimation->pTimer == 0)
{
guiEnterWCS() ;
return STATUS_ERR;
}
if(pAnimation->frmCnt >= pAnimation->frmNum)
pAnimation->frmCnt = 0;
//pAnimation->rptCnt = 0;
//pBitmap = (BYTE *)(*((unsigned int *)pAnimation->pBitmaps + pAnimation->frmCnt));
//guiPutImage(hAnimation, 0, 0, pAnimation->base.right-pAnimation->base.left,
// pAnimation->base.bottom-pAnimation->base.top,pBitmap);
//pAnimation->frmCnt++;
guiExitWCS() ;
return STATUS_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -