/usr/share/mozart/doc/demo/Board.oz 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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | %%%
%%% Authors:
%%%   Michael Mehl (mehl@dfki.de)
%%%   Ralf Scheidhauer (scheidhr@dfki.de)
%%%   Christian Schulte <schulte@ps.uni-sb.de>
%%%   Gert Smolka (smolka@dfki.de)
%%%
%%% Copyright:
%%%   Michael Mehl, 1997
%%%   Ralf Scheidhauer, 1997
%%%   Christian Schulte, 1997, 1998
%%%   Gert Smolka, 1997
%%%
%%% Last change:
%%%   $Date: 1999-01-21 21:56:20 +0100 (Thu, 21 Jan 1999) $ by $Author: schulte $
%%%   $Revision: 10589 $
%%%
%%% This file is part of Mozart, an implementation
%%% of Oz 3
%%%    http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%%    http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%
local
   PickleCompressionLevel = 9
   
   local
      InitServer = {NewName}
   in
      class Server
	 attr
	    port close serve
	    
	 meth !InitServer(?Port)
	    proc {Serve X|Xs}
	       {@serve X}
	       {Serve Xs}
	    end
	    Stream
	    CloseException = {NewName}
	 in
	    proc {@close}
	       raise CloseException end
	    end
	    {NewPort Stream Port}
	    @port  = Port
	    @serve = self
	    thread
	       try
		  {Serve Stream}
	       catch
		  !CloseException then skip
	       end
	    end
	 end
      end
      
      fun {NewServer Class Init}
	 Port
	 Object = {New Class InitServer(Port)}
      in
	 {Object Init}
	 Port
      end
      
   end
   
   proc {NewAgenda ?Port ?Connect}
      Stream
   in
      {NewPort Stream Port}
      proc {Connect P}
	 thread
	    {ForAll Stream proc {$ M} {Send P M} end}
	 end
      end
   end
   
   fun {NewBoardFunctor IsMaster Ticket User}
      
      ArgSpec = record(master(single type:bool default:IsMaster)
		       ticket(single type:atom default:Ticket)
		       user(single type:atom   default:User))
   in
      
      functor
      
      import
	 Tk
	 TkTools
	 Connection
	 OS
	 Application
	 Pickle
      
      define
   
	 Args = {Application.getCmdArgs ArgSpec}
	 proc {SendApplet FileName Subject To}
	    if
	       {OS.system ('metasend -b -e base64 -f '#FileName#
			   ' -m application/x-oz-application'#
			   ' -s "'#Subject#'" -t '#To)}\=0
	    then
	       raise failed(mail) end
	    end
	 end
	 class Board from Server
	    attr
	       agenda connect
	    
	    meth init
	       {NewAgenda @agenda @connect}
	    end
	 
	    meth newWindow($)
	       Connect = @connect % Don't pass reference to object
	    in
	       proc {$ Tk Desc}
		  {NewServer Window init(Tk
					 {AdjoinAt Desc
					  agenda @agenda}
					 Connect) _}
	       end
	    end
	 
	    meth newTool(Label BClass WClass)
	       T = {NewServer Tool init(BClass @agenda)}
	    in
	       {Send @agenda newTool(Label T WClass)}
	    end
	 
	    meth newUser(UserId Name)
	       {Send @agenda newUser(UserId Name)}
	    end
	 
	    meth deleteUser(UserId)
	       {Send @agenda deleteUser(UserId)}
	    end
	 
	    meth close
	       {Send @agenda shutdown}
	       {@close}
	    end
	 end
      
	 class Tool from Server
	    attr
	       bClass  agenda
	    
	    meth init(BClass Agenda) % invoked by Board
	       @bClass  = BClass
	       @agenda  = Agenda
	    end
	 
	    meth newBObj(X Y) % invoked by Window
	       {NewServer @bClass init(@agenda @port X Y) _}
	    end
	 end
      
	 class BObject
	    from Server
	       %% virtual, needs attributes kind, props, dx, dy
	    attr
	       agenda
	       updating: false
	    
	    meth init(Agenda Tool X Y) % invoked by Tool
	       Message = create(@kind X Y X+@dx Y+@dy
				{List.toRecord o {self GetProps($)}})
	    in
	       @agenda = Agenda
	       {Send @agenda newWObj(@port Tool Message)}
	    end
	 
	    meth requestUpdate(Window) % invoked by Window
	       if @updating then {Send Window rejectRequest}
	       else
		  updating <- true
		  {Send Window grantUpdate({self GetProps($)} @port)}
	       end
	    end
	 
	    meth requestClose(Window) % invoked by Window
	       if @updating then {Send Window rejectRequest}
	       else
		  {Send @agenda closeWObj(@port Window)}
		  {@close}
	       end
	    end
	 
	    meth update(NewProps) % invoked by Dialog
	       {ForAll NewProps proc {$ A#V} A <- V end}
	       {Send @agenda updateWObj(@port NewProps)}
	       updating <- false
	    end
	 
	    meth GetProps($)
	       {Map @props fun {$ A} A#@A end}
	    end
	 end
      
	 class Window from Server
	    attr
	       tk  top  bar  radio  canvas
	       tool page1 page2
	       BObj2WObj:   nil
	       Tool2WClass: nil
	       Name2Label:  nil
	       BGColor:     ivory
	       Busy:        false
	       MyDialog:    nil
	    
	    
	    meth init(Tk Desc ConnectToAgenda) % invoked by Board
	       proc {ActionNewBObj X Y}
		  {Send @port NewBObj(X Y)}
	       end
	       proc {ActionDelete}
		  {Send Desc.agenda deleteUser(Desc.user)} 
		  {Send @port   Close}
		  if {HasFeature Desc close} then
		     {Desc.close}
		  end
	       end
	       Title   = {CondSelect Desc title 'Drawing Board'}
	       TkTools = Tk.tools
	    in
	       @tool   = {NewPort _}
	       @tk     = Tk
	       @top    = {New Tk.toplevel
			  tkInit(title:Title delete:ActionDelete
				 withdraw:true)}
	       @page1  = {New TkTools.textframe tkInit(parent:@top text:'Tools')}
	       @radio  = {New Tk.variable tkInit}
	       @page2  = {New TkTools.textframe tkInit(parent:@top text:'Users')}
	       @canvas = {New Tk.canvas
			  tkInit(parent:@top bd:2 relief:sunken
				 width:300 height:300 bg:@BGColor)}
	       {@canvas tkBind(event:  '<1>'
			       args:   [int(x) int(y)]
			       action: ActionNewBObj)}
	       {Tk.batch [grid(@page1  row:0 column:0 pady:4 sticky:ew)
			  grid(@page2  row:1 column:0 pady:4 sticky:ew)
			  grid(@canvas row:0 column:1 sticky:sn padx:2 pady:2
			       rowspan:4)
			  grid({New Tk.button
				tkInit(parent: @top
				       text:  'Mail Applet'
				       action: Desc.mail)}
			       sticky:ew pady:4
			       row:2 column:0)
			  grid({New Tk.button
				tkInit(parent: @top
				       text:  'Save Applet'
				       action: Desc.save)}
			       sticky:ew pady:4
			       row:3 column:0)
			  update(idletasks)
			  wm(deiconify @top)]}
	       {ConnectToAgenda @port}
	    end
	 
	    meth newTool(Label Tool WClass) % invoked by Board
	       proc {ActionSelectTool}
		  {Send @port SelectTool(Tool)}
	       end
	       C|S    = {VirtualString.toString Label}
	    
	       Button = {New @tk.radiobutton
			 tkInit(parent: @page1.inner
				text:   {Char.toUpper C}|S
				anchor: w
				bg:'#b9b9b9'
				var:    @radio
				value:  Label
				relief: groove
				bd:     2
				action: ActionSelectTool)}
	    in
	       {@tk.send grid(Button sticky:sew padx:2 pady:2)}
	       {self Put(Tool2WClass Tool WClass)}
	    end
	 
	    meth newUser(UserId Name) % invoked by Board
	       Label = {New @tk.label
			tkInit(parent: @page2.inner
			       text:   Name
			       anchor: w
			       bg:     white
			       bd:     2)}
	    in
	       {@tk.send grid(Label sticky:sew padx:2 pady:2)}
	       {self Put(Name2Label UserId Label)}
	    end
	 
	    meth deleteUser(UserId)
	       {{self Get(Name2Label UserId $)} tkClose}
	       {self Delete(Name2Label UserId)}
	    end
	 
	    meth shutdown % invoked by Board
	       if @MyDialog \= nil then {Send @MyDialog close} end
	       {@top tkClose}
	       {@close}
	    end 
	 
	    meth NewBObj(X Y) % invoked by User <1>
	       {Send @tool newBObj(X Y)}
	    end
	 
	    meth updateBObj(BObj) % invoked by User <2>
	       if @Busy then {self Flash(black)} else
		  {self MkBusy}
		  {Send BObj requestUpdate(@port)}
	       end
	    end	 
	 
	    meth closeBObj(BObj) % invoked by User <3>
	       if @Busy then  {self Flash(black)} else
		  {self MkBusy}
		  {Send BObj requestClose(@port)}
	       end
	    end
	 
	    meth SelectTool(Tool) % invoked by User <1>
	       tool <- Tool
	    end
	 
	    meth Close % invoked by User <1>
	       if @Busy then  {self Flash(black)}  else
		  {@top tkClose}
		  {@close}
	       end
	    end
	 
	    meth newWObj(BObj Tool Message) % invoked by BObject through agenda
	       WObj = {New {self Get(Tool2WClass Tool $)}
		       init(@tk @port @canvas BObj Message)}
	    in
	       {self Put(BObj2WObj BObj WObj)}
	    end
	 
	    meth updateWObj(BObj Props) % invoked by BObject through agenda
	       {{self Get(BObj2WObj BObj $)} update(Props)}
	    end
	 
	    meth closeWObj(BObj Window) % invoked by BObject through agenda
	       if Window == @port then {self MkIdle} end
	       {{self Get(BObj2WObj BObj $)} close}
	    end
	 
	    meth grantUpdate(Old BObj) % invoked by BObject
	       MyDialog <- {NewServer Dialog init(@tk @port Old BObj)}
	    end
	 
	    meth rejectRequest % invoked by BObject
	       {self Flash(red)}
	       {self MkIdle}
	    end
	 
	    meth dialogClosed % invoked by Dialog
	       MyDialog <- nil
	       {self MkIdle}
	    end
	 
	    meth Put(A K V)
	       A <- K#V | @A
	    end
	 
	    meth Get(A K $)
	       {LookUp @A K}
	    end
	 
	    meth Delete(A K)
	       A <- {Remove @A K}
	    end
	 
	    meth MkBusy
	       Busy <- true
	       {self ChangeColor(thistle)}
	    end
	 
	    meth MkIdle
	       Busy <- false
	       {self ChangeColor(ivory)}
	    end
	 
	    meth ChangeColor(Color)
	       {@canvas tk(configure(bg:Color))}
	       BGColor <- Color
	    end
	 
	    meth Flash(Color)
	       OldColor = @BGColor
	    in
	       {self ChangeColor(Color)}
	       {Delay 200}
	       {self ChangeColor(OldColor)}
	    end
	 end
      
	 fun {LookUp K#I|KIr GK}
	    if K==GK then I else {LookUp KIr GK} end
	 end
      
	 fun {Remove KIs DK}
	    case KIs of nil then nil
	    [] KI|KIr then K#_=KI in
	       if K==DK then KIr else KI|{Remove KIr DK} end
	    end
	 end
      
	 fun {GetHostName}
	    UTS = {OS.uName}
	 in
	    UTS.nodename
	 end
      
	 class WObject
	    attr
	       canvas tag
	    
	    meth init(Tk Window Canvas BObj Message) % invoked by Window
	       proc {ActionUpdate} {Send Window updateBObj(BObj)} end
	       proc {ActionClose} {Send Window closeBObj(BObj)} end
	    in
	       @canvas = Canvas
	       @tag  = {New Tk.canvasTag tkInit(parent:Canvas)}
	       {Canvas tk(Message o(tag:@tag))}
	       {@tag tkBind(event:'<2>' action: ActionUpdate)}
	       {@tag tkBind(event:'<3>' action: ActionClose)}
	    end
	 
	    meth update(Props) % invoked by Window on request of BObject
	       {@canvas tk({List.toRecord itemconfigure (1#@tag|Props)})}
	    end
	 
	    meth close % invoked by Window on request of BObject
	       {@tag tk(delete)}
	    end
	 end
      
	 class Dialog from Server
	    attr
	       top window entries oldProps bObj
	    
	    meth init(Tk Window OldProps BObj) % invoked by Window
	       proc {ActionOk}
		  {Send @port Ok}
	       end
	       proc {ActionCancel}
		  {Send @port Cancel}
	       end
	       @window  = Window
	       @oldProps= OldProps
	       @bObj    = BObj
	       @top     = {New Tk.toplevel
			   tkInit(title:'Object Attributes' delete:ActionCancel
				  withdraw:true)}
	       {@top tkWM(geometry '+'#{Tk.returnInt winfo(pointerx @top)}+5#
			  '+'#{Tk.returnInt winfo(pointery @top)}+10)}
	       @entries = {List.mapInd @oldProps
			   fun {$ I A#V}
			      L = {New Tk.label
				   tkInit(parent:@top text:A#':' anchor:w)}
			      E = {New Tk.entry
				   tkInit(parent:@top width:10 bg:white)}
			   in
			      {E tk(insert 0 V)}
			      {Tk.send grid(row:I L E sticky:w padx:4 pady:4)}
			      A#E
			   end}
	       OkButton     = {New Tk.button
			       tkInit(parent:@top  text:'Okay' action: ActionOk)}
	    in
	       {Tk.send grid(row:{Length @entries}+1 columnspan:2 pady:10 OkButton)}
	       {@top tkWM(deiconify)}
	    end
	 
	    meth close  % invoked by Window
	       {@top tkClose}
	       {@close}
	    end 
	 
	    meth Ok  % invoked by User <1>
	       NewProps = {Map @entries fun {$ A#E} A # {E tkReturn(get $)} end}
	    in
	       {Send @bObj update(NewProps)}
	       {Send @window dialogClosed}
	       {self close}
	    end
	 
	    meth Cancel  % invoked by User <1>
	       {Send @bObj update(@oldProps)}
	       {Send @window dialogClosed}
	       {self close}
	    end
	 end
      
	 class Circle from BObject
	    attr
	       kind:  oval
	       props: [fill width]
	       dx:    20
	       dy:    20
	       fill:   red
	       width:  1
	 end
      
	 class Square from Circle
	    attr
	       kind: rectangle
	       fill: blue
	 end
      
	 class HBar from Square
	    attr
	       dy:   4
	       fill: orange
	 end
      
	 class VBar from Square
	    attr
	       dx:   4
	       fill: green
	 end
      
	 class Arc from Circle
	    attr
	       kind:   arc
	       props:  [fill start extent]
	       fill:   yellow
	       start:  22.5
	       extent: 315
	 end
      
	 proc {MailBoard}
	    FN = {OS.tmpnam}
	 
	    To
	 
	    T = {New Tk.toplevel tkInit}
	    L = {New Tk.label  tkInit(parent:T text:'To: ')}
	    E = {New Tk.entry  tkInit(parent:T width:20)}
	    B = {New Tk.button tkInit(parent:T text:'Send'
				      action: proc {$}
						 To = {E tkReturnAtom(get $)}
						 {T tkClose}
					      end)}
	    {Tk.batch [pack(L E side:left pady:1#m padx:1#m)
		       pack(B side:bottom pady:2#m)
		       focus(E)]}
	 
	 in
	    {Wait To}
	 
	    {Pickle.saveCompressed
	     {NewBoardFunctor false Ticket To} FN PickleCompressionLevel}
	    
	    try
	       {SendApplet FN 'Oz Drawing Board' To}
	    catch _ then
	       D={New TkTools.error
		  tkInit(text: ('Could not send mail. Please check whether '#
				'metamail package is installed properly.'))}
	    in
	       {Wait D.tkClosed}
	    end
	    
	    {OS.unlink FN}
	 end
	 proc {SaveBoard}
	    case {Tk.return
		  tk_getSaveFile(filetypes: q(q('Oz Applications'
						'.oza')
					      q('All files'
						'*')))}
	    of nil then skip 
	    [] S then 
	       {Pickle.saveCompressed
		{NewBoardFunctor false Ticket 'Saved'}
		S PickleCompressionLevel}
	    end
	 end
	 Ticket B
	 UserId = {NewName}
      
	 if Args.master then
	    B      = {NewServer Board init}
	    Ticket = {New Connection.gate init(B $) _}
	 else
	    Ticket = Args.ticket
	    B      = {Connection.take Ticket}
	 end
	 {Wait Tk}
	 {Wait TkTools}
   
	 {{Send B newWindow($)} {AdjoinAt Tk tools TkTools}
	  d(title: 'Drawing Board'#'@'#{GetHostName}
	    close: proc {$}
		      {Application.exit 0}
		   end
	    mail:  MailBoard
	    save:  SaveBoard
	    user:  UserId)}
   
	 {Send B newUser(UserId Args.user)}
   
	 if Args.master then
	    {Send B newTool(circle Circle WObject)}
	    {Send B newTool(square Square WObject)}
	    {Send B newTool(hbar HBar WObject)}
	    {Send B newTool(vbar VBar WObject)}
	    {Send B newTool(arc Arc WObject)}
	 end
      end
   end
in
   {NewBoardFunctor true '' master}
end
 |