(FILECREATED " 1-Jun-86 17:40:11" {QV}<NOTECARDS>1.3K>FGHLIO.;16 21939  

      changes to:  (CLASSES NumberedObjectMixin)
		   (METHODS NumberedObjectMixin.Renumber FigureTag.GetLabel)
		   (FNS NumberedObjectMixin.Renumber)

      previous date: " 1-Jun-86 14:47:22" {QV}<NOTECARDS>1.3K>FGHLIO.;14)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FGHLIOCOMS)

(RPAQQ FGHLIOCOMS ((FILES (FROM {PHYLUM}<LOOPS>USERS>)
			    LOOPSIMAGEOBJECTS)
	(CLASSES BoxedLabelOnDisplayMixin FigureTag FigureReference FigureTagSpecs 
		 NumberedObjectMixin SectReference SectTag)
	(METHODS BoxedLabelOnDisplayMixin.Display FigureReference.Display FigureReference.GetLabel 
		 FigureTag.Display FigureTag.GetLabel FigureTagSpecs.GetDisplayLabel 
		 FigureTagSpecs.HardcopySideEffect NumberedObjectMixin.AfterGetFromFile 
		 NumberedObjectMixin.MarkForRenumbering NumberedObjectMixin.Renumber 
		 NumberedObjectMixin.SequenceNumber NumberedObjectMixin.WhenCopied 
		 NumberedObjectMixin.WhenDeleted NumberedObjectMixin.WhenInserted 
		 NumberedObjectMixin.WhenMoved SectReference.Display SectReference.GetLabel 
		 SectTag.Display SectTag.GetLabel)
	(CLASSES WhenLastSaved)))
(FILESLOAD (FROM {PHYLUM}<LOOPS>USERS>)
	   LOOPSIMAGEOBJECTS)
(DEFCLASSES BoxedLabelOnDisplayMixin FigureTag FigureReference FigureTagSpecs NumberedObjectMixin 
	    SectReference SectTag)
[DEFCLASS BoxedLabelOnDisplayMixin
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 17:24"))
   (Supers LabelImageMixin)]

[DEFCLASS FigureTag
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 18:48"))
   (Supers TEditableImageObjectMixin NumberedObjectMixin BoxedLabelOnDisplayMixin)
   (ClassVariables (referenceFlg NIL doc                     (* this is a tag type object))
		   (sequenceType Figure doc                  (* XX)))
   (InstanceVariables (tag NIL doc                           (* the symbolic name of this figure))
		      (text "Figure" doc                     (* default preceeding text in a figure reference)
			    ))]

[DEFCLASS FigureReference
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 18:48"))
   (Supers TEditableImageObjectMixin BoxedLabelOnDisplayMixin NumberedObjectMixin)
   (ClassVariables (sequenceType Figure doc                  (* XX)))
   (InstanceVariables (tag NIL doc                           (* tag of figure being referenced))
		      (text "Figure" doc                     (* default text to be displayed before the figure 
							     number)))]

[DEFCLASS FigureTagSpecs
   (MetaClass Class Edited:                                  (* fgh: "29-May-86 23:54"))
   (Supers EditableImageObjectMixin HardcopySideEffectObject)
   (InstanceVariables (showTagsAtHardcopy T doc              (* should figure tags be shown in hardcopy mode?)
					  ))]

[DEFCLASS NumberedObjectMixin
   (MetaClass Class Edited:                                  (* fgh: " 1-Jun-86 17:31"))
   (Supers TEditImageObject)
   (ClassVariables (sequenceType Section doc                 (* type or name of numbered sequence))
		   (referenceFlg T doc                       (* Is this a reference type object or a tag type 
							     object?)))
   (InstanceVariables (level 1 doc                           (* depth of sequence numbers))
		      (fixedSequenceNumber NIL doc           (* sequence number that this object should always 
							     have))
		      (needsRenumbering T doc                (* flg to indicate whether containing stream needs to 
							     be renumbered)))]

