(defform ("vp" "form") ()
  (gm 'rubber-gm)
  (background "gray75")
  (constants (title-font (make-font :name "9x15bold"))
	     (helv12 (make-font :name "7x13"))
	     (helv12b (make-font :name "8x13bold")))
  (height 350)
  (width 600)
  (children 
   (card-1 (make-image-widget :base-height 121 
			      :base-width 77
			      :gray t
			      :geom-spec '(0 .1 .16 .35 :center)))
   (card-2 (make-image-widget :base-height 121 
			      :base-width 77
			      :gray t
			      :geom-spec '(.16 .1 .16 .35 :center)))
   (card-3 (make-image-widget :base-height 121 
			      :base-width 77
			      :gray t
			      :geom-spec '(.32 .1 .16 .35 :center)))
   (card-4 (make-image-widget :base-height 121 
			      :base-width 77
			      :gray t
			      :geom-spec '(.48 .1 .16 .35 :center)))
   (card-5 (make-image-widget :base-height 121 
			      :base-width 77
			      :gray t
			      :geom-spec '(.64 .1 .16 .35 :center)))
   (hold-button-1 (make-gray-button :base-height 30 
				    :base-width 77
				    :press-func
				      '(let ((holds (copy-list #!holds)))
					    (setf (first holds) t)
					    (setf #!holds holds))
				    :geom-spec '(0 .5 .16 .1 :center)))
   (hold-button-2 (make-gray-button :base-height 30 
				    :base-width 77
				    :press-func
				      '(let ((holds (copy-list #!holds)))
					    (setf (second holds) t)
					    (setf #!holds holds))
				    :geom-spec '(.16 .5 .16 .1 :center)))
   (hold-button-3 (make-gray-button :base-height 30 
				    :base-width 77
				    :press-func
				      '(let ((holds (copy-list #!holds)))
					    (setf (third holds) t)
					    (setf #!holds holds))
				    :geom-spec '(.32 .5 .16 .1 :center)))
   (hold-button-4 (make-gray-button :base-height 30 
				    :base-width 77
				    :press-func
				      '(let ((holds (copy-list #!holds)))
					    (setf (fourth holds) t)
					    (setf #!holds holds))
				    :geom-spec '(.48 .5 .16 .1 :center)))
   (hold-button-5 (make-gray-button :base-height 30 
				    :base-width 77
				    :press-func
				      '(let ((holds (copy-list #!holds)))
					    (setf (fifth holds) t)
					    (setf #!holds holds))
				    :geom-spec '(.64 .5 .16 .1 :center)))
   (deal-button   (make-gray-button :base-height 40
				    :base-width 90
				    :value "DEAL"
				    :press-func
				      '(setf #!mode :draw)
				    :geom-spec '(0 .7 .2 .2 :center)))
   (stand-button  (make-gray-button :base-height 40
				    :base-width 90
				    :value "STAND"
				    :press-func
				      '(progn
					(setf #!holds 
					      (make-list 5 :initial-element t))
					(setf #!mode :pay))
				    :geom-spec '(.2 .7 .2 .2 :center)))
   (cancel-button (make-gray-button :base-height 40
				    :base-width 90
				    :value "CANCEL"
				    :press-func
				      '(setf #!holds (make-list 5))
				    :geom-spec '(.4 .7 .2 .2 :center)))
   (draw-button   (make-gray-button :base-height 40
				    :base-width 90
				    :value "DRAW"
				    :press-func
				      '(setf #!mode :pay)
				    :geom-spec '(.6 .7 .2 .2 :center)))
   (bet-max-button (make-gray-button :base-height 40
				     :base-width 90
				     :value "BET MAX"
				     :press-func
				       '(let ((bet-amt (- *max-bet* #!bet)))
					     (setq bet-amt 
						   (min bet-amt #!credits))
					     (decf #!credits bet-amt)
					     (incf #!bet bet-amt))
				     :geom-spec '(.8 .7 .2 .2 :center)))
   (bet-one-button (make-gray-button :base-height 40
				     :base-width 90
				     :value "BET ONE"
				     :press-func 
				       '(progn
					 (decf #!credits)
					 (incf #!bet))
				     :geom-spec '(.8 .55 .2 .2 :center)))
   (bankroll (make-text-gadget :gray t
			       :label "Bankroll"
			       :base-height 40
			       :base-width 90
			       :geom-spec '(.8 .15 .2 .2 :center)))
   (bet-amt (make-text-gadget  :gray t
			       :label "Amount Bet"
			       :base-height 40
			       :base-width 90
			       :geom-spec '(.8 .35 .2 .2 :center)))
   #|(previous-hand (make-text-widget :editable nil
				    :gray t
				    :label "Last Hand"
				    :base-height 60
				    :base-width 90
				    :geom-spec '(.8 0 .2 .3 :center)))|#
   (message-window (make-text-gadget :gray t
				     :base-height 25
				     :base-width 600
				     :geom-spec '( 0 .87 1 .13 :center)))
   )
  (setup-code
   (progn
    (blet (value #!card-1)
	  :var ((card #!card1))
	  (picture card))
    (blet (value #!card-2)
	  :var ((card #!card2))
	  (picture card))
    (blet (value #!card-3)
	  :var ((card #!card3))
	  (picture card))
    (blet (value #!card-4)
	  :var ((card #!card4))
	  (picture card))
    (blet (value #!card-5)
	  :var ((card #!card5))
	  (picture card))
    (blet (dimmed #!hold-button-1)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (first holds)))
    (blet (dimmed #!hold-button-2)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (second holds)))
    (blet (dimmed #!hold-button-3)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (third holds)))
    (blet (dimmed #!hold-button-4)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (fourth holds)))
    (blet (dimmed #!hold-button-5)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (fifth holds)))
    (blet (value #!hold-button-1)
	  :var ((mode #!mode)
		(holds #!holds))
	  (if (eql mode :draw)
	      (if (first holds) "held" "HOLD")
	      ""))
    (blet (value #!hold-button-2)
	  :var ((mode #!mode)
		(holds #!holds))
	  (if (eql mode :draw)
	      (if (second holds) "held" "HOLD")
	      ""))
    (blet (value #!hold-button-3)
	  :var ((mode #!mode)
		(holds #!holds))
	  (if (eql mode :draw)
	      (if (third holds) "held" "HOLD")
	      ""))
    (blet (value #!hold-button-4)
	  :var ((mode #!mode)
		(holds #!holds))
	  (if (eql mode :draw)
	      (if (fourth holds) "held" "HOLD")
	      ""))
    (blet (value #!hold-button-5)
	  :var ((mode #!mode)
		(holds #!holds))
	  (if (eql mode :draw)
	      (if (fifth holds) "held" "HOLD")
	      ""))
    (blet (dimmed #!deal-button)
	  :var ((mode #!mode)
		(bet #!bet))
	  (or (not (eql mode :bet))
	      (eql #!bet 0)))
    (blet (dimmed #!stand-button)
	  :var ((mode #!mode))
	  (not (eql mode :draw)))
    (blet (dimmed #!cancel-button)
	  :var ((mode #!mode)
		(holds #!holds))
	  (or (not (eql mode :draw))
	      (every #'null holds)))
    (blet (dimmed #!draw-button)
	  :var ((mode #!mode))
	  (not (eql mode :draw)))
    (blet (dimmed #!bet-max-button)
	  :var ((mode #!mode)
		(credits #!credits))
	  (or (eql mode :draw)
	      (<= #!credits 0)))
    (blet (dimmed #!bet-one-button)
	  :var ((mode #!mode)
		(credits #!credits))
	  (or (eql mode :draw)
	      (<= #!credits 0)))
    (blet (value #!bankroll)
	  :var ((credits #!credits))
	  (write-to-string credits))
    (blet (value #!bet-amt)
	  :var ((bet #!bet))
	  (write-to-string bet))
    (bind (value #!message-window) #!message)
#|    (blet (value #!previous-hand)
	  :var ((mode #!mode))
	  (if (eql mode :pay) ""
	      (list
	       (format nil "Amount Bet:  ~D" #!old-bet)
	       (format nil "Hand Drawn:  ~A" #!hand-name)
	       (format nil "Amount Won:  ~D" (* #!old-bet #!payoff)))))|#
    )))

