mirror of
https://gitee.com/Polarix/simplegui.git
synced 2025-06-18 05:57:53 +00:00
2019-12-01:
修改文字显示为资源模式。 其他控件同步整理中。
This commit is contained in:
parent
02d7fdc004
commit
7ce09f624b
@ -4,7 +4,7 @@
|
|||||||
/* Screen 1: Multiple lines text. */
|
/* Screen 1: Multiple lines text. */
|
||||||
/* Start screen scroll text. */
|
/* Start screen scroll text. */
|
||||||
#define DEMO_START_NOTICE (\
|
#define DEMO_START_NOTICE (\
|
||||||
"welcom to SimpleGUI demo process, ti will show you how \
|
"Welcom to SimpleGUI demo process, it will show you how \
|
||||||
to use GUI to show and deal some user action with HMI \
|
to use GUI to show and deal some user action with HMI \
|
||||||
interfacce.\n\
|
interfacce.\n\
|
||||||
This program uses a uart port to simulate user interaction. \
|
This program uses a uart port to simulate user interaction. \
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
//= Static variable declaration. =//
|
//= Static variable declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
SGUI_SCR_DEV g_stDeviceInterface;
|
SGUI_SCR_DEV g_stDeviceInterface;
|
||||||
|
#if 0
|
||||||
HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] =
|
HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] =
|
||||||
{
|
{
|
||||||
&g_stHMIDemo_ScrollingText,
|
&g_stHMIDemo_ScrollingText,
|
||||||
@ -33,6 +34,7 @@ HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] =
|
|||||||
&g_stHMIDemo_VariableBox,
|
&g_stHMIDemo_VariableBox,
|
||||||
&g_stHMI_DemoRealtimeGraph,
|
&g_stHMI_DemoRealtimeGraph,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
HMI_ENGINE_OBJECT g_stDemoEngine;
|
HMI_ENGINE_OBJECT g_stDemoEngine;
|
||||||
|
|
||||||
#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||||
@ -82,8 +84,8 @@ HMI_ENGINE_RESULT InitializeHMIEngineObj(void)
|
|||||||
SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
|
SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
|
||||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||||
/* Initialize display size. */
|
/* Initialize display size. */
|
||||||
g_stDeviceInterface.stSize.Width = 128;
|
g_stDeviceInterface.stSize.iWidth = 128;
|
||||||
g_stDeviceInterface.stSize.Height = 64;
|
g_stDeviceInterface.stSize.iHeight = 64;
|
||||||
/* Initialize interface object. */
|
/* Initialize interface object. */
|
||||||
g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel;
|
g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel;
|
||||||
g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel;
|
g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel;
|
||||||
@ -91,15 +93,15 @@ HMI_ENGINE_RESULT InitializeHMIEngineObj(void)
|
|||||||
g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay;
|
g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay;
|
||||||
#else
|
#else
|
||||||
/* Initialize display size. */
|
/* Initialize display size. */
|
||||||
g_stDeviceInterface.stSize.Width = 128;
|
g_stDeviceInterface.stSize.iWidth = 128;
|
||||||
g_stDeviceInterface.stSize.Height = 64;
|
g_stDeviceInterface.stSize.iHeight = 64;
|
||||||
/* Initialize interface object. */
|
/* Initialize interface object. */
|
||||||
g_stDeviceInterface.fnSetPixel = OLED_SetPixel;
|
g_stDeviceInterface.fnSetPixel = OLED_SetPixel;
|
||||||
g_stDeviceInterface.fnGetPixel = OLED_GetPixel;
|
g_stDeviceInterface.fnGetPixel = OLED_GetPixel;
|
||||||
g_stDeviceInterface.fnClear = OLED_ClearDisplay;
|
g_stDeviceInterface.fnClear = OLED_ClearDisplay;
|
||||||
g_stDeviceInterface.fnSyncBuffer = OLED_RefreshScreen;
|
g_stDeviceInterface.fnSyncBuffer = OLED_RefreshScreen;
|
||||||
#endif
|
#endif
|
||||||
|
#if 0
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Prepare HMI engine object. */
|
/* Prepare HMI engine object. */
|
||||||
@ -143,6 +145,9 @@ HMI_ENGINE_RESULT InitializeHMIEngineObj(void)
|
|||||||
}while(0);
|
}while(0);
|
||||||
|
|
||||||
return eProcessResult;
|
return eProcessResult;
|
||||||
|
#else
|
||||||
|
return HMI_RET_NORMAL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||||
@ -186,6 +191,11 @@ bool CheckEventFlag(ENV_FLAG_INDEX eIndex)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void DemoMainProcess(void)
|
void DemoMainProcess(void)
|
||||||
{
|
{
|
||||||
|
SGUI_RECT_AREA stDisplayArea = {15, 15, 50, 8};
|
||||||
|
SGUI_POINT stInnerPos = {-4, 0};
|
||||||
|
SGUI_AREA_SIZE stAreaSize;
|
||||||
|
char szTempBuffer[100] = {0x00};
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
@ -195,8 +205,52 @@ void DemoMainProcess(void)
|
|||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
|
//SGUI_Basic_DrawLine(&g_stDeviceInterface, 2, 2, 40, 40, SGUI_COLOR_FRGCLR);
|
||||||
|
SGUI_Basic_DrawRectangle(&g_stDeviceInterface, 1, 1, 126, 10, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
|
||||||
|
stDisplayArea.iPosX = 2;
|
||||||
|
stDisplayArea.iPosY = 2;
|
||||||
|
stDisplayArea.iWidth = 124;
|
||||||
|
stDisplayArea.iHeight = 8;
|
||||||
|
stInnerPos.iPosX = 0;
|
||||||
|
stInnerPos.iPosY = 0;
|
||||||
|
SGUI_Text_DrawText(&g_stDeviceInterface, "This is text form SGUI_DEFAULT_FONT_8", &SGUI_DEFAULT_FONT_8, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
|
SGUI_Basic_DrawRectangle(&g_stDeviceInterface, 1, 12, 126, 14, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
|
||||||
|
stDisplayArea.iPosX = 2;
|
||||||
|
stDisplayArea.iPosY = 13;
|
||||||
|
stDisplayArea.iWidth = 124;
|
||||||
|
stDisplayArea.iHeight = 12;
|
||||||
|
stInnerPos.iPosX = 5;
|
||||||
|
stInnerPos.iPosY = 0;
|
||||||
|
SGUI_Text_GetTextExtent("123ABC", &SGUI_DEFAULT_FONT_12, &stAreaSize);
|
||||||
|
sprintf(szTempBuffer, "Size is (%d, %d).", stAreaSize.iWidth, stAreaSize.iHeight);
|
||||||
|
SGUI_Text_DrawText(&g_stDeviceInterface, szTempBuffer, &SGUI_DEFAULT_FONT_12, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
|
SGUI_Basic_DrawRectangle(&g_stDeviceInterface, 1, 27, 126, 18, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
|
||||||
|
stDisplayArea.iPosX = 2;
|
||||||
|
stDisplayArea.iPosY = 28;
|
||||||
|
stDisplayArea.iWidth = 124;
|
||||||
|
stDisplayArea.iHeight = 16;
|
||||||
|
stInnerPos.iPosX = 0;
|
||||||
|
stInnerPos.iPosY = 0;
|
||||||
|
SGUI_Text_DrawText(&g_stDeviceInterface, "Pixel 16 font source.", &SGUI_DEFAULT_FONT_16, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
|
stDisplayArea.iPosX = -10;
|
||||||
|
stDisplayArea.iPosY = 0;
|
||||||
|
stDisplayArea.iWidth = 64;
|
||||||
|
stDisplayArea.iHeight = 64;
|
||||||
|
SGUI_Text_DrawMultipleLinesText(&g_stDeviceInterface, DEMO_START_NOTICE, &SGUI_DEFAULT_FONT_8, &stDisplayArea, -0, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
|
stDisplayArea.iPosX = 64;
|
||||||
|
stDisplayArea.iPosY = 0;
|
||||||
|
stDisplayArea.iWidth = 64;
|
||||||
|
stDisplayArea.iHeight = 64;
|
||||||
|
SGUI_Text_DrawMultipleLinesText(&g_stDeviceInterface, DEMO_START_NOTICE, &SGUI_DEFAULT_FONT_8, &stDisplayArea, -0, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
|
g_stDeviceInterface.fnSyncBuffer();
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Check and process heart-beat timer event.
|
// Check and process heart-beat timer event.
|
||||||
if(true == SysTickTimerTriggered())
|
if(true == SysTickTimerTriggered())
|
||||||
{
|
{
|
||||||
@ -212,6 +266,7 @@ void DemoMainProcess(void)
|
|||||||
{
|
{
|
||||||
RTCEventProc();
|
RTCEventProc();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_SCR_DEV* pstIFObj, HMI_EN
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Static variable declaration. =//
|
//= Static variable declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
static SGUI_CSZSTR s_szListTitle = DEMO_LIST_TITLE;
|
static SGUI_CSZSTR s_szListTitle = NULL;//DEMO_LIST_TITLE;
|
||||||
static SGUI_CSZSTR s_arrszNoticeType[] = { DEMO_LIST_ITEM_NOTICE_TEXT, DEMO_LIST_ITEM_NOTICE_TIME};
|
static SGUI_CSZSTR s_arrszNoticeType[] = { DEMO_LIST_ITEM_NOTICE_TEXT, DEMO_LIST_ITEM_NOTICE_TIME};
|
||||||
#ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_
|
#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_arrszEnumedValue[] = { DEMO_LIST_ITEM_ENUM_VALUE1, DEMO_LIST_ITEM_ENUM_VALUE2, DEMO_LIST_ITEM_ENUM_VALUE3};
|
||||||
@ -87,12 +87,12 @@ HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstIFObj)
|
|||||||
// Initialize list data.
|
// Initialize list data.
|
||||||
SGUI_SystemIF_MemorySet(&s_stDemoListObject, 0x00, sizeof(SGUI_List_STRUCT));
|
SGUI_SystemIF_MemorySet(&s_stDemoListObject, 0x00, sizeof(SGUI_List_STRUCT));
|
||||||
// Title and font size must set before initialize list object.
|
// Title and font size must set before initialize list object.
|
||||||
s_stDemoListObject.Data.Rect.PosX = 0;
|
s_stDemoListObject.Data.Rect.PosX = 5;
|
||||||
s_stDemoListObject.Data.Rect.PosY = 0;
|
s_stDemoListObject.Data.Rect.PosY = 5;
|
||||||
s_stDemoListObject.Data.Rect.Width = RECT_WIDTH(pstIFObj->stSize);
|
s_stDemoListObject.Data.Rect.Width = 96;//RECT_WIDTH(pstIFObj->stSize);
|
||||||
s_stDemoListObject.Data.Rect.Height = RECT_HEIGHT(pstIFObj->stSize);
|
s_stDemoListObject.Data.Rect.Height = 48; //RECT_HEIGHT(pstIFObj->stSize);
|
||||||
s_stDemoListObject.Data.Title = s_szListTitle;
|
s_stDemoListObject.Data.Title = s_szListTitle;
|
||||||
s_stDemoListObject.FontSize = SGUI_FONT_SIZE_H12;
|
s_stDemoListObject.FontRes = &SGUI_DEFAULT_FONT;
|
||||||
#ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_
|
#ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_
|
||||||
s_stDemoListObject.Data.Items = NULL;
|
s_stDemoListObject.Data.Items = NULL;
|
||||||
s_stDemoListObject.Data.Count = 0;
|
s_stDemoListObject.Data.Count = 0;
|
||||||
|
@ -68,7 +68,7 @@ HMI_ENGINE_RESULT HMI_DemoRTCNotice_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const
|
|||||||
sprintf(s_szRTCNoticeText, DEMO_RTC_NOTICE_TEXT_FMT,
|
sprintf(s_szRTCNoticeText, DEMO_RTC_NOTICE_TEXT_FMT,
|
||||||
stRTCTime.Year, stRTCTime.Month, stRTCTime.Day,
|
stRTCTime.Year, stRTCTime.Month, stRTCTime.Day,
|
||||||
stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second);
|
stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second);
|
||||||
SGUI_Notice_Repaint(pstIFObj, s_szRTCNoticeText, SGUI_FONT_SIZE_H12, 0, SGUI_ICON_INFORMATION);
|
SGUI_Notice_Repaint(pstIFObj, s_szRTCNoticeText, &SGUI_DEFAULT_FONT, 0, SGUI_ICON_INFORMATION);
|
||||||
return HMI_RET_NORMAL;
|
return HMI_RET_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const
|
|||||||
stTextDisplayArea.Height = 8;
|
stTextDisplayArea.Height = 8;
|
||||||
stTextDataArea.PosX = 0;
|
stTextDataArea.PosX = 0;
|
||||||
stTextDataArea.PosY = 0;
|
stTextDataArea.PosY = 0;
|
||||||
SGUI_Text_DrawSingleLineText(pstIFObj, "Real-time graph", SGUI_FONT_SIZE_H8, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL);
|
SGUI_Text_DrawSingleLineText(pstIFObj, "Real-time graph", &SGUI_DEFAULT_FONT, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL);
|
||||||
// Paint value.
|
// Paint value.
|
||||||
SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, -15, ' ');
|
SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, -15, ' ');
|
||||||
stTextDisplayArea.PosX = 1;
|
stTextDisplayArea.PosX = 1;
|
||||||
@ -87,7 +87,7 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const
|
|||||||
stTextDisplayArea.Height = 8;
|
stTextDisplayArea.Height = 8;
|
||||||
stTextDataArea.PosX = 0;
|
stTextDataArea.PosX = 0;
|
||||||
stTextDataArea.PosY = 0;
|
stTextDataArea.PosY = 0;
|
||||||
SGUI_Text_DrawSingleLineText(pstIFObj, szTextBuffer, SGUI_FONT_SIZE_H8, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL);
|
SGUI_Text_DrawSingleLineText(pstIFObj, szTextBuffer, &SGUI_DEFAULT_FONT, &stTextDisplayArea, &stTextDataArea, SGUI_DRAW_NORMAL);
|
||||||
SGUI_RealtimeGraph_Repaint(pstIFObj, &s_stRealtimeGraph);
|
SGUI_RealtimeGraph_Repaint(pstIFObj, &s_stRealtimeGraph);
|
||||||
return HMI_RET_NORMAL;
|
return HMI_RET_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = {
|
|||||||
HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(SGUI_SCR_DEV* Interface)
|
HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(SGUI_SCR_DEV* Interface)
|
||||||
{
|
{
|
||||||
s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT(Interface->stSize);
|
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[SCROLL_TEXT_FONT_SIZE].Width))*g_stFontSize[SCROLL_TEXT_FONT_SIZE].Height;
|
s_iTextHeight = SGUI_Text_GetMultiLineTextLines(s_szDemoText, (HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(Interface->stSize)/SGUI_DEFAULT_FONT.iHalfWidth))*SGUI_DEFAULT_FONT.iHeight;
|
||||||
s_stTextDisplayArea.PosX = HMI_TEXT_DEMO_FRAME_TEXT_POSX;
|
s_stTextDisplayArea.PosX = HMI_TEXT_DEMO_FRAME_TEXT_POSX;
|
||||||
s_stTextDisplayArea.PosY = HMI_TEXT_DEMO_FRAME_TEXT_POSY;
|
s_stTextDisplayArea.PosY = HMI_TEXT_DEMO_FRAME_TEXT_POSY;
|
||||||
s_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(Interface->stSize);
|
s_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH(Interface->stSize);
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
### 3.4. Unicode编码
|
### 3.4. Unicode编码
|
||||||
  由于ANSI无法表达特定的编码,在跨地域时乱码的问题几乎无可避免,这就催生了Unicoed,这种一个联合编码集,意在使用一个字符集表达世界上所有语言所包含的所有书面符号(甚至是同一汉字的不同写法,如“户”和“戸”等),且每一个符号都有自己唯一的编码,这样一来,乱码的问题就迎刃而解了。
|
  由于ANSI无法表达特定的编码,在跨地域时乱码的问题几乎无可避免,这就催生了Unicoed,这种一个联合编码集,意在使用一个字符集表达世界上所有语言所包含的所有书面符号(甚至是同一汉字的不同写法,如“户”和“戸”等),且每一个符号都有自己唯一的编码,这样一来,乱码的问题就迎刃而解了。
|
||||||
  Unicode码使用3字节的长度表达一个字符,最高字节为平面(Panel)索引,范围为0x00\~0x10(十进制17),低两字节为字符码,表达范围为0\~65535。也就是说,Unicode编码的表达范围为0x000000\~0x10FFFF。
|
  Unicode码使用3字节的长度表达一个字符,最高字节为平面(Panel)索引,范围为0x00~0x10(十进制17),低两字节为字符码,表达范围为0~65535。也就是说,Unicode编码的表达范围为0x000000~0x10FFFF。
|
||||||
  其他Unicode编码的细节,网上有详细介绍,不作详述。
|
  其他Unicode编码的细节,网上有详细介绍,不作详述。
|
||||||
|
|
||||||
### 3.5. UTF-8的编码与解码
|
### 3.5. UTF-8的编码与解码
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
如何移植SimpleGUI
|
<h1 id="0">目录</h1>
|
||||||
|
|
||||||
|
* [1. 概述](#1)
|
||||||
|
* [2. 向STM32F103平台上移植Demo程序](#2)
|
||||||
|
* [3. 从“Hello world”开始](#3)
|
||||||
|
* [4. HMI交互模型](#4)
|
||||||
|
* [5. 联系开发者](#5)
|
||||||
---
|
---
|
||||||
## 简介
|
<h2 id="1">1. 概述</h2>
|
||||||
|
|
||||||
  为了方便大家学习和使用SimpleGUI,我对Demo程序向STM32F103芯片上进行了移植并保留了工程代码,本文将演示如何搭建并使用这个工程。
|
  为了方便大家学习和使用SimpleGUI,我对Demo程序向STM32F103芯片上进行了移植并保留了工程代码,本文将演示如何搭建并使用这个工程。
|
||||||
|
|
||||||
## 2. 向STM32F103平台上移植Demo程序。
|
<返回到[目录](#0)/[标题](#1)>
|
||||||
|
|
||||||
|
<h2 id="2">2. 向STM32F103平台上移植Demo程序</h2>
|
||||||
|
|
||||||
#### 2.1. 概述。
|
#### 2.1. 概述。
|
||||||
|
|
||||||
@ -14,11 +22,9 @@
|
|||||||
|
|
||||||
#### 2.2. 准备工程模板
|
#### 2.2. 准备工程模板
|
||||||
|
|
||||||
  在移植和使用Demo程序之前,请先依照个人习惯,创建一个空白的STM32F103工程。工程中请不要包含诸如串口重定向等的代码实现,以避免意料之外的错误。
|
  在移植和使用Demo程序之前,请先依照个人习惯,创建一个空白的STM32F103工程。工程中请不要包含诸如串口重定向等的代码实现,以避免不必要的编译错误。
|
||||||
|
|
||||||
  由于演示工程中包含GB2312的字库,所以编译后体积较大,请大家在移植时,最好使用STM32F103VE/ZE芯片,以确保Flash资源的充足。
|
  由于演示工程中包含GB2312的字库,所以编译后体积较大,请大家在移植时,最好使用STM32F103VE/ZE芯片,以确保Flash资源的充足。当然,这并不是硬性需求,如果您确实需要在少资源的芯片中运行,后续将有介绍如何使Demo运行于诸如STM32F103C8这样的资源相对较少的芯片,毕竟SimpleGUI本身对系统资源的消耗并不高。
|
||||||
|
|
||||||
  当然,这并不是硬性需求,如果您确实需要在少资源的芯片中运行,后续将有介绍如何使Demo运行于诸如STM32F103C8这样的资源相对较少的芯片,毕竟SimpleGUI本身对系统资源的消耗并不高。
|
|
||||||
|
|
||||||
#### 2.3. 移植Demo程序。
|
#### 2.3. 移植Demo程序。
|
||||||
|
|
||||||
@ -82,13 +88,13 @@ OLED_RST---------PB10
|
|||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
  由于包含有12像素和16像素的中文字库,所以编译的程序比较大,这也就是为什么选用STM32F103VE/ZE这样的大容量芯片运行Demo的原因了。接下来将程序下载到芯片,下载方式请根据用户自己的硬件设备环境决定,下载完成后,OLED显示屏上就可以看到显示内容了。
|
  由于包含有12像素和16像素的中文字库,所以编译的程序比较大,这也就是为什么选用STM32F103VE/ZE这样的大容量芯片运行Demo的原因了。接下来将程序下载到芯片,下载完成后,OLED显示屏上就可以看到显示内容了。
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
#### 2.4. Demo程序的交互。
|
#### 2.4. Demo程序的交互。
|
||||||
|
|
||||||
  为了确保所有尝试使用和学习的朋友都能以最快速,最便捷的方式体验和使用SimpleGUI,Demo程序使用串口来模拟键盘进行Demo程序的交互,以此来避免大家在使用不同开发板或最小系统时,因为硬件原因导致交互实现起来困难的尴尬。
|
  为了确保所有尝试使用和学习SimpleGUI的朋友都能以最快速,最便捷的方式体验和使用SimpleGUI,Demo程序使用串口来模拟键盘进行Demo程序的交互,以此来避免在使用不同开发板或最小系统时,因为硬件原因导致交互实现起来困难的尴尬。
|
||||||
  完成前文描述的移植操作并成功烧录到芯片中运行,在确保芯片的串口正确连接到电脑后,就可以尝试与SimpleGUI的Demo程序进行交互了。在此之前,请准保好一个您习惯使用的串口调试软件,但此软件需要支持发送十六进制数据。
|
  完成前文描述的移植操作并成功烧录到芯片中运行,在确保芯片的串口正确连接到电脑后,就可以尝试与SimpleGUI的Demo程序进行交互了。在此之前,请准保好一个您习惯使用的串口调试软件,但此软件需要支持发送十六进制数据。
|
||||||
  基于前文的操作,确保芯片硬件系统处于上电运行状态,显示屏上滚动显示关于SimpleGUI的简介内容。此时使用串口发送十六进制数据0x0020模拟空格按键操作,此时何以看到,SimpleGUI的Demo程序已经显示列表画面了。
|
  基于前文的操作,确保芯片硬件系统处于上电运行状态,显示屏上滚动显示关于SimpleGUI的简介内容。此时使用串口发送十六进制数据0x0020模拟空格按键操作,此时何以看到,SimpleGUI的Demo程序已经显示列表画面了。
|
||||||
|
|
||||||
@ -146,9 +152,29 @@ OLED_RST---------PB10
|
|||||||
>
|
>
|
||||||
|
|
||||||
  为了兼容在VirtualSDK中运行、片上全字库运行和片上精简字库运行等多种情况,Demo程序中使用了DemoResource_UTF8.h、DemoResource_GB2312.h和DemoResource_ASCII.h三个文件作为显示用的资源文件,Demo程序中显示的文字均为同名不同内容的宏定义,在不同环境下根据不同的宏开关、引用不同的文件来实现切换不同显示内容的效果。
|
  为了兼容在VirtualSDK中运行、片上全字库运行和片上精简字库运行等多种情况,Demo程序中使用了DemoResource_UTF8.h、DemoResource_GB2312.h和DemoResource_ASCII.h三个文件作为显示用的资源文件,Demo程序中显示的文字均为同名不同内容的宏定义,在不同环境下根据不同的宏开关、引用不同的文件来实现切换不同显示内容的效果。
|
||||||
  为了避免不同情况下的乱码,在VirtualSDK中运行时,使用的资源文件是DemoResource_UTF8.h,运行时通过iconv转换库将字符串转换为GB2312编码再进行解码和显示。 而由于在芯片上运行全字库时,由于没有足够的资源保存转码库的资源,所以使用DemoResource_GB2312.h文件,此文件本身就以GB2312形式保存无需转码,壳直接解码,而使用精简字库时,由于只有ASCII文字,所以使用DemoResource_ASCII.h文件,使界面显示英语,不使用中文字库。
|
  为了避免不同情况下的乱码,在VirtualSDK中运行时,使用的资源文件是DemoResource_UTF8.h,运行时通过iconv转换库将字符串转换为GB2312编码再进行解码和显示。 而由于在芯片上运行全字库时,由于没有足够的资源保存转码库的资源,所以使用DemoResource_GB2312.h文件,此文件本身就以GB2312形式保存,无需转码。而使用精简字库时,由于只有ASCII文字,所以使用DemoResource_ASCII.h文件,使界面显示英语,不使用中文字库。
|
||||||
|
|
||||||
|
<返回到[目录](#0)/[标题](#2)>
|
||||||
|
|
||||||
|
<h2 id="3">3. 从“Hello world”开始</h2>
|
||||||
|
|
||||||
|
#### 3.1准备驱动程序
|
||||||
|
  由于SimpleGUI本身不提供屏幕设备的驱动程序,而是借助既有的硬件设备接口组织基础的绘制操作,所以在使用SimpleGUI之前,需要开发者自行准备好屏幕设备的驱动函数。至少准备好“初始化”、“读像素”和“写像素”两个函数,函数的原型需要严格按照以下形式声明和定义。
|
||||||
|
```
|
||||||
|
void OLED_Initialize(void);
|
||||||
|
void OLED_SetPixel(int iPosX, int iPosY, int iColor);
|
||||||
|
int OLED_GetPixel(int iPosX, int iPosY);
|
||||||
|
```
|
||||||
|
  
|
||||||
|
|
||||||
|
<返回到[目录](#0)/[标题](#3)>
|
||||||
|
|
||||||
|
<h2 id="3">4. HMI交互模型</h2>
|
||||||
|
|
||||||
|
<返回到[目录](#0)/[标题](#4)>
|
||||||
|
|
||||||
|
<h2 id="3">5. 联系开发者</h2>
|
||||||
|
|
||||||
### 4. 联系开发者
|
|
||||||
  首先,感谢您对SimpleGUI的赏识与支持。
|
  首先,感谢您对SimpleGUI的赏识与支持。
|
||||||
  虽然最早仅仅作为一套GUI接口库使用,但我最终希望SimpleGUI能够为您提供一套完整的单色屏GUI及交互设计解决方案,如果您有新的需求、提议亦或想法,欢迎在以下地址留言,或加入[QQ交流群799501887](https://jq.qq.com/?_wv=1027&k=5ahGPvK)留言交流。
|
  虽然最早仅仅作为一套GUI接口库使用,但我最终希望SimpleGUI能够为您提供一套完整的单色屏GUI及交互设计解决方案,如果您有新的需求、提议亦或想法,欢迎在以下地址留言,或加入[QQ交流群799501887](https://jq.qq.com/?_wv=1027&k=5ahGPvK)留言交流。
|
||||||
>SimpleGUI@开源中国:https://www.oschina.net/p/simplegui
|
>SimpleGUI@开源中国:https://www.oschina.net/p/simplegui
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define BASIC_FONT_WIDTH (6)
|
#define BASIC_FONT_WIDTH (6)
|
||||||
#define BASIC_FONT_CHAR_DATA_SIZE (((BASIC_FONT_HEIGHT-1)/8)+1)*BASIC_FONT_WIDTH
|
#define BASIC_FONT_CHAR_DATA_SIZE (((BASIC_FONT_HEIGHT-1)/8)+1)*BASIC_FONT_WIDTH
|
||||||
#define BASIC_FONT_DATA (SGUI_BASIC_FONT_H8)
|
#define BASIC_FONT_DATA (SGUI_BASIC_FONT_H8)
|
||||||
|
#define SGUI_USED_BYTE(V) (((V-1)/8)+1)
|
||||||
|
|
||||||
//Bitmap(include font) data bit operation
|
//Bitmap(include font) data bit operation
|
||||||
#define SGUI_SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit)))
|
#define SGUI_SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit)))
|
||||||
@ -39,6 +40,6 @@ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstIFObj, SGUI_INT uiStartX, SGUI_INT
|
|||||||
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);
|
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);
|
||||||
void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCx, SGUI_UINT uiCy, SGUI_UINT uiRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor);
|
void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiCx, SGUI_UINT uiCy, SGUI_UINT uiRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor);
|
||||||
void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_UINT uiWidth, SGUI_UINT uiHeight);
|
void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_UINT uiWidth, SGUI_UINT uiHeight);
|
||||||
void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayArea, SGUI_RECT_AREA* pstDataArea, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adDataStartAddr, SGUI_DRAW_MODE eDrawMode);
|
void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstDataArea, SGUI_BMP_RES* pstBitmapData, SGUI_DRAW_MODE eDrawMode);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Public function declaration. =//
|
//= Public function declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
void SGUI_Common_AdaptDisplayInfo(SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos);
|
||||||
SGUI_SIZE SGUI_Common_IntegerToStringWithDecimalPoint(SGUI_INT iInteger, SGUI_UINT uiDecimalPlaces, SGUI_SZSTR pszStringBuffer, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter);
|
SGUI_SIZE SGUI_Common_IntegerToStringWithDecimalPoint(SGUI_INT iInteger, SGUI_UINT uiDecimalPlaces, SGUI_SZSTR pszStringBuffer, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter);
|
||||||
SGUI_SIZE SGUI_Common_IntegerToString(SGUI_INT iInteger, SGUI_SZSTR pszStringBuffer, SGUI_UINT uiBase, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter);
|
SGUI_SIZE SGUI_Common_IntegerToString(SGUI_INT iInteger, SGUI_SZSTR pszStringBuffer, SGUI_UINT uiBase, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter);
|
||||||
SGUI_UINT SGUI_Common_ConvertStringToUnsignedInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase);
|
SGUI_UINT SGUI_Common_ConvertStringToUnsignedInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase);
|
||||||
|
@ -20,6 +20,6 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Used for SimpleGUI demo process. =//
|
//= Used for SimpleGUI demo process. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
#define _SIMPLE_GUI_NON_ASCII_
|
//#define _SIMPLE_GUI_NON_ASCII_
|
||||||
|
|
||||||
#endif // _INCLUDE_SIMPLE_GUI_CONFIG_H_
|
#endif // _INCLUDE_SIMPLE_GUI_CONFIG_H_
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Public variable declaration. =//
|
//= Public variable declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_8;
|
||||||
|
extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_12;
|
||||||
|
extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_16;
|
||||||
//#ifdef _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_
|
//#ifdef _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_
|
||||||
extern const SGUI_CBYTE SGUI_FONT_H8[];
|
extern const SGUI_CBYTE SGUI_FONT_H8[];
|
||||||
extern const SGUI_CBYTE SGUI_FONT_H12[];
|
extern const SGUI_CBYTE SGUI_FONT_H12[];
|
||||||
extern const SGUI_CBYTE SGUI_FONT_H16[];
|
extern const SGUI_CBYTE SGUI_FONT_H16[];
|
||||||
extern const SGUI_CBYTE SGUI_FONT_H32[];
|
|
||||||
extern const SGUI_CBYTE SGUI_NOTICE_ICON_DATA[];
|
extern const SGUI_CBYTE SGUI_NOTICE_ICON_DATA[];
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
@ -49,6 +49,5 @@ SGUI_SIZE SGUI_SystemIF_StringLength(SGUI_CSZSTR szString);
|
|||||||
SGUI_SZSTR SGUI_SystemIF_StringCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc);
|
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);
|
SGUI_SZSTR SGUI_SystemIF_StringLengthCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc, SGUI_SIZE sSize);
|
||||||
void SGUI_SystemIF_GetNowTime(SGUI_TIME* pstTime);
|
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);
|
|
||||||
|
|
||||||
#endif // __INCLUDED_SGUI_INTERFACE_H__
|
#endif // __INCLUDED_SGUI_INTERFACE_H__
|
||||||
|
@ -74,7 +74,7 @@ typedef struct
|
|||||||
SGUI_List_DATA Data;
|
SGUI_List_DATA Data;
|
||||||
SGUI_List_CONTROL ControlVariable;
|
SGUI_List_CONTROL ControlVariable;
|
||||||
SGUI_List_SUBELEMENT SubElement;
|
SGUI_List_SUBELEMENT SubElement;
|
||||||
SGUI_FONT_SIZE FontSize;
|
const SGUI_FONT_RES* FontRes;
|
||||||
}SGUI_List_STRUCT;
|
}SGUI_List_STRUCT;
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
@ -15,18 +15,10 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Data type definition. =//
|
//= Data type definition. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SGUI_ICON_ERROR = 0,
|
|
||||||
SGUI_ICON_INFORMATION,
|
|
||||||
SGUI_ICON_QUESTION,
|
|
||||||
SGUI_ICON_WARNING,
|
|
||||||
SGUI_ICON_NONE,
|
|
||||||
}SGUI_NOTICE_ICON_IDX;
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Public function declaration. =//
|
//= Public function declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, SGUI_FONT_SIZE iFontSize, SGUI_INT uiTextOffset, SGUI_NOTICE_ICON_IDX eIcon);
|
SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, const SGUI_FONT_RES* pstFontRes, SGUI_INT uiTextOffset, SGUI_NOTICE_ICON_IDX eIcon);
|
||||||
|
|
||||||
#endif // __INCLUDE_GUI_NOTICE_H__
|
#endif // __INCLUDE_GUI_NOTICE_H__
|
||||||
|
@ -10,47 +10,27 @@
|
|||||||
//= User Macro definition. =//
|
//= User Macro definition. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
#define FONT_LIB_ADDR 0X00000
|
#define FONT_LIB_ADDR 0X00000
|
||||||
#define FONT_LIB_OFFSET_ASCII (-32)
|
|
||||||
#define FONT_LIB_OFFSET_GB2312_SYMBOL (95)
|
|
||||||
#define FONT_LIB_OFFSET_GB2312_CHARL1 (659)
|
|
||||||
// Max font size is 64 pix, maximum of font data size is 64 * 8 = 512 Bytes.
|
// Max font size is 64 pix, maximum of font data size is 64 * 8 = 512 Bytes.
|
||||||
#define FONT_DATA_BUFFER_SIZE (512)
|
|
||||||
#define TEXT_NUMBER_STR_LENGTH_MAX (12)
|
#define TEXT_NUMBER_STR_LENGTH_MAX (12)
|
||||||
#define TEXT_PLACEHOLDER_CHARACTER ('*')
|
#define TEXT_PLACEHOLDER_CHARACTER ('*')
|
||||||
|
#define SGUI_IS_VISIBLE_CHAR(C) ((C>0x1F) && (C<0x7F))
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Data type definition. =//
|
//= Data type definition. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
const SGUI_UINT16 Size;
|
|
||||||
const SGUI_UINT16 Width;
|
|
||||||
const SGUI_UINT16 Height;
|
|
||||||
const SGUI_UINT16 HalfCharDataSize;
|
|
||||||
}SGUI_FONT_SIZE_STRUCT;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SGUI_FONT_SIZE_H6 = 0,
|
|
||||||
SGUI_FONT_SIZE_H8,
|
|
||||||
SGUI_FONT_SIZE_H12,
|
|
||||||
SGUI_FONT_SIZE_H16,
|
|
||||||
SGUI_FONT_SIZE_H24,
|
|
||||||
SGUI_FONT_SIZE_H32,
|
|
||||||
SGUI_FONT_SIZE_MAX,
|
|
||||||
}SGUI_FONT_SIZE;
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Public variable declaration. =//
|
//= Public variable declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
extern const SGUI_FONT_SIZE_STRUCT g_stFontSize[];
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Public function declaration. =//
|
//= Public function declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
void SGUI_Text_DrawSingleLineText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szTextBuffer, SGUI_FONT_SIZE eFontSize, SGUI_RECT_AREA* pstDisplayArea, SGUI_RECT_AREA* pstStringDataArea, SGUI_DRAW_MODE eFontMode);
|
void SGUI_Text_GetTextExtent(SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_AREA_SIZE* pstTextExtent);
|
||||||
SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szTextBuffer, SGUI_FONT_SIZE eFontSize, SGUI_RECT_AREA* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode);
|
void SGUI_Text_DrawText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_DRAW_MODE eFontMode);
|
||||||
SGUI_SIZE SGUI_Text_GetTextGraphicsWidth(SGUI_CSZSTR szText, SGUI_FONT_SIZE eFontSize);
|
SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT_AREA* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode);
|
||||||
SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR szNoticeText, SGUI_SIZE uiHalfWidthCharInLine);
|
SGUI_SIZE SGUI_Text_GetTextGraphicsWidth(SGUI_CSZSTR szText, const SGUI_FONT_RES* pstFontRes);
|
||||||
|
SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_SIZE uiDisplayAreaWidth);
|
||||||
|
SGUI_SIZE SGUI_Text_GetCharacterData(const SGUI_FONT_RES* pstFontRes, SGUI_UINT32 uiCode, SGUI_BYTE* pDataBuffer, SGUI_SIZE sBufferSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,14 +10,14 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= User Macro definition. =//
|
//= User Macro definition. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
#define RECT_X_START(ST) ((ST).PosX)
|
#define RECT_X_START(ST) ((ST).iPosX)
|
||||||
#define RECT_X_END(ST) (((ST).PosX + (ST).Width - 1))
|
#define RECT_X_END(RC, POS) (((POS).iPosX + (RC).iWidth - 1))
|
||||||
#define RECT_Y_START(ST) ((ST).PosY)
|
#define RECT_Y_START(ST) ((ST).iPosY)
|
||||||
#define RECT_Y_END(ST) (((ST).PosY + (ST).Height - 1))
|
#define RECT_Y_END(RC, POS) (((POS).iPosY + (RC).iHeight - 1))
|
||||||
#define RECT_WIDTH(ST) ((ST).Width)
|
#define RECT_WIDTH(ST) ((ST).iWidth)
|
||||||
#define RECT_HEIGHT(ST) ((ST).Height)
|
#define RECT_HEIGHT(ST) ((ST).iHeight)
|
||||||
#define RECT_VALID_WIDTH(ST) ((RECT_X_START(ST)>0)?RECT_WIDTH(ST):(RECT_WIDTH(ST)+RECT_X_START(ST)))
|
#define RECT_VALID_WIDTH(DATA, POS) ((RECT_X_START(POS)>0)?RECT_WIDTH(DATA):(RECT_WIDTH(DATA)+RECT_X_START(POS)))
|
||||||
#define RECT_VALID_HEIGHT(ST) ((RECT_Y_START(ST)>0)?RECT_HEIGHT(ST):(RECT_HEIGHT(ST)+RECT_Y_START(ST)))
|
#define RECT_VALID_HEIGHT(DATA, POS) ((RECT_Y_START(POS)>0)?RECT_HEIGHT(DATA):(RECT_HEIGHT(DATA)+RECT_Y_START(POS)))
|
||||||
|
|
||||||
#define SGUI_DEVPF_IF_DEFINE(R, FN, PARAM) typedef R(*FN)PARAM
|
#define SGUI_DEVPF_IF_DEFINE(R, FN, PARAM) typedef R(*FN)PARAM
|
||||||
#define SGUI_BMP_DATA_BUFFER_SIZE (512)
|
#define SGUI_BMP_DATA_BUFFER_SIZE (512)
|
||||||
@ -57,22 +57,22 @@ typedef SGUI_UINT32 SGUI_ROM_ADDRESS;
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SGUI_INT PosX;
|
SGUI_INT iPosX;
|
||||||
SGUI_INT PosY;
|
SGUI_INT iPosY;
|
||||||
SGUI_INT Width;
|
SGUI_INT iWidth;
|
||||||
SGUI_INT Height;
|
SGUI_INT iHeight;
|
||||||
}SGUI_RECT_AREA;
|
}SGUI_RECT_AREA;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SGUI_INT Width;
|
SGUI_INT iWidth;
|
||||||
SGUI_INT Height;
|
SGUI_INT iHeight;
|
||||||
}SGUI_AREA_SIZE;
|
}SGUI_AREA_SIZE;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SGUI_INT PosX;
|
SGUI_INT iPosX;
|
||||||
SGUI_INT PosY;
|
SGUI_INT iPosY;
|
||||||
}SGUI_POINT;
|
}SGUI_POINT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -98,25 +98,6 @@ typedef enum
|
|||||||
SGUI_DRAW_REVERSE = 1,
|
SGUI_DRAW_REVERSE = 1,
|
||||||
}SGUI_DRAW_MODE;
|
}SGUI_DRAW_MODE;
|
||||||
|
|
||||||
// Declare data source flag here.
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SGUI_FONT_SRC_NONE = 0,
|
|
||||||
SGUI_FONT_SRC_H6,
|
|
||||||
SGUI_FONT_SRC_H8,
|
|
||||||
SGUI_FONT_SRC_H12,
|
|
||||||
SGUI_FONT_SRC_H16,
|
|
||||||
SGUI_NOTICE_ICON,
|
|
||||||
SGUI_FONT_SRC_UNKNOWN,
|
|
||||||
}SGUI_FLASH_DATA_SOURCE;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SGUI_FLASH_DATA_SOURCE Source;
|
|
||||||
SGUI_ROM_ADDRESS StartAddr;
|
|
||||||
SGUI_SIZE Length;
|
|
||||||
}SGUI_BMP_DATA;
|
|
||||||
|
|
||||||
// Screen device operation interface type declare.
|
// Screen device operation interface type declare.
|
||||||
SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_INITIALIZE, (void));
|
SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_INITIALIZE, (void));
|
||||||
SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_CLEAR, (void));
|
SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_CLEAR, (void));
|
||||||
@ -128,8 +109,10 @@ SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_REFRESH, (void));
|
|||||||
|
|
||||||
// System function interface type declare.
|
// System function interface type declare.
|
||||||
SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_GET_RTC, (SGUI_INT iYear, SGUI_INT iMounth, SGUI_INT iDay, SGUI_INT iWeekDay, SGUI_INT iHour, SGUI_INT iMinute, SGUI_INT iSecond));
|
SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_GET_RTC, (SGUI_INT iYear, SGUI_INT iMounth, SGUI_INT iDay, SGUI_INT iWeekDay, SGUI_INT iHour, SGUI_INT iMinute, SGUI_INT iSecond));
|
||||||
SGUI_DEVPF_IF_DEFINE(SGUI_SIZE, SGUI_FN_IF_READ_FLASH, (SGUI_INT iSourceID, SGUI_ROM_ADDRESS adStartAddr, SGUI_SIZE sReadSize, SGUI_BYTE* pOutputBuffer));
|
SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_CHAR_INDEX, (SGUI_UINT32 uiCode));
|
||||||
SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_CHAR_INDEX, (SGUI_CSZSTR cszSrc));
|
SGUI_DEVPF_IF_DEFINE(SGUI_CSZSTR, SGUI_FN_IF_STEP_NEXT, (SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode));
|
||||||
|
SGUI_DEVPF_IF_DEFINE(SGUI_SIZE, SGUI_FN_IF_GET_DATA, (SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize));
|
||||||
|
SGUI_DEVPF_IF_DEFINE(SGUI_BOOL, SGUI_FN_IF_IS_FULL_WIDTH, (SGUI_UINT32 uiCode));
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -149,4 +132,24 @@ typedef struct
|
|||||||
SGUI_FN_IF_REFRESH fnSyncBuffer;
|
SGUI_FN_IF_REFRESH fnSyncBuffer;
|
||||||
}SGUI_SCR_DEV;
|
}SGUI_SCR_DEV;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SGUI_INT iHeight;
|
||||||
|
SGUI_INT iHalfWidth;
|
||||||
|
SGUI_INT iFullWidth;
|
||||||
|
//SGUI_INT iHorizontalSpacing;
|
||||||
|
//SGUI_INT iVerticalSpacing;
|
||||||
|
SGUI_FN_IF_GET_CHAR_INDEX fnGetIndex;
|
||||||
|
SGUI_FN_IF_GET_DATA fnGetData;
|
||||||
|
SGUI_FN_IF_STEP_NEXT fnStepNext;
|
||||||
|
SGUI_FN_IF_IS_FULL_WIDTH fnIsFullWidth;
|
||||||
|
}SGUI_FONT_RES;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SGUI_INT iHeight;
|
||||||
|
SGUI_INT iWidth;
|
||||||
|
SGUI_BYTE* pData;
|
||||||
|
}SGUI_BMP_RES;
|
||||||
|
|
||||||
#endif // _INCLUDE_GUI_TYPEDEF_H_
|
#endif // _INCLUDE_GUI_TYPEDEF_H_
|
||||||
|
@ -153,6 +153,7 @@ void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstIFObj)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Draw a blank rectangle for clean screen when clean function is not supposed. */
|
||||||
SGUI_Basic_DrawRectangle(pstIFObj, 0, 0, RECT_WIDTH(pstIFObj->stSize), RECT_HEIGHT(pstIFObj->stSize), 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,13 +440,13 @@ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstIFObj, SGUI_UINT uiStartX, SG
|
|||||||
/** Params: **/
|
/** Params: **/
|
||||||
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
||||||
/** @ pstDisplayArea[in]: Display area position and size. **/
|
/** @ pstDisplayArea[in]: Display area position and size. **/
|
||||||
/** @ pstDataArea[in]: Data area size and display offset. **/
|
/** @ pstInnerPos[in]: Data area size and display offset. **/
|
||||||
/** @ pDataBuffer[in]: Bit map data buffer. **/
|
/** @ pstBitmapData[in]: Bitmap object, include size and data. **/
|
||||||
/** @ eDrawMode[in] Bit map display mode(normal or reverse color). **/
|
/** @ eDrawMode[in] Bit map display mode(normal or reverse color). **/
|
||||||
/** Return: None. **/
|
/** Return: None. **/
|
||||||
/** Notice: None. **/
|
/** Notice: None. **/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayArea, SGUI_RECT_AREA* pstDataArea, SGUI_FLASH_DATA_SOURCE eDataSource, SGUI_ROM_ADDRESS adDataStartAddr, SGUI_DRAW_MODE eDrawMode)
|
void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_BMP_RES* pstBitmapData, SGUI_DRAW_MODE eDrawMode)
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
@ -454,8 +455,7 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre
|
|||||||
SGUI_INT iBmpPixX, iBmpPixY;
|
SGUI_INT iBmpPixX, iBmpPixY;
|
||||||
SGUI_UINT uiDrawnWidthIndex, uiDrawnHeightIndex;
|
SGUI_UINT uiDrawnWidthIndex, uiDrawnHeightIndex;
|
||||||
SGUI_UINT uiPixIndex;
|
SGUI_UINT uiPixIndex;
|
||||||
SGUI_BYTE* pData;
|
SGUI_BYTE* pData;
|
||||||
SGUI_SIZE sBitmapDataSize;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
@ -468,66 +468,51 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstIFObj, SGUI_RECT_AREA* pstDisplayAre
|
|||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
// Only draw in visible area of screen.
|
// Only draw in visible area of screen.
|
||||||
if( (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)) && (RECT_Y_START(*pstDisplayArea) < RECT_HEIGHT(pstIFObj->stSize)) &&
|
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))
|
(RECT_X_END(*pstDisplayArea, *pstDisplayArea) > 0) && (RECT_Y_END(*pstDisplayArea, *pstDisplayArea) > 0))
|
||||||
{
|
{
|
||||||
// Recalculate display area and data area.
|
// Adapt text display area and data area.
|
||||||
if(RECT_X_START(*pstDisplayArea) < 0)
|
SGUI_Common_AdaptDisplayInfo(pstDisplayArea, pstInnerPos);
|
||||||
{
|
|
||||||
RECT_X_START(*pstDataArea) += RECT_X_START(*pstDisplayArea);
|
|
||||||
RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea);
|
|
||||||
RECT_X_START(*pstDisplayArea) = 0;
|
|
||||||
}
|
|
||||||
if(RECT_Y_START(*pstDisplayArea) < 0)
|
|
||||||
{
|
|
||||||
RECT_Y_START(*pstDataArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_Y_START(*pstDisplayArea) = 0;
|
|
||||||
}
|
|
||||||
// Only process drawing when valid display data existed
|
// Only process drawing when valid display data existed
|
||||||
if((RECT_VALID_WIDTH(*pstDataArea) > 0) && (RECT_VALID_HEIGHT(*pstDataArea) > 0))
|
if((RECT_VALID_WIDTH(*pstBitmapData, *pstInnerPos) > 0) && (RECT_VALID_HEIGHT(*pstBitmapData, *pstInnerPos) > 0))
|
||||||
{
|
{
|
||||||
// Calculate bitmap data size.
|
|
||||||
sBitmapDataSize = pstDataArea->Width * ((pstDataArea->Height-1)/8+1);
|
|
||||||
// Read flash data.
|
|
||||||
SGUI_SystemIF_GetFlashData(pstIFObj, eDataSource, adDataStartAddr, sBitmapDataSize);
|
|
||||||
// Set loop start parameter of x coordinate
|
// Set loop start parameter of x coordinate
|
||||||
iDrawPixX = RECT_X_START(*pstDisplayArea);
|
iDrawPixX = RECT_X_START(*pstDisplayArea);
|
||||||
iBmpPixX = 0;
|
iBmpPixX = 0;
|
||||||
if(RECT_X_START(*pstDataArea) > 0)
|
if(RECT_X_START(*pstInnerPos) > 0)
|
||||||
{
|
{
|
||||||
iDrawPixX += RECT_X_START(*pstDataArea);
|
iDrawPixX += RECT_X_START(*pstInnerPos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iBmpPixX -= RECT_X_START(*pstDataArea);
|
iBmpPixX -= RECT_X_START(*pstInnerPos);
|
||||||
}
|
}
|
||||||
uiDrawnWidthIndex = iBmpPixX;
|
uiDrawnWidthIndex = iBmpPixX;
|
||||||
// Loop for x coordinate;
|
// Loop for x coordinate;
|
||||||
while((uiDrawnWidthIndex<RECT_WIDTH(*pstDataArea)) && (iDrawPixX<=RECT_X_END(*pstDisplayArea)) && (iDrawPixX<RECT_WIDTH(pstIFObj->stSize)))
|
while((uiDrawnWidthIndex<RECT_WIDTH(*pstBitmapData)) && (iDrawPixX<=RECT_X_END(*pstDisplayArea, *pstDisplayArea)) && (iDrawPixX<RECT_WIDTH(pstIFObj->stSize)))
|
||||||
{
|
{
|
||||||
// Redirect to data array for column.
|
// Redirect to data array for column.
|
||||||
pData = pstIFObj->arrBmpDataBuffer + iBmpPixX;
|
pData = pstBitmapData->pData+iBmpPixX;
|
||||||
// Set loop start parameter of y coordinate
|
// Set loop start parameter of y coordinate
|
||||||
iDrawPixY = RECT_Y_START(*pstDisplayArea);
|
iDrawPixY = RECT_Y_START(*pstDisplayArea);
|
||||||
iBmpPixY = 0;
|
iBmpPixY = 0;
|
||||||
if(RECT_Y_START(*pstDataArea) > 0)
|
if(RECT_Y_START(*pstInnerPos) > 0)
|
||||||
{
|
{
|
||||||
iDrawPixY += RECT_Y_START(*pstDataArea);
|
iDrawPixY += RECT_Y_START(*pstInnerPos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iBmpPixY -= RECT_Y_START(*pstDataArea);
|
iBmpPixY -= RECT_Y_START(*pstInnerPos);
|
||||||
}
|
}
|
||||||
uiDrawnHeightIndex = iBmpPixY;
|
uiDrawnHeightIndex = iBmpPixY;
|
||||||
uiPixIndex = iBmpPixY % 8;
|
uiPixIndex = iBmpPixY % 8;
|
||||||
pData += (iBmpPixY / 8) * RECT_WIDTH(*pstDataArea);
|
pData += (iBmpPixY / 8) * RECT_WIDTH(*pstBitmapData);
|
||||||
// Loop for y coordinate;
|
// Loop for y coordinate;
|
||||||
while((uiDrawnHeightIndex<RECT_HEIGHT(*pstDataArea)) && (iDrawPixY<=RECT_Y_END(*pstDisplayArea)) && (iDrawPixY<RECT_HEIGHT(pstIFObj->stSize)))
|
while((uiDrawnHeightIndex<RECT_HEIGHT(*pstBitmapData)) && (iDrawPixY<=RECT_Y_END(*pstDisplayArea, *pstDisplayArea)) && (iDrawPixY<RECT_HEIGHT(pstIFObj->stSize)))
|
||||||
{
|
{
|
||||||
if(uiPixIndex == 8)
|
if(uiPixIndex == 8)
|
||||||
{
|
{
|
||||||
uiPixIndex = 0;
|
uiPixIndex = 0;
|
||||||
pData += RECT_WIDTH(*pstDataArea);
|
pData += RECT_WIDTH(*pstBitmapData);
|
||||||
}
|
}
|
||||||
if(SGUI_GET_PAGE_BIT(*pData, uiPixIndex) != eDrawMode)
|
if(SGUI_GET_PAGE_BIT(*pData, uiPixIndex) != eDrawMode)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,38 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Function define. =//
|
//= Function define. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
/*************************************************************************/
|
||||||
|
/** Function Name: SGUI_Common_AdaptDisplayInfo **/
|
||||||
|
/** Purpose: Adapt display area data and internal position data **/
|
||||||
|
/** order by display area position and screen size. **/
|
||||||
|
/** Params: **/
|
||||||
|
/** @ pstDisplayArea[in/out]: Display area info. **/
|
||||||
|
/** @ pstInnerPos[in/out]: Display position info in display rectangular **/
|
||||||
|
/** area . **/
|
||||||
|
/** Return: None. **/
|
||||||
|
/** Notice: This function will reset display information on **/
|
||||||
|
/** given data, make sure the display area is within **/
|
||||||
|
/** the screen area. **/
|
||||||
|
/*************************************************************************/
|
||||||
|
void SGUI_Common_AdaptDisplayInfo(SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos)
|
||||||
|
{
|
||||||
|
if((NULL != pstDisplayArea) && (NULL != pstInnerPos))
|
||||||
|
{
|
||||||
|
if(RECT_X_START(*pstDisplayArea) < 0)
|
||||||
|
{
|
||||||
|
RECT_X_START(*pstInnerPos) += RECT_X_START(*pstDisplayArea);
|
||||||
|
RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea);
|
||||||
|
RECT_X_START(*pstDisplayArea) = 0;
|
||||||
|
}
|
||||||
|
if(RECT_Y_START(*pstDisplayArea) < 0)
|
||||||
|
{
|
||||||
|
RECT_Y_START(*pstInnerPos) += RECT_Y_START(*pstDisplayArea);
|
||||||
|
RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea);
|
||||||
|
RECT_Y_START(*pstDisplayArea) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/** Function Name: SGUI_Common_IntegerToStringWithDecimalPoint **/
|
/** Function Name: SGUI_Common_IntegerToStringWithDecimalPoint **/
|
||||||
/** Purpose: Convert number to a string and insert decimal point.**/
|
/** Purpose: Convert number to a string and insert decimal point.**/
|
||||||
|
16281
GUI/src/SGUI_FlashData.c
16281
GUI/src/SGUI_FlashData.c
File diff suppressed because it is too large
Load Diff
@ -449,87 +449,3 @@ SGUI_SZSTR SGUI_SystemIF_StringCopy(SGUI_SZSTR szDest, SGUI_CSZSTR szSrc)
|
|||||||
|
|
||||||
return pcDestPtr;
|
return pcDestPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/** Function Name: SGUI_FlashData_GetFilash **/
|
|
||||||
/** Purpose: Read a byte array form ROM(ex. flash). **/
|
|
||||||
/** Params: **/
|
|
||||||
/** @ 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. **/
|
|
||||||
/** Return: None. **/
|
|
||||||
/** Notice: You can specify a data source by eDataSource parameter, **/
|
|
||||||
/** and it always used when your data is in different ROM **/
|
|
||||||
/** space yet. For example, Font data is in external flash **/
|
|
||||||
/** and bitmap data is in chip. **/
|
|
||||||
/** Text paint and bitmap paint in SimpleGUI are processed **/
|
|
||||||
/** as bitmap yet, so tt is necessary to distinguish data **/
|
|
||||||
/** sources in some cases. **/
|
|
||||||
/** 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)
|
|
||||||
{
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Variable Declaration */
|
|
||||||
/*----------------------------------*/
|
|
||||||
SGUI_ROM_ADDRESS adBaseAddr;
|
|
||||||
SGUI_BYTE* pOutPutDataPtr;
|
|
||||||
SGUI_CBYTE* pDataSource;
|
|
||||||
SGUI_SIZE sReadBytes;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Initialize */
|
|
||||||
/*----------------------------------*/
|
|
||||||
adBaseAddr = adStartAddr;
|
|
||||||
pOutPutDataPtr = pstIFObj->arrBmpDataBuffer;
|
|
||||||
pDataSource = NULL;
|
|
||||||
|
|
||||||
sReadBytes = 0;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Process */
|
|
||||||
/*----------------------------------*/
|
|
||||||
if((eDataSource > SGUI_FONT_SRC_NONE) && (eDataSource < SGUI_FONT_SRC_UNKNOWN) && (sReadSize > 0))
|
|
||||||
{
|
|
||||||
switch(eDataSource)
|
|
||||||
{
|
|
||||||
case SGUI_FONT_SRC_H8:
|
|
||||||
{
|
|
||||||
pDataSource = SGUI_FONT_H8;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SGUI_FONT_SRC_H12:
|
|
||||||
{
|
|
||||||
pDataSource = SGUI_FONT_H12;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SGUI_FONT_SRC_H16:
|
|
||||||
{
|
|
||||||
pDataSource = SGUI_FONT_H16;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SGUI_NOTICE_ICON:
|
|
||||||
{
|
|
||||||
pDataSource = SGUI_NOTICE_ICON_DATA;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
/* no valid data. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != pDataSource)
|
|
||||||
{
|
|
||||||
for(sReadBytes=0; sReadBytes<sReadSize; sReadBytes++)
|
|
||||||
{
|
|
||||||
*(pOutPutDataPtr+sReadBytes) = *(pDataSource+adBaseAddr+sReadBytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sReadBytes;
|
|
||||||
}
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define LIST_SCROLLBAR_WIDTH (5)
|
#define LIST_SCROLLBAR_WIDTH (5)
|
||||||
// Automatic calculation
|
// Automatic calculation
|
||||||
#define LIST_EDGE_SIZE 1
|
#define LIST_EDGE_SIZE 1
|
||||||
#define LIST_TITLE_HEIGHT(FONT) (g_stFontSize[FONT].Height+2)
|
#define LIST_TITLE_HEIGHT(FONT_HEIGH) ((FONT_HEIGH)+2)
|
||||||
|
|
||||||
#define LIST_RECT_START_X(LIST_RECT) ((LIST_RECT).PosX)
|
#define LIST_RECT_START_X(LIST_RECT) ((LIST_RECT).PosX)
|
||||||
#define LIST_RECT_END_X(LIST_RECT) ((LIST_RECT).PosX+(LIST_RECT).Width-1)
|
#define LIST_RECT_END_X(LIST_RECT) ((LIST_RECT).PosX+(LIST_RECT).Width-1)
|
||||||
@ -73,12 +73,12 @@ void SGUI_List_Initialize(SGUI_List_STRUCT* pstList)
|
|||||||
pstListData = &(pstList->Data);
|
pstListData = &(pstList->Data);
|
||||||
pstSubElement = &(pstList->SubElement);
|
pstSubElement = &(pstList->SubElement);
|
||||||
// Initialize visible area control parameter.
|
// Initialize visible area control parameter.
|
||||||
pstListControl->ListTitleHeight = LIST_TITLE_HEIGHT(pstList->FontSize); // List title height, Include border.
|
pstListControl->ListTitleHeight = LIST_TITLE_HEIGHT(pstList->FontRes->iHeight); // List title height, Include border.
|
||||||
pstListControl->PageStartIndex = 0;
|
pstListControl->PageStartIndex = 0;
|
||||||
pstListControl->SelectIndex = 0;
|
pstListControl->SelectIndex = 0;
|
||||||
pstListControl->ItemPosYOffSet = 0;
|
pstListControl->ItemPosYOffSet = 0;
|
||||||
pstListControl->FirstVisibleItemPosY = LIST_RECT_START_Y(pstListData->Rect)+LIST_EDGE_SIZE;
|
pstListControl->FirstVisibleItemPosY = LIST_RECT_START_Y(pstListData->Rect)+LIST_EDGE_SIZE;
|
||||||
pstListControl->ListItemHeight = g_stFontSize[pstList->FontSize].Height + (LIST_ITEM_TEXT_BLANK_EDGEY*2);
|
pstListControl->ListItemHeight = pstList->FontRes->iHeight + (LIST_ITEM_TEXT_BLANK_EDGEY*2);
|
||||||
pstListControl->VisibleItemsAreaHeight = LIST_RECT_HEIGHT(pstListData->Rect)-LIST_EDGE_SIZE*2;
|
pstListControl->VisibleItemsAreaHeight = LIST_RECT_HEIGHT(pstListData->Rect)-LIST_EDGE_SIZE*2;
|
||||||
// Reset list items display area when title is existed.
|
// Reset list items display area when title is existed.
|
||||||
if(NULL != pstList->Data.Title)
|
if(NULL != pstList->Data.Title)
|
||||||
@ -211,7 +211,7 @@ void SGUI_List_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_List_STRUCT* pstList)
|
|||||||
stTitleTextDisplayArea.Width = pstListData->Rect.Width - 4;
|
stTitleTextDisplayArea.Width = pstListData->Rect.Width - 4;
|
||||||
stTitleTextDisplayArea.Height = g_stFontSize[pstList->FontSize].Height;
|
stTitleTextDisplayArea.Height = g_stFontSize[pstList->FontSize].Height;
|
||||||
|
|
||||||
SGUI_Text_DrawSingleLineText(pstIFObj, pstListData->Title, pstList->FontSize,
|
SGUI_Text_DrawSingleLineText(pstIFObj, pstListData->Title, SGUI_DEFAULT_FONT,
|
||||||
&stTitleTextDisplayArea, &stTitleTextDataArea, SGUI_DRAW_NORMAL);
|
&stTitleTextDisplayArea, &stTitleTextDataArea, SGUI_DRAW_NORMAL);
|
||||||
}
|
}
|
||||||
// Draw list items
|
// Draw list items
|
||||||
@ -413,7 +413,7 @@ void SGUI_List_DrawItem(SGUI_SCR_DEV* pstIFObj, SGUI_List_STRUCT* pstList, SGUI_
|
|||||||
|
|
||||||
// Draw list item text.
|
// Draw list item text.
|
||||||
SGUI_Text_DrawSingleLineText( pstIFObj,
|
SGUI_Text_DrawSingleLineText( pstIFObj,
|
||||||
pstListItemPointer->Text, pstList->FontSize,
|
pstListItemPointer->Text, SGUI_DEFAULT_FONT,
|
||||||
&stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
|
&stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
|
||||||
|
|
||||||
// Prepare draw parameter text.
|
// Prepare draw parameter text.
|
||||||
@ -470,7 +470,7 @@ void SGUI_List_DrawItem(SGUI_SCR_DEV* pstIFObj, SGUI_List_STRUCT* pstList, SGUI_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Draw parameter text.
|
// Draw parameter text.
|
||||||
SGUI_Text_DrawSingleLineText(pstIFObj, szParameterStringBuffer, pstList->FontSize, &stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
|
SGUI_Text_DrawSingleLineText(pstIFObj, szParameterStringBuffer, SGUI_DEFAULT_FONT, &stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
#define NOTICE_TEXT_POSX_NOICON (NOTICE_BOX_POSX+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_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_POSY(SCR_OBJ, HEIGHT) (NOTICE_BOX_POSY(SCR_OBJ, HEIGHT)+NOTICE_BOX_MARGIN)
|
||||||
#define NOTICE_TEXT_LINES_MAX(SCR_OBJ, FONT_SIZE) (NOTICE_TEXT_AREA_WIDTH(SCR_OBJ)/g_stFontSize[FONT_SIZE].Width)
|
#define NOTICE_TEXT_LINES_MAX(SCR_OBJ, FONT_WIDTH) (NOTICE_TEXT_AREA_WIDTH(SCR_OBJ)/FONT_WIDTH)
|
||||||
#define NOTICE_TEXT_LINES_MAX_NOICON(SCR_OBJ, FONT_SIZE) (NOTICE_TEXT_AREA_WIDTH_NOICON(SCR_OBJ)/g_stFontSize[FONT_SIZE].Width)
|
#define NOTICE_TEXT_LINES_MAX_NOICON(SCR_OBJ, FONT_WIDTH) (NOTICE_TEXT_AREA_WIDTH_NOICON(SCR_OBJ)/FONT_WIDTH)
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Function define. =//
|
//= Function define. =//
|
||||||
@ -52,7 +52,7 @@
|
|||||||
/** Return: Remaining text height display. **/
|
/** Return: Remaining text height display. **/
|
||||||
/** Notice: None. **/
|
/** Notice: None. **/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, SGUI_FONT_SIZE iFontSize, SGUI_INT uiTextOffset, SGUI_NOTICE_ICON_IDX eIcon)
|
SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText, const SGUI_FONT_RES* pstFontRes, SGUI_INT uiTextOffset, SGUI_NOTICE_ICON_IDX eIcon)
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
@ -62,7 +62,8 @@ SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText,
|
|||||||
SGUI_SIZE uiTextLines;
|
SGUI_SIZE uiTextLines;
|
||||||
SGUI_RECT_AREA stTextDisplayArea;
|
SGUI_RECT_AREA stTextDisplayArea;
|
||||||
SGUI_RECT_AREA stIconDisplayArea, stIconDataArea;
|
SGUI_RECT_AREA stIconDisplayArea, stIconDataArea;
|
||||||
SGUI_CSZSTR pszNoticeTextPtr;
|
SGUI_CSZSTR pszNoticeTextPtr;
|
||||||
|
SGUI_SIZE sIconDataAddr;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
@ -72,11 +73,11 @@ SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText,
|
|||||||
// Get max line of notice text.
|
// Get max line of notice text.
|
||||||
if(SGUI_ICON_NONE != eIcon)
|
if(SGUI_ICON_NONE != eIcon)
|
||||||
{
|
{
|
||||||
uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX(*pstIFObj, iFontSize));
|
uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX(*pstIFObj, pstFontRes->iHalfWidth));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX_NOICON(*pstIFObj, iFontSize));
|
uiLineCount = SGUI_Text_GetMultiLineTextLines(pszNoticeTextPtr, NOTICE_TEXT_LINES_MAX_NOICON(*pstIFObj, pstFontRes->iHalfWidth));
|
||||||
}
|
}
|
||||||
if(uiLineCount < 2)
|
if(uiLineCount < 2)
|
||||||
{
|
{
|
||||||
@ -100,7 +101,12 @@ SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szNoticeText,
|
|||||||
stIconDataArea.PosY = 0;
|
stIconDataArea.PosY = 0;
|
||||||
stIconDataArea.Width = NOTICE_ICON_SIZE;
|
stIconDataArea.Width = NOTICE_ICON_SIZE;
|
||||||
stIconDataArea.Height = NOTICE_ICON_SIZE;
|
stIconDataArea.Height = NOTICE_ICON_SIZE;
|
||||||
SGUI_Basic_DrawBitMap(pstIFObj, &stIconDisplayArea, &stIconDataArea, SGUI_NOTICE_ICON, eIcon*(NOTICE_ICON_SIZE*(NOTICE_ICON_SIZE/8)), SGUI_DRAW_NORMAL);
|
|
||||||
|
sIconDataAddr = (NOTICE_ICON_SIZE*NOTICE_ICON_SIZE/8)*eIcon;
|
||||||
|
|
||||||
|
SGUI_SystemIF_GetFlashData(pstIFObj, SGUI_NOTICE_ICON, sIconDataAddr, NOTICE_ICON_SIZE*NOTICE_ICON_SIZE);
|
||||||
|
|
||||||
|
SGUI_Basic_DrawBitMap(pstIFObj, &stIconDisplayArea, &stIconDataArea, pstIFObj->arrBmpDataBuffer, SGUI_DRAW_NORMAL);
|
||||||
}
|
}
|
||||||
// Draw text;
|
// Draw text;
|
||||||
if(SGUI_ICON_NONE != eIcon)
|
if(SGUI_ICON_NONE != eIcon)
|
||||||
|
@ -14,503 +14,317 @@
|
|||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Static variable declaration. =//
|
//= Static variable declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
const SGUI_FONT_SIZE_STRUCT g_stFontSize[SGUI_FONT_SIZE_MAX] = { {6, 4, 6, 4},
|
|
||||||
{8, 6, 8, 6},
|
|
||||||
{12, 6, 12, 12},
|
|
||||||
{16, 8, 16, 16},
|
|
||||||
{24, 12, 24, 36},
|
|
||||||
{32, 16, 32, 64}};
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Static function declaration. =//
|
//= Static function declaration. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
static SGUI_SIZE SGUI_Text_GetCharacterTableIndex(SGUI_UINT16 uiCharacterCode);
|
|
||||||
static SGUI_FLASH_DATA_SOURCE SGUI_Text_GetFontResource(SGUI_FONT_SIZE eFontSize);
|
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Function define. =//
|
//= Function define. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
/*************************************************************************/
|
||||||
|
/** Function Name: SGUI_Text_GetTextExtent **/
|
||||||
|
/** Purpose: Get the area size if show given text completely. **/
|
||||||
|
/** Params: **/
|
||||||
|
/** @ szText[in]: Text array pointer. **/
|
||||||
|
/** @ pstFontRes[in]: Font resource, improve font size info. **/
|
||||||
|
/** @ pstTextExtent[out]: Text extent size. **/
|
||||||
|
/** Return: Next character X coordinate in current line. **/
|
||||||
|
/** Limitation: None. **/
|
||||||
|
/*************************************************************************/
|
||||||
|
void SGUI_Text_GetTextExtent(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_AREA_SIZE* pstTextExtent)
|
||||||
|
{
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Variable Declaration */
|
||||||
|
/*----------------------------------*/
|
||||||
|
const SGUI_CHAR* pcChar;
|
||||||
|
SGUI_UINT32 uiCharacterCode;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Initialize */
|
||||||
|
/*----------------------------------*/
|
||||||
|
pcChar = cszText;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Process */
|
||||||
|
/*----------------------------------*/
|
||||||
|
if((NULL != pcChar) && (NULL != pstTextExtent))
|
||||||
|
{
|
||||||
|
pstTextExtent->iHeight = pstFontRes->iHeight;
|
||||||
|
pstTextExtent->iWidth=0;
|
||||||
|
while('\0' != *pcChar)
|
||||||
|
{
|
||||||
|
uiCharacterCode = 0;
|
||||||
|
pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode);
|
||||||
|
if(SGUI_IS_VISIBLE_CHAR(uiCharacterCode))
|
||||||
|
{
|
||||||
|
pstTextExtent->iWidth+=(pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/** Function Name: SGUI_Text_DrawSingleLineText **/
|
/** Function Name: SGUI_Text_DrawSingleLineText **/
|
||||||
/** Purpose: Write a single line text in a fixed area. **/
|
/** Purpose: Write a single line text in a fixed area. **/
|
||||||
/** Params: **/
|
/** Params: **/
|
||||||
/** @szText[in]: Text array pointer. **/
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
||||||
/** @eFontSize[in]: Font size. **/
|
/** @ cszText[in]: Text array pointer. **/
|
||||||
/** @pstDisplayArea[in]: Display area size. **/
|
/** @ pstFontRes[in]: Font resource object. **/
|
||||||
/** @pstTextDataArea[in]: Text area size. **/
|
/** @ pstDisplayArea[in]: Display area size. **/
|
||||||
/** @eFontMode[in] Character display mode(normal or reverse color).**/
|
/** @ pstInnerPos[in]: Text paint position in display area. **/
|
||||||
/** Return: Next character X coordinate in current line. **/
|
/** @ eFontMode[in] Character display mode(normal or reverse color). **/
|
||||||
/** Limitation: None. **/
|
/** Return: None. **/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
void SGUI_Text_DrawSingleLineText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szText, SGUI_FONT_SIZE eFontSize, SGUI_RECT_AREA* pstDisplayArea, SGUI_RECT_AREA* pstTextDataArea, SGUI_DRAW_MODE eFontMode)
|
void SGUI_Text_DrawText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_RECT_AREA* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_DRAW_MODE eFontMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_SZSTR pcTextPointer; // Text character pointer.
|
const SGUI_CHAR* pcChar; // Text character pointer.
|
||||||
SGUI_UINT16 uiCodeHighByte, uiCodeLowByte, uiCharacterCode; // Character byte, might be tow bytes.
|
SGUI_UINT32 uiCharacterCode; // Character byte, might be tow bytes.
|
||||||
SGUI_UINT16 uiFontWidth, uiFontHeight, uiCharacterWidth; // Font size and character graphics width.
|
|
||||||
SGUI_UINT32 uiCharacterDataSize;
|
|
||||||
SGUI_RECT_AREA stCharacterDataArea = {0};
|
|
||||||
SGUI_COLOR eBackColor;
|
SGUI_COLOR eBackColor;
|
||||||
SGUI_FLASH_DATA_SOURCE eFontResource;
|
SGUI_BMP_RES stCharBitmap;
|
||||||
SGUI_ROM_ADDRESS adFontDataAddr;
|
SGUI_POINT stPaintPos;
|
||||||
SGUI_INT iFontDataIndex;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
// Initialize variable.
|
// Initialize variable.
|
||||||
pcTextPointer = (SGUI_SZSTR)ENCODE(szText);
|
pcChar = cszText;
|
||||||
uiCharacterCode = 0x0000;
|
uiCharacterCode = 0x00000000;
|
||||||
eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
|
eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
|
||||||
// Get font graphics size.
|
|
||||||
uiFontWidth = g_stFontSize[eFontSize].Width;
|
|
||||||
uiFontHeight = g_stFontSize[eFontSize].Height;
|
|
||||||
uiCharacterDataSize = (((uiFontHeight-1)/8)+1)*uiFontWidth;
|
|
||||||
eFontResource = SGUI_Text_GetFontResource(eFontSize);
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)) && (SGUI_FONT_SRC_UNKNOWN != eFontResource))
|
if((NULL != pcChar) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)))
|
||||||
{
|
{
|
||||||
// Recalculate text display area and data area.
|
// Adapt text display area and data area.
|
||||||
if(RECT_X_START(*pstDisplayArea) < 0)
|
SGUI_Common_AdaptDisplayInfo(pstDisplayArea, pstInnerPos);
|
||||||
{
|
|
||||||
RECT_X_START(*pstTextDataArea) += RECT_X_START(*pstDisplayArea);
|
|
||||||
RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea);
|
|
||||||
RECT_X_START(*pstDisplayArea) = 0;
|
|
||||||
}
|
|
||||||
if(RECT_Y_START(*pstDisplayArea) < 0)
|
|
||||||
{
|
|
||||||
RECT_Y_START(*pstTextDataArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_Y_START(*pstDisplayArea) = 0;
|
|
||||||
}
|
|
||||||
// Clear text area.
|
// Clear text area.
|
||||||
SGUI_Basic_DrawRectangle(pstIFObj, RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea),
|
SGUI_Basic_DrawRectangle(pstIFObj, RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea),
|
||||||
RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea),
|
RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea),
|
||||||
eBackColor, eBackColor);
|
eBackColor, eBackColor);
|
||||||
// Initialize drawing area data.
|
// Initialize drawing area data.
|
||||||
RECT_X_START(stCharacterDataArea) = RECT_X_START(*pstTextDataArea);
|
RECT_X_START(stPaintPos) = RECT_X_START(*pstInnerPos);
|
||||||
RECT_Y_START(stCharacterDataArea) = RECT_Y_START(*pstTextDataArea);
|
RECT_Y_START(stPaintPos) = RECT_Y_START(*pstInnerPos);
|
||||||
RECT_HEIGHT(stCharacterDataArea) = uiFontHeight;
|
RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight;
|
||||||
|
stCharBitmap.pData = pstIFObj->arrBmpDataBuffer;
|
||||||
|
|
||||||
// Loop for Each char.
|
// Loop for Each char.
|
||||||
while(((NULL != pcTextPointer) && ('\0' != *pcTextPointer)) && (RECT_X_START(stCharacterDataArea) < RECT_WIDTH(*pstDisplayArea)))
|
while(((NULL != pcChar) && ('\0' != *pcChar)) && (RECT_X_START(stPaintPos) < RECT_WIDTH(*pstDisplayArea)))
|
||||||
{
|
{
|
||||||
// Get character.
|
uiCharacterCode = 0;
|
||||||
uiCodeHighByte = 0x00;
|
pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode);
|
||||||
uiCodeLowByte = 0x00;
|
if(SGUI_IS_VISIBLE_CHAR(uiCharacterCode))
|
||||||
// Process with ASCII code.
|
|
||||||
if((SGUI_BYTE)(*pcTextPointer) < 0x7F)
|
|
||||||
{
|
{
|
||||||
uiCodeLowByte = (SGUI_BYTE)(*pcTextPointer);
|
RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth;
|
||||||
uiCharacterWidth = uiFontWidth;
|
if(RECT_X_END(stCharBitmap, stPaintPos) >= 0)
|
||||||
pcTextPointer++;
|
{
|
||||||
|
SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstIFObj->arrBmpDataBuffer, SGUI_BMP_DATA_BUFFER_SIZE);
|
||||||
|
SGUI_Basic_DrawBitMap(pstIFObj, pstDisplayArea, &stPaintPos, &stCharBitmap, eFontMode);
|
||||||
|
}
|
||||||
|
RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap);
|
||||||
}
|
}
|
||||||
// Process with GB2312.
|
|
||||||
else if(((SGUI_BYTE)(*pcTextPointer) >= 0xA1) && ((SGUI_BYTE)(*pcTextPointer) <= 0xF7))
|
|
||||||
{
|
|
||||||
uiCodeHighByte = (SGUI_BYTE)*pcTextPointer++;
|
|
||||||
uiCodeLowByte = (SGUI_BYTE)*pcTextPointer++;
|
|
||||||
uiCharacterWidth = uiFontWidth << 1; //uiCharacterWidth = uiFontWidth * 2; for full-width character;
|
|
||||||
}
|
|
||||||
// Invalid character
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiCharacterWidth = 0;
|
|
||||||
pcTextPointer++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
uiCharacterCode = uiCodeHighByte;
|
|
||||||
uiCharacterCode = uiCharacterCode << 8;
|
|
||||||
uiCharacterCode = uiCharacterCode | uiCodeLowByte;
|
|
||||||
|
|
||||||
RECT_WIDTH(stCharacterDataArea) = uiCharacterWidth;
|
|
||||||
|
|
||||||
if(RECT_X_END(stCharacterDataArea) >= 0)
|
|
||||||
{
|
|
||||||
iFontDataIndex = SGUI_Text_GetCharacterTableIndex(uiCharacterCode);
|
|
||||||
adFontDataAddr = iFontDataIndex * uiCharacterDataSize;
|
|
||||||
SGUI_Basic_DrawBitMap(pstIFObj, pstDisplayArea, &stCharacterDataArea, eFontResource, adFontDataAddr, eFontMode);
|
|
||||||
}
|
|
||||||
RECT_X_START(stCharacterDataArea) += uiCharacterWidth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
/*****************************************************************************/
|
/** Function Name: GUI_DrawMultipleLinesText **/
|
||||||
/** Function Name: GUI_DrawMultipleLinesText **/
|
/** Purpose: Write a mulitiplt line text in a rectangular area. **/
|
||||||
/** Purpose: Write a mulitiplt line text in a rectangular area. **/
|
/** Params: **/
|
||||||
/** Params: **/
|
/** @ pstIFObj[in]: SimpleGUI object pointer. **/
|
||||||
/** @szText[in]: Text array pointer. **/
|
/** @ cszText[in]: Text array pointer. **/
|
||||||
/** @eFontSize[in]: Font size. **/
|
/** @ pstFontRes[in]: Font resource object. **/
|
||||||
/** @pstDisplayArea[in]: Display area size. **/
|
/** @ pstDisplayArea[in]: Display area size. **/
|
||||||
/** @eFontMode[in]: Character display mode(normal or reverse color). **/
|
/** @ iTopOffset[in]: Text paint offset in vertical. **/
|
||||||
/** Return: Next character X coordinate in current line. **/
|
/** @ eFontMode[in]: Character display mode(normal or reverse color). **/
|
||||||
/** Notice: None. **/
|
/** Return: Used line count. **/
|
||||||
/*****************************************************************************/
|
/** Notice: None. **/
|
||||||
SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR szText, SGUI_FONT_SIZE eFontSize, SGUI_RECT_AREA* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode)
|
/*************************************************************************/
|
||||||
|
SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstIFObj, SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_RECT_AREA* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode)
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_SZSTR pcTextPointer;
|
const SGUI_CHAR* pcChar;
|
||||||
SGUI_UINT16 uiCodeHighByte, uiCodeLowByte, uiCharacterCode;
|
SGUI_UINT32 uiCharacterCode;
|
||||||
SGUI_UINT16 uiFontWidth, uiFontHeight;
|
|
||||||
SGUI_UINT32 uiCharacterDataSize;
|
|
||||||
SGUI_SIZE uiLines;
|
SGUI_SIZE uiLines;
|
||||||
SGUI_RECT_AREA stCharacterDataArea = {0};
|
|
||||||
SGUI_COLOR eBackColor;
|
SGUI_COLOR eBackColor;
|
||||||
SGUI_FLASH_DATA_SOURCE eFontResource;
|
SGUI_BMP_RES stCharBitmap;
|
||||||
SGUI_ROM_ADDRESS adFontDataAddr;
|
SGUI_POINT stPaintPos;
|
||||||
SGUI_INT iFontDataIndex;
|
SGUI_INT iStartOffsetX;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
pcTextPointer = (SGUI_SZSTR)ENCODE(szText);
|
pcChar = cszText;
|
||||||
uiCharacterCode = 0x0000;
|
uiCharacterCode = 0;
|
||||||
uiLines = 0;
|
uiLines = 0;
|
||||||
eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
|
eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
|
||||||
// Get font graphics size.
|
|
||||||
uiFontWidth = g_stFontSize[eFontSize].Width;
|
|
||||||
uiFontHeight = g_stFontSize[eFontSize].Height;
|
|
||||||
uiCharacterDataSize = (((uiFontHeight-1)/8)+1)*uiFontWidth;
|
|
||||||
eFontResource = SGUI_Text_GetFontResource(eFontSize);
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
if((szText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)))
|
if((cszText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstIFObj->stSize)))
|
||||||
{
|
{
|
||||||
// Recalculate text display area and data area.
|
// Initialize drawing position.
|
||||||
if(RECT_X_START(*pstDisplayArea) < 0)
|
RECT_X_START(stPaintPos) = 0;
|
||||||
{
|
RECT_Y_START(stPaintPos) = iTopOffset;
|
||||||
RECT_X_START(stCharacterDataArea) += RECT_X_START(*pstDisplayArea);
|
// Adapt text display area and data area.
|
||||||
RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea);
|
SGUI_Common_AdaptDisplayInfo(pstDisplayArea, &stPaintPos);
|
||||||
RECT_X_START(*pstDisplayArea) = 0;
|
iStartOffsetX = stPaintPos.iPosX;
|
||||||
}
|
|
||||||
if(RECT_Y_START(*pstDisplayArea) < 0)
|
|
||||||
{
|
|
||||||
RECT_Y_START(stCharacterDataArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea);
|
|
||||||
RECT_Y_START(*pstDisplayArea) = 0;
|
|
||||||
}
|
|
||||||
// Clear text area.
|
// Clear text area.
|
||||||
SGUI_Basic_DrawRectangle(pstIFObj,
|
SGUI_Basic_DrawRectangle(pstIFObj,
|
||||||
RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea),
|
RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea),
|
||||||
RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea),
|
RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea),
|
||||||
eBackColor, eBackColor);
|
eBackColor, eBackColor);
|
||||||
// Initialize drawing area data.
|
|
||||||
RECT_X_START(stCharacterDataArea) = 0;
|
|
||||||
RECT_Y_START(stCharacterDataArea) = iTopOffset;
|
|
||||||
RECT_HEIGHT(stCharacterDataArea) = uiFontHeight;
|
|
||||||
uiLines = 1;
|
|
||||||
|
|
||||||
|
RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight;
|
||||||
|
uiLines = 1;
|
||||||
|
stCharBitmap.pData = pstIFObj->arrBmpDataBuffer;
|
||||||
// Loop for each word in display area.
|
// Loop for each word in display area.
|
||||||
if(NULL != pcTextPointer)
|
while(((NULL != pcChar) && ('\0' != *pcChar)))
|
||||||
{
|
{
|
||||||
while(*pcTextPointer != '\0')
|
uiCharacterCode = 0;
|
||||||
{
|
pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode);
|
||||||
uiCodeHighByte = 0x00;
|
|
||||||
uiCodeLowByte = 0x00;
|
|
||||||
// Judge change line symbol.
|
|
||||||
if(*pcTextPointer == '\n')
|
|
||||||
{
|
|
||||||
if(RECT_X_START(stCharacterDataArea) == 0)
|
|
||||||
{
|
|
||||||
// Ignore change lines in line start.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Change lines.
|
|
||||||
RECT_X_START(stCharacterDataArea) = 0;
|
|
||||||
RECT_Y_START(stCharacterDataArea) += uiFontHeight;
|
|
||||||
uiLines ++;
|
|
||||||
}
|
|
||||||
pcTextPointer++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Process with ASCII code.
|
|
||||||
if(((SGUI_BYTE)(*pcTextPointer) < 0x7F) && ((SGUI_BYTE)(*pcTextPointer) >= 0x20))
|
|
||||||
{
|
|
||||||
uiCodeLowByte = (SGUI_BYTE)*pcTextPointer++;
|
|
||||||
RECT_WIDTH(stCharacterDataArea) = uiFontWidth;
|
|
||||||
}
|
|
||||||
// Process with GB2312.
|
|
||||||
else if(((SGUI_BYTE)(*pcTextPointer) >= 0xA1) && ((SGUI_BYTE)(*pcTextPointer) <= 0xF7))
|
|
||||||
{
|
|
||||||
uiCodeHighByte = (SGUI_BYTE)*pcTextPointer++;
|
|
||||||
uiCodeLowByte = (SGUI_BYTE)*pcTextPointer++;
|
|
||||||
RECT_WIDTH(stCharacterDataArea) = uiFontWidth << 1;
|
|
||||||
}
|
|
||||||
// Invalid character
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pcTextPointer++;
|
|
||||||
RECT_WIDTH(stCharacterDataArea) = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
uiCharacterCode = uiCodeHighByte;
|
|
||||||
uiCharacterCode = uiCharacterCode << 8;
|
|
||||||
uiCharacterCode = uiCharacterCode | uiCodeLowByte;
|
|
||||||
|
|
||||||
// Judge change line
|
// Judge change line symbol.
|
||||||
if(RECT_X_END(stCharacterDataArea) >= RECT_WIDTH(*pstDisplayArea))
|
if(uiCharacterCode == '\n')
|
||||||
{
|
{
|
||||||
// Change lines.
|
// Change lines.
|
||||||
RECT_X_START(stCharacterDataArea) = 0;
|
RECT_X_START(stPaintPos) = iStartOffsetX;
|
||||||
RECT_Y_START(stCharacterDataArea) += uiFontHeight;
|
RECT_Y_START(stPaintPos) += pstFontRes->iHeight;
|
||||||
uiLines ++;
|
uiLines ++;
|
||||||
}
|
continue;
|
||||||
// Draw characters.
|
}
|
||||||
if((RECT_Y_END(stCharacterDataArea) >= 0) && (RECT_Y_START(stCharacterDataArea) < RECT_HEIGHT(*pstDisplayArea)))
|
// Get character width;
|
||||||
{
|
RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth;
|
||||||
// Draw character.
|
|
||||||
iFontDataIndex = SGUI_Text_GetCharacterTableIndex(uiCharacterCode);
|
|
||||||
adFontDataAddr = iFontDataIndex * uiCharacterDataSize;
|
|
||||||
SGUI_Basic_DrawBitMap(pstIFObj, pstDisplayArea, &stCharacterDataArea, eFontResource, adFontDataAddr, eFontMode);
|
|
||||||
|
|
||||||
}
|
// Judge change line
|
||||||
else
|
if(RECT_X_END(stCharBitmap, stPaintPos) >= RECT_WIDTH(*pstDisplayArea))
|
||||||
{
|
{
|
||||||
// character is not in visible area, ignore.
|
// Change lines.
|
||||||
}
|
RECT_X_START(stPaintPos) = iStartOffsetX;
|
||||||
RECT_X_START(stCharacterDataArea) += RECT_WIDTH(stCharacterDataArea);
|
RECT_Y_START(stPaintPos) += pstFontRes->iHeight;
|
||||||
}
|
uiLines ++;
|
||||||
}
|
}
|
||||||
|
// Draw characters.
|
||||||
|
if((RECT_Y_END(stCharBitmap, stPaintPos) >= 0) && (RECT_Y_START(stPaintPos) < RECT_HEIGHT(*pstDisplayArea)))
|
||||||
|
{
|
||||||
|
// Draw character.
|
||||||
|
SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstIFObj->arrBmpDataBuffer, SGUI_BMP_DATA_BUFFER_SIZE);
|
||||||
|
SGUI_Basic_DrawBitMap(pstIFObj, pstDisplayArea, &stPaintPos, &stCharBitmap, eFontMode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// character is not in visible area, ignore.
|
||||||
|
}
|
||||||
|
RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return uiLines;
|
return uiLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*************************************************************************/
|
||||||
/** Function Name: SGUI_Text_GetCharacterTableIndex **/
|
/** Function Name: SGUI_Text_GetMultiLineTextLines **/
|
||||||
/** Purpose: Get character index in font mode table. **/
|
/** Purpose: Get a string's lines in a fixed width area. **/
|
||||||
/** Params: **/
|
/** Resources: None. **/
|
||||||
/** @uiCharacterCode[in]: Data buffer pointer of read font data. **/
|
/** Params: **/
|
||||||
/** Return: Font mode data index in table. **/
|
/** @ cszText[in]: Text array pointer. **/
|
||||||
/** Limitation: This function need to override when use external flash **/
|
/** @ pstFontRes[in]: Font resource object. **/
|
||||||
/** ROM data, user must redefine the data offset by the **/
|
/** @ uiDisplayAreaWidth[in]: Display area width. **/
|
||||||
/** actual data. **/
|
/** Return: String lines. **/
|
||||||
/*****************************************************************************/
|
/*************************************************************************/
|
||||||
SGUI_SIZE SGUI_Text_GetCharacterTableIndex(SGUI_UINT16 uiCharacterCode)
|
SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_SIZE uiDisplayAreaWidth)
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_UINT16 uiCharacterCodeHighByte;
|
SGUI_SIZE uiLineNumber, uiLineLength;
|
||||||
SGUI_UINT16 uiCharacterCodeLowByte;
|
SGUI_UINT32 uiCharacterCode;
|
||||||
SGUI_SIZE uiFontTableIndex;
|
SGUI_UINT16 uiCharWidth;
|
||||||
|
SGUI_CSZSTR pcChar;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
uiCharacterCodeHighByte = (uiCharacterCode >> 8) & 0x00FF;
|
uiLineLength = 0;
|
||||||
uiCharacterCodeLowByte = uiCharacterCode & 0x00FF;
|
uiLineNumber = 1;
|
||||||
|
pcChar = cszText;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
// ASCII code.
|
while('\0' != *pcChar)
|
||||||
if((0 == uiCharacterCodeHighByte) && (uiCharacterCodeLowByte < 128))
|
|
||||||
{
|
{
|
||||||
uiFontTableIndex = (uiCharacterCodeLowByte + FONT_LIB_OFFSET_ASCII);
|
uiCharacterCode = 0;
|
||||||
}
|
pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode);
|
||||||
// GB2312 punctuation
|
if('\n' == uiCharacterCode)
|
||||||
else if((0xAA > uiCharacterCodeHighByte) && (0xA0 < uiCharacterCodeHighByte))
|
|
||||||
{
|
|
||||||
uiFontTableIndex = ((((uiCharacterCodeHighByte-0xA1)*94 + (uiCharacterCodeLowByte-0xA1))*2) + FONT_LIB_OFFSET_GB2312_SYMBOL);
|
|
||||||
}
|
|
||||||
// GB2312 level one character.
|
|
||||||
else if((0xF8 > uiCharacterCodeHighByte) && (0xAF < uiCharacterCodeHighByte))
|
|
||||||
{
|
|
||||||
uiFontTableIndex = ((((uiCharacterCodeHighByte-0xB0)*94 + (uiCharacterCodeLowByte-0xA1))*2) + FONT_LIB_OFFSET_GB2312_CHARL1);
|
|
||||||
}
|
|
||||||
// Other to return full width space.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiFontTableIndex = FONT_LIB_OFFSET_GB2312_SYMBOL; // Full-size space.
|
|
||||||
}
|
|
||||||
|
|
||||||
return uiFontTableIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/** Function Name: SGUI_Text_GetTextGraphicsWidth **/
|
|
||||||
/** Purpose: Get text displayed full width. **/
|
|
||||||
/** Params: **/
|
|
||||||
/** @szText[in]: Text pointer. **/
|
|
||||||
/** @eFontSize[in]: Font size, usually means font height. **/
|
|
||||||
/** Return: None. **/
|
|
||||||
/** Notice: Only used with Equal-width characters. **/
|
|
||||||
/*****************************************************************************/
|
|
||||||
SGUI_SIZE SGUI_Text_GetTextGraphicsWidth(SGUI_CSZSTR szText, SGUI_FONT_SIZE eFontSize)
|
|
||||||
{
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Variable Declaration */
|
|
||||||
/*----------------------------------*/
|
|
||||||
SGUI_SIZE uiTextHalfCharLength;
|
|
||||||
SGUI_UINT16 uiHalfFontWidth;
|
|
||||||
SGUI_SIZE uiTextGraphicsWidth;
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Initialize */
|
|
||||||
/*----------------------------------*/
|
|
||||||
uiTextHalfCharLength = 0;
|
|
||||||
uiTextGraphicsWidth = 0;
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Process */
|
|
||||||
/*----------------------------------*/
|
|
||||||
if(NULL != szText)
|
|
||||||
{
|
|
||||||
uiTextHalfCharLength = SGUI_SystemIF_StringLength(ENCODE(szText));
|
|
||||||
uiHalfFontWidth = g_stFontSize[eFontSize].Width;
|
|
||||||
uiTextGraphicsWidth = uiHalfFontWidth * uiTextHalfCharLength;
|
|
||||||
}
|
|
||||||
return uiTextGraphicsWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/** Function Name: SGUI_Text_GetMultiLineTextLines **/
|
|
||||||
/** Purpose: Get a string's lines in a fixed width area. **/
|
|
||||||
/** Resources: None. **/
|
|
||||||
/** Params: **/
|
|
||||||
/** @szNoticeText[in]: Notice text resource. **/
|
|
||||||
/** @uiHalfWidthCharInLine[in]: Max number of half-width character in each **/
|
|
||||||
/** line. **/
|
|
||||||
/** Return: String lines. **/
|
|
||||||
/** Notice: None. **/
|
|
||||||
/*****************************************************************************/
|
|
||||||
SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR szNoticeText, SGUI_SIZE uiHalfWidthCharInLine)
|
|
||||||
{
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Variable Declaration */
|
|
||||||
/*----------------------------------*/
|
|
||||||
SGUI_SIZE uiLineCount, uiLineByteCount;
|
|
||||||
SGUI_CSZSTR pcCur;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Initialize */
|
|
||||||
/*----------------------------------*/
|
|
||||||
uiLineByteCount = 0;
|
|
||||||
uiLineCount = 1;
|
|
||||||
pcCur = ENCODE(szNoticeText);
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Process */
|
|
||||||
/*----------------------------------*/
|
|
||||||
if(NULL != pcCur)
|
|
||||||
{
|
|
||||||
while('\0' != *pcCur)
|
|
||||||
{
|
{
|
||||||
if(*pcCur == '\n')
|
uiLineNumber++;
|
||||||
|
uiLineLength = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uiCharWidth = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth;
|
||||||
|
if((uiLineLength+uiCharWidth)>uiDisplayAreaWidth)
|
||||||
{
|
{
|
||||||
if(uiLineByteCount > 0)
|
uiLineNumber++;
|
||||||
{
|
uiLineLength = uiCharWidth;
|
||||||
// Change lines.
|
|
||||||
uiLineCount ++;
|
|
||||||
uiLineByteCount = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Ignore change lines in line start.
|
|
||||||
}
|
|
||||||
pcCur++;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((uint8_t)(*pcCur) < 0x7F)
|
|
||||||
{
|
|
||||||
if(uiLineByteCount<uiHalfWidthCharInLine)
|
|
||||||
{
|
|
||||||
uiLineByteCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiLineByteCount = 1;
|
|
||||||
uiLineCount++;
|
|
||||||
}
|
|
||||||
pcCur++;
|
|
||||||
}
|
|
||||||
// Process with GB2312.
|
|
||||||
else if(((uint8_t)(*pcCur) >= 0xA1) && ((uint8_t)(*pcCur) <= 0xF7))
|
|
||||||
{
|
|
||||||
//GB2312
|
|
||||||
if((uiHalfWidthCharInLine-uiLineByteCount)>2)
|
|
||||||
{
|
|
||||||
uiLineByteCount+=2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiLineByteCount = 2;
|
|
||||||
uiLineCount++;
|
|
||||||
}
|
|
||||||
pcCur+=2;
|
|
||||||
}
|
|
||||||
// Invalid character
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pcCur++;
|
uiLineLength+=uiCharWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uiLineCount;
|
return uiLineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/** Function Name: SGUI_Text_GetFontResource **/
|
/** Function Name: SGUI_Text_GetCharacterData **/
|
||||||
/** Purpose: Get character index in font mode table. **/
|
/** Purpose: Get character data form font resource by char code. **/
|
||||||
/** Params: **/
|
/** Params: **/
|
||||||
/** @ eFontSize[in]: Get font resource ID by font size. **/
|
/** @ pstFontRes[in]: Font resource structure pointer. **/
|
||||||
/** Return: Font data resource ID. **/
|
/** @ uiCode[in]: Character code. **/
|
||||||
/** Limitation: This function will be used when user data is in differ- **/
|
/** @ pDataBuffer[out]: Buffer for output char data. **/
|
||||||
/** end media, like flash on chip or external flash. user **/
|
/** @ sBufferSize[in]: Output buffer size. **/
|
||||||
/** can distinguish many different resources by ID, and **/
|
/** Return: Number of read data, return 0 when error occurred. **/
|
||||||
/** this function will read data form different media with **/
|
|
||||||
/** different parameter. **/
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
SGUI_FLASH_DATA_SOURCE SGUI_Text_GetFontResource(SGUI_FONT_SIZE eFontSize)
|
SGUI_SIZE SGUI_Text_GetCharacterData(const SGUI_FONT_RES* pstFontRes, SGUI_UINT32 uiCode, SGUI_BYTE* pDataBuffer, SGUI_SIZE sBufferSize)
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_FLASH_DATA_SOURCE eResourceID;
|
SGUI_SIZE sGetDataSize;
|
||||||
|
SGUI_SIZE sReadDataSize;
|
||||||
|
SGUI_SIZE sDataBlockSize;
|
||||||
|
SGUI_SIZE sCharIndex;
|
||||||
|
SGUI_BOOL bIsFullWidth;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Initialize */
|
||||||
|
/*----------------------------------*/
|
||||||
|
sGetDataSize = 0;
|
||||||
|
bIsFullWidth = SGUI_FALSE;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
switch(eFontSize)
|
if((NULL != pstFontRes) && (NULL != pDataBuffer) && (0 != sBufferSize))
|
||||||
{
|
{
|
||||||
case SGUI_FONT_SIZE_H6:
|
sCharIndex = pstFontRes->fnGetIndex(uiCode);
|
||||||
{
|
if(SGUI_INVALID_INDEX != sCharIndex)
|
||||||
eResourceID = SGUI_FONT_SRC_H6;
|
{
|
||||||
break;
|
sDataBlockSize = SGUI_USED_BYTE(pstFontRes->iHeight) * pstFontRes->iHalfWidth;
|
||||||
}
|
sReadDataSize = bIsFullWidth?(sDataBlockSize*2):sDataBlockSize;
|
||||||
case SGUI_FONT_SIZE_H8:
|
sGetDataSize = pstFontRes->fnGetData(sCharIndex*sDataBlockSize, pDataBuffer, sReadDataSize>sBufferSize?sBufferSize:sReadDataSize);
|
||||||
{
|
}
|
||||||
eResourceID = SGUI_FONT_SRC_H8;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SGUI_FONT_SIZE_H12:
|
|
||||||
{
|
|
||||||
eResourceID = SGUI_FONT_SRC_H12;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SGUI_FONT_SIZE_H16:
|
|
||||||
{
|
|
||||||
eResourceID = SGUI_FONT_SRC_H16;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
eResourceID = SGUI_FONT_SRC_UNKNOWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return eResourceID;
|
return sGetDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ wxThread::ExitCode LCDFrame::Entry(void)
|
|||||||
while(false == bExit)
|
while(false == bExit)
|
||||||
{
|
{
|
||||||
bExit = pclsThread->TestDestroy();
|
bExit = pclsThread->TestDestroy();
|
||||||
lExitCode = (wxThread::ExitCode)SGUI_SDK_DummyMainProc();
|
lExitCode = reinterpret_cast<wxThread::ExitCode>(SGUI_SDK_DummyMainProc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,24 +97,6 @@
|
|||||||
<Unit filename="../../../DemoProc/src/DemoProc.c">
|
<Unit filename="../../../DemoProc/src/DemoProc.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="../../../DemoProc/src/List.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../DemoProc/src/RTCNotice.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../DemoProc/src/RealtimeGraph.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../DemoProc/src/ScrollingText.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../DemoProc/src/TextNotice.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../DemoProc/src/VariableBox.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../GUI/inc/SGUI_Basic.h" />
|
<Unit filename="../../../GUI/inc/SGUI_Basic.h" />
|
||||||
<Unit filename="../../../GUI/inc/SGUI_Common.h" />
|
<Unit filename="../../../GUI/inc/SGUI_Common.h" />
|
||||||
<Unit filename="../../../GUI/inc/SGUI_Config.h" />
|
<Unit filename="../../../GUI/inc/SGUI_Config.h" />
|
||||||
@ -140,27 +122,15 @@
|
|||||||
<Unit filename="../../../GUI/src/SGUI_Interface.c">
|
<Unit filename="../../../GUI/src/SGUI_Interface.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="../../../GUI/src/SGUI_List.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../GUI/src/SGUI_Notice.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../GUI/src/SGUI_ProcessBar.c">
|
<Unit filename="../../../GUI/src/SGUI_ProcessBar.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="../../../GUI/src/SGUI_RealtimeGraph.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../GUI/src/SGUI_ScrollBar.c">
|
<Unit filename="../../../GUI/src/SGUI_ScrollBar.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="../../../GUI/src/SGUI_Text.c">
|
<Unit filename="../../../GUI/src/SGUI_Text.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="../../../GUI/src/SGUI_VariableBox.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="../../../HMI/inc/HMI_Engine.h" />
|
<Unit filename="../../../HMI/inc/HMI_Engine.h" />
|
||||||
<Unit filename="../../../HMI/src/HMI_Engine.c">
|
<Unit filename="../../../HMI/src/HMI_Engine.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
|
Loading…
Reference in New Issue
Block a user