home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Clock / Sources / Content.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.9 KB  |  147 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Content.cpp
  4. //    Release Version:    $ ODF 2 $
  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.     fHasTickSound(false),
  63.     fHasChimeSound(true)
  64. {
  65.     // ----- Load the face string ("ODF") -----
  66.     FW_PSharedLibraryResourceFile resFile(ev);
  67.     ::FW_LoadStringByID(ev, resFile, kClockFaceStrings, FW_kMultiStringRes, kClockOpenDocString, fFaceString);
  68.     FW_END_CONSTRUCTOR
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. // CClockContent destructor
  73. //----------------------------------------------------------------------------------------
  74.  
  75. CClockContent::~CClockContent()
  76. {
  77.     FW_START_DESTRUCTOR
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. // CClockContent::ExternalizeKind
  82. //----------------------------------------------------------------------------------------
  83.  
  84. void CClockContent::ExternalizeKind(Environment* ev,
  85.                                 ODStorageUnit* storageUnit,
  86.                                 FW_CKind* kind,
  87.                                 FW_StorageKinds storageKind,
  88.                                 FW_CPromise* promise,
  89.                                 FW_CCloneInfo* cloneInfo)
  90. {
  91. FW_UNUSED(cloneInfo);
  92. FW_UNUSED(storageKind);
  93. FW_UNUSED(promise);
  94.  
  95.     short dummy = 0;
  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.     stream << dummy;    // to keep compatibility
  103.     stream << fHasTickSound;
  104.     stream << fHasChimeSound;
  105.  
  106.     hoursOffset = fTimeOffset.GetHours();
  107.     stream << hoursOffset;
  108.     stream << fFaceString;
  109.     
  110.     // ----- Clear the end of the value -----
  111.     FW_SUDeleteEndOfFocusedValue(ev, storageUnit);
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. // CClockContent::InternalizeKind
  116. //----------------------------------------------------------------------------------------
  117.  
  118. FW_Boolean CClockContent::InternalizeKind(Environment* ev,
  119.                                            ODStorageUnit* storageUnit, 
  120.                                         FW_CKind* kind,
  121.                                            FW_StorageKinds storageKind,
  122.                                            FW_CCloneInfo* cloneInfo)
  123. {
  124. FW_UNUSED(cloneInfo);
  125. FW_UNUSED(storageKind);
  126.  
  127.     short dummy, hoursOffset;
  128.  
  129.     FW_ASSERT(kind->IsPartKind(ev));
  130.  
  131.     FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, kind->GetType(ev));
  132.     FW_PBufferedSink sink(ev, suSink);
  133.     FW_CReadableStream stream(sink);
  134.     stream >> dummy;    // to keep compatibility
  135.     stream >> fHasTickSound;
  136.     stream >> fHasChimeSound;
  137.     
  138.     stream >> hoursOffset;    // offset, in hours
  139.     stream >> fFaceString;
  140.     // FW_CTimeSpan(long days, short hours, short minutes, short seconds);
  141.     FW_CTimeSpan offset(0, hoursOffset, 0, 0);
  142.     fTimeOffset = offset;
  143.     
  144.     return true;
  145. }
  146.  
  147.