⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hl_stosd.c

📁 编程序的一些规范和例题
💻 C
字号:
/*
 * hl_stosd.c 		                                    Ver 0.0
 *
 * (c) Copyright ChangHong NetWork Co. Ltd, MianYang PRC, 2004.8.19
 *
 * Source file name : hl_stosd.c
 * Author	    : Robert ChengZhiJun  ( czj_robert@sohu.com )
 *
 * Original Work    : none
 *
 * Introduction     :
 *      This file is to encapsulate the fundation of DRAWING functions!
 *
 * =======================
 * IMPROVEMENTS THOUGHT OF
 * =======================
 *
 * =====================
 * MODIFICATION HISTORY
 * =====================
 *
 * Date        Initials        Modification
 * ----        --------	       ------------
 * 
 * 
 */
 
 
 
/*define this in order to adapt to Turbo C*/ 
typedef  int  STOSD_RegionHandle_t;
typedef  int  U8;
typedef  int  U16;
typedef  int  U32;
typedef  int  ST_ErrorCode_t;

typedef  int  STOSD_Color_t;
typedef  int  HL_STOSD_FontStruct_t;

#define  ST_DRIVER_ID     0
#define  ST_DRIVER_BASE   ( ST_DRIVER_ID << 16 )
enum
{
    ST_NO_ERROR = ST_DRIVER_BASE,
    ST_ERROR_BAD_PARAMETER,             /* Bad parameter passed       */
    ST_ERROR_NO_MEMORY,                 /* Memory allocation failed   */
    ST_ERROR_UNKNOWN_DEVICE,            /* Unknown device name        */
    ST_ERROR_ALREADY_INITIALIZED,       /* Device already initialized */
    ST_ERROR_NO_FREE_HANDLES,           /* Cannot open device again   */
    ST_ERROR_OPEN_HANDLE,               /* At least one open handle   */
    ST_ERROR_INVALID_HANDLE,            /* Handle is not valid        */
    ST_ERROR_FEATURE_NOT_SUPPORTED,     /* Feature unavailable        */
    ST_ERROR_INTERRUPT_INSTALL,         /* Interrupt install failed   */
    ST_ERROR_INTERRUPT_UNINSTALL,       /* Interrupt uninstall failed */
    ST_ERROR_TIMEOUT,                   /* Timeout occured            */
    ST_ERROR_DEVICE_BUSY                /* Device is currently busy   */
};



/* 
 * For the pixel 
 */
/*
 * draw the pixel
 */
ST_ErrorCode_t STOSD_SetPixel ( 
                                 STOSD_RegionHandle_t   Handle,
                                 U32                    PositionX,
                                 U32                    PositionY,
                                 STOSD_Color_t          Color
                              )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   putpixel ( PositionX, PositionY, Color );
   
   return  ST_NO_ERROR;
}


/*
 * returns the specified pixel color
 */
ST_ErrorCode_t STOSD_GetPixel (
                                 STOSD_RegionHandle_t   Handle,
                                 U32                    PositionX,
                                 U32                    PositionY,
                                 STOSD_Color_t*         Color_p
                              )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   Color_p =  getpixel ( PositionX, PositionY );
   
   return  ST_NO_ERROR;
}



/* 
 * For the line
 */
/*
 * draw the line
 */
ST_ErrorCode_t HL_STOSD_DrawLine ( 
                                    STOSD_RegionHandle_t Handle, 
                                    U32 x1, U32 y1,
                                    U32 x2, U32 y2, 
                                    STOSD_Color_t        Color 
                                 )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   setcolor ( Color );
   line     ( x1, y1, x2, y2 );

   return  ST_NO_ERROR;
}



/* 
 * For the circle
 */
/*
 * draw the hollow circle
 */
ST_ErrorCode_t HL_STOSD_DrawCircle (
                                      STOSD_RegionHandle_t  Handle, 
                                      U32 xCenter, U32 yCenter, 
                                      U32 radius, 
                                      STOSD_Color_t         Color
                                   )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   setcolor ( Color );
   circle   ( xCenter, yCenter, radius );

   return  ST_NO_ERROR;
}


