📄 uianimat.c
字号:
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : STATUS guiAnimation_Stop() */
/* Purpose : Stop Animation */
/* Input : */
/* pAnimation : Address of Animation */
/* Output : */
/* void : */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
DLL_EXP(STATUS) guiAnimation_Stop(HNDL hAnimation)
{
TGuiAnimation *pAnimation;
if(hAnimation == 0)
return STATUS_ERR;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation == 0)
{
guiExitWCS() ;
return STATUS_ERR;
}
if(pAnimation->pTimer == 0)
{
guiExitWCS() ;
return STATUS_ERR;
}
gui_freeTimer(pAnimation->pTimer);
pAnimation->pTimer = 0;
guiExitWCS() ;
return STATUS_OK;
}
/*=====================================================================*/
/********************************************************************/
/* */
/* Function name : int _guiAnimation_Action() */
/* Purpose : Deal message */
/* Input : */
/* Event : Address of Event */
/* Output : */
/* void : */
/* Create : 15/Dec/2001 */
/* Done : 15/Dec/2001 */
/* Author : Cangers */
/* History : */
/* */
/********************************************************************/
static int _guiAnimation_Action(HNDL hAnimation, WORD Pen_Type, WORD x , WORD y)
{
BOOL bIfProcess;
TGuiAnimation *pAnimation;
TGuiMessage message;
if(hAnimation == 0)
return FALSE;
guiEnterWCS() ;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return 0;
}
bIfProcess = TRUE;
switch (Pen_Type)
{
// case TIMER_TIMEOUT:
// _guiAnimation_Process(hAnimation);
// break;
case PENUP:
message.elseInfo = 0;
message.handle = hAnimation;
message.messageType = BITMAP_CLICK;
guiEnqueue(gpTopWindow->messageQueue,&message);
guiPenSound();
break;
default:
bIfProcess = FALSE;
break;
}
if(bIfProcess == TRUE)
{
guiExitWCS() ;
return 1L;
}
else
{
guiExitWCS() ;
return 0L;
}
}
/**************************************************************************************/
static BOOL _DrawBmpByStyle(HNDL hAnimation,const BYTE* pBitmap, WORD ShowStyle )
{
TGuiAnimation *pAnimation;
unsigned short i,j,p,q,h,k,n,m;
unsigned int width,height;
unsigned short sFlag,sx,sy;
if(hAnimation == 0)
return FALSE;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pAnimation->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return 0;
}
if(!pBitmap) return 0;
// if(2 != guiGetImageMode( pBitmap))
// return 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);
sFlag = (width>=height)?1:0;
switch(ShowStyle)
{
default:
case STATIC_SHOW:
guiPutImage(hAnimation, sx, sy, sx+width,sy+height,pBitmap);
break;
case LTOR_SHOW:
// guiClearBlock(hAnimation, 0, 0, pAnimation->base.right-pAnimation->base.left, pAnimation->base.bottom-pAnimation->base.top, GUI_WHITE, REPLACE_STYLE);
for(i=0;i<width;i++)
{
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
for(j=0;j<height;j++)
{
_ShowOnePixelByCoor(hAnimation, i,j, pBitmap);
}
}
break;
case RTOL_SHOW:
//guiClearBlock(hAnimation, 0, 0, pAnimation->base.right-pAnimation->base.left, pAnimation->base.bottom-pAnimation->base.top, GUI_WHITE, REPLACE_STYLE);
for(i=((unsigned short)width);i>0;i--)
{
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
for(j=0;j<height-1;j++)
{
if(!_ShowOnePixelByCoor(hAnimation, i,j, pBitmap))
break;
}
}
break;
case BTOC_SHOW:
i = 0;j = 0;
p = width;q=height;
while(1)
{
if(i == width/2 && j==height/2 && p==width/2 && q==height/2)
break;
for(m=j;m<=q;m++)
{
n = i;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
n = p;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
}
for(n=i;n<=p;n++)
{
m = j;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
m = q;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
}
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
if(i<width/2)
i++;
else
i = width/2;
if(j<height/2)
j++;
else
j = height/2;
if(q>height/2) q--;
else
q =height/2;
if(p>width/2) p--;
else
p =width/2;
}
break;
case CTOB_SHOW:
i = width/2;j = height/2;
p = width/2;q = height/2;
while(1)
{
if(i == width && j==height && p==0 && q==0)
break;
for(m=q;m<=j;m++)
{
n = i;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
n = p;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
}
for(n=p;n<=i;n++)
{
m = j;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
m = q;
_ShowOnePixelByCoor(hAnimation,n,m, pBitmap);
}
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
if(i<width)
i++;
else
i =width;
if(j<height)
j++;
else
j =height;
if(q>0) q--;
else
q =0;
if(p>0) p--;
else
p =0;
}
break;
case TTOB_SHOW:
for(j=0;j<height;j++)
{
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
for(i=0;i<width;i++)
{
_ShowOnePixelByCoor(hAnimation, i,j, pBitmap);
}
}
break;
case BTOT_SHOW:
for(j=(unsigned short)height-1;j>0;j--)
{
for(h=0;h<DRAWPIXEL_LAST_TIME;h++)
{
for(k=0;k<1000;k++);
}
for(i=(unsigned short)width-1;i>0;i--)
{
_ShowOnePixelByCoor(hAnimation, i,j, pBitmap);
}
}
break;
}
return 1;
}
static int _GetBmpPixel(unsigned short x,unsigned short y,const BYTE* pBitmap)
{
char cBy;
int pixel;
unsigned int width;
unsigned int height;
unsigned int Vwidth;
unsigned int xByte;
unsigned int xplace;
if(!pBitmap) return -1;
width = guiGetImageWidth((BYTE*) pBitmap);
height = guiGetImageHeight( pBitmap);
if(x<0 || x>width || y<0 || y>height)
return -1;
Vwidth =( width%4)?((width/4+1)*4):width;
xByte = (x + y*Vwidth)/4;
xplace = ( x + y*Vwidth)%4;
cBy = pBitmap[12 + xByte];
pixel = cBy&BMPMASK[xplace];
return pixel>>((3-xplace)*2) ;
}
static int _ShowOnePixelByCoor(HNDL hAnimation,WORD x,WORD y,const BYTE* pBitmap)
{
TGuiAnimation *pAnimation;
int pixel ;
WORD width,height;
WORD sx,sy;
if(hAnimation == 0)
return FALSE;
pAnimation = ( TGuiAnimation *)hAnimation;
if(pBitmap == NULL) return 0;
pixel = _GetBmpPixel( x, y, pBitmap);
if(pixel == -1) return 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);
guiDrawPixel(hAnimation,sx+x, sy+y, pixel);
return 1;
}
/*=====================================================================*/
/*=====================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -