home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Container / Sources / Commands.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  22.2 KB  |  675 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Commands.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Container.hpp"
  11.  
  12. #ifndef COMMANDS_H
  13. #include "Commands.h"
  14. #endif
  15.  
  16. #ifndef DEFINES_K
  17. #include "Defines.k"
  18. #endif
  19.  
  20. #ifndef PART_H
  21. #include "Part.h"
  22. #endif
  23.  
  24. #ifndef CONTENT_H
  25. #include "Content.h"
  26. #endif
  27.  
  28. #ifndef FRAME_H
  29. #include "Frame.h"
  30. #endif
  31.  
  32. #ifndef SELECT_H
  33. #include "Select.h"
  34. #endif
  35.  
  36. #ifndef PROXY_H
  37. #include "Proxy.h"
  38. #endif
  39.  
  40. // ----- FrameWork Includes -----
  41.  
  42. #ifndef FWFRAME_H
  43. #include "FWFrame.h"
  44. #endif
  45.  
  46. #ifndef FWPRESEN_H
  47. #include "FWPresen.h"
  48. #endif
  49.  
  50. #ifndef FWFCTCLP_H
  51. #include "FWFctClp.h"
  52. #endif
  53.  
  54. // ----- OpenDoc Includes -----
  55.  
  56. #ifndef SOM_Module_OpenDoc_Commands_defined
  57. #include <CmdDefs.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODShape_xh
  61. #include <Shape.xh>
  62. #endif
  63.  
  64. #if defined(__MWERKS__) && GENERATING68K
  65. // A hack to work around a bug
  66. #pragma import list somGetGlobalEnvironment
  67. #endif
  68.  
  69. //========================================================================================
  70. // Runtime Information
  71. //========================================================================================
  72.  
  73. #ifdef FW_BUILD_MAC
  74. #pragma segment odfcontainer
  75. #endif
  76.  
  77. FW_DEFINE_AUTO(CClipboardCommand)
  78. FW_DEFINE_AUTO(CDragCommand)
  79. FW_DEFINE_AUTO(CDropCommand)
  80. FW_DEFINE_AUTO(CInsertCommand)
  81. FW_DEFINE_AUTO(CResizeCommand)
  82.  
  83. //========================================================================================
  84. // CClipboardCommand
  85. //========================================================================================
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //    CClipboardCommand constructor
  89. //----------------------------------------------------------------------------------------
  90.  
  91. CClipboardCommand::CClipboardCommand(Environment* ev, 
  92.                                      ODCommandID commandID,
  93.                                      CContainerPart* part, 
  94.                                      CContainerFrame* frame, 
  95.                                      CContainerSelection* selection,
  96.                                      FW_Boolean canUndo) :
  97.     FW_CClipboardCommand(ev, commandID, frame, canUndo),
  98.         fContainerPart(part),
  99.         fContainerSelection(selection),
  100.         fUndoContent(NULL)
  101. {
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. //    CClipboardCommand destructor
  106. //----------------------------------------------------------------------------------------
  107.  
  108. CClipboardCommand::~CClipboardCommand()
  109. {
  110.     delete fUndoContent;
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    CClipboardCommand::SaveUndoState
  115. //----------------------------------------------------------------------------------------
  116. void CClipboardCommand::SaveUndoState(Environment* ev)    // Override
  117. {
  118.     ODCommandID commandID = GetCommandID(ev);
  119.     
  120.     if (commandID == kODCommandCut || commandID == kODCommandClear)
  121.     {
  122.         FW_ASSERT(fUndoContent == NULL);
  123.         fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
  124.     }
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    CClipboardCommand::SaveRedoState
  129. //----------------------------------------------------------------------------------------
  130. void CClipboardCommand::SaveRedoState(Environment* ev)    // Override
  131. {
  132.     if (GetCommandID(ev) == kODCommandPaste)
  133.     {
  134.         FW_ASSERT(fUndoContent == NULL);
  135.         fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
  136.     }    
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    CClipboardCommand::FreeUndoState
  141. //----------------------------------------------------------------------------------------
  142. void CClipboardCommand::FreeUndoState(Environment* ev)    // Override
  143. {
  144.     ODCommandID commandID = GetCommandID(ev);
  145.     
  146.     if (commandID == kODCommandCut || commandID == kODCommandClear)
  147.         fUndoContent->DeleteSavedProxies(ev);
  148. }
  149.  
  150. //----------------------------------------------------------------------------------------
  151. //    CClipboardCommand::FreeRedoState
  152. //----------------------------------------------------------------------------------------
  153. void CClipboardCommand::FreeRedoState(Environment* ev)    // Override
  154. {
  155.     if (GetCommandID(ev) == kODCommandPaste)
  156.         fUndoContent->DeleteSavedProxies(ev);
  157. }
  158.  
  159. //----------------------------------------------------------------------------------------
  160. //    CClipboardCommand::UndoIt
  161. //----------------------------------------------------------------------------------------
  162. void CClipboardCommand::UndoIt(Environment* ev)    // Override
  163. {
  164.     FW_CClipboardCommand::UndoIt(ev);    // call inherited
  165.  
  166.     switch (GetCommandID(ev))
  167.     {
  168.         case kODCommandCut:
  169.         case kODCommandClear:
  170.             fUndoContent->RestoreProxySelection(ev);
  171.             break;
  172.  
  173.         case kODCommandPaste:
  174.             fUndoContent->RemoveProxySelection(ev);
  175.             break;
  176.     }    
  177. }
  178.  
  179. //----------------------------------------------------------------------------------------
  180. //    CClipboardCommand::RedoIt
  181. //----------------------------------------------------------------------------------------
  182. void CClipboardCommand::RedoIt(Environment* ev)    // Override
  183. {
  184.     FW_CClipboardCommand::RedoIt(ev);    // call inherited
  185.  
  186.     switch (GetCommandID(ev))
  187.     {
  188.         case kODCommandCut:
  189.         case kODCommandClear:
  190.             fUndoContent->RemoveProxySelection(ev);
  191.             break;
  192.  
  193.         case kODCommandPaste:
  194.             fUndoContent->RestoreProxySelection(ev);
  195.             break;
  196.     }    
  197. }
  198.  
  199. //----------------------------------------------------------------------------------------
  200. //    CClipboardCommand::PreCommand
  201. //----------------------------------------------------------------------------------------
  202.  
  203. void CClipboardCommand::PreCommand(Environment* ev)
  204. {
  205.     if (GetCommandID(ev) == kODCommandPaste)
  206.         fContainerSelection->CloseSelection(ev);
  207. }
  208.  
  209. //----------------------------------------------------------------------------------------
  210. //    CClipboardCommand::CommandDone
  211. //----------------------------------------------------------------------------------------
  212.  
  213. void CClipboardCommand::CommandDone(Environment* ev)
  214. {
  215.     if (GetCommandID(ev) == kODCommandPaste)
  216.         fContainerSelection->CenterSelection(ev, GetFrame(ev));
  217. }
  218.  
  219. //========================================================================================
  220. // class CDragCommand
  221. //========================================================================================
  222.  
  223. //----------------------------------------------------------------------------------------
  224. //    CDragCommand constructor
  225. //----------------------------------------------------------------------------------------
  226. CDragCommand::CDragCommand(Environment* ev,
  227.                            CContainerPart* part,
  228.                            FW_CFrame* frame,
  229.                            CContainerSelection* selection,
  230.                            FW_Boolean canUndo)
  231.     : FW_CDragCommand(ev, frame, canUndo),
  232.         fContainerPart(part),
  233.         fContainerSelection(selection),
  234.         fDraggedContent(NULL)
  235. {
  236. }
  237.  
  238. //----------------------------------------------------------------------------------------
  239. //    CDragCommand destructor
  240. //----------------------------------------------------------------------------------------
  241.  
  242. CDragCommand::~CDragCommand()
  243. {
  244.     delete fDraggedContent;        // Will call remove all if necessary
  245.     fDraggedContent = NULL;
  246. }
  247.  
  248. //----------------------------------------------------------------------------------------
  249. //    CDragCommand::SaveUndoState
  250. //----------------------------------------------------------------------------------------
  251.  
  252. void CDragCommand::SaveUndoState(Environment* ev)    // Override
  253. {
  254.     FW_ASSERT(fDraggedContent == NULL);    
  255.     fDraggedContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
  256. }
  257.  
  258. //----------------------------------------------------------------------------------------
  259. //    CDragCommand::UndoIt
  260. //----------------------------------------------------------------------------------------
  261.  
  262. void CDragCommand::UndoIt(Environment* ev)    // Override
  263. {
  264.     // ----- Add the dragged proxies back into the part
  265.     CContentProxyIterator ite(fDraggedContent);
  266.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  267.     {
  268.         fContainerPart->AttachProxy(ev, proxy);
  269.     }
  270.  
  271.     // ----- Add the saved proxies to the selection
  272.     fContainerSelection->SelectContent(ev, fDraggedContent);
  273.     
  274.     // ----- Invalidate 
  275.     GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape());
  276. }
  277.  
  278. //----------------------------------------------------------------------------------------
  279. //    CDragCommand::RedoIt
  280. //----------------------------------------------------------------------------------------
  281.  
  282. void CDragCommand::RedoIt(Environment* ev)    // Override
  283. {
  284.     // Select saved proxies
  285.     fContainerSelection->SelectContent(ev, fDraggedContent);
  286.  
  287.     fContainerSelection->ClearSelection(ev); // clear them, again
  288. }
  289.  
  290. //----------------------------------------------------------------------------------------
  291. //    CDragCommand::FreeUndoState
  292. //----------------------------------------------------------------------------------------
  293.  
  294. void CDragCommand::FreeUndoState(Environment* ev)    // Override
  295. {
  296.     // Delete the dragged proxies - they're gone forever
  297.     fDraggedContent->DeleteSavedProxies(ev);
  298. }
  299.  
  300. //========================================================================================
  301. // class CDropCommand
  302. //========================================================================================
  303.  
  304. //----------------------------------------------------------------------------------------
  305. //    CDropCommand constructor
  306. //----------------------------------------------------------------------------------------
  307. CDropCommand::CDropCommand(Environment* ev,
  308.                            CContainerPart* part,
  309.                            FW_CFrame* frame,
  310.                            ODDragItemIterator* dropInfo, 
  311.                            ODFacet* facet, 
  312.                            const FW_CPoint& dropPoint,
  313.                            FW_Boolean canUndo)
  314.     : FW_CDropCommand(ev, frame, dropInfo, facet, dropPoint, canUndo),
  315.         fContainerPart(part),
  316.         fDropDelta(FW_kZeroPoint),
  317.         fDroppedContent(NULL),
  318.         fContainerSelection((CContainerSelection*)frame->GetPresentation(ev)->GetSelection(ev))
  319. {
  320. }
  321.  
  322. //----------------------------------------------------------------------------------------
  323. //    CDropCommand destructor
  324. //----------------------------------------------------------------------------------------
  325.  
  326. CDropCommand::~CDropCommand()
  327. {
  328.     delete fDroppedContent;
  329. }
  330.  
  331. //----------------------------------------------------------------------------------------
  332. //    CDropCommand::DoDrop
  333. //----------------------------------------------------------------------------------------
  334. FW_Boolean CDropCommand::DoDrop(Environment* ev, 
  335.                                 ODStorageUnit* dropSU, 
  336.                                 const FW_CPoint& mouseDownOffset, 
  337.                                 const FW_CPoint& dropPoint,
  338.                                 FW_Boolean isDropMove,
  339.                                 short itemNumber)
  340. {
  341.     if (itemNumber == 1)
  342.         fContainerSelection->CloseSelection(ev);
  343.     
  344.     FW_Boolean result = FW_CDropCommand::DoDrop(ev, dropSU, mouseDownOffset, dropPoint, isDropMove, itemNumber);
  345.     
  346.     if (result)
  347.     {    
  348.         fContainerSelection->CalcCache(ev);
  349.         
  350.         FW_CPoint newPosition(dropPoint.x - mouseDownOffset.x, dropPoint.y - mouseDownOffset.y);
  351.         
  352.         FW_CRect box;
  353.         fContainerSelection->GetDragRect(box);
  354.  
  355.         fContainerSelection->OffsetSelection(ev, newPosition.x - box.left, newPosition.y - box.top);
  356.         
  357.         ODShape* updateShape = fContainerSelection->GetUpdateShape();
  358.         
  359.         // ----- Calculate clip -----
  360.         FW_CFacetClipper facetClipper(ev, fContainerPart);
  361.         facetClipper.Clip(ev, fContainerSelection->GetPresentation(ev), updateShape);    
  362.  
  363.         // ----- Invalidate -----
  364.         GetPresentation(ev)->Invalidate(ev, updateShape);
  365.         
  366.         // ----- If I am not the active part I should not have a selection -----
  367.         if (!fContainerPart->HasSelectionFocus(ev))
  368.             fContainerSelection->CloseSelection(ev);
  369.     }
  370.     
  371.     return result;
  372. }
  373.  
  374. //----------------------------------------------------------------------------------------
  375. //    CDropCommand::DoDroppedInSameFrame
  376. //----------------------------------------------------------------------------------------
  377. FW_Boolean CDropCommand::DoDroppedInSameFrame(Environment* ev, 
  378.                                               ODStorageUnit* dropSU, 
  379.                                               const FW_CPoint& mouseDownOffset,
  380.                                               const FW_CPoint& dropPoint)
  381. {
  382.     FW_UNUSED(dropSU);
  383.     
  384.     FW_CPoint newPosition(dropPoint.x - mouseDownOffset.x, dropPoint.y - mouseDownOffset.y);
  385.             
  386.     FW_CRect box;
  387.     fContainerSelection->GetDragRect(box);
  388.  
  389.     fDropDelta = newPosition - box.TopLeft();
  390.     this->OffsetSelection(ev, fDropDelta);
  391.  
  392.     return TRUE;
  393. }
  394.  
  395. //----------------------------------------------------------------------------------------
  396. //    CDropCommand::SaveRedoState
  397. //----------------------------------------------------------------------------------------
  398.  
  399. void CDropCommand::SaveRedoState(Environment* ev)    // Override
  400. {
  401.     // Save proxies that were just dropped
  402.     FW_ASSERT(fDroppedContent == NULL);
  403.     fDroppedContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
  404. }
  405.  
  406. //----------------------------------------------------------------------------------------
  407. //    CDropCommand::UndoIt
  408. //----------------------------------------------------------------------------------------
  409. void CDropCommand::UndoIt(Environment* ev)    // Override
  410. {
  411.     if (this->IsDragMoveInSameFrame(ev))    // it's a drag-move
  412.     {
  413.         // select dropped proxies and move them back to the original position
  414.         fContainerSelection->SelectContent(ev, fDroppedContent);
  415.         this->OffsetSelection(ev, -fDropDelta);
  416.         fContainerSelection->SelectionChanged(ev);    // need more than this for redraw???
  417.     }
  418.     else
  419.     {
  420.         // select dropped proxies and remove them from the document
  421.         fContainerSelection->SelectContent(ev, fDroppedContent);
  422.         fContainerSelection->ClearSelection(ev);
  423.     }
  424. }
  425.  
  426. //----------------------------------------------------------------------------------------
  427. //    CDropCommand::RedoIt
  428. //----------------------------------------------------------------------------------------
  429. void CDropCommand::RedoIt(Environment* ev)    // Override
  430. {
  431.     if (this->IsDragMoveInSameFrame(ev))    // it's a drag-move
  432.     {
  433.         // select dropped proxies and move them to new position
  434.         fContainerSelection->SelectContent(ev, fDroppedContent);
  435.         this->OffsetSelection(ev, fDropDelta);
  436.     }
  437.     else    // dropped proxies are copies
  438.     {
  439.         // add dropped proxies back into document
  440.         this->RestoreDroppedProxies(ev);
  441.         GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape());
  442.     }
  443.     fContainerSelection->SelectionChanged(ev);
  444. }
  445.  
  446. //----------------------------------------------------------------------------------------
  447. //    CDropCommand::RestoreDroppedProxies
  448. //----------------------------------------------------------------------------------------
  449. void CDropCommand::RestoreDroppedProxies(Environment* ev)
  450. {
  451.     // Add the dropped proxies back into the part
  452.     CContentProxyIterator ite(fDroppedContent);
  453.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  454.     {
  455.         fContainerPart->AttachProxy(ev, proxy);
  456.     }
  457.  
  458.     // Add the saved proxies to the selection
  459.     fContainerSelection->SelectContent(ev, fDroppedContent);
  460. }
  461.  
  462. //----------------------------------------------------------------------------------------
  463. //    CDropCommand::OffsetSelection
  464. //----------------------------------------------------------------------------------------
  465. void CDropCommand::OffsetSelection(Environment* ev, const FW_CPoint& delta)
  466. {
  467.     if (delta != FW_kZeroPoint)
  468.     {
  469.         GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape());
  470.         fContainerSelection->OffsetSelection(ev, delta.x, delta.y);
  471.         GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape());
  472.     }
  473. }
  474.  
  475. //----------------------------------------------------------------------------------------
  476. //    CDropCommand::FreeRedoState
  477. //----------------------------------------------------------------------------------------
  478. void CDropCommand::FreeRedoState(Environment* ev)    // Override
  479. {
  480.     fDroppedContent->DeleteSavedProxies(ev);
  481. }
  482.  
  483. //========================================================================================
  484. // CInsertCommand
  485. //========================================================================================
  486.  
  487. //----------------------------------------------------------------------------------------
  488. //    CInsertCommand constructor
  489. //----------------------------------------------------------------------------------------
  490.  
  491. CInsertCommand::CInsertCommand(Environment* ev, 
  492.                                CContainerFrame* frame, 
  493.                                const FW_PFileSpecification& fileSpec, 
  494.                                CContainerSelection* selection,
  495.                                FW_Boolean canUndo) :
  496.     FW_CInsertCommand(ev, frame, fileSpec, canUndo),
  497.     fUndoContent(NULL),
  498.     fContainerSelection(selection)
  499. {
  500. }
  501.  
  502. //----------------------------------------------------------------------------------------
  503. //    CInsertCommand destructor
  504. //----------------------------------------------------------------------------------------
  505.  
  506. CInsertCommand::~CInsertCommand()
  507. {
  508.     delete fUndoContent;
  509. }
  510.  
  511. //----------------------------------------------------------------------------------------
  512. //    CInsertCommand::PreCommand
  513. //----------------------------------------------------------------------------------------
  514.  
  515. void CInsertCommand::PreCommand(Environment* ev)
  516. {
  517.     fContainerSelection->CloseSelection(ev);
  518. }
  519.  
  520. //----------------------------------------------------------------------------------------
  521. //    CInsertCommand::CommandDone
  522. //----------------------------------------------------------------------------------------
  523.  
  524. void CInsertCommand::CommandDone(Environment* ev)
  525. {
  526.     fContainerSelection->CenterSelection(ev, GetFrame(ev));
  527. }
  528.  
  529. //----------------------------------------------------------------------------------------
  530. //    CInsertCommand::SaveRedoState
  531. //----------------------------------------------------------------------------------------
  532.  
  533. void CInsertCommand::SaveRedoState(Environment* ev)
  534. {
  535.     FW_ASSERT(fUndoContent == NULL);
  536.     fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
  537. }
  538.  
  539. //----------------------------------------------------------------------------------------
  540. //    CInsertCommand::FreeRedoState
  541. //----------------------------------------------------------------------------------------
  542.  
  543. void CInsertCommand::FreeRedoState(Environment* ev)
  544. {
  545.     fUndoContent->DeleteSavedProxies(ev);
  546. }
  547.  
  548. //----------------------------------------------------------------------------------------
  549. //    CInsertCommand::UndoIt
  550. //----------------------------------------------------------------------------------------
  551.  
  552. void CInsertCommand::UndoIt(Environment* ev)
  553. {
  554.     FW_CInsertCommand::UndoIt(ev);
  555.     fUndoContent->RemoveProxySelection(ev);
  556. }
  557.  
  558. //----------------------------------------------------------------------------------------
  559. //    CInsertCommand::RedoIt
  560. //----------------------------------------------------------------------------------------
  561.  
  562. void CInsertCommand::RedoIt(Environment* ev)
  563. {
  564.     FW_CInsertCommand::RedoIt(ev);
  565.     fUndoContent->RestoreProxySelection(ev);
  566. }
  567.  
  568. //========================================================================================
  569. // CResizeCommand
  570. //========================================================================================
  571.  
  572. //----------------------------------------------------------------------------------------
  573. //    CResizeCommand constructor
  574. //----------------------------------------------------------------------------------------
  575. CResizeCommand::CResizeCommand(Environment* ev, 
  576.                                          CContainerPart* part, 
  577.                                          FW_CFrame* frame,
  578.                                          CContainerSelection* selection,
  579.                                          const FW_CRect& srcRect,
  580.                                          const FW_CRect& dstRect) 
  581. :    FW_CCommand(ev, cResizeCommand, frame, FW_kCanUndo),
  582.     fContainerPart(part),
  583.     fContainerSelection(selection),
  584.     fSourceRect(srcRect),
  585.     fDestRect(dstRect),
  586.     fUpdateShape(NULL),
  587.     fChangedContent(NULL)
  588. {
  589.     SetMenuStringsFromResource(ev, kUndoStrings, kUndoResizeMsg, kRedoResizeMsg);
  590.     FW_END_CONSTRUCTOR    
  591. }
  592.  
  593. //----------------------------------------------------------------------------------------
  594. //    CResizeCommand destructor
  595. //----------------------------------------------------------------------------------------
  596. CResizeCommand::~CResizeCommand()
  597. {
  598.     FW_START_DESTRUCTOR
  599.     delete fChangedContent;
  600.     
  601.     if (fUpdateShape)
  602.         fUpdateShape->Release(somGetGlobalEnvironment());
  603.     fUpdateShape = NULL;
  604. }
  605.  
  606. //----------------------------------------------------------------------------------------
  607. //    CResizeCommand::DoIt
  608. //----------------------------------------------------------------------------------------
  609. void CResizeCommand::DoIt(Environment* ev)    // Override
  610. {
  611.     // Copy selected proxy pointers to our content object
  612.     FW_ASSERT(fChangedContent == NULL);
  613.     fChangedContent = FW_NEW(CBaseContent, (ev, fContainerSelection->GetSelectionContent(ev)));
  614.  
  615.     FW_ASSERT(fUpdateShape == NULL);
  616.     fUpdateShape = fChangedContent->CalcUpdateShape(ev);
  617.  
  618.     this->ResizeProxies(ev, fSourceRect, fDestRect);
  619.  
  620.     {
  621.         FW_CAcquiredODShape tempShape = fChangedContent->CalcUpdateShape(ev);
  622.         fUpdateShape->Union(ev, tempShape);
  623.     }
  624.  
  625.     this->Redraw(ev, kODDone);
  626. }
  627.  
  628. //----------------------------------------------------------------------------------------
  629. //    CResizeCommand::UndoIt
  630. //----------------------------------------------------------------------------------------
  631. void CResizeCommand::UndoIt(Environment* ev)    // Override
  632. {
  633.     this->ResizeProxies(ev, fDestRect, fSourceRect);
  634.     this->Redraw(ev, kODUndone);
  635. }
  636.  
  637. //----------------------------------------------------------------------------------------
  638. //    CResizeCommand::RedoIt
  639. //----------------------------------------------------------------------------------------
  640. void CResizeCommand::RedoIt(Environment* ev)    // Override
  641. {
  642.     this->ResizeProxies(ev, fSourceRect, fDestRect);
  643.     this->Redraw(ev, kODRedone);
  644. }
  645.  
  646. //----------------------------------------------------------------------------------------
  647. //    CResizeCommand::ResizeProxies
  648. //----------------------------------------------------------------------------------------
  649. void CResizeCommand::ResizeProxies(Environment* ev, const FW_CRect& srcRect, const FW_CRect& dstRect)
  650. {
  651.     //--- Resize each proxy ---
  652.     CContentProxyIterator it(fChangedContent);
  653.     for (CProxy* proxy = it.First(); it.IsNotComplete(); proxy = it.Next())
  654.     {
  655.         proxy->ResizeProxy(ev, srcRect, dstRect);
  656.     }
  657. }
  658.  
  659. //----------------------------------------------------------------------------------------
  660. //    CResizeCommand::Redraw
  661. //----------------------------------------------------------------------------------------
  662. void CResizeCommand::Redraw(Environment* ev, ODDoneState doneState)
  663. {
  664.     FW_CPresentation* presentation = fContainerPart->GetMainPresentation();
  665.     presentation->Invalidate(ev, fUpdateShape);
  666.     
  667.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  668.     facetClipper.Clip(ev, presentation, fUpdateShape);
  669.  
  670.     // Select the resized proxies
  671.     fContainerSelection->SelectContent(ev, fChangedContent);
  672.     fContainerSelection->SelectionChanged(ev);    // Notify everybody
  673. }
  674.  
  675.