home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / Lookup 1.0d2 / Sources / CDeleteEntryAction.cp < prev    next >
Encoding:
Text File  |  1995-09-12  |  1.8 KB  |  78 lines  |  [TEXT/CWIE]

  1. /*
  2.     CDeleteEntryAction.cp
  3.     
  4.     Copyright © 1995 Alastair Rankine.
  5.     All Rights Reserved.
  6. */
  7.  
  8. #include "CDeleteEntryAction.h"
  9. #include "CLookupDocument.h"
  10. #include "CEntryList.h"
  11. #include "ResourceIDs.h"
  12.  
  13. #include <UAEGizmos.h>
  14.  
  15. // ------------------------------------------------------------
  16. // CLASS CDeleteEntryAction
  17.  
  18.  
  19. CDeleteEntryAction::CDeleteEntryAction(CLookupDocument & inDocument, UInt16 inRow)
  20.     : LAEAction(STRx_RedoEdit, str_RedoDelete)
  21. {
  22.     const CEntry & theEntry = inDocument.GetEntryAt(inRow);
  23.     
  24.     LAEStream redo(kAECoreSuite, kAEDelete);
  25.     
  26.     //    keyDirectObject - The record to delete
  27.     redo.WriteKey(keyDirectObject);
  28.     redo.WriteSpecifier(&theEntry);
  29.  
  30.     // Close the stream, and assign the AE to the Redo event.
  31.     StAEDescriptor redoEvent;
  32.     redo.Close(&redoEvent.mDesc);
  33.     SetRedoAE(redoEvent.mDesc);
  34.  
  35.     LAEStream undo(kAECoreSuite, kAECreateElement);
  36.  
  37.     //    keyAEObjectClass - Create a CEntry
  38.     undo.WriteKey(keyAEObjectClass);
  39.     undo.WriteTypeDesc(CEntry::kModelID);
  40.  
  41.     undo.WriteKey(keyAEInsertHere);
  42.     undo.OpenRecord(typeInsertionLoc);
  43.     // Is there a record before this one?
  44.     if(!inRow)
  45.     {
  46.         // No, insert at the beginning...
  47.         undo.WriteKey(keyAEObject);
  48.         undo.WriteSpecifier(&inDocument);
  49.         undo.WriteKey(keyAEPosition);
  50.         undo.WriteEnumDesc(kAEBeginning);
  51.     }
  52.     else
  53.     {
  54.         // Yes, insert after it:
  55.         undo.WriteKey(keyAEObject);
  56.         undo.WriteSpecifier(inDocument.GetEntryPtrAt(inRow - 1));
  57.         undo.WriteKey(keyAEPosition);
  58.         undo.WriteEnumDesc(kAEAfter);
  59.     }
  60.     undo.CloseRecord();
  61.  
  62.     //    keyAEPropData - Copy the properties from inEntry
  63.     StAEDescriptor objProps;
  64.     theEntry.GetDifferentAEProperties(sEmptyEntry, objProps.mDesc);
  65.     undo.WriteKeyDesc(keyAEPropData, objProps.mDesc);
  66.  
  67.     // Close the stream, and assign the AE to the Redo event.
  68.     StAEDescriptor undoEvent;
  69.     undo.Close(&undoEvent.mDesc);
  70.     SetUndoAE(undoEvent.mDesc);
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.