home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.9 KB | 223 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Content.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: M.Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef ACTIONS_H
- #include "Actions.h"
- #endif
-
- #ifndef FWKIND_H
- #include "FWKind.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWSUUTIL_H
- #include "FWSUUtil.h"
- #endif
-
- #ifndef FWAROPER_H
- #include "FWArOper.h"
- #endif
-
- #ifndef FWNOTIFI_H
- #include "FWNotifi.h"
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfbutton
- #endif
-
- //========================================================================================
- // Class CButtonContent
- //========================================================================================
-
- FW_DEFINE_AUTO(CButtonContent)
-
- //----------------------------------------------------------------------------------------
- // CButtonContent constructor
- //----------------------------------------------------------------------------------------
-
- CButtonContent::CButtonContent(Environment* ev, CButtonPart* part) :
- FW_CContent(ev, part),
- fAction(NULL),
- fPart(part),
- fActionType(0)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent destructor
- //----------------------------------------------------------------------------------------
-
- CButtonContent::~CButtonContent()
- {
- delete fAction;
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::ExternalizeKind
- //----------------------------------------------------------------------------------------
-
- void CButtonContent::ExternalizeKind(Environment* ev,
- ODStorageUnit* destinationSU,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CPromise* promise,
- FW_CCloneInfo* cloneInfo)
- {
- FW_UNUSED(promise);
- FW_UNUSED(storageKind);
- FW_UNUSED(cloneInfo);
- if (kind->IsPartKind(ev))
- {
- FW_PStorageUnitSink sink(ev, destinationSU, kODPropContents, kind->GetType(ev));
- FW_CWritableStream stream(sink);
- stream << fActionType;
- FW_SUDeleteEndOfFocusedValue(ev, destinationSU);
- }
- else if (kind->IsEqual(ev, fPart->fDataSoundKind))
- {
- FW_ASSERT(fAction != NULL);
- FW_ASSERT(fAction->GetActionType() == kSound);
- fAction->Externalize(ev, destinationSU, kind);
- }
- else if (kind->IsEqual(ev, fPart->fDataScriptKind))
- {
- FW_ASSERT(fAction != NULL);
- FW_ASSERT(fAction->GetActionType() == kScript);
- fAction->Externalize(ev, destinationSU, kind);
- }
-
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::InternalizeKind
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CButtonContent::InternalizeKind(Environment* ev,
- ODStorageUnit* storage,
- FW_CKind* kind,
- FW_StorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- FW_UNUSED(storageKind);
- FW_UNUSED(cloneInfo);
-
- CAction* action = NULL;
- short actionType = kNothing;
-
- if (kind->IsPartKind(ev))
- {
- FW_PStorageUnitSink sink(ev, storage, kODPropContents, kind->GetType(ev));
- FW_CReadableStream stream(sink);
- stream >> actionType;
-
- if (actionType == kSound)
- {
- if (storage->Exists(ev, kODPropContents, fPart->fDataSoundKind->GetType(ev), 0))
- action = new CSoundAction(ev, storage, fPart->fDataSoundKind);
- }
- else if (actionType == kScript)
- {
- if (storage->Exists(ev, kODPropContents, fPart->fDataScriptKind->GetType(ev), 0))
- action = new CScriptAction(ev, storage, fPart->fDataScriptKind);
- }
- }
- else if (kind->IsEqual(ev, 'snd ', kODPlatformDataType) || kind->IsEqual(ev, 'sfil', kODPlatformFileType))
- {
- action = new CSoundAction(ev, storage, kind);
- actionType = kSound;
- }
- else if (kind->IsEqual(ev, 'scpt', kODPlatformDataType) || kind->IsEqual(ev, 'osas', kODPlatformFileType))
- {
- action = new CScriptAction(ev, storage, kind);
- actionType = kScript;
- }
- else
- FW_DEBUG_MESSAGE("CButtonContent::InternalizeKind - Unknown type");
-
- ChangeAction(ev, action, actionType);
-
- return true;
- }
-
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::ChangeAction
- //----------------------------------------------------------------------------------------
-
- void CButtonContent::ChangeAction(Environment* ev, CAction* action, short actionType)
- {
- if (action != fAction)
- {
- if (actionType != fActionType)
- {
- if (fActionType == kSound)
- fPart->fDataSoundKind->ChangeImportExport(ev, FW_kImport);
- else if (fActionType == kScript)
- fPart->fDataScriptKind->ChangeImportExport(ev, FW_kImport);
-
- fActionType = actionType;
-
- if (fActionType == kSound)
- fPart->fDataSoundKind->ChangeImportExport(ev, FW_kImportExportEnabled);
- else if (fActionType == kScript)
- fPart->fDataScriptKind->ChangeImportExport(ev, FW_kImportExportEnabled);
- }
-
- delete fAction;
- fAction = action;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::HandleNotification
- //----------------------------------------------------------------------------------------
-
- void CButtonContent::HandleNotification(Environment* ev, const FW_CNotification& notification)
- {
- FW_UNUSED(ev);
-
- if (notification.GetMessage() == FW_kButtonPressedMsg && fAction != NULL)
- {
- // no need to check for the button ID, there is only 1 button in this frame
- fAction->DoIt();
- }
- }
-
-
-