Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Slider&ProgressIndicator » Use slider from layout designer?
Re: Use slider from layout designer? [message #8494 is a reply to message #8493] Wed, 14 March 2007 00:17 Go to previous messageGo to previous message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
Please discard my previous message... The following code now works with Ctrl frames. I have also included a "basic" ProgressIndicator. They should be ready for integration in the main branch.

ctrl SliderCtrl {
	group "Progress";

	GetMinSize() { return Size(0, 0); }
	GetStdSize() { return Size(64, 24); }

	Frame  SetFrame @1;

	Paint(w) {
		r = GetRect();
		DrawCtrlFrame(w, r, .SetFrame);
		
		sz = Size(r.right - r.left, r.bottom - r.top);

		halfX = int(r.left + r.right) >> 1;
		halfY = int(r.top + r.bottom) >> 1;
		
		if (sz.cx < sz.cy) {
			DrawInsetFrame(w, Rect(halfX - 2, r.top + 2, halfX + 2, r.bottom - 2));
			imgSz = GetImageSize("CtrlImg::vthumb");			
			w.DrawImage(halfX - (imgSz.cx >> 1), halfY - (imgSz.cy >> 1), "CtrlImg::vthumb");
		} else {
			DrawInsetFrame(w, Rect(r.left + 2, halfY - 2, r.right - 2, halfY + 2));
			imgSz = GetImageSize("CtrlImg::hthumb");			
			w.DrawImage(halfX - (imgSz.cx >> 1), halfY - (imgSz.cy >> 1), "CtrlImg::hthumb");			
		}					
	}
}


ctrl ProgressIndicator {
	group "Progress";

	GetMinSize() { return Size(0, 0); }
	GetStdSize() { return Size(64, 24); }

	Frame  SetFrame @1;

	Paint(w) {
		r = GetRect();

		DrawCtrlFrame(w, r, .SetFrame);	
		DrawInsetFrame(w, r);
		
		sz = Size(r.right - r.left, r.bottom - r.top);
		
		w.DrawRect(r.left, r.top, sz.cx, sz.cy, :SBlack);
		DeflateRect(r);
		sz = Size(r.right - r.left, r.bottom - r.top);
		w.DrawRect(r.left, r.top, sz.cx, sz.cy, :SWhite);		

		if(sz.cx > sz.cy) {
			w.DrawRect(r.left, r.top, sz.cx >> 2, sz.cy, :SLtGreen);		
		}
		else {
			w.DrawRect(r.left, r.bottom - (sz.cy >> 2), sz.cx, sz.cy >> 2, :SLtGreen);
		}
	}
}


Writting usc is very easy... when you understand how to deal with frames Smile
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ProcessMessages question
Next Topic: ProgressIndicator in StatusBar
Goto Forum:
  


Current Time: Sun Aug 24 21:45:54 CEST 2025

Total time taken to generate the page: 0.05096 seconds