U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Widgets - General questions or Mixed problems » AlignDisplay bug (?)
AlignDisplay bug (?) [message #6660] Wed, 22 November 2006 01:33 Go to previous message
zsolt is currently offline  zsolt
Messages: 702
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);
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DropList bug
Next Topic: Mouse wheel and TopWindow
Goto Forum:
  


Current Time: Thu May 07 07:13:07 GMT+2 2026

Total time taken to generate the page: 0.00849 seconds