(FILECREATED "31-OCT-83 10:48:45" {INDIGO}<LOOPS>SOURCES>LOOPSWINDOW.;5 13161  

      previous date: "19-OCT-83 00:18:16" {INDIGO}<LOOPS>SOURCES>LOOPSWINDOW.;4)


(* Copyright (c) 1983 by Xerox Corporation)

(PRETTYCOMPRINT LOOPSWINDOWCOMS)

(RPAQQ LOOPSWINDOWCOMS ((CLASSES Window)
	(METHODS Window.Blink Window.Bury Window.Clear Window.Close Window.Destroy Window.GetProp 
		 Window.HasLispWindow Window.LeftSelection Window.MiddleSelection Window.Move 
		 Window.Open Window.Paint Window.Repaint Window.RightSelection Window.SetProp 
		 Window.Shape Window.Shape? Window.Shrink Window.Snap Window.TitleSelection 
		 Window.Update)
	(FNS GetLispWindow WindowButtonEventFn WindowRightButtonFn)))
(DEFCLASSES Window)
[DEFCLASS Window
   (MetaClass Class Edited:                                  (* dgb: "28-MAR-83 17:13")
	      doc                                            (* A Loops object which represents a window)
	      )
   (Supers Object)
   (ClassVariables (TitleItems NIL doc                       (* special items to be done if in title part of window)
			       )
		   (LeftButtonItems ((Update (QUOTE Update)
					     "Update window to agree with object IVs"))
				    doc                      (* Items to be done if Left button is selected in main 
							     window)
				    )
		   (MiddleButtonItems NIL doc                (* Items to be done if Middle button is selected in main
							     window))
		   (RightButtonItems (Close Snap Paint Clear Bury Repaint Move Shape Shrink)
				     doc                     (* Items to be done if Right button is selected)
				     ))
   (InstanceVariables (window #(NIL GetLispWindow NIL) doc 
                                                             (* Holds real window. Ensured to be window by 
							     GetLispWindow))
		      (title NIL doc                         (* If not NIL will be put in title of window)
			     )
		      (width NIL doc                         (* inner width of window, not counting border)
			     )
		      (height NIL doc                        (* inner height of window, not counting border)
			      )
		      (left NIL doc                          (* left position of window))
		      (bottom NIL doc                        (* bottom position of window)))]

[METH Window  Blink (numBlinks)
      (* Turn Window inverted, dismiss for 200, and return it to normal)]


[METH Window  Bury NIL
      (* Calls BURYW on window)]


[METH Window  Clear NIL
      (* Calls CLEARW on window)]


[METH Window  Close NIL
      (* Close the window)]


[METH Window  Destroy NIL
      (* get property from window)]


[METH Window  GetProp (prop)
      (* get property from window)]


[METH Window  HasLispWindow NIL
      (* Checks if a Lisp window has ever been created for this Loops Window)]


[METH Window  LeftSelection NIL
      (* Do LeftButtonItems on selection)]


[METH Window  MiddleSelection NIL
      (* Do MiddleButtonItems on selection)]


[METH Window  Move (xOrPos y)
      (* Open the window)]


[METH Window  Open NIL
      (* Open the window)]


[METH Window  Paint NIL
      (* Calls paint on window)]


[METH Window  Repaint (reg alwaysFlg)
      (* Calls Update on window)]


[METH Window  RightSelection NIL
      (* Do RightButtonItems on selection.)]


[METH Window  SetProp (prop value)
      (* set value in real window)]


[METH Window  Shape (newRegion)
      (* Shapes outside of region to specified shape. %.)]


[METH Window  Shape? NIL
      (* Returns the current region for window)]


[METH Window  Shrink (towhat iconPos expandFn)
      (* Calls SHRINKW on window)]


[METH Window  Snap NIL
      (* Takes snapshot of screen)]


[METH Window  TitleSelection NIL
      (* Do TitleItems if selected in title area)]


[METH Window  Update NIL
      (* make the IV window be a window with properties consistent with ivs)]


