(FILECREATED " 9-JUN-82 21:39:17" {IVY}<BOBROW>LISP>ICON.;14 10302  

     changes to:  CedarIconIndex SELECTW

     previous date: " 8-JUN-82 18:28:47" {IVY}<BOBROW>LISP>ICON.;13)


(PRETTYCOMPRINT ICONCOMS)

(RPAQQ ICONCOMS ((VARS * ICONVARS)
		 (FNS * ICONFNS)
		 (FNS * ICONWFNS)))

(RPAQQ ICONVARS (BG1 CedarIconIndex DefaultIconHeight DefaultIconRegion IconMenuItems (IconMenu)))

(RPAQQ BG1 34850)

(RPAQQ CedarIconIndex ((Document . 0)
		       (FileCabinet . 1)
		       (Envelope . 2)
		       (People . 3)
		       (Map . 4)
		       (Printer . 5)
		       (Calendar . 6)
		       (QuestionMark . 7)
		       (TV . 8)
		       (BriefCase . 9)
		       (ToolBox . 10)
		       (Envelopes . 11)
		       (Person . 12)
		       (NotePad . 13)
		       (Squirrel . 14)
		       (MailBox . 15)
		       (Lecturer . 16)
		       (Scroll . 17)))

(RPAQQ DefaultIconHeight 13)

(RPAQQ DefaultIconRegion (500 400 128 22))

(RPAQQ IconMenuItems (Open))

(RPAQQ IconMenu NIL)

(RPAQQ ICONFNS (IconButtonEventFn MakeWindowIcon MakeWindowShade SELECTW WindowShadeButtonFn 
				  MoveShadeFn OpenIconWindow ReadCedarBM UnMakeWindowShade))
