;;; -*-Mode: LISP; Package: PICASSO; Base: 10; Syntax: Common-lisp -*-
;;;
;;; Copyright (c) 1990 Regents of the University of California
;;;
;;; Permission to use, copy, modify, and distribute this software and its
;;; documentation for any purpose and without fee is hereby granted,
;;; provided that the above copyright notice appear in all copies and
;;; that both that copyright notice and this permission notice appear in
;;; supporting documentation, and that the name of the University of
;;; California not be used in advertising or publicity pertaining to
;;; distribution of the software without specific, written prior
;;; permission.  The University of California makes no representations
;;; about the suitability of this software for any purpose.  It is
;;; provided "as is" without express or implied warranty.
;;;
;;;
;;;       $Source: /n/hermes/pic2/picasso/lib/po/mosaic/RCS/form,v $
;;;       $Author: johnb $
;;;       $Header: /n/hermes/pic2/picasso/lib/po/mosaic/RCS/form,v 1.7 1991/11/19 02:27:07 johnb Exp smoot $
;;;       $Locker: smoot $
;;;

(defform ("mosaic" "form") ()
  "The mosaic game form"
  (gm 'anchor-gm)
  (constants (title-font (make-font :name "9x15bold"))
	     (matrix-size 484))
  (background "gray75")
  (children
   (board (make-table-field
	   :geom-spec '(:anchor (:left 4 :top 4))
	   :base-size `(,#!matrix-size ,#!matrix-size)
	   :grid-lines '()
	   :unique-selection t
	   :inter-row-pad 0
	   :inter-col-pad 0
    	   :background "gray75"
	   :horiz-scroll-bar-p  nil
	   :vert-scroll-bar-p nil
	   :border-type :box
	   :data (make-array `(,BoardSize ,BoardSize) 
			     :element-type (type-of zero-tile)
			     :initial-element zero-tile)
	   :row-heights TileSize
	   :col-widths TileSize
	   :row-title-width 0
	   :col-title-width 0
	   :visible-rows BoardSize
	   :visible-cols BoardSize
	   :initial-rows BoardSize
	   :initial-cols BoardSize
	   :rows BoardSize
	   :cols BoardSize
	   ))
   
   (cg (make-collection-widget
	:geom-spec `(:anchor (:top 4 :left ,(+ 14 #!matrix-size)))
	:gm 'anchor-gm
	:border-width 2
	:border-type :box
	:base-size `(100 ,#!matrix-size)
    	:background "gray75"
	:conform :dont-conform
	:children
	'((piece-box (make-table-field
		      :conform :dont-conform
		      :geom-spec '(:anchor (:top 10 :left 20))
		      :base-size '(54 54)
		      :grid-lines '()
		      :unique-selection t
		      :inter-row-pad 0
		      :inter-col-pad 0
    		      :background "gray75"
		      :horiz-scroll-bar-p '()
		      :vert-scroll-bar-p '()
		      :border-type :frame
		      :data (make-array '(2 2)
					:element-type (type-of zero-tile)
					:initial-element zero-tile)
		      :row-heights TileSize
		      :col-widths TileSize
		      :row-title-width 0
		      :col-title-width 0
		      :visible-rows 2
		      :visible-cols 2
		      :initial-rows 2
		      :initial-cols 2
		      :rows 2
		      :cols 2
		      ))

      ;;; The to Play display
	  (play-title (make-text-gadget :geom-spec '(:anchor (:left 0 :top 80 :right 0) 
							     :arrow (:horiz))
					:conform :grow-only
					:value "to play"))

	  (play-one-label (make-collection-gadget
			   :conform :dont-conform
			   :background one-tile
			   :base-size '(20 20)
			   :geom-spec '(:anchor (:left 5 :top 105))
			   :children '()))
	  (play-one (make-text-gadget :geom-spec '(:anchor (:left 30 :top 105) 
							   :arrow (:horiz))
				      :conform :dont-conform
				      :base-size '(65 20)
				      :background "gray75"
				      :value "1140"))
	  (play-two-label (make-collection-gadget
			   :conform :dont-conform
			   :background two-tile
			   :base-size '(20 20)
			   :geom-spec '(:anchor (:left 5 :top 130))
			   :children '()))
	  (play-two (make-text-gadget :geom-spec '(:anchor (:left 30 :top 130) 
							   :arrow (:horiz))
				      :conform :dont-conform
				      :base-size '(65 20)
				      :background "gray75"
				      :value "40"))
	  (play-three-label (make-collection-gadget
			     :conform :dont-conform
			     :background three-tile
			     :base-size '(20 20)
			     :geom-spec '(:anchor (:left 5 :top 155))
			     :children '()))
	  (play-three (make-text-gadget :geom-spec '(:anchor (:left 30 :top 155) 
							     :arrow (:horiz))
					:conform :dont-conform
					:background "gray75"
					:base-size '(65 20)
					:label-x -25
					:value "20"))

      ;;; The Total display
	  (total-title (make-text-gadget :geom-spec '(:anchor (:left 0 :top 205 :right 0) 
							      :arrow (:horiz))
					 :conform :grow-only
					 :value "point total"))

	  (total-one-label (make-collection-gadget
			    :conform :dont-conform
			    :background one-tile
			    :base-size '(20 20)
			    :geom-spec '(:anchor (:left 5 :top 230))
			    :children '()))
	  (total-one (make-text-gadget :geom-spec '(:anchor (:left 30 :top 230) 
							    :arrow (:horiz))
				       :base-size '(65 20)
				       :conform :dont-conform
				       :background "gray75"
				       :value "1140"))
	  (total-two-label (make-collection-gadget
			    :background two-tile
			    :base-size '(20 20)
			    :conform :dont-conform
			    :geom-spec '(:anchor (:left 5 :top 255))
			    :children '()))
	  (total-two (make-text-gadget :geom-spec '(:anchor (:left 30 :top 255) 
							    :arrow (:horiz))
				       :base-size '(65 20)
				       :conform :dont-conform
				       :background "gray75"
				       :label-x -25
				       :value "40"))
	  (total-three-label (make-collection-gadget
			      :background three-tile
			      :conform :dont-conform
			      :base-size '(20 20)
			      :geom-spec '(:anchor (:left 5 :top 280))
			      :children '()))
	  (total-three (make-text-gadget :geom-spec '(:anchor (:left 30 :top 280) 
							      :arrow (:horiz))
					 :conform :dont-conform
					 :base-size '(65 20)
					 :background "gray75"
					 :value "20"))
	  (total-total (make-text-gadget :geom-spec '(:anchor (:left 30 :top 305 :right 0)
							      :arrow (:horiz))
					 :conform :dont-conform
					 :base-size '(65 20)
					 :background "gray75"
					 :label "Total"
					 :label-type :left
					 :label-x -25
					 :value "1140"))

      ;;; The Piece display
	  (piece-title (make-text-gadget :geom-spec '(:anchor (:left 0 :top 345) 
							      :arrow (:horiz))
					 :conform :grow-only
					 :value "last piece"))

	  (piece-one-label (make-collection-gadget
			    :conform :dont-conform
			    :background one-tile
			    :base-size '(20 20)
			    :geom-spec '(:anchor (:left 5 :top 370))
			    :children '()))
	  (piece-one (make-text-gadget :geom-spec '(:anchor (:left 30 :top 370) 
							    :arrow (:horiz))
				       :conform :dont-conform
				       :base-size '(65 20)
				       :background "gray75"
				       :value "1140"))
	  (piece-two-label (make-collection-gadget
			    :conform :dont-conform
			    :background two-tile
			    :base-size '(20 20)
			    :geom-spec '(:anchor (:left 5 :top 395))
			    :children '()))
	  (piece-two (make-text-gadget :geom-spec '(:anchor (:left 30 :top 395) 
							    :arrow (:horiz))
				       :conform :dont-conform
				       :base-size '(65 20)
				       :background "gray75"
				       :value "40"))
	  (piece-three-label (make-collection-gadget
			      :conform :dont-conform
			      :background three-tile
			      :base-size '(20 20)
			      :geom-spec '(:anchor (:left 5 :top 420))
			      :children '()))
	  (piece-three (make-text-gadget :geom-spec '(:anchor (:left 30 :top 420) 
							      :arrow (:horiz))
					 :conform :dont-conform
					 :base-size '(65 20)
					 :background "gray75"
					 :value "20"))
	  (piece-total (make-text-gadget :geom-spec '(:anchor (:left 30 :top 445) 
							      :arrow (:horiz))
					 :base-size '(65 20)
					 :conform :dont-conform
					 :background "gray75"
					 :label "Total"
					 :label-type :left
					 :label-x -25
					 :value "1140"))
	  ))))
   
  (setup-code (progn 		 
;;;		(format t "Form Setup code~%")	   	 
		(setf (select-func  #!board) '(drop-on-table event))))
  
  (init-code
   (progn 
     (setf (horiz-just #!piece-total) :right)
     (setf (horiz-just #!piece-three) :right)
     (setf (horiz-just #!piece-two) :right)
     (setf (horiz-just #!piece-one) :right)
     (setf (horiz-just #!total-total) :right)
     (setf (horiz-just #!total-three) :right)
     (setf (horiz-just #!total-two) :right)
     (setf (horiz-just #!total-one) :right)
     (setf (horiz-just #!play-three) :right)
     (setf (horiz-just #!play-two) :right)
     (setf (horiz-just #!play-one) :right)
     (Update-Totals)
     (Update-Next-Piece)
     (setf (cursor #!board) 
	   (make-cursor :file "bigbox.cursor"	       
			:name "bigbox" 	      
			:mask-file "bigbox.cursor"	      
			:display (current-display)))
     (format t "And away we go!~%")))
  (exit-code
   (setf (data #!board) 
	 (make-array `(,BoardSize ,BoardSize) 
		     :element-type (type-of zero-tile)
		     :initial-element zero-tile)))

  )
  
  
