2019-12-26 14:44:47 +00:00
|
|
|
/*************************************************************************/
|
2021-04-13 15:09:25 +00:00
|
|
|
/** Copyright. **/
|
|
|
|
/** FileName: Text.c **/
|
|
|
|
/** Author: Polarix **/
|
|
|
|
/** Description: HMI demo for text paint interface. **/
|
2019-12-26 14:44:47 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
//= Include files. =//
|
2019-12-26 14:44:47 +00:00
|
|
|
//=======================================================================//
|
|
|
|
#include "DemoProc.h"
|
|
|
|
#include "SGUI_Text.h"
|
|
|
|
#include "SGUI_FontResource.h"
|
|
|
|
#include "Resource.h"
|
|
|
|
|
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
//= Static function declaration. =//
|
2019-12-26 14:44:47 +00:00
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
static HMI_ENGINE_RESULT HMI_DemoText_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters);
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoText_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters);
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoText_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID);
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoText_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID);
|
2019-12-26 14:44:47 +00:00
|
|
|
|
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
//= Static variable declaration. =//
|
2019-12-26 14:44:47 +00:00
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
HMI_SCREEN_ACTION s_stDemoTextActions = { NULL,
|
|
|
|
HMI_DemoText_Prepare,
|
|
|
|
HMI_DemoText_RefreshScreen,
|
|
|
|
HMI_DemoText_ProcessEvent,
|
|
|
|
HMI_DemoText_PostProcess
|
|
|
|
};
|
2019-12-26 14:44:47 +00:00
|
|
|
|
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
//= Global variable declaration. =//
|
2019-12-26 14:44:47 +00:00
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
HMI_SCREEN_OBJECT g_stHMIDemo_TextPaint = { HMI_SCREEN_ID_DEMO_PAINT_TEXT,
|
|
|
|
&s_stDemoTextActions
|
|
|
|
};
|
2019-12-26 14:44:47 +00:00
|
|
|
|
|
|
|
//=======================================================================//
|
2021-04-13 15:09:25 +00:00
|
|
|
//= Function define. =//
|
2019-12-26 14:44:47 +00:00
|
|
|
//=======================================================================//
|
|
|
|
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoText_Prepare (SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters)
|
|
|
|
{
|
2021-04-13 15:09:25 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
if(NULL != pstDeviceIF->fnClear)
|
|
|
|
{
|
|
|
|
pstDeviceIF->fnClear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR);
|
|
|
|
}
|
|
|
|
HMI_DemoText_RefreshScreen(pstDeviceIF, pstParameters);
|
|
|
|
return HMI_RET_NORMAL;
|
2019-12-26 14:44:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoText_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters)
|
|
|
|
{
|
2021-04-13 15:09:25 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
2022-10-26 07:13:48 +00:00
|
|
|
SGUI_INT iTextPosX = 1;
|
|
|
|
SGUI_INT iTextPosY = 1;
|
|
|
|
SGUI_INT iTextAreaWidth;
|
|
|
|
SGUI_INT iTextAreaHeight;
|
2021-04-13 15:09:25 +00:00
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2022-10-26 07:13:48 +00:00
|
|
|
iTextAreaWidth = 62;
|
|
|
|
iTextAreaHeight = SGUI_DEFAULT_FONT_MiniNum.iHeight+1;
|
|
|
|
SGUI_Basic_SetMask(pstDeviceIF, iTextPosX, iTextPosY, iTextPosX + iTextAreaWidth - 1, iTextPosY + iTextAreaHeight - 1);
|
|
|
|
SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_MIN_NUM, &SGUI_DEFAULT_FONT_MiniNum, iTextPosX, iTextPosY, SGUI_DRAW_NORMAL);
|
2021-04-13 15:09:25 +00:00
|
|
|
|
2022-10-26 07:13:48 +00:00
|
|
|
iTextPosY += iTextAreaHeight;
|
|
|
|
iTextAreaHeight = SGUI_DEFAULT_FONT_8.iHeight+1;
|
|
|
|
SGUI_Basic_SetMask(pstDeviceIF, iTextPosX, iTextPosY, iTextPosX + iTextAreaWidth - 1, iTextPosY + iTextAreaHeight - 1);
|
|
|
|
SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_8, &SGUI_DEFAULT_FONT_8, iTextPosX, iTextPosY, SGUI_DRAW_NORMAL);
|
2021-04-13 15:09:25 +00:00
|
|
|
|
2022-10-26 07:13:48 +00:00
|
|
|
iTextPosY += iTextAreaHeight;
|
|
|
|
iTextAreaHeight = SGUI_DEFAULT_FONT_12.iHeight+1;
|
|
|
|
SGUI_Basic_SetMask(pstDeviceIF, iTextPosX, iTextPosY, iTextPosX + iTextAreaWidth - 1, iTextPosY + iTextAreaHeight - 1);
|
|
|
|
SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_12, &SGUI_DEFAULT_FONT_12, iTextPosX, iTextPosY, SGUI_DRAW_REVERSE);
|
2021-04-13 15:09:25 +00:00
|
|
|
|
2022-10-26 07:13:48 +00:00
|
|
|
iTextPosY += iTextAreaHeight;
|
|
|
|
iTextAreaHeight = SGUI_DEFAULT_FONT_12.iHeight+1;
|
|
|
|
SGUI_Basic_SetMask(pstDeviceIF, iTextPosX, iTextPosY, iTextPosX + iTextAreaWidth - 1, iTextPosY + iTextAreaHeight - 1);
|
|
|
|
SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_EXTEN_12, &GB2312_FZXS12, iTextPosX, iTextPosY, SGUI_DRAW_NORMAL);
|
2021-04-13 15:09:25 +00:00
|
|
|
|
2022-10-26 07:13:48 +00:00
|
|
|
iTextPosX = 64;
|
|
|
|
iTextPosY = 1;
|
|
|
|
iTextAreaHeight = 62;
|
2022-10-27 06:46:59 +00:00
|
|
|
SGUI_Basic_SetMask(pstDeviceIF, iTextPosX, iTextPosY, iTextPosX + iTextAreaWidth - 1, iTextPosY + iTextAreaHeight - 1);
|
|
|
|
SGUI_Text_DrawMultipleLinesText(pstDeviceIF, SCR3_TEXT_MULTILINE_12, &GB2312_FZXS12, iTextPosX, iTextPosY, iTextAreaWidth, SGUI_DRAW_NORMAL);
|
2021-04-13 15:09:25 +00:00
|
|
|
return HMI_RET_NORMAL;
|
2019-12-26 14:44:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoText_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID)
|
|
|
|
{
|
2021-04-13 15:09:25 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
HMI_ENGINE_RESULT eProcessResult;
|
|
|
|
SGUI_INT iProcessAction;
|
|
|
|
KEY_PRESS_EVENT* pstKeyEvent;
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
eProcessResult = HMI_RET_NORMAL;
|
|
|
|
iProcessAction = HMI_DEMO_PROC_NO_ACT;
|
|
|
|
pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent;
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
2022-03-19 12:35:09 +00:00
|
|
|
// Check event is valid.
|
|
|
|
if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT))
|
2021-04-13 15:09:25 +00:00
|
|
|
{
|
2022-03-19 12:35:09 +00:00
|
|
|
// Event data is invalid.
|
|
|
|
eProcessResult = HMI_RET_INVALID_DATA;
|
|
|
|
}
|
|
|
|
else if(EVENT_ID_KEY_PRESS == pstEvent->iID)
|
|
|
|
{
|
|
|
|
iProcessAction = HMI_DEMO_PROC_CANCEL;
|
2021-04-13 15:09:25 +00:00
|
|
|
}
|
|
|
|
if(NULL != piActionID)
|
|
|
|
{
|
|
|
|
*piActionID = iProcessAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eProcessResult;
|
2019-12-26 14:44:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoText_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID)
|
|
|
|
{
|
2021-04-13 15:09:25 +00:00
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
if(HMI_PROCESS_SUCCESSFUL(eProcResult))
|
|
|
|
{
|
|
|
|
if(HMI_DEMO_PROC_CANCEL == iActionID)
|
|
|
|
{
|
|
|
|
HMI_GoBack(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return HMI_RET_NORMAL;
|
2019-12-26 14:44:47 +00:00
|
|
|
}
|
|
|
|
|