home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 9.0 KB | 301 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSelect.cpp
- // Release Version: $ ODF 2 $
- //
- // 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
-
- #ifndef FWLNKMGR_H
- #include "FWLnkMgr.h"
- #endif
-
- // ----- OS Layer Includes -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef SLODFSTR_K
- #include "SLODFStr.k"
- #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::AcquireSelectionOutline
- //----------------------------------------------------------------------------------------
- // By default just outline the shape returned by AcquireSelectionShape
-
- ODShape* FW_CSelection::AcquireSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame)
- {
- FW_CAcquiredODShape outline = FW_CopyAndRelease(ev, AcquireSelectionShape(ev, facet, frame));
-
- if (!outline->IsEmpty(ev))
- ::FW_OutlineODShape(ev, outline, FW_kFixedPos1);
-
- return outline.Orphan();
- }
-
- //----------------------------------------------------------------------------------------
- // 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
- {
- FW_ASSERT(fPresentation != NULL);
- return fPresentation->GetPart(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 = AcquireSelectionShape(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::AcquireSelectionShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CSelection::AcquireSelectionShape(Environment* ev,
- ODFacet* facet,
- FW_CFrame* frame)
- {
- FW_UNUSED(frame);
-
- return 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;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::GetSelectionInfoString
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CSelection::GetSelectionInfoString(Environment* ev, FW_CString& infoString)
- {
- FW_UNUSED(ev);
- FW_UNUSED(infoString);
-
- // Override to construct a string describing the selected data.
- // By default return false, meaning we didn't return any information.
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::ShowSelectionInfo
- //----------------------------------------------------------------------------------------
- FW_Handled FW_CSelection::ShowSelectionInfo(Environment* ev)
- {
- FW_UNUSED(ev);
- // Override to put up a dialog with information about the current selection.
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::CanEditSelection
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CSelection::CanEditSelection(Environment* ev, FW_CFrame* frame)
- {
- FW_Boolean result = true; // means OK to edit
-
- //--- Check the selection content to see if it's in a link managed by the part
- FW_CLinkManager* linkMgr = GetPart(ev)->GetLinkManager(ev);
- if (linkMgr) // part supports linking
- {
- FW_Boolean multipleLinks = false;
- FW_CLinkDestination* linkDest = this->GetLinkDestination(ev, multipleLinks);
- if (linkDest) // selection is in a single link destination
- {
- //--- Put up dialog asking user what to do
- result = linkMgr->EditInLinkAlert(ev, linkDest, frame);
- }
- else if (multipleLinks) // selection is in several link destinations
- {
- // Warn user about editing multiple links
- GetPart(ev)->PrivShowErrorAlert(ev, FW_kLinkingStrings, FW_kMultipleLinksMsg);
- result = false;
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSelection::GetLinkDestination
- //----------------------------------------------------------------------------------------
- FW_CLinkDestination* FW_CSelection::GetLinkDestination(Environment* ev, FW_Boolean& multipleLinks)
- {
- FW_UNUSED(ev);
- // Override to check for selected content being part of a link destination.
- // If the selected content is in more than one link destination, set multipleLinks to true
- // and return NULL.
- multipleLinks = false;
- return NULL;
- }
-