home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmodf.zip / CNTNRPRT.ZIP / CNTNRPRT.CPP < prev    next >
C/C++ Source or Header  |  1995-04-13  |  216KB  |  5,357 lines

  1. /* 
  2.  *      File:           CntnrPrt.cpp //(rlt 3-8-95)
  3.  *
  4.  *   Contains:  IDL description of Container Part
  5.  *
  6.  *   Written by:        Jason Crawford
  7.  *
  8.  *
  9.  *   Change History (most recent first):
  10.  *      
  11.  *        <7>    3/07/95   rlt       Added Frame->Invalidate after UsedShapeChanged
  12.  *        <6>    2/24/95   rlt       Enabled "grid" toggle
  13.  *        <5>    2/22/95   rlt       Enabled "View As" thumbnail
  14.  *        <4>   12/08/94   rlt       Changed su->focus to use property/value instead of
  15.  *                                        using index     
  16.  *        <3>   11/05/94   ced      Modifications required because root facet
  17.  *                                  external transform now scales from OpenDoc
  18.  *                                  72 dpi coordinate space to device coordinate
  19.  *                                  space.  Changes are labed with (CED - 110594).
  20.  *        <2>   10/7/94    ced      Added example code for using mouse focus
  21.  *                                  to draw rubber-band tracking rectangle.
  22.  *       <1>      7/6/94        jlc             first checked in
  23.  *
  24.  *
  25.  */
  26.  
  27. /*
  28.  *  This file was generated by the SOM Compiler.
  29.  *  Generated using:
  30.  *     SOM incremental update: 2.38
  31.  */
  32.  
  33.  
  34. #ifndef SOM_Module_cntnrprt_Source
  35. #define SOM_Module_cntnrprt_Source
  36. #endif
  37. #define ContainerPart_Class_Source
  38. #define VARIABLE_MACROS
  39.  
  40. #define INCL_DOSMODULEMGR
  41. #define INCL_DOSRESOURCES
  42. #define INCL_GPIBITMAPS
  43. #define INCL_GPICONTROL
  44. #define INCL_GPIPRIMITIVES
  45. #define INCL_GPIREGIONS
  46. #define INCL_GPITRANSFORMS
  47. #define INCL_WINACCELERATORS
  48. #define INCL_WINFRAMEMGR
  49. #define INCL_WININPUT
  50. #define INCL_WINMENUS
  51. #define INCL_WINMESSAGEMGR
  52. #define INCL_WINPOINTERS
  53. #define INCL_WINSTDDRAG
  54. #define INCL_WINTRACKRECT
  55. #define INCL_WINWINDOWMGR
  56. #define INCL_DEV
  57.  
  58. #define INCL_ODARBITRATOR
  59. #define INCL_ODCANVAS
  60. #define INCL_ODDRAGANDDROP
  61. #define INCL_ODDRAFT
  62. #define INCL_ODERRORS
  63. #define INCL_ODFACET
  64. #define INCL_ODFOCUSSET
  65. #define INCL_ODFRAME
  66. #define INCL_ODMENUBAR
  67. #define INCL_ODSESSION
  68. //#define INCL_ODSEMANTICINTERFACE
  69. #define INCL_ODSHAPE
  70. #define INCL_ODSTORAGEUNIT
  71. #define INCL_ODSTORAGEUNITVIEW
  72. #define INCL_ODTRANSFORM
  73. #define INCL_ODUNDO
  74. #define INCL_ODWINDOW
  75. #define INCL_ODWINDOWSTATE
  76. #include <os2.h>
  77.  
  78. #include <CNNotebk.xh>
  79. #include "cntnrprt.xih"
  80.  
  81. #ifndef SOM_XEmbeddedFramesIterator_xh
  82.    #include <XFrmIter.xh>
  83. #endif
  84.  
  85. #ifndef _ORDCOLL_
  86. #include "OrdColl.h"
  87. #endif
  88.  
  89. #ifndef SOM_ODActiveFrameMenuBar_xh
  90.    #include <menubact.xh>
  91. #endif
  92.  
  93. #ifndef SOM_ODSelectedContainerPartExtension_xh
  94.    #include <cntnrspe.xh>
  95. #endif
  96.  
  97. #ifndef SOM_ODContainerRootFrameMenuBar_xh
  98.    #include <CntnrRMB.xh>
  99. #endif
  100.  
  101. #ifndef SOM_ODPopupContainerMenu_xh
  102.    #include <CntnrPUM.xh>
  103. #endif
  104.  
  105. #define USE_PARTINFO_TO_RECALL_AMENU
  106. // we stash the menubar in the part info, because the AdjustMenus()
  107. //    method doesn't receive a menubar parameter.  We may not need
  108. //    to do this since AdjustMenus does receive a frame parameter 
  109. //    which can be mapped to a window and for which we can call
  110. //    GetMenuBar().  The menubar returned should be our menu.  Anyway,
  111. //    for now I'll stick to using the partinfo since I know that works.
  112. //    
  113.  
  114.  
  115. #include "debug.hpp"
  116. #include "cntnrprt.h"
  117. #include "common.hpp"
  118.  
  119. // I use THISDLL to designate the name of my own DLL for the
  120. //    sake of loading resources.  Code could be added to determine
  121. //    the name of the DLL at runtime, but this is quicker to code up.
  122. //    Maybe later, I'll code up a TermInit routine to determine the 
  123. //    dll name.  (jlc 94-12-06)
  124. //#define THISDLL "cntnrprt.dll"
  125. #define THISDLL "cntnrprt"
  126.  
  127. #define UNDONEEDSFIXINMAYBE
  128.  
  129. #if 1
  130.    // we may want to make PartInfoRec public and declare it in its
  131.    // own IDL file.   I'll wait until after the port before attempting
  132.    // that. (jlc 94-8)
  133.    class PartInfoRec
  134.    {
  135.    public:
  136.       PartInfoRec() { fIsActive = kODFalse; fNeedsActivating = kODFalse; mbActive = kODNULL; }
  137.       virtual ~PartInfoRec() { }
  138.       RGBColor bgColor;
  139.       ODBoolean  fGridOn;  // Is the grid on? //(rlt 3-8-95)
  140.       ODBoolean  fIsActive;  // Does this frame have its focus set?
  141.       ODBoolean  fNeedsActivating; // should this be activated when its window is activated?
  142.       ODActiveFrameMenuBar * mbActive;
  143.    };
  144. #endif
  145.  
  146. // SetBGColorRec is used for Undo/Redo.
  147. struct SetBGColorRec
  148. {
  149.   SetBGColorRec(RGBColor oldColor, RGBColor newColor, ODFrame* frame)
  150.           {_fOldColor = oldColor; _fNewColor = newColor;
  151.             _fFrame = frame;}
  152.   RGBColor   _fOldColor;
  153.   RGBColor   _fNewColor;
  154.   ODFrame*  _fFrame;
  155. };
  156.  
  157.  
  158. #ifndef _CNTNRRES_
  159.    #include "cntnrres.h"
  160. #endif
  161. #include "print.h"
  162.  
  163. #if 1
  164.    // temporary stuff to get things compiling
  165.    #define GetQDRegion GetRegion
  166.    ODIText * PStrToIntl( const char * str, ODIText ** result ) { NOTDONE2("PStrToIntl"); return 0;}
  167.    const ODCommandID cODMaxEmbedParts = 25;
  168.    const long        cODMaxEmbedPartString = 200;
  169.    char partStrings[cODMaxEmbedParts][cODMaxEmbedPartString];
  170. #endif
  171. //+(rlt 3-8-95)
  172. const int YGRID = 32;
  173. const int XGRID = 32;
  174. static int defcolor = 1;
  175. //-
  176. const short kODBorderWidth = 5;
  177. const short kODHandleLenMultiplier = 3;
  178.  
  179. static const ODPropertyName  kPropFrameInfo = "ContainerPart:Property:FrameInfo";
  180. static const ODPropertyName  kPropMouseDownOffset = "ContainerPart:Property:MouseDownOffset";
  181.  
  182. // todo: The following entry almost certainly needs to be placed in a public location
  183. static const ODValueType    kOS2POINTL = "Bento:OS2:IBM:POINTL";
  184.  
  185. const ODType   kContainerPartPresNormal  = "ContainerPart:Presentation:Normal";
  186. #define kKindTestContainer "IBM:Kind:TestContainer"
  187.  
  188. struct Proxy {
  189. /*
  190.  * We no longer use proxy regions associated with frame because now that the
  191.  * root facet external transform scales from OpenDoc's 72 dpi coordinate
  192.  * space to device coordinates, we can no longer simply offset a region in
  193.  * frame coordinates when we need to use it.  Since a region can be obtained
  194.  * from a frame shape by transforming the frame shape using the facet's content
  195.  * transform, it would be more appropriate to maintain the region in the facet's
  196.  * part info, however, since we were only using the proxy region for creating the
  197.  * proxy selection border, we'll just do away with the proxy region and transform
  198.  * the frame shape when we need to.  (CED - 110594)
  199.  *
  200.  * HRGN region;
  201.  */
  202.    ODFrame* frame;
  203.    ODTransform* transform;
  204. // Proxy(HRGN r, ODFrame* f, ODTransform* t) {region = r; frame = f; transform = t; }
  205.    Proxy(ODFrame* f, ODTransform* t) {frame = f; transform = t; }
  206. };
  207.  
  208.  
  209. // stuff for the Embed menu (94-09-12 jlc)
  210. #include <stdio.h>
  211. ODMenuBar *    mbPartHandlers = 0;
  212.  
  213.  
  214. #if 1
  215.    // the following compile well enough, so I'm commenting them out
  216.    //  to save compile time and avoid the distraction of the remaining
  217.    //  warnings.
  218.  
  219.    SOM_Scope ODSemanticInterface*  SOMLINK ContainerPartGetSemanticInterface(ContainerPart *somSelf,
  220.                                                                               Environment *ev)
  221.    {
  222.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  223.        ContainerPartMethodDebug("ContainerPart","ContainerPartGetSemanticInterface");
  224.  
  225.        NOTDONE2("GetSemanticInterface");
  226.        /* Return statement to be customized: */
  227.        { ODSemanticInterface* retVal;  return (retVal); }
  228.    }
  229.  
  230.    SOM_Scope Proxy*  SOMLINK ContainerPartProxyFromFrame(ContainerPart *somSelf,
  231.                                               Environment *ev, ODFrame *frame)
  232.    {
  233.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  234.        ContainerPartMethodDebug("ContainerPart","ContainerPartProxyFromFrame");
  235.  
  236.        if (_fEmbeddedFrames->Contains(frame))
  237.        {
  238.          Proxy* p;
  239.          ODxOrderedCollectionIterator i(_fContents);
  240.          for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  241.            if (p->frame == frame) return p;
  242.          return kODNULL;
  243.        }
  244.        else
  245.          THROW(kODErrInvalidFrame);
  246.  
  247.        return kODNULL;
  248.    }
  249.  
  250.    SOM_Scope Proxy*  SOMLINK ContainerPartProxyForFrame(ContainerPart *somSelf,
  251.                                                          Environment *ev,
  252.                                                         ODFrame* frame)
  253.    {
  254.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  255.        ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrame");
  256.  
  257.        if (_fEmbeddedFrames->Contains(frame))
  258.        {
  259.          Proxy* p;
  260.          ODxOrderedCollectionIterator i(_fContents);
  261.          for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  262.            if (p->frame == frame) return p;
  263.          return kODNULL;
  264.        }
  265.        else
  266.          THROW(kODErrInvalidFrame);
  267.  
  268.        return kODNULL;
  269.    }
  270. #if 0
  271. /*
  272.  * We are no longer using proxy regions associated with frame partinfo because
  273.  * frame does not contain the info we need to transform a shape to device
  274.  * coords so we can get a region.  This info is contained in the facet's
  275.  * content (or window frame) transform.  Therefor, if we still wanted to use
  276.  * a proxy region, we would associate it with the facet partinfo instead of
  277.  * frame partinfo. (CED - 110594)
  278.  */
  279.    SOM_Scope void  SOMLINK ContainerPartUpdateProxyRegion(ContainerPart *somSelf,
  280.                                                            Environment *ev,
  281.                                                           Proxy* proxy)
  282.    {
  283.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  284.        ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateProxyRegion");
  285.  
  286.        ODShape* scratch = new ODShape();
  287.        scratch->CopyFrom(ev, proxy->frame->GetFrameShape(ev));
  288.        scratch->Transform(ev, proxy->transform);
  289.        HRGN scratchRgn = scratch->GetRegion(ev);
  290.        GpiCombineRegion( _hpsMem, proxy->region, scratchRgn, 0, CRGN_COPY );
  291.        delete scratch;
  292.    }
  293. #endif
  294.    SOM_Scope void  SOMLINK ContainerPartCreateProxySelectionBorder(ContainerPart *somSelf,
  295.                                                                     Environment *ev,
  296.                                            /* (CED - 110594) */    ODFacet* facet,
  297.                                                                    Proxy* p)
  298.    {
  299.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  300.        ContainerPartMethodDebug("ContainerPart","ContainerPartCreateProxySelectionBorder");
  301.  
  302.        RECTL arcl[4], borderRect;
  303.        HRGN tempRgn = GpiCreateRegion(_hpsMem, 0, NULL);
  304.  
  305.        // -- selection border region --
  306. #if 1
  307. /*
  308.  * Get region rectangle by transforming points of frame rectangle using the
  309.  * content transform for the proxy (our facet content transform combined with the
  310.  * proxy frame's external transform).  Don't forget to increment the top right
  311.  * coner because region rectangles are inclusive/exclusive. (CED - 110594)
  312.  */
  313.        ODRect boundingBox;
  314.        ODTransform* transform = p->transform->Copy(ev);
  315.        transform->PostCompose(ev, facet->GetContentTransform(ev));
  316.        p->frame->GetFrameShape(ev)->GetBoundingBox(ev, &boundingBox);
  317.        ODPoint botLeft = {boundingBox.left, boundingBox.bottom};
  318.        ODPoint topRight = {boundingBox.right, boundingBox.top};
  319.        arcl[0] = ODRECTL(transform->TransformPoint(ev, &botLeft),
  320.                          transform->TransformPoint(ev, &topRight));
  321.        delete transform;
  322. #else
  323.        GpiQueryRegionBox(_hpsMem, p->region, arcl);
  324. #endif
  325.        GpiSetRegion(_hpsMem, tempRgn, 1, arcl);
  326.        arcl[1] = arcl[0];
  327.        InflateRect(&arcl[1],kODBorderWidth, kODBorderWidth);
  328.        GpiSetRegion(_hpsMem, _fSelectRgn, 1, &arcl[1]);
  329.        GpiCombineRegion(_hpsMem, _fSelectRgn, _fSelectRgn, tempRgn, CRGN_XOR);
  330.  
  331.        GpiQueryRegionBox(_hpsMem, _fSelectRgn, &borderRect);
  332.  
  333.        // -- corner region --
  334.  
  335.        LONG handleWidth = (kODHandleLenMultiplier * kODBorderWidth);
  336.        arcl[1] = arcl[0] = borderRect;
  337.        arcl[0].xLeft += handleWidth;
  338.        arcl[0].xRight -= handleWidth;
  339.        arcl[1].yBottom +=  handleWidth;
  340.        arcl[1].yTop -=  handleWidth;
  341.        GpiCombineRegion(_hpsMem, _fCornerHandleRgn, _fSelectRgn, 0, CRGN_COPY);
  342.        GpiSetRegion(_hpsMem, tempRgn, 2, arcl);
  343.        GpiCombineRegion(_hpsMem, _fCornerHandleRgn, _fCornerHandleRgn, tempRgn, CRGN_DIFF);
  344.  
  345.        // -- edge region --
  346.  
  347.        arcl[0] = arcl[1] = arcl[2] = arcl[3] = borderRect;
  348.        arcl[0].xRight -= (borderRect.xRight - borderRect.xLeft) / 2;
  349.        arcl[0].yTop -= (borderRect.yTop - borderRect.yBottom) / 2;
  350.        arcl[1].xLeft = arcl[0].xRight + 1;
  351.        arcl[1].yTop = arcl[0].yTop;
  352.        arcl[2].xLeft = arcl[0].xRight + 1;
  353.        arcl[2].yBottom = arcl[0].yTop + 1;
  354.        arcl[3].xRight = arcl[0].xRight;
  355.        arcl[3].yBottom = arcl[0].yTop + 1;
  356.  
  357.        if ((borderRect.xRight - borderRect.xLeft) >= (5 * kODHandleLenMultiplier * kODBorderWidth))
  358.        {
  359.           /* top and bottom handles */
  360.  
  361.           LONG hdist = (kODHandleLenMultiplier * kODBorderWidth) / 2;
  362.           arcl[0].xRight -= hdist;
  363.           arcl[1].xLeft += hdist;
  364.           arcl[2].xLeft = arcl[1].xLeft;
  365.           arcl[3].xRight = arcl[0].xRight;
  366.        }
  367.  
  368.        if ((borderRect.yTop - borderRect.yBottom) >= (5 * kODHandleLenMultiplier * kODBorderWidth))
  369.        {
  370.           /* left and right handles */
  371.  
  372.           LONG vdist = (kODHandleLenMultiplier * kODBorderWidth) / 2;
  373.           arcl[0].yTop -= vdist;
  374.           arcl[1].yTop = arcl[0].yTop;
  375.           arcl[2].yBottom += vdist;
  376.           arcl[3].yBottom = arcl[2].yBottom;
  377.        }
  378.        GpiCombineRegion(_hpsMem, _fEdgeHandleRgn, _fSelectRgn, 0, CRGN_COPY);
  379.        GpiSetRegion(_hpsMem, tempRgn, 4, arcl);
  380.        GpiCombineRegion(_hpsMem, _fEdgeHandleRgn, _fEdgeHandleRgn, tempRgn, CRGN_DIFF);
  381.  
  382.     #if 0
  383.  
  384.        // clip by obscuring frames
  385.  
  386.        Proxy* q;
  387.        ODxOrderedCollectionIterator i(fContents);
  388.        ODBoolean above = true;
  389.        for (q = (Proxy*) i.First(); i.IsNotComplete(); q = (Proxy*) i.Next())
  390.        {  if (p == q) {above = false; continue;}
  391.           if (!above) {continue;}
  392.           GpiCombineRegion(_hpsMem, _fSelectRgn, _fSelectRgn, q->region, CRGN_DIFF);
  393.           GpiCombineRegion(_hpsMem, _fCornerHandleRgn, _fCornerHandleRgn, q->region, CRGN_DIFF);
  394.           GpiCombineRegion(_hpsMem, _fEdgeHandleRgn, _fEdgeHandleRgn, q->region, CRGN_DIFF);
  395.        };
  396.     #endif
  397.        GpiDestroyRegion(_hpsMem, tempRgn);
  398.  
  399.        // clip path from obscured frames
  400.        somSelf->ClipEmbeddedFrames(ev, p->frame->GetContainingFrame(ev));
  401.    }
  402.  
  403.    SOM_Scope void  SOMLINK ContainerPartInvalidateSelection(ContainerPart *somSelf,
  404.                                                 Environment *ev,
  405.                                                ODFrame* frame)
  406.    {
  407.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  408.        ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidateSelection");
  409.  
  410.        ODShape* selectShape = new ODShape();
  411.        HRGN invalidRgn = GpiCreateRegion(_hpsMem, 0, NULL);
  412.        GpiCombineRegion( _hpsMem, invalidRgn, _fSelectRgn, _fCornerHandleRgn, CRGN_OR);
  413.        GpiCombineRegion( _hpsMem, invalidRgn, invalidRgn, _fEdgeHandleRgn, CRGN_OR);
  414.        selectShape->SetPlatformShape(ev, kODGPI, invalidRgn);
  415.  
  416.        // transform shape from region coords to frame coords (CED - 110594)
  417.        ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  418.        selectShape->InverseTransform(ev, facets->First(ev)->GetWindowFrameTransform(ev));
  419.        delete facets;
  420.  
  421.        frame->Invalidate(ev, selectShape);
  422.        delete selectShape;
  423.    }
  424.  
  425.    SOM_Scope void  SOMLINK ContainerPartClipEmbeddedFrames(ContainerPart *somSelf,
  426.                                                Environment *ev,
  427.                                               ODFrame* frame)
  428.    {
  429.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  430.        ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFrames");
  431.  
  432.        ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  433.        for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  434.           somSelf->ClipEmbeddedFacets(ev, facet);
  435.        delete facets;
  436.    }
  437.  
  438.  
  439. /*
  440.  *@jlc whatisit? void InstallObjectAccessors();
  441.  */
  442.  
  443.    SOM_Scope void  SOMLINK ContainerPartCommonInitContainerPart(ContainerPart *somSelf,
  444.                                                     Environment *ev)
  445.    {
  446.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  447.        ContainerPartMethodDebug("ContainerPart","ContainerPartCommonInitContainerPart");
  448.  
  449.        _fDisplayFrames = new ODxOrderedCollection;
  450.        _fEmbeddedFrames = new ODxOrderedCollection;
  451.  
  452. //+(rlt 3-8-95(
  453.        _fDefaultColor = 0;  // pick white as default for root frame only
  454. //-
  455.        _fContents = new ODxOrderedCollection;
  456.        _fSelection = new ODxOrderedCollection;
  457.        SIZEL sizlPage = {0, 0};
  458.        _hdcMem = DevOpenDC   (1 , OD_MEMORY, "*", 0L, NULL, (HDC)0) ;
  459.        _hpsMem = GpiCreatePS (1 , _hdcMem, &sizlPage, PU_PELS      | GPIF_DEFAULT |
  460.                                                     GPIT_MICRO   | GPIA_ASSOC) ;
  461.  
  462.        _fSelectRgn = GpiCreateRegion( _hpsMem, 0, NULL);
  463.        _fCornerHandleRgn = GpiCreateRegion( _hpsMem, 0, NULL);
  464.        _fEdgeHandleRgn = GpiCreateRegion( _hpsMem, 0, NULL);
  465.  
  466.        _fSession = somSelf->GetStorageUnit(ev)->GetSession(ev);
  467.  
  468.        _fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
  469.        _fMenuFocus = _fSession->Tokenize(ev, kODMenuFocus);
  470.        _fKeyFocus = _fSession->Tokenize(ev, kODKeyFocus);
  471.        _fMouseFocus = _fSession->Tokenize(ev, kODMouseFocus);
  472.  
  473.        _fFocusSet = new ODFocusSet();
  474.        _fFocusSet->InitFocusSet(ev);
  475.        _fFocusSet->Add(ev, _fSelectionFocus);
  476.        _fFocusSet->Add(ev, _fMenuFocus);
  477.        _fFocusSet->Add(ev, _fKeyFocus);
  478.        _fNotebook = new CNNotebook();
  479.        _fNotebook->InitNotebookExtension(ev, somSelf);
  480.    }
  481.  
  482.    SOM_Scope ODxOrderedCollection*  SOMLINK ContainerPartGetEmbeddedFrames(ContainerPart *somSelf,
  483.                                                             Environment *ev)
  484.    {
  485.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  486.        ContainerPartMethodDebug("ContainerPart","ContainerPartGetEmbeddedFrames");
  487.  
  488.       return _fEmbeddedFrames;
  489.    }
  490.  
  491.    SOM_Scope Proxy*  SOMLINK ContainerPartProxyForFrameID(ContainerPart *somSelf,
  492.                                               Environment *ev, ODID frameID)
  493.    {
  494.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  495.        ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrameID");
  496.  
  497.        ODFrame* frame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->GetFrame(ev, frameID);
  498.        Proxy* p = somSelf->ProxyForFrame(ev, frame);
  499.        frame->Release(ev);
  500.        return p;
  501.    }
  502.  
  503.    SOM_Scope void  SOMLINK ContainerPartHighlightSelection(ContainerPart *somSelf,
  504.                                                Environment *ev,
  505.                                               ODFacet* facet)
  506.    {
  507.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  508.        ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightSelection");
  509.  
  510.        switch (_fSelection->Count())
  511.        {
  512.           case 0:     // no selection
  513.              break;
  514.  
  515.           case 1:     // single selection
  516.              {  ODxOrderedCollectionIterator i(_fSelection);
  517.                 somSelf->HighlightProxyBorder(ev, (Proxy*)i.First(), facet);
  518.              };
  519.              break;
  520.  
  521.           default: // multiple selection
  522.              {  Proxy* p;
  523.                 ODxOrderedCollectionIterator i(_fSelection);
  524.                 for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  525.                 {  if (_fSelection->Contains(p))
  526.                       somSelf->HighlightContentObject(ev, p, facet);
  527.                 };
  528.              };
  529.        };
  530.    }
  531.  
  532.    SOM_Scope void  SOMLINK ContainerPartHighlightProxyBorder(ContainerPart *somSelf,
  533.                                                  Environment *ev,
  534.                                                 Proxy* p, ODFacet* facet)
  535.    {
  536.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  537.        ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightProxyBorder");
  538.  
  539.        HPS hps = facet->GetCanvas(ev)->GetPlatformCanvas(ev);
  540.  
  541.        HRGN shapeRgn = GpiCreateRegion(hps, 0, NULL);
  542.        Rect rect;
  543. // (CED - 110594) ODPoint pt = {0,0};
  544.        SIZEL sizlThickness = {1, 1};
  545.  
  546. // (CED - 110594) pt = facet->GetContentTransform(ev)->TransformPoint(ev, &pt);
  547. // (CED - 110594) ODPOINTL ptl(pt);
  548.  
  549.        // draw frame border
  550.        GpiSavePS(hps);
  551.        GpiSetPattern(hps, PATSYM_DENSE5);
  552.        GpiSetColor(hps, CLR_BLACK);
  553.  
  554.        GpiCombineRegion(hps, shapeRgn, _fSelectRgn, 0, CRGN_COPY);
  555. // (CED - 110594) GpiOffsetRegion(hps, shapeRgn, &ptl);
  556.        GpiPaintRegion(hps, shapeRgn);
  557.  
  558.        GpiSetPattern(hps, PATSYM_SOLID);
  559.        GpiSetColor(hps, CLR_WHITE);
  560.        GpiCombineRegion(hps, shapeRgn, _fCornerHandleRgn, 0, CRGN_COPY);
  561. // (CED - 110594) GpiOffsetRegion(hps, shapeRgn, &ptl);
  562.        GpiPaintRegion(hps, shapeRgn);
  563.        GpiSetColor(hps, CLR_BLACK);
  564.        GpiFrameRegion(hps, shapeRgn, &sizlThickness);
  565.  
  566.        GpiSetColor(hps, CLR_WHITE);
  567.        GpiCombineRegion(hps, shapeRgn, _fEdgeHandleRgn, 0, CRGN_COPY);
  568. // (CED - 110594) GpiOffsetRegion(hps, shapeRgn, &ptl);
  569.        GpiPaintRegion(hps, shapeRgn);
  570.        GpiSetColor(hps, CLR_BLACK);
  571.        GpiFrameRegion(hps, shapeRgn, &sizlThickness);
  572.  
  573.        GpiDestroyRegion(hps, shapeRgn);
  574.        GpiRestorePS(hps, -1);
  575.  
  576.        facet->GetCanvas(ev)->ReleasePlatformCanvas(ev);
  577.    }
  578.  
  579.    SOM_Scope void  SOMLINK ContainerPartHighlightContentObject(ContainerPart *somSelf,
  580.                                                    Environment *ev,
  581.                                                   Proxy* p, ODFacet* facet)
  582.    {
  583.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  584.        ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightContentObject");
  585.  
  586.        NOTDONE2("HighlightContentObject");
  587.    }
  588.  
  589.    SOM_Scope void  SOMLINK ContainerPartClipEmbeddedFacets(ContainerPart *somSelf,
  590.                                                Environment *ev,
  591.                                               ODFacet* facet)
  592.    {
  593.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  594.        ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFacets");
  595.  
  596.        ODTransform* wclipTrans = new ODTransform;
  597.  
  598.        ODShape* workingClip = new ODShape();
  599.        workingClip->CopyFrom(ev, facet->GetClipShape(ev));
  600. //     ODShape* contentClip = (ODShape*)facet->GetPartInfo(ev);
  601.        ODRect emptyRect = {0,0,0,0};
  602. //     contentClip->SetRectangle(ev, &emptyRect);
  603. /*
  604.  * These two lines were moved here from down below because we now need to
  605.  * transform workingClip before subtracting the selection region since the
  606.  * selection region is in device coords. (CED - 110594)
  607.  */
  608.        wclipTrans->CopyFrom(ev, facet->GetWindowFrameTransform(ev));
  609.        workingClip->Transform(ev, wclipTrans);    // now in window coordinates
  610.  
  611.        // let selection obscure embedded parts
  612.  
  613.        HRGN tempRgn;
  614.        ODShape* tempShape = new ODShape;
  615.  
  616.  
  617.        RECTL rclBox;
  618.        LONG lComplexity = GpiQueryRegionBox(_hpsMem, _fSelectRgn, &rclBox);
  619.        if (_fSelectRgn &&  lComplexity != RGN_NULL && lComplexity != RGN_ERROR)
  620.        {
  621.           tempRgn = GpiCreateRegion(_hpsMem, 0, NULL);
  622.           GpiCombineRegion(_hpsMem, tempRgn, _fSelectRgn, 0, CRGN_COPY);
  623.           GpiCombineRegion(_hpsMem, tempRgn, tempRgn, _fCornerHandleRgn, CRGN_OR);
  624.           GpiCombineRegion(_hpsMem, tempRgn, tempRgn, _fEdgeHandleRgn, CRGN_OR);
  625.           tempShape->SetPlatformShape(ev, kODGPI, tempRgn); // shape owns rgn now
  626.           workingClip->Subtract(ev, tempShape);
  627.        }
  628.        delete tempShape;
  629.  
  630. // (CED - 110594) wclipTrans->CopyFrom(ev, facet->GetWindowFrameTransform(ev));
  631. // (CED - 110594) workingClip->Transform(ev, wclipTrans);    // now in window coordinates
  632.  
  633.        ODFacet* embFacet;
  634.        ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  635.        for (embFacet = facets->First(ev);
  636.              facets->IsNotComplete(ev);
  637.              embFacet = facets->Next(ev))
  638.        {
  639.           ODShape* newClipShape = new ODShape();
  640.           newClipShape->CopyFrom(ev, embFacet->GetFrame(ev)->GetUsedShape(ev));
  641.  
  642.           wclipTrans->CopyFrom(ev, embFacet->GetWindowFrameTransform(ev));
  643.           wclipTrans->Invert(ev);
  644.           workingClip->Transform(ev, wclipTrans);    // now in frame coordinates
  645. //        contentClip->Transform(ev, wclipTrans);
  646.  
  647.           newClipShape->Intersect(ev, workingClip);
  648.           workingClip->Subtract(ev, newClipShape);
  649. //        contentClip->Union(ev, newClipShape);
  650.  
  651.           wclipTrans->Invert(ev);
  652.           workingClip->Transform(ev, wclipTrans);    // now in window coordinates
  653. //        contentClip->Transform(ev, wclipTrans);
  654.  
  655.           embFacet->ChangeGeometry(ev, newClipShape, kODNULL);  // facet now owns shape storage
  656.        }
  657.        delete facets;
  658.        delete wclipTrans;
  659.    }
  660.  
  661.    SOM_Scope void  SOMLINK ContainerPartEmptySelection(ContainerPart *somSelf,
  662.                                            Environment *ev)
  663.    {
  664.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  665.        ContainerPartMethodDebug("ContainerPart","ContainerPartEmptySelection");
  666.  
  667.        for(ODULong i = _fSelection->Count(); i > 0; i--)
  668.           _fSelection->RemoveFirst();
  669.        if ( _fSPEMenuOfSelection ) {
  670.           _fSPEMenuOfSelection->Release(ev);
  671.           _fSPEMenuOfSelection = kODNULL;
  672.        } /* endif */
  673.        GpiSetRegion( _hpsMem, _fSelectRgn, 0, NULL);
  674.        GpiSetRegion( _hpsMem, _fCornerHandleRgn, 0 ,NULL);
  675.        GpiSetRegion( _hpsMem, _fEdgeHandleRgn, 0, NULL);
  676.    }
  677.  
  678.  
  679.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDown(ContainerPart *somSelf,
  680.                                                            Environment *ev,
  681.                                                           ODFacet* facet,
  682.                                                           ODPoint* where,
  683.                                                           ODEventData* event)
  684.    {
  685.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  686.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDown");
  687.  
  688.        if (!facet->GetWindow(ev)->IsActive(ev))
  689.           facet->GetWindow(ev)->Select(ev);
  690.        else
  691.           if (event->msg==WM_BUTTON1DOWN) {
  692.              somSelf->ActivateFrame(ev, facet->GetFrame(ev));
  693.           } /* endif */
  694.  
  695. // (CED - 110594) ODPOINTL mouse(facet->GetWindowContentTransform(ev)->InvertPoint(ev, where));
  696.        ODPOINTL mouse(*where);      // Keep in window coords (CED - 110594)
  697.  
  698.        {
  699.  
  700.           ODxOrderedCollectionIterator i(_fSelection);
  701.           Proxy* p = (Proxy*)i.First();
  702.  
  703.           if (GpiPtInRegion(_hpsMem, _fCornerHandleRgn, &mouse) == PRGN_INSIDE)
  704.              return somSelf->HandleMouseDownCornerResize(ev, facet, p, &mouse);
  705.           else if (GpiPtInRegion(_hpsMem, _fEdgeHandleRgn, &mouse) == PRGN_INSIDE)
  706.              return somSelf->HandleMouseDownEdgeResize(ev, facet, p, &mouse);
  707.           else if (GpiPtInRegion(_hpsMem, _fSelectRgn, &mouse) == PRGN_INSIDE)
  708.              return somSelf->HandleMouseDownDrag(ev, facet, p, event);
  709.           else
  710.              switch (_fSelection->Count())
  711.              {
  712.                 case 0:
  713.                    break;
  714.  
  715.                 case 1:
  716.                    if (event->msg==WM_BUTTON1DOWN) {
  717.                       somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
  718.                       somSelf->EmptySelection(ev);
  719.                       somSelf->ClipEmbeddedFrames(ev, facet->GetFrame(ev));
  720.                    } /* endif */
  721.                    break;
  722.  
  723.                 default:
  724.                    // !!! handle multiple selection
  725.                    break;
  726.              }
  727.  
  728.              #if 1
  729.                 // Start rubber band selection.  We don't actually support
  730.                 //   rubber band selection, but this demonstrates one way to
  731.                 //   handle the difficult aspects.  Scan this file
  732.                 //   for instances of _fTracking to see related code.
  733.  
  734.                 ODFrame* frame = facet->GetFrame(ev);
  735.  
  736.                 if (event->msg == WM_BUTTON1DOWN &&
  737.                     _fSession->GetArbitrator(ev)->RequestFocus(ev, _fMouseFocus,
  738.                                                                frame))
  739.                 {
  740.                   if (WinSetCapture(HWND_DESKTOP, event->hwnd))
  741.                   {
  742.                     if (WinLockWindowUpdate(HWND_DESKTOP, event->hwnd))
  743.                     {
  744.                       ODPOINTL ptlMouse = *where;
  745.                       PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  746.                       _fTracking = kODTrue;
  747.                       _ptlOrigin = _ptlEnd = ptlMouse;
  748.  
  749.                       if (_hrgnTrackingClip)
  750.                         GpiDestroyRegion(_hpsMem, _hrgnTrackingClip);
  751.  
  752.                       ODShape* clipShape = new ODShape;
  753.                       clipShape->CopyFrom(ev, facet->GetAggregateClipShape(ev) );
  754.                       clipShape->Transform(ev, facet->GetWindowFrameTransform(ev));
  755.                       _hrgnTrackingClip = clipShape->GetRegion(ev);
  756.                     }
  757.                     else
  758.                     {
  759.                       WinSetCapture(HWND_DESKTOP, 0);
  760.                       _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
  761.                                                                     frame);
  762.                     }
  763.                   }
  764.                   else
  765.                   {
  766.                     _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
  767.                                                                   frame);
  768.                   }
  769.                 }
  770.              #endif
  771.        }
  772.        return kODTrue;
  773.    }
  774.  
  775.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseUp(ContainerPart *somSelf,
  776.                                                            Environment *ev,
  777.                                                           ODFacet* facet,
  778.                                                           ODFrame* frame,
  779.                                                           ODPoint* where,
  780.                                                           ODEventData* event)
  781.    {
  782.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  783.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseUp");
  784.  
  785.        if (_fTracking)
  786.        {
  787.          _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, frame);
  788.          somSelf->FocusLost(ev, _fMouseFocus, frame);
  789.        }
  790.        /*
  791.         * Add code here to select objects within the tracking rectange
  792.         */
  793.  
  794.        return kODTrue;
  795.    }
  796.  
  797.  
  798.    SOM_Scope void  SOMLINK ContainerPartMoveResize(ContainerPart *somSelf,
  799.                                                    Environment *ev,
  800.                                                    ODFacet* facet,
  801.                                                    Proxy* selection,
  802.                                                    ODSLong fs)
  803.  
  804.    {
  805.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  806.        ContainerPartMethodDebug("ContainerPart","ContainerPartMoveResize");
  807.  
  808.        TRACKINFO trackInfo;
  809. // (CED - 110594) ODPoint pt = {0, 0};
  810.  
  811.        memset(&trackInfo, 0, sizeof(trackInfo));
  812.        trackInfo.fs = fs;
  813.        trackInfo.cxBorder = kODBorderWidth;
  814.        trackInfo.cyBorder = kODBorderWidth;
  815.        trackInfo.cxGrid = trackInfo.cyGrid = 1;
  816.        trackInfo.cxKeyboard = trackInfo.cyKeyboard = 8;
  817.        trackInfo.ptlMinTrackSize.x = 2 * kODBorderWidth * kODHandleLenMultiplier
  818.                                      + 2;
  819.        trackInfo.ptlMinTrackSize.y = 2 * kODBorderWidth * kODHandleLenMultiplier
  820.                                      + 2;
  821. // (CED - 110594) pt = facet->GetContentTransform(ev)->TransformPoint(ev, &pt);
  822. // (CED - 110594) ODPOINTL ptl(pt);
  823.        GpiQueryRegionBox(_hpsMem, _fSelectRgn, &trackInfo.rclTrack);
  824. // (CED - 110594) OffsetRect(&trackInfo.rclTrack, ptl.x, ptl.y);
  825.        Rect oldRect = trackInfo.rclTrack;
  826.        InflateRect(&oldRect, -kODBorderWidth, -kODBorderWidth);
  827.  
  828.        ODShape *boundingShape = new ODShape();
  829.        ODRect bounds;
  830.        boundingShape->CopyFrom(ev, facet->GetFrame(ev)->GetFrameShape(ev));
  831.        boundingShape->Transform(ev, facet->GetWindowFrameTransform(ev));
  832.        boundingShape->GetBoundingBox(ev, &bounds);
  833.        trackInfo.rclBoundary = ODRECTL(bounds);
  834.        delete boundingShape;
  835.  
  836.        trackInfo.ptlMaxTrackSize.x = trackInfo.rclBoundary.xRight;
  837.        trackInfo.ptlMaxTrackSize.y = trackInfo.rclBoundary.yTop;
  838.  
  839.        HWND hwnd = facet->GetWindow(ev)->GetPlatformWindow(ev);
  840.  
  841.        // Get the window handle of the client window to track over.
  842.        // Shouldn't GetPlatformWindow return the client window handle? - CED
  843.  
  844.        hwnd = WinWindowFromID(hwnd, FID_CLIENT);
  845.  
  846.        if (WinTrackRect(hwnd, NULLHANDLE, &trackInfo)) {
  847.           InflateRect(&trackInfo.rclTrack, -kODBorderWidth, -kODBorderWidth);
  848.  
  849. #if 1   // (CED - 110594)
  850.  
  851.           ODPoint offset = {
  852.              MAKEFIXED(trackInfo.rclTrack.xLeft, 0),
  853.              MAKEFIXED(trackInfo.rclTrack.yBottom, 0)
  854.           };
  855.           offset = facet->GetWindowFrameTransform(ev)->InvertPoint(ev, &offset);
  856.  
  857.           // offset now in my frame coordinates.
  858.  
  859.           ODTransform* newTransform = new ODTransform;
  860.           newTransform->MoveBy(ev, &offset);
  861.           newTransform->PostCompose(ev, facet->GetWindowFrameTransform(ev));
  862.  
  863.           // newTransform now represents the window frame transform of frame
  864.           // being moved.
  865.  
  866.           ODShape* newShape = new ODShape;
  867.           ODRect newBounds = downcastToODRECTL(trackInfo.rclTrack);
  868.           newShape->SetRectangle(ev, &newBounds);
  869.  
  870.           // Shape is in window coords.  Transform it to local frame coords of
  871.           // the frame being moved.
  872.  
  873.           newShape->InverseTransform(ev, newTransform);
  874.  
  875.           // Set the new external transform of the frame being moved.
  876.           newTransform->SetOffset(ev, &offset);
  877.  
  878.           somSelf->InvalEmbedFrameAfterResize(ev, facet, selection, newShape, newTransform);
  879.           // newShape & newTransform are no longer my responsiblility
  880. #else
  881.           Point transOffset = { trackInfo.rclTrack.xLeft - oldRect.xLeft,
  882.                                 trackInfo.rclTrack.yBottom - oldRect.yBottom };
  883.           OffsetRect(&trackInfo.rclTrack, -trackInfo.rclTrack.xLeft,
  884.                                           -trackInfo.rclTrack.yBottom);
  885.           ODShape* newShape = new ODShape;
  886.           ODRect newBounds = downcastToODRECTL(trackInfo.rclTrack);
  887.           newShape->SetRectangle(ev, &newBounds);
  888.  
  889.           ODShape* oldShape = selection->frame->GetFrameShape(ev);
  890.           somSelf->InvalEmbedFrameAfterResize(ev, facet, selection, oldShape, newShape, &transOffset);
  891. #endif
  892.        }
  893.    }
  894.  
  895.  
  896.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDownDrag(ContainerPart *somSelf,
  897.                                                                Environment *ev,
  898.                                                               ODFacet* facet,
  899.                                                               Proxy* selection,
  900.                                                               ODEventData* event)
  901.    {
  902.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  903.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownDrag");
  904.  
  905.        ODBoolean handled = kODFalse;
  906.  
  907.        ODPart* destPart;
  908.        ODPoint pt = {0, 0};
  909.        ODShape* scratch;
  910.        Point mdOffset = {0,0};
  911.        HRGN dragRgn, tempRgn;
  912.        ODID frameInfoData;
  913.        ODDragAndDrop*   dad;
  914.        ODStorageUnit*   unit;
  915.        ODDropResult dropResult;
  916.  
  917.        handled = kODTrue;
  918.        if (event->msg==WM_BUTTON1DOWN) {
  919.  
  920.           somSelf->MoveResize(ev, facet, selection, TF_MOVE);
  921.  
  922.        } else if  (event->msg==WM_BUTTON2DOWN) {
  923.           POINTL pts[13];
  924.           ODPOINTL odptlMouse(SHORT1FROMMP(event->mp1), SHORT2FROMMP(event->mp1));
  925.           ODDragAndDrop*   dad = _fSession->GetDragAndDrop(ev);
  926.           dad->Clear(ev);
  927.           {
  928.              Rect shapeRect;
  929.              #if 1
  930.                 ODShape *trackingShape = new ODShape();
  931.                 trackingShape->CopyFrom(ev, selection->frame->GetFrameShape(ev));
  932.                 trackingShape->Transform(ev, selection->transform);
  933.                 trackingShape->Transform(ev, facet->GetWindowFrameTransform(ev));
  934.                 //GpiQueryRegionBox( _hpsMem, trackingShape->GetQDRegion(ev), &shapeRect);
  935.                 GpiQueryRegionBox( _hpsMem, trackingShape->GetRegion(ev), &shapeRect);
  936.                 //Rect oldRect = shapeRect;
  937.                 //InflateRect(&shapeRect, kODBorderWidth, kODBorderWidth);
  938.                 shapeRect.xLeft   -= odptlMouse.x;
  939.                 shapeRect.xRight  -= odptlMouse.x;
  940.                 shapeRect.yBottom -= odptlMouse.y;
  941.                 shapeRect.yTop    -= odptlMouse.y;
  942.                 delete trackingShape;
  943.              #endif
  944.              // specify inner box
  945.              pts[ 0].x = 0;   pts[0].y = 0;
  946.              pts[ 1].x = shapeRect.xLeft ;  pts[ 1].y = shapeRect.yBottom;
  947.              pts[ 2].x = shapeRect.xLeft ;  pts[ 2].y = shapeRect.yTop;
  948.              pts[ 3].x = shapeRect.xRight;  pts[ 3].y = shapeRect.yTop;
  949.              pts[ 4].x = shapeRect.xRight;  pts[ 4].y = shapeRect.yBottom;
  950.              pts[ 5].x = shapeRect.xLeft ;  pts[ 5].y = shapeRect.yBottom;
  951.              // do another slightly larger box
  952.              pts[ 6].x = pts[ 1].x - 2   ;  pts[ 6].y = pts[ 1].y - 2;
  953.              pts[ 7].x = pts[ 2].x - 2   ;  pts[ 7].y = pts[ 2].y + 2;
  954.              pts[ 8].x = pts[ 3].x + 2   ;  pts[ 8].y = pts[ 3].y + 2;
  955.              pts[ 9].x = pts[ 4].x + 2   ;  pts[ 9].y = pts[ 4].y - 2;
  956.              pts[10].x = pts[ 5].x - 2   ;  pts[10].y = pts[ 5].y - 2;
  957.              // return to inner box
  958.              pts[11].x = shapeRect.xLeft ;  pts[11].y = shapeRect.yBottom;
  959.              // return to origin to erase xor vector out to edge of box
  960.              pts[12].x = 0;  pts[12].y = 0;
  961.           }
  962.           DRAGIMAGE dimg;         /* DRAGIMAGE structure                   */
  963.           HBITMAP   hbm;          /* Bit-map handle                        */
  964.  
  965.           /*************************************************************/
  966.           /* Initialize the DRAGIMAGE structure                        */
  967.           /*************************************************************/
  968.           dimg.cb = sizeof(DRAGIMAGE); /* Size control block           */
  969.  
  970.           // jlc changed the following code to use a polygon rather than
  971.           //    a bitmap because he wanted to put something on the screen
  972.           //    quickly and didn't want to take the time to code up a
  973.           //    bitmap.  The following code should be changed to
  974.           //    actually provide an outline of the object, or an icon.
  975.  
  976.           dimg.cptl        = 13;  // number of points
  977.           dimg.hImage = (ULONG)(PPOINTL)pts;           /* Image handle passed to       */
  978.                                        /* DrgDrag                      */
  979.           dimg.sizlStretch.cx = 20L;   /* Size to stretch ico or bmp to*/
  980.           dimg.sizlStretch.cy = 20L;
  981.           dimg.fl = DRG_POLYGON;       /* Flags passed to DrgDrag      */
  982.                  //   DRG_STRETCH;       /* Stretch to size specified    */
  983.                                        /* in sizlStretch               */
  984.           dimg.cxOffset = 0;           /* Offset of the origin of      */
  985.           dimg.cyOffset = 0;           /* the image from the pointer   */
  986.                                        /* hotspot                      */
  987.  
  988.           // jlc - rest of the system needs to know that this frame is
  989.           //       responsible for starting the drag.  We will need
  990.           //       to code up some additional support later to insure
  991.           //       that source messages like DM_DRAGOVERNOTIFY get
  992.           //       back here. todo:
  993.  
  994.           // *** Fill DAD SU with Props n' Vals
  995.           //unit = dad->GetStorageUnit(ev);
  996.           unit = dad->GetContentStorageUnit(ev);
  997.  
  998.           ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  999.           ODDraftKey key = fromDraft->BeginClone(ev, kODCloneCut);
  1000.           selection->frame->GetPart(ev)->CloneInto(ev, key, unit, selection->frame->GetStorageUnit(ev));
  1001.           fromDraft->EndClone(ev, key);
  1002.  
  1003.           // *** save ID of frame being dragged
  1004.  
  1005.           frameInfoData = selection->frame->GetID(ev);
  1006.           unit->AddProperty(ev, kPropFrameInfo)->AddValue(ev, kODID);
  1007.           unit->SetValue(ev, sizeof(ODID), (ODValue) &frameInfoData);
  1008.  
  1009.           // *** Save the frame's part info.  This is a kludge because
  1010.           // *** some of the sample parts we have now save their content
  1011.           // *** to the frame's partinfo rather than  adding properties
  1012.           // *** for part content in the storage unit.  The frame's partinfo
  1013.           // *** data should not normally be copied on a drag/drop operation.
  1014.           // *** This code will be removed once the sample parts are fixed
  1015.           // *** up to externalize properly.
  1016.  
  1017.           PartInfoRec* pInfo = (PartInfoRec*) selection->frame->GetPartInfo(ev);
  1018.           unit->AddProperty(ev, kODPropPartInfo)->AddValue(ev, kODPartInfo);
  1019.           ODStorageUnitView *suView = new ODStorageUnitView();
  1020.           suView->InitStorageUnitView(ev, unit, unit->CreateCursor(ev));
  1021.           ODInfoType fPartInfo = selection->frame->GetPartInfo(ev);
  1022.           selection->frame->GetPart(ev)->WritePartInfo(ev, (ODPtr)fPartInfo, suView);
  1023.           delete suView;
  1024.  
  1025.           // *** (optional) save offset between mousedown pt and topLeft pt of selection
  1026.  
  1027.           // assuming event->where is in window coordinates.
  1028.           _mouseStart = ODPoint(odptlMouse);
  1029.  
  1030. #if 1 // (CED - 110594)
  1031.           ODPoint botLeft;       // elsewhere refered to as topLeft (Mac heratige)
  1032.           ODPoint offset(odptlMouse);  // offset of mouse in window coords
  1033.  
  1034.           selection->transform->GetOffset(ev, &botLeft);
  1035.  
  1036.           // botLeft contains offset of frame being dragged in my frame coords.
  1037.  
  1038.           offset = facet->GetWindowFrameTransform(ev)->InvertPoint(ev, &offset);
  1039.  
  1040.           // offset contains the offset of the mouse in my frame coords
  1041.  
  1042.           offset.x -= botLeft.x;
  1043.           offset.y -= botLeft.y;
  1044.  
  1045.           // offset contains offset of mouse relative to position of frame
  1046.           // being dragged in my frame coords (same coords as frame shape).
  1047.  
  1048.           unit->AddProperty(ev, kPropMouseDownOffset)->AddValue(ev, kODPoint);
  1049.           unit->SetValue(ev, sizeof(mdOffset), (ODValue) &offset);
  1050. #else
  1051.           ODFrameFacetIterator* faceti = selection->frame->CreateFacetIterator(ev);
  1052.           //Point topLeft = faceti->First(ev)->GetWindowFrameTransform(ev)->GetQDOffset(ev);
  1053.           ODPoint topLeft;
  1054.           faceti->First(ev)->GetWindowFrameTransform(ev)->GetOffset(ev, &topLeft);
  1055.  
  1056.           facet->GetWindow(ev)->GetFacetUnderPoint( ev, &(_mouseStart) );
  1057.  
  1058.           mdOffset = odptlMouse;
  1059.  
  1060.              ODPOINTL odplTL(topLeft);
  1061.              mdOffset.x -= odplTL.x;
  1062.              mdOffset.y -= odplTL.y;
  1063.  
  1064.              unit->AddProperty(ev, kPropMouseDownOffset)->AddValue(ev, kOS2POINTL);
  1065.              unit->SetValue(ev, sizeof(mdOffset), (ODValue) &mdOffset);
  1066. #endif
  1067.           // *** (optional) if dragging one frame, save its external transform (not aggregate)
  1068.  
  1069. #if 1 // (CED - 110594)
  1070.              ODMatrix m;
  1071.              selection->transform->GetMatrix(ev, &m);
  1072.              unit->AddProperty(ev, kODPropExternalTransform)->AddValue(ev, kODTransform);
  1073.              unit->SetValue(ev, sizeof(m), (ODValue) &m);
  1074. #else
  1075.              unit->AddProperty(ev, kODPropExternalTransform)->AddValue(ev, kOS2POINTL);
  1076.              unit->SetValue(ev, sizeof(odplTL), (ODValue) &odplTL);
  1077. #endif
  1078.           // *** if dragging one frame, write its shape   [jpa]
  1079.  
  1080.           unit->AddProperty(ev, kODPropFrameShape);
  1081.           selection->frame->GetFrameShape(ev)->WriteShape(ev, unit);
  1082.  
  1083.           selection->frame->SetDragging(ev, kODTrue);
  1084.  
  1085.           dropResult = dad->StartDrag(ev, facet->GetFrame(ev), 0, (ODPtr)&dimg, &destPart, &event);
  1086.  
  1087.           if ((dropResult == kODDropCopy) || (dropResult == kODDropMove))
  1088.           {
  1089.              if (destPart)
  1090.              {
  1091.                 // The frame was dropped in the same document
  1092.                 if (destPart == somSelf)
  1093.                 {
  1094.                    beepprintf("debuginfo: cntnrprt: drag was copied/moved to the same parent");
  1095.                    // If this was a move to the same part
  1096.                    facet->GetFrame(ev)->Invalidate(ev, NULL);
  1097.                    selection->frame->SetDragging(ev, kODFalse);
  1098.                 }
  1099.                 else
  1100.                 {
  1101.                    beepprintf("debuginfo: cntnrprt: drag was copied/moved to a different parent");
  1102.                    //<crs> - it was alway's forcing a move ??
  1103.                    if ( dropResult == kODDropMove )
  1104.                       {
  1105.                       // This was a move to a different part
  1106.                       ODPart *oldPart = selection->frame->GetPart(ev);
  1107.                       oldPart->IncrementRefCount(ev);
  1108.                       facet->GetFrame(ev)->Invalidate(ev, NULL);
  1109.                       somSelf->InvalidateSelection(ev, selection->frame);
  1110.                       somSelf->EmptySelection(ev);
  1111.  
  1112.                       ODxOrderedCollection* tempFacets = new ODxOrderedCollection;
  1113.  
  1114.                       ODFrameFacetIterator* facets = selection->frame->CreateFacetIterator(ev);
  1115.                       for (ODFacet* f1 = facets->First(ev);
  1116.                             facets->IsNotComplete(ev);
  1117.                             f1 = facets->Next(ev))
  1118.                       {
  1119.                          tempFacets->AddLast(f1);
  1120.                       }
  1121.                       delete facets;
  1122.  
  1123.                       ODxOrderedCollectionIterator t(tempFacets);
  1124.                       for (ODFacet* f2 = (ODFacet*)t.First();
  1125.                             t.IsNotComplete();
  1126.                             f2 = (ODFacet*)t.Next())
  1127.                       {
  1128.                          f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
  1129.                          ODDeleteObject(f2);
  1130.                       }
  1131.                       delete tempFacets;
  1132.  
  1133.                       somSelf->RemoveEmbeddedFrame(ev, selection->frame);
  1134.                       somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  1135.                       }
  1136.                    else
  1137.                       {
  1138.                       selection->frame->SetDragging(ev, kODFalse);
  1139.                       } //<crs> end
  1140.                 }
  1141.              }
  1142.              else
  1143.              {
  1144.                 // The frame was dropped in a different document
  1145.                 selection->frame->SetDragging(ev, kODFalse);
  1146.              }
  1147.  
  1148.              handled = kODTrue;
  1149.           }
  1150.           else
  1151.           {
  1152.                 beepprintf("debug info: cntnrprt: drag was copied/moved to a null document");
  1153.              selection->frame->SetDragging(ev, kODFalse);
  1154.           }
  1155.        } else {
  1156.           // some other button used.  Undefined action.
  1157.        } /* endif */
  1158.  
  1159.        return handled;
  1160.    }
  1161.  
  1162.  
  1163.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDownEdgeResize(ContainerPart *somSelf,
  1164.                                                                      Environment *ev,
  1165.                                                                     ODFacet* facet,
  1166.                                                                     Proxy* selection,
  1167.                                                                     POINTL* mouse)
  1168.    {
  1169.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1170.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownEdgeResize");
  1171.  
  1172.        ODSLong fs;
  1173.        Rect selectRect;
  1174.        GpiQueryRegionBox(_hpsMem, _fSelectRgn, &selectRect);
  1175.        InflateRect(&selectRect, -kODBorderWidth, -kODBorderWidth);
  1176.  
  1177.        if      (mouse->y >= selectRect.yTop)    fs = TF_TOP;
  1178.        else if (mouse->x <= selectRect.xLeft)   fs = TF_LEFT;
  1179.        else if (mouse->y <= selectRect.yBottom) fs = TF_BOTTOM;
  1180.        else if (mouse->x >= selectRect.xRight)  fs = TF_RIGHT;
  1181.  
  1182.        somSelf->MoveResize(ev, facet, selection, fs);
  1183.  
  1184.        return kODTrue;
  1185.    }
  1186.  
  1187.  
  1188.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDownCornerResize(ContainerPart *somSelf,
  1189.                                                                        Environment *ev,
  1190.                                                                       ODFacet* facet,
  1191.                                                                       Proxy* selection,
  1192.                                                                       POINTL* mouse)
  1193.    {
  1194.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1195.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownCornerResize");
  1196.  
  1197.        ODSLong fs;
  1198.        Rect selectRect;
  1199.        GpiQueryRegionBox(_hpsMem, _fSelectRgn, &selectRect);
  1200.  
  1201.        Point center = {(selectRect.xRight + selectRect.xLeft) / 2 ,
  1202.                        (selectRect.yBottom + selectRect.yTop) / 2 };
  1203.  
  1204.        if      ((mouse->y <= center.y) && (mouse->x <= center.x)) fs = TF_BOTTOM | TF_LEFT;
  1205.        else if ((mouse->y <  center.y) && (mouse->x >  center.x)) fs = TF_BOTTOM | TF_RIGHT;
  1206.        else if ((mouse->y >  center.y) && (mouse->x <  center.x)) fs = TF_TOP | TF_LEFT;
  1207.        else if ((mouse->y >  center.y) && (mouse->x >  center.x)) fs = TF_TOP | TF_RIGHT;
  1208.  
  1209.        somSelf->MoveResize(ev, facet, selection, fs);
  1210.  
  1211.        return kODTrue;
  1212.    }
  1213.  
  1214.  
  1215.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDownInEmbeddedFrame(ContainerPart *somSelf,
  1216.                                                                           Environment *ev,
  1217.                                                                          ODFacet* container,
  1218.                                                                          ODFacet* facet,
  1219.                                                                          ODPoint* where,
  1220.                                                                          ODEventData* event)
  1221.    {
  1222.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1223.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownInEmbeddedFrame");
  1224.  
  1225.        somSelf->ActivateFrame(ev, container->GetFrame(ev));
  1226.        Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
  1227.  
  1228.        switch (_fSelection->Count())
  1229.        {
  1230.           case 0:
  1231.              if ( event->msg != WM_BUTTON2DOWN ) {
  1232.                 _fSelection->AddFirst((ElementType)p);
  1233.                 somSelf->CreateProxySelectionBorder(ev, container, p);
  1234.                 somSelf->ClipEmbeddedFrames(ev, container->GetFrame(ev));
  1235.                 somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  1236.              } /* endif */
  1237.              break;
  1238.  
  1239.           case 1:
  1240.              if ( event->msg != WM_BUTTON2DOWN ) {
  1241.                 somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  1242.                 #if 1
  1243.                    somSelf->EmptySelection( ev );
  1244.                 #else
  1245.                    _fSelection->RemoveFirst();
  1246.                 #endif
  1247.                 _fSelection->AddFirst((ElementType)p);
  1248.                 somSelf->CreateProxySelectionBorder(ev, container, p);
  1249.                 somSelf->ClipEmbeddedFrames(ev, container->GetFrame(ev));
  1250.                 somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  1251.              } /* endif */
  1252.              break;
  1253.  
  1254.           default:
  1255.              // !!! handle multiple selection
  1256.              break;
  1257.        }
  1258.  
  1259.        somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  1260.  
  1261.        return kODTrue;
  1262.    }
  1263.  
  1264.  
  1265.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleKeyDown(ContainerPart *somSelf,
  1266.                                                          Environment *ev,
  1267.                                                         ODFrame* focusFrame,
  1268.                                                         ODEventData* event)
  1269.    {
  1270.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1271.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleKeyDown");
  1272.  
  1273.        ODBoolean handled = kODFalse;
  1274.  
  1275.        if ((SHORT1FROMMP(event->mp1) & KC_VIRTUALKEY) &&
  1276.            (SHORT2FROMMP(event->mp2) == VK_DELETE))
  1277.        {
  1278.           handled = somSelf->DoClear(ev, focusFrame);
  1279.        }
  1280.        else if (SHORT1FROMMP(event->mp2) == '/' &&
  1281.                 SHORT1FROMMP(event->mp1) & KC_ALT)
  1282.        {
  1283.           handled = somSelf->MoveToFront(ev, focusFrame);
  1284.        }
  1285.        else if (SHORT1FROMMP(event->mp2) == '\\' &&
  1286.                 SHORT1FROMMP(event->mp1) & KC_ALT)
  1287.        {
  1288.           handled = somSelf->MoveToBack(ev, focusFrame);
  1289.        }
  1290.        else if (SHORT1FROMMP(event->mp2) == '/' &&
  1291.                 SHORT1FROMMP(event->mp1) & KC_CTRL)
  1292.        {
  1293.           handled = somSelf->MoveForward(ev, focusFrame);
  1294.        }
  1295.        else if (SHORT1FROMMP(event->mp2) == '\\' &&
  1296.                 SHORT1FROMMP(event->mp1) & KC_CTRL)
  1297.        {
  1298.           handled = somSelf->MoveBackward(ev, focusFrame);
  1299.        }
  1300.        return handled;
  1301.    }
  1302.  
  1303.  
  1304.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMenuEvent(ContainerPart *somSelf,
  1305.                                                            Environment *ev,
  1306.                                                           ODFrame* focusFrame,
  1307.                                                           ODEventData* event)
  1308.    {
  1309.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1310.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMenuEvent");
  1311.  
  1312.        ODBoolean handled = kODFalse;
  1313.        ODCommandID command = LONGFROMMP(event->mp1);
  1314.  
  1315.        switch (command)
  1316.        {
  1317.           case IDMA_COLOR_GRAY      :
  1318.           case IDMA_COLOR_RED       :
  1319.           case IDMA_COLOR_GREEN     :
  1320.           case IDMA_COLOR_YELLOW    :
  1321.           case IDMA_COLOR_BLUE      :
  1322.           case IDMA_COLOR_MAGENTA   :
  1323.           case IDMA_COLOR_CYAN      :
  1324.           case IDMA_COLOR_WHITE     :
  1325.              {  //!!! This whole method do with some cleanup
  1326.                 // Change SetBGColor to use a command number
  1327.                 somSelf->SetBGColor1(ev, focusFrame, command);
  1328.                 handled = kODTrue;
  1329.              }
  1330.              break;
  1331.  
  1332.           case IDMA_FREEZE:
  1333.              {
  1334.                Proxy* p;
  1335.                ODxOrderedCollectionIterator i(_fSelection);
  1336.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1337.                {
  1338.                   p->frame->SetFrozen(ev, true);
  1339.                }
  1340.              }
  1341.              break;
  1342.  
  1343.           case IDMA_THAW:
  1344.              {
  1345.                Proxy* p;
  1346.                ODxOrderedCollectionIterator i(_fSelection);
  1347.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1348.                {
  1349.                   p->frame->SetFrozen(ev, false);
  1350.                }
  1351.              }
  1352.              break;
  1353.           case IDMA_DELETE     :
  1354.                   somSelf->DoClear(ev, focusFrame);
  1355.                   break;
  1356.           case IDMA_CUT       :
  1357.                   somSelf->DoCut(ev, focusFrame);
  1358.                   break;
  1359.           case IDMA_COPY      :
  1360.                   somSelf->DoCopy(ev, focusFrame);
  1361.                   break;
  1362.           case IDMA_PASTE     :
  1363.                   somSelf->DoPaste(ev, focusFrame);
  1364.                   break;
  1365.           case IDMA_MOVETOFRONT :
  1366.                   somSelf->MoveToFront(ev, focusFrame);
  1367.                   break;
  1368.           case IDMA_MOVETOBACK  :
  1369.                   somSelf->MoveToBack(ev, focusFrame);
  1370.                   break;
  1371.           case IDMA_MOVEFORWARD :
  1372.                   somSelf->MoveForward(ev, focusFrame);
  1373.                   break;
  1374.           case IDMA_MOVEBACKWARD:
  1375.                   somSelf->MoveBackward(ev, focusFrame);
  1376.                   break;
  1377.           case IDMR_PRINT :
  1378.                   somSelf->HandlePrinting(ev,  focusFrame );
  1379.                   break;
  1380.           case IDMA_CNT_DEMOITEM1:
  1381.           case IDMR_ROOTITEM1:
  1382.                   _DemoState++;
  1383.                   break;
  1384. //+(rlt 3-8-95)
  1385.           case IDMA_TOGGLE_GRID:
  1386.            {  
  1387.            PartInfoRec* pInfo = (PartInfoRec*) focusFrame->GetPartInfo(ev);
  1388.                 if (pInfo->fGridOn) pInfo->fGridOn = kODFalse;
  1389.                   else  pInfo->fGridOn = kODTrue;
  1390.                 focusFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  1391.                 focusFrame->Invalidate(ev, kODNULL);
  1392.            }
  1393.                 break;      
  1394.  
  1395.           case IDMA_SA_LICONS:
  1396.              {
  1397.                Proxy* p;
  1398.                ODxOrderedCollectionIterator i(_fSelection);
  1399.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1400.                {
  1401.                   p->frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsLargeIcon));
  1402.                }
  1403.              }
  1404.                   break;
  1405.  
  1406.           case IDMA_SA_SICONS:
  1407.              {
  1408.                Proxy* p;
  1409.                ODxOrderedCollectionIterator i(_fSelection);
  1410.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1411.                {
  1412.                   p->frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsSmallIcon));
  1413.                }
  1414.              }
  1415.                   break;
  1416.  
  1417.           case IDMA_SA_THUMBNAIL:
  1418.              {
  1419.                Proxy* p;
  1420.                ODxOrderedCollectionIterator i(_fSelection);
  1421.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1422.                {
  1423.                   p->frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsThumbnail));
  1424.                }
  1425.              }
  1426.                   break;
  1427.                
  1428.           case IDMA_SA_FRAME:
  1429.              {
  1430.                Proxy* p;
  1431.                ODxOrderedCollectionIterator i(_fSelection);
  1432.                for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1433.                {
  1434.                   p->frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));
  1435.                }
  1436.              }
  1437.                   break;
  1438. //-
  1439.           case IDMA_CNT_SETTINGS:
  1440.                   _fNotebook->Display(ev);
  1441.                   break;
  1442.           default:
  1443.                 if((command >= (IDMA_CNT_SELECTEDREMAP_FIRST)) && (command <= IDMA_CNT_SELECTEDREMAP_LAST) ) {
  1444.                    // The menu item selected was provided by the selected part.  We have
  1445.                    //    remapped those ID's, and now we'll need to map them back and
  1446.                    //    forward the event.
  1447.                    ODActiveFrameMenuBar * mb;
  1448.                    #ifdef USE_PARTINFO_TO_RECALL_AMENU
  1449.                       PartInfoRec* pInfo = (PartInfoRec *) focusFrame->GetPartInfo(ev);
  1450.                       mb = pInfo->mbActive;
  1451.                    #else
  1452.                       mb = (ODActiveFrameMenuBar*)focusFrame->GetWindow(ev)->GetMenuBar( ev);
  1453.                    #endif
  1454.                    if ( _fRemappedSPEMenuOfSelection ) {
  1455.                       ODCommandID commandOld = _fRemappedSPEMenuOfSelection->GetOldMenuID( ev, command );
  1456.  
  1457.                       ODEventData eventTmp = *event;
  1458.                       eventTmp.mp1 = MPFROMSHORT( commandOld);
  1459.    
  1460.                       ODMenuBar * SPEMenu = somSelf->GetSPEMenuOfSelection( ev);
  1461.                       if (SPEMenu) {
  1462.                          return SPEMenu->HandleEvent( ev, &eventTmp );
  1463.                       } else {
  1464.                          // internal error?
  1465.                       } /* endif */
  1466.                    } else {
  1467.                       // internal error?
  1468.                    } /* endif */
  1469.                 } else if((command < (IDMA_EMBED_BASE+1 + cODMaxEmbedParts)) && (command >=  IDMA_EMBED_BASE+1) )
  1470.                    {
  1471.                     somSelf->InvalidateSelection(ev, focusFrame);
  1472.                     somSelf->EmptySelection(ev);
  1473.                     // somSelf->ClipEmbeddedFrames(ev, focusFrame);
  1474.                     somSelf->Embed(ev, command, focusFrame, /*newPart:*/kODNULL);
  1475.                     handled = kODTrue;
  1476.                    }
  1477.              break;
  1478.        }
  1479.        return handled;
  1480.    }
  1481.  
  1482.  
  1483.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseMove(ContainerPart *somSelf,
  1484.                                                            Environment *ev,
  1485.                                                           ODFacet* facet,
  1486.                                                           ODFrame* frame,
  1487.                                                           ODPoint* where,
  1488.                                                           ODEventData* event)
  1489.    {
  1490.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1491.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseMove");
  1492.  
  1493.        ODBoolean handled = kODFalse;
  1494.        RECTL rclBox;
  1495.  
  1496.        PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  1497.        if (_fTracking)
  1498.        {
  1499.          ODPOINTL ptlMouse = *where;
  1500.          if (!SHORT1FROMMP(event->mp2))     // Mouse still captured?
  1501.          {
  1502.            somSelf->UpdateTrackRect(ev, &ptlMouse, event->hwnd);
  1503.            _ptlEnd = ptlMouse;
  1504.          }
  1505.          else                            // mouse is no longer captured
  1506.          {
  1507.            _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, frame);
  1508.            somSelf->FocusLost(ev, _fMouseFocus, frame);
  1509.          }
  1510.        }
  1511.        else if (facet->GetWindow(ev)->IsActive(ev) )
  1512.        {
  1513.           if (_fSelection->Count() >= 1)
  1514.           {
  1515. // (CED - 110594) ODPOINTL ptlMouse = facet->GetWindowContentTransform(ev)->InvertPoint(ev, where);
  1516.              ODPOINTL ptlMouse(*where);     // Keep in device coords (CED - 110594)
  1517.  
  1518.              if (GpiPtInRegion(_hpsMem, _fCornerHandleRgn, &ptlMouse) == PRGN_INSIDE)
  1519.              {
  1520.                 GpiQueryRegionBox(_hpsMem, _fCornerHandleRgn, &rclBox);
  1521.                 ptlMouse.x -= (rclBox.xLeft + rclBox.xRight) / 2;
  1522.                 ptlMouse.y -= (rclBox.yBottom + rclBox.yTop) / 2;
  1523.                 WinSetPointer(HWND_DESKTOP,
  1524.                    WinQuerySysPointer(
  1525.                        HWND_DESKTOP,
  1526.                        (ptlMouse.x * ptlMouse.y > 0) ? SPTR_SIZENESW : SPTR_SIZENWSE,
  1527.                        FALSE));
  1528.                 handled = kODTrue;
  1529.              }
  1530.              else if (GpiPtInRegion(_hpsMem, _fEdgeHandleRgn, &ptlMouse) == PRGN_INSIDE)
  1531.              {
  1532.                 GpiQueryRegionBox(_hpsMem, _fCornerHandleRgn, &rclBox);
  1533.                 ptlMouse.x -= (rclBox.xLeft + rclBox.xRight) / 2;
  1534.                 ptlMouse.y -= (rclBox.yBottom + rclBox.yTop) / 2;
  1535.                 WinSetPointer(HWND_DESKTOP,
  1536.                    WinQuerySysPointer(
  1537.                        HWND_DESKTOP,
  1538.                        (abs(ptlMouse.x) > abs(ptlMouse.y)) ? SPTR_SIZEWE : SPTR_SIZENS,
  1539.                        FALSE));
  1540.                 handled = kODTrue;
  1541.              }
  1542.              else if (GpiPtInRegion(_hpsMem, _fSelectRgn, &ptlMouse) == PRGN_INSIDE)
  1543.              {
  1544.                 WinSetPointer(HWND_DESKTOP,
  1545.                    WinQuerySysPointer( HWND_DESKTOP, SPTR_MOVE, FALSE));
  1546.                 handled = kODTrue;
  1547.              }
  1548.           }
  1549.        }
  1550.        return handled;
  1551.    }
  1552. #endif
  1553.  
  1554.  
  1555.    SOM_Scope void SOMLINK ContainerPartUpdateTrackRect(ContainerPart *somSelf,
  1556.                                                           Environment *ev,
  1557.                                                           POINTL* pptlMouse,
  1558.                                                           ODPlatformWindow hwnd)
  1559.    {
  1560.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1561.        ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateTrackRect");
  1562.  
  1563.        HRGN hrgnOld;
  1564.        HPS hps = WinGetClipPS(hwnd, 0, PSF_LOCKWINDOWUPDATE);
  1565.        GpiSetClipRegion(hps, _hrgnTrackingClip, &hrgnOld);
  1566.        GpiSetMix(hps, FM_INVERT);
  1567.        GpiMove(hps, &_ptlOrigin);
  1568.        GpiBox(hps, DRO_OUTLINE, &_ptlEnd, 0, 0);
  1569.        GpiMove(hps, &_ptlOrigin);
  1570.        GpiBox(hps, DRO_OUTLINE, pptlMouse, 0, 0);
  1571.        GpiSetClipRegion(hps, 0, &hrgnOld);
  1572.        WinReleasePS(hps);
  1573.    }
  1574.  
  1575.    SOM_Scope void SOMLINK ContainerPartMouseFocusLost(ContainerPart *somSelf,
  1576.                                                        Environment *ev,
  1577.                                                        ODFrame* ownerFrame)
  1578.    {
  1579.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1580.        ContainerPartMethodDebug("ContainerPart","ContainerPartMouseFocusLost");
  1581.  
  1582.        HWND hwndFrame = ownerFrame->GetWindow(ev)->GetPlatformWindow(ev);
  1583.        HWND hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
  1584.        somSelf->UpdateTrackRect(ev, &_ptlOrigin, hwndClient);
  1585.        _fTracking = kODFalse;
  1586.        if (_hrgnTrackingClip)
  1587.        {
  1588.           GpiDestroyRegion(_hpsMem, _hrgnTrackingClip);
  1589.          _hrgnTrackingClip = 0;
  1590.        }
  1591.        if (WinQueryCapture(HWND_DESKTOP) == hwndClient)
  1592.          WinSetCapture(HWND_DESKTOP, 0);
  1593.  
  1594.        WinLockWindowUpdate(HWND_DESKTOP, 0);
  1595.    }
  1596.  
  1597. //------------------------------------------------------------------------------
  1598. // Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING
  1599. //------------------------------------------------------------------------------
  1600. typedef struct {
  1601.   USHORT size, dummy;
  1602.   PSZ    szQueue;
  1603. } PRNDLGINFO , *PPRNDLGINFO;
  1604.  
  1605. #define PRINT_QUEUE_LENGTH 100
  1606.  
  1607.  
  1608. ULONG _System ViewPrintGetQueue( HWND hwnd, PSZ szQueue) { NOTDONE2("ViewPrintGetQueue"); return 0; };
  1609. #if 0
  1610.    ULONG _System ViewPrintGetQueue( HWND hwnd, PSZ szQueue)
  1611.    { ULONG rc=0;
  1612.      //HWND  hwnd = FrameToWindow( frame, fSession );
  1613.      if (hwnd) {
  1614.        PRNDLGINFO pdi;
  1615.        HMODULE hmod = 0;
  1616.        DosQueryModuleHandle( THISDLL, &hmod);
  1617.        pdi.size = sizeof(PRNDLGINFO);
  1618.        pdi.szQueue = szQueue;
  1619.        rc = WinDlgBox( HWND_DESKTOP, hwnd,
  1620.                        ViewPrintDefDlgProc, hmod, ID_PRINT, &pdi ) ? 0 : 1;
  1621.      } else {
  1622.        rc = ViewPrintGetDefQueue( szQueue );
  1623.      } /* endif */
  1624.      return(rc);
  1625.    }
  1626. #endif
  1627.  
  1628. static HDC _Optlink printer_HDC( PSZ szQueue ) { return (HDC)0; NOTDONE2("printer_HDC"); };
  1629. #if 0
  1630.    static HDC _Optlink printer_HDC( PSZ szQueue )
  1631.    {
  1632.      HDC          hdc;
  1633.      PPRQINFO3    prq;                    // pointer to PRQINFO3 struct
  1634.      DEVOPENSTRUC DevData;                // Printer DevOpen
  1635.      CHAR         szDDName[81];           // Buffer for driver full name
  1636.  
  1637.      if ( (prq = QueueInfoBlock(szQueue)) != NULL ) {
  1638.        StrToken( szDDName, prq->pszDriverName, '.', 1 );
  1639.        DevData.pszQueueProcName  = prq->pszPrProc;          // pick up PMPLOT!!
  1640.        DevData.pdriv = prq->pDriverData;
  1641.      } else {
  1642.        szDDName[0] = '\0';
  1643.        DevData.pszQueueProcName = NULL;
  1644.        DevData.pdriv = NULL;
  1645.      } /* endif */
  1646.  
  1647.      DevData.pszLogAddress      = szQueue   ;
  1648.      DevData.pszDriverName      = szDDName  ;
  1649.      DevData.pszDataType        = "PM_Q_STD";
  1650.      DevData.pszComment         = "OpenDoc";
  1651.      DevData.pszQueueProcParams = "COL=C"   ;
  1652.      DevData.pszSpoolerParams   = NULL      ;
  1653.      DevData.pszNetworkParams   = NULL      ;
  1654.  
  1655.      hdc = DevOpenDC( (HAB)0, OD_QUEUED, "*", 9L,
  1656.                       (PDEVOPENDATA)&DevData, (HDC)NULL );
  1657.  
  1658.      if ( prq ) delete prq;
  1659.      return hdc;
  1660.    }
  1661. #endif
  1662.  
  1663. #if 1
  1664.    SOM_Scope ODBoolean  SOMLINK ContainerPartHandlePrinting(ContainerPart *somSelf,
  1665.                                                 Environment *ev,
  1666.                                                ODFrame* frame)
  1667.    {
  1668.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1669.        ContainerPartMethodDebug("ContainerPart","ContainerPartHandlePrinting");
  1670.  
  1671.        ULONG   rc=0;
  1672.        SIZEL   szlPrn;
  1673.        PRNINFO PI;
  1674.        CHAR    szQueue[PRINT_QUEUE_LENGTH];
  1675.        //LogFlow(C_ENTER, ("ViewPrint: self=%p, options=%#X", (PVOID)somSelf, flOptions));
  1676.        if (somThis) {
  1677.          memset(&PI,0,sizeof(PRNINFO));
  1678.          rc = ViewPrintGetQueue( frame->GetWindow( ev)->GetPlatformWindow( ev), szQueue );
  1679.          if (!rc) {
  1680.             PI.hdc = printer_HDC(szQueue);
  1681.             if (PI.hdc) {
  1682.                szlPrn.cx = szlPrn.cy = 0;
  1683.                PI.hps = GpiCreatePS( (HAB)0, PI.hdc, &szlPrn,
  1684.                                      /*PU_TWIPS*/ PU_PELS | GPIT_NORMAL | GPIA_ASSOC );
  1685.                if (PI.hps) {
  1686.                   GpiQueryPS( PI.hps, &szlPrn );
  1687.                } else {
  1688.                   rc=2;                              // get hps failure
  1689.                } /* endif */
  1690.             } else {
  1691.                rc=1;                                 // get hdc failure
  1692.             } /* endif */
  1693.          } /* endif */
  1694.          if ( !rc ) {
  1695.            // STARTDOC
  1696.            if ( DevEscape( PI.hdc, DEVESC_STARTDOC,
  1697.                            (LONG)strlen("test"), "test", NULL, NULL ) == DEV_OK ) {
  1698.              // set up bounds
  1699.              PI.bounds.xLeft = PI.bounds.yBottom =  0;
  1700.              PI.bounds.xRight = szlPrn.cx-1;
  1701.              PI.bounds.yTop = szlPrn.cy-1;
  1702.              PI.pagenum = 1;
  1703.              //PI.somMaster = somSelf;
  1704.              rc = somSelf->PrintPages( ev, frame, &PI );
  1705.              DevEscape( PI.hdc, DEVESC_ENDDOC, 0, NULL, NULL, NULL );
  1706.              #if 0
  1707.                 if (!rc) {
  1708.                   HWND hwnd = /*_ViewQueryWindow()*/ frame->GetWindow( ev)->GetPlatformWindow( ev);
  1709.                   if (hwnd) {
  1710.                     CHAR szInfo[80];
  1711.                     sprintf(szInfo, "Error printing to %s, page %d", szQueue, PI.pagenum );
  1712.                     WinMessageBox( HWND_DESKTOP, hwnd, szInfo,
  1713.                                   "OpenDoc container part printing", 0, MB_OK | MB_MOVEABLE);
  1714.                   } /* endif */
  1715.                 } /* endif */
  1716.              #endif
  1717.            } else {
  1718.              rc=3;                                 // STARTDOC failure
  1719.            } /* endif */
  1720.          } /* endif */
  1721.          if (PI.hps) {
  1722.             GpiDestroyPS( PI.hps );
  1723.          } /* endif */
  1724.          if (PI.hdc) {
  1725.             DevCloseDC( PI.hdc );
  1726.          } /* endif */
  1727.        } else {
  1728.          rc=4;                                     // NULL somSelf
  1729.        } /* endif */
  1730.  
  1731.        return kODTrue;
  1732.    }
  1733.  
  1734.    SOM_Scope ODFacet*  SOMLINK ContainerPartBeginPrinting(ContainerPart *somSelf,
  1735.                                               Environment *ev, ODFrame* rootFrame,
  1736.                                              PRNINFO* pPI)
  1737.    {
  1738.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1739.        ContainerPartMethodDebug("ContainerPart","ContainerPartBeginPrinting");
  1740.  
  1741.        ODTransform* xtransform = new ODTransform;
  1742.  
  1743.        ODShape* clipshape = new ODShape;
  1744.        ODRect cliprect(downcastToODRECTL(pPI->bounds));
  1745.  
  1746.        clipshape->SetRectangle(ev, &cliprect);
  1747.  
  1748.        ODCanvas* prCanvas = new ODCanvas;
  1749.        prCanvas->InitCanvas(ev, kODGPI, (ODPlatformCanvas)pPI->hps, kODFalse, kODFalse);
  1750.  
  1751.        ODFacet* prFacet = new ODFacet;
  1752.        prFacet->InitFacet(ev, rootFrame, clipshape, xtransform, /*(rootpart)*/kODNULL);
  1753.        prFacet->SetCanvas(ev, prCanvas);  // jys says this should go before InitFacet, as soon
  1754.                                       //   as we have facet windows.  Right now, this remains
  1755.                                       //   here because it traps if moved.
  1756.  
  1757.  
  1758.        rootFrame->FacetAdded(ev, prFacet);
  1759.  
  1760.        return prFacet;
  1761.    }
  1762.  
  1763.    SOM_Scope void  SOMLINK ContainerPartPrintPage(ContainerPart *somSelf,  Environment *ev,
  1764.                                      ODFacet* prFacet, ODUShort pagenum,
  1765.                                      PRNINFO* pPI)
  1766.    {
  1767.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1768.        ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPage");
  1769.  
  1770.        ODRect bbox;
  1771.  
  1772.        prFacet->GetFrame(ev)->GetFrameShape(ev)->GetBoundingBox(ev, &bbox);
  1773.        ODRECTL frect = bbox;
  1774.  
  1775.        ODULong height = bbox.top;
  1776.        ODULong width  = bbox.right;
  1777.  
  1778.        ODPoint    pt = {0,0};
  1779.        ODUShort   locator = pagenum-1;
  1780.  
  1781.        int height_in_pages = 1 + ((bbox.top-1) / (pPI->bounds.yTop));
  1782.        pt.y =  height - (1 + (locator % height_in_pages)) * pPI->bounds.yTop;
  1783.        pt.x =  (locator / height_in_pages)    * pPI->bounds.xRight;
  1784.  
  1785.        ODTransform* xtransform = new ODTransform;
  1786.  
  1787.        xtransform->MoveBy(ev, &pt);
  1788.  
  1789.        //Rect pagerect = (**fPrintRecord).prInfo.rPage;
  1790.  
  1791.        ODShape* clipshape = new ODShape;
  1792.        ODShape* invalshape = new ODShape;
  1793.        ODRect cliprect(downcastToODRECTL(pPI->bounds));
  1794.  
  1795.        clipshape->SetRectangle(ev, &cliprect);
  1796.        invalshape->CopyFrom(ev, clipshape);
  1797.        clipshape->Transform(ev, xtransform);
  1798.        xtransform->Invert(ev);
  1799.        prFacet->ChangeGeometry(ev, clipshape, xtransform);
  1800.  
  1801.        prFacet->Update(ev, invalshape);
  1802.    }
  1803.  
  1804.    SOM_Scope long  SOMLINK ContainerPartPrintPages(ContainerPart *somSelf,
  1805.                                                     Environment *ev,
  1806.                                                    ODFrame* frame,
  1807.                                                    PRNINFO* pPI)
  1808.    {
  1809.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1810.        ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPages");
  1811.  
  1812.        #if 1
  1813.           NOTDONE2("PrintPages");  // uncomment code and pick up partner functions from
  1814.                       //   old .cpp file when get time.
  1815.           return 0;
  1816.        #else
  1817.           ODUShort
  1818.                    firstPage,
  1819.                    lastPage,
  1820.                    realNumberOfPagesinDoc,
  1821.                    pageNumber;
  1822.           ODFacet*   prFacet;
  1823.  
  1824.           if (1/*PrError() == noErr*/)
  1825.           {
  1826.              realNumberOfPagesinDoc = DetermineNumberOfPagesinDoc(frame, pPI->bounds );
  1827.  
  1828.              //numberOfCopies = 1;
  1829.  
  1830.              firstPage = 1/*(**fPrintRecord).prJob.iFstPage*/;
  1831.              lastPage = realNumberOfPagesinDoc/*(**fPrintRecord).prJob.iLstPage*/;
  1832.  
  1833.              if (realNumberOfPagesinDoc < lastPage)
  1834.                 lastPage = realNumberOfPagesinDoc;
  1835.  
  1836.              //for (copies = 1; copies <= numberOfCopies; copies++)
  1837.              {
  1838.  
  1839.                 if (1/*PrError() == noErr*/)
  1840.                 {
  1841.                    TRY
  1842.                       prFacet = this->BeginPrinting(frame, pPI);
  1843.                       THROW_IF_NULL(prFacet);
  1844.  
  1845.                       pageNumber = firstPage;
  1846.                       while (pageNumber <= lastPage /*&& PrError() == noErr*/)
  1847.                       {
  1848.                          LONG lOut=0;
  1849.                          LONG rc = 0;
  1850.                          this->PrintPage(prFacet, pageNumber, pPI);
  1851.                          if (DevEscape( pPI->hdc, DEVESC_NEWFRAME,
  1852.                                       0, NULL, &lOut, (PBYTE)&rc ) != DEVESC_ERROR ) {
  1853.                             // no particular action
  1854.                          }
  1855.                          pageNumber++;
  1856.                       }
  1857.  
  1858.                       this->EndPrinting(prFacet);
  1859.                    CATCH_ALL
  1860.                       // garbage collection needs to be improved
  1861.                    ENDTRY
  1862.  
  1863.                 }
  1864.              }
  1865.           }
  1866.  
  1867.           return 0; // no error
  1868.        #endif
  1869.    }
  1870.  
  1871.    SOM_Scope void  SOMLINK ContainerPartEndPrinting(ContainerPart *somSelf,  Environment *ev,
  1872.                                        ODFacet* prFacet)
  1873.    {
  1874.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1875.        ContainerPartMethodDebug("ContainerPart","ContainerPartEndPrinting");
  1876.  
  1877.        ODCanvas* prCanvas = prFacet->GetCanvas(ev);
  1878.  
  1879.        prFacet->GetFrame(ev)->FacetRemoved(ev, prFacet);
  1880.  
  1881.        delete prCanvas;
  1882.        delete prFacet;
  1883.    }
  1884.  
  1885.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoCut(ContainerPart *somSelf,  Environment *ev,
  1886.                                       ODFrame* frame)
  1887.    {
  1888.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1889.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoCut");
  1890.  
  1891.        NOTDONE2("DoCut");
  1892.        return kODFalse;
  1893.    }
  1894.  
  1895.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoCopy(ContainerPart *somSelf,  Environment *ev,
  1896.                                        ODFrame* frame)
  1897.    {
  1898.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1899.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoCopy");
  1900.  
  1901.        NOTDONE2("DoCopy");
  1902.        return kODFalse;
  1903.    }
  1904.  
  1905.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoPaste(ContainerPart *somSelf,
  1906.                                          Environment *ev, ODFrame* frame)
  1907.    {
  1908.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1909.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoPaste");
  1910.  
  1911.        NOTDONE2("DoPaste");
  1912.        return kODFalse;
  1913.    }
  1914.  
  1915.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoPasteLink(ContainerPart *somSelf,
  1916.                                              Environment *ev, ODFrame* frame)
  1917.    {
  1918.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1919.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoPasteLink");
  1920.  
  1921.        NOTDONE2("DoPasteLink");
  1922.        return kODFalse;
  1923.    }
  1924.  
  1925.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoClear(ContainerPart *somSelf,
  1926.                                          Environment *ev, ODFrame* frame)
  1927.    {
  1928.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1929.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoClear");
  1930.  
  1931.        Proxy* p;
  1932.        ODxOrderedCollectionIterator i(_fSelection);
  1933.        for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1934.        {
  1935.           p->frame->Invalidate(ev, NULL);
  1936.  
  1937.           /* Make a copy of the frame's facet collection so that we can  */
  1938.           /* iterate through the copy.  The reason for this is that when */
  1939.           /* we call RemoveFacet, the facet is removed from the frame's  */
  1940.           /* collection of facet's thereby invalidating the iterator     */
  1941.           /* cursor.  By iterating through the copy collection, we avoid */
  1942.           /* this side effect.                                           */
  1943.  
  1944.           ODxOrderedCollection* tempFacets = new ODxOrderedCollection;
  1945.  
  1946.           ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  1947.           for (ODFacet* f1 = facets->First(ev);
  1948.                 facets->IsNotComplete(ev);
  1949.                 f1 = facets->Next(ev))
  1950.           {
  1951.              tempFacets->AddLast(f1);
  1952.           }
  1953.           delete facets;
  1954.  
  1955.           ODxOrderedCollectionIterator t(tempFacets);
  1956.           for (ODFacet* f2 = (ODFacet*)t.First();
  1957.                 t.IsNotComplete();
  1958.                 f2 = (ODFacet*)t.Next())
  1959.           {
  1960.              f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
  1961.              ODDeleteObject(f2);
  1962.           }
  1963.           delete tempFacets;
  1964.           somSelf->RemoveEmbeddedFrame(ev, p->frame);
  1965.        }
  1966.        somSelf->InvalidateSelection(ev, frame);
  1967.        somSelf->EmptySelection(ev);
  1968.        somSelf->ClipEmbeddedFrames(ev, frame);
  1969.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  1970.        return kODTrue;
  1971.    }
  1972.  
  1973.    SOM_Scope ODBoolean  SOMLINK ContainerPartDoSelectAll(ContainerPart *somSelf,
  1974.                                              Environment *ev, ODFrame* frame)
  1975.    {
  1976.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1977.        ContainerPartMethodDebug("ContainerPart","ContainerPartDoSelectAll");
  1978.  
  1979.        NOTDONE2("DoSelectAll");
  1980.        return kODFalse;
  1981.    }
  1982.  
  1983.    SOM_Scope void  SOMLINK ContainerPartActivateFrame(ContainerPart *somSelf,
  1984.                                           Environment *ev, ODFrame* frame)
  1985.    {
  1986.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1987.        ContainerPartMethodDebug("ContainerPart","ContainerPartActivateFrame");
  1988.  
  1989.        if (frame != kODNULL) {
  1990.           PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  1991.           if (!(pInfo->fIsActive))
  1992.           {
  1993.             ODBoolean succeeded = false;
  1994.  
  1995.             succeeded = _fSession->GetArbitrator(ev)->RequestFocusSet(ev, _fFocusSet,frame);
  1996.  
  1997.             if (succeeded)
  1998.             {
  1999.                somSelf->FocusAcquired(ev, _fSelectionFocus, frame);
  2000.                somSelf->FocusAcquired(ev, _fMenuFocus, frame);
  2001.                somSelf->FocusAcquired(ev, _fKeyFocus, frame);
  2002.             }
  2003.           }
  2004.        }
  2005.    }
  2006.  
  2007.    SOM_Scope void  SOMLINK ContainerPartDeActivateFrame(ContainerPart *somSelf,
  2008.                                             Environment *ev, ODFrame* frame)
  2009.    {
  2010.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2011.        ContainerPartMethodDebug("ContainerPart","ContainerPartDeActivateFrame");
  2012.  
  2013.        if (frame != kODNULL) {
  2014.           _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame);
  2015.           somSelf->FocusLost(ev, _fSelectionFocus, frame);
  2016.           somSelf->FocusLost(ev, _fMenuFocus, frame);
  2017.           somSelf->FocusLost(ev, _fKeyFocus, frame);
  2018.        }
  2019.    }
  2020.  
  2021.    SOM_Scope void  SOMLINK ContainerPartActivatingWindow(ContainerPart *somSelf,
  2022.                                              Environment *ev, ODFrame* frame)
  2023.    {
  2024.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2025.        ContainerPartMethodDebug("ContainerPart","ContainerPartActivatingWindow");
  2026.  
  2027.        PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  2028.        if (pInfo->fNeedsActivating)
  2029.        {
  2030.           somSelf->ActivateFrame(ev, frame);
  2031.           //somSelf->ShowPalette(ev);
  2032.           pInfo->fNeedsActivating = kODFalse;
  2033.        }
  2034.    }
  2035.  
  2036.    SOM_Scope void  SOMLINK ContainerPartDeActivatingWindow(ContainerPart *somSelf,
  2037.                                                Environment *ev,
  2038.                                               ODFrame* frame)
  2039.    {
  2040.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2041.        ContainerPartMethodDebug("ContainerPart","ContainerPartDeActivatingWindow");
  2042.  
  2043.        PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  2044.        if (frame == _fSession->GetArbitrator(ev)->GetFocusOwner(ev, _fSelectionFocus))
  2045.        {
  2046.           pInfo->fNeedsActivating = kODTrue;
  2047.           if (_fTracking)
  2048.           {
  2049.             _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, frame);
  2050.             somSelf->FocusLost(ev, _fMouseFocus, frame);
  2051.           }
  2052.           //somSelf->DeActivateFrame(ev, frame);
  2053.        }
  2054.        else
  2055.           pInfo->fNeedsActivating = kODFalse;
  2056.    }
  2057.  
  2058.  
  2059.    int ExtractMenuPartStrings( char * fullstring , char * * dllstring , int * dllstringlength , char * * descripstring );
  2060.    #if 1
  2061.       int ExtractMenuPartStrings( char * fullstring
  2062.                                                 , char * * dllstring
  2063.                                                 , int * dllstringlength
  2064.                                                 , char * * descripstring
  2065.                                                 )
  2066.       {
  2067.          char * tempstr = fullstring;
  2068.          while ((*tempstr) && (tempstr[0]==' ')) tempstr++;
  2069.          if (!*tempstr) return 1;  // skip this line. has no contents
  2070.          *dllstring = tempstr;
  2071.          tempstr = strchr(tempstr, ' ' );
  2072.          if (tempstr) {
  2073.             *dllstringlength = tempstr - *dllstring;
  2074.             while ((*tempstr) && (tempstr[0]==' ')) tempstr++;
  2075.             if (*tempstr) {
  2076.                *descripstring = tempstr;
  2077.             } else {
  2078.                *descripstring = *dllstring;
  2079.             } /* endif */
  2080.          } else {
  2081.             *descripstring = *dllstring;
  2082.             *dllstringlength = strlen(*dllstring);
  2083.          } /* endif */
  2084.          return 0;
  2085.       }
  2086.    #endif
  2087.  
  2088.    void CollectHandlers( Environment *ev, ODSession * pSession );
  2089.    #if 1
  2090.       void CollectHandlers( Environment *ev, ODSession * pSession )
  2091.       {
  2092.          if (!mbPartHandlers) {
  2093.             ODMenuBar * mbNew = new ODMenuBar;
  2094.             mbNew->InitMenuBar(ev, pSession, 0);
  2095.             FILE* partsFile = fopen("parts.dat", "r");
  2096.             char inbuf[60];
  2097.             ODPlatformMenuItem mi;
  2098.             mi.afAttribute = 0;
  2099.             mi.afStyle = MIS_TEXT;
  2100.             mi.hwndSubMenu = 0;
  2101.  
  2102.             for( int i = 0; i < cODMaxEmbedParts
  2103.                             && fgets( inbuf, sizeof(inbuf), partsFile); i++)
  2104.             {
  2105.                char *ptr;
  2106.                char *dllstring;
  2107.                char *descripstring;
  2108.                int  dllslen;
  2109.                if(ptr = strchr(inbuf, '\n')) *ptr = '\0';
  2110.                int rc = ExtractMenuPartStrings( inbuf
  2111.                                            , &dllstring
  2112.                                            , &dllslen
  2113.                                            , &descripstring
  2114.                                            );
  2115.                if (rc) {
  2116.                   i--;  // skip this one bogus entry
  2117.                } else {
  2118.                   dllstring[dllslen] = 0;
  2119.                   strcpy( partStrings[i], dllstring);
  2120.                   mi.id = i+IDMA_EMBED_BASE+1;
  2121.                   mi.hItem = (ULONG)descripstring;
  2122.                   mbNew->AddItemLast( ev, &mi, ODMENUID_ROOT );
  2123.                } /* endif */
  2124.             } /* endif */
  2125.             fclose(partsFile);
  2126.             mbPartHandlers = mbNew;
  2127.          } /* endif */
  2128.       }
  2129.    #endif
  2130.  
  2131.    SOM_Scope void  SOMLINK ContainerPartInstallMenus(ContainerPart *somSelf,
  2132.                                          Environment *ev, ODFrame* aFrame)
  2133.    {
  2134.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2135.        ContainerPartMethodDebug("ContainerPart","ContainerPartInstallMenus");
  2136.  
  2137.        #if 1
  2138.           #ifdef _PLATFORM_OS2_
  2139.              ODActiveFrameMenuBar * mb = new ODActiveFrameMenuBar;
  2140.              mb->InitMenuBar( ev, _fSession, kODNULL);
  2141.              mb->SetOwner( ev, aFrame );
  2142.  
  2143.              #ifdef USE_PARTINFO_TO_RECALL_AMENU
  2144.                 PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
  2145.                 if (!pInfo)
  2146.                 {  pInfo = new PartInfoRec;
  2147.                   aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  2148.                 }
  2149.                 pInfo->mbActive = mb;
  2150.              #endif
  2151.  
  2152.              ODWindow * window = aFrame->GetWindow( ev);
  2153.              window->SetMenuBar( ev, mb );
  2154.              mb->Release(ev);  // when SetMenuBar is called again, it will be deleted
  2155.           #else
  2156.              if (aFrame && _fMenuBar)
  2157.                _fMenuBar->Display(ev);
  2158.           #endif
  2159.        #endif
  2160.    }
  2161.  
  2162.    SOM_Scope void  SOMLINK ContainerPartRemoveMenus(ContainerPart *somSelf,  Environment *ev,
  2163.                                        ODFrame* aFrame)
  2164.    {
  2165.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2166.        ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveMenus");
  2167.  
  2168.        #ifdef _PLATFORM_OS2_
  2169.           ODWindow * window = aFrame->GetWindow( ev);
  2170.           window->SetMenuBar(ev,  0 );
  2171.           PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
  2172.           pInfo->mbActive = 0;
  2173.        #endif
  2174.    }
  2175.  
  2176.    SOM_Scope void  SOMLINK ContainerPartUserSetBGColor(ContainerPart *somSelf,
  2177.                                            Environment *ev, ODFrame* frame,
  2178.                                           RGBColor whichColor)
  2179.    {
  2180.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2181.        ContainerPartMethodDebug("ContainerPart","ContainerPartUserSetBGColor");
  2182.  
  2183.        PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  2184.        if (!pInfo)
  2185.        {  pInfo = new PartInfoRec;
  2186.          frame->SetPartInfo(ev, (ODInfoType) pInfo);
  2187.        }
  2188.        if (whichColor != pInfo->bgColor)
  2189.        {
  2190.          ODIText*  undoActionName;
  2191.          ODIText*  redoActionName;
  2192.  
  2193.          undoActionName = PStrToIntl("Undo Set Color", kODNULL );
  2194.          redoActionName = PStrToIntl("Redo Set Color", kODNULL );
  2195.          SetBGColorRec* undoRec = new SetBGColorRec(pInfo->bgColor, whichColor,
  2196.                                frame);
  2197.      #ifndef UNDONEEDSFIXINMAYBE
  2198.          _fSession->GetUndo(ev)->AddActionToHistory(ev, somSelf, (ODActionData)undoRec,
  2199.                              kODSingleAction,
  2200.                              (ODName*)undoActionName,
  2201.                              (ODName*)redoActionName);
  2202.      #endif
  2203.          somSelf->SetBGColor2(ev, frame, whichColor);
  2204.        }
  2205.    }
  2206.  
  2207.    RGBColor RGBColorFromMenuColor( ODUShort whichColor )
  2208.    {
  2209.        switch (whichColor)
  2210.        {
  2211.          case  IDMA_COLOR_GRAY   : return  CLR_DARKGRAY  ; break;
  2212.          case  IDMA_COLOR_RED    : return  CLR_RED       ; break;
  2213.          case  IDMA_COLOR_GREEN  : return  CLR_GREEN     ; break;
  2214.          case  IDMA_COLOR_YELLOW : return  CLR_YELLOW    ; break;
  2215.          case  IDMA_COLOR_BLUE   : return  CLR_BLUE      ; break;
  2216.          case  IDMA_COLOR_MAGENTA: return  CLR_DARKPINK  ; break;
  2217.          case  IDMA_COLOR_CYAN   : return  CLR_CYAN      ; break;
  2218.          case  IDMA_COLOR_WHITE  : return  CLR_WHITE     ; break;
  2219.          default: break;
  2220.        }
  2221.        return  CLR_PINK;
  2222.    }
  2223.  
  2224.    ODUShort MenuColorFromRGBColor( RGBColor inColor )
  2225.    {
  2226.        switch (inColor)
  2227.        {
  2228.          case  CLR_DARKGRAY  : return  IDMA_COLOR_GRAY   ; break;
  2229.          case  CLR_RED       : return  IDMA_COLOR_RED    ; break;
  2230.          case  CLR_GREEN     : return  IDMA_COLOR_GREEN  ; break;
  2231.          case  CLR_YELLOW    : return  IDMA_COLOR_YELLOW ; break;
  2232.          case  CLR_BLUE      : return  IDMA_COLOR_BLUE   ; break;
  2233.          case  CLR_DARKPINK  : return  IDMA_COLOR_MAGENTA; break;
  2234.          case  CLR_CYAN      : return  IDMA_COLOR_CYAN   ; break;
  2235.          case  CLR_WHITE     : return  IDMA_COLOR_WHITE  ; break;
  2236.          default: break;
  2237.        }
  2238.        return IDMA_COLOR_GRAY;
  2239.    }
  2240.  
  2241.    SOM_Scope void  SOMLINK ContainerPartSetBGColor1(ContainerPart *somSelf,  Environment *ev,
  2242.                                        ODFrame* aFrame, ODUShort whichColor)
  2243.    {
  2244.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2245.        ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor1");
  2246.  
  2247.        PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
  2248.        if (!pInfo)
  2249.        {  pInfo = new PartInfoRec;
  2250.          aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  2251.        };
  2252.  
  2253.        //RGBColor newColor = pInfo->bgColor;
  2254.        RGBColor newColor = RGBColorFromMenuColor( whichColor );
  2255.  
  2256.        //switch (whichColor)
  2257.        //{
  2258.        //  case  IDMA_COLOR_GRAY   : newColor = CLR_DARKGRAY  ; break;
  2259.        //  case  IDMA_COLOR_RED    : newColor = CLR_RED       ; break;
  2260.        //  case  IDMA_COLOR_GREEN  : newColor = CLR_GREEN     ; break;
  2261.        //  case  IDMA_COLOR_YELLOW : newColor = CLR_YELLOW    ; break;
  2262.        //  case  IDMA_COLOR_BLUE   : newColor = CLR_BLUE      ; break;
  2263.        //  case  IDMA_COLOR_MAGENTA: newColor = CLR_DARKPINK  ; break;
  2264.        //  case  IDMA_COLOR_CYAN   : newColor = CLR_CYAN      ; break;
  2265.        //  case  IDMA_COLOR_WHITE  : newColor = CLR_WHITE     ; break;
  2266.        //  default: break;
  2267.        //}
  2268.        somSelf->UserSetBGColor(ev, aFrame,newColor);
  2269.    }
  2270.  
  2271.    SOM_Scope void  SOMLINK ContainerPartSetBGColor2(ContainerPart *somSelf,  Environment *ev,
  2272.                                        ODFrame* aFrame, RGBColor whichColor)
  2273.    {
  2274.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2275.        ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor2");
  2276.  
  2277.        PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
  2278.        if (!pInfo)
  2279.        {  pInfo = new PartInfoRec;
  2280.          aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  2281.        }
  2282.        if (whichColor != pInfo->bgColor)
  2283.        {
  2284.          pInfo->bgColor = whichColor;
  2285.          somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2286.          aFrame->Invalidate(ev, NULL);
  2287.        }
  2288.    }
  2289.  
  2290.    SOM_Scope void  SOMLINK ContainerPartEmbed(ContainerPart *somSelf,  Environment *ev,
  2291.                                  short item, ODFrame* frame, ODPart** newPart)
  2292.    {
  2293.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2294.        ContainerPartMethodDebug("ContainerPart","ContainerPartEmbed");
  2295.  
  2296.        ODPart* embeddedPart;
  2297.        ODFrame* embeddedFrame;
  2298.        ODTransform* externalXForm = new ODTransform;
  2299.        ODSLong count = 1 + _fContents->Count();
  2300.  
  2301.        ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  2302.  
  2303.        #if 1
  2304.           #ifdef _PLATFORM_OS2_
  2305.              embeddedPart = su->GetDraft(ev)->CreatePart(ev, partStrings[item - (IDMA_EMBED_BASE+1)], kODNULL);
  2306.              if(!embeddedPart) {
  2307.                 //<crs>-12/01/94-display messagebox on error 
  2308.                 // print error message and return if unable to load dll
  2309.                 char errmsg[100];
  2310.                 sprintf(errmsg, "Unable to load module for %s, verify DLL exists and retry!",
  2311.                          partStrings[item - (IDMA_EMBED_BASE+1)] );
  2312.                 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, errmsg, "Error Information", 0, MB_ERROR | MB_OK);
  2313.                 delete externalXForm;
  2314.                 return;
  2315.              }
  2316.           #else
  2317.              switch (item)
  2318.              {
  2319.                case 1:
  2320.                  embeddedPart = su->GetDraft(ev)->CreatePart(ev, kODPartDrawPart,kODNULL);
  2321.                  break;
  2322.                case 2:
  2323.                  embeddedPart = su->GetDraft(ev)->CreatePart(ev, kODPartDragPart,kODNULL);
  2324.                  break;
  2325.                case 3:
  2326.                  embeddedPart = su->GetDraft(ev)->CreatePart(ev, kODPartClockPart,kODNULL);
  2327.                  break;
  2328.                default:
  2329.                  break;
  2330.              }
  2331.           #endif
  2332.  
  2333.           //Point ptTemp;
  2334.           //SetPt(&ptTemp,(short)(count*20),(short)(count*20));
  2335.           #if 0
  2336.              Point ptTemp = {(count*20),(count*20)};
  2337.              externalXForm->SetQDOffset(ev, &ptTemp);
  2338.           #else
  2339.              ODPoint ptTemp = {MAKEFIXED(count*20,0),MAKEFIXED(count*20,0)};
  2340.              externalXForm->SetOffset(ev, &ptTemp);
  2341.           #endif
  2342.           embeddedFrame = somSelf->MakeEmbeddedFrame(ev, frame,
  2343.                                  NULL,
  2344.                                  externalXForm,
  2345.                                  embeddedPart,
  2346.                                  kODFalse);
  2347.  
  2348.           ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  2349.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev);
  2350.               facet = facets->Next(ev))
  2351.           {
  2352.             ODShape* clip = new ODShape;
  2353.             clip->CopyFrom(ev, embeddedFrame->GetFrameShape(ev));
  2354.             ODTransform* xform = new ODTransform;
  2355.             xform->CopyFrom(ev, somSelf->ProxyForFrame(ev, embeddedFrame)->transform);
  2356.             facet->CreateEmbeddedFacet(ev, embeddedFrame, clip, xform, kODNULL, kODFrameInFront);
  2357.           }
  2358.           delete facets;
  2359.           somSelf->ClipEmbeddedFrames(ev, frame);
  2360.           frame->Invalidate(ev, NULL);
  2361.  
  2362.           if (newPart)
  2363.             *newPart = embeddedPart;
  2364.           else
  2365.             ODReleaseObject(ev,embeddedPart);
  2366.        #endif
  2367.    }
  2368.  
  2369.    SOM_Scope void  SOMLINK ContainerPartSetGrafPortOrigin(ContainerPart *somSelf,
  2370.                                               Environment *ev, ODFacet* facet)
  2371.    {
  2372.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2373.        ContainerPartMethodDebug("ContainerPart","ContainerPartSetGrafPortOrigin");
  2374.  
  2375.        #ifdef _PLATFORM_OS2_
  2376.           ODTransform* localToGlobal = facet->GetContentTransform(ev);
  2377.           HPS hps = facet->GetCanvas(ev)->GetPlatformCanvas(ev);
  2378.           MATRIXLF mtx;
  2379.           facet->GetContentTransform(ev)->GetMATRIXLF(ev, &mtx);
  2380.  
  2381.             #if 0 // debug
  2382.                // move this code to learn about Gpi's transforms
  2383.                {
  2384.                   POINTL ptl;
  2385.                   HPS hpsDraw = hps;
  2386.                   ptl.y = 0;
  2387.                   ptl.x = 0;
  2388.                   GpiMove(hpsDraw, &ptl);
  2389.                   ptl.x = 300;
  2390.                   GpiLine( hpsDraw, &ptl);
  2391.                   ptl.y = 300;
  2392.                   GpiLine( hpsDraw, &ptl);
  2393.                   ptl.x = 500;
  2394.                   GpiLine( hpsDraw, &ptl);
  2395.                   ptl.y = 500;
  2396.                   GpiLine( hpsDraw, &ptl);
  2397.                   ptl.x = 700;
  2398.                   GpiLine( hpsDraw, &ptl);
  2399.                   ptl.y = 700;
  2400.                   GpiLine( hpsDraw, &ptl);
  2401.                   ptl.x = 800;
  2402.                   GpiLine( hpsDraw, &ptl);
  2403.                   ptl.y = 800;
  2404.                   GpiLine( hpsDraw, &ptl);
  2405.                   ptl.x = 900;
  2406.                   GpiLine( hpsDraw, &ptl);
  2407.                   ptl.y = 900;
  2408.                   GpiLine( hpsDraw, &ptl);
  2409.                   ptl.x = 1200;
  2410.                   GpiLine( hpsDraw, &ptl);
  2411.                   ptl.y = 1200;
  2412.                   GpiLine( hpsDraw, &ptl);
  2413.  
  2414.                   MATRIXLF mlf;
  2415.                   GpiQueryModelTransformMatrix( hpsDraw, 9, &mlf );
  2416.                   GpiQueryDefaultViewMatrix( hpsDraw, 9, &mlf );
  2417.                   GpiQueryViewingTransformMatrix( hpsDraw, 9, &mlf );
  2418.                   DosBeep(200, 200);
  2419.                }
  2420.             #endif
  2421.           GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
  2422.           facet->GetCanvas(ev)->ReleasePlatformCanvas(ev);
  2423.        #else
  2424.           ODTransform* localToGlobal = facet->GetContentTransform(ev);
  2425.           ODPoint offset(0,0);
  2426.           offset = localToGlobal->TransformPoint(ev, &offset);
  2427.           SetOrigin(-offset.IntX(), -offset.IntY());
  2428.        #endif
  2429.    }
  2430.  
  2431.  
  2432.    SOM_Scope void  SOMLINK ContainerPartInvalEmbedFrameAfterResize(ContainerPart *somSelf,
  2433.                                                                  Environment *ev,
  2434.                                                                 ODFacet* facet,
  2435.                                                                 Proxy* selection,
  2436.                                        // (CED - 110594)        ODShape* oldShape,
  2437.                                                                 ODShape* newShape,
  2438.                                        /* (CED - 110594) */     ODTransform* newTransform)
  2439.                                        // (CED - 110594)        POINTL* transOffset)
  2440.    {
  2441.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2442.        ContainerPartMethodDebug("ContainerPart","ContainerPartInvalEmbedFrameAfterResize");
  2443.  
  2444.        // invalidate old frame shape
  2445.        ODShape* oldShape = selection->frame->GetFrameShape(ev)->Copy(ev); //(CED - 110594)
  2446.        oldShape->Transform(ev, selection->transform);
  2447.        facet->GetFrame(ev)->Invalidate(ev, oldShape);
  2448.        delete oldShape;                                 // (CED - 110594)
  2449.  
  2450.        ODShape* newShapeCopy = new ODShape;
  2451.        newShapeCopy->CopyFrom(ev, newShape);    // save to invalidate later
  2452.  
  2453.        selection->frame->ChangeFrameShape(ev, newShape);  // already in frame coords
  2454.  
  2455. #if 1  // (CED - 110594)
  2456.        // if transform has changed then update facets with new transform
  2457.        if (!selection->transform->IsSameAs(ev, newTransform))
  2458.        {
  2459.          selection->transform->CopyFrom(ev, newTransform);
  2460. #else
  2461.        // if the left or top side of the frame was adjusted, the transform will be updated
  2462.        if ((transOffset->x != 0) || (transOffset->y != 0))
  2463.        {
  2464.          ODPoint ODtransOffset (downcastToODPOINTL(*transOffset));
  2465.          selection->transform->MoveBy(ev, &ODtransOffset);
  2466. #endif
  2467.          _fNeedToExternalize = kODTrue;
  2468.          // $$$$$ move facets for selected frame - this is slightly hackish
  2469.          ODTransform* newTrans;
  2470.          ODFacetIterator* facets =
  2471.            facet->GetWindow(ev)->GetRootFacet(ev)->CreateFacetIterator(ev, kODTopDown, kODFrontToBack);
  2472.          for (ODFacet* child = facets->First(ev);
  2473.              facets->IsNotComplete(ev); child = facets->Next(ev))
  2474.          {
  2475.            if (child->GetFrame(ev) == selection->frame)
  2476.            {
  2477.              newTrans = new ODTransform;
  2478.              newTrans->CopyFrom(ev, selection->transform);
  2479.              child->ChangeGeometry(ev, kODNULL, newTrans);
  2480.              facets->SkipChildren(ev);
  2481.            }
  2482.          }
  2483.          delete facets;
  2484.        }
  2485.        delete newTransform;              // (CED - 110594)
  2486.  
  2487.        // invalidate changed areas
  2488.        newShapeCopy->Transform(ev, selection->transform);
  2489.        facet->GetFrame(ev)->Invalidate(ev, newShapeCopy);
  2490.        delete newShapeCopy;
  2491.  
  2492.        somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
  2493. // (CED - 110594) somSelf->UpdateProxyRegion(ev, selection);
  2494.        somSelf->CreateProxySelectionBorder(ev, facet, selection);
  2495.        somSelf->ClipEmbeddedFrames(ev, facet->GetFrame(ev));
  2496.        somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
  2497.  
  2498.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2499.    }
  2500.  
  2501.  
  2502.    SOM_Scope RECTL*  SOMLINK ContainerPartGetSelectionRectLocal(ContainerPart *somSelf,
  2503.                                                               Environment *ev,
  2504.                                                              Proxy* selection)
  2505.    {
  2506.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2507.        ContainerPartMethodDebug("ContainerPart","ContainerPartGetSelectionRectLocal");
  2508.  
  2509.        //HRGN shapeRgn = selection->frame->GetFrameShape(ev)->GetQDRegion(ev);
  2510.        HRGN shapeRgn = selection->frame->GetFrameShape(ev)->GetRegion(ev);
  2511.        ODRECTL shapeRect;
  2512.        GpiQueryRegionBox(_hpsMem, shapeRgn, &shapeRect);
  2513.  
  2514.        ODRECTL * localRect = new ODRECTL(shapeRect);
  2515.        //SetRect(localRect, shapeRect.left, shapeRect.top,
  2516.         //         shapeRect.right, shapeRect.bottom);
  2517.  
  2518.        #if 0
  2519.           Point offset = selection->transform->GetQDOffset(ev);
  2520.           OffsetRect(&localRect, offset.x, offset.y);
  2521.        #else
  2522.           ODPoint ptTemp;
  2523.           selection->transform->GetOffset(ev, &ptTemp);
  2524.           OffsetRect(localRect, ptTemp.x, ptTemp.y);
  2525.        #endif
  2526.  
  2527.        return localRect;
  2528.    }
  2529.  
  2530.    #ifdef _PLATFORM_OS2_
  2531.       // GetBGColor isn't needed
  2532.    #else
  2533.       SOM_Scope void  SOMLINK ContainerPartGetBGColor(ContainerPart *somSelf,  Environment *ev,
  2534.                                          ODUShort whichColor, RGBColor* newColor)
  2535.       {
  2536.           ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2537.           ContainerPartMethodDebug("ContainerPart","ContainerPartGetBGColor");
  2538.  
  2539.       }
  2540.    #endif
  2541. #endif
  2542.  
  2543. SOM_Scope ODFrame*  SOMLINK ContainerPartMakeEmbeddedFrame(ContainerPart *somSelf,
  2544.                                                             Environment *ev,
  2545.                                                            ODFrame* containingFrame,
  2546.                                                            ODShape* frameShape,
  2547.                                                            ODTransform* externalTransform,
  2548.                                                            ODPart* embedPart,
  2549.                                                            ODBoolean isOverlaid)
  2550. {
  2551.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2552.     ContainerPartMethodDebug("ContainerPart","ContainerPartMakeEmbeddedFrame");
  2553.  
  2554.     ODShape* newShape = NULL;
  2555.  
  2556.     // decide what newShape should be - for now, give it what it asked for
  2557.     if (frameShape)
  2558.     {
  2559.       newShape = frameShape;
  2560.     }
  2561.     else
  2562.     {  // no frameShape specified, use a default size
  2563.       ODRect rect = { 0, MAKEFIXED(200,0), MAKEFIXED(200,0), 0};
  2564.       newShape = new ODShape;
  2565.       newShape->SetRectangle(ev, &rect);
  2566.     };
  2567.  
  2568.     // create the new frame
  2569.     // kODNullTypeToken
  2570.     ODFrame* newFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->
  2571.         CreateFrame(ev, containingFrame, newShape, embedPart,
  2572.               kODNullTypeToken, kODNullTypeToken, kODFalse,
  2573.               isOverlaid);
  2574.     _fEmbeddedFrames->AddFirst(newFrame);
  2575.  
  2576. # if 0  // (CED - 110594)  No longer using proxy regions
  2577.     // create a proxy to hold the embedded frame
  2578.     ODShape* scratch = new ODShape;
  2579.     scratch->CopyFrom(ev, newShape);
  2580.     scratch->Transform(ev, externalTransform);
  2581.     //HRGN scratchRgn = scratch->CopyQDRegion(ev);
  2582.     HRGN scratchRgn = scratch->CopyRegion(ev);
  2583.     delete scratch;
  2584.     Proxy* p = new Proxy(scratchRgn, newFrame, externalTransform);  // new for Facets
  2585. #else
  2586.     Proxy* p = new Proxy( newFrame, externalTransform);  // new for Facets
  2587. #endif
  2588.     // put proxy into contents, possibly adjusting other content
  2589.     _fContents->AddFirst(p);
  2590.     _fNeedToExternalize = kODTrue;
  2591.  
  2592.     return newFrame;
  2593. }
  2594.  
  2595. SOM_Scope ODWindow*  SOMLINK ContainerPartCreateWindow(ContainerPart *somSelf,
  2596.                                            Environment *ev, ODFrame* sourceFrame)
  2597. {
  2598.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2599.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateWindow");
  2600.  
  2601.     #ifdef _PLATFORM_OS2_
  2602.        Rect windRect;
  2603.        ODPlatformWindow platformWindow = kODNULL;
  2604.        ODWindow* window = kODNULL;
  2605.  
  2606.        platformWindow = _fSession->CreatePlatformWindow(ev);
  2607.        window =  _fSession->GetWindowState(ev)->CreateWindow(ev, platformWindow,
  2608.                                             (sourceFrame==kODNULL),  // Keeps draft open
  2609.                                             kODTrue,  // Is resizable
  2610.                                             kODFalse, // Is floating
  2611.                                             kODTrue,  // should save
  2612.                                          somSelf, kODNullTypeToken, kODNullTypeToken, sourceFrame);
  2613.        return window;
  2614.     #else
  2615.        Rect windRect;
  2616.        ODPlatformWindow platformWindow = kODNULL;
  2617.        ODWindow* window = kODNULL;
  2618.  
  2619.        if (sourceFrame)
  2620.        {
  2621.          SetRect(&windRect, 100, 100, 300, 300);
  2622.        }
  2623.        else
  2624.        {
  2625.          const  ODSShort    kOnePageWidth = 600;
  2626.          // Get the menu bar height, for figuring the top of our windows
  2627.          ODSShort  mbHeight  = 24; //(*(ODSShort*)MBarHeight);  //get it from lomem
  2628.          SetRect(&windRect, 4, mbHeight+16,
  2629.              ODQDGlobals.screenBits.bounds.right - 64,
  2630.              ODQDGlobals.screenBits.bounds.bottom - 4);
  2631.  
  2632.          if (windRect.right-windRect.left > kOnePageWidth)
  2633.          {
  2634.            windRect.right = windRect.left + kOnePageWidth;
  2635.          }
  2636.        }
  2637.  
  2638.        Str255 aStr255;
  2639.        ODULong maxsize = 32+sizeof(ODName);
  2640.        ODName* partName = ODGetPOName( somSelf, kODNULL, &maxsize );
  2641.        IntlToPStr(partName,(StringPtr)&aStr255);
  2642.        ODDisposePtr(partName);
  2643.  
  2644.        platformWindow = NewCWindow(kODNULL, &windRect, aStr255, false, zoomDocProc, (WindowPtr)-1L, true, kODNULL);
  2645.        window =  _fSession->GetWindowState(ev)->CreateWindow(ev, platformWindow,
  2646.                                 (sourceFrame==kODNULL),  // Keeps draft open
  2647.                                 kODTrue,  // Is resizable
  2648.                                 kODFalse,  // Is floating
  2649.                                 kODTrue,  // should save
  2650.                               somSelf, kODNullTypeToken, kODNullTypeToken, sourceFrame);
  2651.  
  2652.        return window;
  2653.     #endif
  2654. }
  2655.  
  2656. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveToFront(ContainerPart *somSelf,
  2657.                                                        Environment *ev,
  2658.                                                       ODFrame* frame)
  2659. {
  2660.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2661.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToFront");
  2662.  
  2663.     if (_fSelection->Count() == 1)
  2664.     {
  2665.        ODxOrderedCollectionIterator i(_fSelection);
  2666.        ODxOrderedCollection *tempFacets = new ODxOrderedCollection;
  2667.        Proxy* p = (Proxy*) i.First();
  2668.  
  2669.        _fEmbeddedFrames->Remove(p->frame);
  2670.        _fEmbeddedFrames->AddFirst(p->frame);
  2671.        _fContents->Remove(p);
  2672.        _fContents->AddFirst(p);
  2673.        _fNeedToExternalize = kODTrue;
  2674.        ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  2675.        for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  2676.        {
  2677.           tempFacets->AddFirst(facet);
  2678.        }
  2679.        ODxOrderedCollectionIterator iter(tempFacets);
  2680.        for (facet = (ODFacet*)iter.First();
  2681.             iter.IsNotComplete();
  2682.             facet = (ODFacet*)iter.Next())
  2683.        {
  2684.           facet->GetContainingFacet(ev)->MoveBefore(ev, facet, kODNULL);
  2685.        }
  2686.        somSelf->ClipEmbeddedFrames(ev, frame);
  2687.        p->frame->Invalidate(ev, kODNULL);
  2688.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2689.  
  2690.        delete tempFacets;
  2691.     }
  2692.     return kODTrue;
  2693. }
  2694.  
  2695. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveToBack(ContainerPart *somSelf,
  2696.                                                       Environment *ev,
  2697.                                                      ODFrame* frame)
  2698. {
  2699.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2700.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToBack");
  2701.  
  2702.     if (_fSelection->Count() == 1)
  2703.     {
  2704.        ODxOrderedCollectionIterator i(_fSelection);
  2705.        ODxOrderedCollection *tempFacets = new ODxOrderedCollection;
  2706.        Proxy* p = (Proxy*) i.First();
  2707.  
  2708.        _fEmbeddedFrames->Remove(p->frame);
  2709.        _fEmbeddedFrames->AddLast(p->frame);
  2710.        _fContents->Remove(p);
  2711.        _fContents->AddLast(p);
  2712.        _fNeedToExternalize = kODTrue;
  2713.        ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  2714.        for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  2715.        {
  2716.           tempFacets->AddLast(facet);
  2717.        }
  2718.        ODxOrderedCollectionIterator iter(tempFacets);
  2719.        for (facet = (ODFacet*)iter.First();
  2720.             iter.IsNotComplete();
  2721.             facet = (ODFacet*)iter.Next())
  2722.        {
  2723.           facet->GetContainingFacet(ev)->MoveBehind(ev, facet, kODNULL);
  2724.        }
  2725.        p->frame->Invalidate(ev, kODNULL);
  2726.        somSelf->ClipEmbeddedFrames(ev, frame);
  2727.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2728.  
  2729.        delete tempFacets;
  2730.     }
  2731.     return kODTrue;
  2732. }
  2733.  
  2734. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveForward(ContainerPart *somSelf,
  2735.                                                        Environment *ev,
  2736.                                                       ODFrame* frame)
  2737. {
  2738.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2739.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveForward");
  2740.  
  2741.     if (_fSelection->Count() == 1)
  2742.     {
  2743.        ODxOrderedCollectionIterator i(_fSelection);
  2744.        ODxOrderedCollection *tempFacets = new ODxOrderedCollection;
  2745.        Proxy* p = (Proxy*) i.First();
  2746.  
  2747.        ODFrame* siblingFrame = (ODFrame*)_fEmbeddedFrames->Before(p->frame);
  2748.        if (siblingFrame)
  2749.        {
  2750.           _fEmbeddedFrames->Remove(p->frame);
  2751.           _fEmbeddedFrames->AddBefore(siblingFrame, p->frame);
  2752.           Proxy* siblingProxy = (Proxy*)_fContents->Before(p);
  2753.           _fContents->Remove(p);
  2754.           _fContents->AddBefore(siblingProxy, p);
  2755.           _fNeedToExternalize = kODTrue;
  2756.  
  2757.           ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  2758.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  2759.           {
  2760.              tempFacets->AddFirst(facet);
  2761.           }
  2762.           ODxOrderedCollectionIterator iter(tempFacets);
  2763.           ODFrameFacetIterator* siblingFacets = siblingFrame->CreateFacetIterator(ev);
  2764.           ODFacet* siblingFacet = siblingFacets->First(ev);
  2765.  
  2766.           for (facet = (ODFacet*)iter.First();
  2767.                iter.IsNotComplete();
  2768.                facet = (ODFacet*)iter.Next())
  2769.           {
  2770.              facet->GetContainingFacet(ev)->MoveBefore(ev, facet, siblingFacet);
  2771.              siblingFacet = facet;
  2772.           }
  2773.           somSelf->ClipEmbeddedFrames(ev, frame);
  2774.           p->frame->Invalidate(ev, kODNULL);
  2775.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2776.        }
  2777.        delete tempFacets;
  2778.     }
  2779.     return kODTrue;
  2780. }
  2781.  
  2782. /*
  2783.  * -utilities
  2784.  */
  2785.  
  2786. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveBackward(ContainerPart *somSelf,
  2787.                                                         Environment *ev,
  2788.                                                        ODFrame* frame)
  2789. {
  2790.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2791.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveBackward");
  2792.  
  2793.     if (_fSelection->Count() == 1)
  2794.     {
  2795.        ODxOrderedCollectionIterator i(_fSelection);
  2796.        ODxOrderedCollection *tempFacets = new ODxOrderedCollection;
  2797.        Proxy* p = (Proxy*) i.First();
  2798.  
  2799.        ODFrame* siblingFrame = (ODFrame*)_fEmbeddedFrames->After(p->frame);
  2800.        if (siblingFrame)
  2801.        {
  2802.           _fEmbeddedFrames->Remove(p->frame);
  2803.           _fEmbeddedFrames->AddAfter( siblingFrame, p->frame);
  2804.           Proxy* siblingProxy = (Proxy*)_fContents->After(p);
  2805.           _fContents->Remove(p);
  2806.           _fContents->AddAfter(siblingProxy, p);
  2807.           _fNeedToExternalize = kODTrue;
  2808.  
  2809.           ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  2810.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  2811.           {
  2812.              tempFacets->AddLast(facet);
  2813.           }
  2814.  
  2815.           ODFrameFacetIterator* siblingFacets = siblingFrame->CreateFacetIterator(ev);
  2816.           ODFacet* siblingFacet;
  2817.           for (facet = siblingFacets->First(ev);
  2818.                siblingFacets->IsNotComplete(ev);
  2819.                facet = siblingFacets->Next(ev))
  2820.           {
  2821.              siblingFacet = facet;
  2822.           }
  2823.  
  2824.           ODxOrderedCollectionIterator iter(tempFacets);
  2825.           for (facet = (ODFacet*)iter.First();
  2826.                iter.IsNotComplete();
  2827.                facet = (ODFacet*)iter.Next())
  2828.           {
  2829.              facet->GetContainingFacet(ev)->MoveBehind(ev, facet, siblingFacet);
  2830.              siblingFacet = facet;
  2831.           }
  2832.           p->frame->Invalidate(ev, kODNULL);
  2833.           somSelf->ClipEmbeddedFrames(ev, frame);
  2834.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2835.        }
  2836.        delete tempFacets;
  2837.     }
  2838.     return kODTrue;
  2839. }
  2840.  
  2841. SOM_Scope void  SOMLINK ContainerPartClearAccelTable(ContainerPart *somSelf,
  2842.                                                       Environment *ev,
  2843.                                                      ODFrame* oldOwner)
  2844. {
  2845.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2846.     ContainerPartMethodDebug("ContainerPart","ContainerPartClearAccelTable");
  2847.  
  2848.     HWND hwndFrame = oldOwner->GetWindow( ev)->GetPlatformWindow( ev);
  2849.     HACCEL hAccelOld;
  2850.  
  2851.     hAccelOld = WinQueryAccelTable( (HAB)0, hwndFrame);
  2852.     if (hAccelOld) {
  2853.        WinDestroyAccelTable( hAccelOld );
  2854.        WinSetAccelTable( (HAB)0, 0, hwndFrame);
  2855.     } /* endif */
  2856. }
  2857.  
  2858. SOM_Scope void  SOMLINK ContainerPartSetAccelTable(ContainerPart *somSelf,
  2859.                                                     Environment *ev,
  2860.                                                    ODFrame* newOwner)
  2861. {
  2862.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2863.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetAccelTable");
  2864.  
  2865.     HWND hwndFrame = newOwner->GetWindow( ev)->GetPlatformWindow( ev);
  2866.     ULONG rc;
  2867.     HMODULE hmodDLL;
  2868.     HACCEL hAccelOld;
  2869.     HACCEL hAccel;
  2870.  
  2871.     hAccelOld = WinQueryAccelTable( (HAB)0, hwndFrame);
  2872.     rc = DosQueryModuleHandle( THISDLL, &hmodDLL);
  2873.     if ( rc == 0) {
  2874.        hAccel = WinLoadAccelTable(1, hmodDLL, ID_ACCELTABLE);
  2875.        WinSetAccelTable(1, hAccel, hwndFrame);
  2876.        if (hAccelOld) WinDestroyAccelTable( hAccelOld );
  2877.     } /* endif */
  2878. }
  2879.  
  2880. SOM_Scope long  SOMLINK ContainerPartGetDemoState(ContainerPart *somSelf,
  2881.                                                    Environment *ev)
  2882. {
  2883.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2884.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetDemoState");
  2885.  
  2886.     /* Return statement to be customized: */
  2887.     return _DemoState;
  2888. }
  2889.  
  2890. SOM_Scope void  SOMLINK ContainerPartsomInit(ContainerPart *somSelf)
  2891. {
  2892.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2893.     ContainerPartMethodDebug("ContainerPart","ContainerPartsomInit");
  2894.  
  2895.     ContainerPart_parent_ODPart_somInit(somSelf);
  2896.  
  2897.     _fDisplayFrames = kODNULL;
  2898.     _fEmbeddedFrames = kODNULL;
  2899.     _fWindowID = 0;
  2900.  
  2901.     _fContents = kODNULL;
  2902.     _fSelection = kODNULL;
  2903.     _fNeedToExternalize = kODFalse;
  2904.  
  2905.     _fSelectRgn = kODNULL;
  2906.     _fCornerHandleRgn = kODNULL;
  2907.     _fEdgeHandleRgn = kODNULL;
  2908.  
  2909.     _fFocusSet = kODNULL;
  2910.  
  2911.     _fSemtIntf = kODNULL;
  2912.     //_fTestDrawSU = kODNULL;
  2913.  
  2914.     _fSPEMenuOfSelection = kODNULL;
  2915.     _fRemappedSPEMenuOfSelection = kODNULL;
  2916.  
  2917.     //_fLargeIcons = kODNULL;
  2918.     //_fSmallIcons = kODNULL;
  2919.  
  2920.     _DemoState = 0;
  2921.     _DemoOpenCount = 0;
  2922.  
  2923.     _fSession = kODNULL;
  2924.  
  2925.     _fNotebook = kODNULL;
  2926. }
  2927.  
  2928. SOM_Scope void  SOMLINK ContainerPartsomUninit(ContainerPart *somSelf)
  2929. {
  2930.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2931.     ContainerPartMethodDebug("ContainerPart","ContainerPartsomUninit");
  2932.  
  2933.     Environment* ev = somGetGlobalEnvironment();
  2934.     if (_fContents != kODNULL)
  2935.       delete _fContents;
  2936.     if (_fSelection != kODNULL)
  2937.       delete _fSelection;
  2938.     if (_fSelectRgn) GpiDestroyRegion(_hpsMem, _fSelectRgn);
  2939.     if (_fCornerHandleRgn) GpiDestroyRegion(_hpsMem, _fCornerHandleRgn);
  2940.     if (_fEdgeHandleRgn) GpiDestroyRegion(_hpsMem, _fEdgeHandleRgn);
  2941.     if (_hpsMem) GpiDestroyPS(_hpsMem);
  2942.     if (_hdcMem) DevCloseDC(_hdcMem);
  2943.     if ( _fSPEMenuOfSelection ) {
  2944.        _fSPEMenuOfSelection->Release(ev);
  2945.     } /* endif */
  2946.     if ( _fRemappedSPEMenuOfSelection ) {
  2947.        _fRemappedSPEMenuOfSelection->Release(ev);
  2948.     } /* endif */
  2949.  
  2950.  
  2951.     if (_fDisplayFrames != kODNULL)
  2952.       delete _fDisplayFrames;    // make sure it's empty first
  2953.     if (_fEmbeddedFrames != kODNULL)
  2954.       delete _fEmbeddedFrames;    // make sure it's empty first
  2955.  
  2956.     #define SEMANTIC_INTERFACES_NOT_DONE
  2957.     #ifndef SEMANTIC_INTERFACES_NOT_DONE
  2958.        if (_fSemtIntf != kODNULL)
  2959.            delete _fSemtIntf;
  2960.     #endif
  2961.  
  2962.     //ODReleaseObject(ev,_fTestDrawSU);
  2963.     ContainerPart_parent_ODPart_somUninit(somSelf);
  2964. }
  2965.  
  2966. SOM_Scope void  SOMLINK ContainerPartFulfillPromise(ContainerPart *somSelf,
  2967.                                         Environment *ev, ODStorageUnitView* promiseSUView)
  2968. {
  2969.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2970.     ContainerPartMethodDebug("ContainerPart","ContainerPartFulfillPromise");
  2971.  
  2972.     NOTDONE2("FulfillPromise");
  2973.     ContainerPart_parent_ODPart_FulfillPromise(somSelf, ev, promiseSUView);
  2974. }
  2975.  
  2976. SOM_Scope void  SOMLINK ContainerPartDropCompleted(ContainerPart *somSelf,
  2977.                                        Environment *ev, ODPart* destPart,
  2978.                                       ODDropResult dropResult)
  2979. {
  2980.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2981.     ContainerPartMethodDebug("ContainerPart","ContainerPartDropCompleted");
  2982.  
  2983.     NOTDONE2("DropCompleted");
  2984. //    ContainerPart_parent_ODPart_DropCompleted(somSelf, ev, destPart,
  2985. //<crs>                                              dropResult);
  2986. }
  2987.  
  2988.  
  2989. #if 0
  2990.                                                    // helpful debug routine
  2991.   DumpRegionRects( PSZ prompt, HPS hps, HRGN hrgn )
  2992.   {
  2993.     RECTL rects[5];
  2994.     BOOL  retval;
  2995.     RGNRECT rr;
  2996.     rr.ircStart = 1;
  2997.     rr.crc = 5;
  2998.     rr.ulDirection = RECTDIR_LFRT_TOPBOT;
  2999.     retval = GpiQueryRegionRects( hps
  3000.                                 , hrgn
  3001.                                 , /*prclBound:*/0
  3002.                                 , &rr
  3003.                                 , rects
  3004.                                 );
  3005.     rrprintf( "rects for \"%s\" hrgn(", prompt);
  3006.     rrprintf( "%lx", hrgn);
  3007.     rrprintf( ") ");
  3008.     if (retval) {
  3009.        int ix;
  3010.        for (ix=0; ix<rr.crcReturned; ix++) {
  3011.           rrprintf( "(x=%ld..%ld,"
  3012.                     , rects[ix].xLeft
  3013.                     , rects[ix].xRight
  3014.                     );
  3015.           rrprintf( "y=%ld..%ld)"
  3016.                     , rects[ix].yBottom
  3017.                     , rects[ix].yTop
  3018.                     );
  3019.        } /* endfor */
  3020.     } else {
  3021.        rrprintf( "error" );
  3022.     } /* endif */
  3023.     rrprintf( "\r\n" );
  3024.   }
  3025. #endif
  3026.  
  3027.  
  3028.    void InvertDragHilite( Environment * ev, ODFacet* facet)
  3029.    {
  3030.       HWND hwnd = facet->GetWindow(ev)->GetPlatformWindow(ev);
  3031.       hwnd = WinWindowFromID( hwnd, FID_CLIENT );
  3032.          // the following code was added because with the new facet window
  3033.          //   design, we appear to need to need to draw on the topmost
  3034.          //   facet window.  If we don't, nothing appears. (jlc 94/9/19)
  3035.          {
  3036.             //<crs>-12/07/94-validate facet via metaclass method
  3037.             HWND prevhwnd;
  3038.             M_ODFacet *m = new M_ODFacet;
  3039.             while (hwnd) {
  3040.                prevhwnd = hwnd;
  3041.                hwnd = WinQueryWindow( hwnd, QW_TOP );
  3042.                if ( (hwnd) && (m->clsODFacetFromHWND( ev, hwnd ) == kODNULL ))
  3043.                   {
  3044.                   hwnd = prevhwnd;
  3045.                   break;
  3046.                   }  
  3047.             }
  3048.             hwnd = prevhwnd;
  3049.             delete m;
  3050.          }
  3051.  
  3052.       HPS hps = DrgGetPS( hwnd );
  3053.  
  3054.       LONG mixOld = GpiQueryMix( hps );
  3055.       LONG colorOld = GpiQueryColor( hps);
  3056.       GpiSetMix( hps, FM_XOR );
  3057.       GpiSetColor( hps, CLR_TRUE );
  3058.  
  3059.       RECTL rectl;
  3060.       ODShape *clipShape = new ODShape();
  3061.       HRGN saveClip;
  3062.       ODShape *trackingShape = new ODShape();
  3063.  
  3064.       // for people just learning about the various OpenDoc facet/frame shapes,
  3065.       //   modifying the following code to set the trackingShape to be the Active,
  3066.       //   Used, Clip, AggregateClip, or various other shapes can be very
  3067.       //   educational.  For the best results, turn off the clipping while
  3068.       //   experimenting.
  3069.  
  3070.       trackingShape->CopyFrom( ev, facet->GetFrame(ev)->GetFrameShape(ev) );
  3071.       trackingShape->Transform( ev, facet->GetWindowFrameTransform(ev) );
  3072.  
  3073.       // Specify that the highlight painting will clip off portions of
  3074.       //         highlight that are covered by descendants/uncles or
  3075.       //         clipped by parentage.
  3076.       {
  3077.          // todo: determine which of these two is prefered.
  3078.          #if 1
  3079.             clipShape->CopyFrom(ev, facet->GetAggregateClipShape(ev) );
  3080.          #else
  3081.             clipShape->CopyFrom(ev, facet->GetClipShape(ev) );
  3082.          #endif
  3083.          clipShape->Transform(ev, facet->GetWindowFrameTransform(ev));
  3084.          HRGN clip = clipShape->GetRegion(ev);
  3085.          GpiSetClipRegion(hps, clip, &saveClip);
  3086.       }
  3087.  
  3088.       #if 1
  3089.          SIZEL szl;
  3090.          szl.cx = 5;
  3091.          szl.cy = 5;
  3092.          /*LONG  APIENTRY*/ GpiFrameRegion( hps
  3093.                                       , trackingShape->GetRegion(ev)
  3094.                                       , /*thickness:*/&szl);
  3095.          delete trackingShape;
  3096.       #endif
  3097.  
  3098.       GpiSetClipRegion(hps, saveClip, (PHRGN)0);
  3099.       delete clipShape;
  3100.  
  3101.       GpiSetColor( hps, colorOld );
  3102.       GpiSetMix( hps, mixOld );
  3103.  
  3104.       DrgReleasePS(hps);
  3105.    }
  3106.  
  3107. #if 1
  3108.    SOM_Scope MRESULT  SOMLINK ContainerPartDragEnter(ContainerPart *somSelf,
  3109.                                                       Environment *ev,
  3110.                                                      ODDragItemIterator* dragInfo,
  3111.                                                      ODFacet* facet,
  3112.                                                      ODPoint* where)
  3113.    {
  3114.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3115.        ContainerPartMethodDebug("ContainerPart","ContainerPartDragEnter");
  3116.  
  3117.        InvertDragHilite( ev, facet );
  3118.  
  3119.        return MRFROM2SHORT (DOR_DROP, DO_MOVE);
  3120.    }
  3121.  
  3122.  
  3123.    SOM_Scope MRESULT  SOMLINK ContainerPartDragWithin(ContainerPart *somSelf,
  3124.                                                        Environment *ev,
  3125.                                                       ODDragItemIterator* dragInfo,
  3126.                                                       ODFacet* facet,
  3127.                                                       ODPoint* where)
  3128.    {
  3129.        ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3130.        ContainerPartMethodDebug("ContainerPart","ContainerPartDragWithin");
  3131.  
  3132.        return MRFROM2SHORT (DOR_DROP, DO_MOVE);
  3133.    }
  3134. #endif
  3135.  
  3136. SOM_Scope void  SOMLINK ContainerPartDragLeave(ContainerPart *somSelf,  Environment *ev,
  3137.                                   ODFacet* facet, ODPoint* where)
  3138. {
  3139.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3140.     ContainerPartMethodDebug("ContainerPart","ContainerPartDragLeave");
  3141.  
  3142.     InvertDragHilite( ev, facet );
  3143. }
  3144.  
  3145. SOM_Scope ODDropResult  SOMLINK ContainerPartDrop(ContainerPart *somSelf,
  3146.                                       Environment *ev, ODDragItemIterator* dropInfo,
  3147.                                      ODFacet* facet, ODPoint* where)
  3148. {
  3149.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3150.     ContainerPartMethodDebug("ContainerPart","ContainerPartDrop");
  3151.  
  3152.     #if 0
  3153.        NOTDONE2("Drop");
  3154.        return (ODDropResult)0;
  3155.     #else
  3156.        #ifdef _PLATFORM_OS2_
  3157.           ODDraft       *theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  3158.           ODULong        attributes;
  3159.           //DragReference   theDrag;
  3160.           ODPoint           delta;
  3161.           Point           dragPoint, dropPoint, pinnedPoint;
  3162.           //MATRIXLF        newXTrans;
  3163.           short           mouseDownModifiers, mouseUpModifiers, movePart;
  3164.           ODStorageUnit *dropSU, *newSU;
  3165.           ODID           draggedFrameID;
  3166.           Proxy          *p;
  3167.           ODFrame       *frameDroppedIn;
  3168.           ODFrame       *newFrame = kODNULL;
  3169.           ODPart        *newPart;
  3170.           ODShape       *clipShape, *newFrameShape;
  3171.           ODTransform   *newExternalXForm;
  3172.           ODBoolean      canHandleDrop = kODFalse;
  3173.  
  3174.           ODDropResult  dropResult = kODDropMove;
  3175.           InvertDragHilite(ev, facet);  // presumably I've highlighted myself, so turn it off now.
  3176.  
  3177.           // Check to see if we can handle the info in this drag (right now only parts)
  3178.           for (dropSU = dropInfo->First(ev); dropSU; dropSU = dropInfo->Next(ev))
  3179.              if (dropSU->Exists(ev, kODPropPart, kODISOStr, 0))
  3180.                 canHandleDrop = kODTrue;
  3181.  
  3182.           if (canHandleDrop == kODFalse)
  3183.                 return kODDropFail;
  3184.  
  3185.           // Get the attributes for this drag
  3186.           attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
  3187.           //theDrag = _fSession->GetDragAndDrop(ev)->GetDragReference(ev);
  3188.           movePart = (attributes & kODdragIsInSourceFrame);
  3189.  
  3190.           ODBoolean  notDone = kODTrue;
  3191.           for (dropSU = dropInfo->First(ev); dropSU && notDone; dropSU = dropInfo->Next(ev))
  3192.           {
  3193.              if (movePart)
  3194.              {
  3195.                 // Get where drag started and tweak our own structures to do the move.
  3196.                 ODPoint ms = facet->GetWindowFrameTransform(ev)->InvertPoint(ev, &_mouseStart);
  3197.                 delta.x = where->x - ms.x;
  3198.                 delta.y = where->y - ms.y;
  3199.  
  3200.                 dropSU->Focus(ev, kPropFrameInfo, kODPosUndefined, kODID, 0, kODPosFirstSib);
  3201.                 dropSU->GetValue(ev, sizeof(ODID), (ODValue) &draggedFrameID);
  3202.                 p = somSelf->ProxyForFrameID(ev, draggedFrameID);
  3203.  
  3204.                 // !!! this is a single-facet hack
  3205.                 p->transform->MoveBy(ev, &delta);
  3206.                 newExternalXForm = new ODTransform;
  3207.                 newExternalXForm->CopyFrom(ev, p->transform);
  3208.                 ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  3209.                 #if 0
  3210.                    facets->First(ev)->ChangeExternalTransform(ev, newExternalXForm);
  3211.                 #else
  3212.                    facets->First(ev)->ChangeGeometry(ev, kODNULL, newExternalXForm);
  3213.                    //NOTDONE2("ChangeExternalTransform.3184");
  3214.                 #endif
  3215.                 delete facets;
  3216.                 _fNeedToExternalize = kODTrue;
  3217.  
  3218. // (CED 110594) somSelf->UpdateProxyRegion(ev, p);
  3219. // (CED 110594) somSelf->CreateProxySelectionBorder(ev, p);
  3220.                 somSelf->CreateProxySelectionBorder(ev, facet, p);
  3221.  
  3222.  
  3223.                 notDone = kODFalse;
  3224.              }
  3225.              else
  3226.              {
  3227.                 ODDraftKey key;
  3228.  
  3229.                 //ODVolatile(dropSU);
  3230.                 //ODVolatile(key);
  3231.  
  3232.                 try{
  3233.                    key = dropSU->GetDraft(ev)->BeginClone(ev, kODClonePaste);
  3234.                    newSU = dropSU->CloneTo(ev, key, theDraft, kODNULL);
  3235.                    dropSU->GetDraft(ev)->EndClone(ev, key);
  3236.                 } catch (... ) {
  3237.                    dropSU->GetDraft(ev)->AbortClone(ev, key);
  3238.                    throw;
  3239.                 } /* end catch */
  3240.  
  3241.                 ODPoint newTransPt = {MAKEFIXED(10,0), MAKEFIXED(10,0)};
  3242. #if 1  // (CED - 110594)
  3243.                 if (dropSU->Exists(ev, kPropMouseDownOffset, kODPoint, 0))
  3244.                 {
  3245.                    ODPoint offset;
  3246.                    dropSU->Focus(ev, kPropMouseDownOffset, kODPosUndefined, kODPoint, 0, kODPosFirstSib);
  3247.                    dropSU->GetValue(ev, sizeof(offset), (ODValue) &offset);
  3248.                    newTransPt.x = where->x - offset.x;
  3249.                    newTransPt.y = where->y - offset.y;
  3250.                 }
  3251. #else
  3252.                 if (dropSU->Exists(ev, kPropMouseDownOffset, kOS2POINTL, 0))
  3253.                 {
  3254.                    ODPOINTL mdOffset(0,0);
  3255.                    newTransPt = *where;
  3256.  
  3257.                    dropSU->Focus(ev, kPropMouseDownOffset, kODPosUndefined, kOS2POINTL, 0, kODPosFirstSib);
  3258.                    dropSU->GetValue(ev, sizeof(mdOffset), (ODValue) &mdOffset);
  3259.                    newTransPt.x -= MAKEFIXED(mdOffset.x,0);
  3260.                    newTransPt.y -= MAKEFIXED(mdOffset.y,0);
  3261.                 }
  3262. #endif
  3263.  
  3264.                 newExternalXForm = new ODTransform;
  3265.                 newExternalXForm->MoveBy(ev,  &newTransPt );
  3266.  
  3267.                 if (dropSU->Exists(ev, kODPropFrameShape, NULL, 0))
  3268.                 {
  3269.                    dropSU->Focus(ev, kODPropFrameShape, kODPosUndefined, NULL, 1, kODPosUndefined);
  3270.                    newFrameShape = new ODShape;
  3271.                    newFrameShape = newFrameShape->ReadShape(ev, dropSU);
  3272.                 }
  3273.                 else
  3274.                 {
  3275.                    newFrameShape = kODNULL;     // use default size {80,80}
  3276.                 }
  3277.  
  3278.                 newPart = theDraft->GetPart(ev, newSU->GetID(ev));
  3279.                 newSU->Release(ev);
  3280.  
  3281.                 frameDroppedIn = facet->GetFrame(ev);
  3282.  
  3283.                 // We should be internalizing the frame from the storage unit
  3284.                 #if 1
  3285.                    // jlc Apple appears to have replaced tCreateEmbeddedFrame
  3286.                    // jlc with MakeEmbeddedFrame.  I've converted the names of
  3287.                    // jlc the invocations here, but I haven't had a chance to
  3288.                    // jlc test this.  todo jlc 94/8
  3289.                    #if 1
  3290.                       newFrame = somSelf->MakeEmbeddedFrame(ev, frameDroppedIn,
  3291.                                                   newFrameShape,
  3292.                                                   newExternalXForm,
  3293.                                                   newPart,
  3294.                                                   /*
  3295.                                                   viewtype:     kODNullTypeToken,
  3296.                                                   presentation: kODNullTypeToken,
  3297.                                                   groupID:      0,
  3298.                                                   */
  3299.                                                   kODFalse);
  3300.                    #else
  3301.                       newFrame = somSelf->CreateEmbeddedFrame(ev, frameDroppedIn,
  3302.                                                   newFrameShape,
  3303.                                                   newExternalXForm,
  3304.                                                   newPart,
  3305.                                                   kODNullTypeToken,
  3306.                                                   kODNullTypeToken,
  3307.                                                   0,
  3308.                                                   kODFalse);
  3309.                    #endif
  3310.                 #endif
  3311.  
  3312.                 #if 1
  3313.                    // *** Set the frame's part info.  This is a kludge because
  3314.                    // *** some of the sample parts we have now save their content
  3315.                    // *** to the frame's partinfo rather than  adding properties
  3316.                    // *** for part content in the storage unit.  The frame's partinfo
  3317.                    // *** data should not normally be copied on a drag/drop operation.
  3318.                    // *** This code will be removed once the sample parts are fixed
  3319.                    // *** up to externalize properly.
  3320.                    // ************************************************************************
  3321.                    // I believe the code (and the comment above) in this #if was
  3322.                    //    written by DougF.  Apple's code is much simplier, but I
  3323.                    //    don't think it will work when the containing frames has
  3324.                    //    multiple facets because Apple's code only adds one embedded
  3325.                    //    facet rather than one per container facet.
  3326.                    // Also I don't believe Apple's code will handle the situation where
  3327.                    //    a part has multiple frames.  I'm not sure if Doug's code will
  3328.                    //    handle that.  I suspect not.
  3329.                    // I don't understand Doug's comment about storing things in the
  3330.                    //    part info.  Apple's draw part handles storage the same way
  3331.                    //    and they don't require and partinfo related code here.
  3332.                    //    I'll dig further when I get a chance.
  3333.                    // todo: Talk to Apple or try out their code to determine if their
  3334.                    //    code is deficient. (jlc 94/9/16)
  3335.  
  3336.                    dropSU->Focus(ev, kODPropPartInfo, kODPosUndefined, kODPartInfo, 0, kODPosUndefined);
  3337.                    ODStorageUnitView *suView = new ODStorageUnitView();
  3338.                    suView->InitStorageUnitView(ev, dropSU, dropSU->CreateCursor(ev));
  3339.                    ODInfoType fPartInfo = (ODInfoType)(newPart->ReadPartInfo(ev, newFrame, suView));
  3340.                    newFrame->SetPartInfo(ev, fPartInfo);
  3341.                    delete suView;
  3342.  
  3343.                    ODFrameFacetIterator* facets = frameDroppedIn->CreateFacetIterator(ev);
  3344.                    for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  3345.                    {
  3346.                       ODShape* clip = new ODShape;
  3347.                       clip->CopyFrom(ev, newFrame->GetFrameShape(ev));
  3348.                       ODTransform* xform = new ODTransform;
  3349.                       xform->CopyFrom(ev, somSelf->ProxyForFrame(ev, newFrame)->transform);
  3350.                       facet->CreateEmbeddedFacet(ev, newFrame, clip, xform, kODNULL, kODFrameInFront);
  3351.                    }
  3352.                    delete facets;
  3353.                    somSelf->ClipEmbeddedFrames(ev, frameDroppedIn);
  3354.                 #endif
  3355.                 frameDroppedIn->Invalidate(ev, NULL);
  3356.  
  3357.                 newPart->Release(ev);
  3358.  
  3359.                 notDone = kODFalse;
  3360.              }
  3361.           }
  3362.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  3363.  
  3364.           return dropResult;
  3365.        #else
  3366.           ODDraft       *theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  3367.           ODULong        attributes;
  3368.           DragReference   theDrag;
  3369.           Point           delta, dragPoint, dropPoint, pinnedPoint, newXTrans;
  3370.           short           mouseDownModifiers, mouseUpModifiers;
  3371.           ODStorageUnit *dropSU, *newSU;
  3372.           ODID           draggedFrameID;
  3373.           Proxy          *p;
  3374.           ODFrame       *frameDroppedIn;
  3375.           ODFrame    *newFrame = kODNULL;
  3376.           ODPart        *newPart;
  3377.           ODShape     *clipShape, *newFrameShape;
  3378.           ODTransform   *newExternalXForm;
  3379.           ODBoolean    canHandleDrop = kODFalse;
  3380.  
  3381.           ODDropResult  dropResult = kODDropMove;
  3382.  
  3383.           // Check to see if we can handle the info in this drag (right now only parts)
  3384.           for (dropSU = dropInfo->First(ev); dropSU; dropSU = dropInfo->Next(ev))
  3385.             if (dropSU->Exists(ev, kODPropPart, kODISOStr, 0))
  3386.               canHandleDrop = kODTrue;
  3387.  
  3388.           if (canHandleDrop == kODFalse)
  3389.               return kODDropFail;
  3390.  
  3391.           // Get the attributes and other stuff for this drag
  3392.           attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
  3393.           theDrag = _fSession->GetDragAndDrop(ev)->GetDragReference(ev);
  3394.           GetDragModifiers(theDrag, 0L, &mouseDownModifiers, &mouseUpModifiers);
  3395.           if ((mouseDownModifiers & optionKey) || (mouseUpModifiers & optionKey))
  3396.             dropResult = kODDropCopy;
  3397.  
  3398.           ODBoolean  notDone = kODTrue;
  3399.           for (dropSU = dropInfo->First(ev); dropSU && notDone;
  3400.               dropSU = dropInfo->Next(ev))
  3401.           {
  3402.             if ((attributes & kODdragIsInSourceFrame) && (dropResult == kODDropMove))
  3403.             {
  3404.               // Get where drag started and tweak our own structures to do the move.
  3405.               GetDragOrigin(theDrag, &dragPoint);
  3406.               GetDragMouse(theDrag, &dropPoint, &pinnedPoint);
  3407.               delta.h = dropPoint.h - dragPoint.h;
  3408.               delta.v = dropPoint.v - dragPoint.v;
  3409.               dropSU->Focus(ev, kPropFrameInfo, kODPosUndefined, kODID, 0, kODPosFirstSib);
  3410.               dropSU->GetValue(ev, sizeof(ODID), (ODValue) &draggedFrameID);
  3411.               p = somSelf->ProxyForFrameID(ev, draggedFrameID);
  3412.  
  3413.               // $$$$$ this is a single-facet hack
  3414.               ODPoint ODDelta (delta);
  3415.               p->transform->MoveBy(ev, &ODDelta);
  3416.               newExternalXForm = new ODTransform;
  3417.               newExternalXForm->CopyFrom(ev, p->transform);
  3418.               ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
  3419.               facets->First(ev)->ChangeGeometry(ev, kODNULL, newExternalXForm);
  3420.               delete facets;
  3421.  
  3422.               somSelf->UpdateProxyRegion(ev, p);
  3423.               somSelf->CreateProxySelectionBorder(ev, p);
  3424.  
  3425.               notDone = kODFalse;
  3426.             }
  3427.             else
  3428.             {
  3429.               // Create a new storage unit for the part
  3430.         //      newSU = theDraft->CreateStorageUnit(ev);
  3431.  
  3432.               ODDraftKey  key;
  3433.  
  3434.               // $$$$$ OBSOLETE: Volatile(dropSU);
  3435.               // $$$$$ OBSOLETE: Volatile(key);
  3436.  
  3437.               TRY
  3438.                 key = dropSU->GetDraft(ev)->BeginClone(ev, kODClonePaste);
  3439.                 newSU = dropSU->CloneTo(ev, key, theDraft, kODNULL);
  3440.                 dropSU->GetDraft(ev)->EndClone(ev, key);
  3441.  
  3442.               CATCH_ALL
  3443.                 dropSU->GetDraft(ev)->AbortClone(ev, key);
  3444.                 RERAISE;
  3445.               ENDTRY
  3446.  
  3447.               if (dropSU->Exists(ev, kPropMouseDownOffset, kQDPoint, 0))
  3448.               {
  3449.                 Point mdOffset = {0,0};
  3450.                 newXTrans = where->AsQDPoint();
  3451.  
  3452.                 dropSU->Focus(ev, kPropMouseDownOffset, kODPosUndefined, kQDPoint, 0, kODPosFirstSib);
  3453.                 dropSU->GetValue(ev, sizeof(Point), (ODValue) &mdOffset);
  3454.  
  3455.                 SubPt(mdOffset,&newXTrans);
  3456.               }
  3457.               else
  3458.               {
  3459.                 SetPt(&newXTrans, 20, 20);
  3460.               }
  3461.  
  3462.               newExternalXForm = new ODTransform;
  3463.               newExternalXForm->SetQDOffset(ev, &newXTrans);
  3464.  
  3465.               if (dropSU->Exists(ev, kODPropFrameShape, NULL, 0))
  3466.               {
  3467.                 dropSU->Focus(ev, kODPropFrameShape, kODPosUndefined, NULL, 1, kODPosUndefined);
  3468.                 newFrameShape = new ODShape;
  3469.                 newFrameShape = newFrameShape->ReadShape(ev, dropSU);
  3470.               }
  3471.               else
  3472.               {
  3473.                 newFrameShape = kODNULL;    // use default size {80,80}
  3474.               }
  3475.  
  3476.               newPart = theDraft->GetPart(ev, newSU->GetID(ev));
  3477.               newSU->Release(ev);
  3478.  
  3479.               frameDroppedIn = facet->GetFrame(ev);
  3480.               newFrame = somSelf->MakeEmbeddedFrame(ev, frameDroppedIn,
  3481.                   newFrameShape, newExternalXForm, newPart, kODFalse);
  3482.  
  3483.               clipShape = new ODShape;
  3484.               clipShape->CopyFrom(ev, newFrame->GetFrameShape(ev));
  3485.  
  3486.               newExternalXForm = new ODTransform;
  3487.               newExternalXForm->CopyFrom(ev, somSelf->ProxyForFrame(ev, newFrame)->transform);
  3488.               facet->CreateEmbeddedFacet(ev, newFrame, clipShape, newExternalXForm,
  3489.                             kODNULL, kODFrameInFront);
  3490.               frameDroppedIn->Invalidate(ev, kODNULL);
  3491.               newPart->Release(ev);
  3492.  
  3493.               notDone = kODFalse;
  3494.             }
  3495.           }
  3496.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  3497.  
  3498.           return dropResult;
  3499.        #endif
  3500.     #endif
  3501. }
  3502.  
  3503. SOM_Scope void  SOMLINK ContainerPartContainingPartPropertiesChanged(ContainerPart *somSelf,
  3504.                                                          Environment *ev,
  3505.                                                         ODFrame* frame,
  3506.                                                         ODStorageUnit* propertyUnit)
  3507. {
  3508.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3509.     ContainerPartMethodDebug("ContainerPart","ContainerPartContainingPartPropertiesChanged");
  3510.  
  3511.     // nothing to do yet
  3512. }
  3513.  
  3514. SOM_Scope ODStorageUnit*  SOMLINK ContainerPartGetContainingPartProperties(ContainerPart *somSelf,
  3515.                                                                Environment *ev,
  3516.                                                               ODFrame* frame)
  3517. {
  3518.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3519.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetContainingPartProperties");
  3520.  
  3521.     // this part has no properties to return
  3522.     return kODNULL;
  3523. }
  3524.  
  3525. SOM_Scope ODMenuBar*  SOMLINK ContainerPartCreateRootMenuBar(ContainerPart *somSelf,
  3526.                                                               Environment *ev,
  3527.                                                              ODFrame* frame)
  3528. {
  3529.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3530.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateRootMenuBar");
  3531.  
  3532.     ODContainerRootFrameMenuBar * mb = new ODContainerRootFrameMenuBar;
  3533.     mb->InitMenuBar( ev, _fSession, kODNULL);
  3534.     mb->SetOwner( ev, frame );
  3535.  
  3536.     ODWindowState * windowState = _fSession->GetWindowState( ev);
  3537.     ODMenuBar * mbold = windowState->GetBaseMenuBar(ev);
  3538.     mb->SetDependeeMenuBar( ev, mbold );
  3539.     return mb;
  3540. }
  3541.  
  3542. SOM_Scope void  SOMLINK ContainerPartRevealFrame(ContainerPart *somSelf,  Environment *ev,
  3543.                                     ODFrame* embeddedFrame, ODShape* revealShape)
  3544. {
  3545.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3546.     ContainerPartMethodDebug("ContainerPart","ContainerPartRevealFrame");
  3547.  
  3548.     NOTDONE2("RevealFrame"); // even Apple hasn't finished this one.
  3549.     ContainerPart_parent_ODPart_RevealFrame(somSelf, ev, embeddedFrame,
  3550.                                             revealShape);
  3551. }
  3552.  
  3553. SOM_Scope void  SOMLINK ContainerPartEmbeddedFrameSpec(ContainerPart *somSelf,
  3554.                                            Environment *ev, ODFrame* embeddedFrame,
  3555.                                           ODObjectSpec spec)
  3556. {
  3557.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3558.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameSpec");
  3559.  
  3560.     NOTDONE2("EmbeddedFrameSpec");
  3561.     ContainerPart_parent_ODPart_EmbeddedFrameSpec(somSelf, ev,
  3562.                                                   embeddedFrame,
  3563.                                                   spec);
  3564. }
  3565.  
  3566. SOM_Scope ODEmbeddedFramesIterator*  SOMLINK ContainerPartCreateEmbeddedFramesIterator(ContainerPart *somSelf,
  3567.                                                                            Environment *ev,
  3568.                                                                           ODFrame* frame)
  3569. {
  3570.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3571.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateEmbeddedFramesIterator");
  3572.  
  3573.                // todo: this method is required to set up the iterator so that
  3574.                //   it only iterates though the children of the given
  3575.                //   frame.  Clearly this code it is not doing this...
  3576.                //   or is assuming that a single display frame will
  3577.                //   be created.  The Apple code is no better yet.
  3578.                //   (jlc 94-9-16)
  3579.  
  3580.     XEmbeddedFramesIterator * xefi = new XEmbeddedFramesIterator();
  3581.     xefi->InitXEmbeddedFramesIterator( ev, _fEmbeddedFrames );
  3582.     return xefi;
  3583. }
  3584.  
  3585. SOM_Scope void  SOMLINK ContainerPartAddDisplayFrame(ContainerPart *somSelf,
  3586.                                          Environment *ev, ODFrame* frame)
  3587. {
  3588.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3589.     ContainerPartMethodDebug("ContainerPart","ContainerPartAddDisplayFrame");
  3590.  
  3591.     if (frame->GetPart(ev) == somSelf)    // frame belongs to me
  3592.     {
  3593.       ODxOrderedCollectionIterator  displayFramesIter(_fDisplayFrames);
  3594.       ODFrame* displayFrame = (ODFrame*) displayFramesIter.First();
  3595.       if (displayFramesIter.IsNotComplete() == kODFalse) {
  3596.         ODxOrderedCollectionIterator  contentsIter(_fContents);
  3597.         Proxy*            proxy;
  3598.  
  3599.         for (proxy = (Proxy*) contentsIter.First();
  3600.             contentsIter.IsNotComplete();
  3601.             proxy = (Proxy*) contentsIter.Next())
  3602.         {
  3603.           proxy->frame->SetContainingFrame(ev, frame);
  3604.         }
  3605.       }
  3606.  
  3607.       // !!! do something with viewType and partInfo...
  3608.       PartInfoRec* pInfo = new PartInfoRec;
  3609. //+(rlt 3-8-95)
  3610.         pInfo->fGridOn = kODFalse;      //Default is grid off
  3611. //-
  3612.       //pInfo->bgClipRegion = frame->GetFrameShape(ev)->CopyQDRegion(ev);      // <12> was GetQDRegion()
  3613.  
  3614.       if (frame->IsRoot(ev))
  3615. //+(rlt 3-8-95)
  3616.         pInfo->fNeedsActivating = kODTrue;
  3617.         else 
  3618.          _fDefaultColor = (defcolor++) % 8;  // pick semi random color for non root frames
  3619.       
  3620. //-
  3621.       pInfo->bgColor = _fDefaultColor;
  3622.       frame->SetPartInfo(ev, (ODInfoType) pInfo);
  3623.       _fDisplayFrames->AddLast(frame);
  3624.       frame->IncrementRefCount(ev);
  3625.       frame->SetDroppable(ev, kODTrue);
  3626.  
  3627.       _fNeedToExternalize = kODTrue;
  3628.  
  3629.       if (frame->GetViewType(ev) == kODNullTypeToken)            // if frame view is set don't change it
  3630.         frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));    // if not, make it viewasframe
  3631.       if (frame->GetPresentation(ev) == kODNullTypeToken)
  3632.         frame->SetPresentation(ev, _fSession->Tokenize(ev, kContainerPartPresNormal));
  3633.  
  3634.       if (frame->GetContainingFrame(ev) == kODNULL)
  3635.       {
  3636.         //Wrong place. somSelf->ActivateFrame(ev, frame);
  3637.       }
  3638.     }
  3639.     else
  3640.       THROW(kODErrInvalidFrame);
  3641.  
  3642.     // render in frame?
  3643. }
  3644.  
  3645. SOM_Scope void  SOMLINK ContainerPartAttachSourceFrame(ContainerPart *somSelf,
  3646.                                            Environment *ev, ODFrame* frame,
  3647.                                           ODFrame* sourceFrame)
  3648. {
  3649.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3650.     ContainerPartMethodDebug("ContainerPart","ContainerPartAttachSourceFrame");
  3651.  
  3652.     if (_fDisplayFrames->Contains(frame)
  3653.        && sourceFrame && _fDisplayFrames->Contains(sourceFrame))
  3654.     {
  3655.       //RCR Note. DrawPart does not currently store embedded
  3656.       // frames on a per-containing-frame basis (eg. in the part info
  3657.       // of each frame). Since we can't add to the embedded frames list
  3658.       // while iterating over it, we make a temporary list here
  3659.  
  3660.         ODxOrderedCollection* embeddedFrames = new ODxOrderedCollection;
  3661.         {
  3662.           ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
  3663.           for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3664.               iter.IsNotComplete();
  3665.               embeddedFrame = (ODFrame*) iter.Next())
  3666.           {
  3667.             embeddedFrames->AddLast(embeddedFrame);
  3668.           }
  3669.         }
  3670.  
  3671.         ODxOrderedCollectionIterator iter(embeddedFrames);
  3672.         for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3673.             iter.IsNotComplete();
  3674.             embeddedFrame = (ODFrame*) iter.Next())
  3675.         {
  3676.           if (embeddedFrame->GetContainingFrame(ev) == sourceFrame)
  3677.           {
  3678.             ODPart* embeddedPart = embeddedFrame->GetPart(ev);
  3679.             ODShape* newShape = new ODShape();
  3680.             newShape->CopyFrom(ev, embeddedFrame->GetFrameShape(ev));
  3681.             ODTransform* newXForm = new ODTransform();
  3682.             newXForm->CopyFrom(ev, somSelf->ProxyForFrame(ev, embeddedFrame)->transform);
  3683.             ODFrame* newFrame = somSelf->MakeEmbeddedFrame(ev, frame,
  3684.                 newShape, newXForm, embeddedPart,
  3685.                 embeddedFrame->IsOverlaid(ev));
  3686.           embeddedPart->AttachSourceFrame(ev, newFrame, embeddedFrame);
  3687.           }
  3688.         }
  3689.         delete embeddedFrames; // Delete the copy
  3690.       }
  3691.     else
  3692.       THROW(kODErrInvalidFrame);
  3693. }
  3694.  
  3695. SOM_Scope void  SOMLINK ContainerPartRemoveDisplayFrame(ContainerPart *somSelf,
  3696.                                             Environment *ev,
  3697.                                            ODFrame* frame)
  3698. {
  3699.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3700.     ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveDisplayFrame");
  3701.  
  3702.     if (frame != kODNULL ) {
  3703.       if (_fDisplayFrames->Contains(frame))
  3704.       {
  3705.         ODxOrderedCollection* embeddedFrames = new ODxOrderedCollection;
  3706.         {
  3707.           ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
  3708.           for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3709.               iter.IsNotComplete();
  3710.               embeddedFrame = (ODFrame*) iter.Next())
  3711.           {
  3712.             embeddedFrames->AddLast(embeddedFrame);
  3713.           }
  3714.         }
  3715.         ODxOrderedCollectionIterator iter(embeddedFrames);
  3716.         for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3717.             iter.IsNotComplete();
  3718.             embeddedFrame = (ODFrame*) iter.Next())
  3719.         {
  3720.           if (embeddedFrame->GetContainingFrame(ev) == frame)
  3721.           {
  3722.   ////        embeddedFrame->Close(ev);
  3723.   //          _fEmbeddedFrames->Remove(embeddedFrame);
  3724.   ////        embeddedFrame->Release(ev);
  3725.   //          embeddedFrame->Remove(ev);
  3726.             somSelf->RemoveEmbeddedFrame(ev, embeddedFrame);
  3727.           }
  3728.         }
  3729.         delete embeddedFrames; // Delete the copy
  3730.  
  3731.         _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame);
  3732.  
  3733.         PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  3734.         frame->SetPartInfo(ev, (ODInfoType) kODNULL);
  3735.         delete pInfo;
  3736.         _fDisplayFrames->Remove(frame);
  3737.         frame->Release(ev);
  3738.  
  3739.         _fNeedToExternalize = kODTrue;
  3740.  
  3741.         ODxOrderedCollectionIterator dIter(_fDisplayFrames);
  3742.         ODFrame*  displayFrame = (ODFrame*) dIter.First();
  3743.         if (dIter.IsNotComplete() == kODFalse) {
  3744.           //somSelf->DestroyPalette(ev);
  3745.         }
  3746.       }
  3747.       else
  3748.         THROW(kODErrInvalidFrame);
  3749.     }
  3750.  
  3751.     // any display frames left?
  3752. }
  3753.  
  3754. SOM_Scope void  SOMLINK ContainerPartCloseDisplayFrame(ContainerPart *somSelf,
  3755.                                            Environment *ev, ODFrame* frame)
  3756. {
  3757.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3758.     ContainerPartMethodDebug("ContainerPart","ContainerPartCloseDisplayFrame");
  3759.  
  3760.     if (_fDisplayFrames->Contains(frame))
  3761.     {
  3762.       ODxOrderedCollection* embeddedFrames = new ODxOrderedCollection;
  3763.       {
  3764.         ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
  3765.         for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3766.             iter.IsNotComplete();
  3767.             embeddedFrame = (ODFrame*) iter.Next())
  3768.         {
  3769.           embeddedFrames->AddLast(embeddedFrame);
  3770.         }
  3771.       }
  3772.  
  3773.       ODxOrderedCollectionIterator iter(embeddedFrames);
  3774.       for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  3775.           iter.IsNotComplete();
  3776.           embeddedFrame = (ODFrame*) iter.Next())
  3777.       {
  3778.         if (embeddedFrame->GetContainingFrame(ev) == frame)
  3779.         {
  3780.           embeddedFrame->Close(ev);
  3781.           _fEmbeddedFrames->Remove(embeddedFrame);
  3782.           ODReleaseObject(ev,embeddedFrame);
  3783.         }
  3784.       }
  3785.       delete embeddedFrames; // Delete the copy
  3786.  
  3787.       _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
  3788.  
  3789.       PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  3790.       frame->SetPartInfo(ev, (ODInfoType) kODNULL);
  3791.       delete pInfo;
  3792.       _fDisplayFrames->Remove(frame);
  3793.       ODReleaseObject(ev,frame);
  3794.       _fNeedToExternalize = kODTrue;
  3795.     }
  3796.     else
  3797.       THROW(kODErrInvalidFrame);
  3798. }
  3799.  
  3800. SOM_Scope void  SOMLINK ContainerPartFrameShapeChanged(ContainerPart *somSelf,
  3801.                                            Environment *ev, ODFrame* frame)
  3802. {
  3803.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3804.     ContainerPartMethodDebug("ContainerPart","ContainerPartFrameShapeChanged");
  3805.  
  3806.     if (_fDisplayFrames->Contains(frame))
  3807.     {
  3808.       /// !!! should leave UsedShape and ActiveShape null to inherit FrameShape
  3809.     }
  3810.     else
  3811.       THROW(kODErrInvalidFrame);
  3812. }
  3813.  
  3814. SOM_Scope void  SOMLINK ContainerPartViewTypeChanged(ContainerPart *somSelf,
  3815.                                          Environment *ev, ODFrame* frame)
  3816. {
  3817.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3818.     ContainerPartMethodDebug("ContainerPart","ContainerPartViewTypeChanged");
  3819.  
  3820.     if (_fDisplayFrames->Contains(frame))
  3821.       { NOTDONE2("ViewTypeChanged"); /* !!! change viewType of frame */ }
  3822.     else
  3823.       THROW(kODErrInvalidFrame);
  3824. }
  3825.  
  3826. SOM_Scope void  SOMLINK ContainerPartPresentationChanged(ContainerPart *somSelf,
  3827.                                              Environment *ev,
  3828.                                             ODFrame* frame)
  3829. {
  3830.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3831.     ContainerPartMethodDebug("ContainerPart","ContainerPartPresentationChanged");
  3832.  
  3833.     if (_fDisplayFrames->Contains(frame))
  3834.       { NOTDONE2("PresentationChanged"); /* !!! change presentation of frame */ }
  3835.     else
  3836.       THROW(kODErrInvalidFrame);
  3837. }
  3838.  
  3839. SOM_Scope void  SOMLINK ContainerPartSequenceChanged(ContainerPart *somSelf,
  3840.                                          Environment *ev, ODFrame* frame)
  3841. {
  3842.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3843.     ContainerPartMethodDebug("ContainerPart","ContainerPartSequenceChanged");
  3844.  
  3845.     ContainerPart_parent_ODPart_SequenceChanged(somSelf, ev,
  3846.                                                 frame);
  3847. }
  3848.  
  3849. SOM_Scope void  SOMLINK ContainerPartWritePartInfo(ContainerPart *somSelf,
  3850.                                        Environment *ev, ODPtr partInfo,
  3851.                                       ODStorageUnitView* storageUnitView)
  3852. {
  3853.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3854.     ContainerPartMethodDebug("ContainerPart","ContainerPartWritePartInfo");
  3855.  
  3856.     if (partInfo)
  3857.     {
  3858.       RGBColor forDebuggingRGBColor ;
  3859.       forDebuggingRGBColor = ((PartInfoRec*)partInfo)->bgColor;
  3860.       storageUnitView->SetValue(ev, sizeof(RGBColor), (ODValue)&forDebuggingRGBColor);
  3861.       ODBoolean needsActivating = ((PartInfoRec*)partInfo)->fNeedsActivating
  3862.                     || ((PartInfoRec*)partInfo)->fIsActive;
  3863.       storageUnitView->SetValue(ev, sizeof(ODBoolean),
  3864.                     (ODValue)&needsActivating);
  3865. //+ (rlt 3-8-95)
  3866.       ODBoolean needsGrid = ((PartInfoRec*)partInfo)->fGridOn;
  3867.       storageUnitView->SetValue(ev, sizeof(ODBoolean),
  3868.                     (ODValue)&needsGrid);
  3869. //-
  3870.     }
  3871. }
  3872.  
  3873. SOM_Scope ODPtr  SOMLINK ContainerPartReadPartInfo(ContainerPart *somSelf,
  3874.                                        Environment *ev, ODFrame* frame,
  3875.                                       ODStorageUnitView* storageUnitView)
  3876. {
  3877.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3878.     ContainerPartMethodDebug("ContainerPart","ContainerPartReadPartInfo");
  3879.  
  3880.     if (storageUnitView->GetSize(ev))
  3881.     {
  3882.       PartInfoRec* partInfo = new PartInfoRec;
  3883.  
  3884.       RGBColor forDebuggingRGBColor ;
  3885.       storageUnitView->GetValue(ev, sizeof(RGBColor),
  3886.                     (ODValue)&forDebuggingRGBColor);
  3887.       partInfo->bgColor = forDebuggingRGBColor;
  3888.   //    storageUnitView->GetValue(ev, sizeof(RGBColor),
  3889.   //                  (ODValue)&(partInfo->bgColor));
  3890.       ODBoolean needsActivating;
  3891.       storageUnitView->GetValue(ev, sizeof(ODBoolean),
  3892.                     (ODValue)&(needsActivating));
  3893.       partInfo->fNeedsActivating = needsActivating;
  3894. //+ (rlt 3-8-95)
  3895.       ODBoolean needsGrid;
  3896.       storageUnitView->GetValue(ev, sizeof(ODBoolean),
  3897.                     (ODValue)&(needsGrid));
  3898.       partInfo->fGridOn = needsGrid;
  3899. //-
  3900.  
  3901.       ODxOrderedCollectionIterator d(_fDisplayFrames);
  3902.       ODFrame* dispFrame = (ODFrame*) d.First();
  3903.  
  3904.       return partInfo;
  3905.     }
  3906.     else
  3907.       return ((ODPtr)kODNULL);
  3908. }
  3909.  
  3910. SOM_Scope ODID  SOMLINK ContainerPartOpen(ContainerPart *somSelf,  Environment *ev,
  3911.                              ODFrame* frame)
  3912. {
  3913.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3914.     ContainerPartMethodDebug("ContainerPart","ContainerPartOpen");
  3915.  
  3916.     ODWindow* window = kODNULL;
  3917.  
  3918.     if (frame) // Doing a View As Window
  3919.     {
  3920.       window = _fSession->GetWindowState(ev)->GetWindow(ev, _fWindowID);
  3921.       if (window)
  3922.         window->Select(ev);
  3923.       else
  3924.       {
  3925.         window = somSelf->CreateWindow(ev, frame);
  3926.         _fWindowID = window->GetID(ev);
  3927.         window->Open(ev);
  3928.         window->Show(ev);
  3929.         window->Select(ev);
  3930.       }
  3931.     }
  3932.     else
  3933.     {
  3934.       window = somSelf->CreateWindow(ev, frame);
  3935.       _fWindowID = window->GetID(ev);
  3936.       window->Open(ev);
  3937.       window->Show(ev);
  3938.       window->Select(ev);
  3939.     }
  3940.     return window->GetID(ev);
  3941. }
  3942.  
  3943. SOM_Scope ODFrame*  SOMLINK ContainerPartRequestEmbeddedFrame(ContainerPart *somSelf,
  3944.                                                   Environment *ev,
  3945.                                                  ODFrame* containingFrame,
  3946.                                                  ODFrame* baseFrame,
  3947.                                                  ODShape* frameShape,
  3948.                                                  ODPart* embedPart,
  3949.                                                  ODTypeToken viewType,
  3950.                                                  ODTypeToken presentation,
  3951.                                                  ODBoolean isOverlaid)
  3952. {
  3953.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3954.     ContainerPartMethodDebug("ContainerPart","ContainerPartRequestEmbeddedFrame");
  3955.  
  3956. // Original container part code did not properly handle embedded frame requests.
  3957. // Modifications are from ContainerPartEmbed method.  mcs 3/1/95
  3958. #if 0 
  3959.     return (ContainerPart_parent_ODPart_RequestEmbeddedFrame(somSelf,
  3960.                                                              ev,
  3961.                                                              containingFrame,
  3962.                                                              baseFrame,
  3963.                                                              frameShape,
  3964.                                                              embedPart,
  3965.                                                              viewType,
  3966.                                                              presentation,
  3967.                                                              isOverlaid));
  3968. #endif
  3969.  
  3970.   ODTransform *externalTransform = new ODTransform;
  3971.   externalTransform->InitTransform(ev);
  3972.   ODFrame *embeddedFrame = somSelf->MakeEmbeddedFrame(ev,
  3973.                                                       containingFrame,
  3974.                                                       frameShape,
  3975.                                                       externalTransform,
  3976.                                                       embedPart,
  3977.                                                       isOverlaid);
  3978.  
  3979.   ODFrameFacetIterator* facets = containingFrame->CreateFacetIterator(ev);
  3980.   for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev);
  3981.       facet = facets->Next(ev))
  3982.   {
  3983.     ODShape* clip = new ODShape;
  3984.     clip->CopyFrom(ev, embeddedFrame->GetFrameShape(ev));
  3985.     ODTransform* xform = new ODTransform;
  3986.     xform->CopyFrom(ev, somSelf->ProxyForFrame(ev, embeddedFrame)->transform);
  3987.     facet->CreateEmbeddedFacet(ev, embeddedFrame, clip, xform, kODNULL, kODFrameInFront);
  3988.   }
  3989.   delete facets;
  3990.   somSelf->ClipEmbeddedFrames(ev, containingFrame);
  3991.   containingFrame->Invalidate(ev, NULL);
  3992.  
  3993.   ODReleaseObject(ev,embedPart);
  3994.  
  3995.   return embeddedFrame;
  3996.  
  3997. }
  3998.  
  3999. SOM_Scope void  SOMLINK ContainerPartRemoveEmbeddedFrame(ContainerPart *somSelf,
  4000.                                              Environment *ev,
  4001.                                             ODFrame* embeddedFrame)
  4002. {
  4003.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4004.     ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveEmbeddedFrame");
  4005.  
  4006.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  4007.     {
  4008.       ODFrame* containingFrame = embeddedFrame->GetContainingFrame(ev);
  4009.       Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  4010.       if (p)
  4011.       {
  4012.         _fNeedToExternalize = kODTrue;
  4013.         _fContents->Remove(p);
  4014.         ODDeleteObject(p->transform);
  4015. // (CED - 110594) GpiDestroyRegion( _hpsMem, p->region);
  4016.         delete p;
  4017.       }
  4018.       _fEmbeddedFrames->Remove(embeddedFrame);
  4019.       embeddedFrame->Remove(ev);
  4020.       //somSelf->GetStorageUnit(ev)->GetDraft(ev)->RemoveFrame(ev, embeddedFrame);
  4021.  
  4022.       somSelf->ClipEmbeddedFrames(ev, containingFrame);
  4023.  
  4024.     }
  4025.     else
  4026.       THROW(kODErrInvalidFrame);
  4027. }
  4028.  
  4029. SOM_Scope ODShape*  SOMLINK ContainerPartRequestFrameShape(ContainerPart *somSelf,
  4030.                                                Environment *ev,
  4031.                                               ODFrame* embeddedFrame,
  4032.                                               ODShape* frameShape)
  4033. {
  4034.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4035.     ContainerPartMethodDebug("ContainerPart","ContainerPartRequestFrameShape");
  4036.  
  4037.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  4038.     {  // find frame proxy and fix cached region
  4039.       Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  4040.       if (p)
  4041.       {
  4042. #if 0 // (CED - 110594) Proxy regions no longer used
  4043.         ODShape* scratch = new ODShape();
  4044.         scratch->CopyFrom(ev, frameShape);
  4045.         scratch->Transform(ev, p->transform);
  4046.         //p->region = scratch->CopyQDRegion(ev);
  4047.         p->region = scratch->CopyRegion(ev);
  4048.         delete scratch;
  4049. #endif
  4050.         p->frame->Invalidate(ev, kODNULL);
  4051.         p->frame->Invalidate(ev, frameShape);
  4052.  
  4053.         if (_fSelection->Contains(p)) { /* !!! fix highlighting */ };
  4054.  
  4055.         // fix clipping of obscured frames
  4056. //        somSelf->ClipEmbeddedFrames(ev, embeddedFrame->GetContainingFrame(ev));
  4057.       }
  4058.     }
  4059.     else
  4060.       THROW(kODErrInvalidFrame);
  4061.  
  4062.     return frameShape;
  4063. }
  4064.  
  4065. SOM_Scope void  SOMLINK ContainerPartUsedShapeChanged(ContainerPart *somSelf,
  4066.                                           Environment *ev, ODFrame* embeddedFrame)
  4067. {
  4068.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4069.     ContainerPartMethodDebug("ContainerPart","ContainerPartUsedShapeChanged");
  4070.  
  4071.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  4072.     {
  4073.       somSelf->ClipEmbeddedFrames(ev, embeddedFrame->GetContainingFrame(ev));
  4074.       embeddedFrame->Invalidate(ev, kODNULL); // RLT for DevCon 7
  4075.     }
  4076.     else
  4077.       THROW(kODErrInvalidFrame);
  4078. }
  4079.  
  4080. SOM_Scope ODShape*  SOMLINK ContainerPartAdjustBorderShape(ContainerPart *somSelf,
  4081.                                                Environment *ev,
  4082.                                               ODFrame* embeddedFrame,
  4083.                                               ODShape* shape)
  4084. {
  4085.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4086.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustBorderShape");
  4087.  
  4088.     return shape;
  4089. }
  4090.  
  4091. SOM_Scope void  SOMLINK ContainerPartFacetAdded(ContainerPart *somSelf,  Environment *ev,
  4092.                                    ODFacet* facet)
  4093. {
  4094.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4095.     ContainerPartMethodDebug("ContainerPart","ContainerPartFacetAdded");
  4096.  
  4097.     ODFrame* dispFrame = facet->GetFrame(ev);
  4098.     if (!_fDisplayFrames->Contains(dispFrame))
  4099.       THROW(kODErrInvalidFacet);
  4100.  
  4101.     ODShape* workingClip = new ODShape;
  4102.     workingClip->InitShape(ev);
  4103.     facet->SetPartInfo(ev, (ODInfoType)workingClip);
  4104.  
  4105.     ODxOrderedCollectionIterator frames(_fEmbeddedFrames);
  4106.     for (ODFrame* frame = (ODFrame*) frames.First();
  4107.         frames.IsNotComplete();
  4108.         frame = (ODFrame*) frames.Next())
  4109.     {
  4110.       if (frame->GetContainingFrame(ev) == dispFrame)
  4111.       {
  4112.         ODShape* clip = new ODShape;
  4113.         clip->CopyFrom(ev, frame->GetFrameShape(ev));
  4114.         ODTransform* xform = new ODTransform;
  4115.         xform->CopyFrom(ev, somSelf->ProxyForFrame(ev, frame)->transform);
  4116.         facet->CreateEmbeddedFacet(ev, frame,
  4117.                       clip, xform,
  4118.                       kODNULL, kODFrameBehind);
  4119.       }
  4120.     }
  4121.  
  4122.     somSelf->ClipEmbeddedFacets(ev, facet);
  4123. }
  4124.  
  4125. SOM_Scope void  SOMLINK ContainerPartFacetRemoved(ContainerPart *somSelf,
  4126.                                       Environment *ev, ODFacet* facet)
  4127. {
  4128.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4129.     ContainerPartMethodDebug("ContainerPart","ContainerPartFacetRemoved");
  4130.  
  4131.     ODFrame* dispFrame = facet->GetFrame(ev);
  4132.     if (!_fDisplayFrames->Contains(dispFrame))
  4133.       THROW(kODErrInvalidFacet);
  4134.  
  4135.     ODxOrderedCollection* children = new ODxOrderedCollection;
  4136.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  4137.     for (ODFacet* childFacet = facets->First(ev);
  4138.       facets->IsNotComplete(ev);
  4139.       childFacet = facets->Next(ev))
  4140.     {
  4141.       children->AddLast(childFacet);
  4142.     }
  4143.     delete facets;
  4144.     ODxOrderedCollectionIterator iter(children);
  4145.     for (childFacet = (ODFacet*)iter.First();
  4146.         iter.IsNotComplete();
  4147.         childFacet = (ODFacet*)iter.Next())
  4148.     {
  4149.       facet->RemoveFacet(ev, childFacet);
  4150.       delete childFacet;
  4151.     }
  4152.     #if 0
  4153.        // following line was in OS/2 version before SOM.  Not in Apple
  4154.        //   after SOM. Need to check if needed. todo. (jlc 94-8)
  4155.        delete (ODShape*)facet->GetPartInfo();
  4156.     #endif
  4157.     delete children;
  4158. }
  4159.  
  4160. SOM_Scope void  SOMLINK ContainerPartCanvasChanged(ContainerPart *somSelf,
  4161.                                        Environment *ev, ODFacet* facet)
  4162. {
  4163.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4164.     ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasChanged");
  4165.  
  4166. }
  4167.  
  4168. SOM_Scope void  SOMLINK ContainerPartGeometryChanged(ContainerPart *somSelf,
  4169.                                          Environment *ev, ODFacet* facet)
  4170. {
  4171.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4172.     ContainerPartMethodDebug("ContainerPart","ContainerPartGeometryChanged");
  4173.  
  4174.     somSelf->ClipEmbeddedFacets(ev, facet);  // extra work, but gives correct display
  4175. }
  4176.  
  4177. SOM_Scope void  SOMLINK ContainerPartDraw(ContainerPart *somSelf,  Environment *ev,
  4178.                              ODFacet* facet, ODShape* invalidShape)
  4179. {
  4180.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4181.     ContainerPartMethodDebug("ContainerPart","ContainerPartDraw");
  4182.  
  4183.     ODBoolean drawing = facet->GetCanvas(ev)->IsDynamic(ev);
  4184.  
  4185.     ODFrame* displayFrame = facet->GetFrame(ev);
  4186.     if (_fDisplayFrames->Contains(displayFrame))
  4187.     {
  4188.       // transform grafport
  4189.  
  4190.       HPS hpsDraw = facet->GetCanvas(ev)->GetPlatformCanvas(ev);
  4191.       GpiSavePS(hpsDraw);
  4192.  
  4193.  
  4194.       PartInfoRec* pInfo = (PartInfoRec*) displayFrame->GetPartInfo(ev);
  4195.       #if 1  // (CED - 110594)
  4196.          ODRect rect;
  4197.          displayFrame->GetFrameShape(ev)->GetBoundingBox(ev, &rect);
  4198.          ODRECTL frameRect(rect);
  4199.       #else
  4200.          HRGN frameRgn = displayFrame->GetFrameShape(ev)->GetQDRegion(ev);
  4201.          Rect frameRect;
  4202.          GpiQueryRegionBox(hpsDraw, frameRgn, &frameRect);
  4203.       #endif
  4204.       // set up clipping
  4205.       HRGN saveClip;
  4206.       ODShape* clipShape = new ODShape;
  4207.       clipShape->CopyFrom(ev, facet->GetAggregateClipShape(ev));
  4208. //    clipShape->Transform(ev, facet->GetContentTransform(ev));
  4209.       clipShape->Transform(ev, facet->GetFrameTransform(ev)); // RT - <8>
  4210.       //clipShape->Subtract(ev, (ODShape*)facet->GetPartInfo(ev));
  4211.  
  4212.       HRGN clip = clipShape->GetRegion(ev);
  4213.       GpiSetClipRegion(hpsDraw, clip, &saveClip);
  4214.  
  4215.       if (facet->GetFrame(ev)->GetPresentation(ev) == _fSession->Tokenize(ev, kContainerPartPresNormal))
  4216.       {
  4217.          ODTypeToken curView = facet->GetFrame(ev)->GetViewType(ev);
  4218.  
  4219.          if (curView == _fSession->Tokenize(ev, kODViewAsFrame))
  4220.          {
  4221.             // paint the background
  4222.  
  4223.             GpiResetPS(hpsDraw, GRES_ATTRS);
  4224.  
  4225.             somSelf->SetGrafPortOrigin(ev, facet);
  4226.  
  4227.             RGBColor bgRGB = pInfo->bgColor;
  4228.             //ULONG ulRGB = (bgRGB.bRed << 16) + (bgRGB.bGreen << 8) + bgRGB.bBlue;
  4229.             //ULONG lColorIndex = GpiQueryColorIndex(hpsDraw, 0, ulRGB);
  4230.             GpiSetColor(hpsDraw, pInfo->bgColor);
  4231.             #if 1 // (CED - 110594)
  4232.                //<crs>-110694 GpiErase(hpsDraw);
  4233.                POINTL ptl = {0, 0};
  4234.                GpiMove(hpsDraw, &ptl);
  4235.                ptl.x = frameRect.xRight;
  4236.                ptl.y = frameRect.yTop;
  4237.                GpiBox(hpsDraw, DRO_FILL, &ptl, 0, 0);
  4238.             #else
  4239.                GpiPaintRegion(hpsDraw, invalidShape->GetQDRegion(ev));
  4240.             #endif
  4241.             GpiSetLineType(hpsDraw, LINETYPE_DOT);
  4242.             GpiSetColor(hpsDraw, CLR_BLACK);
  4243.  
  4244.            if (pInfo->fGridOn){
  4245.               for (int y = YGRID / 2; y < frameRect.yTop; y += YGRID) {
  4246.                ptl.y = y;
  4247.                ptl.x = 0;
  4248.                GpiMove(hpsDraw, &ptl);
  4249.                ptl.x = frameRect.xRight;
  4250.                GpiLine(hpsDraw, &ptl);
  4251.                }
  4252.  
  4253.                for (int x = XGRID / 2; x < frameRect.xRight; x += XGRID) {
  4254.                ptl.x = x;
  4255.                ptl.y = 0;
  4256.                GpiMove(hpsDraw, &ptl);
  4257.                ptl.y = frameRect.yTop;
  4258.                GpiLine(hpsDraw, &ptl);
  4259.                }
  4260.            } /* endif fGridOn */
  4261.             // highlite the selected frame.
  4262.  
  4263.             if (displayFrame == _fSession->GetArbitrator(ev)->GetFocusOwner(ev, _fSelectionFocus))
  4264.             {  // drawing active frame - highlight selection
  4265.                somSelf->HighlightSelection(ev, facet);
  4266.             }
  4267.             else
  4268.             {  // drawing inactive frame - do nothing for now
  4269.             }
  4270.          }
  4271.          else if (curView == _fSession->Tokenize(ev, kODViewAsLargeIcon))
  4272.          {
  4273.             /* Render as large Icon */
  4274.          }
  4275.          else if (curView == _fSession->Tokenize(ev, kODViewAsSmallIcon))
  4276.          {
  4277.             /* Render as small icon */
  4278.          }
  4279.       }
  4280.       GpiRestorePS(hpsDraw, -1);
  4281.  
  4282.       GpiSetClipRegion(hpsDraw, saveClip, (PHRGN)0);
  4283.       facet->GetCanvas(ev)->ReleasePlatformCanvas(ev);
  4284.       delete clipShape;
  4285.     }
  4286.     else
  4287.     {
  4288.       // !!! signal error: invalid frame
  4289.     }
  4290. }
  4291.  
  4292. SOM_Scope void  SOMLINK ContainerPartCanvasUpdated(ContainerPart *somSelf,
  4293.                                        Environment *ev, ODCanvas* canvas)
  4294. {
  4295.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4296.     ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasUpdated");
  4297.  
  4298. }
  4299.  
  4300. SOM_Scope void  SOMLINK ContainerPartHighlightChanged(ContainerPart *somSelf,
  4301.                                           Environment *ev, ODFacet* facet)
  4302. {
  4303.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4304.     ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightChanged");
  4305.  
  4306. }
  4307.  
  4308. SOM_Scope ODULong  SOMLINK ContainerPartGetPrintResolution(ContainerPart *somSelf,
  4309.                                                Environment *ev,
  4310.                                               ODFrame* frame)
  4311. {
  4312.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4313.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetPrintResolution");
  4314.  
  4315.     NOTDONE2("GetPrintResolution");
  4316.                 // this is what the Apple code doesn, but it almost certainly
  4317.                 //  is incomplete.
  4318.     return 0;
  4319. }
  4320.  
  4321. SOM_Scope ODLink*  SOMLINK ContainerPartCreateLink(ContainerPart *somSelf,
  4322.                                        Environment *ev, ODPtr data,
  4323.                                       ODULong size)
  4324. {
  4325.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4326.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateLink");
  4327.  
  4328.     return kODNULL;
  4329. }
  4330.  
  4331. SOM_Scope void  SOMLINK ContainerPartLinkUpdated(ContainerPart *somSelf,  Environment *ev,
  4332.                                     ODLink* updatedLink, ODChangeID id)
  4333. {
  4334.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4335.     ContainerPartMethodDebug("ContainerPart","ContainerPartLinkUpdated");
  4336.  
  4337. }
  4338.  
  4339. SOM_Scope void  SOMLINK ContainerPartRevealLink(ContainerPart *somSelf,  Environment *ev,
  4340.                                    ODLinkSource* linkSource)
  4341. {
  4342.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4343.     ContainerPartMethodDebug("ContainerPart","ContainerPartRevealLink");
  4344.  
  4345. }
  4346.  
  4347. SOM_Scope void  SOMLINK ContainerPartEmbeddedFrameChanged(ContainerPart *somSelf,
  4348.                                               Environment *ev,
  4349.                                              ODFrame* frame,
  4350.                                              ODChangeID change)
  4351. {
  4352.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4353.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameChanged");
  4354.  
  4355. }
  4356.  
  4357. SOM_Scope void  SOMLINK ContainerPartLinkStatusChanged(ContainerPart *somSelf,
  4358.                                            Environment *ev, ODFrame* frame)
  4359. {
  4360.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4361.     ContainerPartMethodDebug("ContainerPart","ContainerPartLinkStatusChanged");
  4362.  
  4363. }
  4364.  
  4365. SOM_Scope ODBoolean  SOMLINK ContainerPartBeginRelinquishFocus(ContainerPart *somSelf,
  4366.                                                    Environment *ev,
  4367.                                                   ODTypeToken focus,
  4368.                                                   ODFrame* ownerFrame,
  4369.                                                   ODFrame* proposedFrame)
  4370. {
  4371.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4372.     ContainerPartMethodDebug("ContainerPart","ContainerPartBeginRelinquishFocus");
  4373.  
  4374.     return kODTrue;
  4375. }
  4376.  
  4377. SOM_Scope void  SOMLINK ContainerPartCommitRelinquishFocus(ContainerPart *somSelf,
  4378.                                                Environment *ev,
  4379.                                               ODTypeToken focus,
  4380.                                               ODFrame* ownerFrame,
  4381.                                               ODFrame* proposedFrame)
  4382. {
  4383.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4384.     ContainerPartMethodDebug("ContainerPart","ContainerPartCommitRelinquishFocus");
  4385.  
  4386.     somSelf->FocusLost(ev, focus, ownerFrame);
  4387.     //somSelf->HidePalette(ev);
  4388. }
  4389.  
  4390. SOM_Scope void  SOMLINK ContainerPartAbortRelinquishFocus(ContainerPart *somSelf,
  4391.                                               Environment *ev,
  4392.                                              ODTypeToken focus,
  4393.                                              ODFrame* ownerFrame,
  4394.                                              ODFrame* proposedFrame)
  4395. {
  4396.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4397.     ContainerPartMethodDebug("ContainerPart","ContainerPartAbortRelinquishFocus");
  4398.  
  4399. }
  4400.  
  4401. SOM_Scope void  SOMLINK ContainerPartFocusAcquired(ContainerPart *somSelf,
  4402.                                        Environment *ev, ODTypeToken focus,
  4403.                                       ODFrame* ownerFrame)
  4404. {
  4405.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4406.     ContainerPartMethodDebug("ContainerPart","ContainerPartFocusAcquired");
  4407.  
  4408.     if (focus == _fSelectionFocus)
  4409.     {
  4410.       PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
  4411.       pInfo->fIsActive = kODTrue;
  4412.  
  4413.       //somSelf->ShowPalette(ev);
  4414.     }
  4415.     else if (focus == _fMenuFocus)
  4416.       somSelf->InstallMenus(ev, ownerFrame);
  4417. #ifdef _PLATFORM_OS2_
  4418.     else if (focus == _fKeyFocus)
  4419.        somSelf->SetAccelTable(ev, ownerFrame);
  4420. #endif
  4421. }
  4422.  
  4423. SOM_Scope void  SOMLINK ContainerPartFocusLost(ContainerPart *somSelf,  Environment *ev,
  4424.                                   ODTypeToken focus, ODFrame* ownerFrame)
  4425. {
  4426.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4427.     ContainerPartMethodDebug("ContainerPart","ContainerPartFocusLost");
  4428.  
  4429.     if (focus == _fSelectionFocus)
  4430.     {
  4431.       if (_fTracking)
  4432.       {
  4433.         _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, ownerFrame);
  4434.         somSelf->FocusLost(ev, _fMouseFocus, ownerFrame);
  4435.       }
  4436.       PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
  4437.       pInfo->fIsActive = kODFalse;
  4438.       somSelf->InvalidateSelection(ev, ownerFrame);
  4439.       if (_fSelection->Count())
  4440.       {
  4441.         somSelf->EmptySelection(ev);
  4442.         somSelf->ClipEmbeddedFrames(ev, ownerFrame);
  4443.       }
  4444.       //somSelf->HidePalette(ev);
  4445.     }
  4446.     else if (focus == _fMenuFocus)
  4447.       somSelf->RemoveMenus(ev, ownerFrame);
  4448.     else if (focus == _fKeyFocus)
  4449.        somSelf->ClearAccelTable(ev, ownerFrame);
  4450.     else if (focus == _fMouseFocus)
  4451.     {
  4452.       if (_fTracking)
  4453.         somSelf->MouseFocusLost(ev, ownerFrame);
  4454.     }
  4455. }
  4456.  
  4457. SOM_Scope void  SOMLINK ContainerPartCloneInto(ContainerPart *somSelf,  Environment *ev,
  4458.                                   ODDraftKey key, ODStorageUnit* storageUnit,
  4459.                                   ODStorageUnit* initiatingFrame)
  4460. {
  4461.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4462.     ContainerPartMethodDebug("ContainerPart","ContainerPartCloneInto");
  4463.  
  4464.     ODStorageUnit*  su = somSelf->GetStorageUnit(ev);
  4465.  
  4466.     somSelf->Externalize(ev);
  4467.     #if 0
  4468.        ODStorageUnit* destTestDrawSU = _fTestDrawSU
  4469.                ->CloneTo(ev, key, storageUnit->GetDraft(ev), initiatingFrame);
  4470.    
  4471.        storageUnit->AddProperty(ev, kODPropContents);
  4472.        storageUnit->AddValue(ev, kKindTestContainer);
  4473.        ODStorageUnitRef aSURef = storageUnit->GetStrongStorageUnitRef(ev, destTestDrawSU);
  4474.        storageUnit->SetValue(ev, sizeof(ODStorageUnitRef),&aSURef);
  4475.     #endif
  4476.  
  4477.  
  4478.     ODxOrderedCollectionIterator contentsIter(_fContents);
  4479.     Proxy* proxy;
  4480.     for (proxy = (Proxy*)contentsIter.First();
  4481.         contentsIter.IsNotComplete();
  4482.         proxy = (Proxy*)contentsIter.Next())
  4483.     {
  4484.       if ((initiatingFrame== kODNULL) ||
  4485.         (proxy->frame->GetContainingFrame(ev)->GetStorageUnit(ev) == initiatingFrame)) {
  4486.         ODStorageUnit* toFrameSU = proxy->frame->CloneTo(ev, key, storageUnit->GetDraft(ev));
  4487.         toFrameSU->Release(ev);
  4488.       }
  4489.     }
  4490.     #if 0
  4491.        destTestDrawSU->Release(ev);
  4492.     #endif
  4493.  
  4494.     su->CloneInto(ev, key, storageUnit, initiatingFrame);
  4495. }
  4496.  
  4497. SOM_Scope void  SOMLINK ContainerPartExternalizeKinds(ContainerPart *somSelf,
  4498.                                           Environment *ev, ODTypeList* kindset)
  4499. {
  4500.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4501.     ContainerPartMethodDebug("ContainerPart","ContainerPartExternalizeKinds");
  4502.  
  4503.     // This part only supports one kind and always externalizes it, so no
  4504.     //    could should be needed here.   (jlc 94-11-26)
  4505. }
  4506.  
  4507.  
  4508.  
  4509. SOM_Scope void  SOMLINK ContainerPartExternalize(ContainerPart *somSelf,  Environment *ev)
  4510. {
  4511.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4512.     ContainerPartMethodDebug("ContainerPart","ContainerPartExternalize");
  4513.  
  4514.     ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  4515.     ODStorageUnitRef aSURef;
  4516.     ODULong offset;
  4517.     ODFrame* frame;
  4518.     Proxy* proxy;
  4519.     ODxOrderedCollectionIterator aIter(_fDisplayFrames);
  4520.     //ODxOrderedCollectionIterator bIter(_fEmbeddedFrames);
  4521.     ODxOrderedCollectionIterator cIter(_fContents);
  4522.     ODPOINTL xform;
  4523.    
  4524.     if ( _fNeedToExternalize ) {
  4525.        su->Focus(ev, kODPropDisplayFrames,kODPosUndefined,0,1,kODPosFirstSib);
  4526.        #ifndef SSREMOVEWORKAROUND
  4527.          su->Remove(ev);
  4528.          su->AddProperty(ev, kODPropDisplayFrames);
  4529.          su->AddValue(ev, kODIDs);
  4530.        #else
  4531.          ODULong oldValueSize = su->GetSize(ev);;
  4532.        #endif
  4533.        offset = 0;
  4534.        for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
  4535.            frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
  4536.        {
  4537.          // jlc asserts that we don't need to externalize/clone our display frame because it
  4538.          //    is already externalized since it is the frame externization method that 
  4539.          //    (indirectly) calls this method.  As it turns out, if we have multiple display
  4540.          //    frames, we *might* need to externalize/clone our other display frames.  For now,
  4541.          //    I'm removing this code since in the case of externalization, it tends to slightly 
  4542.          //    reduce the size of resulting file. (jlc 94-11-26)
  4543.          //frame->Externalize(ev);
  4544.    
  4545.          // jlc asserts that we probably only want to store references to frames that
  4546.          //       descend from some root cloned frame.  In a future drop, the following
  4547.          //       code is likely to be conditionally executed. (jlc 94-11-26)
  4548.          aSURef = su->GetWeakStorageUnitRef(ev, frame->GetStorageUnit(ev));
  4549.          su->SetOffset(ev, offset);
  4550.          su->SetValue(ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  4551.        }
  4552.        #ifdef SSREMOVEWORKAROUND
  4553.          if (oldValueSize > offset)
  4554.            su->DeleteValue(ev, oldValueSize-offset);
  4555.        #endif
  4556.     } /* endif */
  4557.    
  4558.     // This Focus call was recently changed to focus on a property of a certain type 
  4559.     //   rather than just the first value/type.  This was done for the sake of subclassing 
  4560.     //   classes.  The subclass might add another type/value pair, and we
  4561.     //   don't want this code writing into the wrong type/value. <4> 
  4562.     su->Focus(ev, kODPropContents,kODPosUndefined,kKindTestContainer,0,kODPosUndefined);
  4563.  
  4564.     #ifndef SSREMOVEWORKAROUND
  4565.       if ( _fNeedToExternalize ) {
  4566.          su->Remove(ev);
  4567.          su->AddProperty(ev, kODPropContents);
  4568.          su->AddValue(ev, kKindTestContainer);
  4569.       } /* endif */
  4570.     #else
  4571.       oldValueSize = su->GetSize(ev);;
  4572.     #endif
  4573.     offset = 0;
  4574.     for (proxy = (Proxy*)cIter.First();
  4575.         cIter.IsNotComplete();
  4576.         proxy = (Proxy*)cIter.Next())
  4577.     {
  4578.       ODPoint ptxform;
  4579.       // When cloning, we explicitly need to externalize our embedded frames to insure
  4580.       //   that they actually get imbedded.  In actuality, I suspect that only descendent
  4581.       //   frames of a certain frame will need to be externalized, but for now, I'll just
  4582.       //   externalize all of them. (jlc 94-11-26)
  4583.       proxy->frame->Externalize(ev);
  4584.  
  4585.       if ( _fNeedToExternalize ) {
  4586.          aSURef = su->GetStrongStorageUnitRef(ev,
  4587.              proxy->frame->GetStorageUnit(ev));
  4588.          su->SetOffset(ev, offset);
  4589.          su->SetValue(ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  4590.          offset += sizeof(ODStorageUnitRef);
  4591.          proxy->transform->GetOffset(ev, &ptxform);
  4592.          su->SetOffset(ev, offset);
  4593.          su->SetValue(ev, sizeof(ptxform), (ODValue)&ptxform);
  4594.          offset += sizeof(ptxform);
  4595.       } /* endif */
  4596.     }
  4597.     #ifdef SSREMOVEWORKAROUND
  4598.       if ( _fNeedToExternalize ) {
  4599.          if (oldValueSize > offset)
  4600.            su->DeleteValue(ev, oldValueSize-offset);
  4601.       } /* endif */
  4602.     #endif
  4603.     _fNeedToExternalize = kODFalse;
  4604. }
  4605.  
  4606. SOM_Scope void  SOMLINK ContainerPartChangeKind(ContainerPart *somSelf,  Environment *ev,
  4607.                                    ODType kind)
  4608. {
  4609.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4610.     ContainerPartMethodDebug("ContainerPart","ContainerPartChangeKind");
  4611.  
  4612. }
  4613.  
  4614.  
  4615. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleEvent(ContainerPart *somSelf,
  4616.                                                        Environment *ev,
  4617.                                                       ODEventData* event,
  4618.                                                       ODFrame* frame,
  4619.                                                       ODFacet* facet)
  4620. {
  4621.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4622.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEvent");
  4623.  
  4624.     ODBoolean handled = kODFalse;
  4625.  
  4626.     switch (event->msg)
  4627.     {
  4628.        case WM_BUTTON1DOWN:
  4629.        case WM_BUTTON2DOWN:
  4630.         {
  4631.           ODPoint windowODPoint(ODPOINTL(SHORT1FROMMP(event->mp1),
  4632.                                          SHORT2FROMMP(event->mp1)));
  4633.           if (event->ulFlags & (kODInEmbedded | kODInBorder))
  4634.           {
  4635.                 handled = somSelf->HandleMouseDownInEmbeddedFrame(ev, facet,
  4636.                                   (ODFacet*)event->mpExtra, &windowODPoint, event);
  4637.           }
  4638.           else
  4639.           {
  4640.                 handled = somSelf->HandleMouseDown(ev, facet, &windowODPoint, event);
  4641.           }
  4642.           break;
  4643.         }
  4644.        case WM_CONTEXTMENU       :
  4645.           {
  4646.              ODPopupContainerMenu * pum = new ODPopupContainerMenu;
  4647.              pum->InitPopupContainerMenu( ev, _fSession, frame );
  4648.              pum->Display( ev );
  4649.              event->result = (MRESULT)1; // handled
  4650.              handled = kODTrue;
  4651.           }
  4652.           break;
  4653.        case WM_MOUSEMOVE:
  4654.           {
  4655.           ODPoint windowODPoint(ODPOINTL(SHORT1FROMMP(event->mp1),
  4656.                                          SHORT2FROMMP(event->mp1)));
  4657.           handled = somSelf->HandleMouseMove(ev, facet, frame, &windowODPoint, event);
  4658.           }
  4659.           break;
  4660.  
  4661.        case WM_BUTTON1UP:
  4662.           {
  4663.           ODPoint windowODPoint(ODPOINTL(SHORT1FROMMP(event->mp1),
  4664.                                          SHORT2FROMMP(event->mp1)));
  4665.           handled = somSelf->HandleMouseUp(ev, facet, frame, &windowODPoint, event);
  4666.           }
  4667.           break;
  4668.  
  4669.        /* JYS: use accelerator instead!
  4670.        case WM_CHAR:
  4671.           if (!(SHORT1FROMMP(event->mp1) & KC_KEYUP))
  4672.           {
  4673.             handled = somSelf->HandleKeyDown(ev, frame, event);
  4674.           }
  4675.           break;
  4676.        */
  4677.        case WM_ACTIVATE:
  4678.           handled = true; // actually ignored by dispatcher
  4679.           if (SHORT1FROMMP(event->mp1) != 0)
  4680.              somSelf->ActivatingWindow(ev, frame);
  4681.           else
  4682.              somSelf->DeActivatingWindow(ev, frame);
  4683.           break;
  4684.  
  4685.        case WM_COMMAND:
  4686.           if (SHORT1FROMMP(event->mp2) & CMDSRC_MENU ||
  4687.               SHORT1FROMMP(event->mp2) & CMDSRC_ACCELERATOR)
  4688.           {
  4689.             handled = somSelf->HandleMenuEvent(ev, frame, event);
  4690.           }
  4691.           break;
  4692.  
  4693.        default:
  4694.           return kODFalse;
  4695.     }
  4696.     return handled;
  4697. }
  4698.  
  4699.  
  4700. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleEventInEmbedded(ContainerPart *somSelf,
  4701.                                                                  Environment *ev,
  4702.                                                                 ODEventData* event,
  4703.                                                                 ODFrame* frame,
  4704.                                                                 ODFacet* facet,
  4705.                                                                 ODFrame* embeddedFrame,
  4706.                                                                 ODFacet* embeddedFacet)
  4707. {
  4708.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4709.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEventInEmbedded");
  4710.  
  4711.     return kODFalse;
  4712. }
  4713.  
  4714. SOM_Scope void  SOMLINK ContainerPartMouseEnter(ContainerPart *somSelf,  Environment *ev,
  4715.                                    ODFacet* facet, ODPoint* where)
  4716. {
  4717.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4718.     ContainerPartMethodDebug("ContainerPart","ContainerPartMouseEnter");
  4719.  
  4720.     NOTDONE2("MouseEnter");  // need to add code here to change the pointer to whatever
  4721.                                       //   pointer type we prefer.
  4722. }
  4723.  
  4724. SOM_Scope void  SOMLINK ContainerPartMouseWithin(ContainerPart *somSelf,  Environment *ev,
  4725.                                     ODFacet* facet, ODPoint* where)
  4726. {
  4727.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4728.     ContainerPartMethodDebug("ContainerPart","ContainerPartMouseWithin");
  4729.  
  4730. }
  4731.  
  4732. SOM_Scope void  SOMLINK ContainerPartMouseLeave(ContainerPart *somSelf,  Environment *ev,
  4733.                                    ODFacet* facet)
  4734. {
  4735.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4736.     ContainerPartMethodDebug("ContainerPart","ContainerPartMouseLeave");
  4737.  
  4738.     // we may need to restore the pointer here.  I'll check later. todo (jlc 94-8)
  4739. }
  4740.  
  4741.  
  4742. ODMenuBar * SOMLINK ContainerPartGetSPEMenuOfSelection( ContainerPart *somSelf, Environment *ev )
  4743. {
  4744.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4745.     ContainerPartMethodDebug("ContainerPart","ContainerGetSPEMenuOfSelection");
  4746.  
  4747.    if ( _fSPEMenuOfSelection) return _fSPEMenuOfSelection;
  4748.  
  4749.    ODMenuBar * mbx = kODNULL;
  4750.  
  4751.    if (_fSelection->Count() == 1 ) {
  4752.       ODxOrderedCollectionIterator i(_fSelection);
  4753.       Proxy *p = (Proxy*)i.First();
  4754.       ODPart * selectedPart = p->frame->GetPart( ev);
  4755.       ODSelectedPartExtension * spe;
  4756.       if ( selectedPart->HasExtension( ev, kODExtSelectedPartExtension)) {
  4757.          spe = (ODSelectedPartExtension*) selectedPart->GetExtension( ev, kODExtSelectedPartExtension);
  4758.       } else {
  4759.          spe = 0;
  4760.       } /* endif */
  4761.       if (spe) {
  4762.          mbx = spe->GetMenu( ev, p->frame);
  4763.          if (mbx) {
  4764.             mbx->UpdateMenuDependencyChain( ev, ODMENUID_ALL );
  4765.             if ( !mbx->GetFirstMenuID( ev, ODMENUID_ROOT) ) {
  4766.                mbx = 0;
  4767.             } else {
  4768.                // we do this to insure that it isn't released when we call ReleaseExtension.
  4769.                mbx->IncrementRefCount(ev );
  4770.                _fSPEMenuOfSelection = mbx;  
  4771.             } /* endif */
  4772.          } /* endif */
  4773.          selectedPart->ReleaseExtension( ev, spe );
  4774.       } else {
  4775.          // selected part didn't have an extension
  4776.       } /* endif */
  4777.    } /* endif */
  4778.    return mbx;
  4779. }
  4780.  
  4781. void SOMLINK ContainerPartRefreshRemappedSPEMenuOfSelection( ContainerPart *somSelf, Environment *ev )
  4782. {
  4783.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4784.     ContainerPartMethodDebug("ContainerPart","ContainerRefreshRemappedSPEMenuOfSelection");
  4785.  
  4786.    if ( !_fSPEMenuOfSelection) return;
  4787.  
  4788.    ODMenuBar * mbTmp;
  4789.    if ( _fRemappedSPEMenuOfSelection ) {
  4790.       mbTmp = _fRemappedSPEMenuOfSelection;
  4791.       mbTmp->RemoveMenu( ev, ODMENUID_ROOT );
  4792.    } else {
  4793.       mbTmp = new ODMenuBar;
  4794.       mbTmp->InitMenuBar(ev,  /*_fSession*/0, /*menu:*/0 );
  4795.       _fRemappedSPEMenuOfSelection = mbTmp;
  4796.    } /* endif */
  4797.  
  4798.    mbTmp->AddMenuBLast(ev,  _fSPEMenuOfSelection, ODMENUID_ROOT );
  4799.    // I've just duplicated the menu.  Now I'll remap the ID's.
  4800.    ODMenuID toLow = IDMA_CNT_SELECTEDREMAP_FIRST;
  4801.    mbTmp->RemapIDs( ev, ODMENUID_SHELL_FIRST, ODMENUID_USER_LAST
  4802.                   ,     &toLow,               IDMA_CNT_SELECTEDREMAP_LAST  
  4803.                   );
  4804. }
  4805.  
  4806. SOM_Scope void  SOMLINK ContainerPartFillSelectedMenu( ContainerPart *somSelf,  Environment *ev,
  4807.         ODFrame * frame, ODMenuBar * menubar)
  4808. {
  4809.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4810.     ContainerPartMethodDebug("ContainerPart","ContainerPartFillSelectedMenu");
  4811.  
  4812.     HMODULE hmodDLL;
  4813.     
  4814.     if (DosQueryModuleHandle( THISDLL, &hmodDLL)) {
  4815.        beepprintf( "Isn't my DLL (%s) loaded?", THISDLL );   
  4816.     } /* endif */
  4817.     ODPlatformMenuBar   menuBar;
  4818.  
  4819.  
  4820.     ODBoolean ItemsAdded = kODFalse;
  4821.     if (_fSelection->Count() == 1 ) {
  4822.        AddMenuResourceLast( ev, hmodDLL, RESID_SELECTEDMENU, menubar, IDMS_SELECTED);
  4823.  
  4824.        ODMenuBar * mbx = somSelf->GetSPEMenuOfSelection( ev);
  4825.        if (mbx) {
  4826.           mbx->UpdateMenuDependencyChain( ev, ODMENUID_ALL );
  4827.           somSelf->RefreshRemappedSPEMenuOfSelection( ev );
  4828.           if ( _fRemappedSPEMenuOfSelection && _fRemappedSPEMenuOfSelection->GetFirstMenuID( ev, ODMENUID_ROOT) ) {
  4829.              ItemsAdded = kODTrue;
  4830.              menubar->AddMenuBLast( ev, _fRemappedSPEMenuOfSelection, IDMS_SELECTED );
  4831.           } /* endif */
  4832.        } /* endif */
  4833.     } else if (_fSelection->Count() > 1) {
  4834.           // if we supported multiple selection, we'd support the
  4835.           //    the our current (10/94) spectrum of commands on the
  4836.           //    selected menu, so we wouldn't need to disable any.
  4837.     } else {
  4838.           // there is no selection.  We'll disable the menu items
  4839.           //   here since they don't do anything.
  4840.           AddMenuResourceLast( ev, hmodDLL, RESID_NOTHINGSELECTEDMENU, menubar, IDMS_SELECTED);
  4841.     } /* endif */
  4842.  
  4843.     if (!ItemsAdded) {
  4844.        // remove the additional separator that we put in since
  4845.        //   it doesn't look very good if it is there, but there are
  4846.        //   no items below it.
  4847.        menubar->RemoveMenu( ev, IDMA_CNT_SEPARATOR5 );
  4848.     } /* endif */
  4849. }
  4850.  
  4851. SOM_Scope void  SOMLINK ContainerPartAdjustSPEMenu( ContainerPart *somSelf,  Environment *ev,
  4852.         ODFrame * frame, ODMenuBar * menubar, ODMenuID menuID )
  4853. {
  4854.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4855.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustSPEMenu");
  4856.  
  4857.     // the following code could be made more efficient, by only updating the 
  4858.     //     portion of the menubar designated by the menuID parameter.
  4859.  
  4860.     menubar->RemoveMenu( ev, ODMENUID_ROOT );
  4861.  
  4862.     HMODULE hmodDLL;
  4863.     if (DosQueryModuleHandle( THISDLL, &hmodDLL)) {
  4864.        beepprintf( "Isn't my DLL (%s) loaded?", THISDLL );   
  4865.     } /* endif */
  4866.     ODPlatformMenuBar   menuBar2;
  4867.     
  4868.     DosGetResource2( hmodDLL
  4869.                    , RT_MENU
  4870.                    , RESID_WHENSELECTEDMENU
  4871.                    , (PPVOID)&menuBar2
  4872.                    );
  4873.     menubar->AddMenuLast( ev, ODMENUID_ROOT, menuBar2, 0 );
  4874.     DosFreeResource( (PVOID)menuBar2 );
  4875.  
  4876.     AddMenuResourceLast( ev, hmodDLL, RESID_BACKGROUNDMENU, menubar, IDMSL_COLOR_BASE );
  4877.  
  4878.     PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  4879.     ODUShort mi = MenuColorFromRGBColor( pInfo->bgColor );
  4880.     menubar->CheckItem(  ev, mi, kODTrue );
  4881. }
  4882.  
  4883. SOM_Scope void  SOMLINK ContainerPartAdjustPopupMenu( ContainerPart *somSelf,  Environment *ev,
  4884.         ODFrame * frame, ODMenuBar * menubar,  ODMenuID menuID )
  4885. {
  4886.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4887.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustPopupMenu");
  4888.  
  4889.     // the following code could be made more efficient, by only updating the 
  4890.     //     portion of the menubar designated by the menuID parameter.
  4891.  
  4892.     enum { selectedMenu, selfMenu } WhichMenu;
  4893.     {
  4894.        // Right here one would normally have code that decides which
  4895.        //   menu to display.  One of the criterion would be if the click
  4896.        //   was in the selected area.  Right now, I haven't added any code
  4897.        //   to detect where the click was, so I'll just alter the menu 
  4898.        //   depending if there is a selection or not rather than if the click
  4899.        //   was over the selection.  In a few weeks I'll add code to 
  4900.        //   comply with the Human Interface Specification.
  4901.  
  4902.        WhichMenu = (_fSelection->Count() > 0)  ? selectedMenu :  selfMenu;
  4903.     }
  4904.  
  4905.     HMODULE hmodDLL;
  4906.     if (DosQueryModuleHandle( THISDLL, &hmodDLL)) {
  4907.        beepprintf( "Isn't my DLL (%s) loaded?", THISDLL );   
  4908.     } /* endif */
  4909.     ODPlatformMenuBar   menuBar;
  4910.  
  4911.     menubar->RemoveMenu( ev, ODMENUID_ROOT );
  4912.  
  4913.     if ( WhichMenu == selectedMenu ) {
  4914.    
  4915.        DosGetResource2( hmodDLL
  4916.                       , RT_MENU
  4917.                       , RESID_POPUPMENU_S
  4918.                       , (PPVOID)&menuBar
  4919.                       );
  4920.        {
  4921.           ODMenuBar * mbNew = new ODMenuBar;
  4922.           mbNew->InitMenuBar(ev,  _fSession, menuBar );
  4923.           menubar->AddMenuBLast(ev,  mbNew, ODMENUID_ROOT );
  4924.           delete mbNew;
  4925.        }
  4926.        DosFreeResource( (PVOID)menuBar );
  4927.    
  4928.        ODBoolean ItemsAdded = kODFalse;
  4929.        if (_fSelection->Count() == 1 ) {
  4930.           ODMenuBar * mbx = somSelf->GetSPEMenuOfSelection( ev);
  4931.           if (mbx) {
  4932.              mbx->UpdateMenuDependencyChain( ev, ODMENUID_ALL );
  4933.              somSelf->RefreshRemappedSPEMenuOfSelection( ev );
  4934.              if ( _fRemappedSPEMenuOfSelection && _fRemappedSPEMenuOfSelection->GetFirstMenuID( ev, ODMENUID_ROOT) ) {
  4935.                 ItemsAdded = kODTrue;
  4936.                 menubar->AddMenuBLast( ev, _fRemappedSPEMenuOfSelection, ODMENUID_ROOT );
  4937.              } /* endif */
  4938.           } /* endif */
  4939.        } else {
  4940.           // if we supported multiple selection, we'd support the
  4941.           //    the our current (10/94) spectrum of commands on the
  4942.           //    selected menu, so we wouldn't need to disable any.
  4943.        } /* endif */
  4944.  
  4945.        if (!ItemsAdded) {
  4946.           // remove the additional separator that we put in since
  4947.           //   it doesn't look very good if it is there, but there are
  4948.           //   no items below it.
  4949.           menubar->RemoveMenu( ev, IDMP_CNT_SEPARATOR8 );
  4950.        } /* endif */
  4951.     } else if ( WhichMenu == selfMenu ) {
  4952.        // this is the popup menu that I've chosen to display when a the
  4953.        //    RMB click is over the background.  
  4954.        DosGetResource2( hmodDLL
  4955.                       , RT_MENU
  4956.                       , RESID_POPUPMENU_O
  4957.                       , (PPVOID)&menuBar
  4958.                       );
  4959.        {
  4960.           ODMenuBar * mbNew = new ODMenuBar;
  4961.           mbNew->InitMenuBar(ev,  _fSession, menuBar );
  4962.           menubar->AddMenuBLast(ev,  mbNew, ODMENUID_ROOT );
  4963. //+ (rlt 3-8-95)
  4964.        PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  4965.        menubar->CheckItem( ev, IDMA_TOGGLE_GRID, pInfo->fGridOn);
  4966. //-
  4967.           delete mbNew;
  4968.        }
  4969.  
  4970.        DosGetResource2( hmodDLL
  4971.                       , RT_MENU
  4972.                       , RESID_BACKGROUNDMENU
  4973.                       , (PPVOID)&menuBar
  4974.                       );
  4975.        {
  4976.  
  4977.           ODMenuBar * mbNew = new ODMenuBar;
  4978.           mbNew->InitMenuBar(ev,  _fSession, menuBar );
  4979.           menubar->AddMenuBLast(ev,  mbNew, IDMP_COLOR_BASE );
  4980.           delete mbNew;
  4981.        }
  4982.        DosFreeResource( (PVOID)menuBar );
  4983.  
  4984.        PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  4985.        ODUShort mi = MenuColorFromRGBColor( pInfo->bgColor );
  4986.        menubar->CheckItem(  ev, mi, kODTrue );
  4987.     } else {
  4988.        // this part doesn't really have any intrinsic data, but if it did
  4989.        //   I might chose to build a special popup menu here that
  4990.        //   reflects the actions that can be performed on the piece
  4991.        //   of intrinsic data under the mouse pointer.
  4992.     } /* endif */
  4993. }
  4994.  
  4995. SOM_Scope void  SOMLINK ContainerPartAdjustMenus(ContainerPart *somSelf,  Environment *ev,
  4996.                                     ODFrame* frame)
  4997. {
  4998.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4999.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustMenus");
  5000.  
  5001.     PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  5002.     #ifdef USE_PARTINFO_TO_RECALL_AMENU
  5003.        ODActiveFrameMenuBar * mb = pInfo->mbActive;
  5004.     #else
  5005.        ODActiveFrameMenuBar * mb = (ODActiveFrameMenuBar*)frame->GetWindow(ev)->GetMenuBar( ev);
  5006.     #endif
  5007.  
  5008.     mb->RemoveMenu( ev, ODMENUID_ROOT );
  5009.  
  5010.     ODWindow * window = frame->GetWindow( ev);
  5011.     ODMenuBar * mbold = window->GetBaseMenuBar(ev);
  5012.     mb->AddMenuBLast( ev, mbold, ODMENUID_ROOT );
  5013.  
  5014.     #if 1
  5015.        HMODULE hmodDLL;
  5016.        if (DosQueryModuleHandle( THISDLL, &hmodDLL)) {
  5017.           beepprintf( "Isn't my DLL (%s) loaded?", THISDLL );   
  5018.        } /* endif */
  5019.        ODPlatformMenuBar   menuBar;
  5020.  
  5021.        DosGetResource2( hmodDLL
  5022.                       , RT_MENU
  5023.                       , RESID_TOPMENU
  5024.                       , (PPVOID)&menuBar
  5025.                       );
  5026.        mb->AddMenuBefore(ev,  kODNULL, menuBar, somSelf, IDMS_HELP );
  5027.        DosFreeResource( (PVOID)menuBar );
  5028.  
  5029.        DosGetResource2( hmodDLL
  5030.                       , RT_MENU
  5031.                       , RESID_EDMENU
  5032.                       , (PPVOID)&menuBar
  5033.                       );
  5034.        {
  5035.           ODMenuBar * mbNew = new ODMenuBar;
  5036.           mbNew->InitMenuBar(ev,  _fSession, menuBar );
  5037.           mb->AddMenuBLast(ev,  mbNew, IDMS_EDIT );
  5038.           delete mbNew;
  5039.        }
  5040.        DosFreeResource( (PVOID)menuBar );
  5041.  
  5042.        DosGetResource2( hmodDLL
  5043.                       , RT_MENU
  5044.                       , RESID_BACKGROUNDMENU
  5045.                       , (PPVOID)&menuBar
  5046.                       );
  5047.        {
  5048.           ODMenuBar * mbNew = new ODMenuBar;
  5049.           mbNew->InitMenuBar(ev,  _fSession, menuBar );
  5050.           mb->AddMenuBLast(ev,  mbNew, IDMA_COLOR_BASE );
  5051.           delete mbNew;
  5052.        }
  5053.        DosFreeResource( (PVOID)menuBar );
  5054.        {
  5055.           CollectHandlers(ev, _fSession);
  5056.           mb->AddMenuBLast(ev,  mbPartHandlers, IDMA_EMBED_BASE);
  5057.        }
  5058.        somSelf->FillSelectedMenu( ev,
  5059.                           frame, mb );
  5060.     #endif
  5061.  
  5062.  
  5063.     // for demo purposes, we'll do some wacky things here with
  5064.     //   menu item text, check state, and enablement.
  5065.     #if 1
  5066.        _DemoOpenCount++;
  5067.        {
  5068.           char stagestring[40];
  5069.           sprintf( stagestring, "Menu open count: %d", _DemoOpenCount);
  5070.           mb->SetItemString( ev, IDMA_CNT_DEMOITEM2, stagestring);
  5071.        }
  5072.  
  5073.        mb->CheckItem(  ev, IDMA_CNT_DEMOITEM2, (_DemoState & 1) );
  5074.        mb->EnableItem( ev, IDMA_CNT_DEMOITEM2, (_DemoState & 2) );
  5075.     #endif
  5076. }
  5077.  
  5078.  
  5079. SOM_Scope ODExtension*  SOMLINK ContainerPartGetExtension(ContainerPart *somSelf, Environment *ev,
  5080.                               ODType extensionName )
  5081. {
  5082.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5083.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetExtension");
  5084.  
  5085.     if ( !strcmp(extensionName, kODExtSelectedPartExtension) ) {
  5086.        if (!_fSelectedPartExtension) {
  5087.           _fSelectedPartExtension = new ODSelectedContainerPartExtension;
  5088.           _fSelectedPartExtension->InitSCPExtension( ev, somSelf, _fSession );
  5089.        } /* endif */
  5090.        return _fSelectedPartExtension;
  5091.     } else {
  5092.        return ContainerPart_parent_ODPart_GetExtension(somSelf, ev, extensionName);
  5093.     } /* endif */
  5094. }
  5095.  
  5096.  
  5097. SOM_Scope boolean  SOMLINK ContainerPartHasExtension(ContainerPart *somSelf, Environment *ev,
  5098.                               ODType extensionName )
  5099. {
  5100.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5101.     ContainerPartMethodDebug("ContainerPart","ContainerPartHasExtension");
  5102.  
  5103.     if ( !strcmp(extensionName, kODExtSelectedPartExtension) ) {
  5104.        return kODTrue;
  5105.     } else {
  5106.        return ContainerPart_parent_ODPart_HasExtension(somSelf, ev, extensionName);
  5107.     } /* endif */
  5108. }
  5109.  
  5110.  
  5111. SOM_Scope void  SOMLINK ContainerPartReleaseExtension(ContainerPart *somSelf, Environment *ev,
  5112.                               ODExtension * extension )
  5113. {
  5114.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5115.     ContainerPartMethodDebug("ContainerPart","ContainerPartReleaseExtension");
  5116.  
  5117.     if ( !extension ) return;
  5118.  
  5119.     if (_fSelectedPartExtension  == extension) {
  5120.        _fSelectedPartExtension->Release( ev);
  5121.        _fSelectedPartExtension = 0;
  5122.     } else {
  5123.        ContainerPart_parent_ODPart_ReleaseExtension(somSelf, ev, extension);
  5124.     } /* endif */
  5125. }
  5126.  
  5127.  
  5128. SOM_Scope void  SOMLINK ContainerPartUndoAction(ContainerPart *somSelf,  Environment *ev,
  5129.                                    ODActionData actionState)
  5130. {
  5131.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5132.     ContainerPartMethodDebug("ContainerPart","ContainerPartUndoAction");
  5133.  
  5134.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  5135.     SetBGColorRec*  undoRec = (SetBGColorRec*)actionState;
  5136.  
  5137.     somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fOldColor);
  5138. }
  5139.  
  5140. SOM_Scope void  SOMLINK ContainerPartRedoAction(ContainerPart *somSelf,  Environment *ev,
  5141.                                    ODActionData actionState)
  5142. {
  5143.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5144.     ContainerPartMethodDebug("ContainerPart","ContainerPartRedoAction");
  5145.  
  5146.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  5147.     SetBGColorRec*  undoRec = (SetBGColorRec*)actionState;
  5148.  
  5149.     somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fNewColor);
  5150. }
  5151.  
  5152. SOM_Scope void  SOMLINK ContainerPartDisposeActionState(ContainerPart *somSelf,
  5153.                                             Environment *ev,
  5154.                                            ODActionData actionState,
  5155.                                            ODDoneState doneState)
  5156. {
  5157.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5158.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisposeActionState");
  5159.  
  5160.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  5161.     delete (SetBGColorRec*)actionState;
  5162. }
  5163.  
  5164. SOM_Scope void  SOMLINK ContainerPartWriteActionState(ContainerPart *somSelf,
  5165.                                           Environment *ev, ODPtr actionState,
  5166.                                          ODStorageUnitView* storageUnitView)
  5167. {
  5168.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5169.     ContainerPartMethodDebug("ContainerPart","ContainerPartWriteActionState");
  5170.  
  5171. }
  5172.  
  5173. SOM_Scope ODPtr  SOMLINK ContainerPartReadActionState(ContainerPart *somSelf,
  5174.                                           Environment *ev, ODStorageUnitView* storageUnitView)
  5175. {
  5176.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5177.     ContainerPartMethodDebug("ContainerPart","ContainerPartReadActionState");
  5178.  
  5179.     return kODNULL;
  5180. }
  5181.  
  5182. SOM_Scope void  SOMLINK ContainerPartInitPart(ContainerPart *somSelf,  Environment *ev,
  5183.                                  ODStorageUnit* storageUnit)
  5184. {
  5185.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5186.     ContainerPartMethodDebug("ContainerPart","ContainerPartInitPart");
  5187.  
  5188.     if (somSelf->IsInitialized(ev))
  5189.       return;
  5190.  
  5191.     somSelf->InitPersistentObject(ev, storageUnit);
  5192.  
  5193.     //    AppleTestDraw_DrawPart_parent_ODPart_InitPart(somSelf,ev,storageUnit);
  5194.  
  5195.     //  SimplePart::InitPart(storageUnit);
  5196.  
  5197.     somSelf->CommonInitContainerPart(ev);
  5198.  
  5199.     ODStorageUnit* msu = somSelf->GetStorageUnit(ev);
  5200.  
  5201.     msu->AddProperty(ev, kODPropDisplayFrames)->AddValue(ev, kODIDs);
  5202.     msu->AddProperty(ev, kODPropEmbeddedFrames)->AddValue(ev, kODIDs);
  5203.     msu->AddProperty(ev, kODPropContents)->AddValue(ev, kKindTestContainer);
  5204.  
  5205.     // I'm not even sure that we need this GroupID property, but I don't have time to 
  5206.     //    check right now.  (todo) (jlc 94-11)
  5207.     ODULong FrameGroupIDCounter = 1;
  5208.     msu->AddProperty(ev, kODPropFrameGroup)->AddValue(ev, kODULong);
  5209.     msu->SetValue(ev, sizeof(ODULong), (ODValue)&FrameGroupIDCounter);
  5210. }
  5211.  
  5212. SOM_Scope void  SOMLINK ContainerPartInitPartFromStorage(ContainerPart *somSelf,
  5213.                                              Environment *ev,
  5214.                                             ODStorageUnit* storageUnit)
  5215. {
  5216.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5217.     ContainerPartMethodDebug("ContainerPart","ContainerPartInitPartFromStorage");
  5218.  
  5219.     if (somSelf->IsInitialized(ev))
  5220.       return;
  5221.  
  5222.     somSelf->InitPersistentObjectFromStorage(ev, storageUnit);
  5223.  
  5224.   //    AppleTestDraw_DrawPart_parent_ODPart_InitPartFromStorage(somSelf,ev,storageUnit);
  5225.  
  5226.  
  5227.   //  SimplePart::InitPartFromStorage(storageUnit);
  5228.  
  5229.     somSelf->CommonInitContainerPart(ev);
  5230.  
  5231.  
  5232.     ODStorageUnit* su;
  5233.      ODStorageUnitRef aSURef;
  5234.     ODFrame* frame;
  5235.     ODShape* newShape;
  5236.     ODULong offset, offsetLimit;
  5237.     //HRGN newRegion;
  5238.     ODPoint  ptOffset;
  5239.     ODTransform* transform;
  5240.  
  5241.     su = somSelf->GetStorageUnit(ev);
  5242.     //su->Focus(ev, kODPropContents,kODPosSame,kKindTestContainer,1,kODPosFirstSib);
  5243.     //su->GetValue(ev, sizeof(ODStorageUnitRef),&aSURef);
  5244.     //_fTestDrawSU = su->GetDraft(ev)->GetStorageUnit(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
  5245.     //su = _fTestDrawSU;
  5246.  
  5247.     su->Focus(ev, kODPropDisplayFrames, kODPosSame, 0, 1, kODPosFirstSib);
  5248.     offsetLimit = su->GetSize(ev);
  5249.     for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
  5250.     {
  5251.       su->SetOffset(ev, offset);
  5252.       su->GetValue(ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  5253.  
  5254.       try {
  5255.  
  5256.         frame = su->GetDraft(ev)->GetFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
  5257.         _fDisplayFrames->AddLast((ElementType)frame);
  5258.         frame->SetDroppable(ev, kODTrue);
  5259.  
  5260.       } catch (... ) {
  5261.  
  5262.         frame = kODNULL;
  5263.  
  5264.       } /* endcatch */
  5265.     }
  5266.  
  5267. // Fix to focus on value instead of index <4> rlt
  5268.     su->Focus(ev, kODPropContents,kODPosUndefined,kKindTestContainer,0,kODPosUndefined);
  5269.  
  5270.     offsetLimit = su->GetSize(ev);
  5271.     newShape = new ODShape();
  5272.     for (offset = 0; offset < offsetLimit;)
  5273.     {
  5274.       su->SetOffset(ev, offset);
  5275.       su->GetValue(ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  5276.       offset += sizeof(ODStorageUnitRef);
  5277.       frame = su->GetDraft(ev)->GetFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
  5278.       _fEmbeddedFrames->AddLast((ElementType)frame);
  5279.  
  5280.       su->SetOffset(ev, offset);
  5281.       su->GetValue(ev, sizeof(ptOffset), (ODValue)&ptOffset);
  5282.       offset += sizeof(ptOffset);
  5283.       transform = new ODTransform;
  5284.       transform->SetOffset(ev, &ptOffset);
  5285.  
  5286.       newShape->CopyFrom(ev, frame->GetFrameShape(ev));
  5287.       newShape->Transform(ev, transform);
  5288. #if 0 // (CED -110594)
  5289.       HRGN newRegion = newShape->CopyRegion(ev);
  5290.       _fContents->AddLast((ElementType)(new Proxy(newRegion, frame, transform)));
  5291. #else
  5292.       _fContents->AddLast((ElementType)(new Proxy(frame, transform)));
  5293. #endif
  5294.     }
  5295.     delete newShape;
  5296. }
  5297.  
  5298. SOM_Scope void  SOMLINK ContainerPartRelease(ContainerPart *somSelf,  Environment *ev)
  5299. {
  5300.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5301.     ContainerPartMethodDebug("ContainerPart","ContainerPartRelease");
  5302.  
  5303.     Proxy*    p;
  5304.     ODFrame*  frame;
  5305.  
  5306.     ContainerPart_parent_ODPart_Release(somSelf, ev);
  5307.     if (somSelf->GetRefCount(ev) == 0) {
  5308.       //somSelf->HidePalette(ev);
  5309.       frame = (ODFrame*) _fDisplayFrames->First();
  5310.       while (frame != kODNULL) {
  5311.         _fDisplayFrames->Remove(frame);
  5312.         ODReleaseObject(ev,frame);
  5313.         frame = (ODFrame*) _fDisplayFrames->First();
  5314.       }
  5315.       frame = (ODFrame*) _fEmbeddedFrames->First();
  5316.       while (frame != kODNULL) {
  5317.         p = somSelf->ProxyForFrame(ev, frame);
  5318.         _fContents->Remove(p);
  5319.         _fEmbeddedFrames->Remove(frame);
  5320.         ODReleaseObject(ev,frame);
  5321.         frame = (ODFrame*) _fEmbeddedFrames->First();
  5322.       }
  5323.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart(ev, somSelf);
  5324.     }
  5325. }
  5326.  
  5327. #ifdef __IBMC___
  5328.   #pragma lnkage (SOMInitModule, system)
  5329. #endif
  5330.  
  5331. SOMEXTERN void SOMLINK SOMInitModule (long majorVersion, long minorVersion,
  5332.                                  string className)
  5333. {
  5334.    SOM_IgnoreWarning (majorVersion);  /* This function makes   */
  5335.    SOM_IgnoreWarning (minorVersion);  /* no use of the passed  */
  5336.    SOM_IgnoreWarning (className);     /* arguments.            */
  5337.  
  5338.    ContainerPartNewClass ( ContainerPart_MajorVersion, ContainerPart_MinorVersion);
  5339. }
  5340.  
  5341. void EXPENTRY AddMenuResourceLast( Environment *ev, HMODULE hmodDLL, long resid, ODMenuBar *menubar, ODMenuID menuid)
  5342. {
  5343.     ODPlatformMenuBar   menuBar;
  5344.     DosGetResource2( hmodDLL
  5345.                    , RT_MENU
  5346.                    , resid
  5347.                    , (PPVOID)&menuBar
  5348.                    );
  5349.     {
  5350.        ODMenuBar * mbNew = new ODMenuBar;
  5351.        mbNew->InitMenuBar(ev,  /*_fSession*/0, menuBar );
  5352.        menubar->AddMenuBLast(ev,  mbNew, menuid );
  5353.        delete mbNew;
  5354.     }
  5355.     DosFreeResource( (PVOID)menuBar );
  5356. }
  5357.