From 9956f92f0d09e3d4317003273e7e9194b1721480 Mon Sep 17 00:00:00 2001 From: Polarix Date: Fri, 15 Feb 2019 21:58:23 +0800 Subject: [PATCH] =?UTF-8?q?2019-02-15=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新实时曲线控件,可以非全屏显示,取消标题和数值显示,需要的可以参照例程自己实现。 更新屏幕驱动对象,屏幕的尺寸参数等不再使用全局宏定义。 --- DemoProc/src/DemoProc.c | 4 + DemoProc/src/List.c | 56 ++++--- DemoProc/src/RealtimeGraph.c | 34 +++- DemoProc/src/ScrollingText.c | 14 +- GUI/inc/SGUI_Common.h | 2 - GUI/inc/SGUI_Frame.h | 2 +- GUI/inc/SGUI_Graph.h | 2 +- GUI/inc/SGUI_Interface.h | 2 +- GUI/inc/SGUI_RealtimeGraph.h | 5 +- GUI/inc/SGUI_Typedef.h | 9 +- GUI/src/SGUI_Basic.c | 61 ++++--- GUI/src/SGUI_Frame.c | 14 +- GUI/src/SGUI_Graph.c | 22 +-- GUI/src/SGUI_Interface.c | 9 +- GUI/src/SGUI_Notice.c | 60 +++---- GUI/src/SGUI_RealtimeGraph.c | 206 +++++++++++------------- GUI/src/SGUI_Text.c | 4 +- VirtualSDK/Common/inc/Common.h | 9 +- VirtualSDK/Common/src/Common.cpp | 4 +- VirtualSDK/Controls/inc/wxLCD.h | 6 + VirtualSDK/Controls/inc/wxLCDBase.h | 9 +- VirtualSDK/Controls/src/wxLCD.cpp | 3 + VirtualSDK/Controls/src/wxLCDBase.cpp | 29 ++-- VirtualSDK/Demo/inc/DemoResource_UTF8.h | 30 ++-- 24 files changed, 312 insertions(+), 284 deletions(-) diff --git a/DemoProc/src/DemoProc.c b/DemoProc/src/DemoProc.c index 6703411..8d4494a 100644 --- a/DemoProc/src/DemoProc.c +++ b/DemoProc/src/DemoProc.c @@ -69,6 +69,10 @@ HMI_ENGINE_RESULT InitializeEngine(void) g_stDeviceInterface.fnClearScreen = SGUI_SDK_ClearDisplay; g_stDeviceInterface.fnRefreshScreen = SGUI_SDK_RefreshDisplay; #else + /* Initialize display size. */ + g_stDeviceInterface.stSize.Width = 128; + g_stDeviceInterface.stSize.Height = 64; + /* Initialize interface object. */ g_stDeviceInterface.stActions.fnSetPixel = OLED_SetPixel; g_stDeviceInterface.stActions.fnGetPixel = OLED_GetPixel; g_stDeviceInterface.stActions.fnClearScreen = OLED_ClearDisplay; diff --git a/DemoProc/src/List.c b/DemoProc/src/List.c index 972fdc7..190de3f 100644 --- a/DemoProc/src/List.c +++ b/DemoProc/src/List.c @@ -31,9 +31,9 @@ static HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_SCR_DEV* pstIFObj, SGUI_I //= Static variable declaration. =// //=======================================================================// static SGUI_CSZSTR s_szListTitle = DEMO_LIST_TITLE; -static SGUI_CSZSTR s_arrszNoticeType[] = { DEMO_LIST_ITEM_NOTICE_TEXT, DEMO_LIST_ITEM_NOTICE_TIME}; -#ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ -static SGUI_CSZSTR s_arrszEnumedValue[] = { DEMO_LIST_ITEM_ENUM_VALUE1, DEMO_LIST_ITEM_ENUM_VALUE2, DEMO_LIST_ITEM_ENUM_VALUE3}; +static SGUI_CSZSTR s_arrszNoticeType[] = { DEMO_LIST_ITEM_NOTICE_TEXT, DEMO_LIST_ITEM_NOTICE_TIME}; +#ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ +static SGUI_CSZSTR s_arrszEnumedValue[] = { DEMO_LIST_ITEM_ENUM_VALUE1, DEMO_LIST_ITEM_ENUM_VALUE2, DEMO_LIST_ITEM_ENUM_VALUE3}; #endif static SGUI_List_ITEM s_arrstTestListItems[] = { DEMO_LIST_ITEM_0, DEMO_LIST_ITEM_1, @@ -45,8 +45,8 @@ static SGUI_List_ITEM s_arrstTestListItems[] = { DEMO_LIST_ITEM_0, }; #ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ -static SGUI_List_ITEM s_arrstAppendListItems[] = { DEMO_LIST_ITEM_7, - DEMO_LIST_ITEM_8, +static SGUI_List_ITEM s_arrstAppendListItems[] = { DEMO_LIST_ITEM_7, + DEMO_LIST_ITEM_8, DEMO_LIST_ITEM_9 }; #endif @@ -86,15 +86,13 @@ HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstIFObj) /*----------------------------------*/ // Initialize list data. SGUI_SystemIF_MemorySet(&s_stDemoListObject, 0x00, sizeof(SGUI_List_STRUCT)); - // Title and font size must set before initialize list object. - s_stDemoListObject.Data.Rect.PosX = 0; - s_stDemoListObject.Data.Rect.PosY = 0; - s_stDemoListObject.Data.Rect.Width = 128; - s_stDemoListObject.Data.Rect.Height = 64; + // Title and font size must set before initialize list object. + s_stDemoListObject.Data.Rect.PosX = 0; + s_stDemoListObject.Data.Rect.PosY = 0; + s_stDemoListObject.Data.Rect.Width = RECT_WIDTH(pstIFObj->stSize); + s_stDemoListObject.Data.Rect.Height = RECT_HEIGHT(pstIFObj->stSize); s_stDemoListObject.Data.Title = s_szListTitle; s_stDemoListObject.FontSize = SGUI_FONT_SIZE_H12; - //Initialize list object. - //SGUI_List_InitializeListData(&s_stDemoListObject); #ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ s_stDemoListObject.Data.Items = NULL; s_stDemoListObject.Data.Count = 0; @@ -106,10 +104,10 @@ HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstIFObj) #else s_stDemoListObject.Data.Items = s_arrstTestListItems; s_stDemoListObject.Data.Count = sizeof(s_arrstTestListItems)/sizeof(SGUI_List_ITEM); -#endif - +#endif + //Initialize list object. - SGUI_List_InitializeListData(&s_stDemoListObject); + SGUI_List_InitializeListData(&s_stDemoListObject); return HMI_RET_NORMAL; } @@ -137,33 +135,33 @@ HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(SGUI_SCR_DEV* pstIFObj, const HMI_EV /*----------------------------------*/ /* Variable Declaration */ /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_UINT16 uiKeyCode; - SGUI_UINT16 uiKeyValue; - SGUI_UINT16 uiOptionCode; + HMI_ENGINE_RESULT eProcessResult; + SGUI_UINT16 uiKeyCode; + SGUI_UINT16 uiKeyValue; + SGUI_UINT16 uiOptionCode; KEY_PRESS_EVENT* pstKeyEvent; /*----------------------------------*/ /* Initialize */ /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; + eProcessResult = HMI_RET_NORMAL; pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; /*----------------------------------*/ /* Process */ /*----------------------------------*/ if(pstEvent->eType == HMI_ENGINE_EVENT_ACTION) - { - // Check event is valid. - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; + { + // Check event is valid. + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; } else if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - uiKeyCode = pstKeyEvent->Data.uiKeyValue; - uiKeyValue = KEY_CODE_VALUE(uiKeyCode); + { + uiKeyCode = pstKeyEvent->Data.uiKeyValue; + uiKeyValue = KEY_CODE_VALUE(uiKeyCode); uiOptionCode = KEY_CODE_OPT(uiKeyCode); switch(uiKeyValue) { diff --git a/DemoProc/src/RealtimeGraph.c b/DemoProc/src/RealtimeGraph.c index fa856e2..c203f23 100644 --- a/DemoProc/src/RealtimeGraph.c +++ b/DemoProc/src/RealtimeGraph.c @@ -9,6 +9,7 @@ //= Include files. =// //=======================================================================// #include "DemoProc.h" +#include "SGUI_Text.h" #include "SGUI_RealtimeGraph.h" //=======================================================================// @@ -23,8 +24,8 @@ static HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_SCR_DEV* pstIFObj, S //=======================================================================// //= Static variable declaration. =// //=======================================================================// -SGUI_RTGRAPH_CONTROL s_stRealtimeGraphControl = {50, -50, SGUI_TRUE, 3, 0}; -SGUI_RTGRAPH_DATA s_stRealtimeGraphData = {{0}, {0}, {0}, 0, 0}; +SGUI_RTGRAPH_CONTROL s_stRealtimeGraphControl = {50, -50, SGUI_TRUE, 3, 0}; +SGUI_RTGRAPH_DATA s_stRealtimeGraphData = {{1, 9, 126, 46}, {0}, {0}, {0}, 0, 0}; SGUI_RTGRAPH s_stRealtimeGraph = {&s_stRealtimeGraphData, &s_stRealtimeGraphControl}; //=======================================================================// //= Global variable declaration. =// @@ -52,8 +53,10 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(SGUI_SCR_DEV* pstIFObj, const void* { // Reinitialize data. SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph); + // Paint frame. + SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, RECT_WIDTH(pstIFObj->stSize), RECT_HEIGHT(pstIFObj->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); // Update screen display. - SGUI_RealtimeGraph_Refresh(pstIFObj, &s_stRealtimeGraph, NULL, "Real-time graph."); + SGUI_RealtimeGraph_Refresh(pstIFObj, &s_stRealtimeGraph); // Start dummy heart-beat timer. SGUI_SDK_ConfigHearBeatTimer(SDK_DEFAULT_HEART_BEAT_INTERVAL_MS); @@ -63,8 +66,29 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(SGUI_SCR_DEV* pstIFObj, const void* HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const void* pstParameters) { SGUI_CHAR szTextBuffer[16]; + SGUI_RECT_AREA stTextDisplayArea; + SGUI_RECT_AREA stTextDataArea; + + // Paint frame. + SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, RECT_WIDTH(pstIFObj->stSize), RECT_HEIGHT(pstIFObj->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + // Paint title + stTextDisplayArea.PosX = 1; + stTextDisplayArea.PosY = 1; + stTextDisplayArea.Width = RECT_WIDTH(pstIFObj->stSize)-2; + stTextDisplayArea.Height = 8; + stTextDataArea.PosX = 0; + stTextDataArea.PosY = 0; + SGUI_Text_DrawSingleLineText(pstIFObj, "Real-time graph", SGUI_FONT_SIZE_H8, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL); + // Paint value. SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, -15, ' '); - SGUI_RealtimeGraph_Refresh(pstIFObj, &s_stRealtimeGraph, szTextBuffer, "Real-time graph."); + stTextDisplayArea.PosX = 1; + stTextDisplayArea.PosY = RECT_HEIGHT(pstIFObj->stSize)-9; + stTextDisplayArea.Width = RECT_WIDTH(pstIFObj->stSize)-2; + stTextDisplayArea.Height = 8; + stTextDataArea.PosX = 0; + stTextDataArea.PosY = 0; + SGUI_Text_DrawSingleLineText(pstIFObj, szTextBuffer, SGUI_FONT_SIZE_H8, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL); + SGUI_RealtimeGraph_Refresh(pstIFObj, &s_stRealtimeGraph); return HMI_RET_NORMAL; } @@ -125,7 +149,7 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(SGUI_SCR_DEV* pstIFObj, const H else { iNewValue = pstDataEvent->Data.iValue; - SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue); + SGUI_RealtimeGraph_AppendValue(pstIFObj, &s_stRealtimeGraph, iNewValue); HMI_DemoRealGraph_RefreshScreen(pstIFObj, NULL); } break; diff --git a/DemoProc/src/ScrollingText.c b/DemoProc/src/ScrollingText.c index 43a7e02..a08fd65 100644 --- a/DemoProc/src/ScrollingText.c +++ b/DemoProc/src/ScrollingText.c @@ -25,8 +25,8 @@ #endif #define HMI_TEXT_DEMO_FRAME_TEXT_POSX (HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1) #define HMI_TEXT_DEMO_FRAME_TEXT_POSY (HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1) -#define HMI_TEXT_DEMO_FRAME_TEXT_WIDTH (SGUI_LCD_SIZE_WIDTH-(HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1)*2) -#define HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT (SGUI_LCD_SIZE_HEIGHT-(HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1)*2) +#define HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(SCR_SIZE) (((SCR_SIZE).Width)-(HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1)*2) +#define HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT(SCR_SIZE) (((SCR_SIZE).Height)-(HMI_TEXT_DEMO_FRAMR_EDGE_WIDTH+1)*2) //=======================================================================// //= Static function declaration. =// @@ -78,12 +78,12 @@ HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = { /*****************************************************************************/ HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(SGUI_SCR_DEV* Interface) { - s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; - s_iTextHeight = SGUI_Text_GetMultiLineTextLines(s_szDemoText, (HMI_TEXT_DEMO_FRAME_TEXT_WIDTH/g_stFontSize[SGUI_FONT_SIZE_H12].Width))*g_stFontSize[SGUI_FONT_SIZE_H12].Height; + s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT(Interface->stSize); + s_iTextHeight = SGUI_Text_GetMultiLineTextLines(s_szDemoText, (HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(Interface->stSize)/g_stFontSize[SGUI_FONT_SIZE_H12].Width))*g_stFontSize[SGUI_FONT_SIZE_H12].Height; s_stTextDisplayArea.PosX = HMI_TEXT_DEMO_FRAME_TEXT_POSX; s_stTextDisplayArea.PosY = HMI_TEXT_DEMO_FRAME_TEXT_POSY; - s_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH; - s_stTextDisplayArea.Height = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; + s_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(Interface->stSize); + s_stTextDisplayArea.Height = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT(Interface->stSize); return HMI_RET_NORMAL; } @@ -170,7 +170,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(SGUI_SCR_DEV* pstIFObj, con SGUI_Text_DrawMultipleLinesText(pstIFObj, s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL); if(s_iTextOffset + s_iTextHeight == 0) { - s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; + s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT(pstIFObj->stSize); } else { diff --git a/GUI/inc/SGUI_Common.h b/GUI/inc/SGUI_Common.h index ed77bfd..eebb49c 100644 --- a/GUI/inc/SGUI_Common.h +++ b/GUI/inc/SGUI_Common.h @@ -21,8 +21,6 @@ //=======================================================================// //= Public function declaration. =// //=======================================================================// -#define SGUI_LCD_SIZE_WIDTH (128) -#define SGUI_LCD_SIZE_HEIGHT (64) //=======================================================================// //= Public function declaration. =// diff --git a/GUI/inc/SGUI_Frame.h b/GUI/inc/SGUI_Frame.h index 84335ae..32b7447 100644 --- a/GUI/inc/SGUI_Frame.h +++ b/GUI/inc/SGUI_Frame.h @@ -18,7 +18,7 @@ typedef struct typedef struct { - SGUI_CSZSTR Title; + SGUI_CSZSTR Title; }SGUI_BOX_FRAME_DATA; typedef struct diff --git a/GUI/inc/SGUI_Graph.h b/GUI/inc/SGUI_Graph.h index dfec746..ae2a9b5 100644 --- a/GUI/inc/SGUI_Graph.h +++ b/GUI/inc/SGUI_Graph.h @@ -61,6 +61,6 @@ typedef struct //=======================================================================// //= Public function declaration. =// //=======================================================================// -void SGUI_Graph_InitializeGraphData(SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData); +void SGUI_Graph_InitializeGraphData(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData); void SGUI_Graph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph); #endif // __INCLUDE_SGUI_GRAPH_H__ diff --git a/GUI/inc/SGUI_Interface.h b/GUI/inc/SGUI_Interface.h index c4b75fb..393ca6c 100644 --- a/GUI/inc/SGUI_Interface.h +++ b/GUI/inc/SGUI_Interface.h @@ -52,6 +52,6 @@ SGUI_SIZE SGUI_SystemIF_StringLength(SGUI_CSZSTR szString); SGUI_SZSTR SGUI_SystemIF_StringCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc); SGUI_SZSTR SGUI_SystemIF_StringLengthCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc, SGUI_SIZE sSize); void SGUI_SystemIF_GetNowTime(SGUI_TIME* pstTime); -SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adStartAddr, SGUI_SIZE sReadSize, SGUI_BYTE* pOutputBuffer); +SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adStartAddr, SGUI_SIZE sReadSize); #endif // __INCLUDED_SGUI_INTERFACE_H__ diff --git a/GUI/inc/SGUI_RealtimeGraph.h b/GUI/inc/SGUI_RealtimeGraph.h index 3ac3930..041dd4b 100644 --- a/GUI/inc/SGUI_RealtimeGraph.h +++ b/GUI/inc/SGUI_RealtimeGraph.h @@ -25,6 +25,7 @@ typedef struct typedef struct { + SGUI_RECT_AREA Rect; SGUI_INT ValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; SGUI_INT LimitedValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; SGUI_INT PointYCoordinateArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; @@ -42,6 +43,6 @@ typedef struct //= Public function declaration. =// //=======================================================================// void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph); -void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph, SGUI_CSZSTR szTopText, SGUI_CSZSTR szBottomText); -void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue); +void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph); +void SGUI_RealtimeGraph_AppendValue(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue); #endif // __INCLUDE_GUI_REAL_GRAPH_H__ diff --git a/GUI/inc/SGUI_Typedef.h b/GUI/inc/SGUI_Typedef.h index 8f311c9..28109ba 100644 --- a/GUI/inc/SGUI_Typedef.h +++ b/GUI/inc/SGUI_Typedef.h @@ -1,5 +1,5 @@ -#ifndef __INCLUDE_GUI_TYPEDEF_H__ -#define __INCLUDE_GUI_TYPEDEF_H__ +#ifndef _INCLUDE_GUI_TYPEDEF_H_ +#define _INCLUDE_GUI_TYPEDEF_H_ //=======================================================================// //= Public function declaration. =// //=======================================================================// @@ -20,6 +20,7 @@ #define RECT_VALID_HEIGHT(ST) ((RECT_Y_START(ST)>0)?RECT_HEIGHT(ST):(RECT_HEIGHT(ST)+RECT_Y_START(ST))) #define SGUI_DEVPF_IF_DEFINE(R, FN, PARAM) typedef R(*FN)PARAM +#define SGUI_BMP_DATA_BUFFER_SIZE (512) //=======================================================================// //= Data type definition. =// @@ -132,6 +133,8 @@ typedef struct { //Screen display area size in pixel. SGUI_AREA_SIZE stSize; + //Bitmap data buffer. + SGUI_BYTE arrBmpDataBuffer[SGUI_BMP_DATA_BUFFER_SIZE]; //Engine & device initialize function. SGUI_ENGINE_ACTION_FN_INITIALIZE fnInitialize; //Clear screen function. @@ -144,4 +147,4 @@ typedef struct SGUI_ENGINE_ACTION_FN_REFRESH fnRefreshScreen; }SGUI_SCR_DEV; -#endif // __INCLUDE_GUI_TYPEDEF_H__ +#endif // _INCLUDE_GUI_TYPEDEF_H_ diff --git a/GUI/src/SGUI_Basic.c b/GUI/src/SGUI_Basic.c index 575bd4d..d87deec 100644 --- a/GUI/src/SGUI_Basic.c +++ b/GUI/src/SGUI_Basic.c @@ -15,7 +15,6 @@ //=======================================================================// //= User Macro definition. =// //=======================================================================// -#define BMP_DATA_BUFFER_SIZE (512) #define SGUI_MIN_VAL(A, B) (((A)>(B)?(B):(A))) #define SGUI_MAX_VAL(A, B) (((A)<(B)?(B):(A))) @@ -46,8 +45,6 @@ SGUI_CBYTE SGUI_BASIC_FONT_H6[] = 0x00, 0x00, 0x00, 0x00, //space }; -static SGUI_BYTE auiBitmapDataBuffer[BMP_DATA_BUFFER_SIZE] = {0x00}; - //=======================================================================// //= Function define. =// //=======================================================================// @@ -68,7 +65,7 @@ void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCoordinateX, SGUI_ /*----------------------------------*/ /* Process */ /*----------------------------------*/ - if((uiCoordinateX < SGUI_LCD_SIZE_WIDTH) && (uiCoordinateY < SGUI_LCD_SIZE_HEIGHT) && (NULL != pstIFObj)) + if((NULL != pstIFObj) && (uiCoordinateX < RECT_WIDTH(pstIFObj->stSize)) && (uiCoordinateY < RECT_HEIGHT(pstIFObj->stSize))) { if(NULL == pstIFObj->fnSetPixel) { @@ -112,7 +109,7 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCoordinateX, /*----------------------------------*/ /* Process */ /*----------------------------------*/ - if((uiCoordinateX < SGUI_LCD_SIZE_WIDTH) && (uiCoordinateY < SGUI_LCD_SIZE_HEIGHT)&& (NULL != pstIFObj)) + if((NULL != pstIFObj) && (uiCoordinateX < RECT_WIDTH(pstIFObj->stSize)) && (uiCoordinateY < RECT_HEIGHT(pstIFObj->stSize))) { if(NULL == pstIFObj->fnSetPixel) { @@ -157,7 +154,7 @@ void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstIFObj) } else { - SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, SGUI_LCD_SIZE_HEIGHT, SGUI_LCD_SIZE_HEIGHT, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, RECT_WIDTH(pstIFObj->stSize), RECT_HEIGHT(pstIFObj->stSize), SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); SGUI_Basic_RefreshDisplay(pstIFObj); } } @@ -168,15 +165,15 @@ void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstIFObj) /** Purpose: Draw a line by the Bresenham algorithm. **/ /** Params: **/ /** @ pstIFObj[in]: SimpleGUI object pointer. **/ -/** @ uiStartX[in]: X coordinate of start point of line. **/ -/** @ uiStartY[in]: Y coordinate of start point of line. **/ -/** @ uiEndX[in]: X coordinate of end point of line. **/ -/** @ uiEndY[in]: Y coordinate of end point of line. **/ +/** @ 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. **/ /** @ eColor[in]: Line color. **/ /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ -void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT uiStartX, SGUI_INT uiStartY, SGUI_INT uiEndX, SGUI_INT uiEndY, SGUI_COLOR eColor) +void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iEndX, SGUI_INT iEndY, SGUI_COLOR eColor) { /*----------------------------------*/ /* Variable Declaration */ @@ -184,18 +181,18 @@ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT uiStartX, SGUI_INT uiS SGUI_INT iDx, iDy; SGUI_INT iIncX, iIncY; SGUI_INT iErrX = 0, iErrY = 0; - SGUI_INT i, uiDs; - SGUI_INT uiCurrentPosX, uiCurrentPosY; + SGUI_INT i, iDs; + SGUI_INT iCurrentPosX, iCurrentPosY; /*----------------------------------*/ /* Initialize */ /*----------------------------------*/ iErrX = 0; iErrY = 0; - iDx = uiEndX - uiStartX; - iDy = uiEndY - uiStartY; - uiCurrentPosX = uiStartX; - uiCurrentPosY = uiStartY; + iDx = iEndX - iStartX; + iDy = iEndY - iStartY; + iCurrentPosX = iStartX; + iCurrentPosY = iStartY; if(iDx > 0) { @@ -233,30 +230,30 @@ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT uiStartX, SGUI_INT uiS if(iDx > iDy) { - uiDs = iDx; + iDs = iDx; } else { - uiDs = iDy; + iDs = iDy; } /*----------------------------------*/ /* Process */ /*----------------------------------*/ - for(i = 0; i <= uiDs+1; i++) + for(i = 0; i <= iDs+1; i++) { - SGUI_Basic_DrawPoint(pstIFObj, uiCurrentPosX,uiCurrentPosY, eColor); + SGUI_Basic_DrawPoint(pstIFObj, iCurrentPosX,iCurrentPosY, eColor); iErrX += iDx; - if(iErrX > uiDs) + if(iErrX > iDs) { - iErrX -= uiDs; - uiCurrentPosX += iIncX; + iErrX -= iDs; + iCurrentPosX += iIncX; } iErrY += iDy; - if(iErrY > uiDs) + if(iErrY > iDs) { - iErrY -= uiDs; - uiCurrentPosY += iIncY; + iErrY -= iDs; + iCurrentPosY += iIncY; } } } @@ -472,7 +469,7 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre /* Process */ /*----------------------------------*/ // Only draw in visible area of screen. - if( (RECT_X_START(*pstDisplayArea) < SGUI_LCD_SIZE_WIDTH) && (RECT_Y_START(*pstDisplayArea) < SGUI_LCD_SIZE_HEIGHT) && + if( (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)) && (RECT_Y_START(*pstDisplayArea) < RECT_HEIGHT(pstIFObj->stSize)) && (RECT_X_END(*pstDisplayArea) > 0) && (RECT_Y_END(*pstDisplayArea) > 0)) { // Recalculate display area and data area. @@ -494,7 +491,7 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre // Calculate bitmap data size. sBitmapDataSize = pstDataArea->Width * ((pstDataArea->Height-1)/8+1); // Read flash data. - SGUI_SystemIF_GetFlashData(pstIFObj, eDataSource, adDataStartAddr, sBitmapDataSize, auiBitmapDataBuffer); + SGUI_SystemIF_GetFlashData(pstIFObj, eDataSource, adDataStartAddr, sBitmapDataSize); // Set loop start parameter of x coordinate iDrawPixX = RECT_X_START(*pstDisplayArea); iBmpPixX = 0; @@ -508,10 +505,10 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre } uiDrawnWidthIndex = iBmpPixX; // Loop for x coordinate; - while((uiDrawnWidthIndexstSize))) { // Redirect to data array for column. - pData = auiBitmapDataBuffer + iBmpPixX; + pData = pstIFObj->arrBmpDataBuffer + iBmpPixX; // Set loop start parameter of y coordinate iDrawPixY = RECT_Y_START(*pstDisplayArea); iBmpPixY = 0; @@ -527,7 +524,7 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre uiPixIndex = iBmpPixY % 8; pData += (iBmpPixY / 8) * RECT_WIDTH(*pstDataArea); // Loop for y coordinate; - while((uiDrawnHeightIndexstSize))) { if(uiPixIndex == 8) { diff --git a/GUI/src/SGUI_Frame.c b/GUI/src/SGUI_Frame.c index 44104aa..d664536 100644 --- a/GUI/src/SGUI_Frame.c +++ b/GUI/src/SGUI_Frame.c @@ -37,12 +37,12 @@ void SGUI_Frame_DrawFullScreenFrame(SGUI_SCR_DEV* pstIFObj, SGUI_BOX_FRAME_STRUC /*----------------------------------*/ /* Initialize */ /*----------------------------------*/ - if(NULL != pstFrameData) + if((NULL != pstFrameData) && (NULL != pstIFObj)) { uiEdgeRectanglePosX = 0; uiEdgeRectanglePosY = 0; - uiEdgeRectangleWidth = SGUI_LCD_SIZE_WIDTH; - uiEdgeRectangleHeight = SGUI_LCD_SIZE_HEIGHT; + uiEdgeRectangleWidth = RECT_WIDTH(pstIFObj->stSize); + uiEdgeRectangleHeight = RECT_HEIGHT(pstIFObj->stSize); uiTitleLineWidth = g_stFontSize[pstFrameData->Parameter.FontSize].Height+2; /*----------------------------------*/ @@ -68,21 +68,21 @@ void SGUI_Frame_DrawFullScreenFrame(SGUI_SCR_DEV* pstIFObj, SGUI_BOX_FRAME_STRUC if(pstFrameData->Parameter.EdgeLayers > 0) { SGUI_Basic_DrawLine(pstIFObj, (pstFrameData->Parameter.EdgeLayers*2-1), (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth), - SGUI_LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*2, (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth), + RECT_WIDTH(pstIFObj->stSize)-pstFrameData->Parameter.EdgeLayers*2, (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth), SGUI_COLOR_FRGCLR); stTitleTextDisplayArea.PosX = pstFrameData->Parameter.EdgeLayers*2; stTitleTextDisplayArea.PosY = pstFrameData->Parameter.EdgeLayers*2; - stTitleTextDisplayArea.Width = SGUI_LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*4; + stTitleTextDisplayArea.Width = RECT_WIDTH(pstIFObj->stSize)-pstFrameData->Parameter.EdgeLayers*4; stTitleTextDisplayArea.Height = g_stFontSize[pstFrameData->Parameter.FontSize].Height; } else { SGUI_Basic_DrawLine( pstIFObj, 0, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth), - SGUI_LCD_SIZE_WIDTH-1, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth), + RECT_WIDTH(pstIFObj->stSize)-1, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth), SGUI_COLOR_FRGCLR); stTitleTextDisplayArea.PosX = 1; stTitleTextDisplayArea.PosY = 1; - stTitleTextDisplayArea.Width = SGUI_LCD_SIZE_WIDTH-2; + stTitleTextDisplayArea.Width = RECT_WIDTH(pstIFObj->stSize)-2; stTitleTextDisplayArea.Height = g_stFontSize[pstFrameData->Parameter.FontSize].Height; } SGUI_Text_DrawSingleLineText(pstIFObj, pstFrameData->Data.Title, pstFrameData->Parameter.FontSize, diff --git a/GUI/src/SGUI_Graph.c b/GUI/src/SGUI_Graph.c index 8b6351e..4868719 100644 --- a/GUI/src/SGUI_Graph.c +++ b/GUI/src/SGUI_Graph.c @@ -16,14 +16,14 @@ //= User Macro definition. =// //=======================================================================// #define GUI_GRAPH_SCROLLBAR_WIDTH (3) -#define GUI_GRAPH_GRAPH_AREA_WIDTH (SGUI_LCD_SIZE_WIDTH-GUI_GRAPH_SCROLLBAR_WIDTH-1) -#define GUI_GRAPH_GRAPH_AREA_HEIGHT (SGUI_LCD_SIZE_HEIGHT- GUI_GRAPH_SCROLLBAR_WIDTH-1) +#define GUI_GRAPH_GRAPH_AREA_WIDTH(GRAP_RECT) (((GRAP_RECT).Width)-GUI_GRAPH_SCROLLBAR_WIDTH-1) +#define GUI_GRAPH_GRAPH_AREA_HEIGHT(GRAP_RECT) (((GRAP_RECT).Height)-GUI_GRAPH_SCROLLBAR_WIDTH-1) //=======================================================================// //= Static function declaration. =// //=======================================================================// static void SGUI_Graph_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_UINT32 uiStartPointIndex, SGUI_UINT32 uiEndPointIndex); -static void SGUI_Praph_GetPointDrawingCoordinate(SGUI_GRAPH_POINT* pstDataPoint, SGUI_GRAPH_CONTROL* pstControlData, SGUI_GRAPH_POINT* pstDrawingPoint); +static void SGUI_Praph_GetPointDrawingCoordinate(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH_POINT* pstDataPoint, SGUI_GRAPH_CONTROL* pstControlData, SGUI_GRAPH_POINT* pstDrawingPoint); //=======================================================================// //= Function implementation. =// @@ -38,7 +38,7 @@ static void SGUI_Praph_GetPointDrawingCoordinate(SGUI_GRAPH_POINT* pstDataPoint, /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ -void SGUI_Graph_InitializeGraphData(SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData) +void SGUI_Graph_InitializeGraphData(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData) { /*----------------------------------*/ /* Process */ @@ -73,7 +73,7 @@ void SGUI_Graph_InitializeGraphData(SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstGraph->SubElement.xScrollBar.Parameter.MaxIndex = pstGraph->Control->PointRangeX; pstGraph->SubElement.xScrollBar.Parameter.PosX = GUI_GRAPH_SCROLLBAR_WIDTH; pstGraph->SubElement.xScrollBar.Parameter.PosY = 0; - pstGraph->SubElement.xScrollBar.Parameter.Width = SGUI_LCD_SIZE_WIDTH - GUI_GRAPH_SCROLLBAR_WIDTH; + pstGraph->SubElement.xScrollBar.Parameter.Width = RECT_WIDTH(pstIFObj->stSize) - GUI_GRAPH_SCROLLBAR_WIDTH; pstGraph->SubElement.xScrollBar.Parameter.Height = GUI_GRAPH_SCROLLBAR_WIDTH; pstGraph->SubElement.yScrollBar.Parameter.eDirection = SGUI_SCROLLBAR_VERTICAL; @@ -81,7 +81,7 @@ void SGUI_Graph_InitializeGraphData(SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstGraph->SubElement.yScrollBar.Parameter.PosX = 0; pstGraph->SubElement.yScrollBar.Parameter.PosY = GUI_GRAPH_SCROLLBAR_WIDTH; pstGraph->SubElement.yScrollBar.Parameter.Width = GUI_GRAPH_SCROLLBAR_WIDTH; - pstGraph->SubElement.yScrollBar.Parameter.Height = SGUI_LCD_SIZE_HEIGHT - GUI_GRAPH_SCROLLBAR_WIDTH; + pstGraph->SubElement.yScrollBar.Parameter.Height = RECT_HEIGHT(pstIFObj->stSize) - GUI_GRAPH_SCROLLBAR_WIDTH; pstGraph->Control->FocusIndex = pstInitializeData->FocusIndex; } @@ -156,11 +156,11 @@ void SGUI_Graph_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_UINT { // Start point. pstStartPoint = pstGraph->Data->Points+uiStartPointIndex; - SGUI_Praph_GetPointDrawingCoordinate(pstStartPoint, pstGraph->Control, &stGStartPoint); + SGUI_Praph_GetPointDrawingCoordinate(pstIFObj, pstStartPoint, pstGraph->Control, &stGStartPoint); // End point. pstEndPoint = pstGraph->Data->Points+uiEndPointIndex; - SGUI_Praph_GetPointDrawingCoordinate(pstEndPoint, pstGraph->Control, &stGEndPoint); + SGUI_Praph_GetPointDrawingCoordinate(pstIFObj, pstEndPoint, pstGraph->Control, &stGEndPoint); // End point. SGUI_Basic_DrawLine(pstIFObj, stGStartPoint.x, stGStartPoint.y, stGEndPoint.x, stGEndPoint.y, SGUI_COLOR_FRGCLR); @@ -178,7 +178,7 @@ void SGUI_Graph_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_UINT /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ -void SGUI_Praph_GetPointDrawingCoordinate(SGUI_GRAPH_POINT* pstDataPoint, SGUI_GRAPH_CONTROL* pstControlData, SGUI_GRAPH_POINT* pstDrawingPoint) +void SGUI_Praph_GetPointDrawingCoordinate(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH_POINT* pstDataPoint, SGUI_GRAPH_CONTROL* pstControlData, SGUI_GRAPH_POINT* pstDrawingPoint) { /*----------------------------------*/ /* Process */ @@ -189,7 +189,7 @@ void SGUI_Praph_GetPointDrawingCoordinate(SGUI_GRAPH_POINT* pstDataPoint, SGUI_G pstDrawingPoint->x = (pstDataPoint->x-pstControlData->xAxis.Min); pstDrawingPoint->y = (pstControlData->PointRangeY-(pstDataPoint->y-pstControlData->yAxis.Min)-1); - pstDrawingPoint->x = GUI_GRAPH_SCROLLBAR_WIDTH+pstDrawingPoint->x*GUI_GRAPH_GRAPH_AREA_WIDTH/pstControlData->PointRangeX; - pstDrawingPoint->y = GUI_GRAPH_SCROLLBAR_WIDTH+pstDrawingPoint->y*GUI_GRAPH_GRAPH_AREA_HEIGHT/pstControlData->PointRangeY; + pstDrawingPoint->x = GUI_GRAPH_SCROLLBAR_WIDTH+pstDrawingPoint->x*GUI_GRAPH_GRAPH_AREA_WIDTH(pstIFObj->stSize)/pstControlData->PointRangeX; + pstDrawingPoint->y = GUI_GRAPH_SCROLLBAR_WIDTH+pstDrawingPoint->y*GUI_GRAPH_GRAPH_AREA_HEIGHT(pstIFObj->stSize)/pstControlData->PointRangeY; } } diff --git a/GUI/src/SGUI_Interface.c b/GUI/src/SGUI_Interface.c index f6ef2e3..361eec0 100644 --- a/GUI/src/SGUI_Interface.c +++ b/GUI/src/SGUI_Interface.c @@ -454,11 +454,10 @@ SGUI_SZSTR SGUI_SystemIF_StringCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc) /** Function Name: SGUI_FlashData_GetFilash **/ /** Purpose: Read a byte array form ROM(ex. flash). **/ /** Params: **/ -/** @ pstIFObj[in]: SimpleGUI object pointer. **/ +/** @ pstIFObj[in]: SimpleGUI device interface object pointer. **/ /** @ eDataSource[in]: Data source. **/ /** @ adStartAddr[in]: Read data array start address in source. **/ /** @ sReadSize[in]: Number of data want to read. **/ -/** @ pOutputBuffer[out]: Output data buffer. **/ /** Return: None. **/ /** Notice: You can specify a data source by eDataSource parameter, **/ /** and it always used when your data is in different ROM **/ @@ -470,7 +469,7 @@ SGUI_SZSTR SGUI_SystemIF_StringCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc) /** This function will be re-write when use in different **/ /** hardware PF. **/ /*****************************************************************************/ -SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adStartAddr, SGUI_SIZE sReadSize, SGUI_BYTE* pOutputBuffer) +SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adStartAddr, SGUI_SIZE sReadSize) { /*----------------------------------*/ /* Variable Declaration */ @@ -487,7 +486,7 @@ SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOU /*----------------------------------*/ //#ifndef _SIMPLE_GUI_USE_SYS_PF_FUNCTIONS_ adBaseAddr = adStartAddr; - pOutPutDataPtr = pOutputBuffer; + pOutPutDataPtr = pstIFObj->arrBmpDataBuffer; pDataSource = NULL; //#endif sReadBytes = 0; @@ -498,7 +497,7 @@ SGUI_SIZE SGUI_SystemIF_GetFlashData(SGUI_SCR_DEV* pstIFObj, SGUI_FLASH_DATA_SOU //#ifdef _SIMPLE_GUI_USE_SYS_PF_FUNCTIONS_ // Add flash operation function here. //#else - if((eDataSource > SGUI_FONT_SRC_NONE) && (eDataSource < SGUI_FONT_SRC_UNKNOWN) && (sReadSize > 0) && (NULL != pOutputBuffer)) + if((eDataSource > SGUI_FONT_SRC_NONE) && (eDataSource < SGUI_FONT_SRC_UNKNOWN) && (sReadSize > 0)) { switch(eDataSource) { diff --git a/GUI/src/SGUI_Notice.c b/GUI/src/SGUI_Notice.c index 4c67e39..3f20ca9 100644 --- a/GUI/src/SGUI_Notice.c +++ b/GUI/src/SGUI_Notice.c @@ -18,27 +18,27 @@ //= User Macro definition. =// //=======================================================================// // User settings -#define NOTICE_FONT_SIZE (SGUI_FONT_SIZE_H12) -#define NOTICE_BOX_EDGE_DIST (6) -#define NOTICE_BOX_MARGIN (2) +#define NOTICE_FONT_SIZE (SGUI_FONT_SIZE_H12) +#define NOTICE_BOX_EDGE_DIST (6) +#define NOTICE_BOX_MARGIN (2) // Automatic calculation -#define NOTICE_BOX_WIDTH (SGUI_LCD_SIZE_WIDTH-NOTICE_BOX_EDGE_DIST*2) -#define NOTICE_BOX_HEIGHT_MIN (g_stFontSize[NOTICE_FONT_SIZE].Height*2+NOTICE_BOX_MARGIN*2) -#define NOTICE_BOX_HEIGHT_MAX (SGUI_LCD_SIZE_HEIGHT-NOTICE_BOX_EDGE_DIST*2) -#define NOTICE_BOX_HEIGHT(LINES) (LINES*g_stFontSize[NOTICE_FONT_SIZE].Height+NOTICE_BOX_MARGIN*2) -#define NOTICE_BOX_POSX (NOTICE_BOX_EDGE_DIST) -#define NOTICE_BOX_POSY(HEIGHT) ((SGUI_LCD_SIZE_HEIGHT-HEIGHT)/2) -#define NOTICE_TEXT_AREA_WIDTH_NOICON (NOTICE_BOX_WIDTH-NOTICE_BOX_MARGIN*4) -#define NOTICE_TEXT_AREA_WIDTH (NOTICE_TEXT_AREA_WIDTH_NOICON-NOTICE_ICON_SIZE-NOTICE_BOX_MARGIN*2) -#define NOTICE_TEXT_AREA_HEIGHT(LINES) (NOTICE_BOX_HEIGHT(LINES)-NOTICE_BOX_MARGIN*2) -#define NOTICE_TEXT_AREA_HEIGHT_MIN (g_stFontSize[NOTICE_FONT_SIZE].Height*2) -#define NOTICE_TEXT_AREA_HEIGHT_MAX (NOTICE_BOX_HEIGHT_MAX-NOTICE_BOX_MARGIN*2) -#define NOTICE_TEXT_POSX_NOICON (NOTICE_BOX_POSX+NOTICE_BOX_MARGIN*2) -#define NOTICE_TEXT_POSX (NOTICE_TEXT_POSX_NOICON+NOTICE_ICON_SIZE+NOTICE_BOX_MARGIN*2) -#define NOTICE_TEXT_POSY(HEIGHT) (NOTICE_BOX_POSY(HEIGHT)+NOTICE_BOX_MARGIN) -#define NOTICE_TEXT_LINES_MAX (NOTICE_TEXT_AREA_WIDTH/g_stFontSize[NOTICE_FONT_SIZE].Width) -#define NOTICE_TEXT_LINES_MAX_NOICON (NOTICE_TEXT_AREA_WIDTH_NOICON/g_stFontSize[NOTICE_FONT_SIZE].Width) +#define NOTICE_BOX_WIDTH(SCR_OBJ) (((SCR_OBJ).stSize.Width)-NOTICE_BOX_EDGE_DIST*2) +#define NOTICE_BOX_HEIGHT_MIN (g_stFontSize[NOTICE_FONT_SIZE].Height*2+NOTICE_BOX_MARGIN*2) +#define NOTICE_BOX_HEIGHT_MAX(SCR_OBJ) (((SCR_OBJ).stSize.Height)-NOTICE_BOX_EDGE_DIST*2) +#define NOTICE_BOX_HEIGHT(LINES) (LINES*g_stFontSize[NOTICE_FONT_SIZE].Height+NOTICE_BOX_MARGIN*2) +#define NOTICE_BOX_POSX (NOTICE_BOX_EDGE_DIST) +#define NOTICE_BOX_POSY(SCR_OBJ, HEIGHT) ((((SCR_OBJ).stSize.Height)-HEIGHT)/2) +#define NOTICE_TEXT_AREA_WIDTH_NOICON(SCR_OBJ) (NOTICE_BOX_WIDTH(SCR_OBJ)-NOTICE_BOX_MARGIN*4) +#define NOTICE_TEXT_AREA_WIDTH(SCR_OBJ) (NOTICE_TEXT_AREA_WIDTH_NOICON(SCR_OBJ)-NOTICE_ICON_SIZE-NOTICE_BOX_MARGIN*2) +#define NOTICE_TEXT_AREA_HEIGHT(LINES) (NOTICE_BOX_HEIGHT(LINES)-NOTICE_BOX_MARGIN*2) +#define NOTICE_TEXT_AREA_HEIGHT_MIN (g_stFontSize[NOTICE_FONT_SIZE].Height*2) +#define NOTICE_TEXT_AREA_HEIGHT_MAX(SCR_OBJ) (NOTICE_BOX_HEIGHT_MAX(SCR_OBJ)-NOTICE_BOX_MARGIN*2) +#define NOTICE_TEXT_POSX_NOICON (NOTICE_BOX_POSX+NOTICE_BOX_MARGIN*2) +#define NOTICE_TEXT_POSX (NOTICE_TEXT_POSX_NOICON+NOTICE_ICON_SIZE+NOTICE_BOX_MARGIN*2) +#define NOTICE_TEXT_POSY(SCR_OBJ, HEIGHT) (NOTICE_BOX_POSY(SCR_OBJ, HEIGHT)+NOTICE_BOX_MARGIN) +#define NOTICE_TEXT_LINES_MAX(SCR_OBJ) (NOTICE_TEXT_AREA_WIDTH(SCR_OBJ)/g_stFontSize[NOTICE_FONT_SIZE].Width) +#define NOTICE_TEXT_LINES_MAX_NOICON(SCR_OBJ) (NOTICE_TEXT_AREA_WIDTH_NOICON(SCR_OBJ)/g_stFontSize[NOTICE_FONT_SIZE].Width) //=======================================================================// //= Function define. =// @@ -75,28 +75,28 @@ SGUI_SIZE SGUI_Notice_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, // Get max line of notice text. if(SGUI_ICON_NONE != eIcon) { - uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX); + uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX(*pstIFObj)); } else { - uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX_NOICON); + uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX_NOICON(*pstIFObj)); } if(uiLineCount < 2) { uiLineCount = 2; } uiNoticeBoxHeight = NOTICE_BOX_HEIGHT(uiLineCount); - if(uiNoticeBoxHeight > NOTICE_BOX_HEIGHT_MAX) + if(uiNoticeBoxHeight > NOTICE_BOX_HEIGHT_MAX(*pstIFObj)) { - uiNoticeBoxHeight = NOTICE_BOX_HEIGHT_MAX; + uiNoticeBoxHeight = NOTICE_BOX_HEIGHT_MAX(*pstIFObj); } // Draw edge - SGUI_Basic_DrawRectangle(pstIFObj, NOTICE_BOX_POSX, NOTICE_BOX_POSY(uiNoticeBoxHeight), NOTICE_BOX_WIDTH, uiNoticeBoxHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_Basic_DrawRectangle(pstIFObj, NOTICE_BOX_POSX, NOTICE_BOX_POSY(*pstIFObj, uiNoticeBoxHeight), NOTICE_BOX_WIDTH(*pstIFObj), uiNoticeBoxHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); // Draw icon if exists. if(SGUI_ICON_NONE != eIcon) { stIconDisplayArea.PosX = NOTICE_BOX_POSX+NOTICE_BOX_MARGIN; - stIconDisplayArea.PosY = NOTICE_BOX_POSY(uiNoticeBoxHeight)+NOTICE_BOX_MARGIN; + stIconDisplayArea.PosY = NOTICE_BOX_POSY(*pstIFObj, uiNoticeBoxHeight)+NOTICE_BOX_MARGIN; stIconDisplayArea.Width = NOTICE_ICON_SIZE; stIconDisplayArea.Height = NOTICE_ICON_SIZE; stIconDataArea.PosX = 0; @@ -109,18 +109,18 @@ SGUI_SIZE SGUI_Notice_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, if(SGUI_ICON_NONE != eIcon) { stTextDisplayArea.PosX = NOTICE_TEXT_POSX; - stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH; + stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH(*pstIFObj); } else { stTextDisplayArea.PosX = NOTICE_TEXT_POSX_NOICON; - stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH_NOICON;; + stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH_NOICON(*pstIFObj); } - stTextDisplayArea.PosY = NOTICE_TEXT_POSY(uiNoticeBoxHeight); + stTextDisplayArea.PosY = NOTICE_TEXT_POSY(*pstIFObj, uiNoticeBoxHeight); stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT(uiLineCount); - if(stTextDisplayArea.Height > NOTICE_TEXT_AREA_HEIGHT_MAX) + if(stTextDisplayArea.Height > NOTICE_TEXT_AREA_HEIGHT_MAX(*pstIFObj)) { - stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT_MAX; + stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT_MAX(*pstIFObj); } uiTextLines = SGUI_Text_DrawMultipleLinesText(pstIFObj, pszNoticeTextPtr, NOTICE_FONT_SIZE, &stTextDisplayArea, uiTextOffset, SGUI_DRAW_NORMAL); diff --git a/GUI/src/SGUI_RealtimeGraph.c b/GUI/src/SGUI_RealtimeGraph.c index b3ad313..521ef02 100644 --- a/GUI/src/SGUI_RealtimeGraph.c +++ b/GUI/src/SGUI_RealtimeGraph.c @@ -2,7 +2,7 @@ /** Copyright. **/ /** FileName: SGUI_Graph.c **/ /** Author: Polarix **/ -/** Version: 1.0.0.0 **/ +/** Version: 1.7.0.0 **/ /** Description: Graph adjustment UI interface. **/ /*************************************************************************/ @@ -13,13 +13,6 @@ #include "SGUI_Text.h" #include "SGUI_RealtimeGraph.h" -//=======================================================================// -//= User Macro definition. =// -//=======================================================================// -#define GUI_GRAPH_SCROLLBAR_WIDTH (3) -#define GUI_GRAPH_GRAPH_AREA_WIDTH (SGUI_LCD_SIZE_WIDTH-GUI_GRAPH_SCROLLBAR_WIDTH-1) -#define GUI_GRAPH_GRAPH_AREA_HEIGHT (SGUI_LCD_SIZE_HEIGHT- GUI_GRAPH_SCROLLBAR_WIDTH-1) - //=======================================================================// //= Static function declaration. =// //=======================================================================// @@ -32,7 +25,7 @@ static SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTG /** Function Name: SGUI_RealtimeGraph_Initialize **/ /** Purpose: Initialize a graph control data. **/ /** Params: **/ -/** @pstRTGraph[in]: Graph map data. **/ +/** @ pstRTGraph[in]: Graph map data. **/ /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ @@ -52,41 +45,36 @@ void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph) { pstData = pstRTGraph->Data; pstControl = pstRTGraph->Control; - // Initialize graph controller. - if((NULL != pstControl) && (NULL != pstData)) + + // yAxisMax must be greater then yAxisMin; + if(pstControl->yAxisMax < pstControl->yAxisMin) { - // yAxisMax must be greater then yAxisMin; - if(pstControl->yAxisMax < pstControl->yAxisMin) - { - SGUI_SWAP(pstControl->yAxisMax, pstControl->yAxisMin); - } - // X-axis step in pixel must be greater then 2. - if(pstControl->xAxisStepPixel < 2) - { - pstControl->xAxisStepPixel = 2; - } + SGUI_SWAP(pstControl->yAxisMax, pstControl->yAxisMin); + } + // X-axis step in pixel must be greater then 2. + if(pstControl->xAxisStepPixel < 2) + { + pstControl->xAxisStepPixel = 2; + } - pstControl->ValueArea = pstControl->yAxisMax - pstControl->yAxisMin; + pstControl->ValueArea = pstControl->yAxisMax - pstControl->yAxisMin+1; - // Initialize graph data. - //SGUI_Common_MemorySet(pstData, 0x00, sizeof(SGUI_RTGRAPH_DATA)); - // Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin. - if(pstData->BaseLineValue > pstControl->yAxisMax) - { - pstData->BaseLineValue = pstControl->yAxisMax; - } - if(pstData->BaseLineValue < pstControl->yAxisMin) - { - pstData->BaseLineValue = pstControl->yAxisMin; - } - // Calculate the number of value points that can be used. - pstData->ValueCount = (SGUI_LCD_SIZE_WIDTH-2)/pstControl->xAxisStepPixel; - for(iValueIndex=0; iValueIndexValueCount; iValueIndex++) - { - pstData->ValueArray[iValueIndex] = pstData->BaseLineValue; - pstData->LimitedValueArray[iValueIndex] = pstData->BaseLineValue; - pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->LimitedValueArray[iValueIndex]); - } + // Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin. + if(pstData->BaseLineValue > pstControl->yAxisMax) + { + pstData->BaseLineValue = pstControl->yAxisMax; + } + if(pstData->BaseLineValue < pstControl->yAxisMin) + { + pstData->BaseLineValue = pstControl->yAxisMin; + } + // Calculate the number of value points that can be used. + pstData->ValueCount = (RECT_WIDTH(pstData->Rect)-2)/pstControl->xAxisStepPixel; + + // Initialize value array. + for(iValueIndex=0; iValueIndexValueCount; iValueIndex++) + { + pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue);; } } } @@ -101,7 +89,7 @@ void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph) /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ -void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph, SGUI_CSZSTR szTopText, SGUI_CSZSTR szBottomText) +void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph) { /*----------------------------------*/ /* Variable Declaration */ @@ -111,45 +99,34 @@ void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph SGUI_INT iValueIndex; SGUI_INT iPixelCoordinateStartX, iPixelCoordinateEndX; SGUI_INT iBaseLineCoordinateY; - SGUI_RECT_AREA stTextDataArea, stTextDispArea; /*----------------------------------*/ /* Process */ /*----------------------------------*/ - // Draw frame - SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, SGUI_LCD_SIZE_WIDTH, SGUI_LCD_SIZE_HEIGHT, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_Basic_DrawLine(pstIFObj, 1, 9, SGUI_LCD_SIZE_WIDTH-2, 9, SGUI_COLOR_FRGCLR); - SGUI_Basic_DrawLine(pstIFObj, 1, SGUI_LCD_SIZE_HEIGHT-9, SGUI_LCD_SIZE_WIDTH-2, SGUI_LCD_SIZE_HEIGHT-9, SGUI_COLOR_FRGCLR); - - if(NULL != pstRTGraph) + if((NULL != pstRTGraph) && (NULL != pstIFObj)) { pstData = pstRTGraph->Data; pstControl = pstRTGraph->Control; - if((NULL != pstControl) && (NULL != pstData)) - { - if(SGUI_TRUE == pstControl->EnableBaseline) - { - iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue); - SGUI_Basic_DrawLine(pstIFObj, 1, iBaseLineCoordinateY, SGUI_LCD_SIZE_WIDTH-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR); - } - if(pstData->ValueCount > 1) + // Draw frame + SGUI_Basic_DrawRectangle(pstIFObj, RECT_X_START(pstData->Rect), RECT_Y_START(pstData->Rect), + RECT_WIDTH(pstData->Rect), RECT_HEIGHT(pstData->Rect), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + + if(SGUI_TRUE == pstControl->EnableBaseline) + { + iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue); + SGUI_Basic_DrawLine(pstIFObj, 1, iBaseLineCoordinateY, RECT_WIDTH(pstIFObj->stSize)-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR); + } + + if(pstData->ValueCount > 1) + { + for(iValueIndex=1; iValueIndexValueCount; iValueIndex++) { - for(iValueIndex=1; iValueIndexValueCount; iValueIndex++) - { - iPixelCoordinateStartX = 1 + (iValueIndex-1) * pstControl->xAxisStepPixel; - iPixelCoordinateEndX = 1 + iValueIndex * pstControl->xAxisStepPixel; - SGUI_Basic_DrawLine(pstIFObj, iPixelCoordinateStartX, pstData->PointYCoordinateArray[iValueIndex-1], - iPixelCoordinateEndX, pstData->PointYCoordinateArray[iValueIndex], SGUI_COLOR_FRGCLR); - } + iPixelCoordinateStartX = 1 + ((iValueIndex-1) * pstControl->xAxisStepPixel) + RECT_X_START(pstData->Rect); + iPixelCoordinateEndX = 1 + (iValueIndex * pstControl->xAxisStepPixel) + RECT_X_START(pstData->Rect); + SGUI_Basic_DrawLine(pstIFObj, iPixelCoordinateStartX, pstData->PointYCoordinateArray[iValueIndex-1], + iPixelCoordinateEndX, pstData->PointYCoordinateArray[iValueIndex], SGUI_COLOR_FRGCLR); } - //SGUI_Common_IntegerToString(pstData->ValueArray[pstData->ValueCount-1], szValueBuffer, 10, 10, ' '); - stTextDataArea.PosX = 0; stTextDataArea.PosY = 0; - stTextDispArea.PosX = 1; stTextDispArea.PosY = 1; - stTextDispArea.Width = SGUI_LCD_SIZE_WIDTH-2, stTextDispArea.Height = 7; - SGUI_Text_DrawSingleLineText(pstIFObj, szTopText, SGUI_FONT_SIZE_H8, &stTextDispArea, &stTextDataArea, SGUI_DRAW_NORMAL); - stTextDispArea.PosY = SGUI_LCD_SIZE_HEIGHT-8; - SGUI_Text_DrawSingleLineText(pstIFObj, szBottomText, SGUI_FONT_SIZE_H8, &stTextDispArea, &stTextDataArea, SGUI_DRAW_NORMAL); } } } @@ -158,12 +135,13 @@ void SGUI_RealtimeGraph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph /** Function Name: SGUI_RealtimeGraph_AppendValue **/ /** Purpose: Append a new value to graph. **/ /** Params: **/ -/** @pstRTGraph[in]: Real-time graph object pointer. **/ -/** @iNewValue[in]: New value will be appended. **/ +/** @ pstIFObj[in]: SimpleGUI object pointer. **/ +/** @ pstRTGraph[in]: Real-time graph object pointer. **/ +/** @ iNewValue[in]: New value will be appended. **/ /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ -void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue) +void SGUI_RealtimeGraph_AppendValue(SGUI_SCR_DEV* pstIFObj, SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue) { /*----------------------------------*/ /* Variable Declaration */ @@ -180,30 +158,28 @@ void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue { pstData = pstRTGraph->Data; pstControl = pstRTGraph->Control; - if((NULL != pstControl) && (NULL != pstData)) + + // Push value. + for(iValueIndex=0; iValueIndexValueCount-1; iValueIndex++) { - // Push value. - for(iValueIndex=0; iValueIndexValueCount-1; iValueIndex++) - { - pstData->ValueArray[iValueIndex] = pstData->ValueArray[iValueIndex+1]; - pstData->LimitedValueArray[iValueIndex] = pstData->LimitedValueArray[iValueIndex+1]; - pstData->PointYCoordinateArray[iValueIndex] = pstData->PointYCoordinateArray[iValueIndex+1]; - } - // Append new value. - iValueIndex = pstData->ValueCount-1; - pstData->ValueArray[iValueIndex] = iNewValue; - iLimitedValue = iNewValue; - if(iLimitedValue > pstControl->yAxisMax) - { - iLimitedValue = pstControl->yAxisMax; - } - if(iLimitedValue < pstControl->yAxisMin) - { - iLimitedValue = pstControl->yAxisMin; - } - pstData->LimitedValueArray[iValueIndex] = iLimitedValue; - pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, iLimitedValue); + pstData->ValueArray[iValueIndex] = pstData->ValueArray[iValueIndex+1]; + pstData->LimitedValueArray[iValueIndex] = pstData->LimitedValueArray[iValueIndex+1]; + pstData->PointYCoordinateArray[iValueIndex] = pstData->PointYCoordinateArray[iValueIndex+1]; } + // Append new value. + iValueIndex = pstData->ValueCount-1; + pstData->ValueArray[iValueIndex] = iNewValue; + iLimitedValue = iNewValue; + if(iLimitedValue > pstControl->yAxisMax) + { + iLimitedValue = pstControl->yAxisMax; + } + if(iLimitedValue < pstControl->yAxisMin) + { + iLimitedValue = pstControl->yAxisMin; + } + pstData->LimitedValueArray[iValueIndex] = iLimitedValue; + pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, iLimitedValue); } } @@ -212,8 +188,8 @@ void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue /** Purpose: Convert data point to a drawing point in visible **/ /** graph area. **/ /** Params: **/ -/** @pstRTGraph[in]: Real-time graph object pointer. **/ -/** @iValue[in]: Real value. **/ +/** @ pstRTGraph[in]: Real-time graph object pointer. **/ +/** @ iValue[in]: Real value. **/ /** Return: None. **/ /** Notice: None. **/ /*************************************************************************/ @@ -230,7 +206,6 @@ SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, S /*----------------------------------*/ /* Initialize */ /*----------------------------------*/ - iDisplayValuePointAreaHeight = SGUI_LCD_SIZE_HEIGHT-9*2; iValuePointCoordinate = -1; /*----------------------------------*/ @@ -240,24 +215,25 @@ SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, S { pstData = pstRTGraph->Data; pstControl = pstRTGraph->Control; - if((NULL != pstControl) && (NULL != pstData)) + + iDisplayValuePointAreaHeight = RECT_HEIGHT(pstData->Rect); + + //Make sure the value is within the valid range + if(iValue > pstControl->yAxisMax) { - if(iValue > pstControl->yAxisMax) - { - iValue = pstControl->yAxisMax; - } - if(iValue < pstControl->yAxisMin) - { - iValue = pstControl->yAxisMin; - } - iAbsoluteValue = iValue - pstControl->yAxisMin; - - iValuePointCoordinate = iAbsoluteValue*iDisplayValuePointAreaHeight/pstControl->ValueArea; - - iValuePointCoordinate = iDisplayValuePointAreaHeight-iValuePointCoordinate; - - iValuePointCoordinate = iValuePointCoordinate +9; + iValue = pstControl->yAxisMax; } + if(iValue < pstControl->yAxisMin) + { + iValue = pstControl->yAxisMin; + } + iAbsoluteValue = iValue - pstControl->yAxisMin; + + iValuePointCoordinate = iAbsoluteValue*iDisplayValuePointAreaHeight/pstControl->ValueArea; + + iValuePointCoordinate = iDisplayValuePointAreaHeight-iValuePointCoordinate; + + iValuePointCoordinate = iValuePointCoordinate + RECT_Y_START(pstData->Rect)-1; } return iValuePointCoordinate; diff --git a/GUI/src/SGUI_Text.c b/GUI/src/SGUI_Text.c index 706f7bb..f11c040 100644 --- a/GUI/src/SGUI_Text.c +++ b/GUI/src/SGUI_Text.c @@ -75,7 +75,7 @@ void SGUI_Text_DrawSingleLineText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szText, SG /*----------------------------------*/ /* Process */ /*----------------------------------*/ - if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < SGUI_LCD_SIZE_WIDTH) && (SGUI_FONT_SRC_UNKNOWN != eFontResource)) + if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)) && (SGUI_FONT_SRC_UNKNOWN != eFontResource)) { // Recalculate text display area and data area. if(RECT_X_START(*pstDisplayArea) < 0) @@ -186,7 +186,7 @@ SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR sz /*----------------------------------*/ /* Process */ /*----------------------------------*/ - if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < SGUI_LCD_SIZE_WIDTH)) + if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize))) { // Recalculate text display area and data area. if(RECT_X_START(*pstDisplayArea) < 0) diff --git a/VirtualSDK/Common/inc/Common.h b/VirtualSDK/Common/inc/Common.h index a271fa2..73f364b 100644 --- a/VirtualSDK/Common/inc/Common.h +++ b/VirtualSDK/Common/inc/Common.h @@ -1,5 +1,6 @@ -#ifndef __INCLUDE_COMMON_H__ -#define __INCLUDE_COMMON_H__ +#ifndef _INCLUDE_COMMON_H_ +#define _INCLUDE_COMMON_H_ + //=======================================================================// //= Include files. =// //=======================================================================// @@ -17,6 +18,7 @@ #define PARAM_DEFAULT_PIXEL_NUM_H (128) #define PARAM_DEFAULT_PIXEL_NUM_V (64) +#define PARAM_DEFAULT_PANEL_BORDER_WIDTH (8) #define PARAM_DEFAULT_PIXEL_WIDTH (3) #define PARAM_DEFAULT_PIXEL_HEIGHT (3) #define PARAM_DEFAULT_GRID_ENABLE (true) @@ -31,6 +33,7 @@ typedef struct size_t VerticalPixelNumber; size_t PixelUnitWidth; size_t PixelUnitHeight; + size_t BorderWidth; bool EnableGrid; unsigned int PanelColor; unsigned int PixelColor; @@ -47,4 +50,4 @@ extern PixelPanelParameter g_stParameters; //=======================================================================// void SetDefaultParameterData(PixelPanelParameter* pstParameter); -#endif // __INCLUDE_LCD_COMMON_H__ +#endif // _INCLUDE_LCD_COMMON_H_ diff --git a/VirtualSDK/Common/src/Common.cpp b/VirtualSDK/Common/src/Common.cpp index 1772853..9619bb4 100644 --- a/VirtualSDK/Common/src/Common.cpp +++ b/VirtualSDK/Common/src/Common.cpp @@ -21,8 +21,8 @@ void SetDefaultParameterData(PixelPanelParameter* pstParameter) pstParameter->VerticalPixelNumber = PARAM_DEFAULT_PIXEL_NUM_V; pstParameter->PixelUnitWidth = PARAM_DEFAULT_PIXEL_WIDTH; pstParameter->PixelUnitHeight = PARAM_DEFAULT_PIXEL_HEIGHT; - pstParameter->EnableGrid = PARAM_DEFAULT_GRID_DISABLE; - + pstParameter->EnableGrid = PARAM_DEFAULT_GRID_ENABLE; + pstParameter->BorderWidth = PARAM_DEFAULT_PANEL_BORDER_WIDTH; // ScreenColor pstParameter->PanelColor = LCD_COLOR_OBJ_BKG; pstParameter->PixelColor = LCD_COLOR_OBJ_PIX; diff --git a/VirtualSDK/Controls/inc/wxLCD.h b/VirtualSDK/Controls/inc/wxLCD.h index 871abdc..0b96308 100644 --- a/VirtualSDK/Controls/inc/wxLCD.h +++ b/VirtualSDK/Controls/inc/wxLCD.h @@ -1,9 +1,15 @@ #ifndef _INCLUDE_CLASS_WXEX_LCD_H_ #define _INCLUDE_CLASS_WXEX_LCD_H_ +//=======================================================================// +//= Include files. =// +//=======================================================================// #include "wxLCDBase.h" #include "Common.h" +//=======================================================================// +//= Class declare. =// +//=======================================================================// class wxLCD: public wxLCDBase { //DECLARE_EVENT_TABLE(); diff --git a/VirtualSDK/Controls/inc/wxLCDBase.h b/VirtualSDK/Controls/inc/wxLCDBase.h index 67de51c..fea7b05 100644 --- a/VirtualSDK/Controls/inc/wxLCDBase.h +++ b/VirtualSDK/Controls/inc/wxLCDBase.h @@ -1,6 +1,9 @@ #ifndef _INCLUDE_CLASS_WXEX_LCD_BASE_H_ #define _INCLUDE_CLASS_WXEX_LCD_BASE_H_ +//=======================================================================// +//= Include files. =// +//=======================================================================// #include #include #include @@ -13,6 +16,7 @@ #define WX_LCD_DEFAULT_GRID_VISIBLE (true) #define WX_LCD_PIX_SIZE_MIN (3) #define WX_LCD_PIX_SIZE_MIN_WITH_GRID (4) +#define WX_LCD_BORDER_WIDTH (5) #define WX_LCD_PIX_RGB(RGBA) ((0x00FFFFFF) & (RGBA)) #define wxDefaultLCDPixelUnitSize (wxSize(2, 2)) @@ -36,14 +40,13 @@ class wxLCDBase wxBrush m_clsBrush; wxColour m_clsGridColor; wxSize m_clsSizeInPixel; - //int m_iPixelSize; wxSize m_clsPixelUnitSize; bool m_bGridVisible; unsigned int** m_ppuiDisplayBuffer; wxCriticalSection m_clsDisplayBufferCS; void (wxLCDBase::*m_pfDrawPoint)(wxDC& clsDCObject, int iPosX, int iPosY, const wxSize& clsPixelSize); bool m_bIsOK; - int m_iLockLevel; + int m_iBorderWidth; bool _initialize(void); void _getBestSize(wxSize& clsBestSize) const; @@ -75,6 +78,8 @@ class wxLCDBase wxLCDBase(wxWindow *pclsParent, wxWindowID iWinID = wxID_ANY, const wxPoint& clsPosition = wxDefaultPosition, const wxSize& clsSizeInPixel = wxDefaultSizeInPixel); ~wxLCDBase(); // Public interface + void SetBorderWidth(int iBorderWidth); + int GetBorderWidth(void) {return m_iBorderWidth;} void SetPixelNumber(int iHorizontalPixelNumber, int iVerticalPixelNumber); void GetPixelNumber(int* piHorizontalPixelNumber, int* piVerticalPixelNumber); void SetPixelUnitSize(const wxSize clsPixelUnitSize); diff --git a/VirtualSDK/Controls/src/wxLCD.cpp b/VirtualSDK/Controls/src/wxLCD.cpp index c577291..9a00854 100644 --- a/VirtualSDK/Controls/src/wxLCD.cpp +++ b/VirtualSDK/Controls/src/wxLCD.cpp @@ -96,9 +96,12 @@ void wxLCD::SetParameter(PixelPanelParameter* pstPanelParameter) SetPixelUnitSize(wxSize(pstPanelParameter->PixelUnitWidth, pstPanelParameter->PixelUnitHeight)); SetGridVisibled(pstPanelParameter->EnableGrid); SetPixelNumber(pstPanelParameter->HorizontalPixelNumber, pstPanelParameter->VerticalPixelNumber); + SetBorderWidth(pstPanelParameter->BorderWidth); SetPixelColour(wxColor(pstPanelParameter->PixelColor), false); SetPanelColour(wxColor(pstPanelParameter->PanelColor), false); SetGridColor(wxColor(pstPanelParameter->GridColor)); + + Layout(); } } diff --git a/VirtualSDK/Controls/src/wxLCDBase.cpp b/VirtualSDK/Controls/src/wxLCDBase.cpp index f46f63e..011c09a 100644 --- a/VirtualSDK/Controls/src/wxLCDBase.cpp +++ b/VirtualSDK/Controls/src/wxLCDBase.cpp @@ -52,7 +52,6 @@ m_clsCDC(this) // Initialize paint buffer and function pointer. m_ppuiDisplayBuffer = nullptr; m_pfDrawPoint = nullptr; - m_iLockLevel = 0; // Process initialize. m_bIsOK = _initialize(); } @@ -90,6 +89,8 @@ bool wxLCDBase::_initialize(void) SetPixelUnitSize(wxDefaultLCDPixelUnitSize); // Set grid visible. SetGridVisibled(WX_LCD_DEFAULT_GRID_VISIBLE); + // Set grid color. + SetBorderWidth(WX_LCD_BORDER_WIDTH); } return bReturn; } @@ -110,8 +111,18 @@ void wxLCDBase::_getBestSize(wxSize& clsBestSize) const /* Process */ /*----------------------------------*/ // Set size object value. - clsBestSize.SetWidth(m_clsSizeInPixel.GetWidth()*m_clsPixelUnitSize.GetWidth()+(bGridIsVisible?1:0)); - clsBestSize.SetHeight(m_clsSizeInPixel.GetHeight()*m_clsPixelUnitSize.GetHeight()+(bGridIsVisible?1:0)); + clsBestSize.SetWidth(m_clsSizeInPixel.GetWidth()*m_clsPixelUnitSize.GetWidth()+(bGridIsVisible?1:0)+(2*m_iBorderWidth)); + clsBestSize.SetHeight(m_clsSizeInPixel.GetHeight()*m_clsPixelUnitSize.GetHeight()+(bGridIsVisible?1:0)+(2*m_iBorderWidth)); +} + +void wxLCDBase::SetBorderWidth(int iBorderWidth) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + m_iBorderWidth = iBorderWidth; + // Repaint + RefreshDisplay(); } void wxLCDBase::SetPixelNumber(int iHorizontalPixelNumber, int iVerticalPixelNumber) @@ -374,7 +385,7 @@ void wxLCDBase::_drawPointSinglePixel(wxDC& clsDCObject, int iPosX, int iPosY, c /*----------------------------------*/ /* Process */ /*----------------------------------*/ - clsDCObject.DrawPoint(wxPoint(iPosX, iPosY)); + clsDCObject.DrawPoint(wxPoint(iPosX+m_iBorderWidth, iPosY+m_iBorderWidth)); } void wxLCDBase::_drawPointMultiplePixel(wxDC& clsDCObject, int iPosX, int iPosY, const wxSize& clsPixelSize) @@ -382,7 +393,7 @@ void wxLCDBase::_drawPointMultiplePixel(wxDC& clsDCObject, int iPosX, int iPosY, /*----------------------------------*/ /* Process */ /*----------------------------------*/ - clsDCObject.DrawRectangle(wxPoint(iPosX*m_clsPixelUnitSize.GetWidth(), iPosY*m_clsPixelUnitSize.GetHeight()), clsPixelSize); + clsDCObject.DrawRectangle(wxPoint(iPosX*m_clsPixelUnitSize.GetWidth()+m_iBorderWidth, iPosY*m_clsPixelUnitSize.GetHeight()+m_iBorderWidth), clsPixelSize); } void wxLCDBase::_drawPointMultiplePixelWithGrid(wxDC& clsDCObject, int iPosX, int iPosY, const wxSize& clsPixelSize) @@ -390,7 +401,7 @@ void wxLCDBase::_drawPointMultiplePixelWithGrid(wxDC& clsDCObject, int iPosX, in /*----------------------------------*/ /* Process */ /*----------------------------------*/ - clsDCObject.DrawRectangle(wxPoint(iPosX*m_clsPixelUnitSize.GetWidth()+1, iPosY*m_clsPixelUnitSize.GetHeight()+1), wxSize(clsPixelSize.GetWidth()-1, clsPixelSize.GetHeight()-1)); + clsDCObject.DrawRectangle(wxPoint(iPosX*m_clsPixelUnitSize.GetWidth()+m_iBorderWidth+1, iPosY*m_clsPixelUnitSize.GetHeight()+m_iBorderWidth+1), wxSize(clsPixelSize.GetWidth()-1, clsPixelSize.GetHeight()-1)); } /*************************************************************************/ @@ -522,8 +533,8 @@ void wxLCDBase::RefreshDisplay(void) /*----------------------------------*/ /* Initialize */ /*----------------------------------*/ - iPaintSizeWidth = m_clsSizeInPixel.GetWidth()*m_clsPixelUnitSize.GetWidth(); - iPaintSizeHeight = m_clsSizeInPixel.GetHeight()*m_clsPixelUnitSize.GetHeight(); + iPaintSizeWidth = m_clsSizeInPixel.GetWidth()*m_clsPixelUnitSize.GetWidth()+(2*m_iBorderWidth); + iPaintSizeHeight = m_clsSizeInPixel.GetHeight()*m_clsPixelUnitSize.GetHeight()+(2*m_iBorderWidth); bGridVisible = GetGridVisibled(); // Set buffer size. @@ -543,7 +554,7 @@ void wxLCDBase::RefreshDisplay(void) { _setDCColor(m_clsGridColor); _prepareDC(clsBufferedDC); - clsBufferedDC.DrawRectangle(wxPoint(0, 0), + clsBufferedDC.DrawRectangle(wxPoint(m_iBorderWidth, m_iBorderWidth), wxSize( m_clsSizeInPixel.GetWidth()*m_clsPixelUnitSize.GetWidth()+1, m_clsSizeInPixel.GetHeight()*m_clsPixelUnitSize.GetHeight()+1)); } diff --git a/VirtualSDK/Demo/inc/DemoResource_UTF8.h b/VirtualSDK/Demo/inc/DemoResource_UTF8.h index 916107c..6d4b9a7 100644 --- a/VirtualSDK/Demo/inc/DemoResource_UTF8.h +++ b/VirtualSDK/Demo/inc/DemoResource_UTF8.h @@ -1,5 +1,5 @@ -#ifndef __INCLUDE_DEMO_RESOURCE_UTF8_H__ -#define __INCLUDE_DEMO_RESOURCE_UTF8_H__ +#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ +#define _INCLUDE_DEMO_RESOURCE_UTF8_H_ /* Screen 1: Multiple lines text. */ /* Start screen scroll text. */ @@ -21,18 +21,18 @@ #define DEMO_LIST_ITEM_ENUM_VALUE3 ("枚举项3") -/* List items data. Sign ListText List item type List value Decimal point Enumed text list */ -/* init. min. max. init. min. max. */ -#define DEMO_LIST_ITEM_0 {0, "简单列表项", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_1 {1, "枚举类型列表项", LIST_ITEM_ENUM, {0, 0, 1 }, {0, 0, 0 }, s_arrszNoticeType} -#define DEMO_LIST_ITEM_2 {2, "数字列表项", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} -#define DEMO_LIST_ITEM_3 {3, "带小数的数字列表项", LIST_ITEM_DIGIT, {1, -50, 50 }, {2, 0, 5 }, NULL} -#define DEMO_LIST_ITEM_4 {4, "超长文字的简单列表项", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_5 {5, "编辑框", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_6 {6, "实时曲线", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_7 {7, "测试项目1", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_8 {8, "测试项目2", LIST_ITEM_ENUM, {0, 0, 2 }, {0, 0, 0 }, s_arrszEnumedValue} -#define DEMO_LIST_ITEM_9 {9, "测试项目3", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} +/* List items data. Sign ListText List item type List value Decimal point Enumed text list */ +/* init. min. max. init. min. max. */ +#define DEMO_LIST_ITEM_0 {0, "简单列表项", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} +#define DEMO_LIST_ITEM_1 {1, "枚举类型列表项", LIST_ITEM_ENUM, {0, 0, 1 }, {0, 0, 0 }, s_arrszNoticeType} +#define DEMO_LIST_ITEM_2 {2, "数字列表项", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} +#define DEMO_LIST_ITEM_3 {3, "带小数的数字列表项", LIST_ITEM_DIGIT, {1, -50, 50 }, {2, 0, 5 }, NULL} +#define DEMO_LIST_ITEM_4 {4, "超长文字的简单列表项", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} +#define DEMO_LIST_ITEM_5 {5, "编辑框", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} +#define DEMO_LIST_ITEM_6 {6, "实时曲线", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} +#define DEMO_LIST_ITEM_7 {7, "测试项目1", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} +#define DEMO_LIST_ITEM_8 {8, "测试项目2", LIST_ITEM_ENUM, {0, 0, 2 }, {0, 0, 0 }, s_arrszEnumedValue} +#define DEMO_LIST_ITEM_9 {9, "测试项目3", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} /* Screen 3: Text notice box. */ /* List notice text format. */ @@ -45,4 +45,4 @@ #define DEMO_VARIABLE_BOX_TITLE ("数值/文本编辑演示") #define DEMO_VARIABLE_BOX_HELPER ("TAB键切换焦点编辑框。\n上下箭头调整数值。\n左右箭头调整焦点字符。\n按空格键继续。") -#endif // __INCLUDE_DEMO_RESOURCE_UTF8_H__ +#endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_