draw first meeting

This commit is contained in:
stubbfelnewpc
2020-05-14 20:06:50 +02:00
parent 443f999d77
commit 6d818b51ee
5 changed files with 94 additions and 41 deletions

View File

@@ -5,6 +5,7 @@
//namespace myink { namespace ui {
PositionalProperties Paint_DrawString(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
TextBlock::TextBlock(const char * t, const TextBlockStyleProperties & s): text(t), style(s)
{
@@ -17,8 +18,51 @@ TextBlock::~TextBlock()
PositionalProperties TextBlock::draw(const PositionalProperties & p)
{
auto font = style.font;
Paint_DrawString_EN(p.left, p.top, text, &font, style.background_color, style.font_color);
return { p.left, p.top, strlen(text) * font.Width, font.Height};
return Paint_DrawString(p.left, p.top, text, &font, style.background_color, style.font_color);
}
PositionalProperties Paint_DrawString(UWORD Xstart, UWORD Ystart, const char * pString,
sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
{
UWORD Xpoint = Xstart;
UWORD max_x_pos = Xstart;
UWORD max_y_pos = Ystart + Font->Height;
UWORD Ypoint = Ystart;
while (* pString != '\0') {
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
if (*pString == '\n'|| (Xpoint + Font->Width ) > Paint.Width ) {
Xpoint = Xstart;
Ypoint += Font->Height;
if(Ypoint >= max_y_pos) {
max_y_pos = Ypoint + Font->Height;
}
if (*pString == '\n')
{
pString++;
}
}
// If the Y direction is full, reposition to(Xstart, Ystart)
if ((Ypoint + Font->Height ) > Paint.Height ) {
Xpoint = Xstart;
Ypoint = Ystart;
}
Paint_DrawChar(Xpoint, Ypoint, * pString, Font, Color_Background, Color_Foreground);
//The next character of the address
pString ++;
//The next word of the abscissa increases the font of the broadband
Xpoint += Font->Width;
if(Xpoint > max_x_pos) {
max_x_pos = Xpoint;
}
}
return{Xstart, Ystart, max_x_pos - Xstart, (max_y_pos - Ystart)};
}
//}}