home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / DU Folder / DU Selection FW / Sources / DUListSelection.cpp < prev    next >
Encoding:
Text File  |  1995-10-26  |  4.3 KB  |  167 lines  |  [TEXT/MPS ]

  1. //    Copyright © 1995 Apple Computer, Inc. All rights reserved.
  2. //    Release Version:    $ 1.0d11 $
  3.  
  4. //========================================================================
  5. // --- DU Selection FW ---------------------
  6. #ifndef DULISTSELECTION_H
  7. #include "DUListSelection.h"    // DU_CListSelection
  8. #endif
  9.  
  10. #ifndef DULISTPART_H
  11. #include "DUListPart.h"            // DU_CListPart
  12. #endif
  13.  
  14. #ifndef DUSELECTABLE_H
  15. #include "DUSelectable.h"        // DU_MSelectable
  16. #endif
  17.  
  18. #ifndef DULIST_H
  19. #include "DUList.h"                // DU_CList
  20. #endif
  21.  
  22. // ----- Part Layer -----
  23. #ifndef FWPRESEN_H
  24. #include "FWPresen.h"
  25. #endif
  26.  
  27. // ----- Foundation Layer -----
  28. #ifndef FWSUSINK_H
  29. #include "FWSUSink.h"
  30. #endif
  31.  
  32. #ifndef FWSTREAM_H
  33. #include "FWStream.h"
  34. #endif
  35.  
  36. //========================================================================
  37. #ifdef FW_BUILD_MAC
  38. #pragma segment talker
  39. #endif
  40.  
  41. //========================================================================
  42. DU_CListSelection::DU_CListSelection(Environment* ev, DU_CListPart* thePart)
  43.   :    FW_CSelection(ev, FALSE, FALSE),
  44.     fListPart(thePart),
  45.     fSelectedItemList(NULL),
  46.     fHasSelection(FALSE)
  47. {
  48.     fSelectedItemList = new DU_CList;
  49. }
  50.  
  51. //-------------------------------------------------------------------------
  52. DU_CListSelection::~DU_CListSelection()
  53. {    
  54.     delete fSelectedItemList;
  55. }
  56.  
  57. //-------------------------------------------------------------------------
  58. FW_Boolean 
  59. DU_CListSelection::DoInternalizeSelection(Environment* ev, 
  60.                                             ODStorageUnit* sourceSU,
  61.                                             FW_CCloneInfo* cloneInfo)
  62. {
  63.     FW_UNUSED(cloneInfo);
  64.     FW_Boolean internalized = FALSE;
  65.     return internalized;
  66. }
  67.  
  68. //-------------------------------------------------------------------------
  69. void 
  70. DU_CListSelection::CloseSelection(Environment* ev)
  71. {
  72.     DU_MSelectable* item = NULL;
  73.     while ((item = fSelectedItemList->FirstItem()) != NULL) {
  74.         fSelectedItemList->Remove(item);
  75.         item->Select(FALSE);
  76.         this->GetPresentation(ev)->Invalidate(ev, item->GetBounds());
  77.         }
  78. }
  79.  
  80. //-------------------------------------------------------------------------
  81. FW_Boolean 
  82. DU_CListSelection::ClearSelection(Environment* ev)
  83. {
  84.     DU_MSelectable* item = NULL;
  85.     while ((item = fSelectedItemList->FirstItem()) != NULL) {
  86.         fSelectedItemList->Remove(item);
  87.         fListPart->RemoveItem(ev, item);    // Remove from part
  88.         }
  89.     this->GetPresentation(ev)->Invalidate(ev);
  90.     return TRUE;
  91. }
  92.  
  93. //-------------------------------------------------------------------------
  94. void 
  95. DU_CListSelection::SelectAll(Environment* ev)
  96. {
  97.     DU_CList* list = fListPart->GetItemList();
  98.     DU_CListIterator iter(list);
  99.     DU_MSelectable* item;
  100.     for (item = iter.First(); iter.IsNotComplete(); item = iter.Next()) {
  101.         this->AddItemToSelection(ev, item);
  102.         }
  103. }
  104.  
  105. //-------------------------------------------------------------------------
  106. void
  107. DU_CListSelection::AddItemToPart(Environment* ev, DU_MSelectable* item)
  108. {
  109.     fListPart->AddItem(ev, item);
  110.     this->CloseSelection(ev);
  111.     this->AddItemToSelection(ev, item);
  112. }
  113.  
  114. //-------------------------------------------------------------------------
  115. void
  116. DU_CListSelection::AddItemToSelection(Environment* ev, DU_MSelectable* item)
  117. {
  118.     if ( ! item->IsSelected() ) {
  119.         item->Select(TRUE);
  120.         fSelectedItemList->AddLast(item);
  121.         this->InvalidateItem(ev, item);
  122.     }
  123. }
  124.  
  125. //-------------------------------------------------------------------------
  126. void
  127. DU_CListSelection::RemoveItemFromPart(Environment* ev, DU_MSelectable* item)
  128. {
  129.     this->RemoveItemFromSelection(ev, item);
  130.     fListPart->RemoveItem(ev, item);
  131. }
  132.  
  133. //-------------------------------------------------------------------------
  134. void
  135. DU_CListSelection::RemoveItemFromSelection(Environment* ev, DU_MSelectable* item)
  136. {
  137.     item->Select(FALSE);
  138.     fSelectedItemList->Remove(item);
  139.     this->InvalidateItem(ev, item);
  140. }
  141.  
  142. //-------------------------------------------------------------------------
  143. void
  144. DU_CListSelection::InvalidateItem(Environment* ev, DU_MSelectable* item)
  145. {
  146.     this->GetPresentation(ev)->Invalidate(ev, item->GetBounds());
  147. }
  148.  
  149. //-------------------------------------------------------------------------
  150. FW_Boolean 
  151. DU_CListSelection::IsEmpty(Environment* ev) const
  152. {
  153.     return (fListPart->GetNumItems() == 0);
  154. }
  155.  
  156. //-------------------------------------------------------------------------
  157. void 
  158. DU_CListSelection::DoExternalizeSelection(Environment* ev, 
  159.                                             ODStorageUnit* destinationSU,
  160.                                             FW_CCloneInfo* cloneInfo)
  161. {
  162.     FW_UNUSED(ev);
  163.     FW_UNUSED(destinationSU);
  164.     FW_UNUSED(cloneInfo);
  165. }
  166.  
  167.