/*
 * draw the filled circle
 */
ST_ErrorCode_t HL_STOSD_DrawFilledCircle ( 
                                            STOSD_RegionHandle_t  Handle, 
                                            U32 xCenter, U32 yCenter, 
                                            U32 radius, 
                                            STOSD_Color_t         Color
                                         )
{
   int iCount = 0;
   
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/
#if 0
    setcolor ( Color );
    putpixel ( xCenter, yCenter, Color );    /*draw the center of the circle*/
    for ( iCount = 1; iCount <= radius; iCount ++ )
        circle ( xCenter, yCenter, iCount ); /*draw the concentric circles*/
#endif
   setcolor     ( Color );
   setfillstyle ( SOLID_FILL, Color );
   fillellipse  ( xCenter, yCenter, radius, radius ); 
      
   return  ST_NO_ERROR;
}



/* 
 * For the rectangle
 */
/*
 * draw the hollow rectangle
 */
ST_ErrorCode_t HL_STOSD_DrawRectangle ( 
                                         STOSD_RegionHandle_t Handle, 
                                         U32 x,      U32 y, 
                                         U32 width , U32 height, 
                                         STOSD_Color_t        Color
                                      )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   setcolor  ( Color );
   rectangle ( x, y, x + width, y + height );

   return  ST_NO_ERROR;
}


/*
 * draw the filled rectangle
 */
ST_ErrorCode_t HL_STOSD_DrawFilledRectangle ( 
                                               STOSD_RegionHandle_t Handle, 
                                               U32 x,      U32 y, 
                                               U32 width , U32 height, 
                                               STOSD_Color_t        Color
                                            )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   setcolor     ( Color );
   rectangle    ( x, y, x + width, y + height );
   setfillstyle ( SOLID_FILL, Color );
   bar          ( x, y, x + width, y + height );

   return  ST_NO_ERROR;
}



/* 
 * For the ellipse
 */
/*
 * draw the hollow ellipse
 */
ST_ErrorCode_t HL_STOSD_DrawEllipse ( 
                                       STOSD_RegionHandle_t  Handle, 
                                       U32 xc, U32 yc, 
                                       U32 a,  U32 b, 
                                       STOSD_Color_t Color
                                    )
{
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   setcolor  ( Color );
   ellipse   ( xc, yc, 0, 360, a, b );

   return  ST_NO_ERROR;
}


/*
 * draw the filled ellipse
 */
ST_ErrorCode_t HL_STOSD_DrawFilledEllipse ( 
                                             STOSD_RegionHandle_t  Handle, 
                                             U32 xc, U32 yc, 
                                             U32 a,  U32 b, 
                                             STOSD_Color_t         Color
                                          )
{
   int iCount = 0;
   
   Handle  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
#if 0  
    setcolor  ( Color );
    ellipse   ( xc, yc, 0, 360, a, b );
    for ( iCount = 0; iCount <= b; iCount ++ )
        ellipse ( xc, yc, 0, 360, a, iCount );    /*filled the ellipse*/
    line ( xc - a, yc, xc + a, yc );
#endif
   setcolor     ( Color );
   setfillstyle ( SOLID_FILL, Color );
   fillellipse  ( xc, yc, a, b ); 
   
   return  ST_NO_ERROR;
}



/* 
 * For the font
 */
/*
 * draw the text on the screen
 */ 
ST_ErrorCode_t HL_STOSD_DrawText (
                                    STOSD_RegionHandle_t   Handle,
				    char*                  text,
				    U16                    numberOfChar,
				    U32                    positionX,
				    U32                    positionY,
				    STOSD_Color_t          TextColor,
				    HL_STOSD_FontStruct_t  Font,
				    U8                     charSpace
				 )
{
   Handle        =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   numberOfChar  =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   Font          =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	
   charSpace     =  0;   /*no use for Turbo C, adding this for no warning when compiling this program*/	 
   setcolor     ( TextColor );
   settextstyle ( TRIPLEX_FONT, HORIZ_DIR, 1 );
   outtextxy    ( positionX, positionY, text );
  
   return  ST_NO_ERROR;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -