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 » Developing U++ » UppHub » StaticImage enhancement
Re: StaticImage enhancement [message #39692 is a reply to message #39681] Wed, 17 April 2013 23:49 Go to previous messageGo to previous message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi Koldo,

USC language may not be able to open images by they're file name but it can open images from iml files ( which I think is sufficient )

The only problem is the code generated in the '.lay' file ==> it doesn't compile Confused

I think converting it to a character string would be enough (this type of processing is already done for Text and Label) so no big deal probably.

The main difficulty is how to select the iml image using this character string ???

Here is the modified StaticImage Usc:
ctrl ModifiedStaticImage {
	group "TEST";

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

	Frame      SetFrame @1;
	ImageFit   SetFit;
	ImageAngle SetAngle;
	Color      SetBackground;
	bool 	   UseAsBackground = false;
	Image       SetImage;                  // ------- NEW PROPERTY  the type is completely arbitrary --------

	Paint(w) {
		r = GetRect();

		DrawCtrlFrame(w, r, .SetFrame);

		sz = Size(r.right - r.left, r.bottom - r.top);

		DeflateRect(r);
		sz = Size(r.right - r.left, r.bottom - r.top);
		w.DrawRect(r.left, r.top, sz.cx, sz.cy, .SetBackground);
			
		img = .SetImage;   ---------- the iml pathName  is retreived from the property --------

		if (.SetFit == "0") {
			imagesize = GetImageSize(img);
			rectaspect  = sz.cx/sz.cy; 
			imageaspect = imagesize.cx/imagesize.cy;
			if (rectaspect > imageaspect) 
				w.DrawImage(r.left+(sz.cx-imageaspect*sz.cy)/2, r.top, imageaspect*sz.cy, sz.cy, img);
			else
				w.DrawImage(r.left, r.top+(sz.cy-sz.cx/imageaspect)/2, sz.cx, sz.cx/imageaspect, img);
		} else if (.SetFit == "1") 
			w.DrawImage(r.left, r.top, sz.cx, sz.cy, img);
		else if (.SetFit == "2") 
			w.DrawImage(r.left, r.top, img);
		else if (.SetFit == "3") {
			imagesize = GetImageSize(img);
			top = r.top;
			for (left = r.left; left < r.right; left += imagesize.cx) 
				for (top = r.top; top < r.bottom; top += imagesize.cy) 
					w.DrawImage(left, top, img);
		}
		if (.UseAsBackground) { 
			PaintCenterText(w, (r.right+r.left)/2,   (r.top+r.bottom)/2,   "Background", Arial(11), :SBlack);
			PaintCenterText(w, 1+(r.right+r.left)/2, 1+(r.top+r.bottom)/2, "Background", Arial(11), :SWhite);
		}
	}
}


BUT ....this gives the following layut file
LAYOUT(SplashScreenLayout, 240, 320)
	ITEM(ModifiedStaticImage, splashImg, SetImage(Controls4U:Controls4U.iml:ImageSample).HSizePosZ(0, 0).VSizePosZ(0, 0))
END_LAYOUT

This of coarse cannot compile

But this will
LAYOUT(SplashScreenLayout, 240, 320)
	ITEM(ModifiedStaticImage, splashImg, SetImage("Controls4U:Controls4U.iml:ImageSample").HSizePosZ(0, 0).VSizePosZ(0, 0))
END_LAYOUT


[Updated on: Wed, 17 April 2013 23:50]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Functions4U doesn't compile anymore
Next Topic: Added FSMon - FileSystem Monitor class
Goto Forum:
  


Current Time: Sun May 05 02:15:14 CEST 2024

Total time taken to generate the page: 0.02426 seconds