(DEFINEQ

(Window.Blink
  [LAMBDA (self numBlinks)                                   (* dgb: "13-JUN-83 11:48")
                                                             (* Turn Window inverted, dismiss for 200, and return it 
							     to normal)
    (for from 1 to numBlinks
       do (DISMISS 250)
	  (BITBLT NIL NIL NIL (@ window)
		  NIL NIL NIL NIL (QUOTE TEXTURE)
		  (QUOTE INVERT)
		  BLACKSHADE)
	  (DISMISS 250)
	  (BITBLT NIL NIL NIL (@ window)
		  NIL NIL NIL NIL (QUOTE TEXTURE)
		  (QUOTE INVERT)
		  BLACKSHADE])

(Window.Bury
  [LAMBDA (self)                                             (* dgb: "26-JAN-83 10:51")
                                                             (* Calls BURYW on window)
    (BURYW (@ window])

(Window.Clear
  [LAMBDA (self)                                             (* dgb: "26-JAN-83 10:51")
                                                             (* Calls CLEARW on window)
    (CLEARW (@ window])

(Window.Close
  [LAMBDA (self)                                             (* dgb: "19-JAN-83 19:47")
                                                             (* Close the window)
    (CLOSEW (@ window])

(Window.Destroy
  [LAMBDA (self)                                             (* dgb: "26-JAN-83 11:19")
    (PROG [(w (GetIVHere self (QUOTE window]
          (COND
	    (w                                               (* there is a window)
	       (SETQ w (@ window))
	       (WINDOWPROP w (QUOTE LoopsWindow)
			   NIL)
	       (WINDOWPROP w (QUOTE RightButtonFn)
			   NIL)
	       (WINDOWPROP w (QUOTE ButtonEventFn)
			   NIL)
	       (CLOSEW w)))
          (←Super
	    self Destroy])

(Window.GetProp
  [LAMBDA (self prop)                                        (* dgb: "19-JAN-83 19:48")
                                                             (* get property from window)
    (WINDOWPROP (@ window)
		prop])

(Window.HasLispWindow
  [LAMBDA (self)                                             (* dgb: "29-JUN-83 17:01")
                                                             (* Checks if a Lisp window has ever been created for 
							     this Loops Window)
    (NEQ NotSetValue (GetIVHere self (QUOTE window])

(Window.LeftSelection
  [LAMBDA (self)                                             (* dgb: "28-MAR-83 17:06")
                                                             (* Do LeftButtonItems on selection)
    (DoMenuMethod self (@@ LeftButtonItems])

(Window.MiddleSelection
  [LAMBDA (self)                                             (* dgb: "28-MAR-83 17:07")
                                                             (* Do MiddleButtonItems on selection)
    (DoMenuMethod self (@@ MiddleButtonItems])

(Window.Move
  [LAMBDA (self xOrPos y)                                    (* dgb: "21-FEB-83 08:55")
    (PROG ((oldRegion (WINDOWPROP (@ window)
				  (QUOTE REGION)))
	   (newPos (MOVEW (@ window)
			  xOrPos y)))
          (←@
	    left
	    (fetch XCOORD of newPos))
          (←@
	    bottom
	    (fetch YCOORD of newPos))                        (* Update image if it started partly off screen)
          (OR (SUBREGIONP (CONSTANT (create REGION
					    LEFT ← 0
					    BOTTOM ← 0
					    WIDTH ← SCREENWIDTH
					    HEIGHT ← SCREENHEIGHT))
			  oldRegion)
	      (← self Update))
          (RETURN newPos])

(Window.Open
  [LAMBDA (self)                                             (* dgb: "23-JUN-83 15:08")
                                                             (* Open the window)
    (OR (ACTIVEWP (@ window))
	(PROGN (← self Update)
	       (OPENW (@ window])

(Window.Paint
  [LAMBDA (self)                                             (* dgb: "26-JAN-83 10:50")
                                                             (* Calls paint on window)
    (PAINTW (@ window])

(Window.Repaint
  [LAMBDA (self reg alwaysFlg)                               (* dgb: "26-JAN-83 23:46")
                                                             (* Calls Update on window)
    (← self Update])

(Window.RightSelection
  [LAMBDA (self)                                             (* dgb: "29-JUN-83 16:41")
                                                             (* Do RightButtonItems on selection.)
    (DoMenuMethod self (@@ RightButtonItems])

(Window.SetProp
  [LAMBDA (self prop value)                                  (* dgb: "19-JAN-83 19:49")
                                                             (* set value in real window)
    (WINDOWPROP self prop value])

(Window.Shape
  [LAMBDA (self newRegion)                                   (* dgb: "28-JAN-83 12:11")
                                                             (* Shapes outside of region to specified shape.
							     %.)
    (PROG (d)
          (SHAPEW (@ window)
		  newRegion)
          (SETQ d (WINDOWPROP (@ window)
			      (QUOTE REGION)))
          (←@
	    left
	    (fetch LEFT of d))
          (←@
	    bottom
	    (fetch BOTTOM of d))
          (←@
	    width
	    (WINDOWPROP (@ window)
			(QUOTE WIDTH)))
          (←@
	    height
	    (WINDOWPROP (@ window)
			(QUOTE HEIGHT)))
          (← self Update)
          (RETURN d])

(Window.Shape?
  [LAMBDA (self)                                             (* dgb: "26-JAN-83 11:21")
                                                             (* Returns the current region for window)
    (WINDOWPROP (@ window)
		(QUOTE REGION])

(Window.Shrink
  [LAMBDA (self towhat iconPos expandFn)                     (* dgb: "26-JAN-83 10:53")
                                                             (* Calls SHRINKW on window)
    (SHRINKW (@ window)
	     towhat iconPos expandFn])

(Window.Snap
  [LAMBDA (self)                                             (* sm: " 9-SEP-83 14:27")
                                                             (* Takes snapshot of screen)
    (SNAPW])

(Window.TitleSelection
  [LAMBDA (self)                                             (* dgb: "28-MAR-83 17:10")
                                                             (* Do TitleItems if selected in title area)
    (DoMenuMethod self (@@ TitleItems])

(Window.Update
  [LAMBDA (self)                                             (* dgb: "13-OCT-83 22:06")
                                                             (* make the IV window be a window with properties 
							     consistent with ivs)
    (PROG (region border (window (@ window)))
          (SETQ border (WINDOWPROP window (QUOTE BORDER)))   (* create a region if width and height known)
          (AND [NOT (EQUAL (@ title)
			   (WINDOWPROP window (QUOTE TITLE]
	       (WINDOWPROP window (QUOTE TITLE)
			   (@ title)))
          [AND (@ width)
	       (@ height)
	       (SETQ region (create REGION
				    LEFT ←(OR (@ left)
					      (←@
						left LASTMOUSEX))
				    BOTTOM ←(OR (@ bottom)
						(←@
						  bottom LASTMOUSEY))
				    WIDTH ←(WIDTHIFWINDOW (@ width)
							  border)
				    HEIGHT ←(HEIGHTIFWINDOW (@ height)
							    (@ title)
							    border]
          (AND region [NOT (EQUAL region (WINDOWPROP window (QUOTE REGION]
	       (SHAPEW window region])
)
(DEFINEQ

(GetLispWindow
  [LAMBDA (self varName localSt propName activeVal type)     (* dgb: "23-JUN-83 14:59")
                                                             (* This is a getFn for Window to insure a window is a 
							     real Lisp window.)
    [COND
      ((NOT (WINDOWP localSt))                               (* replace the local state with a window, associating 
							     this object with the window)
	(SETQ localSt (PutLocalState activeVal (PROG ((W (CREATEW (QUOTE (500 400 9 9))
								  NIL NIL T)))
						     (WINDOWPROP W (QUOTE LoopsWindow)
								 self)
						     (WINDOWPROP W (QUOTE RIGHTBUTTONFN)
								 (QUOTE WindowRightButtonFn))
						     (WINDOWPROP W (QUOTE BUTTONEVENTFN)
								 (QUOTE WindowButtonEventFn))
						     (RETURN W))
				     self varName propName type]
    localSt])

(WindowButtonEventFn
  [LAMBDA (window)                                           (* dgb: "28-MAR-83 17:03")
    (PROG [i itemName (w (WINDOWPROP window (QUOTE LoopsWindow]
          (OR w (RETURN))
          (TOTOPW window)
          (RETURN (COND
		    ((NULL (INSIDEP (DSPCLIPPINGREGION NIL window)
				    (LASTMOUSEX window)
				    (LASTMOUSEY window)))
		      (← w TitleSelection))
		    ((MOUSESTATE LEFT)
		      (← w LeftSelection))
		    ((MOUSESTATE MIDDLE)
		      (← w MiddleSelection])

(WindowRightButtonFn
  [LAMBDA (window)                                           (* dgb: "28-MAR-83 17:46")
    (PROG [i (w (WINDOWPROP window (QUOTE LoopsWindow]
          (OR w (RETURN))
          (TOTOPW window)
          (← w RightSelection])
)
(PUTPROPS LOOPSWINDOW COPYRIGHT ("Xerox Corporation" 1983))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (4001 11450 (Window.Blink 4011 . 4566) (Window.Bury 4568 . 4790) (Window.Clear 4792 . 
5017) (Window.Close 5019 . 5238) (Window.Destroy 5240 . 5742) (Window.GetProp 5744 . 5985) (
Window.HasLispWindow 5987 . 6311) (Window.LeftSelection 6313 . 6576) (Window.MiddleSelection 6578 . 
6847) (Window.Move 6849 . 7498) (Window.Open 7500 . 7774) (Window.Paint 7776 . 8000) (Window.Repaint 
8002 . 8226) (Window.RightSelection 8228 . 8495) (Window.SetProp 8497 . 8736) (Window.Shape 8738 . 
9415) (Window.Shape? 9417 . 9679) (Window.Shrink 9681 . 9940) (Window.Snap 9942 . 10156) (
Window.TitleSelection 10158 . 10425) (Window.Update 10427 . 11448)) (11451 13079 (GetLispWindow 11461
 . 12309) (WindowButtonEventFn 12311 . 12820) (WindowRightButtonFn 12822 . 13077)))))
STOP