#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; i62)len = 62; for(i=0; i0) 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); }