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); } } }
LAYOUT(SplashScreenLayout, 240, 320) ITEM(ModifiedStaticImage, splashImg, SetImage(Controls4U:Controls4U.iml:ImageSample).HSizePosZ(0, 0).VSizePosZ(0, 0)) END_LAYOUT
LAYOUT(SplashScreenLayout, 240, 320) ITEM(ModifiedStaticImage, splashImg, SetImage("Controls4U:Controls4U.iml:ImageSample").HSizePosZ(0, 0).VSizePosZ(0, 0)) END_LAYOUT
Image img = LoadFromIml("Controls4U:Controls4U.iml:ImageSample_90");
Quote: |
It is possible to call a .iml Image by program "manually" but AFAIK this is only possible for the IMAGECLASS and IMAGEFILE defined in source. This way StaticImage code cannot open an IMAGEFILE defined in your source. |
Quote: |
Image img = LoadFromIml("Controls4U:Controls4U.iml:ImageSample_90"); |
Quote: |
implement first an atan() or something like a DrawCircle() function in .usc. |
Quote: |
implement first an atan() or something like a DrawCircle() function in .usc. |
Quote: |
Does it exist an usc PaintCircle() function?. I could not found it. |
fn PaintEllipse(w, left, top, right, bottom, width, color) { if (width < 1) width = 1; a = (right-left)/2.; b = (bottom-top)/2.; width_2 = width/2.; delta = Pi()/20.; maxi = 2.*Pi(); for (i = 0; i < maxi; i += delta) { if (i == 0) { x0 = left + a + (a - width_2); y0 = top + b; } else { x0 = x1; y0 = y1; } x1 = left + a + (a - width_2) * cos(i + delta); y1 = top + b + (b - width_2) * sin(i + delta); w.DrawLine(x0, y0, x1, y1, width, color); } } fn DrawCircle(w, cx, cy, R, width, color) { PaintEllipse(w, cx-R-width/2., cy-R-width/2., cx+R+width/2., cy+R+width/2., width, color); } fn PaintArc(w, cx, cy, R, ang0, ang1, direction, width, color) { if (direction == -1) { c = ang0; ang0 = ang1; ang1 = c; } ang0 = ang0*Pi()/180; ang1 = ang1*Pi()/180; delta = 3*Pi()/180; if (ang0 > ang1) ang1 += 2*Pi(); for (i = ang0; i < ang1; i += delta) { if (i == ang0) { x0 = cx + R*cos(i); y0 = cy - R*sin(i); } else { x0 = x1; y0 = y1; } x1 = cx + R*cos(i + delta); y1 = cy - R*sin(i + delta); w.DrawLine(x0, y0, x1, y1, width, color); } } fn FillEllipse(w, left, top, right, bottom, background) { a = (right-left)/2.; b = (bottom-top)/2.; if (a <= 0.5 || b <= 0.5) { w.DrawLine(left, top, right, bottom, 1, background); return; } delta = Pi()/10.; x0 = left + a; y0 = top + b; for (i = delta; i < Pi()/2.; i += delta) { x1 = a * cos(i); y1 = b * sin(i); w.DrawRect(x0-x1 , y0-y1, 2*x1 , 2*y1, background); } width = min(a, b)/4.; if (width > 1) PaintEllipse(w, left, top, right, bottom, width, background); } fn FillCircle(w, cx, cy, R, color) { FillEllipse(w, cx-R, cy-R, cx+R, cy+R, color); }