Home » U++ Library support » U++ Widgets - General questions or Mixed problems » AlignDisplay bug (?)
AlignDisplay bug (?) [message #6660] |
Wed, 22 November 2006 01:33 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
The base Display class draws text vertically centered. This would be nice for AlignDisplay also, but renders text to its top.
I changed AlignDisplay to render text vertically centered:
In TDraw/Util.cpp, the last two lines are my changes:
void AlignDisplay::Paint(Draw& draw, const Rect& rc, const Value& v, Color ink, Color paper, dword style) const
{
String s = StdFormat(v);
Font font = StdFont();
Size size = GetTextSize(s, font);
draw.DrawRect(rc, paper);
int x = rc.left;
switch(align)
{
case ALIGN_CENTER: x += (rc.Width() - size.cx) >> 1; break;
case ALIGN_RIGHT: x = rc.right - size.cx; break;
}
int y = rc.top + max((rc.Height() - size.cy) / 2, 0);
draw.DrawText(x, y, s, font, ink);
}
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat May 04 15:49:32 CEST 2024
Total time taken to generate the page: 0.03021 seconds
|