📄 atv.c
字号:
//chinese_msg.lparam=CurWindow;
chinese_msg.lparam=p->currentAtv->extptr1->WndId;//modified by dsa 2002.03.19
SysSendMessage( gLcdOwnerTskId,(&chinese_msg) );
p->currentAtv->extptr1->off=0;
}
PPSMmsg->lparam = (DWORD)p->currentAtv;
p->currentAtv=NULL;
p->lastmsgtype=NONE;
}
}
}
}
}
}
/*****************************************************************
* Function Name: SysInitATVCB
* Param in: void
* Result code: ATVCB *
* Description: Malloc one AtvCB and init it
*****************************************************************/
ATVCB *SysInitATVCB( void )
{
ATVCB *p;
int i;
p=( ATVCB * )SysLmalloc( sizeof ( ATVCB ) );
if( p == NULL )
return NULL;
// longn_qi 2002/01/25 for monitor memory leak
// memdbgprintf( "appeal mem for ATVCB" );
p->top=0;
p->currentAtv=NULL;
p->lastmsgtype=NONE;
for( i=0;i<ATVSTK_LAYER;i++ )
p->stack[ i ]=NULL;
return p;
}
/*****************************************************************
* Function Name: SysFreeATVCB
* Param in: ATVCB *p
* Result code: status
* Description: free all Atv and free all ATVCB
*****************************************************************/
STATUS SysFreeATVCB( ATVCB *p )
{
ATV *start,*info;
int i;
if(p == NULL) return PPSM_OK;
for( i=0;i<ATVSTK_LAYER;i++ )
{
start=p->stack[i];
while( start != NULL )
{
info=start;
start=start->next;
SysLfree(info);
// longn_qi 2002/01/25 for monitor memory leak
// memdbgprintf( "free mem of ATV" );
}
}
SysLfree(p);
// longn_qi 2002/01/25 for monitor memory leak
// memdbgprintf( "free mem of ATVCB" );
return PPSM_OK;
}
/*****************************************************************
* Function Name: SysAdvOpenInputPad
* Param in: PDWORD areaId,DWORD WndId,WORD xPos,WORD yPos,WORD numRow,WORD numCol,
WORD areaWidth,WORD areaHeight,DWORD echoCol,DWORD echoWidth
* Result code: status
* Description: Open an InputPad
*****************************************************************/
STATUS SysAdvOpenInputPad ( PDWORD areaId,DWORD WndId,WORD xPos,WORD yPos,WORD numRow,WORD numCol,WORD areaWidth,WORD areaHeight,
DWORD echoCol,DWORD echoWidth )//PDWORD areaId is added by jinjing 2001/12/24
{
ATVCB *p;
int id;
InPutPad *inputpad,*pad;
ATV *info,*start;
DWORD pGC;
if( areaId == NULL )
return PPSM_ERR_AREA_ID;
/* Get id of the running task */
get_tid(&id);
/* Get pointer to ATVCB of the running task */
p = gSysTcbTbl[id-1].atvcb;
if( p->pad == INPUTPADOPEN )
return PPSM_ERR_INPUT_PAD_OPENED;
p->pad = INPUTPADOPEN;
//if( xPos > LCD_WIDTH - 1 || xPos < 0 ) return PPSM_ERR_INPUT_PAD_X_POS;
//if( yPos > LCD_HEIGHT - 1 || yPos < 0 ) return PPSM_ERR_INPUT_PAD_Y_POS;
//if( xPos + numCol * areaWidth > LCD_WIDTH ) return PPSM_ERR_INPUT_PAD_WIDTH;
//if( xPos + numRow * areaWidth > LCD_HEIGHT ) return PPSM_ERR_INPUT_PAD_WIDTH;
/*PPSM_ERR_INPUT_PAD_WIDTH*/
/*PPSM_ERR_INPUT_PAD_HEIGHT*/
/*PPSM_ERR_INPUT_PAD_X_POS*/
/*PPSM_ERR_INPUT_PAD_Y_POS*/
inputpad=( InPutPad* )SysLcalloc( sizeof( InPutPad ) );
if( inputpad == NULL )
return PPSM_ERR_NO_MEMORY;
inputpad->pbitmap=(WORD *)Lmalloc( numCol*areaWidth*numRow*areaHeight*2);
if( inputpad->pbitmap == NULL )
{
SysLfree( inputpad );
return PPSM_ERR_NO_MEMORY;
}
info=( ATV* )SysLmalloc( sizeof( ATV ) );
if( info == NULL )
{
SysLfree( inputpad->pbitmap );
SysLfree( inputpad );
return PPSM_ERR_NO_MEMORY;
}
inputpad->xPos=xPos;
inputpad->yPos=yPos;
inputpad->numRow=numRow;
inputpad->numCol=numCol;
inputpad->areaWidth=numCol*areaWidth;
inputpad->areaHeight=numRow*areaHeight;
inputpad->echoCol=echoCol;
inputpad->echoWidth=echoWidth;
//inputpad->timerId=timerId;
inputpad->timeroutflag=0;
inputpad->off=0;
inputpad->WndId=WndId;//add by dsa 2002.03.19
inputpad->areaId=( DWORD )info;
start=p->stack[ p->top ];
info->mode=STROKE_MODE;
info->areaId=( DWORD )info;
info->flag=AREA_REENABLE;
info->previous=NULL;
info->next=start;
start->previous=info;
info->type=PAD_AREA;
info->xsrc=inputpad->xPos;
info->ysrc=inputpad->yPos;
info->xdest=inputpad->xPos + inputpad->numCol * inputpad->areaWidth-1;
info->ydest=inputpad->yPos + inputpad->numRow * inputpad->areaHeight-1;
info->wndId=WndId;
info->extptr1=inputpad;
pad=info->extptr1;
start=info;
p->stack[ p->top ]=start;
pGC=GetCurGC( );//2002.1.24
SysSaveRec(pGC,(PIXEL *)inputpad->pbitmap,inputpad->xPos,inputpad->yPos,inputpad->areaWidth,inputpad->areaHeight,0 );//2002.3.15
if( SysCreateTimer( &( (p->stack[p->top])->extptr1->timerId ),800,AtvTimerOutProcess,( InPutPad * )pad,0) == TIMER_ERROR )
{
start=info->next;
if ( start != NULL )
start->previous=NULL;
SysLfree( inputpad );
SysLfree( info );
p->stack[ p->top ]=start;
p->pad = INPUTPADCLOSE;
return PPSM_ERR_INPUT_PAD_OPENED;
}
*areaId=start->areaId;
return PPSM_OK;
}
/*****************************************************************
* Function Name: SysCloseInputPad
* Param in: DWORD areaId
* Result code: status
* Description: Close an InputPad
*****************************************************************/
STATUS SysCloseInputPad ( DWORD areaId )
{
ATVCB *p;
ATV *start,*info;
int id;
InPutPad *inputpad;
DWORD pGC;
/* Get id of the running task */
get_tid(&id);
/* Get pointer to ATVCB of the running task */
p = gSysTcbTbl[id-1].atvcb;
pGC=GetCurGC( );
if( p->pad == INPUTPADCLOSE )
return PPSM_ERR_INPUT_PAD_CLOSED;
p->pad=INPUTPADCLOSE;
start=p->stack[ p->top ];
if( ( info = findId( start,areaId ) ) == NULL || info->extptr2 == NULL )
return PPSM_ERR_AREA_ID;
if( start == info )
{
start=info->next;
if ( start != NULL )
start->previous=NULL;
}
else
{
info->previous->next=info->next;
if( info->next != NULL )
info->previous->next->previous=info->previous;
}
inputpad=info->extptr1;
SysFreeTimer( info->extptr1->timerId );
SysLfree( inputpad->pbitmap );
SysLfree( inputpad );
SysLfree( info );
p->stack[ p->top ]=start;
return PPSM_OK;
}
/*****************************************************************
* Function Name: SysSaveInputPad
* Param in: DWORD areaId
* Result code: status
* Description: Close an InputPad
*****************************************************************/
STATUS SysSaveInputPad ( DWORD areaId )
{
ATVCB *p;
ATV *start,*info;
int id;
InPutPad *inputpad;
DWORD pGC;
/* Get id of the running task */
get_tid(&id);
/* Get pointer to ATVCB of the running task */
p = gSysTcbTbl[id-1].atvcb;
pGC=GetCurGC( );
if( p->pad == INPUTPADCLOSE )
return PPSM_ERR_INPUT_PAD_CLOSED;
start=p->stack[ p->top ];
if( ( info = findId( start,areaId ) ) == NULL )
return PPSM_ERR_AREA_ID;
inputpad=info->extptr1;
SysSaveRec(pGC,(PIXEL *)inputpad->pbitmap,inputpad->xPos,inputpad->yPos,
inputpad->areaWidth,inputpad->areaHeight,0 );
return PPSM_OK;
}
/*****************************************************************
* Function Name: SysClearAndDrawInputPad
* Param in: DWORD areaId
* Result code: status
* Description: Close an InputPad
*****************************************************************/
STATUS SysClearAndDrawInputPad ( DWORD areaId )
{
ATVCB *p;
ATV *start,*info;
int id;
InPutPad *inputpad;
DWORD pGC;
/* Get id of the running task */
get_tid(&id);
/* Get pointer to ATVCB of the running task */
p = gSysTcbTbl[id-1].atvcb;
pGC=GetCurGC( );
if( p->pad == INPUTPADCLOSE )
return PPSM_ERR_INPUT_PAD_CLOSED;
start=p->stack[ p->top ];
if( ( info = findId( start,areaId ) ) == NULL )
return PPSM_ERR_AREA_ID;
inputpad=info->extptr1;
SysClearRec(pGC,GPC_WHITE,inputpad->xPos,inputpad->yPos,inputpad->areaWidth,inputpad->areaHeight,GPC_REPLACE_STYLE);
SysDrawRec(pGC,GPC_BLUE,inputpad->xPos,inputpad->yPos,(U16)(inputpad->xPos+inputpad->areaWidth-1),
(U16)(inputpad->yPos+inputpad->areaHeight-1),GPC_SOLID_LINE,GPC_REPLACE_STYLE);
return PPSM_OK;
}
/*****************************************************************
* Function Name: AtvTimerOutProcess
* Param in: InPutPad *pad
* Result code: void
* Description: send chinese text to pad->WndId when timer is out date
*****************************************************************/
void AtvTimerOutProcess( InPutPad *pad )
{
SHORT off;
DWORD pGC;
static MSG chinese_msg;
off=pad->off;
pad->timeroutflag=1;
pad->point[off-2]=0xff;
pad->point[off-1]=0xff;
pGC=GetCurGC( );
SysActiveAreaSuspend(pad->areaId,AREA_SUSPEND);
ClearPenTrack( pad );
/*识字*/
WTRecognize( pad->point,off,pad->CandidateResult);
chinese_msg.message=ASIX_CHINESE;//chinese_msg.message=SM_CHINESE;
chinese_msg.wparam=HandWriteRecognizeNum;
chinese_msg.data=pad->CandidateResult;
//chinese_msg.lparam=CurWindow;
chinese_msg.lparam=pad->WndId;//add by dsa 2002.03.19
SysSendMessage( gLcdOwnerTskId,(&chinese_msg) );
//AppendDebugLogString("Atv Sent WM_CHINESE = %d", WM_CHINESE);
pad->off=0;/**/
}
/*****************************************************************
* Function Name: ClearPenTrack
* Param in: InPutPad *pad
* Result code: void
* Description: clear the pen track
*****************************************************************/
void ClearPenTrack( InPutPad *pad )
{
SHORT off;
DWORD pGC;
pGC=GetCurGC( );
//SysDrawDot(pGC,GPC_BLACK,pad->point[0],pad->point[1],GPC_XOR_STYLE);
SysDrawDot(pGC,GPC_BLUE,pad->point[0],pad->point[1],GPC_XOR_STYLE);
for( off=2; off<pad->off-2; off=off+2 )
{
if( pad->point[off] == 0xff )
{
//SysDrawDot(pGC,GPC_BLACK,pad->point[off+2],pad->point[off+3],GPC_XOR_STYLE);
SysDrawDot(pGC,GPC_BLUE,pad->point[off+2],pad->point[off+3],GPC_XOR_STYLE);
off=off+2;
}
else
//SysDrawLine(pGC,GPC_BLACK,pad->point[off-2],pad->point[off-1],pad->point[off],
// pad->point[off+1],GPC_SOLID_LINE,GPC_XOR_STYLE);
SysDrawLine(pGC,GPC_BLUE,pad->point[off-2],pad->point[off-1],pad->point[off],
pad->point[off+1],GPC_SOLID_LINE,GPC_XOR_STYLE);
}
}
unsigned short * WTRecognize(unsigned char * PointBuf,short PointsNumber,unsigned short *CandidateResult)
{
#ifdef SIM_ON_PC
static char ch[]={"祝中华人民共和国万岁"};
int i;
unsigned short *p=(unsigned short *)ch;
for(i=0;i<HandWriteRecognizeNum;i++)
{
CandidateResult[i] = *p++;
}
#else
HWRecognize( PointBuf, PointsNumber, CandidateResult, HandWriteRecognizeNum, 0x0020|0x0040 );
#endif
return CandidateResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -