;;; -*- Mode:Common-Lisp; Package:USER; Base:10; Fonts:(COURIER HL12B HL12BI HL12BI HL12B) -*-

(w:make-banding-scheme *my-user-banding-scheme*
		     ()
		     (nil w:*system-colors* *my-orange* *my-gray*)
 (*user-top-band*
   ((*user-attention-red* 255 0 0 nil nil nil)
    (*user-attention-green* 0 255 0))
   1)
 (*user-next-band*
   ((*user-dull-red* 124 0 0 nil nil nil)
    (*user-dull-green* 0 129 0 nil nil nil))))

(DEFFLAVOR 4my-user-window-flavor*
	   ()
	   (tv:blinking-colors-mixin
	    w:graphics-mixin
	    w:minimum-window)
  (:default-init-plist :blink-rate 30.))

(DEFUN 4test-banding-scheme*
       ()
  (LET ((window1 (MAKE-INSTANCE 'my-user-window-flavor
				:left 20 :top 20 :width 500 :height 500
				:background-color w:*transparent-white*
				:blinker-deselected-visibility :off))
	(window2 (MAKE-INSTANCE 'my-user-window-flavor
				:left 750 :top 20 :width 50 :height 50
				:background-color w:*transparent-white*
				:blinker-deselected-visibility :off))
	(window3 (MAKE-INSTANCE 'my-user-window-flavor
				:left 750 :top 200 :width 50 :height 50
				:background-color w:*transparent-white*
				:blinker-deselected-visibility :off)))
    (UNWIND-PROTECT
	(w:using-banding-scheme (*my-user-banding-scheme* (window1 nil) (window2 nil) (window3 nil))
	  (SEND window1 :expose)
	  (SEND window2 :expose)
	  (SEND window3 :expose)
	  ;1; Draw in the bottom band...*
	  (w:using-bands (w:*system-colors*) ()
	    (SEND window1 :draw-filled-circle 475 25 20 w:light-brown)
	    (SEND window1 :draw-filled-triangle 25 455 5 495 45 495 w:dark-green)
	    (SEND window1 :draw-dashed-line 0 0 500 500 15 w:purple)
	    (SEND window2 :draw-filled-circle 25 25 20 w:light-brown)
	    (SEND window3 :draw-filled-triangle 25 5 5 45 45 45 w:dark-green)
	    (SLEEP 4.))
	  ;1; Paint over it all in red in the top band...*
	  (w:using-bands (*user-top-band*) ()
	    (w:paint-window *user-attention-red* window1)
	    (w:paint-window *user-attention-red* window2)
	    (w:paint-window *user-attention-red* window3)
	    (SLEEP 4.)
	    ;1; Now let some show through...*
	    (SEND window1 :draw-filled-rectangle 0 0 500 250 w:*transparent-white*)
	    (SEND window2 :draw-filled-rectangle 0 0 50 25 w:*transparent-white*)
	    (SEND window3 :draw-filled-rectangle 0 0 50 25 w:*transparent-white*)
	    (SLEEP 4.))
	  ;1; Next, do some drawing in the in-between band...*
	  (w:using-bands (*user-next-band*) ()
	    (SEND window1 :draw-filled-rectangle 250 0 250 500 *user-dull-red*)
	    (SEND window2 :draw-filled-rectangle 25 0 25 50 *user-dull-green*)
	    (SEND window3 :draw-filled-rectangle 25 0 25 50 *user-dull-green*)
	    (SLEEP 4.))
	  ;1; Now, change out some colors...*
	  (w:reassign-color-within-band *user-attention-red* *user-attention-red* 220 14 50 nil nil nil)
	  (SLEEP 4.)
	  (w:reassign-color-within-band *user-attention-red* *user-attention-green* 0 255 60 nil nil nil)
	  (SLEEP 4.)
	  (w:change-clear-color *my-gray* 240 230 255 255 230 240)
	  (SLEEP 4.)
	  (w:remove-a-color-from-its-band *user-attention-green*)
	  (w:add-a-color-to-a-band *user-attention-green* *my-orange* 255 190 0 nil nil nil)
	  (SLEEP 4.)
	  ;1; Add a new color...*
	  (w:add-a-color-to-a-band *user-next-band* *user-attention-red* 255 0 0 nil nil nil)
	  ;1; Use it to draw in two bands at once...*
	  (w:using-bands (*user-top-band* *user-next-band*) ()
	    (SEND window1 :draw-filled-rectangle 250 0 125 500 *user-attention-red*)
	    (SEND window2 :draw-filled-rectangle 25 0 12 50 *user-attention-red*)
	    (SEND window3 :draw-filled-rectangle 25 0 12 50 *user-attention-red*)
	    (SLEEP 4.)
	    ;1; Finally, erase some of the superior bands to show that the bottom images are still intact...*
	    (SEND window1 :draw-filled-circle 250 250 250 w:*transparent-white*)
	    (SEND window2 :draw-filled-circle 25 25 25 w:*transparent-white*)
	    (SEND window3 :draw-filled-circle 25 25 25 w:*transparent-white*))
	  (SLEEP 4.))
      ;1; but always get rid of the windows...*
      (SEND window1 :kill)
      (SEND window2 :kill)
      (SEND window3 :kill))))

(DEFUN 4test-banding-scheme-1*
       (&optional (window tv:selected-window))
  (w:using-banding-scheme (*my-user-banding-scheme* (window nil))
    ;1; Make window red...*
    (w:paint-window *user-attention-red* window)
    (SLEEP 2.)
    ;1; Change the red to green...*
    (w:reassign-color-within-band *user-attention-red* *user-attention-green* 0 255 0 255 0 255)
    (SLEEP 2.)
    ;1; Draw some figures underneath the green...*
    (w:using-bands (w:*system-colors*) ()
      (SEND window :draw-filled-circle 475 25 20 w:light-brown)
      (SEND window :draw-filled-triangle 25 455 5 495 45 495 w:dark-green)
      (SEND window :draw-dashed-line 0 0 500 500 15 w:purple))
    (SLEEP 2.)
    ;1; Now erase the green to reveal the figures underneath...*
    (w:using-bands
      (*user-top-band*)
      ((window nil))
      (w:paint-window w:*transparent-white* window))
    (SLEEP 2.)))

(DEFUN 4test-banding-scheme-2*
       ()
  (LET ((window1 (MAKE-INSTANCE 'my-user-window-flavor
				:left 20 :top 20 :width 500 :height 500
				:background-color w:*transparent-white*
				:blinker-deselected-visibility :off)))
    (UNWIND-PROTECT
	(w:using-banding-scheme (*my-user-banding-scheme* (window1 nil))
	  (SEND window1 :expose)
	  ;1; Draw in the bottom band...*
	  (w:using-bands (w:*system-colors*) ()
	    (SEND window1 :draw-filled-circle 475 25 20 w:light-brown)
	    (SEND window1 :draw-filled-triangle 25 455 5 495 45 495 w:dark-green)
	    (SEND window1 :draw-dashed-line 0 0 500 500 15 w:purple)
	    (SLEEP 2.))
	  ;1; Paint over it all in red in the top band.  When it blinks, it should show the images underneath...*
	  (w:using-bands (*user-top-band*) ()
	    (w:paint-window *user-attention-red* window1)
	    (SLEEP 10.)))
      ;1; but always get rid of the window...
*      (SEND window1 :kill))))