home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 27.8 KB | 907 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawFrm.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWVIEW_H
- #include "DrawView.h"
- #endif
-
- #ifndef CLIPCMDS_H
- #include "ClipCmds.h"
- #endif
-
- #ifndef DRAWSEL_H
- #include "DrawSel.h"
- #endif
-
- #ifndef INSRTCMD_H
- #include "InsrtCmd.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef SHPTRAKR_H
- #include "ShpTrakr.h"
- #endif
-
- #ifndef DRAWCMDS_H
- #include "DrawCmds.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef DRWDDCMD_H
- #include "DrwDDCmd.h"
- #endif
-
- #ifndef RULER_H
- #include "Ruler.h"
- #endif
-
- #ifndef DRAWCONT_H
- #include "DrawCont.h"
- #endif
-
- #ifndef PRINTHDL_H
- #include "PrintHdl.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSCROLR_H
- #include "FWScrolr.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef FWFILEOP_H
- #include "FWFileOp.h"
- #endif
-
- #ifndef FWEMBUTL_H
- #include "FWEmbUtl.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawframes
- #endif
-
- FW_DEFINE_AUTO(CDrawFrame)
- FW_DEFINE_CLASS_M1(CDrawFrame, FW_CEmbeddingFrame)
-
- //========================================================================================
- // CDrawFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::CDrawFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- CDrawPart* drawPart,
- FW_ResourceId id) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, drawPart, id),
- FW_MDraggableFrame(ev, this),
- FW_MDroppableFrame(ev, this),
- fDrawPart(drawPart),
- fSelection((CDrawSelection*)GetPresentation(ev)->GetSelection(ev)),
- fHorzRuler(NULL),
- fVertRuler(NULL),
- fGridShown(TRUE),
- fZoomFactor(FW_kFixedPos1),
- fRulersShown(TRUE)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::~CDrawFrame
- //----------------------------------------------------------------------------------------
-
- CDrawFrame::~CDrawFrame()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- // ----- Edit Menu -----
- if (hasMenuFocus)
- {
- menuBar->EnableCommand(ev, kODCommandPaste, HasPropertyOnClipboard(ev, kODPropContents, NULL)); // we don't care about the type
-
- menuBar->EnableAndToggleCommand(ev, cGraphicsGrid, TRUE, fGridShown);
- menuBar->EnableAndToggleCommand(ev, cRulers, TRUE, fRulersShown);
-
- ODTypeToken defaultViewType = GetPresentation(ev)->GetDefaultEmbeddedFrameViewType(ev);
- menuBar->EnableAndCheckCommand(ev, cAsFrame, TRUE, defaultViewType == FW_CPart::gViewAsFrameToken);
- menuBar->EnableAndCheckCommand(ev, cAsLargeIcon, TRUE, defaultViewType == FW_CPart::gViewAsLargeIconToken);
- menuBar->EnableAndCheckCommand(ev, cAsSmallIcon, TRUE, defaultViewType == FW_CPart::gViewAsSmallIconToken);
- menuBar->EnableAndCheckCommand(ev, cAsThumbnail, TRUE, defaultViewType == FW_CPart::gViewAsThumbnailToken);
-
- menuBar->EnableAndCheckCommand(ev, cZoom50, TRUE, fZoomFactor == FW_DoubleToFixed(.5));
- menuBar->EnableAndCheckCommand(ev, cZoom100, TRUE, fZoomFactor == FW_kFixedPos1);
- menuBar->EnableAndCheckCommand(ev, cZoom200, TRUE, fZoomFactor == FW_IntToFixed(2));
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ChangeZoomFactor
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ChangeZoomFactor(Environment* ev, FW_Fixed zoomFactor)
- {
- fHorzRuler->ZoomFactorChanged(ev, zoomFactor);
- fVertRuler->ZoomFactorChanged(ev, zoomFactor);
- fZoomFactor = zoomFactor;
-
- AdjustContentViewSize(ev, FALSE);
-
- FW_ASSERT(GetScroller(ev));
- GetScroller(ev)->ScaleBy(ev, FW_CPoint(zoomFactor, zoomFactor)); // Will invalidate
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean handled = TRUE;
-
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
- switch (commandID)
- {
- case cGraphicsGrid:
- fGridShown = !fGridShown;
- GetContentView(ev)->Invalidate(ev);
- break;
-
- case cRulers:
- fRulersShown = !fRulersShown;
- ToggleRulers(ev, fRulersShown, TRUE);
- break;
-
- case cZoom50:
- if (fZoomFactor != FW_DoubleToFixed(0.5))
- ChangeZoomFactor(ev, FW_DoubleToFixed(0.5));
- break;
- case cZoom100:
- if (fZoomFactor != FW_kFixedPos1)
- ChangeZoomFactor(ev, FW_kFixedPos1);
- break;
- case cZoom200:
- if (fZoomFactor != FW_IntToFixed(2))
- ChangeZoomFactor(ev, FW_IntToFixed(2));
- break;
-
- case cAsFrame:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsFrameToken);
- break;
- case cAsLargeIcon:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsLargeIconToken);
- break;
- case cAsSmallIcon:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsSmallIconToken);
- break;
- case cAsThumbnail:
- GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsThumbnailToken);
- break;
-
- default:
- handled = FALSE;
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* CDrawFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(CDrawClipboardCommand, (ev, commandID, fDrawPart, this, fSelection, FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewInsertCommand
- //----------------------------------------------------------------------------------------
-
- FW_CInsertCommand* CDrawFrame::NewInsertCommand(Environment* ev, const FW_PFileSpecification& fileSpec)
- {
- return FW_NEW(CDrawInsertCommand, (ev, this, fileSpec, fSelection, FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CanAcceptDrop
- //----------------------------------------------------------------------------------------
- // As an embedding frame I can accept anything
-
- ODDragResult CDrawFrame::CanAcceptDrop(Environment *ev, ODDragItemIterator* dragInfo)
- {
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoActivateEvent
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- if (HasSelectionFocus(ev))
- fSelection->RenderAllHandles(ev, this);
- }
-
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustZoomedWindowSize
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustZoomedWindowSize(Environment* ev, FW_CPoint& proposedSize)
- {
- proposedSize = fDrawPart->GetDrawingSize();
- proposedSize.x *= fZoomFactor;
- proposedSize.y *= fZoomFactor;
-
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- if (fRulersShown)
- {
- sbSize.x += kRulerWidth;
- sbSize.y += kRulerWidth;
- }
-
- proposedSize.x += sbSize.x + FW_IntToFixed(3); // I want to leave a little space around
- proposedSize.y += sbSize.y + FW_IntToFixed(3);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustWindowGrowLimits
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustWindowGrowLimits(Environment* ev, FW_CPoint& minSize, FW_CPoint& maxSize)
- {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- if (fRulersShown)
- {
- sbSize.x += kRulerWidth;
- sbSize.y += kRulerWidth;
- }
-
- minSize.x = FW_IntToFixed(72) + sbSize.x;
- minSize.y = FW_IntToFixed(72) + sbSize.y;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GeometryChanged
- //----------------------------------------------------------------------------------------
- // the geometry (clip shape, external or Internal transform) of one of my facet or one of my
- // embedding facet as changed
-
- void CDrawFrame::GeometryChanged(Environment *ev,
- ODFacet* odFacet,
- FW_Boolean clipShapeChanged,
- FW_Boolean externalTransformChanged)
- {
- FW_CEmbeddingFrame::GeometryChanged(ev, odFacet, clipShapeChanged, externalTransformChanged);
-
- if (externalTransformChanged)
- {
- CDrawFacetClipper facetClipper(ev, fDrawPart);
- facetClipper.ClipEmbeddedFacets(ev, this, odFacet, NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (CDrawFrame_CreateEmbeddedFacet);
-
- ODFacet* CDrawFrame::CreateEmbeddedFacet(Environment* ev,
- ODFacet* embeddingFacet,
- FW_MProxy* proxy,
- ODFrame* embeddedFrame,
- ODShape* proposedClipShape)
- {
- FW_CRect embeddedFrameBounds = ((CProxyShape*)proxy)->GetFrameRect(ev);
-
- FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
-
- FW_CHECK_THROW_POINT (CDrawFrame_CreateEmbeddedFacet);
- return embeddingFacet->CreateEmbeddedFacet(ev,
- embeddedFrame,
- proposedClipShape,
- aqExternalTransform,
- NULL, // Canvas
- NULL, // biasCanvas
- NULL, // siblingFacet
- kODFrameInFront);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::PostCreateViewFromStream
- //----------------------------------------------------------------------------------------
- // PostCreateViewFromStream is called after subviews are created from resources.
- // Add code which cannot be handled by current resource types.
-
- void CDrawFrame::PostCreateViewFromStream(Environment* ev)
- {
- fHorzRuler = (CRuler*) FindViewById(ev, kHorzRulerID);
- fVertRuler = (CRuler*) FindViewById(ev, kVertRulerID);
-
- if (!fRulersShown)
- ToggleRulers(ev, FALSE, FALSE);
-
- // WARNING: Make sure that classes created from resources won't be dead-stripped
- FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
- FW_DO_NOT_DEAD_STRIP(FW_CScrollBarScroller);
- FW_DO_NOT_DEAD_STRIP(FW_CScrollBar);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::CreateSubViews
- //----------------------------------------------------------------------------------------
- /** CreateSubViews doesn't need to be implemented if CDrawFrame is created with a
- non-null resource id in CDrawPart::NewFrame.
-
- void CDrawFrame::CreateSubViews(Environment* ev)
- {
- #if 1
- // Load a different set of resources depending on whether this frame is embedded or not
- // because we don't want to create a grow-box and scroll-bars in embedded frames.
- // NOTE: Another solution is to use only 1 set of resources and remove the grow-box
- // and scroll-bars in PostCreateViewFromStream(). See the Container sample.
-
- if (IsRoot(ev))
- CreateSubViewsFromResource(ev, kDrawView);
- else
- CreateSubViewsFromResource(ev, kDrawViewNotRoot);
-
- #else
- // NOTE: This section is not compiled by default (change #if 1 by #if 0 above)
- // It was left in the sample to show how to create views by program
- // instead of using resources.
-
- FW_CRect frameRect = GetBounds(ev);
- FW_CRect contentRect = GetContentRect(ev);
-
- FW_CPoint drawingSize = fDrawPart->GetDrawingSize();
-
- // ----- Create the content view -----
- FW_CRect drawViewBounds(contentRect);
- if (drawViewBounds.Width() > drawingSize.x)
- drawViewBounds.right = drawViewBounds.left + drawingSize.x;
- if (drawViewBounds.Height() > drawingSize.y)
- drawViewBounds.bottom = drawViewBounds.top + drawingSize.y;
-
- CDrawView* contentView = new CDrawView(ev, this, drawViewBounds, drawingSize, fDrawPart);
- contentView->MakeContentView(ev);
-
- // ----- Create scroll bars and grow box in root frame only -----
- FW_CScrollBar* vertSB = NULL;
- FW_CScrollBar* horzSB = NULL;
- if (this->IsRoot(ev))
- {
- // ----- Create the vertical scroll bar
- FW_CRect vertSbRect(contentRect.right, frameRect.top - FW_kFixedPos1,
- frameRect.right + FW_kFixedPos1, contentRect.bottom + FW_kFixedPos1);
- vertSB = FW_NEW(FW_CScrollBar, (ev, this, 0, vertSbRect));
-
- // ----- Create the horizontan scroll bar
- FW_CRect horzSbRect(frameRect.left - FW_kFixedPos1, contentRect.bottom,
- contentRect.right + FW_kFixedPos1, frameRect.bottom + FW_kFixedPos1);
- horzSB = FW_NEW(FW_CScrollBar, (ev, this, 0, horzSbRect));
-
- // ----- Create the GrowBox gadget
- FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, contentRect.BotRight());
- }
-
- // ----- add a scroller to the Frame -----
- FW_CScroller* scroller = FW_NEW(FW_CScrollBarScroller, (ev, this, horzSB, vertSB));
- scroller->SetAutoScrollIncrement(ev, FW_CPoint(FW_IntToFixed(20), FW_IntToFixed(20)));
- scroller->SetAutoScrollInset(ev, FW_IntToFixed(15));
- AdoptScroller(ev, scroller);
-
- // ----- Horizontal ruler
- FW_CRect HorzRulerRect(contentRect.left,
- contentRect.top - kRulerWidth,
- contentRect.left + FW_Minimum(drawingSize.x, contentRect.Width()),
- contentRect.top);
- fHorzRuler = FW_NEW(CRuler, (ev, this, HorzRulerRect, FW_kXscrolling, fZoomFactor));
-
- // Set the content's extent
- fHorzRuler->SetExtent(ev, FW_CPoint(drawingSize.x, kRulerWidth));
- // Change default view binding (ruler's size will be set in AdjustContentViewSize)
- fHorzRuler->SetBindings(ev, FW_kFixedBounds);
-
- // ----- Vertical ruler
- FW_CRect VertRulerRect(contentRect.left - kRulerWidth,
- contentRect.top,
- contentRect.left,
- contentRect.top + FW_Minimum(drawingSize.y, contentRect.Height()));
- fVertRuler = FW_NEW(CRuler, (ev, this, VertRulerRect, FW_kYscrolling, fZoomFactor));
-
- // Set the content's extent
- fVertRuler->SetExtent(ev, FW_CPoint(kRulerWidth, drawingSize.y));
- // Change default view binding (ruler's size will be set in AdjustContentViewSize)
- fVertRuler->SetBindings(ev, FW_kFixedBounds);
-
- if (!fRulersShown)
- {
- fHorzRuler->SetVisible(ev, FALSE);
- fVertRuler->SetVisible(ev, FALSE);
- }
- #endif
- }
- **/
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::GetContentRect
- //----------------------------------------------------------------------------------------
-
- FW_CRect CDrawFrame::GetContentRect(Environment* ev) const
- {
- FW_CRect contentRect = GetBounds(ev);
-
- if (fRulersShown)
- {
- // Make space for rulers
- contentRect.top += kRulerWidth;
- contentRect.left += kRulerWidth;
- }
-
- if (IsRoot(ev))
- {
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
-
- contentRect.bottom -= sbSize.y;
- contentRect.right -= sbSize.x;
- }
-
- return contentRect;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::AdjustContentViewSize
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::AdjustContentViewSize(Environment* ev, FW_Boolean refresh)
- {
- FW_CRect contentRect = GetContentRect(ev);
-
- FW_CPoint drawingSize = fDrawPart->GetDrawingSize();
-
- // ----- I need to take into account the zoom factor -----
- drawingSize.x *= fZoomFactor;
- drawingSize.y *= fZoomFactor;
-
- FW_CPoint drawViewSize(FW_Minimum(drawingSize.x, contentRect.Width()),
- FW_Minimum(drawingSize.y, contentRect.Height()));
-
- FW_CPoint currentSize = GetContentView(ev)->GetSize(ev);
- if (currentSize != drawViewSize)
- {
- fHorzRuler->SetSize(ev, FW_CPoint(drawViewSize.x, kRulerWidth), refresh);
- fVertRuler->SetSize(ev, FW_CPoint(kRulerWidth, drawViewSize.y), refresh);
- GetContentView(ev)->SetSize(ev, drawViewSize, refresh);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CDrawFrame::NewDragCommand(Environment *ev, FW_CFrame* theFrame, const FW_CMouseEvent& theMouseEvent)
- {
- return FW_NEW(CDrawDragCommand, (ev, fDrawPart, theFrame,
- fSelection,
- FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CDrawFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
- return FW_NEW(CDrawDropCommand, (ev, fDrawPart, frame,
- dropInfo, facet, dropPoint,
- FW_kCanUndo));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ToggleRulers
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ToggleRulers(Environment *ev, FW_Boolean visible, FW_Boolean refresh)
- {
- FW_ASSERT(fHorzRuler != NULL && fVertRuler != NULL);
- fHorzRuler->SetVisible(ev, visible);
- fVertRuler->SetVisible(ev, visible);
-
- FW_CRect frameRect = GetContentRect(ev);
-
- GetContentView(ev)->SetLocation(ev, frameRect.TopLeft());
- AdjustContentViewSize(ev, refresh);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- FW_CSuperView* contentView = GetContentView(ev);
- FW_CRect contentRect = GetContentRect(ev);
- FW_CRect contentBounds = contentView->GetBounds(ev);
-
- // The only thing to draw is the top left corner box
- if (fRulersShown)
- {
- FW_CRect box(FW_kFixedNeg1, FW_kFixedNeg1, kRulerWidth, kRulerWidth);
- FW_CRectShape::RenderRect(vc, box, FW_kFill, FW_kWhiteEraseInk);
- FW_CRectShape::RenderRect(vc, box, FW_kFrame);
-
- contentRect.left -= kRulerWidth;
- contentRect.top -= kRulerWidth;
-
- contentBounds.left -= kRulerWidth;
- contentBounds.top -= kRulerWidth;
- }
-
- FW_CAcquiredODShape shape1 = ::FW_NewODShape(ev, contentRect);
- FW_CAcquiredODShape shape2 = ::FW_NewODShape(ev, contentBounds);
- shape1->Subtract(ev, shape2);
- if (!shape1->IsEmpty(ev))
- {
- FW_CRegionShape::RenderRegion(vc, shape1, FW_kFill, FW_kRGBLightGray);
-
- contentBounds.Inset(FW_kFixedNeg1, FW_kFixedNeg1);
- FW_CRectShape::RenderRect(vc, contentBounds, FW_kFrame);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::NewPrintHandler
- //----------------------------------------------------------------------------------------
-
- FW_CPrintHandler* CDrawFrame::NewPrintHandler(Environment* ev)
- {
- return new CDrawPrintHandler(ev, this, fDrawPart->GetDrawContent(), GetPresentation(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::RevealFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- FW_UNUSED(revealShape);
-
- // Look thru shape list for a proxy shape that matches the embeddedFrame
- CDrawContentShapeIterator iter(fDrawPart->GetDrawContent());
- for (CBaseShape* shape = iter.First(); iter.IsNotComplete(); shape = iter.Next())
- {
- if (shape->GetShapeType() == kProxyShape)
- {
- CProxyShape* proxyShape = (CProxyShape*)shape;
- FW_CAcquiredODFrame proxyEmbeddedFrame = proxyShape->AcquireEmbeddedFrame(ev, this);
- if (proxyEmbeddedFrame == embeddedFrame)
- {
- // Select the proxy shape and redraw it
- fSelection->CloseSelection(ev);
- fSelection->AddToSelection(ev, proxyShape, TRUE);
- return TRUE;
- }
- }
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FacetAdded
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CEmbeddingFrame::FacetAdded(ev, facet, facetCount); // Call inherited
-
- // Perform "DoPostCreate"-type initialization here.
- fDrawPart->DoPostCreate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::ExternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::ExternalizeFrame(ev, storageUnitView);
-
- FW_PStorageUnitSink suSink(ev, storageUnitView);
- FW_CWritableStream stream(suSink);
-
- stream << fGridShown;
- stream << fRulersShown;
- stream << fZoomFactor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::InternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CEmbeddingFrame::InternalizeFrame(ev, storageUnitView);
-
- FW_PStorageUnitSink suSink(ev, storageUnitView);
- FW_PBufferedSink sink(ev, suSink);
- FW_CReadableStream stream(sink);
-
- stream >> fGridShown;
- stream >> fRulersShown;
- stream >> fZoomFactor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
-
- void CDrawFrame::FocusStateChanged(Environment *ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
-
- if (focus == FW_CPart::gSelectionFocusToken)
- { // If I am losing the selection focus for a frame other than one of mine then
- // set back the current tool to the selection tool
- if (!this->IsSiblingFrameOf(ev, newOwner))
- fDrawPart->SetTool(ev, kSelectTool);
-
- // • If I get the selection focus I redraw the handles only if the window is not active
- // if the window is active they already have been redrawn by DoActivateEvent
- // • If I am loosing the selection focus I redraw the handles only if the window is active
- // if the window is not active they already have been redrawn by DoActivateEvent
- // The events order is:
- // - Window 1 deactivated
- // - Frame 1 lose selection focus
- // - Frame 2 gain selection focus
- // - Window 2 activated
- FW_Boolean windowActive = GetWindow(ev)->IsActive(ev);
- FW_Boolean hilite = newState ? !windowActive : windowActive;
- if (hilite)
- fSelection->RenderAllHandles(ev, this);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::IsInLinkDestination
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CDrawFrame::IsInLinkDestination(Environment* ev)
- {
- return (this->GetODFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::EmbeddedFrameRequested
- //----------------------------------------------------------------------------------------
-
- FW_MProxy* CDrawFrame::EmbeddedFrameRequested(Environment *ev,
- FW_MProxy* baseProxy,
- ODFrame* baseFrame,
- ODShape* frameShape,
- ODPart* embeddedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODID frameGroupID,
- FW_Boolean isOverlaid,
- FW_Boolean isSubFrame)
- {
-
- FW_CPresentation* myPresentation = GetPresentation(ev);
-
- CProxyShape* baseProxyShape = (CProxyShape*)baseProxy;
- FW_CRect embeddedFrameBounds = baseProxyShape->GetFrameRect(ev);
-
- embeddedFrameBounds.Offset(embeddedFrameBounds.Width(), FW_kFixed0);
-
- CProxyShape* proxy = FW_NEW(CProxyShape, (ev, embeddedFrameBounds, fDrawPart));
-
- FW_CRect tempRect(embeddedFrameBounds);
- tempRect.Place(FW_kFixed0, FW_kFixed0);
- FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, tempRect);
-
- FW_TRY
- {
- myPresentation->Embed(ev,
- embeddedPart,
- NULL,
- kODFrameObject,
- proxy,
- aqFrameShape,
- viewType,
- presentation,
- frameGroupID,
- isOverlaid,
- isSubFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING ()
- {
- delete proxy;
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- // ----- Now I can add it to my data
- fDrawPart->AddShapeToPart(ev, proxy);
-
- // ----- Clip the facets -----
- CDrawFacetClipper facetClipper(ev, fDrawPart);
- FW_CAcquiredODShape limitShape = ::FW_NewODShape(ev, embeddedFrameBounds);
- facetClipper.Clip(ev, myPresentation, limitShape);
-
- return proxy;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMouseDownInEmbeddedFrameBorder
- //----------------------------------------------------------------------------------------
- // Start Dragging an embedded frame using the active border
-
- FW_Boolean CDrawFrame::DoMouseDownInEmbeddedFrameBorder(Environment *ev, const FW_CBorderMouseEvent& theBorderMouseEvent)
- {
- fDrawPart->SetTool(ev, kSelectTool);
-
- Drag(ev, theBorderMouseEvent);
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoMouseDownInEmbeddedFrame
- //----------------------------------------------------------------------------------------
- // Test for double click in a embeddedFrame
-
- FW_Boolean CDrawFrame::DoMouseDownInEmbeddedFrame(Environment* ev,
- const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent)
- {
- FW_Boolean handled = FALSE;
-
- if (theEmbeddedMouseEvent.GetNumberOfClicks(ev) > 1)
- {
- ((FW_CEmbeddingFrame*)GetFrame(ev))->OpenSelection(ev);
- handled = TRUE;
- }
-
- return handled;
- }
-
-