📄 gpccurs.c
字号:
/*************************************************************************
*
* Copyright 2000 National ASIC Center, All right Reserved
*
* FILE NAME: gpcdraw.c
* PROGRAMMER: XuanHui
* Date of Creation:
*
* DESCRIPTION:
*
* NOTE:
*
*
* FUNCTIONS LIST:
* -------------------------------------------------------------------------
*
* GLOBAL VARS LIST:
*
*
**************************************************************************
* MODIFICATION HISTORY
*
*
*************************************************************************/
#include "gpc.h"
#include "lmalloc.h"
#include "systsk.h"
#include "systmr.h"
#include "ros33.h"
static void BlinkProc( GC *pGC );
static void DisplayCursor( GC *pGC );
static void CleanCursor( GC *pGC );
//-------------------------------------------------------------------
// SysSetCursorPosition()
//
// Set xPos and yPos of cursor.
//
// Parameters:
// gc - Address value of graphic context.
// xPos - Width of cursor.
// yPos - Height of cursor.
// style - Output style.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysSetCursorPosition( DWORD gc, WORD xPos, WORD yPos )
{
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 ( xPos > pGC->width - 1 || yPos > pGC->height - 1 ) //if ( xPos > pGC->width || yPos > pGC->height ) zhuli/2002.2.6
return GPC_ERR_FAILED;
// if ( ( pGC->width - xPos ) * ( pGC->height - yPos ) < ( pGC->cursor->width * pGC->cursor->height ) )
// return GPC_ERR_FAILED;
// longn_qi 2001/12/20 replaced above (2) with following (2)
if ( xPos + pGC->cursor->width > pGC->width || yPos + pGC->cursor->height > pGC->height )
return GPC_ERR_FAILED;
if ( pGC->cursor->status == ASIX_CURSOR_ON )
{
SysStopTimer( pGC->cursor->t_id );
CleanCursor( pGC );
pGC->cursor->x = xPos;
pGC->cursor->y = yPos;
DisplayCursor( pGC );
SysStartTimer( pGC->cursor->t_id );
}
else
{
pGC->cursor->x = xPos;
pGC->cursor->y = yPos;
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysSetCursorSize()
//
// Set width and height of cursor.
//
// Parameters:
// gc - Address value of graphic context.
// cursorWidth - Width of cursor.
// cursorheight - Height of cursor.
// style - Output style.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysSetCursorSize( DWORD gc, WORD cursorWidth, WORD cursorHeight )
{
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 ( cursorWidth > WIDTH )
// return GPC_ERR_FAILED;
// if ( cursorHeight > HEIGHT )
// return GPC_ERR_FAILED;
// longn_qi 2001/12/20 replaced above (5) with following (4)
if ( cursorWidth == 0 || cursorWidth > MAX_CURSOR_WIDTH )
return GPC_ERR_FAILED;
if ( cursorWidth == 0 || cursorHeight > MAX_CURSOR_HEIGHT )
return GPC_ERR_FAILED;
// longn_qi 2001/12/20 added (2)
if ( pGC->cursor->x + cursorWidth > pGC->width || pGC->cursor->y + cursorHeight > pGC->height )
return GPC_ERR_FAILED;
if( pGC->cursor->status == ASIX_CURSOR_ON )
{
SysStopTimer( pGC->cursor->t_id );
CleanCursor( pGC );
pGC->cursor->width = cursorWidth;
pGC->cursor->height = cursorHeight;
DisplayCursor( pGC );
SysStartTimer( pGC->cursor->t_id );
}
else
{
pGC->cursor->width = cursorWidth;
pGC->cursor->height = cursorHeight;
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysSetCursorStatus()
//
// Set status of cursor.
//
// Parameters:
// gc - Address value of graphic context.
// status - Status of cursor.
// style - Output style.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysSetCursorStatus( DWORD gc, BYTE status )
{
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 == status )
return GPC_ERR_OK;
if ( !(status & ASIX_CURSOR_OFF) && !(status & ASIX_CURSOR_ON) && !(status & ASIX_CURSOR_REVERSED) )//by zl 2002.4.3 status can only be these three types
return GPC_ERR_FAILED;
if ( status == ASIX_CURSOR_REVERSED )
pGC->cursor->status = ( pGC->cursor->status == ASIX_CURSOR_ON )? ASIX_CURSOR_OFF : ASIX_CURSOR_ON;
else
pGC->cursor->status = status;
switch ( pGC->cursor->status )
{
case ASIX_CURSOR_ON:
DisplayCursor( pGC );
SysStartTimer( pGC->cursor->t_id );
break;
case ASIX_CURSOR_OFF:
pGC->cursor->status = status;
SysStopTimer( pGC->cursor->t_id );
CleanCursor( pGC );
break;
default:
return GPC_ERR_FAILED;
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysSetCursorBlinkFrequency()
//
// Set blink frequency of cursor.
//
// Parameters:
// gc - Address value of graphic context.
// frequency - frequency of cursor.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysSetCursorBlinkFrequency(DWORD gc, WORD frequency )
{
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 ( frequency > FREMAX || frequency < FREMIN )
return GPC_ERR_FAILED;
pGC->cursor->frequency = frequency;
SysFreeTimer( pGC->cursor->t_id );
// SysCreateTimer( &pGC->cursor->t_id, pGC->cursor->frequency, BlinkProc, (GC *)pGC );
// longn_qi 2001/12/20 replaced above (1) with following (2)
if( SysCreateTimer( &pGC->cursor->t_id, pGC->cursor->frequency, BlinkProc, (GC *)pGC, CYC_MODE|AUTO_START_MODE ) == TIMER_ERROR )
return GPC_ERR_FAILED;
if( pGC->cursor->status == ASIX_CURSOR_ON )
SysStartTimer( pGC->cursor->t_id );
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
// SysSetCursorStyle()
//
// Set style of cursor.
//
// Parameters:
// gc - Address value of graphic context.
// cursorstyle - Style of cursor.
// style - Output style.
//
// returns:
// GPC_ERR_OK
//-------------------------------------------------------------------
STATUS SysSetCursorStyle( DWORD gc, BYTE cursorstyle )
{
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;
// ? judge cursorstyle
// if( cursorstyle != CURSOR_THREAD || cursorstyle != CURSOR_REC )//by zl 2002.4.3
if( (cursorstyle != CURSOR_THREAD) && (cursorstyle != CURSOR_REC) )
return GPC_ERR_FAILED;
if( pGC->cursor->status == ASIX_CURSOR_ON )
{
SysStopTimer( pGC->cursor->t_id );
CleanCursor ( pGC );
pGC->cursor->style = cursorstyle;
DisplayCursor( pGC );
SysStartTimer( pGC->cursor->t_id );
}
else
pGC->cursor->style = cursorstyle;
return GPC_ERR_OK;
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// CreatCursor()
//
// Creat a cursor.
//
// Parameters:
// gc - Address value of graphic context.
// xPos - Width of cursor.
// yPos - Height of cursor.
// cursorWidth - Width of cursor.
// cursorheight - Height of cursor.
// status - Status of cursor.
// frequency - frequency of cursor.
// cursorstyle - Style of cursor.
//
// returns:
// GPC_ERR_OK or GPC_ERR_FAILED
//-------------------------------------------------------------------
STATUS SysCreateCursor( DWORD gc, WORD xPos, WORD yPos, WORD cursorWidth, WORD cursorHeight, BYTE status, WORD frequency, BYTE cursorstyle )
{
GC *pGC;
pGC = (GC *)gc;
// longn_qi 2001/12/20 added (2)
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
//Position
// if ( xPos > pGC->width || yPos > pGC->height )//by zl 2002.4.3
if ( xPos > pGC->width - 1 || yPos > pGC->height - 1 )
return GPC_ERR_FAILED;
// if ( ( pGC->width - xPos ) * ( pGC->height - yPos ) < ( cursorWidth * cursorHeight ) )
// return GPC_ERR_FAILED;
// //Size
// if ( cursorWidth > WIDTH )
// return GPC_ERR_FAILED;
// if ( cursorHeight > HEIGHT )
// return GPC_ERR_FAILED;
// longn_qi 2001/12/20 replaced above(7) with following (7)
// Size
if ( cursorWidth == 0 || cursorWidth > MAX_CURSOR_WIDTH )
return GPC_ERR_FAILED;
if ( cursorWidth == 0 || cursorHeight > MAX_CURSOR_HEIGHT )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -