home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Clock / Sources / Content.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  4.0 KB  |  155 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Content.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef CONTENT_H
  11. #include "Content.h"
  12. #endif
  13.  
  14. #ifndef PART_H
  15. #include "Part.h"
  16. #endif
  17.  
  18. #ifndef DEFINES_K
  19. #include "Defines.k"
  20. #endif
  21.  
  22. #ifndef FWKIND_H
  23. #include "FWKind.h"
  24. #endif
  25.  
  26. #ifndef FWUTIL_H
  27. #include "FWUtil.h"
  28. #endif
  29.  
  30. #ifndef FWSUSINK_H
  31. #include "FWSUSink.h"
  32. #endif
  33.  
  34. #ifndef FWSUUTIL_H
  35. #include "FWSUUtil.h"
  36. #endif
  37.  
  38. #ifndef FWRESOUR_H
  39. #include "FWResour.h"
  40. #endif
  41.  
  42. //========================================================================================
  43. // Runtime information
  44. //========================================================================================
  45.  
  46. #ifdef FW_BUILD_MAC
  47. #pragma segment odfclock
  48. #endif
  49.  
  50. //========================================================================================
  51. //    Class CClockContent
  52. //========================================================================================
  53.  
  54. FW_DEFINE_AUTO(CClockContent)
  55.  
  56. //----------------------------------------------------------------------------------------
  57. // CClockContent constructor
  58. //----------------------------------------------------------------------------------------
  59.  
  60. CClockContent::CClockContent(Environment* ev, FW_CPart* part) :
  61.     FW_CContent(ev, part),
  62.     fUseContainerColor(false),
  63.     fHasTickSound(false),
  64.     fHasChimeSound(true)
  65. {
  66.     // ----- Load the face string ("ODF") -----
  67.     FW_PSharedLibraryResourceFile resFile(ev);
  68.     ::FW_LoadStringByID(ev, resFile, kClockFaceStrings, FW_kMultiStringRes, kClockOpenDocString, fFaceString);
  69.     FW_END_CONSTRUCTOR
  70. }
  71.  
  72. //----------------------------------------------------------------------------------------
  73. // CClockContent destructor
  74. //----------------------------------------------------------------------------------------
  75.  
  76. CClockContent::~CClockContent()
  77. {
  78.     FW_START_DESTRUCTOR
  79. }
  80.  
  81. //----------------------------------------------------------------------------------------
  82. // CClockContent::ExternalizeKind
  83. //----------------------------------------------------------------------------------------
  84.  
  85. void CClockContent::ExternalizeKind(Environment* ev,
  86.                                 ODStorageUnit* storageUnit,
  87.                                 FW_CKind* kind,
  88.                                 FW_StorageKinds storageKind,
  89.                                 FW_CPromise* promise,
  90.                                 FW_CCloneInfo* cloneInfo)
  91. {
  92. FW_UNUSED(cloneInfo);
  93. FW_UNUSED(storageKind);
  94. FW_UNUSED(promise);
  95.  
  96.     short hoursOffset;
  97.     
  98.     FW_ASSERT(kind->IsPartKind(ev));
  99.     
  100.     FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, kind->GetType(ev));
  101.     FW_CWritableStream stream(suSink);
  102.  
  103.     FW_Boolean dummyBoolean = FALSE;
  104.     stream << dummyBoolean;
  105.     stream << fUseContainerColor;
  106.  
  107.     stream << fHasTickSound;
  108.     stream << fHasChimeSound;
  109.     
  110.     hoursOffset = fTimeOffset.GetHours();
  111.     stream << hoursOffset;
  112.     stream << fFaceString;
  113.     
  114.     // ----- Clear the end of the value -----
  115.     FW_SUDeleteEndOfFocusedValue(ev, storageUnit);
  116. }
  117.  
  118. //----------------------------------------------------------------------------------------
  119. // CClockContent::InternalizeKind
  120. //----------------------------------------------------------------------------------------
  121.  
  122. FW_Boolean CClockContent::InternalizeKind(Environment* ev,
  123.                                            ODStorageUnit* storageUnit, 
  124.                                         FW_CKind* kind,
  125.                                            FW_StorageKinds storageKind,
  126.                                            FW_CCloneInfo* cloneInfo)
  127. {
  128. FW_UNUSED(cloneInfo);
  129. FW_UNUSED(storageKind);
  130.  
  131.     short hoursOffset;
  132.  
  133.     FW_ASSERT(kind->IsPartKind(ev));
  134.  
  135.     FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, kind->GetType(ev));
  136.     FW_PBufferedSink sink(ev, suSink);
  137.     FW_CReadableStream stream(sink);
  138.  
  139.     FW_Boolean dummyBoolean;
  140.     stream >> dummyBoolean; // may be reused
  141.     stream >> fUseContainerColor;
  142.  
  143.     stream >> fHasTickSound;
  144.     stream >> fHasChimeSound;
  145.  
  146.     stream >> hoursOffset;    // offset, in hours
  147.     stream >> fFaceString;
  148.     // FW_CTimeSpan(long days, short hours, short minutes, short seconds);
  149.     FW_CTimeSpan offset(0, hoursOffset, 0, 0);
  150.     fTimeOffset = offset;
  151.     
  152.     return true;
  153. }
  154.  
  155.