home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 6.7 KB | 276 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Part.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Bitmap.hpp"
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWFILEAC_H
- #include "FWFileAc.h"
- #endif
-
- #ifndef SLMixOS_H
- #include "SLMixOS.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWMEMORY_H
- #include "FWMemory.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
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
- #include <Drag.h>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfbitmap
- #endif
-
- //========================================================================================
- // class CBitmapPart
- //========================================================================================
-
- FW_DEFINE_AUTO(CBitmapPart)
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::CBitmapPart
- //----------------------------------------------------------------------------------------
- // CBitmapPart constructor
-
- CBitmapPart::CBitmapPart(ODPart* odPart) :
- FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fBitmapContent(NULL),
- fBitmapPresentation(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::~CBitmapPart
- //----------------------------------------------------------------------------------------
- // CBitmapPart destructor
-
- CBitmapPart::~CBitmapPart()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::Initialize
- //----------------------------------------------------------------------------------------
- // ODF Method
-
- void CBitmapPart::Initialize(Environment* ev)
- {
- // ----- Call first inherited -----
- FW_CPart::Initialize(ev);
-
- // ----- Initialize my menu -----
- GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
-
- // ----- Register our Presentations
- fBitmapPresentation = RegisterPresentation(ev, "Apple:Presentation:ODFBitmap", TRUE, FW_NEW(CBitmapSelection, (ev, this, fBitmapContent)));
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::NewDocumentWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* CBitmapPart::NewDocumentWindow(Environment* ev)
- {
- FW_CRect bitmapRect;
- fBitmapContent->GetBitmap(ev).GetBitmapBounds(bitmapRect); // return in 72 dpi
- #ifdef FW_BUILD_MAC
- // Leave some room for the grow box
- bitmapRect.Inset(FW_IntToFixed(-16), FW_IntToFixed(-16));
- #endif
-
- FW_CRect screenBounds;
- ::FW_GetMainScreenBounds(screenBounds);
- screenBounds.Inset(FW_IntToFixed(3), FW_IntToFixed(3));
-
- return new FW_CWindow(ev,
- this,
- FW_CPart::gViewAsFrameToken,
- fBitmapPresentation,
- bitmapRect.Size(),
- screenBounds.TopLeft(),
- FW_kDocumentWindow);
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::NewPartContent
- //----------------------------------------------------------------------------------------
- // ODF Method
-
- FW_CContent* CBitmapPart::NewPartContent(Environment* ev)
- {
- fBitmapContent = FW_NEW(CBitmapContent, (ev, this));
- return fBitmapContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::DoMenu
- //----------------------------------------------------------------------------------------
- // ODF method
-
- FW_Boolean CBitmapPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean result = TRUE;
-
- if (theMenuEvent.GetCommandID(ev) == kODCommandAbout)
- ::FW_About(ev, this, kAbout);
- else
- result = FALSE;
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::PartChanged
- //----------------------------------------------------------------------------------------
-
- void CBitmapPart::PartChanged(Environment* ev)
- {
- // ----- Mark the document's draft as changed so it can be saved
- this->Changed(ev);
-
- // ----- Mark the display frames as changed, so that containing parts can update links
- fBitmapPresentation->ContentUpdated(ev);
-
- // ----- Force all display frames to be redrawn
- fBitmapPresentation->Invalidate(ev);
-
- // ----- Force thumbnail to be recalculated -----
- fBitmapPresentation->UpdateViewAs(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::NewFrame
- //----------------------------------------------------------------------------------------
- // ODF Method
-
- FW_CFrame* CBitmapPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage)
- {
- FW_UNUSED(fromStorage);
- FW_ASSERT(presentation == fBitmapPresentation);
-
- return FW_NEW(CBitmapFrame, (ev, odFrame, presentation, this, fBitmapContent));
- }
-
- //----------------------------------------------------------------------------------------
- // CBitmapPart::AdjustFramesSize
- //----------------------------------------------------------------------------------------
- // Bitmap Part Method
-
- void CBitmapPart::AdjustFramesSize(Environment* ev)
- {
- FW_CPartFrameIterator ite(ev, this);
- for (CBitmapFrame* frame = (CBitmapFrame*)ite.First(ev); ite.IsNotComplete(ev); frame = (CBitmapFrame*)ite.Next(ev))
- {
- frame->AdjustFrameSize(ev);
- }
- }
-