implement HelloPrefab; include "sys.m"; include "draw.m"; include "prefab.m"; sys: Sys; draw: Draw; prefab: Prefab; # import prefab elements Display, Font, Rect, Point, Image, Screen: import draw; Style, Element, Compound, Environ: import prefab; HelloPrefab : module { init: fn(ctxt: ref Draw->Context, argv: list of string); }; init(ctxt: ref Draw->Context, argv: list of string) { sys = load Sys Sys->PATH; draw = load Draw Draw->PATH; prefab = load Prefab Prefab->PATH; display := Display.allocate(nil); disp := display.image; white := display.color(Draw->White); yellow := display.color(Draw->Yellow); black := display.color(Draw->Black); grey := display.rgb(160,160,160); ones := display.ones; screen := Screen.allocate(disp, white, 1); textfont := Font.open(display, "/fonts/lucidasans/ unicode.13.font"); titlefont := Font.open(display, "/fonts/lucidasans/ italiclatin1.10.font"); textstyle := ref Style( titlefont, # title font textfont, # text font grey, # element color black, # edge color yellow, # title color black, # text color white); # highlight color env := ref Environ(screen, textstyle); msg: string; if ((tl argv) != nil) { msg = "Hello, " + (hd(tl argv)) + "!"; } else { msg = "Hello, World!"; } icon := display.open("/icons/lucent.bit"); dy := (icon.r.dy()-textfont.height)/2; wintitle := Element.text(env, "Inferno Prefab Example", ((0,0),(0,0)), Prefab->ETitle); ie := Element.icon(env, icon.r, icon, ones); se:= Element.separator(env, ((0,0), (10,0)), display.zeros, display.zeros); te := Element.text(env, msg, ((0,dy),(0,dy)), Prefab- >EText); le := Element.elist(env, ie, Prefab->EHorizontal); le.append(se); le.append(te); le.append(se); le.adjust(Prefab->Adjpack, Prefab->Adjleft); c := Compound.box(env, (20,10), wintitle, le); c.draw(); sys->sleep(15000); }