/usr/share/mozart/doc/demo/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>Root functor: Board.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="board.html">- Up -</A></TD></TR></TABLE><DIV class="unnumbered" id="code.board"><H3><A name="code.board">Root functor: <CODE>Board.oz</CODE></A></H3><P class="margin"><A href="Board.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">local</SPAN> <BR> <BR> PickleCompressionLevel = 9<BR> <BR> <SPAN class="keyword">local</SPAN> <BR> InitServer = {NewName}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Server</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> port close serve<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="keyword">!</SPAN><SPAN class="functionname">InitServer</SPAN>(?Port)<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Serve</SPAN> X<SPAN class="keyword">|</SPAN>Xs}<BR> {<SPAN class="keyword">@</SPAN>serve X}<BR> {Serve Xs}<BR> <SPAN class="keyword">end</SPAN> <BR> Stream<BR> CloseException = {NewName}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">raise</SPAN> CloseException <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> {NewPort Stream Port}<BR> <SPAN class="keyword">@</SPAN>port = Port<BR> <SPAN class="keyword">@</SPAN>serve = <SPAN class="keyword">self</SPAN> <BR> <SPAN class="keyword">thread</SPAN> <BR> <SPAN class="keyword">try</SPAN> <BR> {Serve Stream}<BR> <SPAN class="keyword">catch</SPAN> <BR> <SPAN class="keyword">!</SPAN>CloseException <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NewServer</SPAN> Class Init}<BR> Port<BR> Object = {New Class InitServer(Port)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Object Init}<BR> Port<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NewAgenda</SPAN> ?Port ?Connect}<BR> Stream<BR> <SPAN class="keyword">in</SPAN> <BR> {NewPort Stream Port}<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Connect</SPAN> P}<BR> <SPAN class="keyword">thread</SPAN> <BR> {ForAll Stream <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> M} {Send P M} <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NewBoardFunctor</SPAN> IsMaster Ticket User}<BR> <BR> ArgSpec = record(master(single type:bool default:IsMaster)<BR> ticket(single type:atom default:Ticket)<BR> user(single type:atom default:User))<BR> <BR> <SPAN class="keyword">in</SPAN> <BR> <BR> <SPAN class="keyword">functor</SPAN> <BR> <BR> <SPAN class="keyword">import</SPAN> <BR> Tk<BR> TkTools<BR> Connection<BR> OS<BR> Application<BR> Pickle<BR> <BR> <SPAN class="keyword">define</SPAN> <BR> <BR> Args = {Application<SPAN class="keyword">.</SPAN>getCmdArgs ArgSpec}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SendApplet</SPAN> FileName Subject To}<BR> <SPAN class="keyword">if</SPAN> <BR> {OS<SPAN class="keyword">.</SPAN>system (<SPAN class="string">'metasend -b -e base64 -f '</SPAN><SPAN class="keyword">#</SPAN>FileName<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' -m application/x-oz-application'</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' -s "'</SPAN><SPAN class="keyword">#</SPAN>Subject<SPAN class="keyword">#</SPAN><SPAN class="string">'" -t '</SPAN><SPAN class="keyword">#</SPAN>To)}<SPAN class="keyword">\=</SPAN>0<BR> <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">raise</SPAN> failed(mail) <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Board</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Server</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> agenda connect<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN> <BR> {NewAgenda <SPAN class="keyword">@</SPAN>agenda <SPAN class="keyword">@</SPAN>connect}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newWindow</SPAN>($)<BR> Connect = <SPAN class="keyword">@</SPAN>connect % <SPAN class="comment">Don't pass reference to object<BR></SPAN> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Tk Desc}<BR> {NewServer Window init(Tk<BR> {AdjoinAt Desc<BR> agenda <SPAN class="keyword">@</SPAN>agenda}<BR> Connect) _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newTool</SPAN>(Label BClass WClass)<BR> T = {NewServer Tool init(BClass <SPAN class="keyword">@</SPAN>agenda)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Send <SPAN class="keyword">@</SPAN>agenda newTool(Label T WClass)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newUser</SPAN>(UserId Name)<BR> {Send <SPAN class="keyword">@</SPAN>agenda newUser(UserId Name)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">deleteUser</SPAN>(UserId)<BR> {Send <SPAN class="keyword">@</SPAN>agenda deleteUser(UserId)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> <BR> {Send <SPAN class="keyword">@</SPAN>agenda shutdown}<BR> {<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Tool</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Server</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> bClass agenda<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(BClass Agenda) % <SPAN class="comment">invoked by Board<BR></SPAN> <SPAN class="keyword">@</SPAN>bClass = BClass<BR> <SPAN class="keyword">@</SPAN>agenda = Agenda<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newBObj</SPAN>(X Y) % <SPAN class="comment">invoked by Window<BR></SPAN> {NewServer <SPAN class="keyword">@</SPAN>bClass init(<SPAN class="keyword">@</SPAN>agenda <SPAN class="keyword">@</SPAN>port X Y) _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">BObject</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> Server</SPAN> <BR> %% <SPAN class="comment">virtual, needs attributes kind, props, dx, dy<BR></SPAN> <SPAN class="keyword">attr</SPAN> <BR> agenda<BR> updating: <SPAN class="keyword">false</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Agenda Tool X Y) % <SPAN class="comment">invoked by Tool<BR></SPAN> Message = create(<SPAN class="keyword">@</SPAN>kind X Y X<SPAN class="keyword">+@</SPAN>dx Y<SPAN class="keyword">+@</SPAN>dy<BR> {List<SPAN class="keyword">.</SPAN>toRecord o {<SPAN class="keyword">self</SPAN> GetProps($)}})<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">@</SPAN>agenda = Agenda<BR> {Send <SPAN class="keyword">@</SPAN>agenda newWObj(<SPAN class="keyword">@</SPAN>port Tool Message)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">requestUpdate</SPAN>(Window) % <SPAN class="comment">invoked by Window<BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>updating <SPAN class="keyword">then</SPAN> {Send Window rejectRequest}<BR> <SPAN class="keyword">else</SPAN> <BR> updating <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> {Send Window grantUpdate({<SPAN class="keyword">self</SPAN> GetProps($)} <SPAN class="keyword">@</SPAN>port)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">requestClose</SPAN>(Window) % <SPAN class="comment">invoked by Window<BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>updating <SPAN class="keyword">then</SPAN> {Send Window rejectRequest}<BR> <SPAN class="keyword">else</SPAN> <BR> {Send <SPAN class="keyword">@</SPAN>agenda closeWObj(<SPAN class="keyword">@</SPAN>port Window)}<BR> {<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">update</SPAN>(NewProps) % <SPAN class="comment">invoked by Dialog<BR></SPAN> {ForAll NewProps <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A<SPAN class="keyword">#</SPAN>V} A <SPAN class="keyword"><-</SPAN> V <SPAN class="keyword">end</SPAN>}<BR> {Send <SPAN class="keyword">@</SPAN>agenda updateWObj(<SPAN class="keyword">@</SPAN>port NewProps)}<BR> updating <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">GetProps</SPAN>($)<BR> {Map <SPAN class="keyword">@</SPAN>props <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A} A<SPAN class="keyword">#@</SPAN>A <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Window</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Server</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> tk top bar radio canvas<BR> tool page1 page2<BR> BObj2WObj: nil<BR> Tool2WClass: nil<BR> Name2Label: nil<BR> BGColor: ivory<BR> Busy: <SPAN class="keyword">false</SPAN> <BR> MyDialog: nil<BR> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Tk Desc ConnectToAgenda) % <SPAN class="comment">invoked by Board<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionNewBObj</SPAN> X Y}<BR> {Send <SPAN class="keyword">@</SPAN>port NewBObj(X Y)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionDelete</SPAN>}<BR> {Send Desc<SPAN class="keyword">.</SPAN>agenda deleteUser(Desc<SPAN class="keyword">.</SPAN>user)} <BR> {Send <SPAN class="keyword">@</SPAN>port Close}<BR> <SPAN class="keyword">if</SPAN> {HasFeature Desc close} <SPAN class="keyword">then</SPAN> <BR> {Desc<SPAN class="keyword">.</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> Title = {CondSelect Desc title <SPAN class="string">'Drawing Board'</SPAN>}<BR> TkTools = Tk<SPAN class="keyword">.</SPAN>tools<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">@</SPAN>tool = {NewPort _}<BR> <SPAN class="keyword">@</SPAN>tk = Tk<BR> <SPAN class="keyword">@</SPAN>top = {New Tk<SPAN class="keyword">.</SPAN>toplevel<BR> tkInit(title:Title delete:ActionDelete<BR> withdraw:<SPAN class="keyword">true</SPAN>)}<BR> <SPAN class="keyword">@</SPAN>page1 = {New TkTools<SPAN class="keyword">.</SPAN>textframe tkInit(parent:<SPAN class="keyword">@</SPAN>top text:<SPAN class="string">'Tools'</SPAN>)}<BR> <SPAN class="keyword">@</SPAN>radio = {New Tk<SPAN class="keyword">.</SPAN>variable tkInit}<BR> <SPAN class="keyword">@</SPAN>page2 = {New TkTools<SPAN class="keyword">.</SPAN>textframe tkInit(parent:<SPAN class="keyword">@</SPAN>top text:<SPAN class="string">'Users'</SPAN>)}<BR> <SPAN class="keyword">@</SPAN>canvas = {New Tk<SPAN class="keyword">.</SPAN>canvas<BR> tkInit(parent:<SPAN class="keyword">@</SPAN>top bd:2 relief:sunken<BR> width:300 height:300 bg:<SPAN class="keyword">@</SPAN>BGColor)}<BR> {<SPAN class="keyword">@</SPAN>canvas tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> args: [int(x) int(y)]<BR> action: ActionNewBObj)}<BR> {Tk<SPAN class="keyword">.</SPAN>batch [grid(<SPAN class="keyword">@</SPAN>page1 row:0 column:0 pady:4 sticky:ew)<BR> grid(<SPAN class="keyword">@</SPAN>page2 row:1 column:0 pady:4 sticky:ew)<BR> grid(<SPAN class="keyword">@</SPAN>canvas row:0 column:1 sticky:sn padx:2 pady:2<BR> rowspan:4)<BR> grid({New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: <SPAN class="keyword">@</SPAN>top<BR> text: <SPAN class="string">'Mail Applet'</SPAN> <BR> action: Desc<SPAN class="keyword">.</SPAN>mail)}<BR> sticky:ew pady:4<BR> row:2 column:0)<BR> grid({New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: <SPAN class="keyword">@</SPAN>top<BR> text: <SPAN class="string">'Save Applet'</SPAN> <BR> action: Desc<SPAN class="keyword">.</SPAN>save)}<BR> sticky:ew pady:4<BR> row:3 column:0)<BR> update(idletasks)<BR> wm(deiconify <SPAN class="keyword">@</SPAN>top)]}<BR> {ConnectToAgenda <SPAN class="keyword">@</SPAN>port}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newTool</SPAN>(Label Tool WClass) % <SPAN class="comment">invoked by Board<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionSelectTool</SPAN>}<BR> {Send <SPAN class="keyword">@</SPAN>port SelectTool(Tool)}<BR> <SPAN class="keyword">end</SPAN> <BR> C<SPAN class="keyword">|</SPAN>S = {VirtualString<SPAN class="keyword">.</SPAN>toString Label}<BR> <BR> Button = {New <SPAN class="keyword">@</SPAN>tk<SPAN class="keyword">.</SPAN>radiobutton<BR> tkInit(parent: <SPAN class="keyword">@</SPAN>page1<SPAN class="keyword">.</SPAN>inner<BR> text: {Char<SPAN class="keyword">.</SPAN>toUpper C}<SPAN class="keyword">|</SPAN>S<BR> anchor: w<BR> bg:<SPAN class="string">'#b9b9b9'</SPAN> <BR> var: <SPAN class="keyword">@</SPAN>radio<BR> value: Label<BR> relief: groove<BR> bd: 2<BR> action: ActionSelectTool)}<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">@</SPAN>tk<SPAN class="keyword">.</SPAN>send grid(Button sticky:sew padx:2 pady:2)}<BR> {<SPAN class="keyword">self</SPAN> Put(Tool2WClass Tool WClass)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newUser</SPAN>(UserId Name) % <SPAN class="comment">invoked by Board<BR></SPAN> Label = {New <SPAN class="keyword">@</SPAN>tk<SPAN class="keyword">.</SPAN>label<BR> tkInit(parent: <SPAN class="keyword">@</SPAN>page2<SPAN class="keyword">.</SPAN>inner<BR> text: Name<BR> anchor: w<BR> bg: white<BR> bd: 2)}<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">@</SPAN>tk<SPAN class="keyword">.</SPAN>send grid(Label sticky:sew padx:2 pady:2)}<BR> {<SPAN class="keyword">self</SPAN> Put(Name2Label UserId Label)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">deleteUser</SPAN>(UserId)<BR> {{<SPAN class="keyword">self</SPAN> Get(Name2Label UserId $)} tkClose}<BR> {<SPAN class="keyword">self</SPAN> Delete(Name2Label UserId)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">shutdown</SPAN> % <SPAN class="comment">invoked by Board<BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>MyDialog <SPAN class="keyword">\=</SPAN> nil <SPAN class="keyword">then</SPAN> {Send <SPAN class="keyword">@</SPAN>MyDialog close} <SPAN class="keyword">end</SPAN> <BR> {<SPAN class="keyword">@</SPAN>top tkClose}<BR> {<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">NewBObj</SPAN>(X Y) % <SPAN class="comment">invoked by User <1><BR></SPAN> {Send <SPAN class="keyword">@</SPAN>tool newBObj(X Y)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">updateBObj</SPAN>(BObj) % <SPAN class="comment">invoked by User <2><BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Busy <SPAN class="keyword">then</SPAN> {<SPAN class="keyword">self</SPAN> Flash(black)} <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self</SPAN> MkBusy}<BR> {Send BObj requestUpdate(<SPAN class="keyword">@</SPAN>port)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">closeBObj</SPAN>(BObj) % <SPAN class="comment">invoked by User <3><BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Busy <SPAN class="keyword">then</SPAN> {<SPAN class="keyword">self</SPAN> Flash(black)} <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self</SPAN> MkBusy}<BR> {Send BObj requestClose(<SPAN class="keyword">@</SPAN>port)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SelectTool</SPAN>(Tool) % <SPAN class="comment">invoked by User <1><BR></SPAN> tool <SPAN class="keyword"><-</SPAN> Tool<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Close</SPAN> % <SPAN class="comment">invoked by User <1><BR></SPAN> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Busy <SPAN class="keyword">then</SPAN> {<SPAN class="keyword">self</SPAN> Flash(black)} <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">@</SPAN>top tkClose}<BR> {<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">newWObj</SPAN>(BObj Tool Message) % <SPAN class="comment">invoked by BObject through agenda<BR></SPAN> WObj = {New {<SPAN class="keyword">self</SPAN> Get(Tool2WClass Tool $)}<BR> init(<SPAN class="keyword">@</SPAN>tk <SPAN class="keyword">@</SPAN>port <SPAN class="keyword">@</SPAN>canvas BObj Message)}<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> Put(BObj2WObj BObj WObj)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">updateWObj</SPAN>(BObj Props) % <SPAN class="comment">invoked by BObject through agenda<BR></SPAN> {{<SPAN class="keyword">self</SPAN> Get(BObj2WObj BObj $)} update(Props)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">closeWObj</SPAN>(BObj Window) % <SPAN class="comment">invoked by BObject through agenda<BR></SPAN> <SPAN class="keyword">if</SPAN> Window <SPAN class="keyword">==</SPAN> <SPAN class="keyword">@</SPAN>port <SPAN class="keyword">then</SPAN> {<SPAN class="keyword">self</SPAN> MkIdle} <SPAN class="keyword">end</SPAN> <BR> {{<SPAN class="keyword">self</SPAN> Get(BObj2WObj BObj $)} close}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">grantUpdate</SPAN>(Old BObj) % <SPAN class="comment">invoked by BObject<BR></SPAN> MyDialog <SPAN class="keyword"><-</SPAN> {NewServer Dialog init(<SPAN class="keyword">@</SPAN>tk <SPAN class="keyword">@</SPAN>port Old BObj)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rejectRequest</SPAN> % <SPAN class="comment">invoked by BObject<BR></SPAN> {<SPAN class="keyword">self</SPAN> Flash(red)}<BR> {<SPAN class="keyword">self</SPAN> MkIdle}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">dialogClosed</SPAN> % <SPAN class="comment">invoked by Dialog<BR></SPAN> MyDialog <SPAN class="keyword"><-</SPAN> nil<BR> {<SPAN class="keyword">self</SPAN> MkIdle}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Put</SPAN>(A K V)<BR> A <SPAN class="keyword"><-</SPAN> K<SPAN class="keyword">#</SPAN>V <SPAN class="keyword">|</SPAN> <SPAN class="keyword">@</SPAN>A<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Get</SPAN>(A K $)<BR> {LookUp <SPAN class="keyword">@</SPAN>A K}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Delete</SPAN>(A K)<BR> A <SPAN class="keyword"><-</SPAN> {Remove <SPAN class="keyword">@</SPAN>A K}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">MkBusy</SPAN> <BR> Busy <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> {<SPAN class="keyword">self</SPAN> ChangeColor(thistle)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">MkIdle</SPAN> <BR> Busy <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> {<SPAN class="keyword">self</SPAN> ChangeColor(ivory)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ChangeColor</SPAN>(Color)<BR> {<SPAN class="keyword">@</SPAN>canvas tk(configure(bg:Color))}<BR> BGColor <SPAN class="keyword"><-</SPAN> Color<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Flash</SPAN>(Color)<BR> OldColor = <SPAN class="keyword">@</SPAN>BGColor<BR> <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> ChangeColor(Color)}<BR> {Delay 200}<BR> {<SPAN class="keyword">self</SPAN> ChangeColor(OldColor)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">LookUp</SPAN> K<SPAN class="keyword">#</SPAN>I<SPAN class="keyword">|</SPAN>KIr GK}<BR> <SPAN class="keyword">if</SPAN> K<SPAN class="keyword">==</SPAN>GK <SPAN class="keyword">then</SPAN> I <SPAN class="keyword">else</SPAN> {LookUp KIr GK} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Remove</SPAN> KIs DK}<BR> <SPAN class="keyword">case</SPAN> KIs <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> KI<SPAN class="keyword">|</SPAN>KIr <SPAN class="keyword">then</SPAN> K<SPAN class="keyword">#</SPAN>_=KI <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> K<SPAN class="keyword">==</SPAN>DK <SPAN class="keyword">then</SPAN> KIr <SPAN class="keyword">else</SPAN> KI<SPAN class="keyword">|</SPAN>{Remove KIr DK} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetHostName</SPAN>}<BR> UTS = {OS<SPAN class="keyword">.</SPAN>uName}<BR> <SPAN class="keyword">in</SPAN> <BR> UTS<SPAN class="keyword">.</SPAN>nodename<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">WObject</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> canvas tag<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Tk Window Canvas BObj Message) % <SPAN class="comment">invoked by Window<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionUpdate</SPAN>} {Send Window updateBObj(BObj)} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionClose</SPAN>} {Send Window closeBObj(BObj)} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">@</SPAN>canvas = Canvas<BR> <SPAN class="keyword">@</SPAN>tag = {New Tk<SPAN class="keyword">.</SPAN>canvasTag tkInit(parent:Canvas)}<BR> {Canvas tk(Message o(tag:<SPAN class="keyword">@</SPAN>tag))}<BR> {<SPAN class="keyword">@</SPAN>tag tkBind(event:<SPAN class="string">'<2>'</SPAN> action: ActionUpdate)}<BR> {<SPAN class="keyword">@</SPAN>tag tkBind(event:<SPAN class="string">'<3>'</SPAN> action: ActionClose)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">update</SPAN>(Props) % <SPAN class="comment">invoked by Window on request of BObject<BR></SPAN> {<SPAN class="keyword">@</SPAN>canvas tk({List<SPAN class="keyword">.</SPAN>toRecord itemconfigure (1<SPAN class="keyword">#@</SPAN>tag<SPAN class="keyword">|</SPAN>Props)})}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> % <SPAN class="comment">invoked by Window on request of BObject<BR></SPAN> {<SPAN class="keyword">@</SPAN>tag tk(delete)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Dialog</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Server</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> top window entries oldProps bObj<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Tk Window OldProps BObj) % <SPAN class="comment">invoked by Window<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionOk</SPAN>}<BR> {Send <SPAN class="keyword">@</SPAN>port Ok}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ActionCancel</SPAN>}<BR> {Send <SPAN class="keyword">@</SPAN>port Cancel}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">@</SPAN>window = Window<BR> <SPAN class="keyword">@</SPAN>oldProps= OldProps<BR> <SPAN class="keyword">@</SPAN>bObj = BObj<BR> <SPAN class="keyword">@</SPAN>top = {New Tk<SPAN class="keyword">.</SPAN>toplevel<BR> tkInit(title:<SPAN class="string">'Object Attributes'</SPAN> delete:ActionCancel<BR> withdraw:<SPAN class="keyword">true</SPAN>)}<BR> {<SPAN class="keyword">@</SPAN>top tkWM(geometry <SPAN class="string">'+'</SPAN><SPAN class="keyword">#</SPAN>{Tk<SPAN class="keyword">.</SPAN>returnInt winfo(pointerx <SPAN class="keyword">@</SPAN>top)}<SPAN class="keyword">+</SPAN>5<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">'+'</SPAN><SPAN class="keyword">#</SPAN>{Tk<SPAN class="keyword">.</SPAN>returnInt winfo(pointery <SPAN class="keyword">@</SPAN>top)}<SPAN class="keyword">+</SPAN>10)}<BR> <SPAN class="keyword">@</SPAN>entries = {List<SPAN class="keyword">.</SPAN>mapInd <SPAN class="keyword">@</SPAN>oldProps<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I A<SPAN class="keyword">#</SPAN>V}<BR> L = {New Tk<SPAN class="keyword">.</SPAN>label<BR> tkInit(parent:<SPAN class="keyword">@</SPAN>top text:A<SPAN class="keyword">#</SPAN><SPAN class="string">':'</SPAN> anchor:w)}<BR> E = {New Tk<SPAN class="keyword">.</SPAN>entry<BR> tkInit(parent:<SPAN class="keyword">@</SPAN>top width:10 bg:white)}<BR> <SPAN class="keyword">in</SPAN> <BR> {E tk(insert 0 V)}<BR> {Tk<SPAN class="keyword">.</SPAN>send grid(row:I L E sticky:w padx:4 pady:4)}<BR> A<SPAN class="keyword">#</SPAN>E<BR> <SPAN class="keyword">end</SPAN>}<BR> OkButton = {New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent:<SPAN class="keyword">@</SPAN>top text:<SPAN class="string">'Okay'</SPAN> action: ActionOk)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send grid(row:{Length <SPAN class="keyword">@</SPAN>entries}<SPAN class="keyword">+</SPAN>1 columnspan:2 pady:10 OkButton)}<BR> {<SPAN class="keyword">@</SPAN>top tkWM(deiconify)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> % <SPAN class="comment">invoked by Window<BR></SPAN> {<SPAN class="keyword">@</SPAN>top tkClose}<BR> {<SPAN class="keyword">@</SPAN>close}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Ok</SPAN> % <SPAN class="comment">invoked by User <1><BR></SPAN> NewProps = {Map <SPAN class="keyword">@</SPAN>entries <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A<SPAN class="keyword">#</SPAN>E} A <SPAN class="keyword">#</SPAN> {E tkReturn(get $)} <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">in</SPAN> <BR> {Send <SPAN class="keyword">@</SPAN>bObj update(NewProps)}<BR> {Send <SPAN class="keyword">@</SPAN>window dialogClosed}<BR> {<SPAN class="keyword">self</SPAN> close}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Cancel</SPAN> % <SPAN class="comment">invoked by User <1><BR></SPAN> {Send <SPAN class="keyword">@</SPAN>bObj update(<SPAN class="keyword">@</SPAN>oldProps)}<BR> {Send <SPAN class="keyword">@</SPAN>window dialogClosed}<BR> {<SPAN class="keyword">self</SPAN> close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Circle</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> BObject</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> kind: oval<BR> props: [fill width]<BR> dx: 20<BR> dy: 20<BR> fill: red<BR> width: 1<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Square</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Circle</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> kind: rectangle<BR> fill: blue<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">HBar</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Square</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> dy: 4<BR> fill: orange<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">VBar</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Square</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> dx: 4<BR> fill: green<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Arc</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Circle</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> kind: arc<BR> props: [fill start extent]<BR> fill: yellow<BR> start: 22<SPAN class="keyword">.</SPAN>5<BR> extent: 315<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MailBoard</SPAN>}<BR> FN = {OS<SPAN class="keyword">.</SPAN>tmpnam}<BR> <BR> To<BR> <BR> T = {New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit}<BR> L = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:T text:<SPAN class="string">'To: '</SPAN>)}<BR> E = {New Tk<SPAN class="keyword">.</SPAN>entry tkInit(parent:T width:20)}<BR> B = {New Tk<SPAN class="keyword">.</SPAN>button tkInit(parent:T text:<SPAN class="string">'Send'</SPAN> <BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> To = {E tkReturnAtom(get $)}<BR> {T tkClose}<BR> <SPAN class="keyword">end</SPAN>)}<BR> {Tk<SPAN class="keyword">.</SPAN>batch [pack(L E side:left pady:1<SPAN class="keyword">#</SPAN>m padx:1<SPAN class="keyword">#</SPAN>m)<BR> pack(B side:bottom pady:2<SPAN class="keyword">#</SPAN>m)<BR> focus(E)]}<BR> <BR> <SPAN class="keyword">in</SPAN> <BR> <BR> {Wait To}<BR> <BR> {Pickle<SPAN class="keyword">.</SPAN>saveCompressed<BR> {NewBoardFunctor <SPAN class="keyword">false</SPAN> Ticket To} FN PickleCompressionLevel}<BR> <BR> <SPAN class="keyword">try</SPAN> <BR> {SendApplet FN <SPAN class="string">'Oz Drawing Board'</SPAN> To}<BR> <SPAN class="keyword">catch</SPAN> _ <SPAN class="keyword">then</SPAN> <BR> D={New TkTools<SPAN class="keyword">.</SPAN>error<BR> tkInit(text: (<SPAN class="string">'Could not send mail. Please check whether '</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">'metamail package is installed properly.'</SPAN>))}<BR> <SPAN class="keyword">in</SPAN> <BR> {Wait D<SPAN class="keyword">.</SPAN>tkClosed}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> {OS<SPAN class="keyword">.</SPAN>unlink FN}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SaveBoard</SPAN>}<BR> <SPAN class="keyword">case</SPAN> {Tk<SPAN class="keyword">.</SPAN>return<BR> tk_getSaveFile(filetypes: q(q(<SPAN class="string">'Oz Applications'</SPAN> <BR> <SPAN class="string">'.oza'</SPAN>)<BR> q(<SPAN class="string">'All files'</SPAN> <BR> <SPAN class="string">'*'</SPAN>)))}<BR> <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> S <SPAN class="keyword">then</SPAN> <BR> {Pickle<SPAN class="keyword">.</SPAN>saveCompressed<BR> {NewBoardFunctor <SPAN class="keyword">false</SPAN> Ticket <SPAN class="string">'Saved'</SPAN>}<BR> S PickleCompressionLevel}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> Ticket B<BR> <BR> UserId = {NewName}<BR> <BR> <SPAN class="keyword">if</SPAN> Args<SPAN class="keyword">.</SPAN>master <SPAN class="keyword">then</SPAN> <BR> B = {NewServer Board init}<BR> Ticket = {New Connection<SPAN class="keyword">.</SPAN>gate init(B $) _}<BR> <SPAN class="keyword">else</SPAN> <BR> Ticket = Args<SPAN class="keyword">.</SPAN>ticket<BR> B = {Connection<SPAN class="keyword">.</SPAN>take Ticket}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> {Wait Tk}<BR> {Wait TkTools}<BR> <BR> {{Send B newWindow($)} {AdjoinAt Tk tools TkTools}<BR> d(title: <SPAN class="string">'Drawing Board'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'@'</SPAN><SPAN class="keyword">#</SPAN>{GetHostName}<BR> close: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {Application<SPAN class="keyword">.</SPAN>exit 0}<BR> <SPAN class="keyword">end</SPAN> <BR> mail: MailBoard<BR> save: SaveBoard<BR> user: UserId)}<BR> <BR> {Send B newUser(UserId Args<SPAN class="keyword">.</SPAN>user)}<BR> <BR> <SPAN class="keyword">if</SPAN> Args<SPAN class="keyword">.</SPAN>master <SPAN class="keyword">then</SPAN> <BR> {Send B newTool(circle Circle WObject)}<BR> {Send B newTool(square Square WObject)}<BR> {Send B newTool(hbar HBar WObject)}<BR> {Send B newTool(vbar VBar WObject)}<BR> {Send B newTool(arc Arc WObject)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">in</SPAN> <BR> <BR> {NewBoardFunctor <SPAN class="keyword">true</SPAN> <SPAN class="string">''</SPAN> master}<BR> <BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="board.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|