(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED " 8-Mar-88 12:37:13" {QV}<NOTECARDS>1.3LNEXT>PMIPATCH090.;11 27133  

      changes to%:  (FNS NCGT.CreateTableTop NCTableTop.ComputeTableTop NCTableTop.MakeFn 
                         NCTableTop.RemakeTableTop NCTableTop.RecomputeTableTop 
                         NCTableTop.OpenCardInTableTop)
                    (VARS PMIPATCH090COMS)

      previous date%: "18-Feb-88 12:01:58" {QV}<NOTECARDS>1.3LNEXT>PMIPATCH090.;2)


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

(PRETTYCOMPRINT PMIPATCH090COMS)

(RPAQQ PMIPATCH090COMS (

(* ;;; "Miscellaneous changes to NCTABLETOPCARD and NCGUIDEDTOURCARD")

                        (DECLARE%: DONTCOPY (PROPS (PMIPATCH090 MAKEFILE-ENVIRONMENT)
                                                   (PMIPATCH090 FILETYPE)))
                        
          
          (* ;; " Changed in NCTABLETOPCARD")

                        (FNS NCTableTop.ComputeTableTop NCTableTop.OpenCardInTableTop 
                             NCTableTop.RemakeTableTopSelectingNewCards NCTableTop.RemakeTableTop 
                             NCTableTop.RecomputeTableTop NCTableTop.ComputeTableTop 
                             NCTableTop.MakeFn)
                        
          
          (* ;; " Changed in NCGUIDEDTOURCARD")

                        (FNS NCGT.CreateTableTop NCGT.MakeGuidedTourCard)))



(* ;;; "Miscellaneous changes to NCTABLETOPCARD and NCGUIDEDTOURCARD")

(DECLARE%: DONTCOPY 

(PUTPROPS PMIPATCH090 MAKEFILE-ENVIRONMENT (:PACKAGE "INTERLISP" :READTABLE "INTERLISP"))

(PUTPROPS PMIPATCH090 FILETYPE :BCOMPL)
)



(* ;; " Changed in NCTABLETOPCARD")

