home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 5.9 KB | 243 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: HelloPrt.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Hello.hpp"
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESTYP_H
- #include "FWResTyp.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- //========================================================================================
- // Constants and Globals
- //========================================================================================
-
- #define kMainPresentation "ODFExamples:Presentation:ODFHello"
-
- //========================================================================================
- // Runtime info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfhello
- #endif
-
- FW_DEFINE_AUTO(CHelloPart)
-
- //========================================================================================
- // CHelloPart class
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CHelloPart constructor
- //----------------------------------------------------------------------------------------
-
- CHelloPart::CHelloPart(ODPart* odPart) :
- FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPartContent(NULL),
- fPresentation(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart destructor
- //----------------------------------------------------------------------------------------
-
- CHelloPart::~CHelloPart()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CHelloPart::Initialize(Environment* ev)
- {
- FW_CPart::Initialize(ev);
-
- // ----- Register our Presentation
- fPresentation = RegisterPresentation(ev, kMainPresentation, TRUE, FW_NEW(CHelloSelection, (ev, fPartContent)));
-
- // ----- Initialize my menu -----
- GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CHelloPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(fromStorage);
-
- return FW_NEW(CHelloFrame, (ev, odFrame, presentation, fPartContent));
- }
-
- //------------------------------------------------------------------------------
- // CHelloPart::NewPartContent
- //------------------------------------------------------------------------------
-
- FW_CContent* CHelloPart::NewPartContent(Environment* ev)
- {
- fPartContent = FW_NEW(CHelloContent, (ev, this));
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CHelloPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = TRUE;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- switch (id)
- {
- case cFirstCommand:
- case cSecondCommand:
- // Toggle the flag that tells whether to center the string
- fPartContent->CenterText(ev, !fPartContent->IsTextCentered());
- break;
-
- case kODCommandAbout:
- ::FW_About(ev, this, kAbout);
- break;
-
- default:
- menuHandled = FALSE;
- }
-
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CHelloPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- // ----- Set up the Hello menu
- menuBar->EnableAndCheckCommand(ev, cFirstCommand, TRUE, fPartContent->IsTextCentered());
- menuBar->EnableAndCheckCommand(ev, cSecondCommand, TRUE, !fPartContent->IsTextCentered());
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::PartChanged
- //----------------------------------------------------------------------------------------
-
- void CHelloPart::PartChanged(Environment* ev)
- {
- // Mark the document's draft as changed so it can be saved
- this->Changed(ev);
-
- // Mark the display frame as changed, so that containing parts can update links
- fPresentation->ContentUpdated(ev);
-
- // Force all display frames to be redrawn
- fPresentation->Invalidate(ev);
- }
-