home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 6.7 KB | 235 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSelect.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWCONTNT_H
- #include "FWContnt.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWCLNINF_H
- #include "FWClnInf.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- // ----- OS Layer Includes -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWFrameworkSelection
- #endif
-
- FW_DEFINE_AUTO(FW_CSelection)
-
- //========================================================================================
- // class FW_CSelection
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::FW_CSelection
- //----------------------------------------------------------------------------------------
-
- FW_CSelection::FW_CSelection(Environment* ev, FW_Boolean allowLinkSource, FW_Boolean allowLink) :
- fPresentation(NULL),
- fAllowLinkSource(allowLinkSource),
- fAllowLink(allowLink)
- {
- FW_UNUSED(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::~FW_CSelection
- //----------------------------------------------------------------------------------------
-
- FW_CSelection::~FW_CSelection()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::CreateSelectionOutline
- //----------------------------------------------------------------------------------------
- // By default just outline the shape returned by CreateSelectionShape
-
- ODShape* FW_CSelection::CreateSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame) const
- {
- ODShape* outline = CreateSelectionShape(ev, facet, frame);
-
- if (!outline->IsEmpty(ev))
- ::FW_OutlineODShape(ev, outline, FW_kFixedPos1);
-
- return outline;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::IsSelectionLinkable
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSelection::IsSelectionLinkable(Environment* ev)
- {
- FW_UNUSED(ev);
- return fAllowLinkSource;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::GetPart
- //----------------------------------------------------------------------------------------
-
- FW_CPart* FW_CSelection::GetPart(Environment *ev) const
- {
- return GetPresentation(ev)->GetPart(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::GetSession
- //----------------------------------------------------------------------------------------
-
- ODSession* FW_CSelection::GetSession(Environment *ev) const
- {
- return GetPart(ev)->GetSession(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::IsMouseInDraggableItem
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSelection::IsMouseInDraggableItem(Environment* ev,
- FW_CFrame* frame,
- const FW_CMouseEvent& theMouseEvent,
- FW_Boolean inBackground)
- {
- FW_UNUSED(inBackground);
- if (IsEmpty(ev))
- return FALSE;
-
- FW_CAcquiredODShape selectionShape = CreateSelectionShape(ev,
- theMouseEvent.GetFacet(ev),
- frame);
-
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- frame->GetContentView(ev)->FrameToViewContent(ev, where);
-
- ODPoint odWhere = where;
- return selectionShape->ContainsPoint(ev, &odWhere);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::UpdateSelectionOnMouseDown
- //----------------------------------------------------------------------------------------
-
- void FW_CSelection::UpdateSelectionOnMouseDown(Environment* ev,
- const FW_CMouseEvent& mouseEvent,
- ODFacet* embeddedFacet,
- FW_Boolean inEmbeddedFrameBorder,
- FW_Boolean inBackground)
- {
- FW_UNUSED(ev);
- FW_UNUSED(mouseEvent);
- FW_UNUSED(embeddedFacet);
- FW_UNUSED(inEmbeddedFrameBorder);
- FW_UNUSED(inBackground);
- // Don't do anything
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::CreateSelectionShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CSelection::CreateSelectionShape(Environment* ev,
- ODFacet* facet,
- FW_CFrame* frame) const
- {
- FW_UNUSED(frame);
- return ::FW_CopyAndRelease(ev, facet->AcquireActiveShape(ev, NULL));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::CanPasteAsLink
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CSelection::CanPasteAsLink(Environment* ev,
- ODPasteAsMergeSetting& setting,
- ODStorageUnit* su)
- {
- FW_UNUSED(ev);
- FW_UNUSED(su);
- // Return value specifies whether this selection can become a destination link.
- // Also specify default settings for the PasteAs dialog:
- // kODPasteAsMergeOnly, kODPasteAsEmbedOnly, kODPasteAsMerge, kODPasteAsEmbed
- setting = kODPasteAsMergeOnly; // default is no embedding
-
- return fAllowLink;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::DoFindLinkSource
- //----------------------------------------------------------------------------------------
- FW_CLinkSource* FW_CSelection::DoFindLinkSource(Environment* ev)
- {
- FW_UNUSED(ev);
- // Override to search for a link source corresponding to this selection
- return NULL;
- }
-