Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Refactoring of StdDisplayClass::Paint0()
Refactoring of StdDisplayClass::Paint0() [message #44985] |
Fri, 07 August 2015 05:41 |
Novo
Messages: 1378 Registered: December 2006
|
Ultimate Contributor |
|
|
Is it possible to refactor StdDisplayClass::Paint0() to make drawing of truncated strings a separate function?
This is needed very often when making your own Display classes.
At this time I'm using copy-pasted simplified code from StdDisplayClass::Paint0() which looks like below.
{
WString txt;
Font font = StdFont();
int x = r.left;
int width = r.GetWidth();
txt = StdConvert().Format(offset);
Size tsz = GetTLTextSize(txt, font);
int tcy = GetTLTextHeight(txt, font);
int tt = r.top + max((r.Height() - tcy) / 2, 0);
if(tsz.cx > width) {
Size isz = DrawImg::threedots().GetSize();
int wd = width - isz.cx;
w.Clip(r.left, r.top, wd, r.GetHeight());
DrawTLText(w, x, tt, width, txt, font, ink);
w.End();
w.DrawImage(r.left + wd, tt + font.Info().GetAscent() - isz.cy, DrawImg::threedots(), ink);
}
else
DrawTLText(w, x, tt, width, txt, font, ink);
}
IMHO, it would be useful to have a reusable and supported function for such common functionality.
Thanks.
Regards,
Novo
|
|
|
Goto Forum:
Current Time: Sun Dec 08 04:03:26 CET 2024
Total time taken to generate the page: 0.01828 seconds
|