2017-05-29 07:54:57 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/** Copyright. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** FileName: SGUI_Basic.c **/
|
2017-05-29 07:54:57 +00:00
|
|
|
/** Author: XuYulin **/
|
2018-10-29 15:51:57 +00:00
|
|
|
/** Description: Simple GUI basic drawing operating interface. **/
|
2017-05-29 07:54:57 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
//=======================================================================//
|
|
|
|
//= Include files. =//
|
|
|
|
//=======================================================================//
|
2018-10-29 15:51:57 +00:00
|
|
|
#include "SGUI_Basic.h"
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
//= User Macro definition. =//
|
|
|
|
//=======================================================================//
|
|
|
|
#define SGUI_MIN_VAL(A, B) (((A)>(B)?(B):(A)))
|
|
|
|
#define SGUI_MAX_VAL(A, B) (((A)<(B)?(B):(A)))
|
|
|
|
|
2017-05-29 07:54:57 +00:00
|
|
|
//=======================================================================//
|
|
|
|
//= Static variable declaration. =//
|
|
|
|
//=======================================================================//
|
2017-09-22 14:09:36 +00:00
|
|
|
// Here is the 4*6 pixel font data definition, only number characters
|
|
|
|
// and plug(+), subtract(-), multiply(*), divide(/), brackets and space.
|
2018-10-29 15:51:57 +00:00
|
|
|
SGUI_CBYTE SGUI_BASIC_FONT_H6[] =
|
|
|
|
{
|
|
|
|
0x1F, 0x11, 0x1F, 0x00, //0
|
|
|
|
0x00, 0x1F, 0x00, 0x00, //1
|
|
|
|
0x1D, 0x15, 0x17, 0x00, //2
|
|
|
|
0x15, 0x15, 0x1F, 0x00, //3
|
|
|
|
0x07, 0x04, 0x1F, 0x00, //4
|
|
|
|
0x17, 0x15, 0x1D, 0x00, //5
|
|
|
|
0x1F, 0x15, 0x1D, 0x00, //6
|
|
|
|
0x19, 0x05, 0x03, 0x00, //7
|
|
|
|
0x1F, 0x15, 0x1F, 0x00, //8
|
|
|
|
0x17, 0x15, 0x1F, 0x00, //9
|
|
|
|
0x00, 0x10, 0x00, 0x00, //.
|
|
|
|
0x04, 0x0E, 0x04, 0x00, //+
|
|
|
|
0x04, 0x04, 0x04, 0x00, //-
|
|
|
|
0x0A, 0x04, 0x0A, 0x00, //**
|
|
|
|
0x18, 0x04, 0x03, 0x00, ///
|
|
|
|
0x00, 0x0E, 0x11, 0x00, //(
|
|
|
|
0x11, 0x0E, 0x00, 0x00, //)
|
|
|
|
0x00, 0x00, 0x00, 0x00, //space
|
2017-05-29 07:54:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=======================================================================//
|
2017-12-27 12:03:30 +00:00
|
|
|
//= Function define. =//
|
2017-05-29 07:54:57 +00:00
|
|
|
//=======================================================================//
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_DrawPoint **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Purpose: Set a pixel color or draw a point. **/
|
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ uiCoordinateX[in]: X coordinate of point by pixels. **/
|
|
|
|
/** @ uiCoordinateY[in]: Y coordinate of point by pixels. **/
|
|
|
|
/** @ eColor[in]: Point color, GUI_COLOR_BKGCLR means clear pix, **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** GUI_COLOR_FRGCLR means set pix. **/
|
|
|
|
/** Return: None. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Notice: None. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY, SGUI_COLOR eColor)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2019-02-15 13:58:23 +00:00
|
|
|
if((NULL != pstIFObj) && (uiCoordinateX < RECT_WIDTH(pstIFObj->stSize)) && (uiCoordinateY < RECT_HEIGHT(pstIFObj->stSize)))
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
if(NULL == pstIFObj->fnSetPixel)
|
2018-12-11 13:49:24 +00:00
|
|
|
{
|
|
|
|
/* Action function is unspecified, no actions. */
|
|
|
|
}
|
|
|
|
else if(SGUI_COLOR_FRGCLR == eColor)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
pstIFObj->fnSetPixel(uiCoordinateX, uiCoordinateY, 1);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else if(SGUI_COLOR_BKGCLR == eColor)
|
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
pstIFObj->fnSetPixel(uiCoordinateX, uiCoordinateY, 0);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_GetPoint **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Purpose: Get a pixel color . **/
|
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ uiCoordinateX[in]: X coordinate of point by pixels. **/
|
|
|
|
/** @ uiCoordinateY[in]: Y coordinate of point by pixels. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Return: SGUI_COLOR type enumerated for point color. **/
|
|
|
|
/** Notice: None. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
SGUI_COLOR eColor;
|
|
|
|
SGUI_UINT uiPixValue;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
eColor = SGUI_COLOR_BKGCLR;
|
|
|
|
uiPixValue = 0;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2019-02-15 13:58:23 +00:00
|
|
|
if((NULL != pstIFObj) && (uiCoordinateX < RECT_WIDTH(pstIFObj->stSize)) && (uiCoordinateY < RECT_HEIGHT(pstIFObj->stSize)))
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
if(NULL == pstIFObj->fnSetPixel)
|
2018-12-11 13:49:24 +00:00
|
|
|
{
|
|
|
|
/* Action function is unspecified, no actions. */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
uiPixValue = pstIFObj->fnGetPixel(uiCoordinateX, uiCoordinateY);
|
2018-12-11 13:49:24 +00:00
|
|
|
if(0 == uiPixValue)
|
|
|
|
{
|
|
|
|
eColor = SGUI_COLOR_BKGCLR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eColor = SGUI_COLOR_FRGCLR;
|
|
|
|
}
|
|
|
|
}
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
return eColor;
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/** Function Name: SGUI_Basic_ClearScreen **/
|
|
|
|
/** Purpose: Clean LCD screen display. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Notice: None. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstIFObj)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2018-12-11 13:49:24 +00:00
|
|
|
if(NULL != pstIFObj)
|
|
|
|
{
|
|
|
|
/* Clear screen. */
|
2019-03-07 14:17:35 +00:00
|
|
|
if((NULL != pstIFObj->fnClear) && (NULL != pstIFObj->fnSyncBuffer))
|
2018-12-11 13:49:24 +00:00
|
|
|
{
|
2019-03-07 14:17:35 +00:00
|
|
|
pstIFObj->fnClear();
|
2018-12-11 13:49:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
/* Draw a blank rectangle for clean screen when clean function is not supposed. */
|
2019-02-15 13:58:23 +00:00
|
|
|
SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, RECT_WIDTH(pstIFObj->stSize), RECT_HEIGHT(pstIFObj->stSize), SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR);
|
2018-12-11 13:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_DrawLine **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Purpose: Draw a line by the Bresenham algorithm. **/
|
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2019-02-15 13:58:23 +00:00
|
|
|
/** @ iStartX[in]: X coordinate of start point of line. **/
|
|
|
|
/** @ iStartY[in]: Y coordinate of start point of line. **/
|
|
|
|
/** @ iEndX[in]: X coordinate of end point of line. **/
|
|
|
|
/** @ iEndY[in]: Y coordinate of end point of line. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ eColor[in]: Line color. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Notice: None. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2019-02-15 13:58:23 +00:00
|
|
|
void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iEndX, SGUI_INT iEndY, SGUI_COLOR eColor)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
SGUI_INT iDx, iDy;
|
|
|
|
SGUI_INT iIncX, iIncY;
|
|
|
|
SGUI_INT iErrX = 0, iErrY = 0;
|
2019-02-15 13:58:23 +00:00
|
|
|
SGUI_INT i, iDs;
|
|
|
|
SGUI_INT iCurrentPosX, iCurrentPosY;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
iErrX = 0;
|
|
|
|
iErrY = 0;
|
2019-02-15 13:58:23 +00:00
|
|
|
iDx = iEndX - iStartX;
|
|
|
|
iDy = iEndY - iStartY;
|
|
|
|
iCurrentPosX = iStartX;
|
|
|
|
iCurrentPosY = iStartY;
|
2017-06-07 13:50:51 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
if(iDx > 0)
|
|
|
|
{
|
|
|
|
iIncX = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(iDx == 0)
|
|
|
|
{
|
|
|
|
iIncX = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iIncX = -1;
|
|
|
|
iDx = -iDx;
|
|
|
|
}
|
|
|
|
}
|
2017-06-07 13:50:51 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
if(iDy > 0)
|
|
|
|
{
|
|
|
|
iIncY = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(iDy == 0)
|
|
|
|
{
|
|
|
|
iIncY = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iIncY = -1;
|
|
|
|
iDy = -iDy;
|
|
|
|
}
|
|
|
|
}
|
2017-06-07 13:50:51 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
if(iDx > iDy)
|
|
|
|
{
|
2019-02-15 13:58:23 +00:00
|
|
|
iDs = iDx;
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-15 13:58:23 +00:00
|
|
|
iDs = iDy;
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2019-02-15 13:58:23 +00:00
|
|
|
for(i = 0; i <= iDs+1; i++)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-02-15 13:58:23 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, iCurrentPosX,iCurrentPosY, eColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
iErrX += iDx;
|
2019-02-15 13:58:23 +00:00
|
|
|
if(iErrX > iDs)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-02-15 13:58:23 +00:00
|
|
|
iErrX -= iDs;
|
|
|
|
iCurrentPosX += iIncX;
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
iErrY += iDy;
|
2019-02-15 13:58:23 +00:00
|
|
|
if(iErrY > iDs)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2019-02-15 13:58:23 +00:00
|
|
|
iErrY -= iDs;
|
|
|
|
iCurrentPosY += iIncY;
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_DrawRectangle **/
|
|
|
|
/** Purpose: Draw a rectangle on screen. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ uiStartX[in]: X coordinate of the upper-left corner. **/
|
|
|
|
/** @ uiStartY[in]: Y coordinate of the upper-left corner. **/
|
|
|
|
/** @ uiWidth[in]: . Width of rectangle. **/
|
|
|
|
/** @ uiHeight[in]: Height of rectangle. **/
|
|
|
|
/** @ eEdgeColor[in]: Edge color. **/
|
|
|
|
/** @ eFillColor[in]: Fill color. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
void SGUI_Basic_DrawRectangle(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_UINT uiWidth, SGUI_UINT uiHeight, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
SGUI_UINT uiColumnIndex;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
if((uiWidth > 0) && (uiHeight > 0))
|
|
|
|
{
|
|
|
|
if((uiWidth == 1) && (uiHeight == 1))
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiStartX, uiStartY, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else if(uiWidth == 1)
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX, uiStartY, uiStartX, uiStartY+uiHeight-1, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else if(uiHeight == 1)
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX, uiStartY, uiStartX+uiWidth-1, uiStartY, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Draw edge.
|
|
|
|
// Check and set changed page and column index is in edge display action.
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX, uiStartY, uiStartX, uiStartY+uiHeight-1, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX+uiWidth-1, uiStartY, uiStartX+uiWidth-1, uiStartY+uiHeight-1, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX, uiStartY, uiStartX+uiWidth-1, uiStartY, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiStartX, uiStartY+uiHeight-1, uiStartX+uiWidth-1, uiStartY+uiHeight-1, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
// Fill area.
|
|
|
|
if((eFillColor != SGUI_COLOR_TRANS) && (uiWidth > 2) && (uiHeight > 2))
|
|
|
|
{
|
|
|
|
for(uiColumnIndex=(uiStartX+1); uiColumnIndex<(uiStartX+uiWidth-1); uiColumnIndex++)
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiColumnIndex, uiStartY+1, uiColumnIndex, uiStartY+uiHeight-2, eFillColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_DrawCircle **/
|
|
|
|
/** Purpose: Draw a circle by center coordinate and radius. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ uiCx[in]: Circle center X coordinate. **/
|
|
|
|
/** @ uiCy[in]: Circle center Y coordinate. **/
|
|
|
|
/** @ uiRadius[in]: Circle radius. **/
|
|
|
|
/** @ eEdgeColor[in]: Edge color. **/
|
|
|
|
/** @ eFillColor[in]: Fill color. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Notice: None. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCx, SGUI_UINT uiCy, SGUI_UINT uiRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
SGUI_UINT uiPosXOffset, uiPosYOffset;
|
|
|
|
SGUI_UINT uiPosXOffset_Old, uiPosYOffset_Old;
|
|
|
|
SGUI_INT iXChange, iYChange, iRadiusError;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
uiPosXOffset = uiRadius;
|
|
|
|
uiPosYOffset = 0;
|
|
|
|
uiPosXOffset_Old = 0xFFFF;
|
|
|
|
uiPosYOffset_Old = 0xFFFF;
|
|
|
|
iXChange = 1 - 2 * uiRadius;
|
|
|
|
iYChange = 1;
|
|
|
|
iRadiusError = 0;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
if(uiRadius < 1)
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx, uiCy, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while(uiPosXOffset >= uiPosYOffset)
|
|
|
|
{
|
|
|
|
if((uiPosXOffset_Old != uiPosXOffset) || (uiPosYOffset_Old != uiPosYOffset) )
|
|
|
|
{
|
|
|
|
// Fill the circle
|
|
|
|
if((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset))
|
|
|
|
{
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiCx-uiPosXOffset, uiCy-uiPosYOffset+1, uiCx-uiPosXOffset, uiCy+uiPosYOffset-1, eFillColor);
|
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiCx+uiPosXOffset, uiCy-uiPosYOffset+1, uiCx+uiPosXOffset, uiCy+uiPosYOffset-1, eFillColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
uiPosXOffset_Old = uiPosXOffset;
|
|
|
|
}
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiCx-uiPosYOffset, uiCy-uiPosXOffset+1, uiCx-uiPosYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
|
|
|
SGUI_Basic_DrawLine(pstIFObj, uiCx+uiPosYOffset, uiCy-uiPosXOffset+1, uiCx+uiPosYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
uiPosYOffset_Old = uiPosYOffset;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
// Draw edge.
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx+uiPosXOffset, uiCy+uiPosYOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx-uiPosXOffset, uiCy+uiPosYOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx-uiPosXOffset, uiCy-uiPosYOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx+uiPosXOffset, uiCy-uiPosYOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx+uiPosYOffset, uiCy+uiPosXOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx-uiPosYOffset, uiCy+uiPosXOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx-uiPosYOffset, uiCy-uiPosXOffset, eEdgeColor);
|
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiCx+uiPosYOffset, uiCy-uiPosXOffset, eEdgeColor);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
uiPosYOffset++;
|
|
|
|
iRadiusError += iYChange;
|
|
|
|
iYChange += 2;
|
|
|
|
if ((2 * iRadiusError + iXChange) > 0)
|
|
|
|
{
|
|
|
|
uiPosXOffset--;
|
|
|
|
iRadiusError += iXChange;
|
|
|
|
iXChange += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
2017-10-08 16:03:05 +00:00
|
|
|
/** Function Name: SGUI_Basic_ReverseBlockColor **/
|
|
|
|
/** Purpose: Reverse all pixel color in a rectangle area. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ uiStartX[in]: X coordinate of the upper-left corner. **/
|
|
|
|
/** @ uiStartY[in]: Y coordinate of the upper-left corner. **/
|
|
|
|
/** @ uiWidth[in]: . Width of rectangle. **/
|
|
|
|
/** @ uiHeight[in]: Height of rectangle. **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*************************************************************************/
|
2019-01-11 14:03:38 +00:00
|
|
|
void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_UINT uiWidth, SGUI_UINT uiHeight)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
SGUI_UINT i_W, i_H;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
2018-10-29 15:51:57 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
for(i_W=0; i_W<uiWidth; i_W++)
|
|
|
|
{
|
2017-05-29 07:54:57 +00:00
|
|
|
for(i_H=0; i_H<uiHeight; i_H++)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
if(SGUI_Basic_GetPoint(pstIFObj, uiStartX+i_W, uiStartY+i_H) == SGUI_COLOR_FRGCLR)
|
2018-10-29 15:51:57 +00:00
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_BKGCLR);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_FRGCLR);
|
2018-10-29 15:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 14:24:26 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/** Function Name: SGUI_Basic_DrawBitMap **/
|
|
|
|
/** Purpose: Draw a rectangular area bit map on LCD screen. **/
|
|
|
|
/** Params: **/
|
2018-12-12 13:06:03 +00:00
|
|
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ pstDisplayArea[in]: Display area position and size. **/
|
2019-12-01 15:04:02 +00:00
|
|
|
/** @ pstInnerPos[in]: Data area size and display offset. **/
|
|
|
|
/** @ pstBitmapData[in]: Bitmap object, include size and data. **/
|
2018-12-11 13:49:24 +00:00
|
|
|
/** @ eDrawMode[in] Bit map display mode(normal or reverse color). **/
|
2017-08-02 14:24:26 +00:00
|
|
|
/** Return: None. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*************************************************************************/
|
2019-12-09 14:11:37 +00:00
|
|
|
void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos, const SGUI_BMP_RES* pstBitmapData, SGUI_DRAW_MODE eDrawMode)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
2017-08-02 14:24:26 +00:00
|
|
|
SGUI_INT iDrawPixX, iDrawPixY;
|
|
|
|
SGUI_INT iBmpPixX, iBmpPixY;
|
|
|
|
SGUI_UINT uiDrawnWidthIndex, uiDrawnHeightIndex;
|
|
|
|
SGUI_UINT uiPixIndex;
|
2019-12-09 14:11:37 +00:00
|
|
|
const SGUI_BYTE* pData;
|
2017-05-29 07:54:57 +00:00
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
uiDrawnWidthIndex = 0;
|
|
|
|
uiDrawnHeightIndex = 0;
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
// Only draw in visible area of screen.
|
2019-02-15 13:58:23 +00:00
|
|
|
if( (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)) && (RECT_Y_START(*pstDisplayArea) < RECT_HEIGHT(pstIFObj->stSize)) &&
|
2019-12-01 15:04:02 +00:00
|
|
|
(RECT_X_END(*pstDisplayArea, *pstDisplayArea) > 0) && (RECT_Y_END(*pstDisplayArea, *pstDisplayArea) > 0))
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
// Adapt text display area and data area.
|
|
|
|
SGUI_Common_AdaptDisplayInfo(pstDisplayArea, pstInnerPos);
|
2017-05-29 07:54:57 +00:00
|
|
|
// Only process drawing when valid display data existed
|
2019-12-01 15:04:02 +00:00
|
|
|
if((RECT_VALID_WIDTH(*pstBitmapData, *pstInnerPos) > 0) && (RECT_VALID_HEIGHT(*pstBitmapData, *pstInnerPos) > 0))
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
|
|
|
// Set loop start parameter of x coordinate
|
2019-01-11 14:03:38 +00:00
|
|
|
iDrawPixX = RECT_X_START(*pstDisplayArea);
|
2017-05-29 07:54:57 +00:00
|
|
|
iBmpPixX = 0;
|
2019-12-01 15:04:02 +00:00
|
|
|
if(RECT_X_START(*pstInnerPos) > 0)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
iDrawPixX += RECT_X_START(*pstInnerPos);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
iBmpPixX -= RECT_X_START(*pstInnerPos);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
uiDrawnWidthIndex = iBmpPixX;
|
|
|
|
// Loop for x coordinate;
|
2019-12-01 15:04:02 +00:00
|
|
|
while((uiDrawnWidthIndex<RECT_WIDTH(*pstBitmapData)) && (iDrawPixX<=RECT_X_END(*pstDisplayArea, *pstDisplayArea)) && (iDrawPixX<RECT_WIDTH(pstIFObj->stSize)))
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
|
|
|
// Redirect to data array for column.
|
2019-12-01 15:04:02 +00:00
|
|
|
pData = pstBitmapData->pData+iBmpPixX;
|
2017-05-29 07:54:57 +00:00
|
|
|
// Set loop start parameter of y coordinate
|
2019-01-11 14:03:38 +00:00
|
|
|
iDrawPixY = RECT_Y_START(*pstDisplayArea);
|
2017-05-29 07:54:57 +00:00
|
|
|
iBmpPixY = 0;
|
2019-12-01 15:04:02 +00:00
|
|
|
if(RECT_Y_START(*pstInnerPos) > 0)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
iDrawPixY += RECT_Y_START(*pstInnerPos);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-01 15:04:02 +00:00
|
|
|
iBmpPixY -= RECT_Y_START(*pstInnerPos);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
uiDrawnHeightIndex = iBmpPixY;
|
|
|
|
uiPixIndex = iBmpPixY % 8;
|
2019-12-01 15:04:02 +00:00
|
|
|
pData += (iBmpPixY / 8) * RECT_WIDTH(*pstBitmapData);
|
2017-05-29 07:54:57 +00:00
|
|
|
// Loop for y coordinate;
|
2019-12-01 15:04:02 +00:00
|
|
|
while((uiDrawnHeightIndex<RECT_HEIGHT(*pstBitmapData)) && (iDrawPixY<=RECT_Y_END(*pstDisplayArea, *pstDisplayArea)) && (iDrawPixY<RECT_HEIGHT(pstIFObj->stSize)))
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
|
|
|
if(uiPixIndex == 8)
|
|
|
|
{
|
|
|
|
uiPixIndex = 0;
|
2019-12-01 15:04:02 +00:00
|
|
|
pData += RECT_WIDTH(*pstBitmapData);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
2018-06-20 14:34:03 +00:00
|
|
|
if(SGUI_GET_PAGE_BIT(*pData, uiPixIndex) != eDrawMode)
|
2017-05-29 07:54:57 +00:00
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, iDrawPixX, iDrawPixY, SGUI_COLOR_FRGCLR);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-11 13:49:24 +00:00
|
|
|
SGUI_Basic_DrawPoint(pstIFObj, iDrawPixX, iDrawPixY, SGUI_COLOR_BKGCLR);
|
2017-05-29 07:54:57 +00:00
|
|
|
}
|
|
|
|
uiDrawnHeightIndex ++;
|
|
|
|
uiPixIndex ++;
|
|
|
|
iDrawPixY ++;
|
|
|
|
iBmpPixY ++;
|
|
|
|
}
|
|
|
|
uiDrawnWidthIndex ++;
|
|
|
|
iDrawPixX ++;
|
|
|
|
iBmpPixX ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|