/usr/share/mozart/doc/demo/node7.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>Graphical tools to manipulate tasks: Tools.oz</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="node6.html#code.jobshop.taskboard"><< Prev</A></TD><TD><A href="jobshop.html">- Up -</A></TD><TD><A href="node8.html#code.jobshop.configure">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.jobshop.tools"><H3><A name="code.jobshop.tools">Graphical tools to manipulate tasks: <CODE>Tools.oz</CODE></A></H3><P class="margin"><A href="JobShop/Tools.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">import</SPAN> <BR> TkTools<BR> Tk<BR> Explorer<BR> <BR> Configure(text: Helv<BR> typeSmall: SmallCourierBold<BR> resColors: ResColors<BR> maxDur: MaxDur<BR> maxRes: MaxRes)<BR> <BR><SPAN class="keyword">export</SPAN> <BR> <SPAN class="string">'class'</SPAN>: Tools<BR> <BR><SPAN class="keyword">define</SPAN> <BR> <BR> <SPAN class="keyword">local</SPAN> <BR> HideY = 1000<BR> Rows = 2<BR> Cols = MaxRes <SPAN class="keyword">div</SPAN> Rows<BR> CellSize = 20<BR> CellBorder = 1<BR> CellFrame = 1<BR> CellDelta = CellBorder <SPAN class="keyword">+</SPAN> CellFrame<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">ResourceTool</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> TkTools.textframe</SPAN> <BR> <SPAN class="keyword">feat</SPAN> <BR> Canvas<BR> DisableTag<BR> Action<BR> <SPAN class="keyword">attr</SPAN> <BR> Selected: <SPAN class="keyword">unit</SPAN> <BR> Enabled: <SPAN class="keyword">false</SPAN> <BR> Resource: 1<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">tkInit</SPAN>(parent:P action:A)<BR> TkTools<SPAN class="keyword">.</SPAN>textframe<SPAN class="keyword">,</SPAN> tkInit(parent:P font:Helv text:<SPAN class="string">'Resource'</SPAN>)<BR> CA = {New Tk<SPAN class="keyword">.</SPAN>canvas tkInit(parent: <SPAN class="keyword">self.</SPAN>inner<BR> width: CellSize <SPAN class="keyword">*</SPAN> Cols <SPAN class="keyword">+</SPAN> 2<BR> height: CellSize <SPAN class="keyword">*</SPAN> Rows <SPAN class="keyword">+</SPAN> 2<BR> xscrollinc: 1<BR> yscrollinc: 1)}<BR> DT = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:CA)}<BR> <SPAN class="keyword">in</SPAN> <BR> {DT tkBind(event:<SPAN class="string">'<1>'</SPAN> action:<SPAN class="keyword">self#</SPAN>enable)}<BR> {CA tk(yview scroll <SPAN class="keyword">~</SPAN>2 units)}<BR> {CA tk(xview scroll <SPAN class="keyword">~</SPAN>2 units)}<BR> {For 1 Rows 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> R}<BR> Y = (Rows <SPAN class="keyword">-</SPAN> R) <SPAN class="keyword">*</SPAN> CellSize<BR> <SPAN class="keyword">in</SPAN> <BR> {For 1 Cols 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> C}<BR> X = (Cols <SPAN class="keyword">-</SPAN> C) <SPAN class="keyword">*</SPAN> CellSize<BR> Res = (R<SPAN class="keyword">-</SPAN>1)<SPAN class="keyword">*</SPAN>Cols <SPAN class="keyword">+</SPAN> C<BR> T = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:CA)}<BR> <SPAN class="keyword">in</SPAN> <BR> {CA tk(create rectangle<BR> X <SPAN class="keyword">+</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellDelta<BR> X <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> fill: ResColors<SPAN class="keyword">.</SPAN>Res<BR> width: 1<BR> outline: white<BR> tags: T)}<BR> {CA tk(create rectangle<BR> X <SPAN class="keyword">+</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellDelta<BR> X <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> fill: gray50<BR> outline: <SPAN class="string">''</SPAN> <BR> stipple: gray50<BR> tags: q(T DT))}<BR> {T tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> action: <SPAN class="keyword">self</SPAN> <SPAN class="keyword">#</SPAN> Choose(Res T))}<BR> <SPAN class="keyword">if</SPAN> Res<SPAN class="keyword">==</SPAN>MaxRes <SPAN class="keyword">then</SPAN> Selected <SPAN class="keyword"><-</SPAN> T<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">self.</SPAN>DisableTag = DT<BR> <SPAN class="keyword">self.</SPAN>Canvas = CA<BR> <SPAN class="keyword">self.</SPAN>Action = A<BR> ResourceTool<SPAN class="keyword">,</SPAN> Choose(MaxRes <SPAN class="keyword">@</SPAN>Selected)<BR> {Tk<SPAN class="keyword">.</SPAN>send pack(CA)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Choose</SPAN>(Res Tag)<BR> {<SPAN class="keyword">@</SPAN>Selected tk(itemconfigure width:1 outline:white)}<BR> {Tag tk(itemconfigure width:CellFrame<SPAN class="keyword">+</SPAN>1 outline:black)}<BR> Selected <SPAN class="keyword"><-</SPAN> Tag<BR> Resource <SPAN class="keyword"><-</SPAN> Res<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getRes</SPAN>($)<BR> <SPAN class="keyword">@</SPAN>Resource<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">disable</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Enabled <SPAN class="keyword">then</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>DisableTag tk(move 0 HideY)}<BR> Enabled <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">enable</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Enabled <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>DisableTag tk(move 0 <SPAN class="keyword">~</SPAN>HideY)}<BR> Enabled <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>Action}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <SPAN class="keyword">local</SPAN> <BR> HideY = 1000<BR> Rows = 2<BR> Cols = MaxDur <SPAN class="keyword">div</SPAN> Rows<BR> CellSize = 20<BR> CellBorder = 1<BR> CellFrame = 1<BR> CellDelta = CellBorder <SPAN class="keyword">+</SPAN> CellFrame<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">DurationTool</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> TkTools.textframe</SPAN> <BR> <SPAN class="keyword">feat</SPAN> <BR> Canvas<BR> DisableTag<BR> Action<BR> <SPAN class="keyword">attr</SPAN> <BR> Selected: <SPAN class="keyword">unit</SPAN> <BR> Enabled: <SPAN class="keyword">false</SPAN> <BR> Duration: 1<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">tkInit</SPAN>(parent:P action:A)<BR> TkTools<SPAN class="keyword">.</SPAN>textframe<SPAN class="keyword">,</SPAN> tkInit(parent: P<BR> font: Helv<BR> text: <SPAN class="string">'Duration'</SPAN>)<BR> CA = {New Tk<SPAN class="keyword">.</SPAN>canvas tkInit(parent: <SPAN class="keyword">self.</SPAN>inner<BR> width: CellSize <SPAN class="keyword">*</SPAN> Cols <SPAN class="keyword">+</SPAN> 2<BR> height: CellSize <SPAN class="keyword">*</SPAN> Rows <SPAN class="keyword">+</SPAN> 2<BR> xscrollinc: 1<BR> yscrollinc: 1)}<BR> DT = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:CA)}<BR> <SPAN class="keyword">in</SPAN> <BR> {CA tk(yview scroll <SPAN class="keyword">~</SPAN>2 units)}<BR> {CA tk(xview scroll <SPAN class="keyword">~</SPAN>2 units)}<BR> {DT tkBind(event:<SPAN class="string">'<1>'</SPAN> action:<SPAN class="keyword">self#</SPAN>enable)}<BR> {For 1 Rows 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> R}<BR> Y = (Rows <SPAN class="keyword">-</SPAN> R) <SPAN class="keyword">*</SPAN> CellSize<BR> <SPAN class="keyword">in</SPAN> <BR> {For 1 Cols 1<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> C}<BR> X = (Cols <SPAN class="keyword">-</SPAN> C) <SPAN class="keyword">*</SPAN> CellSize<BR> Dur = (Rows<SPAN class="keyword">-</SPAN>R)<SPAN class="keyword">*</SPAN>Cols <SPAN class="keyword">+</SPAN> Cols<SPAN class="keyword">-</SPAN>C<SPAN class="keyword">+</SPAN>1<BR> T1 = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:CA)}<BR> T2 = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:CA)}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> Dur<SPAN class="keyword">=<</SPAN>MaxDur <SPAN class="keyword">then</SPAN> <BR> {CA tk(create rectangle<BR> X <SPAN class="keyword">+</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellDelta<BR> X <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> width: 1<BR> fill: wheat<BR> outline: white<BR> tags: q(T1 T2))}<BR> {CA tk(create text<BR> X <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">div</SPAN> 2<BR> Y <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">div</SPAN> 2<BR> text: Dur<BR> font: SmallCourierBold<BR> tags: T2)}<BR> {CA tk(create rectangle<BR> X <SPAN class="keyword">+</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellDelta<BR> X <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> Y <SPAN class="keyword">+</SPAN> CellSize <SPAN class="keyword">-</SPAN> CellDelta<BR> fill: gray50<BR> outline: <SPAN class="string">''</SPAN> <BR> stipple: gray50<BR> tags: q(T1 T2 DT))}<BR> {T2 tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> action: <SPAN class="keyword">self</SPAN> <SPAN class="keyword">#</SPAN> Choose(Dur T1))}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">if</SPAN> Dur<SPAN class="keyword">==</SPAN>1 <SPAN class="keyword">then</SPAN> Selected <SPAN class="keyword"><-</SPAN> T1<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">self.</SPAN>DisableTag = DT<BR> <SPAN class="keyword">self.</SPAN>Canvas = CA<BR> <SPAN class="keyword">self.</SPAN>Action = A<BR> DurationTool<SPAN class="keyword">,</SPAN> Choose(1 <SPAN class="keyword">@</SPAN>Selected)<BR> {Tk<SPAN class="keyword">.</SPAN>send pack(CA)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Choose</SPAN>(Dur Tag)<BR> {<SPAN class="keyword">@</SPAN>Selected tk(itemconfigure width:1 outline:white)}<BR> {Tag tk(itemconfigure width:CellFrame<SPAN class="keyword">+</SPAN>1 outline:black)}<BR> Selected <SPAN class="keyword"><-</SPAN> Tag<BR> Duration <SPAN class="keyword"><-</SPAN> Dur<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getDur</SPAN>($)<BR> <SPAN class="keyword">@</SPAN>Duration<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">disable</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Enabled <SPAN class="keyword">then</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>DisableTag tk(move 0 HideY)}<BR> Enabled <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">enable</SPAN> <BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Enabled <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>DisableTag tk(move 0 <SPAN class="keyword">~</SPAN>HideY)}<BR> Enabled <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>Action}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Tools</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> TkTools.note</SPAN> <BR> <SPAN class="keyword">feat</SPAN> Board<BR> <SPAN class="keyword">attr</SPAN> Current:create(MaxRes 1)<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">tkInit</SPAN>(parent:P board:B)<BR> TkTools<SPAN class="keyword">.</SPAN>note<SPAN class="keyword">,</SPAN>tkInit(parent:P text:<SPAN class="string">'Edit'</SPAN>)<BR> <BR> Var = {New Tk<SPAN class="keyword">.</SPAN>variable tkInit(create)}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ResA</SPAN>}<BR> {DurT disable}<BR> {Var tkSet(none)}<BR> Current <SPAN class="keyword"><-</SPAN> resource(<SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {ResT getRes($)} <SPAN class="keyword">end</SPAN>)<BR> <SPAN class="keyword">end</SPAN> <BR> ResT = {New ResourceTool tkInit(parent:<SPAN class="keyword">self</SPAN> action:ResA)}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">DurA</SPAN>}<BR> {ResT disable}<BR> {Var tkSet(none)}<BR> Current <SPAN class="keyword"><-</SPAN> duration(<SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {DurT getDur($)} <SPAN class="keyword">end</SPAN>)<BR> <SPAN class="keyword">end</SPAN> <BR> DurT = {New DurationTool tkInit(parent:<SPAN class="keyword">self</SPAN> action:DurA)}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">CreA</SPAN>}<BR> {ResT disable}<BR> {DurT disable}<BR> Current <SPAN class="keyword"><-</SPAN> create({ResT getRes($)} {DurT getDur($)})<BR> <SPAN class="keyword">end</SPAN> <BR> CreT = {New Tk<SPAN class="keyword">.</SPAN>radiobutton tkInit(parent: <SPAN class="keyword">self</SPAN> <BR> var: Var<BR> val: create<BR> text: <SPAN class="string">'Create Task'</SPAN> <BR> action: CreA<BR> font: Helv<BR> relief: ridge<BR> bd: 2<BR> anchor: w)}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">DelA</SPAN>}<BR> {ResT disable} {DurT disable}<BR> Current <SPAN class="keyword"><-</SPAN> delete<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> DelT = {New Tk<SPAN class="keyword">.</SPAN>radiobutton tkInit(parent: <SPAN class="keyword">self</SPAN> <BR> var: Var<BR> val: delete<BR> text: <SPAN class="string">'Delete Task'</SPAN> <BR> action: DelA<BR> font: Helv<BR> relief: ridge<BR> bd: 2<BR> anchor: w)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [pack(ResT DurT padx:2 fill:x)<BR> pack(CreT DelT pady:1 ipadx:2 fill:x)]}<BR> {DurT disable}<BR> {ResT disable}<BR> <SPAN class="keyword">self.</SPAN>Board = B<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getTool</SPAN>($)<BR> <SPAN class="keyword">@</SPAN>Current<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">toTop</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>Board setEdit}<BR> {Explorer<SPAN class="keyword">.</SPAN>object close}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node6.html#code.jobshop.taskboard"><< Prev</A></TD><TD><A href="jobshop.html">- Up -</A></TD><TD><A href="node8.html#code.jobshop.configure">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|