Home » Developing U++ » UppHub » StaticImage enhancement
Re: StaticImage enhancement [message #39692 is a reply to message #39681] |
Wed, 17 April 2013 23:49 |
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
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
|
|
|
|
|
StaticImage enhancement
By: Didier on Tue, 16 April 2013 23:15
|
|
|
Re: StaticImage enhancement
By: koldo on Wed, 17 April 2013 08:31
|
|
|
Re: StaticImage enhancement
By: Didier on Wed, 17 April 2013 23:49
|
|
|
Re: StaticImage enhancement
By: koldo on Fri, 19 April 2013 12:57
|
|
|
Re: StaticImage enhancement
By: Didier on Fri, 19 April 2013 15:44
|
|
|
Re: StaticImage enhancement
By: koldo on Sat, 20 April 2013 00:05
|
|
|
Re: StaticImage enhancement
By: Didier on Mon, 22 April 2013 20:14
|
|
|
Re: StaticImage enhancement
By: koldo on Tue, 23 April 2013 09:09
|
|
|
Re: StaticImage enhancement
By: Didier on Wed, 24 April 2013 00:02
|
|
|
Re: StaticImage enhancement
By: koldo on Wed, 24 April 2013 08:29
|
|
|
Re: StaticImage enhancement
By: Didier on Thu, 25 April 2013 20:45
|
Goto Forum:
Current Time: Sun May 05 02:15:14 CEST 2024
Total time taken to generate the page: 0.02426 seconds
|