Initial commit

This commit is contained in:
2026-04-06 19:02:09 +08:00
commit d186d7dcc7
743 changed files with 521821 additions and 0 deletions

185
MyCode/Gui/StaticText.cpp Normal file
View File

@@ -0,0 +1,185 @@
#include"StaticText.h"
void TStaticText::Init(int aX, int aY, int aW, int aH, int OwnerX, int OwnerY, unsigned int aTextColor, unsigned int aColor)
{
unsigned short Left,Right,Top,Bottom;
Bound.SetBySize(aX+OwnerX, aY+OwnerY, aW, aH);
OwnerLeftTop.x = OwnerX;
OwnerLeftTop.y = OwnerY;
Border.Width = 1;
Border.Color = aColor;
Left = Bound.Left;
Right = Bound.Right;
Top = Bound.Top;
Bottom = Bound.Bottom;
Content.Set(Left,Top,Right,Bottom);
FontSize = 24;
Visible = 1;
Enable = 1;
Color = aColor;
TextColor = aTextColor;
TextLeftSpacing = 3;
Selected = 0;
};
void TStaticText::SetText(const char *p, int aFontSize)
{
s16 len, i;
s16 PixelWidth;
const char *ap = p;
len = 0;
for(i=0; i<62; i++){
if(*ap != 0)len++;
}
//len = sizeof(p);
if(len>62)len = 62;
for(i=0; i<len; i++){
Text[i]=*p++;
}
Text[i]=0;
FontSize = aFontSize;
PixelWidth = GetFontWidth(aFontSize);
if( (aFontSize==16) || (aFontSize == 24) ) PixelWidth = PixelWidth/2;
//TextLeftSpacing = (Bound.Width-PixelWidth) / 2;
}
void TStaticText::SetText( char *cr, int aFontSize)
{
s16 len, i;
s16 PixelWidth;
char *p = cr;
len = 0;
for(i=0; i<62; i++){
if(*p != 0)len++;
}
//len = sizeof(cr);
if(len>62)len = 62;
for(i=0; i<len; i++){
Text[i]=*cr++;
}
Text[i]=0;
FontSize = aFontSize;
PixelWidth = GetFontWidth(aFontSize);
if( (aFontSize==16) || (aFontSize == 24) ) PixelWidth = PixelWidth/2;
//TextLeftSpacing = (Bound.Width-PixelWidth) / 2;
}
void TStaticText::SetTextLeftSpacing(unsigned int spc)
{
TextLeftSpacing = spc;
if(Visible){
SelfDraw();
TextDraw();
}
}
void TStaticText::SetEnable(void)
{
Enable = 1;
if(Visible){
SelfDraw();
TextDraw();
}
}
void TStaticText::SetDisable(void)
{
Enable = 0;
if(Visible){
SelfDraw();
TextDraw();
}
}
void TStaticText::TextClear(void)
{
Text[0]=0;
Text[1]=0;
if(0){
SelfDraw();
TextDraw();
}
}
void TStaticText::SelfDraw(void)
{
if (Border.Width>0)
RectRender(Bound.Left,Bound.Top,Bound.Right,Bound.Bottom, Border.Width, Border.Color);
if(Enable){
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
}else{
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
}
}
void TStaticText::TextDraw(void)
{
int aVal, tclr;
if(Enable){
tclr = TextColor;
}else{
tclr = clSilver;
}
aVal = GetFontHeight(FontSize);
TextTop = Content.Top + (Content.Height - aVal) / 2;
aVal = Content.Left + TextLeftSpacing;
if(FontSize == 16){
TextRender_string24(aVal, TextTop, tclr, Color, Text);
}else
if(FontSize == 24){
TextRender_string24(aVal, TextTop, tclr, Color, Text);
}else{
TextRender_string24(aVal, TextTop, tclr, Color, Text);
}
}
void TStaticText::FullRedraw(void)
{
SelfDraw();
TextDraw();
}
void TStaticText::Show(void)
{
Visible = 1;
SelfDraw();
TextDraw();
}
void TStaticText::sShow(int aX, int aY, int aR, int aB, unsigned int aTc, char *Text)
{
TextRender_string24(aX +4, aY+2, aTc, Text);
}
void TStaticText::sShow(int aX, int aY, int aR, int aB, unsigned int aTc, unsigned int aBc, char *Text)
{
RectFillRender(aX, aY, aR, aB, aBc);
TextRender_string24(aX +4, aY+2, aTc, Text);
}
void TStaticText::sDrawDump(int aX, int aY, int aR, int aB, unsigned int aBc)
{
RectFillRender(aX, aY, aR, aB, aBc);
}