[DEFCLASS SectReference
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 18:53"))
   (Supers TEditableImageObjectMixin NumberedObjectMixin BoxedLabelOnDisplayMixin)
   (ClassVariables (sequenceType Section doc                 (* type or name of numbered sequence)))
   (InstanceVariables (tag NIL doc                           (* tag of figure being referenced))
		      (text "Section" doc                    (* default text to be displayed before the figure 
							     number)))]

[DEFCLASS SectTag
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 18:57"))
   (Supers TEditableImageObjectMixin NumberedObjectMixin BoxedLabelOnDisplayMixin)
   (ClassVariables (referenceFlg NIL doc                     (* this is a tag type object))
		   (sequenceType Section doc                 (* type or name of numbered sequence)))
   (InstanceVariables (tag NIL doc                           (* the symbolic name of this figure))
		      (text "Section" doc                    (* default preceeding text in a figure reference)
			    ))]

[METH BoxedLabelOnDisplayMixin  Display (imageStream)
      (* Specialization)]


[METH FigureReference  Display (imageStream)
      (* New method template)]


[METH FigureReference  GetLabel (imageStream)
      (* * Display the tag and figure number if any.)]


[METH FigureTag  Display (imageStream)
      (* New method template)]


[METH FigureTag  GetLabel (imageStream)
      (* * Figure number)]


[METH FigureTagSpecs  GetDisplayLabel NIL
      (* New method template)]


[METH FigureTagSpecs  HardcopySideEffect (imageStream)
      (* chache the figure tags specs on the text stream)]


[METH NumberedObjectMixin  AfterGetFromFile NIL
      (* Make sure get renumbered before being displayed.)]


[METH NumberedObjectMixin  MarkForRenumbering (textStream)
      (* mark all sequence objects on text stream for renumbering)]


[METH NumberedObjectMixin  Renumber (textStream)
      (* * renumber all of the objects in text stream.)]


[METH NumberedObjectMixin  SequenceNumber (imageStream)
      (* Renumber if required)]


[METH NumberedObjectMixin  WhenCopied (targetWindowStream sourceTextStream targetTextStream)
      (* Mark all sequence objects for recomputation)]


[METH NumberedObjectMixin  WhenDeleted (window)
      (* Mark all sequence objects for recomputation)]


[METH NumberedObjectMixin  WhenInserted (windowStream DUMMY textStream)
      (* Mark all sequence objects for recomputation)]


[METH NumberedObjectMixin  WhenMoved (targetWindowStream sourceTextStream targetTextStream)
      (* Mark all sequence objects for recomputation)]


[METH SectReference  Display (imageStream)
      (* New method template)]


[METH SectReference  GetLabel (imageStream)
      (* * Display the tag and figure number if any.)]


[METH SectTag  Display (imageStream)
      (* New method template)]


[METH SectTag  GetLabel (imageStream)
      (* * Figure number)]


