📄 gpccurs.c
字号:
return GPC_ERR_FAILED;
if ( xPos + cursorWidth > pGC->width || yPos + cursorHeight > pGC->height )
return GPC_ERR_FAILED;
//Frequency
if ( frequency > FREMAX || frequency < FREMIN )
return GPC_ERR_FAILED;
if ( pGC->cursor != NULL ) // cursor has already existed
{
return GPC_ERR_FAILED;
}
else {
pGC->cursor = (CURSOR *)SysLmalloc( sizeof(CURSOR) );
if( pGC->cursor == NULL )
return GPC_ERR_FAILED;
pGC->cursor->x = xPos;
pGC->cursor->y = yPos;
pGC->cursor->width = cursorWidth;
pGC->cursor->height = cursorHeight;
pGC->cursor->status = status;
pGC->cursor->frequency = frequency;
pGC->cursor->style = cursorstyle;
pGC->cursor->flag = FALSE;
pGC->cursor->symbol = GPC_CURSOR_SYMBOL;
DisplayCursor( pGC );
// SysCreateTimer( &pGC->cursor->t_id, pGC->cursor->frequency, BlinkProc, (GC *)pGC );
// longn_qi 2001/12/20 replaced above (1) with following (5)
if( SysCreateTimer( &pGC->cursor->t_id, pGC->cursor->frequency, BlinkProc, (GC *)pGC, CYC_MODE|AUTO_START_MODE ) == TIMER_ERROR )
{
SysLfree( pGC->cursor );
return GPC_ERR_FAILED;
}
if( status == ASIX_CURSOR_ON )
SysStartTimer( pGC->cursor->t_id );
return GPC_ERR_OK;
}
}
//-------------------------------------------------------------------
// SysStartCursor()
//
// Start a cursor.
//
// Parameters:
// gc - Address value of graphic context.
// style - Output style.
//
// returns:
// GPC_ERR_OK or GPC_ERR_FAILED
//-------------------------------------------------------------------
STATUS SysStartCursor( DWORD gc )
{
GC *pGC;
pGC = (GC *)gc;
// longn_qi 2001/12/20 added (5)
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor == NULL || pGC->cursor->symbol != GPC_CURSOR_SYMBOL )
return GPC_ERR_FAILED;
if ( pGC->cursor->status == ASIX_CURSOR_OFF )
{
pGC->cursor->status = ASIX_CURSOR_ON;
DisplayCursor( pGC );
SysStartTimer( pGC->cursor->t_id );
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysStopCursor()
//
// Stop a cursor.
//
// Parameters:
// gc - Address value of graphic context.
// style - Output style.
//
// returns:
// GPC_ERR_OK or GPC_ERR_FAILED
//-------------------------------------------------------------------
STATUS SysStopCursor( DWORD gc )
{
GC *pGC;
pGC = (GC *)gc;
// longn_qi 2001/12/20 added (5)
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor == NULL || pGC->cursor->symbol != GPC_CURSOR_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor->status == ASIX_CURSOR_ON )
{
SysStopTimer( pGC->cursor->t_id );
if( pGC->cursor->flag == TRUE )
{
// pGC->cursor->flag = FALSE;
CleanCursor( pGC );
}
return GPC_ERR_OK;
}
else
return GPC_ERR_FAILED;
}
//-------------------------------------------------------------------
// SysCloseCursor()
//
// Stop a cursor.
//
// Parameters:
// gc - Address value of graphic context.
// style - Output style.
//
// returns:
// GPC_ERR_OK or GPC_ERR_FAILED
//-------------------------------------------------------------------
STATUS SysFreeCursor( DWORD gc )
{
GC *pGC;
pGC = (GC *)gc;
// longn_qi 2001/12/20 added (5)
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor == NULL || pGC->cursor->symbol != GPC_CURSOR_SYMBOL )
return GPC_ERR_FAILED;
SysFreeTimer( pGC->cursor->t_id );
if ( pGC->cursor->status == ASIX_CURSOR_ON )
CleanCursor( pGC );
SysLfree( pGC->cursor );
pGC->cursor = NULL;
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// BlinkFunc()
//
// Process of timer.
//
// Parameters:
// gc - Address value of graphic context.
// style - Output style.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
void BlinkProc( GC *pGC )
{
//WORD ColorIndex;
//dis_dsp( );
pGC->cursor->flag = !pGC->cursor->flag;
//seGetPixel( pGC, (SHORT)pGC->cursor->x, (SHORT)pGC->cursor->y, &ColorIndex );
switch( pGC->cursor->style )
{
case CURSOR_THREAD :
SysDrawVert( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->height, GPC_SOLID_LINE, GPC_XOR_STYLE );
break;
case CURSOR_REC :
SysClearRec( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->width, pGC->cursor->height, GPC_XOR_STYLE );
break;
}
//ena_dsp( );
SysStartTimer( pGC->cursor->t_id );
}
//-------------------------------------------------------------------
// DisplayCursor()
//
// Display a cursor.
//
// Parameters:
// pGC - The point that points the current task's gc.
// style - Output style.
//
// returns:
// void
//-------------------------------------------------------------------
void DisplayCursor( GC *pGC )
{
if ( pGC->cursor->flag == FALSE )
{
switch ( pGC->cursor->style )
{
case CURSOR_THREAD:
SysDrawVert( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->height, GPC_SOLID_LINE, GPC_XOR_STYLE );
break;
case CURSOR_REC:
SysClearRec( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->width, (SHORT)pGC->cursor->height, GPC_XOR_STYLE );
break;
}
pGC->cursor->flag = TRUE;
}
}
//-------------------------------------------------------------------
// CleanCursor()
//
// Clean a cursor.
//
// Parameters:
// gc - Address value of graphic context.
// style - Output style.
//
// returns:
// void
//-------------------------------------------------------------------
void CleanCursor( GC *pGC )
{
//WORD i, k;
//PWORD bitmap;
//if ( ( style < GPC_REPLACE_STYLE ) || ( style > GPC_NOT_STYLE ) )
//return GPC_ERR_FAILED;
/*bitmap = ( PWORD )malloc(1 * pGC->cursor->height);
if( bitmap == NULL )
return GPC_ERR_FAILED;
for( i = pGC->cursor->y; i < ( pGC->cursor->y + pGC->cursor->height ); i++ )
{
bitmap[k]= 0xfff;
k++;
}
//SysPutRec( gc, bitmap, pGC->cursor->x, pGC->cursor->y, pGC->cursor->width, pGC->cursor->height, GPC_REPLACE_STYLE, reserved );
//seSetImage( pGC, (SHORT)pGC->cursor->x, (SHORT)pGC->cursor->y, (SHORT)pGC->cursor->width, (SHORT)pGC->cursor->height, bitmap, GPC_REPLACE_STYLE );
*/
if ( pGC->cursor->flag == TRUE )
{
switch ( pGC->cursor->style )
{
case CURSOR_THREAD:
SysDrawVert( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->height, GPC_SOLID_LINE, GPC_XOR_STYLE );
break;
case CURSOR_REC:
SysClearRec( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->width, pGC->cursor->height, GPC_XOR_STYLE );
break;
}
pGC->cursor->flag = FALSE;
}
}
//-------------------------------------------------------------------
// SysAdjustCursorDisp()
//
// If cursor is covered, user should call this function to
// adjust cursor display.
//
// Parameters:
// gc - Address value of graphic context.
//
// returns:
// GPC_ERR_FAILED
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysAdjustCursorDisp( DWORD gc )
{
GC *pGC;
pGC = (GC *)gc;
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor == NULL || pGC->cursor->symbol != GPC_CURSOR_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor->flag == TRUE )
{
switch( pGC->cursor->style )
{
case CURSOR_THREAD :
SysDrawVert( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->height, GPC_SOLID_LINE, GPC_XOR_STYLE );
break;
case CURSOR_REC :
SysClearRec( (DWORD)pGC, BLINK_MASK, pGC->cursor->x, pGC->cursor->y, pGC->cursor->width, (SHORT)pGC->cursor->height, GPC_XOR_STYLE );
break;
}
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysGetCursorStatus()
//
// Get cursor status.
//
// Parameters:
// gc - Address value of graphic context.
//
// returns:
// GPC_ERR_FAILED
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysGetCursorStatus( DWORD gc, PWORD status )
{
GC *pGC;
pGC = (GC *)gc;
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if( pGC->cursor == NULL || pGC->cursor->symbol != GPC_CURSOR_SYMBOL )
return GPC_ERR_FAILED;
if( status == NULL )
return GPC_ERR_FAILED;
*status = pGC->cursor->status;
return GPC_ERR_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -