(FILECREATED "20-SEP-83 09:38:08" {INDIGO}<LOOPS>SOURCES>LOOPSWINDOW.;2 14182  

      changes to:  (VARS LOOPSWINDOWCOMS)
		   (FNS GetLispWindow)

      previous date: "20-SEP-83 09:10:18" {INDIGO}<LOOPS>SOURCES>LOOPSWINDOW.;1)


(PRETTYCOMPRINT LOOPSWINDOWCOMS)

(RPAQQ LOOPSWINDOWCOMS ((CLASSES Window)
	(FNS GetLispWindow WindowButtonEventFn WindowRightButtonFn 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 Window.Blink)))
(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)))
   (Methods (Bury Window.Bury args NIL doc                   (* Calls BURYW on window))
	    (Clear Window.Clear args NIL doc                 (* Calls CLEARW on window))
	    (Close Window.Close args NIL doc                 (* Close the window))
	    (Destroy Window.Destroy args NIL doc             (* get property from window))
	    (GetProp Window.GetProp args (prop)
		     doc                                     (* get property from window)
		     )
	    (HasLispWindow Window.HasLispWindow args NIL doc 
                                                             (* Checks if a Lisp window has ever been created for 
							     this Loops Window))
	    (LeftSelection Window.LeftSelection args NIL doc 
                                                             (* Do LeftButtonItems on selection))
	    (MiddleSelection Window.MiddleSelection args NIL doc 
                                                             (* Do MiddleButtonItems on selection))
	    (Move Window.Move args (xOrPos y)
		  doc                                        (* Open the window)
		  )
	    (Open Window.Open args NIL doc                   (* Open the window))
	    (Paint Window.Paint args NIL doc                 (* Calls paint on window))
	    (Repaint Window.Repaint args (reg alwaysFlg)
		     doc                                     (* Calls Update on window)
		     )
	    (RightSelection Window.RightSelection args NIL doc 
                                                             (* Do RightButtonItems on selection.))
	    (SetProp Window.SetProp args (prop value)
		     doc                                     (* set value in real window)
		     )
	    (Shape Window.Shape args (newRegion)
		   doc                                       (* Shapes outside of region to specified shape.
							     %.)
		   )
	    (Shape? Window.Shape? args NIL doc               (* Returns the current region for window)
		    )
	    (Shrink Window.Shrink args (towhat iconPos expandFn)
		    doc                                      (* Calls SHRINKW on window)
		    )
	    (Snap Window.Snap args NIL doc                   (* Takes snapshot of screen))
	    (TitleSelection Window.TitleSelection args NIL doc 
                                                             (* Do TitleItems if selected in title area)
			    )
	    (Update Window.Update args NIL doc               (* make the IV window be a window with properties 
							     consistent with ivs))
	    (Blink Window.Blink args (numBlinks)
		   doc                                       (* Turn Window inverted, dismiss for 200, and return it 
							     to normal)
		   ))]

(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])

(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: "23-JUN-83 14:48")
                                                             (* 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])

(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])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (5093 14160 (GetLispWindow 5103 . 5951) (WindowButtonEventFn 5953 . 6462) (
WindowRightButtonFn 6464 . 6719) (Window.Bury 6721 . 6943) (Window.Clear 6945 . 7170) (Window.Close 
7172 . 7391) (Window.Destroy 7393 . 7895) (Window.GetProp 7897 . 8138) (Window.HasLispWindow 8140 . 
8464) (Window.LeftSelection 8466 . 8729) (Window.MiddleSelection 8731 . 9000) (Window.Move 9002 . 9651
) (Window.Open 9653 . 9927) (Window.Paint 9929 . 10153) (Window.Repaint 10155 . 10379) (
Window.RightSelection 10381 . 10648) (Window.SetProp 10650 . 10889) (Window.Shape 10891 . 11568) (
Window.Shape? 11570 . 11832) (Window.Shrink 11834 . 12093) (Window.Snap 12095 . 12309) (
Window.TitleSelection 12311 . 12578) (Window.Update 12580 . 13601) (Window.Blink 13603 . 14158)))))
STOP