(DEFINEQ

(NCTableTop.ComputeTableTop
  [LAMBDA (ListOfCards TableTopCard RetainClosedCardsFlg)    (* ; "Edited 22-Feb-88 15:02 by pmi")
          
          (* ;; "This looks at all the open windows and computes the tabletop, a list of records containing card, windowregion, shrunken window position, and flag indicating whether window is shrunken.  Only done for those entries in ListOfCards that have open windows.  TOTOPW order is preserved.")
          
          (* ;; "rht 1/21/88: Had to do REVERSE to get the right to-top order.  Wonder whether (OPENWINDOWS) reversed in lyric.")
          
          (* ;; "pmi 2/17/88: Added check for ListOfCards in case user cancels operation.")
          
          (* ;; "pmi 2/19/88: Added TableTopCard and RetainClosedCardsFlg arguments.  If RetainClosedCardsFlg is non-NIL, cards that are closed will be added to the TableTop using their region stored in the notefile.  If RetainClosedCardsFlg is NIL, the user will be asked to confirm deleting closed cards from the TableTop.")

    (RESETLST
     (RESETSAVE (CURSOR WAITINGCURSOR))
     (if (NEQ ListOfCards 'DON'T)
         then
         (LET (TableTopEntryList OpenCardsList)
              [SETQ TableTopEntryList
               (REVERSE (for Win in (OPENWINDOWS) bind Card IconFor IconWin
                           when (AND (SETQ Card (NC.CoerceToCard (OR (SETQ IconFor
                                                                      (WINDOWPROP Win 'ICONFOR))
                                                                     Win)))
                                     (FMEMB Card ListOfCards))
                           collect (push OpenCardsList Card)
                                 (create TableTopEntry
                                        Card ← Card
                                        Region ← (WINDOWPROP (OR IconFor Win)
                                                        'REGION)
                                        ShrunkenWinPos ← (COND
                                                            (IconFor (WINDOWPOSITION Win))
                                                            ([WINDOWP (SETQ IconWin
                                                                       (WINDOWPROP Win 'ICONWINDOW]
                                                             (WINDOWPOSITION IconWin)))
                                        ShrunkenFlg ← (AND IconFor T]
              (if RetainClosedCardsFlg
                  then 
          
          (* ;; "If some of the cards are closed, use their notefile region for the TableTop.")

                       (APPEND TableTopEntryList (for ClosedCard in (LDIFFERENCE ListOfCards 
                                                                           OpenCardsList)
                                                    when (NC.ValidCardP ClosedCard)
                                                    collect (create TableTopEntry
                                                                   Card ← ClosedCard
                                                                   Region ← (NCP.CardRegion 
                                                                                   ClosedCard)
                                                                   ShrunkenFlg ← NIL)))
                else 
          
          (* ;; 
        "If some of the cards are closed, check with the user about deleting them from the TableTop.")

                     (SETQ ClosedCardList (LDIFFERENCE ListOfCards OpenCardsList))
                     (SETQ OldTableTopEntriesWithCards
                      (for TableTopEntry in (NCP.CardSubstance TableTopCard) bind Card
                         when (AND (NCP.ValidCardP (SETQ Card (fetch (TableTopEntry Card)
                                                                 of TableTopEntry)))
                                   (FMEMB Card ClosedCardList)) collect (CONS Card TableTopEntry)))
                     [SETQ AdditionalTableTopEntries
                      (for ClosedCard in ClosedCardList
                         eachtime [SETQ UserAnswer
                                   (AND (NC.ValidCardP ClosedCard)
                                        (RESETLST (RESETSAVE (CURSOR T))
                                               (SELECTQ (NC.AskUserWithMenu
                                                         '(Cancel Keep Remove)
                                                         (MKSTRING (CONCAT 
                                                                        "Do you want to keep card %""
                                                                          (NC.FetchTitle ClosedCard)
                                                                          
                                                "%" at old location or remove it from this TableTop?"
                                                                          ))
                                                         (NCP.CoerceToInterestedWindow TableTopCard))
                                                   (Cancel 'CANCELLED)
                                                   (Keep T)
                                                   (Remove NIL)
                                                   'CANCELLED] when UserAnswer
                         collect (if (EQ UserAnswer 'CANCELLED)
                                     then (RETURN 'CANCELLED)
                                   elseif (SETQ TableTopEntry (CDR (FASSOC ClosedCard 
                                                                          OldTableTopEntriesWithCards
                                                                          )))
                                     then (SETQ CardRegion (fetch (TableTopEntry Region) of 
                                                                                        TableTopEntry
                                                                  ))
                                          (create TableTopEntry
                                                 Card ← ClosedCard
                                                 Region ← (OR CardRegion (NCP.CardRegion ClosedCard))
                                                 ShrunkenFlg ← NIL]
                     (if (EQ AdditionalTableTopEntries 'CANCELLED)
                         then 'CANCELLED
                       else (APPEND TableTopEntryList AdditionalTableTopEntries])

(NCTableTop.OpenCardInTableTop
  [LAMBDA (TableTopCardOrWindow)                             (* ; "Edited 18-Feb-88 15:09 by pmi")

(* ;;; "Open one of the cards in TableTopCard.")
          
          (* ;; 
        " pmi 2/18/88: Added check for non-nil menu items, in case the TableTop card has no entries.")

    (DECLARE (GLOBALVARS NC.MsgDelay))
    (LET ((TableTopCard (NCP.CoerceToCard TableTopCardOrWindow))
          (InterestedWindow (NCP.CoerceToInterestedWindow TableTopCardOrWindow)))
         (NC.ActivateCardAndDo TableTopCard
                (LET ([MenuItems (for TableTopEntry in (NCP.CardSubstance TableTopCard) bind Card
                                    when (NCP.ValidCardP (SETQ Card (fetch (TableTopEntry Card)
                                                                       of TableTopEntry)))
                                    collect `(,(NCP.CardTitle Card) ',TableTopEntry 
                                                    "Open Card having given title."]
                      Menu)
                     (if MenuItems
                         then (SETQ Menu (create MENU
                                                ITEMS ← MenuItems
                                                TITLE ← "Open card in TableTop?"))
                              (NCTableTop.BringUpCardInTableTop (MENU Menu))
                       else (NC.PrintMsg InterestedWindow T "No cards in this TableTop.")
                            (DISMISS NC.MsgDelay)
                            (NC.ClearMsg InterestedWindow T])

(NCTableTop.RemakeTableTopSelectingNewCards
  [LAMBDA (TableTopCardOrWindow InterestedWindow)            (* ; "Edited 19-Feb-88 15:37 by pmi")

(* ;;; "Rebuild the substance of TableTopCard using a new list of cards provided by the user.")
          
          (* ;; "rht 1/23/88: Added InterestedWindow and pass to NCP.SelectCards.")
          
          (* ;; "pmi 2/19/88: Now passes T to NCTableTop.RemakeTableTop as RetainClosedCardsFlg - this allows the user to select new cards from link icons even though they are not up on the screen.")

    (LET ((TableTopCard (NCP.CoerceToCard TableTopCardOrWindow))
          ListOfCards)
         (SETQ ListOfCards (NCP.SelectCards (OR (OPENWP InterestedWindow)
                                                TableTopCard)
                                  NIL
                                  (FUNCTION NCP.ValidCardP)
                                  "Choose new cards for rebuilding table top." T))
         (if (EQ ListOfCards 'CANCELLED)
             then NIL
           else (NCTableTop.RemakeTableTop TableTopCard ListOfCards T])

(NCTableTop.RemakeTableTop
  [LAMBDA (TableTopCardOrWindow ListOfCards RetainClosedCardsFlg)
                                                             (* ; "Edited 19-Feb-88 17:58 by pmi")
          
          (* ;; "Rebuild the substance of TableTopCard using a new list of cards.")
          
          (* ;; "pmi 2/19/88: Added RetainClosedCardsFlg argument to be passed in as T when we know that we want closed cards included in the TableTop.  Also added check for 'CANCELLED.")

    (LET ((TableTopCard (NCP.CoerceToCard TableTopCardOrWindow))
          NewTableTop)
         (OR (NC.ActiveCardP TableTopCard)
             (NCP.CacheCards TableTopCard))
         (if (NEQ (SETQ NewTableTop (NCTableTop.ComputeTableTop ListOfCards TableTopCard 
                                           RetainClosedCardsFlg))
                  'CANCELLED)
             then (NC.SetSubstance TableTopCard NewTableTop)
                  (NC.MarkCardDirty TableTopCard])

(NCTableTop.RecomputeTableTop
  [LAMBDA (TableTopCardOrWindow)                             (* ; "Edited 19-Feb-88 17:59 by pmi")
          
          (* ;; "Reusing the cards in the TableTopCard, recompute the substance based on the card's new shapes, positions, and totopw ordering.")
          
          (* ;; "pmi 2/19/88: Added check for 'CANCELLED.")

    (LET ((TableTopCard (NCP.CoerceToCard TableTopCardOrWindow))
          NewTableTop)
         (OR (NC.ActiveCardP TableTopCard)
             (NCP.CacheCards TableTopCard))
         (if (NEQ (SETQ NewTableTop (NCTableTop.ComputeTableTop
                                     (for TableTopEntry in (NC.FetchSubstance TableTopCard)
                                        bind Card when (NCP.ValidCardP (SETQ Card (fetch (
                                                                                        TableTopEntry
                                                                                          Card)
                                                                                     of TableTopEntry
                                                                                         )))
                                        collect Card)
                                     TableTopCard NIL))
                  'CANCELLED)
             then (NC.SetSubstance TableTopCard NewTableTop)
                  (NC.MarkCardDirty TableTopCard])

(NCTableTop.ComputeTableTop
  [LAMBDA (ListOfCards TableTopCard RetainClosedCardsFlg)    (* ; "Edited 22-Feb-88 15:02 by pmi")
          
          (* ;; "This looks at all the open windows and computes the tabletop, a list of records containing card, windowregion, shrunken window position, and flag indicating whether window is shrunken.  Only done for those entries in ListOfCards that have open windows.  TOTOPW order is preserved.")
          
          (* ;; "rht 1/21/88: Had to do REVERSE to get the right to-top order.  Wonder whether (OPENWINDOWS) reversed in lyric.")
          
          (* ;; "pmi 2/17/88: Added check for ListOfCards in case user cancels operation.")
          
          (* ;; "pmi 2/19/88: Added TableTopCard and RetainClosedCardsFlg arguments.  If RetainClosedCardsFlg is non-NIL, cards that are closed will be added to the TableTop using their region stored in the notefile.  If RetainClosedCardsFlg is NIL, the user will be asked to confirm deleting closed cards from the TableTop.")

    (RESETLST
     (RESETSAVE (CURSOR WAITINGCURSOR))
     (if (NEQ ListOfCards 'DON'T)
         then
         (LET (TableTopEntryList OpenCardsList)
              [SETQ TableTopEntryList
               (REVERSE (for Win in (OPENWINDOWS) bind Card IconFor IconWin
                           when (AND (SETQ Card (NC.CoerceToCard (OR (SETQ IconFor
                                                                      (WINDOWPROP Win 'ICONFOR))
                                                                     Win)))
                                     (FMEMB Card ListOfCards))
                           collect (push OpenCardsList Card)
                                 (create TableTopEntry
                                        Card ← Card
                                        Region ← (WINDOWPROP (OR IconFor Win)
                                                        'REGION)
                                        ShrunkenWinPos ← (COND
                                                            (IconFor (WINDOWPOSITION Win))
                                                            ([WINDOWP (SETQ IconWin
                                                                       (WINDOWPROP Win 'ICONWINDOW]
                                                             (WINDOWPOSITION IconWin)))
                                        ShrunkenFlg ← (AND IconFor T]
              (if RetainClosedCardsFlg
                  then 
          
          (* ;; "If some of the cards are closed, use their notefile region for the TableTop.")

                       (APPEND TableTopEntryList (for ClosedCard in (LDIFFERENCE ListOfCards 
                                                                           OpenCardsList)
                                                    when (NC.ValidCardP ClosedCard)
                                                    collect (create TableTopEntry
                                                                   Card ← ClosedCard
                                                                   Region ← (NCP.CardRegion 
                                                                                   ClosedCard)
                                                                   ShrunkenFlg ← NIL)))
                else 
          
          (* ;; 
        "If some of the cards are closed, check with the user about deleting them from the TableTop.")

                     (SETQ ClosedCardList (LDIFFERENCE ListOfCards OpenCardsList))
                     (SETQ OldTableTopEntriesWithCards
                      (for TableTopEntry in (NCP.CardSubstance TableTopCard) bind Card
                         when (AND (NCP.ValidCardP (SETQ Card (fetch (TableTopEntry Card)
                                                                 of TableTopEntry)))
                                   (FMEMB Card ClosedCardList)) collect (CONS Card TableTopEntry)))
                     [SETQ AdditionalTableTopEntries
                      (for ClosedCard in ClosedCardList
                         eachtime [SETQ UserAnswer
                                   (AND (NC.ValidCardP ClosedCard)
                                        (RESETLST (RESETSAVE (CURSOR T))
                                               (SELECTQ (NC.AskUserWithMenu
                                                         '(Cancel Keep Remove)
                                                         (MKSTRING (CONCAT 
                                                                        "Do you want to keep card %""
                                                                          (NC.FetchTitle ClosedCard)
                                                                          
                                                "%" at old location or remove it from this TableTop?"
                                                                          ))
                                                         (NCP.CoerceToInterestedWindow TableTopCard))
                                                   (Cancel 'CANCELLED)
                                                   (Keep T)
                                                   (Remove NIL)
                                                   'CANCELLED] when UserAnswer
                         collect (if (EQ UserAnswer 'CANCELLED)
                                     then (RETURN 'CANCELLED)
                                   elseif (SETQ TableTopEntry (CDR (FASSOC ClosedCard 
                                                                          OldTableTopEntriesWithCards
                                                                          )))
                                     then (SETQ CardRegion (fetch (TableTopEntry Region) of 
                                                                                        TableTopEntry
                                                                  ))
                                          (create TableTopEntry
                                                 Card ← ClosedCard
                                                 Region ← (OR CardRegion (NCP.CardRegion ClosedCard))
                                                 ShrunkenFlg ← NIL]
                     (if (EQ AdditionalTableTopEntries 'CANCELLED)
                         then 'CANCELLED
                       else (APPEND TableTopEntryList AdditionalTableTopEntries])

(NCTableTop.MakeFn
  [LAMBDA (TableTopCard Title NoDisplayFlg ListOfCards InterestedWindow)
                                                             (* ; "Edited 26-Feb-88 12:37 by pmi")
          
          (* ;; "Create a table top card substance.  If ListOfCards is nil, ask user to select cards.  Substance consists of list of pairs of card uid and screen window region.  Note that OPENWINDOWS is used to get proper TOTOPW ordering or cards.")
          
          (* ;; "rht 1/14/88: Now passes TableTopCard as instigating card to NCP.SelectCards in case NoDisplayFlg is set.")
          
          (* ;; "rht 1/23/88: Incredible kludge: NoDisplayFlg can be a window in which case pass it to NCP.SelectCards.")
          
          (* ;; "pmi 2/19/88: Added TableTopCard and T to call to NCTableTop.ComputeTableTop.  T is the RetainClosedCardsFlg, and indicates that some of ListOfCards may be closed, and should be included in the TableTop.")
          
          (* ;; "pmi 2/26/88: Solved NoDisplayFly kludge by passing in InterestedWindow argument.")

    (LET (Window)
         (if (NOT NoDisplayFlg)
             then (SETQ Window (NC.MakeNewCardWindow TableTopCard (OR Title "Untitled")
                                      NIL NIL))
                  (NCP.SetUpTitleBar Window (NC.RetrieveType TableTopCard))
                  (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn))
           else (SETQ Window InterestedWindow))
         (OR (LISTP ListOfCards)
             (SETQ ListOfCards (NCP.SelectCards (OR (OPENWP Window)
                                                    TableTopCard)
                                      NIL
                                      (FUNCTION NCP.ValidCardP)
                                      "Choose cards for table top." T)))
         (if (EQ ListOfCards 'DON'T)
             then (NC.DeactivateCard TableTopCard)
                  (AND (WINDOWP Window)
                       (CLOSEW Window))
                  NIL
           else (NC.SetSubstance TableTopCard (NCTableTop.ComputeTableTop ListOfCards TableTopCard T)
                       )
                (if NoDisplayFlg
                    then TableTopCard
                  else Window])
)



(* ;; " Changed in NCGUIDEDTOURCARD")

(DEFINEQ

(NCGT.CreateTableTop
  [LAMBDA (Graph Window)                                     (* ; "Edited  8-Mar-88 12:34 by pmi")
          
          (* ;; "Called from grapher ADDNODE fn.  Used to create a new Tabletop card and corresponding browser node.  Note kludge of passing WIndow as NoDisplayFlg argument to NCP.CreateCard.  This allows interaction over creating tabletop to happen using the guided tour window as InterestedWindow.")
          
          (* ;; "pmi 2/18/88: Added check for non-NIL card returned by NCP.CreateCard, in case user cancels out of creating a tabletop card")
          
          (* ;; "pmi 2/26/88: Added InterestedWindow argument to NCP.CreateCard, so kludge to pass it as NoDisplayFlg no longer needed.")

    (LET ((GraphCard (NC.CoerceToCard Window))
          Link GraphNodeID Card)
         (NC.ProtectedCardOperation GraphCard "Create card from browser" Window
                (SETQ Card (NCP.CreateCard 'TableTop (NCP.CardNoteFile GraphCard)
                                  (OR (NC.AskUser "Title of new TableTop card: " NIL "" T Window)
                                      "Untitled")
                                  T NIL NIL NIL Window))
                (if (SETQ Link (AND Card (NC.MakeLink Window NC.BrowserContentsLinkLabel Card 
                                                GraphCard)))
                    then (ALLOW.BUTTON.EVENTS)               (* ; 
                                                             "Create hash array if haven't already.")

                         (NC.GetBrowserHashArray GraphCard Graph)
                         (SETQ GraphNodeID (NC.GetBrowserNodeID GraphCard Card))
                         (NC.MarkCardDirty GraphCard)
                         (NODECREATE GraphNodeID (NC.MakeLinkIcon Link)
                                (CURSORPOSITION NIL Window))
                  else NIL])

(NCGT.MakeGuidedTourCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow)
                                                             (* ; "Edited 26-Feb-88 15:49 by pmi")
          
          (* ;; "Create a new GuidedTour card - basically just wraps a call to NC.MakeBrowserCard.")
          
          (* ;; "pmi 2/26/88: Added InterestedWindow argument which is passed to NC.MakeBrowserCard.  Also checks that NC.MakeBrowserCard doesn't return NIL (as when the user cancels out of selecting TableTop cards).")

    (DECLARE (GLOBALVARS NCGT.GuidedTourLinkType NCGT.ShrunkenIconTemplate))
    (LET ((NoteFile (NCP.CardNoteFile Card))
          CardOrWindow)                                      (* ; 
                                                       "Should only follow forward GuidedTour links.")

         (OR (NCP.ValidLinkTypeP NCGT.GuidedTourLinkType NoteFile)
             (NCP.CreateLinkType NCGT.GuidedTourLinkType NoteFile))
         [SETQ ParamList (if ParamList
                             then (LISTPUT ParamList 'LINKTYPES (LIST NCGT.GuidedTourLinkType))
                           else `(LINKTYPES (,NCGT.GuidedTourLinkType]
                                                             (* ; 
                                              "Forget links legend and link labels in browser specs.")

         (NCP.CardUserDataProp Card 'OmitLinksLegendFlg T)
         (NCP.CardUserDataProp Card 'OmitLinkLabelsFromBrowserSpecsFlg T)
                                                             (* ; "Build a browser card")

         (if (SETQ CardOrWindow (NC.MakeBrowserCard Card Title NoDisplayFlg ParamList 
                                       InterestedWindow))
             then (if (WINDOWP CardOrWindow)
                      then (NCGT.SetUpGraphEditMenus CardOrWindow)
                           (NCGT.AttachOperationsMenu CardOrWindow)
                           (WINDOWADDPROP CardOrWindow 'REPAINTFN (FUNCTION NCGT.GuidedTourRepaintFn)
                                  )
                           (WINDOWPROP CardOrWindow 'ShrunkenIconTemplate NCGT.ShrunkenIconTemplate)
                           (WINDOWADDPROP CardOrWindow 'SHRINKFN (FUNCTION NCGT.GuidedTourShrinkFn))
                           (WINDOWADDPROP CardOrWindow 'EXPANDFN (FUNCTION NCGT.GuidedTourExpandFn)))
                  (NCGT.SetGTState Card (create GTState))
                  CardOrWindow])
)
(PUTPROPS PMIPATCH090 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1741 22582 (NCTableTop.ComputeTableTop 1751 . 8405) (NCTableTop.OpenCardInTableTop 8407
 . 10020) (NCTableTop.RemakeTableTopSelectingNewCards 10022 . 11148) (NCTableTop.RemakeTableTop 11150
 . 12141) (NCTableTop.RecomputeTableTop 12143 . 13627) (NCTableTop.ComputeTableTop 13629 . 20283) (
NCTableTop.MakeFn 20285 . 22580)) (22629 27050 (NCGT.CreateTableTop 22639 . 24554) (
NCGT.MakeGuidedTourCard 24556 . 27048)))))
STOP