home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-26 | 7.3 KB | 284 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: ODFxPrt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFx.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 "AppleComputer:Presentation:ODFx"
-
- //========================================================================================
- // Runtime info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfx
- #endif
-
- FW_DEFINE_AUTO(CODFxPart)
-
- //========================================================================================
- // CODFxPart class
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CODFxPart constructor
- //----------------------------------------------------------------------------------------
-
- CODFxPart::CODFxPart(ODPart* odPart) :
- FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPartContent(NULL),
- fPresentation(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart destructor
- //----------------------------------------------------------------------------------------
-
- CODFxPart::~CODFxPart()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CODFxPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage)
- {
- FW_CPart::Initialize(ev, storageUnit, fromStorage);
-
- // ----- Register our Presentation
- fPresentation = RegisterPresentation(ev, kMainPresentation, TRUE, FW_NEW(CODFxSelection, (ev, fPartContent)));
-
- // ----- Register our other kinds -----
- RegisterKind(ev, 'PICT', kODPlatformDataType, FW_kDataInterchangeStorage/*FW_kAllStorage*/, FW_kExportEnabled);
- RegisterKind(ev, 'PICT', kODPlatformFileType, FW_kFileStorage, FW_kExportEnabled);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CODFxPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(fromStorage);
-
- return FW_NEW(CODFxFrame, (ev, odFrame, presentation, fPartContent));
- }
-
- //------------------------------------------------------------------------------
- // CODFxPart::NewPartContent
- //------------------------------------------------------------------------------
-
- FW_CContent* CODFxPart::NewPartContent(Environment* ev)
- {
- fPartContent = FW_NEW(CODFxContent, (ev, this));
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Handled CODFxPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Handled menuHandled = FW_kHandled;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- switch (id)
- {
- case c4Colors:
- fPartContent->SetNumColors(ev, CODFxContent::kMinColors);
- break;
-
- case c9Colors:
- fPartContent->SetNumColors(ev, CODFxContent::kMaxColors);
- break;
-
- case cLowRes:
- fPartContent->SetPixPerRow(ev, CODFxContent::kMinPixPerRow);
- break;
-
- case cMedRes:
- fPartContent->SetPixPerRow(ev, CODFxContent::kMidPixPerRow);
- break;
-
- case cHighRes:
- fPartContent->SetPixPerRow(ev, CODFxContent::kMaxPixPerRow);
- break;
-
- case cRotateColors:
- fPartContent->RotateColors(ev);
- break;
-
- case cGridLines:
- fPartContent->SetShowGridLines(ev, ! fPartContent->GetShowGridLines());
- break;
-
- default:
- menuHandled = FW_kNotHandled;
- }
-
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::DoAbout
- //----------------------------------------------------------------------------------------
-
- FW_Handled CODFxPart::DoAbout(Environment* ev)
- {
- ::FW_About(ev, this, kAbout);
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled CODFxPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- if (hasMenuFocus)
- {
- // ----- Set up the ODFx menu
- menuBar->EnableAndCheckCommand(ev, c4Colors, TRUE, fPartContent->GetNumColors() == 4);
- menuBar->EnableAndCheckCommand(ev, c9Colors, TRUE, fPartContent->GetNumColors() == 9);
-
- menuBar->EnableAndCheckCommand(ev, cLowRes, TRUE, fPartContent->GetPixPerRow() == CODFxContent::kMinPixPerRow);
- menuBar->EnableAndCheckCommand(ev, cMedRes, TRUE, fPartContent->GetPixPerRow() == CODFxContent::kMidPixPerRow);
- menuBar->EnableAndCheckCommand(ev, cHighRes, TRUE, fPartContent->GetPixPerRow() == CODFxContent::kMaxPixPerRow);
-
- menuBar->EnableAndCheckCommand(ev, cGridLines, TRUE, fPartContent->GetShowGridLines());
-
- menuBar->EnableCommand(ev, cRotateColors, TRUE);
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxPart::PartChanged
- //----------------------------------------------------------------------------------------
-
- void CODFxPart::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);
- }
-