home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWSelect.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  6.7 KB  |  235 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWSelect.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWSELECT_H
  13. #include "FWSelect.h"
  14. #endif
  15.  
  16. #ifndef FWCONTNT_H
  17. #include "FWContnt.h"
  18. #endif
  19.  
  20. #ifndef FWUTIL_H
  21. #include "FWUtil.h"
  22. #endif
  23.  
  24. #ifndef FWPRESEN_H
  25. #include "FWPresen.h"
  26. #endif
  27.  
  28. #ifndef FWPART_H
  29. #include "FWPart.h"
  30. #endif
  31.  
  32. #ifndef FWCLNINF_H
  33. #include "FWClnInf.h"
  34. #endif
  35.  
  36. #ifndef FWFRAME_H
  37. #include "FWFrame.h"
  38. #endif
  39.  
  40. #ifndef FWGRUTIL_H
  41. #include "FWGrUtil.h"
  42. #endif
  43.  
  44. // ----- OS Layer Includes -----
  45.  
  46. #ifndef FWODGEOM_H
  47. #include "FWODGeom.h"
  48. #endif
  49.  
  50. #ifndef FWEVENT_H
  51. #include "FWEvent.h"
  52. #endif
  53.  
  54. // ----- OpenDoc Includes -----
  55.  
  56. #ifndef SOM_ODStorageUnit_xh
  57. #include <StorageU.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODSession_xh
  61. #include <ODSessn.xh>
  62. #endif
  63.  
  64. #ifndef SOM_ODShape_xh
  65. #include <Shape.xh>
  66. #endif
  67.  
  68. #ifndef SOM_ODFacet_xh
  69. #include <Facet.xh>
  70. #endif
  71.  
  72. #ifndef SOM_Module_OpenDoc_StdProps_defined
  73. #include <StdProps.xh>
  74. #endif
  75.  
  76. //========================================================================================
  77. // RunTime Info
  78. //========================================================================================
  79.  
  80. #ifdef FW_BUILD_MAC
  81. #pragma segment FWFrameworkSelection
  82. #endif
  83.  
  84. FW_DEFINE_AUTO(FW_CSelection)
  85.  
  86. //========================================================================================
  87. //    class FW_CSelection
  88. //========================================================================================
  89.  
  90. //----------------------------------------------------------------------------------------
  91. //    FW_CSelection::FW_CSelection
  92. //----------------------------------------------------------------------------------------
  93.  
  94. FW_CSelection::FW_CSelection(Environment* ev, FW_Boolean allowLinkSource, FW_Boolean allowLink) :
  95.     fPresentation(NULL),
  96.     fAllowLinkSource(allowLinkSource),
  97.     fAllowLink(allowLink)
  98. {
  99. FW_UNUSED(ev);
  100.     FW_END_CONSTRUCTOR
  101. }
  102.  
  103. //----------------------------------------------------------------------------------------
  104. //    FW_CSelection::~FW_CSelection
  105. //----------------------------------------------------------------------------------------
  106.  
  107. FW_CSelection::~FW_CSelection()
  108. {
  109.     FW_START_DESTRUCTOR
  110. }
  111.  
  112. //----------------------------------------------------------------------------------------
  113. //    FW_CSelection::CreateSelectionOutline
  114. //----------------------------------------------------------------------------------------
  115. // By default just outline the shape returned by CreateSelectionShape
  116.  
  117. ODShape* FW_CSelection::CreateSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame) const
  118. {
  119.     ODShape* outline = CreateSelectionShape(ev, facet, frame);
  120.     
  121.     if (!outline->IsEmpty(ev))
  122.         ::FW_OutlineODShape(ev, outline, FW_kFixedPos1);
  123.     
  124.     return outline;
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    FW_CSelection::IsSelectionLinkable
  129. //----------------------------------------------------------------------------------------
  130.  
  131. FW_Boolean FW_CSelection::IsSelectionLinkable(Environment* ev)
  132. {
  133. FW_UNUSED(ev);
  134.     return fAllowLinkSource;
  135. }
  136.  
  137. //----------------------------------------------------------------------------------------
  138. //    FW_CSelection::GetPart
  139. //----------------------------------------------------------------------------------------
  140.  
  141. FW_CPart* FW_CSelection::GetPart(Environment *ev) const
  142. {
  143.     return GetPresentation(ev)->GetPart(ev);
  144. }
  145.  
  146. //----------------------------------------------------------------------------------------
  147. //    FW_CSelection::GetSession
  148. //----------------------------------------------------------------------------------------
  149.  
  150. ODSession* FW_CSelection::GetSession(Environment *ev) const
  151. {
  152.     return GetPart(ev)->GetSession(ev);
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    FW_CSelection::IsMouseInDraggableItem
  157. //----------------------------------------------------------------------------------------
  158.  
  159. FW_Boolean FW_CSelection::IsMouseInDraggableItem(Environment* ev, 
  160.                                                 FW_CFrame* frame, 
  161.                                                 const FW_CMouseEvent& theMouseEvent, 
  162.                                                 FW_Boolean inBackground)
  163. {
  164. FW_UNUSED(inBackground);
  165.     if (IsEmpty(ev))
  166.         return FALSE;
  167.         
  168.     FW_CAcquiredODShape selectionShape = CreateSelectionShape(ev, 
  169.                                                 theMouseEvent.GetFacet(ev), 
  170.                                                 frame);
  171.     
  172.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  173.     frame->GetContentView(ev)->FrameToViewContent(ev, where);
  174.     
  175.     ODPoint odWhere = where;
  176.     return selectionShape->ContainsPoint(ev, &odWhere);        
  177. }
  178.  
  179. //----------------------------------------------------------------------------------------
  180. //    FW_CSelection::UpdateSelectionOnMouseDown
  181. //----------------------------------------------------------------------------------------
  182.  
  183. void FW_CSelection::UpdateSelectionOnMouseDown(Environment* ev, 
  184.                                             const FW_CMouseEvent& mouseEvent,
  185.                                             ODFacet* embeddedFacet,
  186.                                             FW_Boolean inEmbeddedFrameBorder,
  187.                                             FW_Boolean inBackground)
  188. {
  189. FW_UNUSED(ev);
  190. FW_UNUSED(mouseEvent);
  191. FW_UNUSED(embeddedFacet);
  192. FW_UNUSED(inEmbeddedFrameBorder);
  193. FW_UNUSED(inBackground);
  194.     // Don't do anything
  195. }
  196.  
  197. //----------------------------------------------------------------------------------------
  198. //    FW_CSelection::CreateSelectionShape
  199. //----------------------------------------------------------------------------------------
  200.  
  201. ODShape* FW_CSelection::CreateSelectionShape(Environment* ev,  
  202.                                             ODFacet* facet,  
  203.                                             FW_CFrame* frame) const
  204. {
  205. FW_UNUSED(frame);
  206.     return ::FW_CopyAndRelease(ev, facet->AcquireActiveShape(ev, NULL));
  207. }
  208.  
  209. //----------------------------------------------------------------------------------------
  210. //    FW_CSelection::CanPasteAsLink
  211. //----------------------------------------------------------------------------------------
  212. FW_Boolean FW_CSelection::CanPasteAsLink(Environment* ev, 
  213.                                         ODPasteAsMergeSetting& setting,
  214.                                         ODStorageUnit* su)
  215. {
  216. FW_UNUSED(ev);
  217. FW_UNUSED(su);
  218.     // Return value specifies whether this selection can become a destination link.
  219.     // Also specify default settings for the PasteAs dialog: 
  220.     //    kODPasteAsMergeOnly, kODPasteAsEmbedOnly, kODPasteAsMerge, kODPasteAsEmbed
  221.     setting = kODPasteAsMergeOnly;    // default is no embedding
  222.  
  223.     return fAllowLink;
  224. }
  225.  
  226. //----------------------------------------------------------------------------------------
  227. //    FW_CSelection::DoFindLinkSource
  228. //----------------------------------------------------------------------------------------
  229. FW_CLinkSource* FW_CSelection::DoFindLinkSource(Environment* ev)
  230. {
  231. FW_UNUSED(ev);
  232.     // Override to search for a link source corresponding to this selection
  233.     return NULL;
  234. }
  235.