(DEFINEQ

(BoxedLabelOnDisplayMixin.Display
  (Method ((BoxedLabelOnDisplayMixin Display)
	   self imageStream)                                 (* fgh: "30-May-86 17:27")
                                                             (* Specialization)
	  (LET ((xPos (DSPXPOSITION NIL imageStream))
		(yPos (DSPYPOSITION NIL imageStream))
		(imageBox (← self CachedImageBox imageStream)))
	       (PROG1 (←Super)
			(if (← self DisplayImageStream? imageStream)
			    then 

          (* Draw a box around the object, then invert the whole thing. The box will then show up if the object is inverted 
	  again, like it is when it is selected for deletetion.)


				   (LET ((x0 (DIFFERENCE xPos (fetch XKERN of imageBox)))
					 (y0 (DIFFERENCE yPos (fetch YDESC of imageBox)))
					 (xSize (fetch XSIZE of imageBox))
					 (ySize (fetch YSIZE of imageBox)))
				        (BITBLT NIL NIL NIL imageStream x0 y0 1 ySize (QUOTE
						    TEXTURE)
						  (QUOTE PAINT)
						  BLACKSHADE)
				        (BITBLT NIL NIL NIL imageStream (PLUS x0 (SUB1 xSize))
						  y0 1 ySize (QUOTE TEXTURE)
						  (QUOTE PAINT)
						  BLACKSHADE)
				        (BITBLT NIL NIL NIL imageStream x0 y0 xSize 1 (QUOTE
						    TEXTURE)
						  (QUOTE PAINT)
						  BLACKSHADE)
				        (BITBLT NIL NIL NIL imageStream x0 (PLUS y0 (SUB1
										       ySize))
						  xSize 1 (QUOTE TEXTURE)
						  (QUOTE PAINT)
						  BLACKSHADE)
				        (BITBLT NIL NIL NIL imageStream x0 y0 xSize ySize
						  (QUOTE TEXTURE)
						  (QUOTE INVERT)
						  BLACKSHADE)))))))

(FigureReference.Display
  (Method ((FigureReference Display)
	   self imageStream)                                 (* fgh: "29-May-86 18:04")
                                                             (* New method template)
	  (LET ((xPos (DSPXPOSITION NIL imageStream))
		(yPos (DSPYPOSITION NIL imageStream))
		(imageBox (← self CachedImageBox imageStream)))
	       (PROG1 (←Super)
			(if (← self DisplayImageStream? imageStream)
			    then                           (* Re-invert)
				   (BITBLT NIL NIL NIL imageStream (DIFFERENCE xPos
										   (fetch XKERN
										      of imageBox))
					     (DIFFERENCE yPos (fetch YDESC of imageBox))
					     (fetch XSIZE of imageBox)
					     (fetch YSIZE of imageBox)
					     (QUOTE TEXTURE)
					     (QUOTE INVERT)
					     BLACKSHADE))))))

(FigureReference.GetLabel
  (Method ((FigureReference GetLabel)
	   self imageStream)                                 (* fgh: "30-May-86 23:32")

          (* * Display the tag and figure number if any.)


	  (CONCAT (if (@ text)
			then (CONCAT (@ text)
					 " ")
		      else "")
		    (OR (LISTGET (STREAMPROP (← self TextStream imageStream)
						   (@ self sequenceType))
				     (@ tag))
			  "N")
		    (if (OR (← self DisplayImageStream? imageStream)
				(STREAMPROP (← self TextStream imageStream)
					      (QUOTE ShowFigureTagsInHardcopy)))
			then (CONCAT " (@" (@ tag)
					 ")")
		      else ""))))

(FigureTag.Display
  (Method ((FigureTag Display)
	   self imageStream)                                 (* fgh: "29-May-86 18:04")
                                                             (* New method template)
	  (LET ((xPos (DSPXPOSITION NIL imageStream))
		(yPos (DSPYPOSITION NIL imageStream))
		(imageBox (← self CachedImageBox imageStream)))
	       (PROG1 (←Super)
			(if (← self DisplayImageStream? imageStream)
			    then                           (* Re-invert)
				   (BITBLT NIL NIL NIL imageStream (DIFFERENCE xPos
										   (fetch XKERN
										      of imageBox))
					     (DIFFERENCE yPos (fetch YDESC of imageBox))
					     (fetch XSIZE of imageBox)
					     (fetch YSIZE of imageBox)
					     (QUOTE TEXTURE)
					     (QUOTE INVERT)
					     BLACKSHADE))))))

(FigureTag.GetLabel
  (Method ((FigureTag GetLabel)
	   self imageStream)                                 (* fgh: "30-May-86 19:20")

          (* * Figure number)


	  (CONCAT (if (@ text)
			then (CONCAT (@ text)
					 " ")
		      else "")
		    (OR (← self SequenceNumber imageStream)
			  "N")
		    (if (OR (← self DisplayImageStream? imageStream)
				(STREAMPROP (← self TextStream imageStream)
					      (QUOTE ShowFigureTagsInHardcopy)))
			then (CONCAT " (" (@ tag)
					 ")")
		      else ""))))

(FigureTagSpecs.GetDisplayLabel
  (Method ((FigureTagSpecs GetDisplayLabel)
	   self)                                             (* fgh: "29-May-86 23:53")
                                                             (* New method template)
	  "Figure tag specs"))

(FigureTagSpecs.HardcopySideEffect
  (Method ((FigureTagSpecs HardcopySideEffect)
	   self imageStream)                                 (* fgh: "29-May-86 23:51")
                                                             (* chache the figure tags specs on the text stream)
	  (STREAMPROP (← self TextStream imageStream)
			(QUOTE ShowFigureTagsInHardcopy)
			(@ showTagsAtHardcopy))))

(NumberedObjectMixin.AfterGetFromFile
  (Method ((NumberedObjectMixin AfterGetFromFile)
	   self)                                             (* fgh: "30-May-86 20:33")
                                                             (* Make sure get renumbered before being displayed.)
	  (←@
	    self needsRenumbering T)
	  (←Super)))

(NumberedObjectMixin.MarkForRenumbering
  (Method ((NumberedObjectMixin MarkForRenumbering)
	   self textStream)                                  (* fgh: "30-May-86 17:51")
                                                             (* mark all sequence objects on text stream for 
							     renumbering)
	  (for Item in (TEDIT.LIST.OF.OBJECTS (TEXTOBJ textStream)
						    (FUNCTION (LAMBDA (ImageObj)
							(AND (Object? (IMAGEOBJPROP ImageObj
											(QUOTE
											  OBJECTDATUM)
											))
							       (← (IMAGEOBJPROP ImageObj
										    (QUOTE 
										      OBJECTDATUM))
								    InstOf!(QUOTE 
									      NumberedObjectMixin)))))
						    )
	     do 

          (* * Mark for renumbering)


		  (←@
		    (IMAGEOBJPROP (CAR Item)
				    (QUOTE OBJECTDATUM))
		    needsRenumbering T))))

(NumberedObjectMixin.Renumber
  (Method ((NumberedObjectMixin Renumber)
	   self textStream)                                  (* fgh: " 1-Jun-86 17:30")

          (* * renumber all of the objects in text stream.)


	  (LET ((CtrLst (LIST (QUOTE \X)
				0))
		Ctr sequenceNumber)
	       (STREAMPROP textStream (@ self sequenceType)
			     NIL)
	       (bind Object for Item in (TEDIT.LIST.OF.OBJECTS
						(TEXTOBJ textStream)
						(FUNCTION (LAMBDA (ImageObj)
						    (AND (Object? (IMAGEOBJPROP ImageObj
										    (QUOTE 
										      OBJECTDATUM)))
							   (← (IMAGEOBJPROP ImageObj
										(QUOTE OBJECTDATUM))
								InstOf!(QUOTE NumberedObjectMixin))
							   (NULL (@ (IMAGEOBJPROP ImageObj
										      (QUOTE 
										      OBJECTDATUM))
								      ::referenceFlg))
							   (EQ (@ self ::sequenceType)
								 (@ (IMAGEOBJPROP ImageObj
										    (QUOTE 
										      OBJECTDATUM))
								    ::sequenceType))))))
		  do 

          (* * Get the actual loops object from the imageobj)


		       (SETQ Object (IMAGEOBJPROP (CAR Item)
						      (QUOTE OBJECTDATUM)))

          (* * Unmark for renumbering)


		       (←@
			 Object needsRenumbering NIL)

          (* * If no existing ctr, make one.)


		       (if (SETQ Ctr (LISTGET CtrLst (@ Object sequenceType)))
			 else (SETQ Ctr (LISTPUT CtrLst (@ Object sequenceType)
						       (for I from 1 to (@ Object level)
							  collect 0))))

          (* * Make sure the ctr length matches the level)


		       (if (LESSP (LENGTH Ctr)
				      (@ Object level))
			   then (NCONC Ctr (for I from (ADD1 (LENGTH Ctr))
						  to (@ Object level) collect 0))
			 elseif (LESSP (@ Object level)
					   (LENGTH Ctr))
			   then (RPLACD (NTH Ctr (@ Object level))
					    NIL))

          (* * Bump the last item up by one or reset it to the specified number.)


		       (RPLACA (LAST Ctr)
				 (OR (@ Object fixedSequenceNumber)
				       (ADD1 (CAR (LAST Ctr)))))

          (* * Cache the resulting sequence number.)


		       (← Object PutCache (QUOTE sequenceNumber)
			    (SETQ sequenceNumber (APPLY (FUNCTION CONCAT)
							    (CONS (CAR Ctr)
								    (for Level in (CDR Ctr)
								       collect (CONCAT "." Level))
								    ))))

          (* * also change label for references)


		       (if (STREAMPROP textStream (@ Object sequenceType))
			   then (LISTPUT (STREAMPROP textStream (@ self sequenceType))
					     (@ Object tag)
					     sequenceNumber)
			 else (STREAMPROP textStream (@ Object sequenceType)
					      (LIST (@ Object tag)
						      sequenceNumber)))))))

(NumberedObjectMixin.SequenceNumber
  (Method ((NumberedObjectMixin SequenceNumber)
	   self imageStream)                                 (* fgh: "30-May-86 17:58")
                                                             (* Renumber if required)
	  (if (@ needsRenumbering)
	      then (← self Renumber (← self TextStream imageStream)))
	  (← self GetCache (QUOTE sequenceNumber))))

(NumberedObjectMixin.WhenCopied
  (Method ((NumberedObjectMixin WhenCopied)
	   self targetWindowStream sourceTextStream targetTextStream)
                                                             (* fgh: "30-May-86 17:48")
                                                             (* Mark all sequence objects for recomputation)
	  (← self MarkForRenumbering targetTextStream)))

(NumberedObjectMixin.WhenDeleted
  (Method ((NumberedObjectMixin WhenDeleted)
	   self window)                                      (* fgh: "30-May-86 17:47")
                                                             (* Mark all sequence objects for recomputation)
	  (← self MarkForRenumbering (TEXTSTREAM window))))

(NumberedObjectMixin.WhenInserted
  (Method ((NumberedObjectMixin WhenInserted)
	   self windowStream DUMMY textStream)               (* fgh: "30-May-86 17:48")
                                                             (* Mark all sequence objects for recomputation)
	  (← self MarkForRenumbering textStream)))

(NumberedObjectMixin.WhenMoved
  (Method ((NumberedObjectMixin WhenMoved)
	   self targetWindowStream sourceTextStream targetTextStream)
                                                             (* fgh: "30-May-86 17:48")
                                                             (* Mark all sequence objects for recomputation)
	  (← self MarkForRenumbering targetTextStream)))

(SectReference.Display
  (Method ((SectReference Display)
	   self imageStream)                                 (* fgh: "30-May-86 18:47")
                                                             (* New method template)
	  (LET ((xPos (DSPXPOSITION NIL imageStream))
		(yPos (DSPYPOSITION NIL imageStream))
		(imageBox (← self CachedImageBox imageStream)))
	       (PROG1 (←Super)
			(if (← self DisplayImageStream? imageStream)
			    then                           (* Re-invert)
				   (BITBLT NIL NIL NIL imageStream (DIFFERENCE xPos
										   (fetch XKERN
										      of imageBox))
					     (DIFFERENCE yPos (fetch YDESC of imageBox))
					     (fetch XSIZE of imageBox)
					     (fetch YSIZE of imageBox)
					     (QUOTE TEXTURE)
					     (QUOTE INVERT)
					     BLACKSHADE))))))

(SectReference.GetLabel
  (Method ((SectReference GetLabel)
	   self imageStream)                                 (* fgh: "30-May-86 19:22")

          (* * Display the tag and figure number if any.)


	  (CONCAT (if (@ text)
			then (CONCAT (@ text)
					 " ")
		      else "")
		    (OR (LISTGET (STREAMPROP (← self TextStream imageStream)
						   (@ self sequenceType))
				     (@ tag))
			  "N")
		    (if (OR (← self DisplayImageStream? imageStream)
				(STREAMPROP (← self TextStream imageStream)
					      (QUOTE ShowFigureTagsInHardcopy)))
			then (CONCAT " (" (@ tag)
					 ")")
		      else ""))))

(SectTag.Display
  (Method ((SectTag Display)
	   self imageStream)                                 (* fgh: "30-May-86 18:46")
                                                             (* New method template)
	  (LET ((xPos (DSPXPOSITION NIL imageStream))
		(yPos (DSPYPOSITION NIL imageStream))
		(imageBox (← self CachedImageBox imageStream)))
	       (PROG1 (←Super)
			(if (← self DisplayImageStream? imageStream)
			    then                           (* Re-invert)
				   (BITBLT NIL NIL NIL imageStream (DIFFERENCE xPos
										   (fetch XKERN
										      of imageBox))
					     (DIFFERENCE yPos (fetch YDESC of imageBox))
					     (fetch XSIZE of imageBox)
					     (fetch YSIZE of imageBox)
					     (QUOTE TEXTURE)
					     (QUOTE INVERT)
					     BLACKSHADE))))))

(SectTag.GetLabel
  (Method ((SectTag GetLabel)
	   self imageStream)                                 (* fgh: "30-May-86 19:22")

          (* * Figure number)


	  (CONCAT (if (@ text)
			then (CONCAT (@ text)
					 " ")
		      else "")
		    (OR (← self SequenceNumber imageStream)
			  "N")
		    (if (OR (← self DisplayImageStream? imageStream)
				(STREAMPROP (← self TextStream imageStream)
					      (QUOTE ShowFigureTagsInHardcopy)))
			then (CONCAT " (" (@ tag)
					 ")")
		      else ""))))
)
(DEFCLASSES WhenLastSaved)
[DEFCLASS WhenLastSaved
   (MetaClass Class Edited:                                  (* fgh: "30-May-86 00:38")
	      doc                                            (* The time the containing TEdit file was last put)
	      )
   (Supers WhenSavedImageObject)
   (InstanceVariables (labelForm (CONCAT (SUBATOM (DATE)
						      1 -4))))]

(PUTPROPS FGHLIO COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (6799 21471 (BoxedLabelOnDisplayMixin.Display 6809 . 8511) (FigureReference.Display 8513
 . 9413) (FigureReference.GetLabel 9415 . 10114) (FigureTag.Display 10116 . 11004) (FigureTag.GetLabel
 11006 . 11589) (FigureTagSpecs.GetDisplayLabel 11591 . 11868) (FigureTagSpecs.HardcopySideEffect 
11870 . 12281) (NumberedObjectMixin.AfterGetFromFile 12283 . 12628) (
NumberedObjectMixin.MarkForRenumbering 12630 . 13540) (NumberedObjectMixin.Renumber 13542 . 16506) (
NumberedObjectMixin.SequenceNumber 16508 . 16931) (NumberedObjectMixin.WhenCopied 16933 . 17334) (
NumberedObjectMixin.WhenDeleted 17336 . 17676) (NumberedObjectMixin.WhenInserted 17678 . 18007) (
NumberedObjectMixin.WhenMoved 18009 . 18408) (SectReference.Display 18410 . 19306) (
SectReference.GetLabel 19308 . 20002) (SectTag.Display 20004 . 20888) (SectTag.GetLabel 20890 . 21469)
))))
STOP