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 / Button / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.2 KB  |  139 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Part.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //    Modified by:        M.Boetcher to accept Dropped and Pasted sounds
  8. //
  9. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef PART_H
  14. #include "Part.h"
  15. #endif
  16.  
  17. #ifndef DEFINES_K
  18. #include "Defines.k"
  19. #endif
  20.  
  21. #ifndef SELECT_H
  22. #include "Select.h"
  23. #endif
  24.  
  25. #ifndef CONTENT_H
  26. #include "Content.h"
  27. #endif
  28.  
  29. #ifndef ACTIONS_H
  30. #include "Actions.h"
  31. #endif
  32.  
  33. #ifndef FRAME_H
  34. #include "Frame.h"
  35. #endif
  36.  
  37. #ifndef FWCFMRES_H
  38. #include "FWCFMRes.h"
  39. #endif
  40.  
  41. //========================================================================================
  42. //    Runtime information
  43. //========================================================================================
  44.  
  45. #ifdef FW_BUILD_MAC
  46. #pragma segment odfbutton
  47. #endif
  48.  
  49. //========================================================================================
  50. //    class CButtonPart
  51. //========================================================================================
  52.  
  53. FW_DEFINE_AUTO(CButtonPart)
  54.     
  55. //----------------------------------------------------------------------------------------
  56. //    CButtonPart::CButtonPart
  57. //----------------------------------------------------------------------------------------
  58.  
  59. CButtonPart::CButtonPart(ODPart* odPart) :
  60.     FW_CPart(odPart, FW_gInstance, kPartInfoID)
  61. {
  62.     FW_END_CONSTRUCTOR
  63. }
  64.  
  65. //----------------------------------------------------------------------------------------
  66. //    CButtonPart::~CButtonPart
  67. //----------------------------------------------------------------------------------------
  68.  
  69. CButtonPart::~CButtonPart()
  70. {
  71.     FW_START_DESTRUCTOR
  72. }
  73.  
  74. //----------------------------------------------------------------------------------------
  75. //    CButtonPart::Initialize
  76. //----------------------------------------------------------------------------------------
  77.  
  78. void CButtonPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage)
  79. {
  80.     FW_CPart::Initialize(ev, storageUnit, fromStorage);
  81.     
  82.     // ----- Register our Presentation
  83.     CButtonSelection* selection = FW_NEW(CButtonSelection, (ev, fButtonContent));
  84.     RegisterPresentation(ev, kODFButtonPresentation, TRUE, kButtonView, kButtonView, selection);
  85.     
  86.     // ----- Register our kinds -----
  87.     
  88.     // Sound
  89.     fDataSoundKind = RegisterKind(ev, 'snd ', kODPlatformDataType, FW_kAllStorage, FW_kImport);
  90.     RegisterKind(ev, 'sfil', kODPlatformFileType, FW_kAllStorage, FW_kImport);
  91.     
  92.     // Script
  93.     fDataScriptKind = RegisterKind(ev, 'scpt', kODPlatformDataType, FW_kAllStorage, FW_kImport);
  94.     RegisterKind(ev, 'osas', kODPlatformFileType, FW_kAllStorage, FW_kImport);
  95. }
  96.  
  97. //----------------------------------------------------------------------------------------
  98. //    CButtonPart::NewPartContent
  99. //----------------------------------------------------------------------------------------
  100.  
  101. FW_CContent* CButtonPart::NewPartContent(Environment* ev)
  102. {
  103.     fButtonContent = FW_NEW(CButtonContent, (ev, this));
  104.     return fButtonContent;
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. //    CButtonPart::DoSemanticEvent
  109. //----------------------------------------------------------------------------------------
  110. void CButtonPart::DoSemanticEvent(Environment* ev,
  111.                                 FW_CPart* part,
  112.                                 AEKeyword eventClass,
  113.                                 AEKeyword eventID,
  114.                                 const FW_CAppleEvent& event,
  115.                                 FW_CAppleEvent& reply)
  116. {
  117.     if (eventClass == kODFButtonSuiteID && eventID == kDoItEventID)
  118.     {
  119.         CAction* action = fButtonContent->GetAction();
  120.         if (action)
  121.             action->DoIt();
  122.     }
  123.     else
  124.         FW_MPartScriptable::HandleSemanticEvent(ev, part, eventClass, eventID, event, reply);
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    CButtonPart::NewFrame
  129. //----------------------------------------------------------------------------------------
  130.  
  131. FW_CFrame* CButtonPart::NewFrame(Environment* ev,
  132.                                  ODFrame* frame,
  133.                                  FW_CPresentation* presentation,
  134.                                  FW_Boolean storage)
  135. {
  136. FW_UNUSED(storage);
  137.     return FW_NEW(CButtonFrame, (ev, frame, presentation, this, fButtonContent));
  138. }
  139.