demo_raster.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
---------------------------> Sather 1.1 source file <--------------------------
-- Demo of the raster widget
class DEMO_RASTER
class DEMO_RASTER is
-- The raster widget provides a much faster, lower level way of
-- drawing to the screen. It is not as sophisticated as the canvas
-- widget, but since it avoids silly tcl string conversions, it can
-- be orders of magnitude faster and is close to the speed of
-- raw X lib calls
include GUI_UTIL;
attr x0, y0: FLTD;
init is
raster ::= #TK_RASTER(root_window, "test_raster",
TK_RASTER_CFG::std, TK_PACK::top);
raster.bind_action(TK_BUTTON_EVENT::Press+2,
bind(make_demo(raster, _)));
raster.bind_action(TK_BUTTON_EVENT::Press+1,
bind(save_coords(_)));
-- raster.bind(EVENT::Motion.Mouse_1, bind(draw(raster, _)));
raster.bind_action(TK_BUTTON_EVENT::Release+1, bind(draw(raster, _)));
end;
save_coords(cb_info: TK_RASTER_CB) is
#ERR+"Save coordinates\n";
x0 := cb_info.x;
y0 := cb_info.y;
#OUT+"Start of square:"+x0+","+y0+"\n";
end;
draw(raster: TK_RASTER, cb_info: TK_RASTER_CB) is
raster.draw_rectangle(x0, y0, cb_info.x, cb_info.y);
raster.display;
end;
make_demo(raster: TK_RASTER, dummy_info: TK_RASTER_CB) is
#ERR+"Make demo\n";
fg_blue ::= raster.create_env.foreground("blue");
fg_green ::= raster.create_env.foreground("green");
fg_blue.activate;
loop i ::= 100.times!;
loop j ::= 100.times!;
raster.draw_point(i.fltd, j.fltd);
end;
end;
loop n ::= 10.times!;
if n.is_even then raster.set_env(fg_blue);
else raster.set_env(fg_green) end;
loop i ::= 100.times!;
loop j ::= 100.times!;
raster.draw_point((n+i+10).fltd, (n+j+10).fltd);
end;
end;
end;
raster.display;
end; -- make_demo
end;