(DEFINEQ

(IconButtonEventFn
  [LAMBDA (iconWindow)                                       (* dgb: " 4-JUN-82 07:00")
                                                             (* Called when an iconWindow is buttoned.
							     Allows one to open up the mainWindow)
    (TOTOPW)
    (COND
      ((LASTMOUSESTATE (OR LEFT MIDDLE))                     (* Put up menu to open mainWindow)
	(COND
	  ([EQ (QUOTE Open)
	       (MENU (OR IconMenu (SETQ IconMenu (create MENU
							 ITEMS ← IconMenuItems]
                                                             (* Only selection from menu.)
	    (CLOSEW iconWindow)                              (* Close icon Window)
	    (PROG ((mainWindow (WINDOWPROP iconWindow (QUOTE IconFor)))
		   fn)
	          (OPENW mainWindow)
	          (COND
		    ((SETQ fn (WINDOWPROP mainWindow (QUOTE OPENFN)))
                                                             (* If it has an openFn, apply it)
		      (APPLY* fn mainWindow])

(MakeWindowIcon
  [LAMBDA (window contents openFn iconPosition)              (* dgb: " 8-JUN-82 18:28")

          (* Create a small window which acts as an Icon of window. This "icon window" provides a popup menu which will open
	  the main window again, and run the function openFn. contents can be a BITMAP which will be used to make a window 
	  image, an existing window, or a string which will be printed in title only icon window, or can be an existing 
	  window. If contents is NIL, the title of the main window is used as the contents for the icon.
	  If iconPosition is not given, the user is asked to move the window)


    [COND
      ((NULL window)                                         (* If not given, use the one under the cursor)
	(SETQ window (WHICHW)))
      ((EQ window T)
	(SETQ window (SELECTW]
    (COND
      ((NOT (WINDOWP window))
	(ERROR window "Not a window")))
    (PROG [iconWindow (title (WINDOWPROP window (QUOTE TITLE]
          [SETQ iconWindow
	    (COND
	      [(type? BITMAP contents)                       (* use bitMap to create a window)
		(OPENW (CREATEWFROMIMAGE (BITMAPCOPY contents]
	      ((WINDOWP contents)                            (* use given window as icon)
		contents)
	      (T (SETQ title (OR contents title))            (* Used as label in icon)
		 (CREATEW [create REGION
				  LEFT ← LASTMOUSEX
				  BOTTOM ← LASTMOUSEY
				  HEIGHT ← DefaultIconHeight
				  WIDTH ←(IPLUS 8 (STRINGWIDTH title (QUOTE (HELVETICA 8]
			  title]
          (WINDOWPROP window (QUOTE IconWindow)
		      iconWindow)
          (WINDOWPROP window (QUOTE CLOSEFN)
		      (QUOTE OpenIconWindow))
          (WINDOWPROP window (QUOTE OPENFN)
		      openFn)                                (* Function to be applied when window is opened from 
							     icon)
          (WINDOWPROP iconWindow (QUOTE IconFor)
		      window)
          (WINDOWPROP iconWindow (QUOTE BUTTONEVENTFN)
		      (QUOTE IconButtonEventFn))
          (MOVEW iconWindow iconPosition))
    (CLOSEW window])

(MakeWindowShade
  [LAMBDA (window)                                           (* dgb: " 4-JUN-82 14:27")

          (* Create an iconWindow which acts as an Icon of window with only a title -- taken from the main window.
	  This iconWindow opens the main window and runs its BUTTONFN. The region is that of the title of the given window 
	  plus a small white space below.)


    [COND
      ((NULL window)                                         (* If window not given, use the one at the cursor)
	(SETQ window (WHICHW)))
      ((EQ window T)
	(SETQ window (SELECTW]
    (COND
      ((NOT (WINDOWP window))
	(ERROR window "Not a window")))
    (PROG [iconWindow (wregion (WINDOWPROP window (QUOTE REGION)))
		      (title (WINDOWPROP window (QUOTE TITLE]
          (SETQ iconWindow (CREATEW (create REGION
					    LEFT ←(fetch LEFT of wregion)
					    BOTTOM ←(IPLUS (fetch BOTTOM of wregion)
							   (fetch HEIGHT of wregion)
							   -20)
					    HEIGHT ← 20
					    WIDTH ←(fetch WIDTH of wregion))
				    title))
          (WINDOWPROP window (QUOTE IconWindow)
		      iconWindow)
          (WINDOWPROP window (QUOTE CLOSEFN)
		      (QUOTE OpenIconWindow))
          (WINDOWPROP iconWindow (QUOTE IconFor)
		      window)
          (WINDOWPROP iconWindow (QUOTE BUTTONEVENTFN)
		      (QUOTE WindowShadeButtonFn))
          (WINDOWPROP iconWindow (QUOTE MOVEFN)
		      (QUOTE MoveShadeFn))
          (WINDOWPROP iconWindow (QUOTE CLOSEFN)
		      (QUOTE UnMakeWindowShade))
          (CLOSEW window])

(SELECTW
  [LAMBDA NIL                                                (* dgb: " 9-JUN-82 21:38")
    (PROG NIL
          (PROMPT "Move mouse to desired window.
then press down the CTRL key")
      LP  [COND
	    ((KEYDOWNP (QUOTE CTRL))
	      (GETMOUSESTATE)
	      (PROMPT)
	      (RETURN (WHICHW]
          (GO LP])

(WindowShadeButtonFn
  [LAMBDA (windowShade)                                      (* dgb: " 4-JUN-82 07:14")
                                                             (* Open the main window, run its button fn, close it and
							     return)
    (PROG [(mainWindow (OPENW (WINDOWPROP windowShade (QUOTE IconFor]
          (ADJUSTCURSORPOSITION 0 -20)                       (* Move cursor down so it is sure to be in the 
							     mainWindow)
          (APPLY* (WINDOWPROP mainWindow (QUOTE BUTTONEVENTFN))
		  mainWindow)
          (CLOSEW mainWindow])

(MoveShadeFn
  [LAMBDA (iconWindow pos)                                   (* dgb: " 4-JUN-82 07:17")
                                                             (* Makes sure that mainWindow moves right along with 
							     windowShade)
    (PROG [(wr (WINDOWPROP iconWindow (QUOTE REGION]
          (MOVEWBY (WINDOWPROP iconWindow (QUOTE IconFor))
		   (IDIFFERENCE (fetch XCOORD of pos)
				(fetch LEFT of wr))
		   (IDIFFERENCE (fetch YCOORD of pos)
				(fetch BOTTOM of wr])

(OpenIconWindow
  [LAMBDA (window)                                           (* dgb: " 3-JUN-82 08:50")
    (OPENW (WINDOWPROP window (QUOTE IconWindow])

(ReadCedarBM
  [LAMBDA (key makeWindowFlg)                                (* dgb: " 4-JUN-82 14:09")
                                                             (* Read in one cedar bitmap, and makes a window 
							     makeWindowFlg not = NIL.)
    (COND
      ((NULL key)
	CedarIconIndex)
      (T (PROG [B INDEX (F (\GETOFD (OPENFILE (QUOTE {INDIGO}<CEDAR>VIEWERS>VIEWERS.ICONS)
					      (QUOTE INPUT]
	       [COND
		 ((NUMBERP key)
		   (SETQ INDEX key))
		 (T                                          (* Default is to read in first icon.
							     CedarIconIndex is an assoc list of names and indices)
		    (SETQ INDEX (OR (CDR (ASSOC key CedarIconIndex))
				    0]
	       (COND
		 ((IGREATERP INDEX 17)
		   (ERROR INDEX "larger than number of Icons")))
	       (SETFILEPTR F (ITIMES 512 INDEX))             (* Each icon is 512 bytes, 64 by 64 bits)
	       (SETQ B (BITMAPCREATE 64 64))
	       (BINS F (fetch BITMAPBASE of B)
		     0
		     (ITIMES 128 (fetch BITMAPRASTERWIDTH of B)))
	       (CLOSEF F)
	       (COND
		 (makeWindowFlg                              (* Make an open window at 600 600)
				(SETQ B (CREATEWFROMIMAGE B))
				(MOVEW B (QUOTE (600 . 600)))
				(OPENW B)))
	       (RETURN B])

(UnMakeWindowShade
  [LAMBDA (window)                                           (* dgb: " 3-JUN-82 12:05")
                                                             (* Closefn for MenuShades)
    (OR window (SETQ window (WHICHW)))
    (WINDOWPROP (OPENW (WINDOWPROP window (QUOTE IconFor)))
		(QUOTE IconWindow)
		NIL)                                         (* Open window. Break forward link, and back link)
    (WINDOWPROP window (QUOTE IconFor)
		NIL])
)

(RPAQQ ICONWFNS (FLIPREGION MOVEWBY))
(DEFINEQ

(FLIPREGION
  [LAMBDA (DSP REGION)                                       (* dgb: " 3-JUN-82 10:08")
                                                             (* Complement bits in region in DSP.
							     If only DSP is given, complement the window or the DSP)
    [COND
      ((NULL REGION)
	(SETQ REGION (DSPCLIPPINGREGION NIL DSP]
    (BITBLT NIL NIL NIL DSP (fetch LEFT of REGION)
	    (fetch BOTTOM of REGION)
	    (fetch WIDTH of REGION)
	    (fetch HEIGHT of REGION)
	    (QUOTE TEXTURE)
	    (QUOTE INVERT)
	    BLACKSHADE])

(MOVEWBY
  [LAMBDA (WINDOW DX DY)                                     (* dgb: " 4-JUN-82 07:02")
                                                             (* Move WINDOW by relative DX DY)
    (PROG [(wr (WINDOWPROP WINDOW (QUOTE REGION]
          (MOVEW WINDOW (create POSITION
				XCOORD ←(IPLUS (fetch LEFT of wr)
					       DX)
				YCOORD ←(IPLUS (fetch BOTTOM of wr)
					       DY])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1176 9213 (IconButtonEventFn 1186 . 2185) (MakeWindowIcon 2187 . 4266) (MakeWindowShade
 4268 . 5847) (SELECTW 5849 . 6175) (WindowShadeButtonFn 6177 . 6761) (MoveShadeFn 6763 . 7297) (
OpenIconWindow 7299 . 7460) (ReadCedarBM 7462 . 8734) (UnMakeWindowShade 8736 . 9211)) (9257 10280 (
FLIPREGION 9267 . 9852) (MOVEWBY 9854 . 10278)))))
STOP