/usr/share/mozart/doc/wp/node36.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>6.4 Example: An Animated Time Waster</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node35.html#section.canvas.tags"><< Prev</A></TD><TD><A href="node32.html">- Up -</A></TD></TR></TABLE><DIV id="section.canvas.animated"><H2><A name="section.canvas.animated">6.4 Example: An Animated Time Waster</A></H2><P> In this section we want to program a procedure that signals to the user that a particular computation is still running and entertains the user by some animation. </P><P> <A href="node36.html#figure.canvas.animclass">Figure 6.4</A> shows a subclass of <CODE>Tk<SPAN class="keyword">.</SPAN>canvasTag</CODE> that creates a bitmap item showing a magnifying glass and starts a thread to move that bitmap randomly. The random movement can be stopped by binding the variable <CODE>D</CODE> given as value for the feature <CODE>done</CODE>. If the animation has stopped indeed, the variable <CODE>S</CODE> gets bound, as you can see in method <CODE>move</CODE>. </P><P> </P><DIV id="figure.canvas.animclass"><HR><P><A name="figure.canvas.animclass"></A></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">RandCoord</SPAN>} {OS<SPAN class="keyword">.</SPAN>rand} <SPAN class="keyword">mod</SPAN> 20 <SPAN class="keyword">+</SPAN> 15 <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">RandMag</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Tk.canvasTag</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(parent:P done:D stopped:S)<BR> {<SPAN class="keyword">self</SPAN> tkInit(parent:P)}<BR> {P tk(create bitmap 0 0<BR> bitmap:<SPAN class="string">'@'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'/usr/share/mozart/doc/wp/magnifier.xbm'</SPAN> <BR> tags:<SPAN class="keyword">self</SPAN> foreground:blue)}<BR> <SPAN class="keyword">thread</SPAN> {<SPAN class="keyword">self</SPAN> move(D S)} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">move</SPAN>(D S)<BR> {WaitOr {Alarm 400} D}<BR> <SPAN class="keyword">if</SPAN> {IsDet D} <SPAN class="keyword">then</SPAN> S=<SPAN class="keyword">unit</SPAN> <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self</SPAN> tk(coords {RandCoord} {RandCoord})}<BR> {<SPAN class="keyword">self</SPAN> move(D S)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure 6.4:</STRONG> An animated time waster class.</P><HR></DIV><P> </P><P> The procedure <CODE>WaitDone</CODE> shown in <A href="node36.html#figure.canvas.waitdone">Figure 6.5</A> takes a variable <CODE>Done</CODE> which is used for signalling when the computation we are waiting for is finished. It creates a randomly moving magnifier item and as soon as the magnifier signals that it has been stopped (by <CODE>Stopped</CODE>) the toplevel windows is closed. </P><P> </P><DIV id="figure.canvas.waitdone"><HR><P><A name="figure.canvas.waitdone"></A></P><P> </P><DIV align="center"><IMG alt="" src="waitdone.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">WaitDone</SPAN> Done}<BR> W={New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit(withdraw:<SPAN class="keyword">true</SPAN>)}<BR> L={New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:W text:<SPAN class="string">'Computing...'</SPAN>)}<BR> C={New Tk<SPAN class="keyword">.</SPAN>canvas tkInit(parent:W width:50 height:50)}<BR> Stopped<BR><SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [wm(overrideredirect W <SPAN class="keyword">true</SPAN>)<BR> pack(L C side:left pady:2<SPAN class="keyword">#</SPAN>m padx:2<SPAN class="keyword">#</SPAN>m)<BR> wm(deiconify W)]}<BR> _={New RandMag init(parent:C done:Done stopped:Stopped)}<BR> <SPAN class="keyword">thread</SPAN> {Wait Stopped} {W tkClose} <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 6.5:</STRONG> A procedure for creating wait dialogs.</P><HR></DIV><P> </P><P> For example, </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">declare</SPAN> Done<BR>{WaitDone Done}</CODE></DD></DL><P> creates a waiting dialog which disappears by binding <CODE>Done</CODE> </P><DL class="anonymous"><DD class="code"><CODE>Done=<SPAN class="keyword">unit</SPAN></CODE></DD></DL><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node35.html#section.canvas.tags"><< Prev</A></TD><TD><A href="node32.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|