home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 3.7 KB | 133 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Content.cpp
- // Release Version: $ ODF 1 $
- //
- // 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 ACTIONS_H
- #include "Actions.h"
- #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)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent destructor
- //----------------------------------------------------------------------------------------
-
- CButtonContent::~CButtonContent()
- {
- delete fAction;
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::Externalize
- //----------------------------------------------------------------------------------------
-
- void CButtonContent::Externalize(Environment* ev,
- ODStorageUnit* destinationSU,
- FW_EStorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- FW_ASSERT(destinationSU->Exists(ev, kODPropContents, GetPart(ev)->GetPartKind(ev), 0));
-
- CAction::WriteToStorage(ev, fAction, destinationSU);
- if (fAction != NULL)
- fAction->Externalize(ev, destinationSU);
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::Internalize
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CButtonContent::Internalize(Environment* ev,
- ODStorageUnit* storage,
- FW_EStorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- FW_Boolean result = FALSE;
-
- CAction* action = NULL;
-
- if (CAction::IsInStorage(ev, storage))
- action = CAction::CreateFromStorage(ev, storage);
- else if (CScriptAction::IsInStorage(ev, storage))
- action = new CScriptAction(ev, storage);
- else if (CSoundAction::IsInStorage(ev, storage))
- action = new CSoundAction(ev, storage);
-
- if (action != NULL)
- {
- delete fAction;
- fAction = action;
- result = TRUE;
- }
-
- if (result && storageKind != FW_kPartStorage)
- GetPart(ev)->Changed(ev);
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::SetAction
- //----------------------------------------------------------------------------------------
-
- void CButtonContent::SetAction(CAction* action)
- {
- if (action != NULL && action != fAction)
- {
- delete fAction;
- fAction = action;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CButtonContent::RemoveAction
- //----------------------------------------------------------------------------------------
-
- CAction* CButtonContent::RemoveAction()
- {
- CAction* action = fAction;
- fAction = NULL;
- return action;
- }
-