home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Developer University / DUProjects / Data / Sources / Content.cpp < prev    next >
Encoding:
Text File  |  1996-04-07  |  2.7 KB  |  107 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 1 $
  2. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //========================================================================================
  5. #include "Data.hpp"
  6.  
  7. #ifndef CONTENT_H
  8. #include "Content.h"
  9. #endif
  10.  
  11. #ifndef PART_H
  12. #include "Part.h"
  13. #endif
  14.  
  15. #ifndef FWUTIL_H
  16. #include "FWUtil.h"
  17. #endif
  18.  
  19. #ifndef PIZZA_H
  20. #include "Pizza.h"            //  CPizza
  21. #endif
  22.  
  23. //========================================================================================
  24. #ifdef FW_BUILD_MAC
  25. #pragma segment Data
  26. #endif
  27.  
  28. //========================================================================================
  29. FW_DEFINE_AUTO(CPizzaCollection)
  30. FW_DEFINE_AUTO(CPizzaCollectionIterator)
  31. FW_DEFINE_AUTO(CDataContent)
  32.  
  33. //----------------------------------------------------------------------------------------
  34. CDataContent::CDataContent(Environment* ev, CDataPart* part)
  35.  :    FW_CContent(ev, part),
  36.     fStringPtr(NULL),
  37.     fBufferPtr(NULL),
  38.     fBufferBytes(0),
  39.     fPart(part),
  40.     fNumPizzas(0),
  41.     fPizzaList(NULL)
  42. {
  43.     fEmbeddedString.ReplaceAll("Embedded string");
  44.     fStringPtr = FW_NEW(FW_CString32, ("String Pointer") );
  45.  
  46.     // init buffer
  47.     fBufferBytes = 1000;
  48.     fBufferPtr = FW_CMemoryManager::AllocateBlock(fBufferBytes);    
  49.  
  50.     fPizzaList = FW_NEW(CPizzaCollection, ());
  51.     FW_END_CONSTRUCTOR
  52. }
  53.  
  54. //----------------------------------------------------------------------------------------
  55. CDataContent::~CDataContent()
  56. {
  57.     FW_START_DESTRUCTOR
  58.     delete fStringPtr;
  59.     FW_CMemoryManager::FreeBlock(fBufferPtr);
  60.     CPizza* pizza = NULL;
  61.     while ((pizza = (CPizza*)fPizzaList->First()) != NULL) {
  62.         fPizzaList->Remove(pizza);
  63.         delete pizza;
  64.         }
  65.     delete fPizzaList;
  66. }
  67.  
  68. //----------------------------------------------------------------------------------------
  69. CPizzaCollection*
  70. CDataContent::MyGetPizzaList()
  71. {
  72.     return fPizzaList;
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. void
  77. CDataContent::MyIncrement(Environment* ev, FW_CPoint& position)
  78. {
  79.     fNumPizzas++;
  80.  
  81.     FW_CPoint halfSize( FW_IntToFixed(15), FW_IntToFixed(15) );
  82.     FW_CRect bounds(position - halfSize, position + halfSize);
  83.  
  84.     CPizza* pizza = new CPizza(bounds);
  85.     fPizzaList->AddLast(pizza);
  86.     fPart->MyInvalidatePresentation(ev, bounds);
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90. void
  91. CDataContent::Externalize(Environment* ev,
  92.                             ODStorageUnit* storageUnit,
  93.                             FW_EStorageKinds storageKind,
  94.                             FW_CCloneInfo* cloneInfo)
  95. {
  96. }
  97.  
  98. //----------------------------------------------------------------------------------------
  99. FW_Boolean 
  100. CDataContent::Internalize(Environment* ev,
  101.                                             ODStorageUnit* storageUnit, 
  102.                                             FW_EStorageKinds storageKind,
  103.                                             FW_CCloneInfo* cloneInfo)
  104. {
  105.     return FALSE;
  106. }
  107.