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?
Use slider from layout designer? [message #5816] Tue, 17 October 2006 21:56 Go to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Will Slider be available from the layout designer?
Re: Use slider from layout designer? [message #5851 is a reply to message #5816] Sat, 21 October 2006 03:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lectus wrote on Tue, 17 October 2006 15:56

Will Slider be available from the layout designer?


You can place Slider or any class that does not have .usc description by using "User class" and typing the class name manually.

Sure, .usc description would be useful as well, but right now is not top priority. Maybe the community could help with .usc scripts (it really is not that complicated).

Mirek
Re: Use slider from layout designer? [message #8493 is a reply to message #5851] Tue, 13 March 2007 23:02 Go to previous messageGo to next message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
Here is an update of CtrlLib.usc for SliderCtrl

ctrl SliderCtrl {
	group "Progress";

	GetMinSize() { sz = GetTextSize("X"); sz.cy += 2; return sz; }
	GetStdSize() { sz = GetMinSize(); sz.cx *= 7; return sz; }

	Frame  SetFrame @1;

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


Could someone please add it to the main code tree ?

Thanks,
Victor
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 next 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
Re: Use slider from layout designer? [message #8500 is a reply to message #8494] Wed, 14 March 2007 15:00 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thank you, now it the main tree!'

Mirek
Previous Topic: ProcessMessages question
Next Topic: ProgressIndicator in StatusBar
Goto Forum:
  


Current Time: Thu Mar 28 18:04:42 CET 2024

Total time taken to generate the page: 0.01725 seconds