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

Home » U++ Library support » CalendarCtrl » Clock small scale
Clock small scale [message #15141] Wed, 02 April 2008 17:12 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1428
Registered: September 2007
Ultimate Contributor
I've noticed that Clock does not scale too well with small sizes. Clock probably wasn't designed with this in mind so it is probably Ok to leave it like this. Still, at small sizes the clock needles are drawn on top of the header with the 4 buttons. This looks very ugly. I would propose to change the order of the drawing so at least the header will be drawn on top of everything when the size is too small, like this:

void Clock::Paint(Draw& w)
{
	const Style &st = style ? *style : StyleDefault();

	CalcSizes();

	w.DrawRect(sz, st.bgmain);
	
	if(colon)
		PaintCenteredText(w, sz.cx / 2, hs / 2 - 1, " : ", StdFont().Bold(), SColorHighlightText());

	//w.DrawEllipse(cm.x - r / 2, cm.y - r / 2, cf.x, cf.x, Blend(st.header, White, 250), PEN_NULL, Black);

	Font fnt = st.font;

	if (sz.cy < hs * 4)
		fnt.Height(8);
	else if (sz.cy < hs * 5)
		fnt.Height(10);
	else if (sz.cy < hs * 6)
		fnt.Height(11);
	
	for(int i = 1; i <= 12; i++) {
		PaintCenteredText(w,
		                  cm.x + int(0.8 * sin(i * M_PI / 6.0) * cf.x),
		                  cm.y - int(0.8 * cos(i * M_PI / 6.0) * cf.y),
		                  AsString(i), fnt.Bold(i % 3 == 0), SBlack());
	}

	int cp = cur_point;
	for(int i = 1; i <= 60; i++) {
		int x = cm.x + int(0.95 * sin(i * M_PI / 30.0) * cf.x);
		int y = cm.y - int(0.95 * cos(i * M_PI / 30.0) * cf.y);
		PaintCenteredImage(w, x, y,
		                   cur_point == i ? CtrlImg::BigDotH()
		                                  : i % 5 == 0 ? CtrlImg::BigDot() : CtrlImg::SmallDot());
	}

	PaintPtr(0, w, cm, cur_time / 3600.0 / 12, 0.5, 5, cur_line == 0 ? st.arrowhl : st.arrowhour, cf);
	PaintPtr(1, w, cm, cur_time / 3600.0, 0.6, 3, cur_line == 1 ? st.arrowhl : st.arrowminute, cf);
	if(seconds)
		PaintPtr(2, w, cm, cur_time / 60.0, 0.75, 2, cur_line == 2 ? st.arrowhl : st.arrowsecond, cf);
	
	DrawBg(w, 0, 0, sz.cx, hs, st.header);
}


And another strange behavior: you have the buttons to adjust minutes and hour, but you can also drag the needles. Dragging needles results in a smooth progression, but using buttons, especially the decrease buttons gives strange results when decreasing under zero, even increasing the time. Would you like me to fix this?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DropTime problem
Next Topic: Events to spin buttons, add mousewheel too.
Goto Forum:
  


Current Time: Thu Jun 25 16:12:19 GMT+2 2026

Total time taken to generate the page: 0.00521 seconds