home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / BETA / SAMPLES / OPENDOC / PARTS / CNTNRPRT / CNTNRPRT.CPP < prev    next >
Text File  |  1995-12-13  |  295KB  |  7,949 lines

  1.                                                                 
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 2.41
  6.  */
  7.  
  8. /*
  9.  *      File:           CntnrPrt.cpp
  10.  *
  11.  *   Contains:  IDL description of Container Part
  12.  *
  13.  *   Written by:   The OpenDoc Development Team
  14.  *
  15.  *   Copyright: (c) 1994 by IBM Corp., all rights reserved.
  16.  *
  17.  *   Change History (most recent first):
  18.  *
  19.  *     146974   12/12/95   ced      Rework to fix Open As Window
  20.  *     146357   12/11/95   ced      Validation changes
  21.  *     146397   12/10/95   st       Fix for details view with no embeds (inf loop)
  22.  *     145808   12/07/95   jso      Fix for extra page when printing                                
  23.  *     145816   12/06/95   aht      Update Send method of message interface for DR4 parm change
  24.  *     145698   12/06/95   BLG      Container view display returns TRUE.
  25.  *     132158   12/05/95   ced      Normalize frame shape to zero offset in RequestFrameShape
  26.  *     126751   12/04/95   faa      Avoid bundling when scaling to zero
  27.  *     142961   12/03/95   aml      Imaging operations performance improvement in ClipEmbeddedFacets
  28.  *     145687   12/02/95   jso      Fix externalize for saved embedded frames
  29.  *     145672   12/02/95   st       caused regr with icon/tree/details view
  30.  *     144010   11/28/95   st       Adjust menus for show as when root part vs embedded part
  31.  *     144742   11/28/95   ced      Use containing frame when requesting status line focus in
  32.  *                                  HandleButton1DownInEmbeddedFrame
  33.  *     144299   11/28/95   jso      Added document name to print job
  34.  *     144010   11/27/95   st       AdjustMenus/HandleMenuEvent for DOC_OPENAS items
  35.  *     137691   11/25/95   ced      Get rid of common.hpp & use AltPoint classes for ODPoint & ODRect.
  36.  *                                  Fix up exception handling.
  37.  *     144744   11/22/95   ced      Remove unnessecary frame->SetPartInfo calls
  38.  *     144532   11/21/95   ced      Fix internalization/externalization, change type of BGColor to long
  39.  *     144408   11/21/95   aml      Update AdjustMenus: enable Paste submenu instead of Paste items
  40.  *     140231   11/20/95   aht      Initialize AEDesc's before using them.
  41.  *     143870   11/18/95   st       Use WinMessageBox for implementing HELP menu items
  42.  *     142798   11/18/95   ced      Fix some printing bugs.  Use existing root frame for printing
  43.  *                                  if it has no facets.  Remove proxy for frame being closed in
  44.  *                                  DisplayFrameClosed.
  45.  *     143654   11/13/95   ced      Apple DR4 IDL changes;  ODObject::IsInitialized() removed,
  46.  *                                  param added to ODWindowState::RegisterWindow.
  47.  *     143568   11/10/95   st       remove dead code
  48.  *     133692   11/03/95   ced      Fix bug causing trap when ESC out of scale or rotate
  49.  *     142637   11/02/95   ced      Fix some ref-counting bugs
  50.  *     140007   10/31/95   aml      Use new DragDrop and Clipboard APIs
  51.  *     141717   10/27/95   BLG      Container releases statusline focus when deleted.
  52.  *     141477   10/26/95   jso      Check rc for WinLoadString in categoryDisplayName
  53.  *     139790   10/11/95   aml      Fix refcounting bug in BeginPrinting
  54.  *     139395   10/06/95   blg      Have Container part release statusline focus on request.
  55.  *     139092   10/03/95   st       Changes for new menus
  56.  *     137664   09/21/95   aml      Some API changes for ODShape, ODTransform
  57.  *     123247   09/21/95   jso      Added partCategoryUserString
  58.  *     137097   09/15/95   aml      Added code for DisplayFrameConnected
  59.  *     137002   09/15/95   jso      Added GetBGColor method for notebook to call
  60.  *     128682   09/14/95   faa      Implement cut/copy/paste functions
  61.  *     134597   9/27/95    ced      Remove content drawing on another thread for now
  62.  *     131406   8/16/95    st       separate MRI into its own DLL
  63.  *     131094   08/14/95   faa      When Container focus is lost, selected items remain
  64.  *                                  selected and show again when focus is regained
  65.  *     127685   08/08/95   map      Content drawing is on another thread
  66.  *     128683   07/25/95   faa      Implement select all/deselect all function
  67.  *     130872   07/25/95   st       Excetp. 22 with context menu and selected part that has no menu ext.
  68.  *     123248   07/21/95   BLG      Get part display name and category from .rc file
  69.  *     129449   07/21/95   st       only pass selected menu commands to selected part
  70.  *     127858   07/20/95   aht      Add scripting support: change background color via osa event
  71.  *     130083   07/19/95   BLG      Use menubar methods to store statusline text
  72.  *                                  for menu items.  The docshell will handle displaying it.
  73.  *     126008   07/17/95   faa      Changed lines on FocustLost to remove code
  74.  *                                  that deselected a part when focus was lost
  75.  *     124806   07/13/95   aml      Changed MotionEnd to leave the embedded frame shape unchanged for
  76.  *                                  illegal resizing operations (dragging a corner of the selection
  77.  *                                  border past its opposite edges)
  78.  *     120365   07/12/95   map      Fix up #define INCL for OD.H
  79.  *     129011   07/12/95   aml      Fixed CloneInto to properly store embedded frames data
  80.  *     128305   07/07/95   st       put samples of adding to popup menus
  81.  *     128494   07/06/95   ced      check ODWindow ptr not null before dereferencing.
  82.  *     127387   06/26/95   ced      code for possibility that status line extension is not
  83.  *                                  available.
  84.  *     126859   06/24/95   st      more menu code-adjusting popup/selected phase I
  85.  *     117197   06/21/95   BLG      open from file in same position/properties as was saved
  86.  *     125708   06/20/95   st       Change to AddDefaultMenuItemBefore
  87.  *     126017   06/19/95   pfe      Fixed breaks in printing/part window
  88.  *     125718   06/16/95   pfe      Fixed OpenAsWindow breaks
  89.  *     125697   06/14/95   ced      Use new support for kODNULL invalidShape when updating
  90.  *                                  embedded facets in Draw method.
  91.  *     124864   06/14/95   ced      Fix divide by zero bug when scaling embedded facets.
  92.  *     124235   06/12/95   ced      Clip single selection handles from embedded facets.  Draw
  93.  *                                  selection border after updating embedded frames.
  94.  *     124689   06/12/95   ced      Fix trap in start drag with no selection.
  95.  *     124927   06/10/95   st       MB1 over part with viewtype not frame should select it
  96.  *     124283   06/07/95   BLG      remove dependency of help panels on menu id's
  97.  *     124281   06/06/95   BLG      Changes in StatusLine - need Statusline focus to display
  98.  *                                  text, have to pass Frame ptr to SetStatusLineText.
  99.  *     124667   06/06/95   st       Menus and multiple selection
  100.  *     108305   06/05/95   aml      Invalidate selection border when a frame shape changes.
  101.  *     124243   06/05/95   aml      Introduce the FacetInfoRec structure for container facets
  102.  *                                  to be used with GetPartInfo and SetPartInfo methods
  103.  *     124328   06/03/95   st       fixes for view extension types/classes
  104.  *     124293   06/03/95   st       menu code in HandleButton1ClickInBorder causes SOM trap
  105.  *     124371   06/02/95   ced      Rework selection, scaling & rotation of embedded frames,
  106.  *                                  improve performance of InvertDragHighlight with non-linear
  107.  *                                  frame transforms.
  108.  *     123945   05/31/95   pfe      OpenAsWindow fixes and changes
  109.  *     122740   05/26/95   st       get selected part's menu over and over and over.....
  110.  *     123386   05/24/95   ced      use window clip region to clip selection border from
  111.  *                                   embedded parts.  Add support for scaling embedded frames.
  112.  *     123239   05/23/95   jv       added Tree/Icon/Details views
  113.  *     122741   05/23/95   st       wrong frame* passed to selected part
  114.  *     123149   05/22/95   ced      Add support for multiple selection of embedded frames
  115.  *     122943   05/21/95   map      Method name changes for multi-threading
  116.  *     122707   05/18/95   BLG      Implement example of part doing Undo/Redo
  117.  *     121968   05/15/95   ced      Use RegisterWindowForFrame when opening a root frame
  118.  *     122322   05/15/95   st       added popup/accelerator support
  119.  *     122244   05/13/95   rlt      added DevCon7 changes (grid enable/disable & view type supp)
  120.  *     121968   05/12/95   ced      fix drop target location bug
  121.  *     121161   05/10/95   aml      some optimization for container part drawing:
  122.  *                                  clip out embedded facets; embedded facets clip
  123.  *                                  shape fix; remove unnecessary code in GeometryChanged
  124.  *     121073   05/03/95   map      changed includes of xih to xh for OD UI classes
  125.  *     119388   04/29/95   st       new menu code
  126.  *     119548   04/25/95   jso      removed private byte array/storage functions
  127.  *     120017   04/22/95   ced      Move storage utils to common header file.
  128.  *     119471   04/18/95   pfe      added support for OpenAsWindow
  129.  *     119447   04/18/95   ced      Add ODPlatformPrintJob setup
  130.  *     117472   04/17/95   ced      Create root frame for facet to be printed.
  131.  *     118227   04/10/95   pfe      changed HandleMouseDownInEmbeddedFrame to activate window
  132.  *     117544   04/03/95   map      replaced true/false with kODTrue/kODFalse
  133.  *     117472   04/01/95   ced      Add printing (without dialogs)
  134.  *
  135.  *        <5>   01/16/95   jso      b1c7 port
  136.  *
  137.  *        <4>   12/08/94   rlt       Changed su->focus to use property/value instead of
  138.  *                                  using index
  139.  *        <3>   11/05/94   ced      Modifications required because root facet
  140.  *                                  external transform now scales from OpenDoc
  141.  *                                  72 dpi coordinate space to device coordinate
  142.  *                                  space.  Changes are labed with (CED - 110594).
  143.  *        <2>   10/7/94    ced      Added example code for using mouse focus
  144.  *                                  to draw rubber-band tracking rectangle.
  145.  *       <1>      7/6/94        jlc             first checked in
  146.  *
  147.  *   To Do:
  148.  *
  149.  *   Copyright: (c) 1993-1994 by IBM Corp., all rights reserved.
  150.  *
  151.  */
  152. /*
  153.  *  This file was generated by the SOM Compiler and Emitter Framework.
  154.  *  Generated using:
  155.  *      SOM Emitter emitxtm: 2.41
  156.  */
  157.  
  158. #ifndef _ALTPOINT_
  159. #include "AltPoint.h"
  160. #endif
  161.  
  162. #ifndef _ALTPOLY_
  163. #include "AltPoly.h"
  164. #endif
  165.  
  166. #ifndef _EXCEPT_
  167. #include "Except.h"
  168. #endif
  169.  
  170. #ifndef SOM_Module_cntnrprt_Source
  171. #define SOM_Module_cntnrprt_Source
  172. #endif
  173. #define ContainerPart_Class_Source
  174. #define VARIABLE_MACROS
  175.  
  176. #define INCL_DOSMODULEMGR
  177. #define INCL_DOSPROCESS       // [127685]
  178. #define INCL_DOSRESOURCES
  179. #define INCL_GPIBITMAPS
  180. #define INCL_GPICONTROL
  181. #define INCL_GPIDEFAULTS      // [127685]
  182. #define INCL_GPIPRIMITIVES
  183. #define INCL_GPIREGIONS
  184. #define INCL_GPIPOLYGON
  185. #define INCL_GPITRANSFORMS
  186. #define INCL_GPIPATHS
  187. #define INCL_WINACCELERATORS
  188. #define INCL_WINFRAMEMGR
  189. #define INCL_WININPUT
  190. #define INCL_WINMENUS
  191. #define INCL_WINMESSAGEMGR
  192. #define INCL_WINPOINTERS
  193. #define INCL_WINSTDDLGS
  194. #define INCL_WINDIALOGS
  195. #define INCL_WINSTDDRAG
  196. #define INCL_WINTRACKRECT
  197. #define INCL_WINWINDOWMGR
  198. #define INCL_WINSHELLDATA
  199. #define INCL_DEV
  200. #define INCL_WINSYS
  201. #define INCL_SPL
  202. #define INCL_SPLDOSPRINT
  203.  
  204. #define INCL_ODAPI
  205. #define INCL_ODARBITRATOR
  206. #define INCL_ODCANVAS
  207. #define INCL_ODCLIPBOARD
  208. #define INCL_ODDRAGANDDROP
  209. #define INCL_ODDRAFT
  210. #define INCL_ODERRORS
  211. #define INCL_ODFACET
  212. #define INCL_ODFOCUSSET
  213. #define INCL_ODFRAME
  214. #define INCL_ODINFO
  215. #define INCL_ODPARTHANDLERINFO
  216. #define INCL_ODPARTHANDLERREGISTRY
  217. #define INCL_ODREGISTERMANAGER
  218. #define INCL_ODSESSION
  219. #define INCL_OSAAPI //@143928
  220. #define INCL_OSA    //@127858
  221. #define INCL_ODOSA  //@127858
  222. #define INCL_ODSHAPE
  223. #define INCL_ODSTORAGEUNIT
  224. #define INCL_ODTRANSFORM
  225. #define INCL_ODUI
  226. #define INCL_ODUNDO
  227. #define INCL_ODWINDOW
  228. #define INCL_ODWINDOWSTATE
  229. #define INCL_ODDOCUMENT
  230. #define INCL_ODCONTAINER //[144299]
  231. #include <os2.h>
  232. #include <math.h>
  233.  
  234. #include "cntnrprt.xih"
  235.  
  236. #include <CNNotebk.xh>
  237.  
  238. #ifndef _FOCUSLIB_
  239.    #include "focuslib.h"
  240. #endif
  241.  
  242. #ifndef _TEMPOBJ_
  243. #include "TempObj.h"
  244. #endif
  245.  
  246. #ifndef _WINUTILS_
  247.    #include "winutils.h"
  248. #endif
  249.  
  250. #ifndef _STDTYPIO_
  251. #include "stdtypio.h"
  252. #endif
  253.  
  254. #ifndef _ODDEBUG_
  255. #include "ODDebug.h"
  256. #endif
  257.  
  258. #ifndef _ODUTILS_
  259. #include "ODUtils.h"
  260. #endif
  261.  
  262. #ifndef _ODMATH_
  263. #include "ODMath.h"
  264. #endif
  265.  
  266. #ifndef SOM_XEmbeddedFramesIterator_xh
  267.    #include <XFrmIter.xh>
  268. #endif
  269.  
  270. #ifndef _ORDCOLL_
  271. #include "OrdColl.h"
  272. #endif
  273.  
  274. #define USE_PARTINFO_TO_RECALL_AMENU
  275. #define ODUnused(s) s
  276.  
  277.  
  278. #include "debug.hpp"
  279. #include "cntnrprt.h"
  280. #include "partinfo.h"
  281. #include "cntnrhlp.h"  // 124283
  282. #include "cntnrprp.h"  //@127858
  283.  
  284. #define THISDLL "cntmri"
  285.  
  286. static const ODPropertyName kPropEmbeddedFrames   = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:EmbeddedFrames";
  287. static const ODPropertyName kPropBGColor = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:BackgroundColor";
  288.  
  289.  
  290. // SetBGColorRec is used for Undo/Redo.
  291. struct SetBGColorRec
  292. {
  293.   SetBGColorRec(long oldColor, long newColor, ODFrame* frame)
  294.           {_fOldColor = oldColor; _fNewColor = newColor;
  295.             _fFrame = frame;}
  296.   long   _fOldColor;
  297.   long   _fNewColor;
  298.   ODFrame*  _fFrame;
  299. };
  300.  
  301.  
  302. #ifndef _CNTMRI_
  303.    #include "cntmri.h"
  304. #endif
  305.  
  306.  
  307. const double pi = 3.14159265358979;
  308. const int YGRID = 72;
  309. const int XGRID = 72;
  310. const ULONG SLEEPTIME = 50;  // [127685]
  311. const ODSLong kODBorderWidth = MAKEFIXED(1,0);
  312. const ODSLong kODBorderHandleWidth = MAKEFIXED(8, 0);
  313. const ODSLong kODHandleLenMultiplier = 1;
  314. const ODSLong kSelectionHandleWidth = MAKEFIXED(6,0);
  315. MATRIXLF mtxIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 1};
  316.  
  317. static const ODPropertyName  kPropFrameInfo = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:FrameInfo";
  318. static const ODPropertyName  kPropMouseDownOffset = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:MouseDownOffset";
  319.  
  320. #define kKindTestContainer "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:Kind:TestContainer"
  321.  
  322. static const ODValueType    kFrameRef = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Type:FrameReference";
  323. // registration types
  324.  
  325. // 123248 const ODType   kContainerPartKindDisplayName = "Container Part Kind";
  326. const ODType   kPartHandlerName         =  "ContainerPart";
  327. // 123248 const ODType   kContainerPartCategory         =  "Test Container";
  328.  
  329. struct Proxy : public ODxOrderedCollection {
  330.    ODTransform* transform;
  331.    ODShape* shape;
  332.    ODPart* part;
  333.    ODBoolean settingFrameShapes;
  334.    Proxy(ODTransform* t, ODShape* s, ODPart* p) {
  335.       transform = t; shape = s; part = p; 
  336.       settingFrameShapes = kODFalse;
  337.    }
  338. };
  339.  
  340. /*
  341.  * The FacetClip struct is used to save the clip shapes of embedded facets
  342.  * when we modify the original clip shape to clip out sizing handles of the
  343.  * selected part.  We do this so that we can restore the original
  344.  * clip shape when the selection is changed without having to recalculate
  345.  * the clipping of all our embedded facets.  Pointers to FacetClip structs
  346.  * for facet's who's clip shapes we're saving are kept in the
  347.  * _fSavedFacetClipShapes collection.
  348.  */
  349. struct FacetClip {
  350.    ODFacet* facet;
  351.    ODShape* clip;
  352. };
  353.  
  354. #include <stdio.h>
  355.  
  356. //------------------------------------------------------------------------------
  357. // Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING
  358. //------------------------------------------------------------------------------
  359. struct PRNINFO {
  360.    HDC        hdc;
  361.    HPS        hps;
  362.    PHCINFO    phcInfo;
  363.    PRINTDEST  printDest;
  364.    ODRect     bounds;
  365. };
  366. typedef PRNINFO* PPRNINFO;
  367.  
  368. #define PRINT_QUEUE_LENGTH 100
  369. #define QUEUENAME_LENGTH   10
  370. #define DRIVERNAME_LENGTH  125
  371. #define LEN_WORKSTRING     256
  372. #define LEN_TITLE          256
  373.  
  374. #define ulmm2fxPt(mm) ((ODCoordinate)(((float)(mm) / 25.4) * 72 * 65536));
  375. #define PtInRect(pt, rect) (pt.x >= rect.left   && \
  376.                             pt.x <  rect.right  && \
  377.                             pt.y >= rect.bottom && \
  378.                             pt.y <  rect.top)
  379.  
  380. ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, ODRect page);
  381.  
  382. MRESULT EXPENTRY CntnrPartInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  383. VOID SetSysMenu(HWND hDlg);
  384.  
  385. // The following properties are defined for View->Details handling. It is just a TEST.
  386. // You can find the same #defines in cntnrprt.cpp as well.
  387. static const ODPropertyName  kSimplePartAddProps = "SimplePart:Property:AddProps";
  388. const ODType   kSimplePartAddProp1         =  "Test AddProp1";
  389. const ODType   kSimplePartAddProp2         =  "Test AddProp2";
  390. const ODType   kSimplePartAddProp3         =  "Test AddProp3";
  391. const ODType   kSimplePartAddProp4         =  "Test AddProp4";
  392. const ODType   kSimplePartKind            = "IBM:Kind:SimplePart";
  393.  
  394. ODBoolean Test_AddDetailsColumns(ContainerPart *somSelf, Environment *ev,
  395.                 ODViewExtension *ViewExt);
  396. ODType  GetPartKind(ODPart* part);
  397.  
  398. //@127858 begin
  399. void GetDirectParam(ODSession* session, OSAEvent* message, AEDesc* evtDp);
  400. void CreatePropObjSpec(ContainerPart* somSelf, Environment* ev, ODFrame* frame,
  401.                        DescType form, DescType prop, AEDesc& objSpec);
  402. void SendSetDataEvent(ContainerPart *somSelf, Environment* ev, AEDesc& objSpec, AEDesc& data);
  403. static ODError APIENTRY GetPropertyFromNULL(  ODPart*        part,
  404.                       DescType      desiredClass,
  405.                       ODOSLToken*      container,
  406.                       DescType      containerClass,
  407.                       DescType      form,
  408.                       ODDesc*        selectionData,
  409.                       ODOSLToken*      value,
  410.                       ODSLong        refCon);
  411.  
  412. static ODError APIENTRY HandleSetData(ODPart*      part,
  413.                   ODOSAEvent*  message,
  414.                   ODOSAEvent*  reply,
  415.                   ODSLong      handlerRefcon);
  416.  
  417. static ODError APIENTRY HandleGetData(ODPart*      part,
  418.                   ODOSAEvent*  message,
  419.                   ODOSAEvent*  reply,
  420.                   ODSLong      handlerRefcon);
  421. //@127858 end
  422.  
  423. //==============================================================================
  424. // Non Som functions for colors
  425. //==============================================================================
  426.  
  427. long ColorIndexFromMenuColor( ODUShort whichColor )
  428. {
  429.     switch (whichColor)
  430.     {
  431.       case  IDMA_COLOR_GRAY   : return  CLR_DARKGRAY  ; break;
  432.       case  IDMA_COLOR_RED    : return  CLR_RED       ; break;
  433.       case  IDMA_COLOR_GREEN  : return  CLR_GREEN     ; break;
  434.       case  IDMA_COLOR_YELLOW : return  CLR_YELLOW    ; break;
  435.       case  IDMA_COLOR_BLUE   : return  CLR_BLUE      ; break;
  436.       case  IDMA_COLOR_MAGENTA: return  CLR_DARKPINK  ; break;
  437.       case  IDMA_COLOR_CYAN   : return  CLR_CYAN      ; break;
  438.       case  IDMA_COLOR_WHITE  : return  CLR_WHITE     ; break;
  439.       default: break;
  440.     }
  441.     return  CLR_PINK;
  442. }
  443.  
  444. ODUShort MenuColorFromColorIndex( long inColor )
  445. {
  446.     switch (inColor)
  447.     {
  448.       case  CLR_DARKGRAY  : return  IDMA_COLOR_GRAY   ; break;
  449.       case  CLR_RED       : return  IDMA_COLOR_RED    ; break;
  450.       case  CLR_GREEN     : return  IDMA_COLOR_GREEN  ; break;
  451.       case  CLR_YELLOW    : return  IDMA_COLOR_YELLOW ; break;
  452.       case  CLR_BLUE      : return  IDMA_COLOR_BLUE   ; break;
  453.       case  CLR_DARKPINK  : return  IDMA_COLOR_MAGENTA; break;
  454.       case  CLR_CYAN      : return  IDMA_COLOR_CYAN   ; break;
  455.       case  CLR_WHITE     : return  IDMA_COLOR_WHITE  ; break;
  456.       default: break;
  457.     }
  458.     return IDMA_COLOR_GRAY;
  459. }
  460.  
  461. /*
  462.  * Calculate the angle in radians of the slope dx/dy
  463.  * relative to the positive x-axis.
  464.  */
  465. double CalcAngleRadians(double dx, double dy)
  466. {
  467.    double theta;
  468.    theta = dx ? atan(fabs(dy/dx)) : (asin((dy > 0) ? 1 : -1));
  469.    theta = (dx*dy > 0) ? (dx>0 ? theta : theta+pi) :
  470.                          (dx>0 ? 2.0*pi-theta : pi-theta);
  471.    return theta;
  472. }
  473.  
  474. double CalcAngleRadians(POINTL &ptlRef, POINTL &ptl)
  475. {
  476.    return CalcAngleRadians((double)(ptl.x - ptlRef.x),
  477.                            (double)(ptl.y - ptlRef.y));
  478. }
  479.  
  480. double CalcAngleRadians(ODPoint &ptRef, ODPoint &pt)
  481. {
  482.    return CalcAngleRadians(ODFixedToFloat(pt.x - ptRef.x),
  483.                            ODFixedToFloat(pt.y - ptRef.y));
  484. }
  485.  
  486. FIXED CalcAngleDegrees(POINTL &ptlRef, POINTL &ptl)
  487. {
  488.    return ODFloatToFixed(CalcAngleRadians(ptlRef, ptl) * 180.0 / pi);
  489. }
  490.  
  491. FIXED CalcAngleDegrees(ODPoint &ptRef, ODPoint &pt)
  492. {
  493.    return ODFloatToFixed(CalcAngleRadians(ptRef, pt) * 180.0 / pi);
  494. }
  495. SOM_Scope ODSemanticInterface*  SOMLINK ContainerPartGetSemanticInterface(ContainerPart *somSelf,
  496.                                                                            Environment *ev)
  497. {
  498.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  499.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetSemanticInterface");
  500.  
  501.     return _fSemtIntf;
  502. }
  503.  
  504. SOM_Scope Proxy*  SOMLINK ContainerPartProxyForFrame(ContainerPart *somSelf,
  505.                                                       Environment *ev,
  506.                                                      ODFrame* frame)
  507. {
  508.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  509.     ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrame");
  510.  
  511.     SOM_TRY
  512.  
  513.     if (_fEmbeddedFrames->Contains(frame))
  514.     {
  515.       Proxy* p;
  516.       ODxOrderedCollectionIterator i(_fContents);
  517.       for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  518.       {
  519.         ODFrame* testFrame;
  520.         ODxOrderedCollectionIterator frames(p);
  521.         for (testFrame = (ODFrame*)frames.First(); 
  522.              frames.IsNotComplete(); 
  523.              testFrame = (ODFrame*)frames.Next())
  524.         {
  525.            if (testFrame == frame)
  526.               return p;
  527.         }
  528.       }
  529.     }
  530.     else
  531.       THROW(kODErrInvalidFrame);
  532.  
  533.     SOM_CATCH_ALL
  534.     SOM_ENDTRY
  535.  
  536.     return kODNULL;
  537. }
  538.  
  539. SOM_Scope ODFrame*  SOMLINK ContainerPartFrameFromProxyForContainingFrame(ContainerPart *somSelf,
  540.                                                                           Environment *ev,
  541.                                                                           Proxy* proxy,
  542.                                                                           ODFrame* containingFrame)
  543. {
  544.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  545.     ContainerPartMethodDebug("ContainerPart","ContainerPartFrameFromProxyForContainingFrame");
  546.  
  547.     SOM_TRY
  548.  
  549.     ODxOrderedCollectionIterator i(proxy);
  550.     for (ODFrame* frame = (ODFrame*)i.First();
  551.          i.IsNotComplete();
  552.          frame = (ODFrame*)i.Next())
  553.     {
  554.        TempODFrame cntFrame = frame->AcquireContainingFrame(ev);
  555.        if (cntFrame == containingFrame)
  556.           return frame;
  557.     }
  558.  
  559.     SOM_CATCH_ALL
  560.     SOM_ENDTRY
  561.  
  562.     return kODNULL;
  563. }
  564.  
  565. SOM_Scope ODBoolean  SOMLINK ContainerPartNormalizeProxyGeometry(ContainerPart *somSelf,
  566.                                                             Environment *ev,
  567.                                                             Proxy* p)
  568. {
  569.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  570.     ContainerPartMethodDebug("ContainerPart","ContainerPartNormalizeProxyGeometry");
  571.  
  572.     ODBoolean geometryChanged = kODFalse;
  573.  
  574.     SOM_TRY
  575.  
  576.     ODRect bbox;
  577.     ODPoint offset;
  578.     p->shape->GetBoundingBox(ev, &bbox);
  579.     offset = bbox.BotLeft();
  580.     if (offset.x != 0 || offset.y != 0)
  581.     {
  582.        geometryChanged = kODTrue;
  583.        // normalize frame shape and adjust external transform
  584.        TempODTransform xform = p->transform->NewTransform(ev);
  585.        xform->SetOffset(ev, &offset);
  586.        p->transform->PreCompose(ev, xform);
  587.        offset.x = -offset.x;
  588.        offset.y = -offset.y;
  589.        xform->SetOffset(ev, &offset);
  590.        p->shape->Transform(ev, xform);
  591.     }
  592.  
  593.     SOM_CATCH_ALL
  594.     SOM_ENDTRY
  595.  
  596.     return geometryChanged;
  597. }
  598.  
  599. SOM_Scope void  SOMLINK ContainerPartSetProxyFrameShapes(ContainerPart *somSelf,
  600.                                                          Environment *ev,
  601.                                                          Proxy* p)
  602. {
  603.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  604.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetProxyFrameShapes");
  605.  
  606.     SOM_TRY
  607.  
  608.     p->settingFrameShapes = kODTrue;
  609.     ODxOrderedCollectionIterator i(p);
  610.     for (ODFrame* frame = (ODFrame*)i.First();
  611.          i.IsNotComplete();
  612.          frame = (ODFrame*)i.Next())
  613.     {
  614.        frame->ChangeFrameShape(ev, p->shape, kODNULL);
  615.     }
  616.     p->settingFrameShapes = kODFalse;
  617.  
  618.     SOM_CATCH_ALL
  619.     SOM_ENDTRY
  620. }
  621.  
  622. SOM_Scope void  SOMLINK ContainerPartInvalidateProxy(ContainerPart *somSelf,
  623.                                                      Environment *ev,
  624.                                                      Proxy* proxy)
  625. {
  626.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  627.     ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidateProxy");
  628.  
  629.     SOM_TRY
  630.  
  631.     ODxOrderedCollectionIterator i(proxy);
  632.     for (ODFrame* frame = (ODFrame*)i.First();
  633.          i.IsNotComplete();
  634.          frame = (ODFrame*)i.Next())
  635.     {
  636.        frame->Invalidate(ev, kODNULL, kODNULL);
  637.     }
  638.  
  639.     SOM_CATCH_ALL
  640.     SOM_ENDTRY
  641. }
  642.  
  643. SOM_Scope void  SOMLINK ContainerPartInvalidate(ContainerPart *somSelf,
  644.                                                 Environment *ev)
  645. {
  646.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  647.     ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidate");
  648.  
  649.     SOM_TRY
  650.  
  651.     // Invalidate all display frames.
  652.  
  653.     ODxOrderedCollectionIterator i(_fDisplayFrames);
  654.     for (ODFrame* frame = (ODFrame*)i.First();
  655.          i.IsNotComplete();
  656.          frame = (ODFrame*)i.Next())
  657.     {
  658.        frame->Invalidate(ev, kODNULL, kODNULL);
  659.     }
  660.  
  661.     SOM_CATCH_ALL
  662.     SOM_ENDTRY
  663. }
  664.  
  665. SOM_Scope void SOMLINK ContainerPartRemoveProxyObject(ContainerPart *somSelf,
  666.                                                       Environment *ev,
  667.                                                       Proxy* p)
  668. {
  669.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  670.     ContainerPartMethodDebug("ContainerPart","ContainerRemoveProxyObject");
  671.  
  672.     while (p->Count())
  673.     {
  674.        ODFrame* frame = (ODFrame*)p->First();
  675.        frame->Invalidate(ev, kODNULL, kODNULL);
  676.        ODxOrderedCollection tempFacets;
  677.        TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  678.        for (ODFacet* f1 = facets->First(ev);
  679.             facets->IsNotComplete(ev);
  680.             f1 = facets->Next(ev))
  681.        {
  682.           if ( f1->GetFrame(ev) == frame )
  683.              tempFacets.AddLast(f1);
  684.        }
  685.        
  686.        ODxOrderedCollectionIterator t(&tempFacets);
  687.        for (ODFacet* f2 = (ODFacet*)t.First();
  688.             t.IsNotComplete();
  689.             f2 = (ODFacet*)t.Next())
  690.        {
  691.           f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
  692.           ODDeleteObject(f2);
  693.        }
  694.        
  695.        // Remove our proxy for the moved frame
  696.        somSelf->RemoveEmbeddedFrame(ev, frame);
  697.     }
  698.     _fContents->Remove(p);
  699.     ODReleaseObject(ev, p->transform);
  700.     ODReleaseObject(ev, p->shape);
  701.     ODReleaseObject(ev, p->part);
  702.     delete p;
  703. }
  704.  
  705. SOM_Scope void  SOMLINK ContainerPartCreateProxySelectionBorder(ContainerPart *somSelf,
  706.                                                                  Environment *ev)
  707. {
  708.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  709.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateProxySelectionBorder");
  710.  
  711.     SOM_TRY
  712.  
  713.     _fSelectShape->Reset(ev);
  714.  
  715.     if (_fSelection->Count())
  716.     {
  717.        ODRect bbox;
  718.        ODPoint ptCorners[4];
  719.        Proxy* p;
  720.        ODxOrderedCollectionIterator iter(_fSelection);
  721.        TempODShape tempShape = _fSelectShape->Copy(ev);
  722.        for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
  723.        {
  724.           p->shape->GetBoundingBox(ev, &bbox);
  725.           ptCorners[0].x = bbox.left;   ptCorners[0].y = bbox.bottom;
  726.           ptCorners[1].x = bbox.left;   ptCorners[1].y = bbox.top;
  727.           ptCorners[2].x = bbox.right;  ptCorners[2].y = bbox.top;
  728.           ptCorners[3].x = bbox.right;  ptCorners[3].y = bbox.bottom;
  729.  
  730.           ODByteArray baPoints;
  731.           UseByteArray(&baPoints, ptCorners, 4 * sizeof(ODPoint));
  732.           p->transform->TransformPoints(ev, &baPoints, 4);
  733.  
  734.           for (int i=0; i<4; i++)
  735.           {
  736.              bbox.left   = ptCorners[i].x - kSelectionHandleWidth / 2;
  737.              bbox.top    = ptCorners[i].y + kSelectionHandleWidth / 2;
  738.              bbox.right  = ptCorners[i].x + kSelectionHandleWidth / 2;
  739.              bbox.bottom = ptCorners[i].y - kSelectionHandleWidth / 2;
  740.              tempShape->SetRectangle(ev, &bbox);
  741.              _fSelectShape->Union(ev, tempShape);
  742.           }
  743.        }
  744.     }
  745.     SOM_CATCH_ALL
  746.     SOM_ENDTRY
  747. }
  748.  
  749. SOM_Scope void  SOMLINK ContainerPartSetFrameSelected(ContainerPart *somSelf,
  750.                                                           Environment *ev,
  751.                                                           ODFrame* frame,
  752.                                                           ODBoolean isSelected)
  753. {
  754.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  755.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetFrameSelected");
  756.  
  757.     SOM_TRY
  758.  
  759.     TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  760.     for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  761.     {
  762.        facet->SetSelected(ev, isSelected);
  763.        facet->ChangeHighlight(ev, isSelected ? kODFullHighlight : kODNoHighlight);
  764.     }
  765.  
  766.     SOM_CATCH_ALL
  767.     SOM_ENDTRY
  768. }
  769.  
  770. SOM_Scope void  SOMLINK ContainerPartFreezeEmbeddedFrames(ContainerPart *somSelf,
  771.                                                           Environment *ev,
  772.                                                           ODBoolean isFrozen)
  773. {
  774.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  775.     ContainerPartMethodDebug("ContainerPart","ContainerPartFreezeEmbeddedFrames");
  776.  
  777.     SOM_TRY
  778.  
  779.     ODFrame* frame;
  780.     ODxOrderedCollectionIterator i(_fEmbeddedFrames);
  781.     for (frame = (ODFrame*) i.First(); i.IsNotComplete(); frame = (ODFrame*) i.Next())
  782.       frame->SetFrozen(ev, isFrozen);
  783.  
  784.     SOM_CATCH_ALL
  785.     SOM_ENDTRY
  786. }
  787.  
  788.  
  789. SOM_Scope void  SOMLINK ContainerPartInvalidateSelection(ContainerPart *somSelf,
  790.                                                           Environment *ev,
  791.                                                          ODFrame* frame)
  792. {
  793.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  794.     ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidateSelection");
  795.  
  796.     SOM_TRY
  797.  
  798.     if (frame)
  799.        frame->Invalidate(ev, kODNULL, kODNULL);
  800.  
  801.     SOM_CATCH_ALL
  802.     SOM_ENDTRY
  803. }
  804.  
  805. SOM_Scope void  SOMLINK ContainerPartClipEmbeddedFrames(ContainerPart *somSelf,
  806.                                                          Environment *ev,
  807.                                                         ODFrame* frame)
  808. {
  809.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  810.     ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFrames");
  811.  
  812.     SOM_TRY
  813.  
  814.     if (frame == kODNULL)   // Do all our display frames
  815.     {
  816.        ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  817.        for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  818.             dispFrames.IsNotComplete();
  819.             dispFrame = (ODFrame*)dispFrames.Next())
  820.        {
  821.           TempODFrameFacetIterator facets = dispFrame->CreateFacetIterator(ev);
  822.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  823.              somSelf->ClipEmbeddedFacets(ev, facet);
  824.        }
  825.     }
  826.     else
  827.     {
  828.        TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  829.        for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  830.           somSelf->ClipEmbeddedFacets(ev, facet);
  831.     }
  832.     SOM_CATCH_ALL
  833.     SOM_ENDTRY
  834. }
  835.  
  836. SOM_Scope void  SOMLINK ContainerPartClipSelectionFromEmbeddedFrames(ContainerPart *somSelf,
  837.                                                                      Environment *ev,
  838.                                                                      ODFrame* frame)
  839. {
  840.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  841.     ContainerPartMethodDebug("ContainerPart","ContainerPartClipSelectionFromEmbeddedFrames");
  842.  
  843.     SOM_TRY
  844.  
  845.     ODReleaseObject(ev, _fSelectionFrame);
  846.     _fSelectionFrame = frame;
  847.     _fSelectionFrame->Acquire(ev);
  848.  
  849.     TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  850.     for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  851.        somSelf->ClipSelectionFromEmbeddedFacets(ev, facet);
  852.  
  853.     SOM_CATCH_ALL
  854.     SOM_ENDTRY
  855. }
  856.  
  857. SOM_Scope void  SOMLINK ContainerPartUnClipSelectionFromEmbeddedFrames(ContainerPart *somSelf,
  858.                                                                        Environment *ev,
  859.                                                                        ODFrame* frame)
  860. {
  861.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  862.     ContainerPartMethodDebug("ContainerPart","ContainerUnPartClipSelectionFromEmbeddedFrames");
  863.  
  864.     SOM_TRY
  865.  
  866.     if (frame != _fSelectionFrame)
  867.        return;
  868.  
  869.     TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  870.     for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  871.        somSelf->UnClipSelectionFromEmbeddedFacets(ev, facet);
  872.  
  873.     SOM_CATCH_ALL
  874.     SOM_ENDTRY
  875. }
  876.  
  877.  
  878. SOM_Scope void  SOMLINK ContainerPartClipSelectionFromEmbeddedFacets(ContainerPart *somSelf,
  879.                                                                      Environment *ev,
  880.                                                                      ODFacet* facet)
  881. {
  882.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  883.     ContainerPartMethodDebug("ContainerPart","ContainerPartClipSelectionFromEmbeddedFacets");
  884.  
  885.     SOM_TRY
  886.  
  887.     if (facet->GetFrame(ev) != _fSelectionFrame)
  888.        return;
  889.  
  890.     TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  891.     if (activeFrame != _fSelectionFrame)
  892.        return;
  893.  
  894.     ODRect bbox;
  895.     ODPoint ptHandles[4];
  896.     if (_fSelection->Count() == 1)
  897.     {
  898.        /*
  899.         * Transform the coordinates of the selection handles for the selected
  900.         * frame to our local coordinates.
  901.         */
  902.  
  903.        ODRect bbox;
  904.        Proxy* p = (Proxy*)_fSelection->First();
  905.        p->shape->GetBoundingBox(ev, &bbox);
  906.        ptHandles[0].x = bbox.left;  ptHandles[0].y = bbox.bottom;
  907.        ptHandles[1].x = bbox.left;  ptHandles[1].y = bbox.top;
  908.        ptHandles[2].x = bbox.right; ptHandles[2].y = bbox.top;
  909.        ptHandles[3].x = bbox.right; ptHandles[3].y = bbox.bottom;
  910.  
  911.        ODByteArray baPoints;
  912.        UseByteArray(&baPoints, ptHandles, 4 * sizeof(ODPoint));
  913.        p->transform->TransformPoints(ev, &baPoints, 4);
  914.     }
  915.  
  916.     ODFacet* embFacet;
  917.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  918.     for (embFacet = facets->First(ev); facets->IsNotComplete(ev); embFacet = facets->Next(ev))
  919.     {
  920.        /*
  921.         * We only clip the selection handles from embedded facets for the
  922.         * single selection case since for multiple selection, the handle are
  923.         * just adornments and do not respond to mouse input.
  924.         */
  925.        ODBoolean clipHandles = kODFalse;
  926.  
  927.        if (_fSelection->Count() == 1)
  928.        {
  929.  
  930.           /*
  931.            * Instead of blindly subtracting the handle shape from each
  932.            * embedded frame, we'll attempt to be intelegent about it and
  933.            * only subtract the handle shape from those frames that we determine
  934.            * overlap the handles.
  935.            */
  936.  
  937.           int i;
  938.           ODFrame* embFrame = embFacet->GetFrame(ev);
  939.           ODPoint ptHandlesLocal[4];
  940.           memcpy(ptHandlesLocal, ptHandles, sizeof(ptHandles));
  941.           Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
  942.           /* need to implement transform->InvertPoints - ced */
  943.           for (i = 0; i < 4; i++)
  944.              p->transform->InvertPoint(ev, &ptHandlesLocal[i]); // [137664]
  945.  
  946.           /*
  947.            * Determine if any of the sizing handles might overlap the frame
  948.            * rectangle.  We inflate the frame rectangle by half the width of
  949.            * the handles multiplied by 1.5 to approximate the diagonal from
  950.            * the center point of the handle to a corner since the frame might
  951.            * be rotated with respect to the handles.
  952.            */
  953.  
  954.           p->shape->GetBoundingBox(ev, &bbox);
  955.           ODCoordinate width = kSelectionHandleWidth >> 1; // divide by 2
  956.           width = width + (width >> 1);    // multiply by 1.5
  957.           bbox.Inset(-width, -width);
  958.           for (i = 0; i < 4; i++)
  959.           {
  960.              /*
  961.               * Does the rectangle contain the point.
  962.               */
  963.              if (ptHandlesLocal[i].x >= bbox.left   &&
  964.                  ptHandlesLocal[i].x <  bbox.right  &&
  965.                  ptHandlesLocal[i].y >= bbox.bottom &&
  966.                  ptHandlesLocal[i].y <  bbox.top)
  967.              {
  968.                 clipHandles = kODTrue;
  969.                 break;
  970.              }
  971.           }
  972.        }
  973.  
  974.        FacetClip* facetClip = somSelf->FindFacetClip(ev, embFacet);
  975.        if (clipHandles)
  976.        {
  977.           if (!facetClip)
  978.           {
  979.              facetClip = new FacetClip;
  980.              facetClip->facet = embFacet;
  981.              facetClip->clip = ODCopyAndRelease(ev, embFacet->AcquireClipShape(ev, kODNULL));
  982.              _fSavedFacetClipShapes->AddFirst(facetClip);
  983.           }
  984.           TempODShape newClipShape = facetClip->clip->Copy(ev);
  985.           Proxy* p = somSelf->ProxyForFrame(ev, embFacet->GetFrame(ev));
  986.           newClipShape->Transform(ev, p->transform);
  987.           newClipShape->Subtract(ev, _fSelectShape);
  988.           TempODTransform invert = p->transform->Copy(ev)->Invert(ev);
  989.           newClipShape->Transform(ev, invert);
  990.           embFacet->ChangeGeometry(ev, newClipShape, kODNULL, kODNULL);
  991.        }
  992.        else
  993.        {
  994.           if (facetClip)
  995.           {
  996.              embFacet->ChangeGeometry(ev, facetClip->clip, kODNULL, kODNULL);
  997.              ODReleaseObject(ev, facetClip->clip);
  998.              _fSavedFacetClipShapes->Remove(facetClip);
  999.              delete facetClip;
  1000.           }
  1001.        }
  1002.     }
  1003.     delete facets;
  1004.  
  1005.     SOM_CATCH_ALL
  1006.     SOM_ENDTRY
  1007. }
  1008.  
  1009. SOM_Scope void  SOMLINK ContainerPartUnClipSelectionFromEmbeddedFacets(ContainerPart *somSelf,
  1010.                                                                        Environment *ev,
  1011.                                                                        ODFacet* facet)
  1012. {
  1013.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1014.     ContainerPartMethodDebug("ContainerPart","ContainerPartUnClipSelectionFromEmbeddedFacets");
  1015.  
  1016.     SOM_TRY
  1017.  
  1018.     ODFacet* embFacet;
  1019.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  1020.     for (embFacet = facets->First(ev); facets->IsNotComplete(ev); embFacet = facets->Next(ev))
  1021.     {
  1022.        FacetClip* facetClip = somSelf->FindFacetClip(ev, embFacet);
  1023.        if (facetClip)
  1024.           embFacet->ChangeGeometry(ev, facetClip->clip, kODNULL, kODNULL);
  1025.     }
  1026.  
  1027.     SOM_CATCH_ALL
  1028.     SOM_ENDTRY
  1029. }
  1030.  
  1031. SOM_Scope void  SOMLINK ContainerPartCommonInitContainerPart(ContainerPart *somSelf,
  1032.                                                               Environment *ev )
  1033. {
  1034.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1035.     ContainerPartMethodDebug("ContainerPart","ContainerPartCommonInitContainerPart");
  1036.  
  1037.     SOM_TRY
  1038.  
  1039.     CHAR  Error[256] = "";                    //used in DosLoadModule
  1040.  
  1041.     _fDisplayFrames = new ODxOrderedCollection;
  1042.     _fEmbeddedFrames = new ODxOrderedCollection;
  1043.  
  1044.  
  1045.     _fContents = new ODxOrderedCollection;
  1046.     _fSelection = new ODxOrderedCollection;
  1047.     _fSavedFacetClipShapes = new ODxOrderedCollection;
  1048.     SIZEL sizlPage = {0, 0};
  1049.     _hdcMem = DevOpenDC   (1 , OD_MEMORY, "*", 0L, NULL, (HDC)0) ;
  1050.     _hpsMem = GpiCreatePS (1 , _hdcMem, &sizlPage, PU_PELS      | GPIF_DEFAULT |
  1051.                                                  GPIT_MICRO   | GPIA_ASSOC) ;
  1052.  
  1053.     ODRect initRect(0,0,0,0);
  1054.     _fSelectShape = new ODShape;
  1055.     _fSelectShape->SetRectangle(ev, &initRect);
  1056.     _fSelectShape->Acquire(ev);
  1057.  
  1058.     _fSession = somSelf->GetStorageUnit(ev)->GetSession(ev);
  1059.  
  1060.  
  1061.     _fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
  1062.     _fMenuFocus = _fSession->Tokenize(ev, kODMenuFocus);
  1063.     _fKeyFocus = _fSession->Tokenize(ev, kODKeyFocus);
  1064.     _fMouseFocus = _fSession->Tokenize(ev, kODMouseFocus);
  1065.  
  1066.     _fClipboardFocus = _fSession->Tokenize(ev, kODClipboardFocus);
  1067.     if (_fSession->HasExtension(ev, kODExtStatusLine))
  1068.     {
  1069.        _fStatusLn =(ODStatusLineExtension*) _fSession->AcquireExtension(ev,kODExtStatusLine); // 124281
  1070.        _fStatusFocus = _fSession->Tokenize(ev, kODStatusLineFocus);
  1071.     }
  1072.     _fFocusSet = _fSession->GetArbitrator(ev)->CreateFocusSet(ev);
  1073.  
  1074.     _fFocusSet->Add(ev, _fSelectionFocus);
  1075.     _fFocusSet->Add(ev, _fMenuFocus);
  1076.     _fFocusSet->Add(ev, _fKeyFocus);
  1077.  
  1078.  
  1079.     if (_hmod == kODNULL)
  1080.     {
  1081.         if(DosLoadModule(Error,sizeof(Error),"CNTMRI",&_hmod))
  1082.            WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to load Container Part's resource file!",
  1083.               NULL, 0, MB_ENTER | MB_ERROR); // 141477
  1084.     }
  1085.  
  1086. //@127858 begin
  1087.     _fSemtIntf = new ODSemanticInterface();
  1088.     _fSemtIntf->InitSemanticInterface(ev, somSelf, _fSession);
  1089.  
  1090.      ODObjectAccessorUPP theAccessorUPP;
  1091.  
  1092.      theAccessorUPP = NewODObjectAccessorProc( GetPropertyFromNULL );
  1093.      _fSemtIntf->InstallObjectAccessor(ev, cProperty, typeNull, theAccessorUPP,
  1094.                     (ODSLong)somSelf);
  1095.  
  1096.      ODEventHandlerUPP newHandler;
  1097.  
  1098.      newHandler = NewODEventHandlerProc( HandleSetData ) ;
  1099.      _fSemtIntf->InstallEventHandler(ev, kAECoreSuite, kAESetData,
  1100.                         newHandler,
  1101.                         (ODSLong)somSelf);
  1102.  
  1103.      newHandler = NewODEventHandlerProc( HandleGetData ) ;
  1104.      _fSemtIntf->InstallEventHandler(ev, kAECoreSuite, kAEGetData,
  1105.                         newHandler,
  1106.                         (ODSLong)somSelf);
  1107. //@127858 end
  1108.  
  1109.     _fNotebook = kODNULL;
  1110.  
  1111.      _fMenuBar = _fSession->GetWindowState(ev)->CopyBaseMenuBar(ev);
  1112.       // It is required that parts instantiate their menu bars from
  1113.       // the base OpenDoc menu bar. This maintains consistency in the
  1114.       // default menu items and their placement.
  1115.       // Since the object is a copy, we can add and subtract menus and
  1116.       // items without affecting other running parts.
  1117.     if ( _fMenuBar ) {
  1118.        _fPopup = _fSession->GetWindowState(ev)->CopyBasePopup(ev);
  1119.        somSelf->InstallMenus(ev);
  1120.     }
  1121.  
  1122.     SOM_CATCH_ALL
  1123.     SOM_ENDTRY
  1124. }
  1125.  
  1126. SOM_Scope ODxOrderedCollection*  SOMLINK ContainerPartGetEmbeddedFrames(ContainerPart *somSelf,
  1127.                                                                          Environment *ev)
  1128. {
  1129.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1130.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetEmbeddedFrames");
  1131.  
  1132.     return _fEmbeddedFrames;
  1133. }
  1134.  
  1135. SOM_Scope ODxOrderedCollection*  SOMLINK ContainerPartGetDisplayFrames(ContainerPart *somSelf,
  1136.                                                                          Environment *ev)
  1137. {
  1138.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1139.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetDisplayFrames");
  1140.  
  1141.     return _fDisplayFrames;
  1142. }
  1143.  
  1144. SOM_Scope FacetClip* SOMLINK ContainerPartFindFacetClip(ContainerPart* somSelf,
  1145.                                                         Environment* ev,
  1146.                                                         ODFacet* facet)
  1147. {
  1148.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1149.     ContainerPartMethodDebug("ContainerPart","ContainerPartFindFacetClip");
  1150.  
  1151.     FacetClip* p = kODNULL;
  1152.  
  1153.     SOM_TRY
  1154.  
  1155.     if (_fSavedFacetClipShapes->Count())
  1156.     {
  1157.        ODxOrderedCollectionIterator i(_fSavedFacetClipShapes);
  1158.        for (p = (FacetClip*) i.First(); i.IsNotComplete(); p = (FacetClip*) i.Next())
  1159.           if (p->facet == facet) break;
  1160.     }
  1161.  
  1162.     SOM_CATCH_ALL
  1163.        p = kODNULL;
  1164.     SOM_ENDTRY
  1165.  
  1166.     return p;
  1167. }
  1168.  
  1169. SOM_Scope Proxy*  SOMLINK ContainerPartProxyForFrameID(ContainerPart *somSelf,
  1170.                                                         Environment *ev,
  1171.                                                        ODID frameID)
  1172. {
  1173.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1174.     ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrameID");
  1175.  
  1176.     Proxy* p = kODNULL;
  1177.  
  1178.     SOM_TRY
  1179.  
  1180.     TempODFrame tempFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->AcquireFrame(ev, frameID);
  1181.     p = somSelf->ProxyForFrame(ev, tempFrame);
  1182.  
  1183.     SOM_CATCH_ALL
  1184.     SOM_ENDTRY
  1185.  
  1186.     return p;
  1187. }
  1188.  
  1189. SOM_Scope void  SOMLINK ContainerPartHighlightSelection(ContainerPart *somSelf,
  1190.                                                          Environment *ev,
  1191.                                                         ODFacet* facet)
  1192. {
  1193.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1194.     ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightSelection");
  1195.  
  1196.     SOM_TRY
  1197.  
  1198.     if (facet->GetCanvas(ev)->IsDynamic(ev))
  1199.     {
  1200.        switch (_fSelection->Count())
  1201.        {
  1202.           case 0:     // no selection
  1203.              break;
  1204.  
  1205.           case 1:     // single selection
  1206.              {  ODxOrderedCollectionIterator i(_fSelection);
  1207.                 somSelf->HighlightProxyBorder(ev, (Proxy*)i.First(), facet);
  1208.              };
  1209.              break;
  1210.  
  1211.           default: // multiple selection
  1212.              {  Proxy* p;
  1213.                 ODxOrderedCollectionIterator i(_fSelection);
  1214.                 somSelf->HighlightProxyBorder(ev, (Proxy*)i.First(), facet);
  1215.                 for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1216.                 {  if (_fSelection->Contains(p))
  1217.                       somSelf->HighlightContentObject(ev, p, facet);
  1218.                 };
  1219.              };
  1220.        };
  1221.     }
  1222.  
  1223.     SOM_CATCH_ALL
  1224.     SOM_ENDTRY
  1225. }
  1226.  
  1227.  
  1228. SOM_Scope void  SOMLINK ContainerPartHighlightProxyBorder(ContainerPart *somSelf,
  1229.                                                            Environment *ev,
  1230.                                                           Proxy* p,
  1231.                                                           ODFacet* facet)
  1232. {
  1233.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1234.     ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightProxyBorder");
  1235.  
  1236.     SOM_TRY
  1237.  
  1238.     if (_fSelection->Count())
  1239.     {
  1240.        AREABUNDLE areaBundle;
  1241.        LINEBUNDLE lineBundle;
  1242.        MATRIXLF mtx, mtxSave;
  1243.        HPS hps = facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->GetPS(ev, facet);
  1244.        areaBundle.lColor = (_fSelection->Count() == 1) ? CLR_BLACK : CLR_PALEGRAY;
  1245.        GpiSetAttrs(hps, PRIM_AREA, ABB_COLOR, 0, &areaBundle);
  1246.        GpiQueryModelTransformMatrix(hps, 9, &mtxSave);
  1247.  
  1248.        Proxy* p;
  1249.        ODxOrderedCollectionIterator i(_fSelection);
  1250.        for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  1251.        {
  1252.           ODRect bbox;
  1253.           ODPoint pt[4];
  1254.           POINTL ptl;
  1255.           RECTL rclBox;
  1256.           p->shape->GetBoundingBox(ev, &bbox);
  1257.           pt[0].x = bbox.left;  pt[0].y = bbox.bottom;
  1258.           pt[1].x = bbox.left;  pt[1].y = bbox.top;
  1259.           pt[2].x = bbox.right; pt[2].y = bbox.top;
  1260.           pt[3].x = bbox.right; pt[3].y = bbox.bottom;
  1261.  
  1262.           ODByteArray baPoints;
  1263.           UseByteArray(&baPoints, pt, 4 * sizeof(ODPoint));
  1264.           p->transform->TransformPoints(ev, &baPoints, 4);
  1265.  
  1266.           lineBundle.lColor = CLR_WHITE;
  1267.           lineBundle.usMixMode = FM_OVERPAINT;
  1268.           GpiSetAttrs(hps, PRIM_LINE, LBB_COLOR | LBB_MIX_MODE, 0, &lineBundle);
  1269.           GpiSetLineType(hps, LINETYPE_SOLID);
  1270.           for (int i = 0; i < 4; i++)
  1271.           {
  1272.              ODPoint point = pt[i];
  1273.              point.Offset(-kSelectionHandleWidth / 2, -kSelectionHandleWidth / 2);
  1274.              ptl = point.AsPOINTL();
  1275.              GpiMove(hps, &ptl);
  1276.              point.Offset(kSelectionHandleWidth, kSelectionHandleWidth);
  1277.              ptl = point.AsPOINTL();
  1278.              GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
  1279.           }
  1280.           p->transform->GetMATRIXLF(ev, &mtx);
  1281.           GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_PREEMPT);
  1282.           lineBundle.lColor = CLR_BLACK;
  1283.           lineBundle.usMixMode = FM_INVERT;
  1284.           GpiSetAttrs(hps, PRIM_LINE, LBB_COLOR | LBB_MIX_MODE, 0, &lineBundle);
  1285.           GpiSetLineType(hps, LINETYPE_LONGDASH);
  1286.           bbox.Inset(-kSelectionHandleWidth / 2, -kSelectionHandleWidth / 2);
  1287.           bbox.AsRECTL(rclBox);
  1288.           ptl.x = rclBox.xLeft;  ptl.y = rclBox.yBottom;
  1289.           GpiMove(hps, &ptl);
  1290.           ptl.x = rclBox.xRight; ptl.y = rclBox.yTop;
  1291.           GpiBox(hps, DRO_OUTLINE, &ptl, (kSelectionHandleWidth * 6) >> 16,
  1292.                                          (kSelectionHandleWidth * 6) >> 16);
  1293.           GpiSetModelTransformMatrix(hps, 9, &mtxSave, TRANSFORM_REPLACE);
  1294.        }
  1295.        facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->ReleasePS(ev, facet);
  1296.     }
  1297.  
  1298.     SOM_CATCH_ALL
  1299.     SOM_ENDTRY
  1300. }
  1301.  
  1302. SOM_Scope void  SOMLINK ContainerPartHighlightContentObject(ContainerPart *somSelf,
  1303.                                                              Environment *ev,
  1304.                                                             Proxy* p,
  1305.                                                             ODFacet* facet)
  1306. {
  1307.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1308.     ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightContentObject");
  1309.  
  1310. }
  1311.  
  1312. SOM_Scope void  SOMLINK ContainerPartClipEmbeddedFacets(ContainerPart *somSelf,
  1313.                                                          Environment *ev,
  1314.                                                         ODFacet* facet)
  1315. {
  1316.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1317.     ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFacets");
  1318.  
  1319.     SOM_TRY
  1320.  
  1321.     FacetInfoRec* pInfo = (FacetInfoRec *)facet->GetPartInfo(ev);
  1322.     ODShape* workingClip = (ODShape *)pInfo->fClipShape;
  1323.     workingClip->Reset(ev);
  1324.  
  1325.     ODFacet* embFacet;
  1326.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  1327.     for (embFacet = facets->First(ev);
  1328.           facets->IsNotComplete(ev);
  1329.           embFacet = facets->Next(ev))
  1330.     {
  1331.        Proxy* p = somSelf->ProxyForFrame(ev, embFacet->GetFrame(ev));
  1332.        TempODShape usedShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL));
  1333.        TempODShape clipShape = usedShape->Copy(ev); // 142961 - aml
  1334.  
  1335.        workingClip->InverseTransform(ev, p->transform);    // now in embedded frame's coordinates
  1336.        clipShape->Subtract(ev, workingClip);
  1337.        workingClip->Union(ev, usedShape);    // 142961 - aml
  1338.        workingClip->Transform(ev, p->transform);           // content coordinates
  1339.  
  1340.        embFacet->ChangeGeometry(ev, clipShape, p->transform, kODNULL);
  1341.     }
  1342.     delete facets;
  1343.  
  1344.  
  1345.     while (_fSavedFacetClipShapes->Count())
  1346.     {
  1347.        FacetClip* facetClip = (FacetClip*)_fSavedFacetClipShapes->First();
  1348.        ODReleaseObject(ev, facetClip->clip);
  1349.        _fSavedFacetClipShapes->RemoveFirst();
  1350.        delete facetClip;
  1351.     }
  1352.  
  1353.     somSelf->ClipSelectionFromEmbeddedFacets(ev, facet);
  1354.  
  1355.     SOM_CATCH_ALL
  1356.     SOM_ENDTRY
  1357. }
  1358.  
  1359.  
  1360. SOM_Scope void  SOMLINK ContainerPartAdjustPopupMenu(ContainerPart *somSelf,
  1361.                                                       Environment *ev,
  1362.                                                       ODFrame* frame)
  1363. {
  1364.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1365.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustPopupMenu");
  1366.  
  1367.  
  1368. }
  1369.  
  1370. SOM_Scope void  SOMLINK ContainerPartAdjustSelectedMenu(ContainerPart *somSelf,
  1371.                                                     Environment *ev,
  1372.                                                    ODFrame* frame)
  1373. {
  1374.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1375.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustSSelectedMenu");
  1376.  
  1377. }
  1378.  
  1379. SOM_Scope void  SOMLINK ContainerPartClearSelectedMenu(ContainerPart *somSelf,
  1380.                                                        Environment *ev,
  1381.                                                       ODFrame* frame)
  1382. {
  1383.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1384.     ContainerPartMethodDebug("ContainerPart","ContainerPartRestoreSelectedMenu");
  1385.  
  1386. }
  1387.  
  1388. SOM_Scope void  SOMLINK ContainerPartClearPopupMenu(ContainerPart *somSelf,
  1389.                                                        Environment *ev,
  1390.                                                       ODFrame* frame)
  1391. {
  1392.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1393.     ContainerPartMethodDebug("ContainerPart","ContainerPartRestoreSelectedMenu");
  1394.  
  1395. }
  1396.  
  1397. SOM_Scope void  SOMLINK ContainerPartEmptySelection(ContainerPart *somSelf,
  1398.                                                      Environment *ev)
  1399. {
  1400.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1401.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmptySelection");
  1402.  
  1403.     SOM_TRY
  1404.  
  1405.     if (_fSelection->Count())
  1406.     {
  1407.        Proxy* p = kODNULL;
  1408.        for(ODULong i = _fSelection->Count(); i > 0; i--)
  1409.        {
  1410.           p = (Proxy*)_fSelection->First();
  1411.           ODxOrderedCollectionIterator i(p);
  1412.           for (ODFrame* frame = (ODFrame*)i.First();
  1413.                i.IsNotComplete();
  1414.                frame = (ODFrame*)i.Next())
  1415.           {
  1416.              somSelf->SetFrameSelected(ev, frame, kODFalse);
  1417.           }
  1418.           _fSelection->RemoveFirst();
  1419.        }
  1420.        _fSelectShape->Reset(ev);
  1421.  
  1422.        ODReleaseObject(ev, _fSelectionFrame);
  1423.     }
  1424.  
  1425.     SOM_CATCH_ALL
  1426.     SOM_ENDTRY
  1427. }
  1428.  
  1429.  
  1430. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1Click(ContainerPart *somSelf,
  1431.                                                           Environment *ev,
  1432.                                                           ODFacet* facet,
  1433.                                                           ODPoint* where,
  1434.                                                           ODEventData* event)
  1435. {
  1436.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1437.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Click");
  1438.  
  1439.     ODBoolean handled = kODFalse;
  1440.  
  1441.     SOM_TRY
  1442.  
  1443.     if (_fMouseMode == kNormal)
  1444.     {
  1445.        if (!facet->GetWindow(ev)->IsActive(ev))
  1446.           facet->GetWindow(ev)->Select(ev);
  1447.  
  1448.        if (event->msg == WM_BUTTON1CLICK)
  1449.        {
  1450.           //   [126751] if scaling to zero, unbundle
  1451.  
  1452.           if ( _fTrackingMode == kSelectScaleOrigin )
  1453.           {
  1454.             _fTrackingMode = 0;                             // default value
  1455.             somSelf->FreezeEmbeddedFrames(ev, kODFalse);    // unbundle frame
  1456.           }
  1457.  
  1458.           ODBoolean bActive = kODFalse;     // [131094]
  1459.  
  1460.           PartInfoRec* pInfo = (PartInfoRec*) facet->GetFrame(ev)->GetPartInfo(ev);
  1461.           if ( pInfo->fIsActive )
  1462.              bActive = kODTrue;             // [131094]
  1463.  
  1464.           if ( bActive )                   
  1465.           {
  1466.              somSelf->DoDeSelectAll(ev, facet->GetFrame(ev));
  1467.           } else
  1468.              somSelf->ActivateFrame(ev, facet->GetFrame(ev));
  1469.  
  1470.           if ( _fPasteESC )                  // we abort the paste operation
  1471.           {
  1472.                _fPasteOn = kODFalse;
  1473.           }
  1474.           else
  1475.           {
  1476.             if ( _fPasteOn )
  1477.             {
  1478.                if ( _fPasteFrame == facet->GetFrame(ev) )
  1479.                {
  1480.                  somSelf->PasteFrameFromClipboard(ev, facet, where);
  1481.                  somSelf->DisplayStatusLineText(ev, "Paste completed", facet->GetFrame(ev));
  1482.                }
  1483.                else
  1484.                {
  1485.                  somSelf->DisplayStatusLineText(ev,
  1486.                                                 "Click again to complete Paste operation",
  1487.                                                 facet->GetFrame(ev));
  1488.                  _fPasteFrame = facet->GetFrame(ev);
  1489.                }
  1490.             }
  1491.                                              // 128682 - faa - ends
  1492.           }
  1493.  
  1494.           handled = kODTrue;
  1495.        }
  1496.     }
  1497.     else
  1498.        handled = kODTrue;
  1499.  
  1500.     SOM_CATCH_ALL
  1501.     SOM_ENDTRY
  1502.  
  1503.     return handled;
  1504. }
  1505.  
  1506. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1Down(ContainerPart *somSelf,
  1507.                                                           Environment *ev,
  1508.                                                           ODFacet* facet,
  1509.                                                           ODPoint* where,
  1510.                                                           ODEventData* event)
  1511. {
  1512.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1513.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Down");
  1514.  
  1515.     ODBoolean handled = kODFalse;
  1516.  
  1517.     SOM_TRY
  1518.  
  1519.     ODPoint mouse = *where;
  1520.     TempODTransform xform = ((_fMouseMode == kTracking) ? _fTrackingFacet : facet)->
  1521.                                             AcquireWindowContentTransform(ev, kODNULL);
  1522.     xform->InvertPoint(ev, &mouse); // [137664]
  1523.  
  1524.     switch(_fMouseMode)
  1525.     {
  1526.        case kRotateSelectCenter:
  1527.           if (somSelf->BeginTrackingMouse(ev, facet))
  1528.           {
  1529.              _fTrackingMode = kSelectRotateOrigin;
  1530.              _ptRef = _ptOrigin = _ptEnd = mouse;
  1531.              somSelf->UpdateTrackRect(ev, &mouse, facet, kUpdateModeStart);
  1532.              ODFrame* frame = facet->GetFrame(ev);            // 124281
  1533.              somSelf->DisplayStatusLineText(ev,"Btn1 drag to rotate; ESC or Btn2 Click to cancel.",frame); // 124281
  1534.           }
  1535.           handled = kODTrue;
  1536.           break;
  1537.  
  1538.        case kScaleSelectRefPoint:
  1539.           if (somSelf->BeginTrackingMouse(ev, facet))
  1540.           {
  1541.              _fTrackingMode = kSelectScaleOrigin;
  1542.              _ptRef = _ptOrigin = _ptEnd = mouse;
  1543.              somSelf->UpdateTrackRect(ev, &mouse, facet, kUpdateModeStart);
  1544.              ODFrame* frame = facet->GetFrame(ev);            // 124281
  1545.              somSelf->DisplayStatusLineText(ev,"Btn1 drag to scale; ESC or Btn2 Click to cancel.",frame); // 124281
  1546.           }
  1547.           handled = kODTrue;
  1548.           break;
  1549.  
  1550.  
  1551.        case kTracking:
  1552.        {
  1553.           if (_fTrackingMode == kSelectRotateOrigin || _fTrackingMode == kSelectScaleOrigin)
  1554.           {
  1555.              POINTL ptlMouse = mouse.AsPOINTL(),
  1556.                     ptlRef   = _ptRef.AsPOINTL();
  1557.              if (_fTrackingMode == kSelectScaleOrigin && (ptlMouse.x == ptlRef.x ||
  1558.                                                           ptlMouse.y == ptlRef.y ))
  1559.              {
  1560.                 somSelf->ResetMouseMode(ev);
  1561.              }
  1562.              else
  1563.              {
  1564.                 somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeEnd);
  1565.                 _ptOrigin = _ptEnd = mouse;
  1566.                 _fTrackingMode = (_fTrackingMode == kSelectScaleOrigin) ?
  1567.                                          kScaleSelection : kRotateSelection;
  1568.                 somSelf->FreezeEmbeddedFrames(ev, kODFalse);
  1569.                 somSelf->CreateTrackingPolygons(ev, kODTrue);
  1570.                 somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeStart);
  1571.              }
  1572.              handled = kODTrue;
  1573.              break;
  1574.           }
  1575.        }
  1576.     }
  1577.  
  1578.     SOM_CATCH_ALL
  1579.     SOM_ENDTRY
  1580.  
  1581.     return handled;
  1582. }
  1583.  
  1584.  
  1585. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1MotionStart(ContainerPart *somSelf,
  1586.                                                                    Environment *ev,
  1587.                                                                    ODFacet* facet,
  1588.                                                                    ODPoint* where,
  1589.                                                                    ODEventData* event)
  1590. {
  1591.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1592.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1MotionStart");
  1593.  
  1594.     ODBoolean handled = kODFalse;
  1595.  
  1596.     SOM_TRY
  1597.  
  1598.     ODFrame* frame = ((_fMouseMode == kTracking) ? _fTrackingFacet : facet)->GetFrame(ev);   // [133692] - ced
  1599.     PartInfoRec* pInfo = (PartInfoRec*)frame->GetPartInfo(ev);
  1600.     if (pInfo->fIsActive && _fMouseMode == kNormal)
  1601.     {
  1602.        ODPoint mouse = *where;
  1603.        TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  1604.        xform->InvertPoint(ev, &mouse); // [137664]
  1605.  
  1606.        if (facet->GetFrame(ev) == _fSelectionFrame && 
  1607.            _fSelection->Count() == 1 && _fSelectShape->ContainsPoint(ev, &mouse))
  1608.        {
  1609.           Proxy* p = (Proxy*)_fSelection->First();
  1610.           ODRect bbox;
  1611.           ODPoint ptCorners[4], ptSelMouse, ptSelCenter;
  1612.           p->shape->GetBoundingBox(ev, &bbox);
  1613.           ptSelMouse = mouse;       // [137664]
  1614.           p->transform->InvertPoint(ev, &ptSelMouse); // in selections frame coords
  1615.           ptSelCenter.x = (bbox.left + bbox.right) / 2;
  1616.           ptSelCenter.y = (bbox.top + bbox.bottom) / 2;
  1617.           ptCorners[0].x = bbox.left;    ptCorners[0].y = bbox.bottom;
  1618.           ptCorners[1].x = bbox.left;    ptCorners[1].y = bbox.top;
  1619.           ptCorners[2].x = bbox.right;   ptCorners[2].y = bbox.top;
  1620.           ptCorners[3].x = bbox.right;   ptCorners[3].y = bbox.bottom;
  1621.  
  1622.           ODByteArray baPoints;
  1623.           UseByteArray(&baPoints, ptCorners, 4 * sizeof(ODPoint));
  1624.           p->transform->TransformPoints(ev, &baPoints, 4);
  1625.  
  1626.           if (ptSelMouse.x < ptSelCenter.x && ptSelMouse.y < ptSelCenter.y)
  1627.           {
  1628.              _fTrackingMode = kBotLeftResize;
  1629.              _ptRef = ptCorners[2];
  1630.              _ptMouseOffset.x = ptCorners[0].x - mouse.x;
  1631.              _ptMouseOffset.y = ptCorners[0].y - mouse.y;
  1632.           }
  1633.           else if (ptSelMouse.x < ptSelCenter.x && ptSelMouse.y > ptSelCenter.y)
  1634.           {
  1635.              _fTrackingMode = kTopLeftResize;
  1636.              _ptRef = ptCorners[3];
  1637.              _ptMouseOffset.x = ptCorners[1].x - mouse.x;
  1638.              _ptMouseOffset.y = ptCorners[1].y - mouse.y;
  1639.           }
  1640.           else if (ptSelMouse.x > ptSelCenter.x && ptSelMouse.y > ptSelCenter.y)
  1641.           {
  1642.              _fTrackingMode = kTopRightResize;
  1643.              _ptRef = ptCorners[0];
  1644.              _ptMouseOffset.x = ptCorners[2].x - mouse.x;
  1645.              _ptMouseOffset.y = ptCorners[2].y - mouse.y;
  1646.           }
  1647.           else if (ptSelMouse.x > ptSelCenter.x && ptSelMouse.y < ptSelCenter.y)
  1648.           {
  1649.              _fTrackingMode = kBotRightResize;
  1650.              _ptRef = ptCorners[1];
  1651.              _ptMouseOffset.x = ptCorners[3].x - mouse.x;
  1652.              _ptMouseOffset.y = ptCorners[3].y - mouse.y;
  1653.           }
  1654.           _ptEnd = _ptOrigin = mouse;
  1655.           somSelf->CreateTrackingPolygons(ev, kODFalse);
  1656.        }
  1657.        else
  1658.        {
  1659.           _fTrackingMode = kRubberBandSelection;
  1660.           _ptEnd = _ptOrigin = mouse;
  1661.  
  1662.           if (_fSelection->Count())
  1663.           {
  1664.              somSelf->DoDeSelectAll(ev, facet->GetFrame(ev));
  1665.              /*
  1666.               * Force updating now since we're about to lock window updating
  1667.               */
  1668.              WinUpdateWindow(facet->GetWindow(ev)->GetPlatformWindow(ev));
  1669.           }
  1670.        }
  1671.  
  1672.        somSelf->BeginTrackingMouse(ev, facet);
  1673.        _ptEnd = mouse;
  1674.        handled = kODTrue;
  1675.     }
  1676.  
  1677.     SOM_CATCH_ALL
  1678.     SOM_ENDTRY
  1679.  
  1680.     return handled;
  1681. }
  1682.  
  1683.  
  1684. SOM_Scope void  SOMLINK ContainerPartCreateTrackingPolygons(ContainerPart *somSelf,
  1685.                                                             Environment *ev,
  1686.                                                             ODBoolean transformPoints)
  1687. {
  1688.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1689.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateTrackingPolygons");
  1690.  
  1691.     SOM_TRY
  1692.  
  1693.     _fNumPolygons = _fSelection->Count();
  1694.     _fPolygons = new POLYGON[_fNumPolygons];
  1695.     Proxy* p;
  1696.     int i;
  1697.     ODxOrderedCollectionIterator iter(_fSelection);
  1698.     for (i = 0, p = (Proxy*) iter.First(); iter.IsNotComplete(); i++, p = (Proxy*) iter.Next())
  1699.     {
  1700.        ODRect bbox;
  1701.        p->shape->GetBoundingBox(ev, &bbox);
  1702.  
  1703.        _fPolygons[i].ulPoints = 4;
  1704.        _fPolygons[i].aPointl = new POINTL[4];
  1705.        ODPoint apt[4];
  1706.        apt[0].x = bbox.left;  apt[0].y = bbox.bottom;
  1707.        apt[1].x = bbox.left;  apt[1].y = bbox.top;
  1708.        apt[2].x = bbox.right; apt[2].y = bbox.top;
  1709.        apt[3].x = bbox.right; apt[3].y = bbox.bottom;
  1710.        for (int j=0; j<4; j++)
  1711.        {
  1712.            if (transformPoints)
  1713.               p->transform->TransformPoint(ev, &apt[j]); // [137664]
  1714.  
  1715.            _fPolygons[i].aPointl[j] = apt[j].AsPOINTL();
  1716.        }
  1717.     }
  1718.  
  1719.     SOM_CATCH_ALL
  1720.     SOM_ENDTRY
  1721. }
  1722.  
  1723.  
  1724. SOM_Scope void SOMLINK ContainerPartResetMouseMode(ContainerPart *somSelf,
  1725.                                                    Environment *ev)
  1726. {
  1727.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1728.     ContainerPartMethodDebug("ContainerPart","ContainerPartResetMouseMode");
  1729.  
  1730.     SOM_TRY
  1731.  
  1732.     if (_fMouseMode == kTracking)
  1733.     {
  1734.        ODFrame* frame = _fTrackingFacet->GetFrame(ev);
  1735.        _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, frame);
  1736.        somSelf->FocusLost(ev, _fMouseFocus, frame);
  1737.        somSelf->DisplayStatusLineText(ev,"",frame); // 124281
  1738.     }
  1739.     else if (_fMouseMode != kNormal)
  1740.     {
  1741.        somSelf->FreezeEmbeddedFrames(ev, kODFalse);
  1742.        WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
  1743.        somSelf->DisplayStatusLineText(ev,"",_fSelectionFrame); // [133692] - ced
  1744.     }
  1745.     _fMouseMode = kNormal;
  1746.  
  1747.     SOM_CATCH_ALL
  1748.     SOM_ENDTRY
  1749. }
  1750.  
  1751.  
  1752. SOM_Scope ODBoolean  SOMLINK ContainerPartBeginTrackingMouse(ContainerPart *somSelf,
  1753.                                                        Environment *ev,
  1754.                                                        ODFacet* facet)
  1755. {
  1756.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1757.     ContainerPartMethodDebug("ContainerPart","ContainerPartBeginTrackingMouse");
  1758.  
  1759.    ODBoolean handled = kODFalse;
  1760.  
  1761.    SOM_TRY
  1762.  
  1763.    HWND hwndFrame = facet->GetWindow(ev)->GetPlatformWindow(ev);
  1764.    HWND hwnd = WinWindowFromID(hwndFrame, FID_CLIENT);
  1765.    ODFrame* frame = facet->GetFrame(ev);
  1766.  
  1767.    if (_fSession->GetArbitrator(ev)->RequestFocus(ev, _fMouseFocus, frame))
  1768.    {
  1769.      if (WinSetCapture(HWND_DESKTOP, hwnd))
  1770.      {
  1771.        if (WinLockWindowUpdate(HWND_DESKTOP, hwnd))
  1772.        {
  1773.          _fTrackingFacet = facet;
  1774.          _fMouseMode = kTracking;
  1775.          handled = kODTrue;
  1776.        }
  1777.        else
  1778.        {
  1779.          WinSetCapture(HWND_DESKTOP, 0);
  1780.          _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
  1781.                                                        frame);
  1782.        }
  1783.      }
  1784.      else
  1785.      {
  1786.        _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
  1787.                                                      frame);
  1788.      }
  1789.    }
  1790.  
  1791.    SOM_CATCH_ALL
  1792.    SOM_ENDTRY
  1793.  
  1794.    return handled;
  1795. }
  1796. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseDrag(ContainerPart *somSelf,
  1797.                                                           Environment *ev,
  1798.                                                           ODFacet* container,
  1799.                                                           ODFacet* facet,
  1800.                                                           ODPoint* mouse,
  1801.                                                           ODEventData* event)
  1802. {
  1803.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  1804.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownDrag");
  1805.  
  1806.     RECTL* arcl   = 0;
  1807.     POINTL* aptl  = 0;
  1808.     ODBoolean handled = kODFalse;
  1809.  
  1810.     SOM_TRY
  1811.  
  1812.     TempODPart destPart = kODNULL;
  1813.     ODPoint pt(0,0);
  1814.     ODShape* scratch;
  1815.     Point mdOffset = {0,0};
  1816.     HRGN dragRgn, tempRgn;
  1817.     ODID frameInfoData;
  1818.     ODDragAndDrop*   dad;
  1819.     ODStorageUnit*   unit;
  1820.     ODDropResult dropResult;
  1821.     ODFrame* containingFrame = container->GetFrame(ev);
  1822.     ODxOrderedCollectionIterator embFrames(_fEmbeddedFrames);
  1823.     ODxOrderedCollectionIterator dspFrames(_fDisplayFrames);
  1824.     Proxy *p;
  1825.     int i;
  1826.  
  1827.     
  1828.     TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  1829.     if (containingFrame != activeFrame)
  1830.        return kODFalse;  // Not handled
  1831.  
  1832.     if (containingFrame != _fSelectionFrame || !_fSelection->Count())
  1833.        return kODTrue;   // Handled
  1834.  
  1835.  
  1836.     POINTL ptlMouse = {SHORT1FROMMP(event->mp1), SHORT2FROMMP(event->mp1)};
  1837.  
  1838.     // *** Fill DAD SU with Props n' Vals
  1839.     dad = _fSession->GetDragAndDrop(ev);
  1840.     dad->Clear(ev);
  1841.     Rect shapeRect;
  1842.  
  1843.     ODULong numRects  = _fSelection->Count(),
  1844.             numPoints = numRects * 6 + 2;
  1845.     arcl   = new RECTL[numRects];
  1846.     aptl  = new POINTL[numPoints];
  1847.     TempODTransform xform = containingFrame->CreateTransform(ev),
  1848.                 contentTransform = container->AcquireWindowContentTransform(ev, kODNULL);
  1849.  
  1850.     ODxOrderedCollectionIterator iter(_fSelection);
  1851.     ODPoint ptNegMouse(-mouse->x, -mouse->y);
  1852.     PPOINTL pptl = &aptl[0];
  1853.     pptl->x = 0;
  1854.     (pptl++)->y = 0;
  1855.     for (i = 0, p = (Proxy*) iter.First(); iter.IsNotComplete(); i++, p = (Proxy*) iter.Next())
  1856.     {
  1857.        ODRect bbox;
  1858.        ODPoint pt[5];
  1859.        p->shape->GetBoundingBox(ev, &bbox);
  1860.  
  1861.  
  1862.        xform->CopyFrom(ev, p->transform);
  1863.        xform->PostCompose(ev, contentTransform);
  1864.        xform->MoveBy(ev, &ptNegMouse);
  1865.        pt[0].x = bbox.left;  pt[0].y = bbox.bottom;
  1866.        pt[1].x = bbox.left;  pt[1].y = bbox.top;
  1867.        pt[2].x = bbox.right; pt[2].y = bbox.top;
  1868.        pt[3].x = bbox.right; pt[3].y = bbox.bottom;
  1869.        pt[4].x = bbox.left;  pt[4].y = bbox.bottom;
  1870.  
  1871.        ODByteArray baPoints;
  1872.        UseByteArray(&baPoints, pt, 5 * sizeof(ODPoint));
  1873.        xform->TransformPoints(ev, &baPoints, 5);
  1874.  
  1875.        for (int j=0; j<5; j++)
  1876.           *(pptl++) = pt[j].AsPOINTL();
  1877.    }
  1878.    for (i = numRects * 5 - 4; i > 0; i -= 5)
  1879.       *(pptl++) = aptl[i];
  1880.  
  1881.    pptl->x = pptl->y = 0;
  1882.  
  1883.    delete[] arcl;
  1884.  
  1885.     DRAGIMAGE dimg;         /* DRAGIMAGE structure                   */
  1886.     HBITMAP   hbm;          /* Bit-map handle                        */
  1887.  
  1888.     /*************************************************************/
  1889.     /* Initialize the DRAGIMAGE structure                        */
  1890.     /*************************************************************/
  1891.     dimg.cb = sizeof(DRAGIMAGE); /* Size control block           */
  1892.  
  1893.     // jlc changed the following code to use a polygon rather than
  1894.     //    a bitmap because he wanted to put something on the screen
  1895.     //    quickly and didn't want to take the time to code up a
  1896.     //    bitmap.  The following code should be changed to
  1897.     //    actually provide an outline of the object, or an icon.
  1898.  
  1899.     dimg.cptl        = numPoints;  // number of points
  1900.     dimg.hImage = (ULONG)aptl;    /* Image handle passed to       */
  1901.                                  /* DrgDrag                      */
  1902.     dimg.fl = DRG_POLYGON;       /* Flags passed to DrgDrag      */
  1903.     dimg.cxOffset = 0;           /* Offset of the origin of      */
  1904.     dimg.cyOffset = 0;           /* the image from the pointer   */
  1905.                                  /* hotspot                      */
  1906.  
  1907.     for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
  1908.     {
  1909.        unit = dad->GetContentStorageUnit(ev);
  1910.        // *** (optional) save offset between mousedown pt and topLeft pt of selection
  1911.  
  1912.        // assuming event->where is in window coordinates.
  1913.        _mouseStart = ODPoint(ptlMouse);
  1914.  
  1915.        ODPoint botLeft;       // elsewhere refered to as topLeft (Mac heratige)
  1916.        ODPoint offset(ptlMouse);  // offset of mouse in window coords
  1917.  
  1918.        p->transform->GetOffset(ev, &botLeft);
  1919.  
  1920.        // botLeft contains offset of frame being dragged in my frame coords.
  1921.  
  1922.        contentTransform->InvertPoint(ev, &offset); // [137664]
  1923.  
  1924.        // offset contains the offset of the mouse in my frame coords
  1925.  
  1926.        offset.x -= botLeft.x;
  1927.        offset.y -= botLeft.y;
  1928.  
  1929.        // offset contains offset of mouse relative to position of frame
  1930.        // being dragged in my frame coords (same coords as frame shape).
  1931.  
  1932.        unit->AddProperty(ev, kPropMouseDownOffset)->AddValue(ev, kODPoint);
  1933.        StorageUnitSetValue(unit, ev, sizeof(mdOffset), (ODValue) &offset);
  1934.        // *** (optional) if dragging one frame, save its external transform (not aggregate)
  1935.  
  1936.        ODMatrix m;
  1937.        p->transform->GetMatrix(ev, &m);
  1938.        unit->AddProperty(ev, kODPropExternalTransform)->AddValue(ev, kODTransform);
  1939.        StorageUnitSetValue(unit, ev, sizeof(m), (ODValue) &m);
  1940.  
  1941.        // *** if dragging one frame, write its shape   [jpa]
  1942.        unit->AddProperty(ev, kODPropFrameShape);
  1943.        p->shape->WriteShape(ev, unit);
  1944.        ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  1945.        ODDraftKey key = fromDraft->BeginClone(ev, unit->GetDraft(ev),
  1946.                                               kODNULL, kODCloneCut);
  1947.  
  1948.        ODFrame* drgFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, containingFrame);
  1949.        p->part->CloneInto(ev, key, unit, drgFrame);
  1950.  
  1951.        fromDraft->EndClone(ev, key);
  1952.  
  1953.        // *** save ID of frame being dragged
  1954.  
  1955.        // WRite out the frame info in case it is dropped back to this part.
  1956.  
  1957.        frameInfoData = drgFrame->GetID(ev);
  1958.        unit->AddProperty(ev, kPropFrameInfo)->AddValue(ev, kFrameRef);
  1959.        StorageUnitSetValue(unit, ev, sizeof(ODID), (ODValue) &frameInfoData);
  1960.  
  1961.  
  1962.        ODxOrderedCollectionIterator i(p);
  1963.        for (ODFrame* f = (ODFrame*)i.First();
  1964.             i.IsNotComplete();
  1965.             f = (ODFrame*)i.Next())
  1966.        {
  1967.           f->SetDragging(ev, kODTrue);
  1968.        }
  1969.     }
  1970.  
  1971.     // Prevent the user from dropping into one of our other display frames.
  1972.     for (ODFrame* dspFrame = (ODFrame*)dspFrames.First();
  1973.          dspFrames.IsNotComplete();
  1974.          dspFrame = (ODFrame*)dspFrames.Next())
  1975.     {
  1976.        if (dspFrame != containingFrame)
  1977.        {
  1978.           PartInfoRec* pInfo = (PartInfoRec*)dspFrame->GetPartInfo(ev);
  1979.           pInfo->fAcceptDrop = kODFalse;
  1980.        }
  1981.     }
  1982.  
  1983.     delete[] aptl;
  1984.  
  1985.     ODByteArray dragImgBA = CreateByteArrayStruct(&dimg, sizeof(DRAGIMAGE));
  1986.     ODByteArray eventBA = CreateByteArrayStruct(&event, sizeof(ODEventData*));
  1987.     {
  1988.        ODPart* tempPart = kODNULL;
  1989.        dropResult = dad->StartDrag(ev, containingFrame, 0,
  1990.            &dragImgBA, &tempPart, &eventBA);
  1991.        destPart = tempPart;
  1992.     }
  1993.     DisposeByteArrayStruct(&dragImgBA); // [119548]
  1994.     DisposeByteArrayStruct(&eventBA);
  1995.  
  1996.     for (ODFrame* embFrame = (ODFrame*) embFrames.First(); 
  1997.          embFrames.IsNotComplete(); 
  1998.          embFrame = (ODFrame*) embFrames.Next())
  1999.     {
  2000.        embFrame->SetDragging(ev, kODFalse);
  2001.     }
  2002.     for (dspFrame = (ODFrame*)dspFrames.First();
  2003.          dspFrames.IsNotComplete();
  2004.          dspFrame = (ODFrame*)dspFrames.Next())
  2005.     {
  2006.        PartInfoRec* pInfo = (PartInfoRec*)dspFrame->GetPartInfo(ev);
  2007.        pInfo->fAcceptDrop = kODTrue;
  2008.     }
  2009.  
  2010.    if ((dropResult == kODDropCopy) || (dropResult == kODDropMove))
  2011.    {
  2012.       if (destPart == _fPartWrapper)
  2013.       {
  2014.          // The frame was dropped within the same part
  2015.          // Handled in Drop method.
  2016.       }
  2017.       else if (dropResult == kODDropMove)
  2018.       {
  2019.          // The frame was moved out
  2020.          somSelf->DoClear(ev, containingFrame);
  2021.       }
  2022.    }
  2023.    handled = kODTrue;
  2024.  
  2025.    SOM_CATCH_ALL
  2026.       delete arcl;
  2027.       delete aptl;
  2028.    SOM_ENDTRY
  2029.  
  2030.    return handled;
  2031. }
  2032.  
  2033. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1ClickInEmbeddedFrame(ContainerPart *somSelf,
  2034.                                                                           Environment *ev,
  2035.                                                                          ODFacet* container,
  2036.                                                                          ODFacet* facet,
  2037.                                                                          ODPoint* where,
  2038.                                                                          ODEventData* event)
  2039. {
  2040.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2041.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1ClickInEmbeddedFrame");
  2042.  
  2043.     ODBoolean handled = kODFalse;
  2044.  
  2045.     SOM_TRY
  2046.  
  2047.     somSelf->DisplayStatusLineText(ev, "HandleButton1ClickInEmbedded", container->GetFrame(ev));
  2048.  
  2049.     if (!container->GetWindow(ev)->IsActive(ev))
  2050.        container->GetWindow(ev)->Select(ev);
  2051.     somSelf->ActivateFrame(ev, container->GetFrame(ev));
  2052.  
  2053.                                              // 128682 - faa - starts
  2054.     if ( _fPasteOn )
  2055.     {
  2056.       somSelf->DisplayStatusLineText(ev,
  2057.                 "Frame must be activated prior to pasting",
  2058.                  container->GetFrame(ev));
  2059.       DosBeep(1500, 500);
  2060.  
  2061.       handled = kODFalse;
  2062.     }
  2063.                                              // 128682 - faa - ends
  2064.     else
  2065.     {
  2066.       Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
  2067.       PartInfoRec* pInfo = (PartInfoRec*) container->GetFrame(ev)->GetPartInfo(ev);
  2068.  
  2069.       if (event->msg == WM_BUTTON1CLICK || event->msg == WM_BUTTON1CLICK  &&
  2070.           (SHORT2FROMMP(event->mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)))
  2071.       {
  2072.          if (container->GetFrame(ev) != _fSelectionFrame)
  2073.             somSelf->DoDeSelectAll(ev, _fSelectionFrame);
  2074.  
  2075.          if (_fSelection->Count() == 0) {
  2076.             somSelf->SetFrameSelected(ev, facet->GetFrame(ev), kODTrue);
  2077.             _fSelection->AddFirst((ElementType)p);
  2078.          }
  2079.          else
  2080.          {
  2081.             somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  2082.             /*
  2083.              * If frame is already in selection then remove it from selection
  2084.              * else add it to selection.
  2085.              */
  2086.             Proxy* proxy;
  2087.             ODxOrderedCollectionIterator i(_fSelection);
  2088.             ODFrame* frame = facet->GetFrame(ev);
  2089.             for (proxy = (Proxy*) i.First(); i.IsNotComplete(); proxy = (Proxy*) i.Next())
  2090.                if (proxy == p) break;
  2091.  
  2092.             if (i.IsNotComplete())
  2093.             {
  2094.                somSelf->SetFrameSelected(ev, frame, kODFalse);
  2095.                _fSelection->Remove((ElementType)p);
  2096.             }
  2097.             else
  2098.             {
  2099.                somSelf->SetFrameSelected(ev, frame, kODTrue);
  2100.                _fSelection->AddFirst((ElementType)p);
  2101.             }
  2102.          }
  2103.  
  2104.          somSelf->CreateProxySelectionBorder(ev);
  2105.          somSelf->ClipSelectionFromEmbeddedFrames(ev, container->GetFrame(ev));
  2106.          somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  2107.       }
  2108.  
  2109.       handled = kODTrue;
  2110.     }
  2111.  
  2112.     SOM_CATCH_ALL
  2113.     SOM_ENDTRY
  2114.  
  2115.     return handled;
  2116. }
  2117.  
  2118. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1ClickInBorder(ContainerPart *somSelf,
  2119.                                                                   Environment *ev,
  2120.                                                                   ODFacet* container,
  2121.                                                                   ODFacet* facet,
  2122.                                                                   ODPoint* where,
  2123.                                                                   ODEventData* event)
  2124. {
  2125.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2126.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1ClickDownInBorder");
  2127.  
  2128.     ODBoolean handled = kODFalse;
  2129.  
  2130.     SOM_TRY
  2131.  
  2132.     somSelf->DoDeSelectAll(ev, container->GetFrame(ev));
  2133.  
  2134.     if (!container->GetWindow(ev)->IsActive(ev))
  2135.        container->GetWindow(ev)->Select(ev);
  2136.     somSelf->ActivateFrame(ev, container->GetFrame(ev));
  2137.     Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
  2138.  
  2139.     somSelf->SetFrameSelected(ev, facet->GetFrame(ev), kODTrue);
  2140.     _fSelection->AddFirst((ElementType)p);
  2141.  
  2142.     somSelf->CreateProxySelectionBorder(ev);
  2143.     somSelf->ClipSelectionFromEmbeddedFrames(ev, container->GetFrame(ev));
  2144.     somSelf->InvalidateSelection(ev, container->GetFrame(ev));
  2145.     handled = kODTrue;
  2146.  
  2147.     SOM_CATCH_ALL
  2148.     SOM_ENDTRY
  2149.  
  2150.     return handled;
  2151. }
  2152.  
  2153. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleKeyDown(ContainerPart *somSelf,
  2154.                                                          Environment *ev,
  2155.                                                         ODFrame* focusFrame,
  2156.                                                         ODEventData* event)
  2157. {
  2158.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2159.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleKeyDown");
  2160.  
  2161.     ODBoolean handled = kODFalse;
  2162.  
  2163.     SOM_TRY
  2164.  
  2165.     if ((SHORT1FROMMP(event->mp1) & KC_VIRTUALKEY) &&
  2166.              SHORT2FROMMP(event->mp2) == VK_ESC)
  2167.     {
  2168.        if (_fMouseMode != kNormal)
  2169.           somSelf->ResetMouseMode(ev);
  2170.        else
  2171.        {
  2172.           _fPasteESC = kODTrue;                        // abort cut and paste
  2173.           WinSetPointer(HWND_DESKTOP,
  2174.                         WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
  2175.        }
  2176.     }
  2177.     handled = kODTrue;
  2178.  
  2179.     SOM_CATCH_ALL
  2180.     SOM_ENDTRY
  2181.  
  2182.     return handled;
  2183. }
  2184.  
  2185. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMenuEvent(ContainerPart *somSelf,
  2186.                                                            Environment *ev,
  2187.                                                           ODFrame* focusFrame,
  2188.                                                           ODEventData* event)
  2189. {
  2190.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2191.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMenuEvent");
  2192.  
  2193.     ODBoolean handled = kODFalse;
  2194.  
  2195.     SOM_TRY
  2196.  
  2197.     PartInfoRec* pInfo = (PartInfoRec*) focusFrame->GetPartInfo(ev);
  2198.  
  2199.     ODCommandID command = LONGFROMMP(event->mp1);
  2200.  
  2201.     if (pInfo->fIsActive) {
  2202.     switch (command)
  2203.     {
  2204.        case IDMA_COLOR_GRAY      :
  2205.        case IDMA_COLOR_RED       :
  2206.        case IDMA_COLOR_GREEN     :
  2207.        case IDMA_COLOR_YELLOW    :
  2208.        case IDMA_COLOR_BLUE      :
  2209.        case IDMA_COLOR_MAGENTA   :
  2210.        case IDMA_COLOR_CYAN      :
  2211.        case IDMA_COLOR_WHITE     :
  2212.                somSelf->HandleColorMenu(ev, focusFrame, command); //@127858 change color via an OSA event now
  2213.                handled = kODTrue;
  2214.                break;
  2215.  
  2216.        case EDIT_DELETE     :
  2217.                somSelf->DoClear(ev, focusFrame);
  2218.                break;
  2219.        case EDIT_CUT       :
  2220.                somSelf->DoCut(ev, focusFrame);
  2221.                break;
  2222.        case EDIT_COPY      :
  2223.                somSelf->DoCopy(ev, focusFrame);
  2224.                break;
  2225.        case EDIT_PASTE     :
  2226.                                              // 128682 - faa - starts
  2227.                if ( somSelf->AllowPaste(ev, focusFrame) )
  2228.                {
  2229.                   _fPasteOn  = kODTrue;
  2230.                   _fPasteESC = kODFalse;
  2231.                   somSelf->FreezeEmbeddedFrames(ev, kODTrue);
  2232.                   WinSetPointer(HWND_DESKTOP,
  2233.                           WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
  2234.                  somSelf->DisplayStatusLineText(ev,
  2235.                  "Btn1 Click to Paste; ESC to cancel.",focusFrame);
  2236.  
  2237.                   handled = kODTrue;
  2238.                }
  2239.                                              // 128682 - faa - ends
  2240.                break;
  2241.        case EDIT_SELECTALL      :
  2242.                somSelf->DoSelectAll(ev, focusFrame);
  2243.                break;
  2244.        case EDIT_DESELECTALL      :
  2245.                somSelf->DoDeSelectAll(ev, focusFrame);
  2246.                break;
  2247.        case IDMA_MOVETOFRONT :
  2248.                somSelf->MoveToFront(ev, focusFrame);
  2249.                break;
  2250.        case IDMA_MOVETOBACK  :
  2251.                somSelf->MoveToBack(ev, focusFrame);
  2252.                break;
  2253.        case IDMA_MOVEFORWARD :
  2254.                somSelf->MoveForward(ev, focusFrame);
  2255.                break;
  2256.        case IDMA_MOVEBACKWARD:
  2257.                somSelf->MoveBackward(ev, focusFrame);
  2258.                break;
  2259.        case IDMA_PRINT :
  2260.                {
  2261.                   ODEventData printEvent;
  2262.                   memset(&printEvent, 0, sizeof(printEvent));
  2263.                   printEvent.hwnd = event->hwnd;
  2264.                   printEvent.msg = OD_PRINT;
  2265.                   somSelf->HandleEvent(ev, &printEvent, focusFrame, kODNULL, kODNULL);
  2266.                }
  2267.                break;
  2268.  
  2269.             case IDMA_PARTINFO:
  2270.                {
  2271.                   HMODULE hMod;
  2272.                   int rc;
  2273.                   DosQueryModuleHandle(THISDLL, &hMod);
  2274.                   rc = WinDlgBox(HWND_DESKTOP,  event->hwnd,
  2275.                 (PFNWP)CntnrPartInfoDlgProc, hMod, DL_PARTINFO, NULL );
  2276.                 }
  2277.                break;
  2278.  
  2279.        case IDMA_TOGGLE_GRID:
  2280.                {
  2281.                   PartInfoRec* pInfo = (PartInfoRec*) focusFrame->GetPartInfo(ev);
  2282.                   if (pInfo->fGridOn)
  2283.                      pInfo->fGridOn = kODFalse;
  2284.                   else
  2285.                      pInfo->fGridOn = kODTrue;
  2286.                   focusFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  2287.                   focusFrame->Invalidate(ev, kODNULL, kODNULL);
  2288.                }
  2289.                break;
  2290.  
  2291.        case IDMA_ROTATE:
  2292.                _fMouseMode = kRotateSelectCenter;
  2293.                somSelf->FreezeEmbeddedFrames(ev, kODTrue);
  2294.                WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
  2295.                somSelf->DisplayStatusLineText(ev,"Btn1 Click to select center; ESC or Btn2 Click to cancel.",focusFrame); // 124281
  2296.                break;
  2297.  
  2298.        case IDMA_SCALE:
  2299.                _fMouseMode = kScaleSelectRefPoint;
  2300.                somSelf->FreezeEmbeddedFrames(ev, kODTrue);
  2301.                WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
  2302.                somSelf->DisplayStatusLineText(ev,"Btn1 Click to select ref point; ESC or Btn2 Click to cancel.",focusFrame); // 124281
  2303.                break;
  2304.  
  2305.        case HELP_GENERAL:
  2306.                WinMessageBox(HWND_DESKTOP,
  2307.                              HWND_DESKTOP,
  2308.                              "General Help goes here",
  2309.                              "Container Part Help",
  2310.                              0L,
  2311.                              MB_OK);
  2312.                break;
  2313.        case HELP_INDEX:
  2314.                WinMessageBox(HWND_DESKTOP,
  2315.                              HWND_DESKTOP,
  2316.                              "Help Index goes here",
  2317.                              "Container Part Help",
  2318.                              0L,
  2319.                              MB_OK);
  2320.                break;
  2321.  
  2322.        case VIEW_SALARGEICON:
  2323.                {
  2324.                   Proxy* p;
  2325.                   ODxOrderedCollectionIterator i(_fSelection);
  2326.                   for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  2327.                   {
  2328.                      ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
  2329.                      for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
  2330.                         if (somSelf->ProxyForFrame(ev, frame) == p)
  2331.                            frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsLargeIcon));
  2332.                   }
  2333.                }
  2334.                break;
  2335.  
  2336.        case VIEW_SASMALLICON:
  2337.                {
  2338.                   Proxy* p;
  2339.                   ODxOrderedCollectionIterator i(_fSelection);
  2340.                   for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  2341.                   {
  2342.                      ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
  2343.                      for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
  2344.                         if (somSelf->ProxyForFrame(ev, frame) == p)
  2345.                             frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsSmallIcon));
  2346.                   }
  2347.                }
  2348.                break;
  2349.  
  2350.        case VIEW_SATHUMBNAIL:
  2351.                {
  2352.                  Proxy* p;
  2353.                  ODxOrderedCollectionIterator i(_fSelection);
  2354.                  for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  2355.                  {
  2356.                      ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
  2357.                      for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
  2358.                         if (somSelf->ProxyForFrame(ev, frame) == p)
  2359.                            frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsThumbnail));
  2360.                  }
  2361.                }
  2362.                break;
  2363.  
  2364.        case VIEW_SAFRAME:
  2365.                {
  2366.                  Proxy* p;
  2367.                  ODxOrderedCollectionIterator i(_fSelection);
  2368.                  for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  2369.                  {
  2370.                      ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
  2371.                      for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
  2372.                         if (somSelf->ProxyForFrame(ev, frame) == p)
  2373.                            frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));
  2374.                  }
  2375.                }
  2376.                break;
  2377.  
  2378.        case VIEW_OAWINDOW:
  2379.                somSelf->Open(ev, focusFrame);
  2380.                break;
  2381.  
  2382.        case VIEW_OATREE:
  2383.        case VIEW_OAICON:
  2384.        case VIEW_OADETAILS:
  2385.        case DOC_OATREE:
  2386.        case DOC_OAICON:
  2387.        case DOC_OADETAILS:
  2388.                 {
  2389.                    ODULong vType;
  2390.                    ODBoolean retVal = kODFalse;
  2391.                    if(_fViewExtension == kODNULL)
  2392.                    {
  2393.                       _fViewExtension = new ODViewExtension;
  2394.                       _fViewExtension->InitViewExtension(ev,somSelf);
  2395.                    }
  2396.                    if ((command == VIEW_OATREE) ||(command ==  DOC_OATREE)) vType = OD_TREEVIEW;
  2397.                    else if ((command == VIEW_OAICON) || (command == DOC_OAICON)) vType = OD_ICONVIEW;
  2398.                    else vType = OD_DETAILSVIEW;
  2399.  
  2400.  
  2401.                    if(vType == OD_DETAILSVIEW)
  2402.                       retVal = Test_AddDetailsColumns(somSelf, ev,_fViewExtension);
  2403.  
  2404.                    _fViewExtension->DisplayView(ev,somSelf,vType);
  2405.  
  2406.                    if((vType == OD_DETAILSVIEW) && (retVal))
  2407.                    {
  2408.                       //remove the z-order info we wrote to the embedded
  2409.                       //part(s)...we only did it to show additional columns
  2410.                       ODEmbeddedFramesIterator *CurrentFrameIter = kODNULL;
  2411.                       ODFrame *ChildFrame = kODNULL;
  2412.                       ODStorageUnit* su; //  = ChildFrame->GetStorageUnit(ev);
  2413.                       CurrentFrameIter=somSelf->CreateEmbeddedFramesIterator(ev,kODNULL);
  2414.                       if (CurrentFrameIter)
  2415.                          ChildFrame=CurrentFrameIter->First(ev);
  2416.                       while (ChildFrame) {    // remove property from all frames
  2417.                          TempODPart ChildPart = ChildFrame->AcquirePart( ev );
  2418.                          su = ChildPart->GetStorageUnit(ev);
  2419.                          if(su->Exists(ev,kZOrderProp, kZOrder , 0)) {
  2420.                             su->Focus(ev,kZOrderProp , kODPosUndefined, kZOrder,
  2421.                                       0, kODPosUndefined);
  2422.                             su->Remove(ev);
  2423.                          }
  2424.                          ChildFrame = kODNULL;
  2425.                          if (CurrentFrameIter->IsNotComplete(ev)) {
  2426.                             ChildFrame = CurrentFrameIter->Next(ev);
  2427.                          }
  2428.                       } // end while
  2429.  
  2430.                       delete CurrentFrameIter;
  2431.                    }
  2432.                 }
  2433.                 handled = kODTrue; 
  2434.                 break;
  2435.  
  2436.        case VIEW_PROPERTIES:
  2437.                    {
  2438.                    TempODFrameFacetIterator facets = focusFrame->CreateFacetIterator(ev);
  2439.                    _fSession->GetInfo(ev)->ShowPartFrameInfo(ev,facets->First(ev), kODFalse);
  2440.                    handled = kODTrue;
  2441.                    }
  2442.                break;
  2443.  
  2444.        default:
  2445.           break;
  2446.     }
  2447.     } //end ifactive
  2448.  
  2449.     SOM_CATCH_ALL
  2450.     SOM_ENDTRY
  2451.  
  2452.     return handled;
  2453. }
  2454.  
  2455.  
  2456.  
  2457. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleMouseMove(ContainerPart *somSelf,
  2458.                                                            Environment *ev,
  2459.                                                           ODFacet* facet,
  2460.                                                           ODFrame* frame,
  2461.                                                           ODPoint* where,
  2462.                                                           ODEventData* event)
  2463. {
  2464.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2465.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseMove");
  2466.  
  2467.     ODBoolean handled = kODFalse;
  2468.  
  2469.     SOM_TRY
  2470.  
  2471.     RECTL rclBox;
  2472.  
  2473.     PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  2474.     switch (_fMouseMode)
  2475.     {
  2476.                                              // 128682 - faa - starts
  2477.        case kNormal:
  2478.           if ( _fPasteOn )
  2479.           {
  2480.              if ( somSelf->AllowPaste(ev, frame) )
  2481.              {
  2482.                 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
  2483.                 handled = kODTrue;
  2484.              }
  2485.              else
  2486.              {
  2487.                                         // been emptied in another docshell
  2488.                 handled   = kODFalse;
  2489.              }
  2490.           }
  2491.           break;
  2492.                                              // 128682 - faa - ends
  2493.        case kRotateSelectCenter:
  2494.        case kScaleSelectRefPoint:
  2495.           WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
  2496.           handled = kODTrue;
  2497.           break;
  2498.  
  2499.        case kTracking:
  2500.  
  2501.           if (_fTrackingFacet)
  2502.           {
  2503.             if (!SHORT1FROMMP(event->mp2))     // Mouse still captured?
  2504.             {
  2505.               TempODTransform xform = _fTrackingFacet->AcquireWindowFrameTransform(ev, _fTrackingFacet->GetCanvas(ev));
  2506.               ODPoint localPoint = *where;   // [137664]
  2507.               xform->InvertPoint(ev, &localPoint);      // window to frame coords
  2508.               somSelf->UpdateTrackRect(ev, &localPoint, _fTrackingFacet, kUpdateModeContinue);
  2509.               _ptEnd = localPoint;
  2510.             }
  2511.             else                            // mouse is no longer captured
  2512.             {
  2513.               somSelf->ResetMouseMode(ev);
  2514.             }
  2515.           }
  2516.           else if (facet->GetWindow(ev)->IsActive(ev) )
  2517.           {
  2518.              if (_fSelection->Count() >= 1)
  2519.              {
  2520.                 ODPoint mouse = *where;
  2521.                 TempODTransform xform = facet->AcquireWindowContentTransform(ev, facet->GetCanvas(ev));
  2522.                 ODRect bbox;
  2523.                 xform->InvertPoint(ev, &mouse); // [137664]
  2524.              }
  2525.           }
  2526.           break;
  2527.     }
  2528.     SOM_CATCH_ALL
  2529.     SOM_ENDTRY
  2530.  
  2531.     return handled;
  2532. }
  2533.  
  2534.  
  2535. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1MotionEnd(ContainerPart *somSelf,
  2536.                                                                  Environment *ev,
  2537.                                                                  ODFacet* facet,
  2538.                                                                  ODFrame* frame,
  2539.                                                                  ODPoint* where,
  2540.                                                                  ODEventData* event)
  2541. {
  2542.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2543.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1MotionEnd");
  2544.  
  2545.     SOM_TRY
  2546.  
  2547.     PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  2548.  
  2549.     if (_fMouseMode == kTracking &&
  2550.         (_fTrackingMode == kRubberBandSelection ||
  2551.          _fTrackingMode == kBotLeftResize       ||
  2552.          _fTrackingMode == kTopLeftResize       ||
  2553.          _fTrackingMode == kTopRightResize      ||
  2554.          _fTrackingMode == kBotRightResize))
  2555.     {
  2556.       /*
  2557.        * _fTrackingFacet is cleared in ResetMouseMode so save the pointer
  2558.        */
  2559.       ODFacet* trackingFacet = _fTrackingFacet;
  2560.  
  2561.       somSelf->ResetMouseMode(ev);
  2562.  
  2563.       TempODTransform xform = trackingFacet->AcquireWindowContentTransform(ev, kODNULL);
  2564.       ODPoint localPoint = *where;      // [137664]
  2565.       xform->InvertPoint(ev, &localPoint);      // window to content coords
  2566.  
  2567.       switch (_fTrackingMode)
  2568.       {
  2569.          case kRubberBandSelection:
  2570.          {
  2571.             somSelf->DoDeSelectAll(ev, _fSelectionFrame);
  2572.  
  2573.             /* select the embedded frames within the tracking rectangle */
  2574.  
  2575.             ODRect trackRect;
  2576.             trackRect.left   = min(_ptOrigin.x, localPoint.x);
  2577.             trackRect.bottom = min(_ptOrigin.y, localPoint.y);
  2578.             trackRect.right  = max(_ptOrigin.x, localPoint.x);
  2579.             trackRect.top    = max(_ptOrigin.y, localPoint.y);
  2580.  
  2581.             TempODShape trackShape = trackingFacet->GetFrame(ev)->CreateShape(ev);
  2582.             trackShape->SetRectangle(ev, &trackRect);
  2583.             TempODTransform contentXform = trackingFacet->AcquireContentTransform(ev, kODNULL);
  2584.             trackShape->Transform(ev, contentXform);
  2585.  
  2586.             /*
  2587.              * Iterate thru the embedded facets of the tracking facet and add
  2588.              * those embedded facets that are contained within the tracking
  2589.              * shape to the selection.
  2590.              */
  2591.  
  2592.             ODFacetIterator* facets = trackingFacet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  2593.             for (ODFacet* embFacet = facets->First(ev);
  2594.                   facets->IsNotComplete(ev);
  2595.                   embFacet = facets->Next(ev))
  2596.             {
  2597.                if (!embFacet) break;
  2598.  
  2599.                ODFrame* embFrame = embFacet->GetFrame(ev);
  2600.                //below 2 lines only used when selection is 1 embed
  2601.                ODReleaseObject( ev, pInfo->fSelectedPart);
  2602.                pInfo->fSelectedPart = embFrame->AcquirePart( ev);
  2603.                pInfo->fSelPartFrame = embFrame;
  2604.                TempODShape usedShape = ODCopyAndRelease(ev, embFrame->AcquireUsedShape(ev, kODNULL));
  2605.                TempODTransform xform = embFacet->AcquireFrameTransform(ev, kODNULL);
  2606.                usedShape->Transform(ev, xform);
  2607.  
  2608.                usedShape->Subtract(ev, trackShape);
  2609.                if (usedShape->IsEmpty(ev))
  2610.                {
  2611.                   somSelf->SetFrameSelected(ev, embFrame, kODTrue);
  2612.                   Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
  2613.                   _fSelection->AddFirst((ElementType)p);
  2614.                }
  2615.             }
  2616.  
  2617.             if (_fSelection->Count())
  2618.             {
  2619.                somSelf->CreateProxySelectionBorder(ev);
  2620.                somSelf->ClipSelectionFromEmbeddedFrames(ev, trackingFacet->GetFrame(ev));
  2621.                somSelf->InvalidateSelection(ev, trackingFacet->GetFrame(ev));
  2622.  
  2623.             }
  2624.             break;
  2625.           }
  2626.          case kBotLeftResize:
  2627.          case kTopLeftResize:
  2628.          case kTopRightResize:
  2629.          case kBotRightResize:
  2630.          {
  2631.             ODPoint ptNewEnd, ptSelMouse, ptOffset;
  2632.             ODRect bbox;
  2633.  
  2634.             ptNewEnd.x = localPoint.x - _ptMouseOffset.x;
  2635.             ptNewEnd.y = localPoint.y - _ptMouseOffset.y;
  2636.  
  2637.             Proxy* p = (Proxy*)_fSelection->First();
  2638.             p->shape->GetBoundingBox(ev, &bbox);
  2639.             ptSelMouse = ptNewEnd;    // [137664]
  2640.             p->transform->InvertPoint(ev, &ptSelMouse); // in selections frame coords
  2641.             switch (_fTrackingMode)
  2642.             {
  2643.                case kBotLeftResize:
  2644.                   if(ptSelMouse.x > bbox.right || ptSelMouse.y > bbox.top) return kODTrue;     // [124806]
  2645.                   bbox.right += (-ptSelMouse.x);
  2646.                   bbox.top   += (-ptSelMouse.y);
  2647.                   ptOffset = ptSelMouse;
  2648.                   break;
  2649.                case kTopLeftResize:
  2650.                   if(ptSelMouse.x > bbox.right || ptSelMouse.y < bbox.bottom) return kODTrue;  // [124806]
  2651.                   bbox.right += (-ptSelMouse.x);
  2652.                   bbox.top   = ptSelMouse.y;
  2653.                   ptOffset.x = ptSelMouse.x;
  2654.                   ptOffset.y = 0;
  2655.                   break;
  2656.                case kTopRightResize:
  2657.                   if(ptSelMouse.x < bbox.left || ptSelMouse.y < bbox.bottom) return kODTrue;   // [124806]
  2658.                   bbox.right = ptSelMouse.x;
  2659.                   bbox.top   = ptSelMouse.y;
  2660.                   ptOffset.x = ptOffset.y = 0;
  2661.                   break;
  2662.                case kBotRightResize:
  2663.                   if(ptSelMouse.x < bbox.left || ptSelMouse.y > bbox.top) return kODTrue;      // [124806]
  2664.                   bbox.right = ptSelMouse.x;
  2665.                   bbox.top   += (-ptSelMouse.y);
  2666.                   ptOffset.x = 0;
  2667.                   ptOffset.y = ptSelMouse.y;
  2668.                   break;
  2669.             }
  2670.             p->shape->SetRectangle(ev, &bbox);
  2671.             ODxOrderedCollectionIterator i(_fEmbeddedFrames);
  2672.             for (ODFrame* frame = (ODFrame*)i.First(); i.IsNotComplete(); frame = (ODFrame*)i.Next())
  2673.             {
  2674.                if (somSelf->ProxyForFrame(ev, frame) == p)
  2675.                {
  2676.                   frame->ChangeFrameShape(ev, p->shape, kODNULL);
  2677.                   if (ptOffset.x || ptOffset.y)
  2678.                   {
  2679.                      TempODTransform xform = frame->CreateTransform(ev);
  2680.                      xform->SetOffset(ev, &ptOffset);
  2681.                      p->transform->PreCompose(ev, xform);
  2682.                   }
  2683.                }
  2684.             }
  2685.             break;
  2686.          }
  2687.       }
  2688.       somSelf->CreateProxySelectionBorder(ev);
  2689.       somSelf->ClipEmbeddedFrames(ev, kODNULL);
  2690.       somSelf->Invalidate(ev);
  2691.  
  2692.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2693.     }
  2694.  
  2695.     SOM_CATCH_ALL
  2696.     SOM_ENDTRY
  2697.  
  2698.     return kODTrue;
  2699. }
  2700.  
  2701. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleButton1Up(ContainerPart *somSelf,
  2702.                                                           Environment *ev,
  2703.                                                           ODFacet* facet,
  2704.                                                           ODFrame* frame,
  2705.                                                           ODPoint* where,
  2706.                                                           ODEventData* event)
  2707. {
  2708.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2709.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Up");
  2710.  
  2711.     SOM_TRY
  2712.  
  2713.     if (_fMouseMode == kTracking &&
  2714.         (_fTrackingMode == kRotateSelection ||
  2715.          _fTrackingMode == kScaleSelection))
  2716.     {
  2717.       /*
  2718.        * _fTrackingFacet is cleared in ResetMouseMode so save the pointer
  2719.        */
  2720.       ODFacet* trackingFacet = _fTrackingFacet;
  2721.  
  2722.       somSelf->ResetMouseMode(ev);
  2723.  
  2724.       TempODTransform xform = trackingFacet->AcquireWindowContentTransform(ev, kODNULL);
  2725.       ODPoint localPoint = *where; // [137664]
  2726.       xform->InvertPoint(ev, &localPoint);      // window to content coords
  2727.  
  2728.       switch (_fTrackingMode)
  2729.       {
  2730.          case kScaleSelection:
  2731.          {
  2732.             ODPoint ptScale;
  2733.             ptScale.x = (localPoint.x - _ptRef.x) / ((_ptOrigin.x - _ptRef.x) >> 16);
  2734.             ptScale.y = (localPoint.y - _ptRef.y) / ((_ptOrigin.y - _ptRef.y) >> 16);
  2735.  
  2736.             TempODTransform xScale = frame->CreateTransform(ev);
  2737.             xScale->ScaleBy(ev,&ptScale);
  2738.  
  2739.  
  2740.             Proxy* p;
  2741.             ODxOrderedCollectionIterator iter(_fSelection);
  2742.             for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
  2743.             {
  2744.                ODPoint ptNegRef(-_ptRef.x,-_ptRef.y);
  2745.                p->transform->MoveBy(ev, &ptNegRef);
  2746.                p->transform->PostCompose(ev, xScale);
  2747.                p->transform->MoveBy(ev, &_ptRef);
  2748.             }
  2749.             break;
  2750.          }
  2751.          case kRotateSelection:
  2752.          {
  2753.             double theta;
  2754.             ODFixed fxSin, fxCos;
  2755.             ODMatrix m;
  2756.  
  2757.             theta = CalcAngleRadians(_ptRef, localPoint) -
  2758.                     CalcAngleRadians(_ptRef, _ptOrigin);
  2759.             fxSin = ODFloatToFixed(sin(theta));
  2760.             fxCos = ODFloatToFixed(cos(theta));
  2761.  
  2762.             TempODTransform rxform = trackingFacet->GetFrame(ev)->CreateTransform(ev);
  2763.             rxform->GetMatrix(ev, &m);
  2764.             m.m[0][0] = fxCos;
  2765.             m.m[0][1] = fxSin;
  2766.             m.m[1][0] = -fxSin;
  2767.             m.m[1][1] = fxCos;
  2768.             rxform->SetMatrix(ev, &m);
  2769.  
  2770.             Proxy* p;
  2771.             ODxOrderedCollectionIterator iter(_fSelection);
  2772.             for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
  2773.             {
  2774.                ODPoint ptNegRef(-_ptRef.x,-_ptRef.y);
  2775.                p->transform->MoveBy(ev, &ptNegRef);
  2776.                p->transform->PostCompose(ev, rxform);
  2777.                p->transform->MoveBy(ev, &_ptRef);
  2778.             }
  2779.             break;
  2780.          }
  2781.       }
  2782.       somSelf->CreateProxySelectionBorder(ev);
  2783.       somSelf->ClipEmbeddedFrames(ev, kODNULL);
  2784.       somSelf->Invalidate(ev);
  2785.  
  2786.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2787.     }
  2788.  
  2789.     SOM_CATCH_ALL
  2790.     SOM_ENDTRY
  2791.  
  2792.     return kODTrue;
  2793. }
  2794.  
  2795. SOM_Scope void  SOMLINK ContainerPartUpdateTrackRect(ContainerPart *somSelf,
  2796.                                                       Environment *ev,
  2797.                                                      ODPoint* ptMouse,
  2798.                                                      ODFacet* facet,
  2799.                                                      TrackingUpdateMode updateMode)
  2800. {
  2801.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  2802.     ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateTrackRect");
  2803.  
  2804.     SOM_TRY
  2805.  
  2806.     HPS hps;
  2807.  
  2808.     POINTL ptlOrigin      = _ptOrigin.AsPOINTL(),
  2809.            ptlEnd         = _ptEnd.AsPOINTL(),
  2810.            ptlMouse       = ptMouse->AsPOINTL(),
  2811.            ptlMouseOffset = _ptMouseOffset.AsPOINTL(),
  2812.            ptlRef         = _ptRef.AsPOINTL(),
  2813.            ptl;
  2814.     MATRIXLF mtx;
  2815.     int i;
  2816.  
  2817.     CFocusWindow f(ev, facet, (ODShape*)kODNULL, &hps, (HWND*)kODNULL, CFocusWindow::LockedWindowUpdatePS);
  2818.  
  2819.     GpiSetMix(hps, FM_INVERT);
  2820.  
  2821.     switch (_fTrackingMode)
  2822.     {
  2823.        case kBotLeftResize:
  2824.        case kTopLeftResize:
  2825.        case kTopRightResize:
  2826.        case kBotRightResize:
  2827.          {
  2828.             ODPoint pt, ptSelEnd, ptSelMouse, ptSelMouseOffset, ptSelOrigin, ptSelRef;
  2829.             FIXED afxScale[2];
  2830.             int i;
  2831.             Proxy* p = (Proxy*)_fSelection->First();
  2832.  
  2833.  
  2834.             /* Adjust end-points for mouse offset */
  2835.             ptSelEnd.x = _ptEnd.x - _ptMouseOffset.x;
  2836.             ptSelEnd.y = _ptEnd.y - _ptMouseOffset.y;
  2837.             ptSelOrigin.x = _ptOrigin.x - _ptMouseOffset.x;
  2838.             ptSelOrigin.y = _ptOrigin.y - _ptMouseOffset.y;
  2839.             ptSelMouse.x = ptMouse->x - _ptMouseOffset.x;
  2840.             ptSelMouse.y = ptMouse->y - _ptMouseOffset.y;
  2841.  
  2842.             /* convert end-points to selected frames local coords */
  2843.             p->transform->InvertPoint(ev, &ptSelEnd);       // [137664]
  2844.             p->transform->InvertPoint(ev, &ptSelMouse);     // [137664]
  2845.             p->transform->InvertPoint(ev, &ptSelOrigin);    // [137664]
  2846.             ptSelRef = _ptRef;                              // [137664]
  2847.             p->transform->InvertPoint(ev, &ptSelRef);       // [137664]
  2848.  
  2849.             POINTL ptlSelRef = ptSelRef.AsPOINTL();
  2850.  
  2851.             for (i = 0, pt = ptSelEnd; i < 2; i++, pt = ptSelMouse)
  2852.             {
  2853.                if (pt.x != ptSelOrigin.x && pt.y != ptSelOrigin.y)
  2854.                {
  2855.                   afxScale[0] = (pt.x - ptSelRef.x) /
  2856.                                 ((ptSelOrigin.x - ptSelRef.x) >> 16);
  2857.                   afxScale[1] = (pt.y - ptSelRef.y) /
  2858.                                 ((ptSelOrigin.y - ptSelRef.y) >> 16);
  2859.  
  2860.                   if (afxScale[0] <= 0 || afxScale[1] <= 0)
  2861.                      afxScale[0] = afxScale[1] = 0x10000;
  2862.  
  2863.                   p->transform->GetMATRIXLF(ev, &mtx);
  2864.                   GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
  2865.                   GpiScale(hps, &mtx, TRANSFORM_REPLACE, afxScale, &ptlSelRef);
  2866.                   GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_PREEMPT);
  2867.                   somSelf->DrawPolygons(ev, hps);
  2868.                }
  2869.             }
  2870.          }
  2871.          break;
  2872.  
  2873.        case kRubberBandSelection:
  2874.        case kSelectScaleOrigin:
  2875.  
  2876.           GpiSetLineType(hps, LINETYPE_SOLID);
  2877.           GpiMove(hps, &ptlOrigin);
  2878.           GpiBox(hps, DRO_OUTLINE, &ptlEnd, 0, 0);
  2879.           GpiMove(hps, &ptlOrigin);
  2880.           GpiBox(hps, DRO_OUTLINE, &ptlMouse, 0, 0);
  2881.           break;
  2882.  
  2883.        case kSelectRotateOrigin:
  2884.           GpiSetLineType(hps, LINETYPE_SOLID);
  2885.           if (updateMode == kUpdateModeStart || updateMode == kUpdateModeEnd)
  2886.           {
  2887.              ULONG ulHandleWidth = kSelectionHandleWidth >> 16;
  2888.              ptl.x = ptlOrigin.x - ulHandleWidth / 2;
  2889.              ptl.y = ptlOrigin.y - ulHandleWidth / 2;
  2890.              GpiMove(hps, &ptl);
  2891.              ptl.x += ulHandleWidth;
  2892.              ptl.y += ulHandleWidth;
  2893.              GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
  2894.           }
  2895.           for (i = 0, ptl = ptlEnd; i < 2; i++, ptl = ptlMouse)
  2896.           {
  2897.              double dx, dy, rad;
  2898.              FIXED fxAngle;
  2899.              ARCPARAMS arcparams;
  2900.  
  2901.              dx = (double)(ptl.x - ptlOrigin.x);
  2902.              dy = (double)(ptl.y - ptlOrigin.y);
  2903.              rad = sqrt(dx*dx + dy*dy);
  2904.              arcparams.lP = arcparams.lQ = rad;
  2905.              arcparams.lR = arcparams.lS = 0;
  2906.              GpiSetArcParams(hps, &arcparams);
  2907.              fxAngle = CalcAngleDegrees(ptlOrigin, ptl);
  2908.              GpiMove(hps, &ptlOrigin);
  2909.              GpiPartialArc(hps, &ptlOrigin, 0x10000, fxAngle, MAKEFIXED(360,0));
  2910.           }
  2911.           break;
  2912.  
  2913.        case kScaleSelection:
  2914.           for (i = 0, ptl = ptlEnd;
  2915.                i < ((updateMode == kUpdateModeContinue) ? 2 : 1);
  2916.                i++, ptl = ptlMouse)
  2917.           {
  2918.              FIXED afxScale[2];
  2919.              afxScale[0] = MAKEFIXED((ptl.x - ptlRef.x),0) / (ptlOrigin.x - ptlRef.x);
  2920.              afxScale[1] = MAKEFIXED((ptl.y - ptlRef.y),0) / (ptlOrigin.y - ptlRef.y);
  2921.              GpiScale(hps, &mtx, TRANSFORM_REPLACE, afxScale, &ptlRef);
  2922.              GpiMove(hps, &ptlRef);
  2923.              GpiSetLineWidth(hps, LINEWIDTH_NORMAL);
  2924.              GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
  2925.              GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
  2926.              somSelf->DrawPolygons(ev, hps);
  2927.              GpiSetModelTransformMatrix(hps, 9, &mtxIdentity, TRANSFORM_REPLACE);
  2928.           }
  2929.           break;
  2930.  
  2931.        case kRotateSelection:
  2932.        {
  2933.           ARCPARAMS arcparams;
  2934.           double dx, dy, rad, theta1, theta2;
  2935.  
  2936.           dx = ptlOrigin.x - ptlRef.x;
  2937.           dy = ptlOrigin.y - ptlRef.y;
  2938.           rad = sqrt(dx*dx + dy*dy);
  2939.           arcparams.lP = arcparams.lQ = rad;
  2940.           arcparams.lR = arcparams.lS = 0;
  2941.           GpiSetArcParams(hps, &arcparams);
  2942.  
  2943.           if (updateMode == kUpdateModeStart || updateMode == kUpdateModeEnd)
  2944.           {
  2945.              ULONG ulHandleWidth = kSelectionHandleWidth >> 16;
  2946.              GpiSetLineType(hps, LINETYPE_SOLID);
  2947.              for (i = 0, ptl = ptlRef; i < 2; i++, ptl = ptlOrigin)
  2948.              {
  2949.                 POINTL ptlCorner;
  2950.                 ptlCorner.x = ptl.x - ulHandleWidth / 2;
  2951.                 ptlCorner.y = ptl.y - ulHandleWidth / 2;
  2952.                 GpiMove(hps, &ptlCorner);
  2953.                 ptlCorner.x += ulHandleWidth;
  2954.                 ptlCorner.y += ulHandleWidth;
  2955.                 GpiBox(hps, DRO_OUTLINE, &ptlCorner, 0, 0);
  2956.              }
  2957.              GpiSetLineType(hps, LINETYPE_DASHDOT);
  2958.              GpiMove(hps, &ptlRef);
  2959.              GpiFullArc(hps, DRO_OUTLINE, 0x10000);
  2960.              GpiMove(hps, &ptlRef);
  2961.              GpiLine(hps, &ptlOrigin);
  2962.           }
  2963.           for (i = 0, ptl = ptlEnd;
  2964.                i < ((updateMode == kUpdateModeContinue) ? 2 : 1);
  2965.                i++, ptl = ptlMouse)
  2966.           {
  2967.              FIXED fxAngle;
  2968.              POINTL ptlCurrentPos;
  2969.  
  2970.              fxAngle = CalcAngleDegrees(ptlRef, ptl);
  2971.              GpiMove(hps, &ptlRef);
  2972.              GpiSetLineType(hps, LINETYPE_INVISIBLE);
  2973.              GpiPartialArc(hps, &ptlRef, 0x10000, fxAngle, 0);
  2974.              GpiQueryCurrentPosition(hps, &ptlCurrentPos);
  2975.              if (ptlCurrentPos.x != ptlOrigin.x || ptlCurrentPos.y != ptlOrigin.y)
  2976.              {
  2977.                 GpiSetLineType(hps, LINETYPE_DASHDOT);
  2978.                 GpiSetLineWidth(hps, LINEWIDTH_NORMAL);
  2979.                 GpiLine(hps, &ptlRef);
  2980.              }
  2981.              fxAngle = CalcAngleDegrees(ptlRef, ptl) - CalcAngleDegrees(ptlRef, ptlOrigin);
  2982.              GpiRotate(hps, &mtx, TRANSFORM_REPLACE, fxAngle, &ptlRef);
  2983.              GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
  2984.              somSelf->DrawPolygons(ev, hps);
  2985.              GpiSetModelTransformMatrix(hps, 9, &mtxIdentity, TRANSFORM_REPLACE);
  2986.           }
  2987.           break;
  2988.        }
  2989.     }
  2990.  
  2991.     SOM_CATCH_ALL
  2992.     SOM_ENDTRY
  2993. }
  2994.  
  2995. SOM_Scope void  SOMLINK ContainerPartDrawPolygons(ContainerPart *somSelf,
  2996.                                                   Environment *ev,
  2997.                                                   HPS hps)
  2998. {
  2999.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3000.     ContainerPartMethodDebug("ContainerPart","ContainerPartDrawPolygons");
  3001.  
  3002.     GpiSetLineWidth(hps, LINEWIDTH_THICK);
  3003.     GpiSetLineType(hps, LINETYPE_SOLID);
  3004.     for (int i=0; i<_fNumPolygons; i++)
  3005.     {
  3006.        GpiMove(hps, &_fPolygons[i].aPointl[_fPolygons[i].ulPoints-1]);
  3007.        GpiPolyLine(hps, _fPolygons[i].ulPoints, &_fPolygons[i].aPointl[0]);
  3008.     }
  3009. }
  3010.  
  3011.  
  3012. SOM_Scope void  SOMLINK ContainerPartMouseFocusLost(ContainerPart *somSelf,
  3013.                                                      Environment *ev,
  3014.                                                     ODFrame* ownerFrame)
  3015. {
  3016.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3017.     ContainerPartMethodDebug("ContainerPart","ContainerPartMouseFocusLost");
  3018.  
  3019.     SOM_TRY
  3020.  
  3021.     if (_fMouseMode == kTracking)
  3022.     {
  3023.        TempODWindow window = ownerFrame->AcquireWindow(ev);
  3024.        HWND hwndFrame = window->GetPlatformWindow(ev);
  3025.        somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeEnd);
  3026.        _fTrackingFacet = kODNULL;
  3027.        _fMouseMode = kNormal;
  3028.        WinSetCapture(HWND_DESKTOP, 0);
  3029.        WinLockWindowUpdate(HWND_DESKTOP, 0);
  3030.     }
  3031.  
  3032.     if (_fPolygons)
  3033.     {
  3034.        for (int i = 0; i < _fNumPolygons; i++)
  3035.           delete[] _fPolygons[i].aPointl;
  3036.        delete[] _fPolygons;
  3037.        _fPolygons = kODNULL;
  3038.     }
  3039.  
  3040.     SOM_CATCH_ALL
  3041.     SOM_ENDTRY
  3042. }
  3043.  
  3044. SOM_Scope ODBoolean  SOMLINK ContainerPartHandlePrinting(ContainerPart *somSelf,
  3045.                                                           Environment *ev,
  3046.                                                          ODFrame* frame,
  3047.                                                          char *pszQueueName)
  3048. {
  3049.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3050.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandlePrinting");
  3051.  
  3052.     PHCINFO         phcInfo = 0, phc = 0;
  3053.     PPRQINFO3       pqi = 0;
  3054.     char            *pszTitle = 0;
  3055.  
  3056.     SOM_TRY
  3057.  
  3058.     ULONG           ul, cReturned, cTotal, cbNeeded, cForms;
  3059.     DEVOPENSTRUC    dos;
  3060.     LONG            i, rc;
  3061.     BOOL            fResult, bOK;
  3062.     CHAR            szWork[LEN_WORKSTRING], *pch, achQueueName[QUEUENAME_LENGTH], achDriverName[DRIVERNAME_LENGTH],
  3063.                     achSpoolerParams[40], achQueueProcParams[8];
  3064.     HWND            hwndFrame = 0;
  3065.     HAB             hab = WinQueryAnchorBlock(HWND_DESKTOP);
  3066.     HDC             hdcPrinter, hdcPrinterInfo;
  3067.     HPS             hpsPrinter, hpsPrinterInfo;
  3068.     SIZEL           sizel;
  3069.     PRNINFO         prnInfo;
  3070.     ODRect          bounds;
  3071.  
  3072.    TempODWindow window = frame->AcquireWindow(ev);
  3073.    if (window)
  3074.       hwndFrame = window->GetPlatformWindow(ev);
  3075.  
  3076.    ODDocumentName title = somSelf->GetStorageUnit(ev)->GetDraft(ev)   //[144299]
  3077.                                  ->GetDocument(ev)->GetContainer(ev)->GetName(ev);
  3078.    if (title.text._length)
  3079.    {
  3080.       pszTitle = (char*)malloc(title.text._length + 1);
  3081.       pszTitle = GetITextCString((ODIText *)&title, pszTitle);        //[144299]
  3082.    }
  3083.    else
  3084.       pszTitle = strdup("Untitled");
  3085.  
  3086.    /*
  3087.     * Get system default queue
  3088.     */
  3089.  
  3090.    if (pszQueueName)
  3091.       strncpy(achQueueName, pszQueueName, sizeof(achQueueName)-1);
  3092.    else {
  3093.       ul = PrfQueryProfileString (HINI_PROFILE, "PM_SPOOLER", "QUEUE", NULL, szWork, LEN_WORKSTRING);
  3094.       if (ul) {
  3095.          /* truncate queuename at terminating semicolon */
  3096.          pch = strchr (szWork, ';');
  3097.          if (pch) {
  3098.             *pch = 0;
  3099.             strcpy( achQueueName, szWork  );
  3100.          }
  3101.       }
  3102.       if (!achQueueName[0]) {
  3103.          WinMessageBox( HWND_DESKTOP,
  3104.                         hwndFrame ? hwndFrame : HWND_DESKTOP,
  3105.                         "Error: No Default Print Queue",
  3106.                         pszTitle,
  3107.                         (USHORT)0,
  3108.                         MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);
  3109.  
  3110.          free(pszTitle);
  3111.          return kODFalse;
  3112.       }
  3113.    }
  3114.    /* get queue settings including the driver data info */
  3115.    SplQueryQueue("", achQueueName, 3, NULL, 0, &cbNeeded);
  3116.    pqi = (PPRQINFO3)malloc(cbNeeded);
  3117.    rc = SplQueryQueue("", achQueueName, 3, pqi, cbNeeded, &cbNeeded);
  3118.  
  3119.    if (rc != 0) {
  3120.       sprintf(szWork, "Error opening printer queue: %s", achQueueName);
  3121.       WinMessageBox( HWND_DESKTOP,
  3122.                      hwndFrame ? hwndFrame : HWND_DESKTOP,
  3123.                      szWork,
  3124.                      pszTitle,
  3125.                      (USHORT)0,
  3126.                      MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);
  3127.  
  3128.       free(pszTitle);
  3129.       free(pqi);
  3130.       return kODFalse;
  3131.    }
  3132.  
  3133.  
  3134.    /* Open an info device context and presentation space for the printer */
  3135.  
  3136.    memset( &dos,   0, sizeof(dos));
  3137.    memset( &sizel, 0, sizeof(sizel));
  3138.  
  3139.    dos.pszLogAddress = achQueueName;
  3140.    strcpy( achDriverName, pqi->pszDriverName);
  3141.    achDriverName[strcspn(achDriverName, ".")] = '\0';
  3142.    dos.pszDriverName = (PSZ)achDriverName;
  3143.    dos.pdriv = pqi->pDriverData;
  3144.  
  3145.    /* Create an OD_QUEUED device context and presentation space for the printer */
  3146.    hdcPrinterInfo = DevOpenDC(hab, OD_INFO, "*", 3, (PDEVOPENDATA)&dos, 0);
  3147.    hpsPrinterInfo = GpiCreatePS(hab, hdcPrinterInfo, (PSIZEL)&sizel,  PU_PELS | GPIA_ASSOC);
  3148.  
  3149.    /* Query available forms and use the currently selected form */
  3150.  
  3151.    cForms = DevQueryHardcopyCaps( hdcPrinterInfo, 0, 0, 0);
  3152.    phcInfo = (PHCINFO)malloc(sizeof(HCINFO) * cForms);
  3153.    DevQueryHardcopyCaps( hdcPrinterInfo, 0, cForms, phcInfo);
  3154.  
  3155.    /* Find the first currently selected form */
  3156.  
  3157.    for (i=0; i< cForms; i++)
  3158.       if (phcInfo[i].flAttributes & HCAPS_CURRENT) break;
  3159.  
  3160.    phc = &phcInfo[i];
  3161.  
  3162.    GpiAssociate(hpsPrinterInfo, 0);
  3163.    GpiDestroyPS(hpsPrinterInfo);
  3164.    DevCloseDC(hdcPrinterInfo);
  3165.  
  3166.    /* determine the bounds of the root facet in OD coords */
  3167.  
  3168.    bounds.left = bounds.bottom = 0;
  3169.    bounds.right  = ulmm2fxPt(phc->xRightClip - phc->xLeftClip);
  3170.    bounds.top    = ulmm2fxPt(phc->yTopClip - phc->yBottomClip);
  3171.  
  3172.    /* Build the device context data for DevOpenDC */
  3173.    sprintf(achQueueProcParams, "COP=%d", 1);
  3174.    sprintf(achSpoolerParams, "FORM=%s", phc->szFormname);
  3175.  
  3176.    memset( &dos,   0, sizeof(dos));
  3177.    dos.pszLogAddress = achQueueName;
  3178.    strcpy( achDriverName, pqi->pszDriverName);
  3179.    achDriverName[strcspn(achDriverName, ".")] = '\0';
  3180.    dos.pszDriverName = (PSZ)achDriverName;
  3181.    dos.pdriv = pqi->pDriverData;
  3182.    dos.pszDataType = "PM_Q_STD";
  3183.    dos.pszComment = pszTitle;
  3184.    dos.pszQueueProcParams = achQueueProcParams;
  3185.    dos.pszSpoolerParams = achSpoolerParams;
  3186.  
  3187.    hdcPrinter = DevOpenDC(  hab, OD_QUEUED, "*", 9, (PDEVOPENDATA)&dos, 0);
  3188.    hpsPrinter = GpiCreatePS( hab, hdcPrinter, &sizel, PU_PELS | GPIA_ASSOC);
  3189.  
  3190.    DevEscape(hdcPrinter, DEVESC_STARTDOC, strlen(pszTitle), pszTitle, 0, 0);
  3191.  
  3192.    prnInfo.hps = hpsPrinter;
  3193.    prnInfo.hdc = hdcPrinter;
  3194.    prnInfo.phcInfo = phc;
  3195.    prnInfo.bounds = bounds;
  3196.  
  3197.    prnInfo.printDest.cb = sizeof(PRINTDEST);
  3198.    prnInfo.printDest.lType = OD_QUEUED;
  3199.    prnInfo.printDest.pszToken = "*";
  3200.    prnInfo.printDest.pdopData = (PDEVOPENDATA)&dos;
  3201.    prnInfo.printDest.fl = 0;
  3202.    prnInfo.printDest.pszPrinter = pqi->pszPrinters;
  3203.  
  3204.    somSelf->PrintPages(ev, frame, &prnInfo);
  3205.  
  3206.    DevEscape( hdcPrinter, DEVESC_ENDDOC, 0, 0, 0, 0);
  3207.    GpiAssociate(hpsPrinter, 0);
  3208.    GpiDestroyPS(hpsPrinter);
  3209.  
  3210.    DevCloseDC(hdcPrinter);
  3211.  
  3212.    /* free the buffer allocated for SplEnumQueue call */
  3213.    free(phcInfo);
  3214.    free(pqi);
  3215.    free(pszTitle);
  3216.  
  3217.    SOM_CATCH_ALL
  3218.       if (phcInfo)  free(phcInfo);
  3219.       if (pqi)      free(pqi);
  3220.       if (pszTitle) free(pszTitle);
  3221.    SOM_ENDTRY
  3222.  
  3223.    return kODTrue;
  3224. }
  3225.  
  3226. SOM_Scope ODFacet*  SOMLINK ContainerPartBeginPrinting(ContainerPart *somSelf,
  3227.                                                         Environment *ev,
  3228.                                                        ODFrame* prFrame,
  3229.                                                        PRNINFO* pPI)
  3230. {
  3231.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3232.     ContainerPartMethodDebug("ContainerPart","ContainerPartBeginPrinting");
  3233.  
  3234.     ODFacet* prFacet = kODNULL;
  3235.  
  3236.     SOM_TRY
  3237.  
  3238.     TempODTransform xtransform = prFrame->CreateTransform(ev);
  3239.     TempODShape clipshape = prFrame->CreateShape(ev);
  3240.     clipshape->SetRectangle(ev, &pPI->bounds);
  3241.  
  3242.     prFacet = _fSession->GetWindowState(ev)->
  3243.       CreateFacet(ev, prFrame, clipshape, xtransform, kODNULL, kODNULL);
  3244.  
  3245.     ODPlatformCanvas* platformCanvas = prFacet->CreatePlatformCanvas(ev, pPI->hps);
  3246.     ODCanvas* prCanvas = prFacet->CreateCanvas(ev, kODGPI,
  3247.                       platformCanvas, kODFalse, kODFalse);
  3248.  
  3249.     prCanvas->SetPlatformPrintJob(ev, kODGPI, &pPI->printDest);
  3250.     prFacet->ChangeCanvas(ev, prCanvas);
  3251.  
  3252.     prFrame->FacetAdded(ev, prFacet);
  3253.  
  3254.     SOM_CATCH_ALL
  3255.        prFacet = kODNULL;
  3256.     SOM_ENDTRY
  3257.  
  3258.     return prFacet;
  3259. }
  3260.  
  3261. SOM_Scope void  SOMLINK ContainerPartPrintPage(ContainerPart *somSelf,
  3262.                                                 Environment *ev,
  3263.                                                ODFacet* prFacet,
  3264.                                                ODUShort pagenum,
  3265.                                                PRNINFO* pPI)
  3266. {
  3267.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3268.     ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPage");
  3269.  
  3270.     SOM_TRY
  3271.  
  3272.     ODRect bbox;
  3273.  
  3274.     TempODShape frameShape = prFacet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
  3275.     frameShape->GetBoundingBox(ev, &bbox);
  3276.  
  3277.     ODULong height = bbox.top;
  3278.     ODULong width  = bbox.right;
  3279.  
  3280.     ODPoint    scale(0,0);
  3281.     ODPoint    offset(0,0);
  3282.     ODUShort   locator = pagenum-1;
  3283.  
  3284.     /**************************************************************************/
  3285.     /* Calculate scaling factor for extenal transform of root facet.  Scale   */
  3286.     /* calcualted using the following formula (for the x factor):             */
  3287.     /*                                                                        */
  3288.     /*                (pel)              xPels         (pel)   25.4 (mm/inch) */
  3289.     /* scaling factor ----- = ------------------------ ----- * ---- --------- */
  3290.     /*                (pt)    (xRightClip - xLeftClip) (mm)    72.0 (pt/inch) */
  3291.     /*                                                                        */
  3292.     /**************************************************************************/
  3293.     scale.x = (ODCoordinate)((float)pPI->phcInfo->xPels
  3294.                              / (float)(pPI->phcInfo->xRightClip -
  3295.                                        pPI->phcInfo->xLeftClip)
  3296.                              * 25.4 / 72.0 * 65536.0);
  3297.  
  3298.     scale.y = (ODCoordinate)((float)pPI->phcInfo->yPels
  3299.                              / (float)(pPI->phcInfo->yTopClip -
  3300.                                        pPI->phcInfo->yBottomClip)
  3301.                              * 25.4 / 72.0 * 65536.0);
  3302.  
  3303.     while (locator) {
  3304.       offset.y += (pPI->bounds.top);
  3305.       locator--;
  3306.       if (PtInRect(offset,bbox))
  3307.         continue;
  3308.       else {
  3309.         offset.y = 0;
  3310.         offset.x += (pPI->bounds.right + 1);
  3311.       }
  3312.     }
  3313.     offset.y = bbox.top - offset.y - pPI->bounds.top;
  3314.  
  3315.     TempODTransform xtransform = prFacet->CreateTransform(ev);
  3316.     TempODShape clipshape = prFacet->CreateShape(ev);
  3317.  
  3318.     clipshape->SetRectangle(ev, &pPI->bounds);
  3319.  
  3320.     xtransform->SetOffset(ev, &offset);
  3321.     clipshape->Transform(ev, xtransform);
  3322.     clipshape->Intersect(ev, frameShape);
  3323.     TempODShape invalshape = clipshape->Copy(ev);
  3324.  
  3325.     xtransform->Invert(ev);
  3326.     xtransform->ScaleBy(ev, &scale);
  3327.     prFacet->ChangeGeometry(ev, clipshape, xtransform, kODNULL);
  3328.  
  3329.     prFacet->Update(ev, invalshape, kODNULL);
  3330.  
  3331.     SOM_CATCH_ALL
  3332.     SOM_ENDTRY
  3333. }
  3334.  
  3335. SOM_Scope long  SOMLINK ContainerPartPrintPages(ContainerPart *somSelf,
  3336.                                                  Environment *ev,
  3337.                                                 ODFrame* frame,
  3338.                                                 PRNINFO* pPI)
  3339. {
  3340.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3341.     ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPages");
  3342.  
  3343.     SOM_TRY
  3344.  
  3345.     ODUShort
  3346.              firstPage,
  3347.              lastPage,
  3348.              realNumberOfPagesinDoc,
  3349.              pageNumber;
  3350.     ODFacet*   prFacet;
  3351.     ODFrame* prFrame;
  3352.     ODBoolean shouldCloseFrame;
  3353.  
  3354.     realNumberOfPagesinDoc = DetermineNumberOfPagesinDoc(ev, frame, pPI->bounds );
  3355.  
  3356.     //numberOfCopies = 1;
  3357.  
  3358.     firstPage = 1;
  3359.     lastPage = realNumberOfPagesinDoc;
  3360.  
  3361.     if (realNumberOfPagesinDoc < lastPage)
  3362.        lastPage = realNumberOfPagesinDoc;
  3363.  
  3364.     TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
  3365.     ODFacet* facet = facets->First(ev);
  3366.  
  3367.     if (facet)      // If this frame already has a facet, create another frame for printing
  3368.     {               // to allow formatting for printer without affecting on-screen display  [142798] - ced
  3369.        TempODShape frameShape = ODCopyAndRelease(ev, frame->AcquireFrameShape( ev, kODNULL )); // [121801]
  3370.        prFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->                 // [139790]
  3371.                    CreateFrame(ev,
  3372.                                kODNonPersistentFrameObject,
  3373.                                kODNULL,
  3374.                                frameShape,
  3375.                                kODNULL,
  3376.                                _fPartWrapper,
  3377.                                frame->GetViewType(ev),
  3378.                                frame->GetPresentation(ev),
  3379.                                kODTrue,
  3380.                                kODFalse);
  3381.  
  3382.        TempODPart tempPart = prFrame->AcquirePart(ev);
  3383.        tempPart->AttachSourceFrame(ev, prFrame, frame);
  3384.        shouldCloseFrame = kODTrue;
  3385.     }
  3386.     else
  3387.     {
  3388.        prFrame = frame;
  3389.        shouldCloseFrame = kODFalse;
  3390.     }
  3391.  
  3392.     prFacet = somSelf->BeginPrinting(ev, prFrame, pPI);
  3393.  
  3394.     pageNumber = firstPage;
  3395.     while (pageNumber <= lastPage /*&& PrError() == noErr*/)
  3396.     {
  3397.        LONG lOut=0;
  3398.        LONG rc = 0;
  3399.        somSelf->PrintPage(ev, prFacet, pageNumber, pPI);
  3400.        if (pageNumber != lastPage) // [145808]
  3401.        {
  3402.          DevEscape( pPI->hdc, DEVESC_NEWFRAME, 0, 0, 0, 0 );
  3403.        }
  3404.        pageNumber++;
  3405.     }
  3406.  
  3407.     somSelf->EndPrinting(ev, prFacet);
  3408.  
  3409.     if (shouldCloseFrame)
  3410.        prFrame->Close(ev);
  3411.  
  3412.     SOM_CATCH_ALL
  3413.     SOM_ENDTRY
  3414.  
  3415.     return 0; // no error
  3416. }
  3417.  
  3418. SOM_Scope void  SOMLINK ContainerPartEndPrinting(ContainerPart *somSelf,
  3419.                                                   Environment *ev,
  3420.                                                  ODFacet* prFacet)
  3421. {
  3422.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3423.     ContainerPartMethodDebug("ContainerPart","ContainerPartEndPrinting");
  3424.  
  3425.     SOM_TRY
  3426.  
  3427.     ODCanvas* prCanvas = prFacet->GetCanvas(ev);
  3428.     ODFrame*  prFrame =  prFacet->GetFrame(ev);
  3429.  
  3430.     prFrame->FacetRemoved(ev, prFacet);
  3431.     delete prCanvas;
  3432.     delete prFacet;
  3433.  
  3434.     SOM_CATCH_ALL
  3435.     SOM_ENDTRY
  3436. }
  3437.  
  3438. ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, ODRect page)
  3439. {
  3440.   ODRect bbox;
  3441.  
  3442.   ODShape* frameShape = frame->AcquireFrameShape(ev, kODNULL);
  3443.   frameShape->GetBoundingBox(ev, &bbox);
  3444.   frameShape->Release(ev); frameShape = kODNULL;
  3445.  
  3446.   ODSLong height = bbox.top-bbox.bottom;
  3447.   ODSLong width  = bbox.right-bbox.left;
  3448.  
  3449.   ODUShort pages = 0;
  3450.  
  3451.   ODSLong wt = width;
  3452.  
  3453.   while (wt > 0)
  3454.   {
  3455.     ODSLong ht = height;
  3456.     while (ht > 0)
  3457.     {
  3458.       ht -= (page.top-page.bottom);
  3459.       pages++;
  3460.     }
  3461.  
  3462.     wt -= (page.right-page.left);
  3463.   }
  3464.  
  3465.   return pages;
  3466. }
  3467.  
  3468. SOM_Scope ODBoolean  SOMLINK ContainerPartDoCut(ContainerPart *somSelf,
  3469.                                                  Environment *ev,
  3470.                                                 ODFrame* frame)
  3471. {
  3472.    ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3473.    ContainerPartMethodDebug("ContainerPart","ContainerPartDoCut");
  3474.  
  3475.    ODBoolean result = kODFalse;
  3476.  
  3477.    SOM_TRY
  3478.  
  3479.     result = somSelf->CloneSelectionToClipboard( ev, frame, kODCloneCut );
  3480.     if (result) 
  3481.        somSelf->DoClear( ev, frame);
  3482.  
  3483.    SOM_CATCH_ALL
  3484.    SOM_ENDTRY
  3485.  
  3486.    return kODTrue;
  3487. }
  3488.  
  3489.  
  3490. SOM_Scope ODBoolean  SOMLINK ContainerPartDoCopy(ContainerPart *somSelf,
  3491.                                                  Environment *ev,
  3492.                                                  ODFrame* frame)
  3493. {
  3494.    ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3495.    ContainerPartMethodDebug("ContainerPart","ContainerPartDoCopy");
  3496.  
  3497.    ODBoolean result = kODFalse;
  3498.  
  3499.    SOM_TRY
  3500.  
  3501.      result = somSelf->CloneSelectionToClipboard( ev, frame, kODCloneCopy );
  3502.  
  3503.    SOM_CATCH_ALL
  3504.    SOM_ENDTRY
  3505.  
  3506.    return result;
  3507. }
  3508.  
  3509. SOM_Scope ODBoolean  SOMLINK ContainerPartCloneSelectionToClipboard(ContainerPart *somSelf,
  3510.                                                                    Environment *ev,
  3511.                                                                    ODFrame* ownerFrame,
  3512.                                                                    ODCloneKind cloneKind)
  3513. {                                                     
  3514.    ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3515.    ContainerPartMethodDebug("ContainerPart","ContainerPartCloneSelectionToClipboard");
  3516.  
  3517.    ODBoolean      result = kODTrue;
  3518.  
  3519.    SOM_TRY
  3520.  
  3521.    ODFrame*   embFrame;                     // contains embedded frames
  3522.    ODClipboard*   clipboard  = _fSession->GetClipboard(ev);
  3523.    ODArbitrator *arbitrator   = _fSession->GetArbitrator( ev );
  3524.    ODTypeToken clipboardFocus = _fSession->Tokenize( ev, kODClipboardFocus );
  3525.    if (arbitrator->RequestFocus( ev, clipboardFocus, ownerFrame )) 
  3526.    {
  3527.       
  3528.       // Container part currently supports copying only a single selected 
  3529.       // frame to the clipboard.  For multiple selection, we should create 
  3530.       // a root frame of our part kind with our selection embedded in it
  3531.       // and put that frame on the clipboard.  For now, we only enable Copy
  3532.       // and Cut for single selection.
  3533.       
  3534.       clipboard->Clear( ev );
  3535.       
  3536.       // Find selected frame
  3537.       ODFrame* embFrame = somSelf->FrameFromProxyForContainingFrame(ev, 
  3538.                                   (Proxy*)_fSelection->First(), ownerFrame);
  3539.                                       // gets root su for clipboard
  3540.       if (embFrame)
  3541.       {
  3542.          ODStorageUnit* clipRootSU = clipboard->GetContentStorageUnit(ev);
  3543.          
  3544.          ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  3545.          ODDraft* toDraft   = clipRootSU->GetDraft(ev);
  3546.          
  3547.          ODDraftKey key  = 0;
  3548.          
  3549.                 // modify clipboard
  3550.          key = fromDraft->BeginClone(ev, toDraft, kODNULL, cloneKind);
  3551.          
  3552.                 // when transfering frame, add content frame property
  3553.          clipRootSU->AddProperty(ev, kODPropContentFrame);
  3554.          
  3555.          TempODPart selectedPart = embFrame->AcquirePart(ev);
  3556.          selectedPart->CloneInto( ev, key, clipRootSU, embFrame);
  3557.          
  3558.          clipRootSU->AddProperty(ev, kODPropFrameShape);
  3559.          
  3560.          TempODShape tempShape = embFrame->AcquireFrameShape( ev, kODNULL);
  3561.          tempShape->WriteShape(ev, clipRootSU);
  3562.          
  3563.          fromDraft->EndClone(ev, key);
  3564.          key = kODNULL;
  3565.       }
  3566.       clipboard->ExportClipboard( ev);
  3567.       arbitrator->RelinquishFocus( ev, clipboardFocus, ownerFrame );
  3568.       
  3569.       somSelf->DisplayStatusLineText(ev,"To Paste, activate frame, then select Paste from Menu Bar", ownerFrame);
  3570.    }
  3571.    SOM_CATCH_ALL
  3572.    SOM_ENDTRY
  3573.  
  3574.    return result;
  3575.  
  3576. }
  3577.  
  3578. SOM_Scope ODBoolean  SOMLINK ContainerPartAllowPaste(ContainerPart *somSelf,
  3579.                                                      Environment *ev,
  3580.                                                      ODFrame* frame)
  3581. {
  3582.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3583.     ContainerPartMethodDebug("ContainerPart","ContainerPartAllowPaste");
  3584.  
  3585.     ODBoolean result = kODFalse;
  3586.  
  3587.     SOM_TRY
  3588.  
  3589. // [140007] :
  3590.     ODClipboard*   clipboard = _fSession->GetClipboard(ev);
  3591.     result = clipboard->CanEmbed(ev);
  3592.  
  3593.     SOM_CATCH_ALL
  3594.     SOM_ENDTRY
  3595.  
  3596.     return result;
  3597. }
  3598.  
  3599.  
  3600. SOM_Scope void  SOMLINK ContainerPartPasteFrameFromClipboard(ContainerPart *somSelf,
  3601.                                                              Environment *ev,
  3602.                                                              ODFacet* facet,
  3603.                                                              ODPoint* where)
  3604. {
  3605.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3606.     ContainerPartMethodDebug("ContainerPart","ContainerPartPasteFrameFromClipboard");
  3607.  
  3608.     SOM_TRY
  3609.  
  3610.     ODTransform   *newExternalXForm;
  3611.  
  3612.     ODFrame *frame = facet->GetFrame(ev);
  3613.  
  3614.     ODFrame *newFrame  = kODNULL;
  3615.     ODShape *newFrameShape;
  3616.     ODFrame *newFrame2 = kODNULL;
  3617.  
  3618.     _fMouseMode = kNormal;
  3619.     somSelf->FreezeEmbeddedFrames(ev, kODFalse);
  3620.  
  3621.     _fPasteOn      = kODFalse;
  3622.     _fPasteESC     = kODFalse;
  3623.  
  3624.     ODTransform *contentXform = facet->AcquireWindowContentTransform(ev,
  3625.                                                       facet->GetCanvas(ev));
  3626.     ODPoint pastePoint = *where;     // [137664]
  3627.     contentXform->InvertPoint(ev, &pastePoint);
  3628.     ODReleaseObject(ev, contentXform);
  3629.  
  3630.     ODArbitrator *arbitrator   = _fSession->GetArbitrator( ev );
  3631.     ODTypeToken clipboardFocus = _fSession->Tokenize( ev, kODClipboardFocus );
  3632.     arbitrator->RequestFocus( ev, clipboardFocus, frame );
  3633.  
  3634.     ODClipboard*   clipboard  = _fSession->GetClipboard(ev);
  3635.  
  3636.     ODDraft*       theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  3637.     ODDraft*       fromDraft = kODNULL;
  3638.     ODDraftKey     key = kODNULL;
  3639.  
  3640.     TRY
  3641.        ODStorageUnit* su = clipboard->GetContentStorageUnit(ev);
  3642.        fromDraft = su->GetDraft( ev );
  3643.  
  3644.        ODID newPartID;
  3645.  
  3646.        key = fromDraft->BeginClone(ev, theDraft, kODNULL, kODClonePaste);
  3647.  
  3648.        newPartID = fromDraft->Clone(ev, key, su->GetID(ev), 0, 0);
  3649.        fromDraft->EndClone(ev, key);
  3650.        key = kODNULL;
  3651.  
  3652.        //  using temp variable because memory gets freed
  3653.        //  when we go out of scope
  3654.  
  3655.        ODPoint  newTransPt = *where;
  3656.        newTransPt.x = pastePoint.x;
  3657.        newTransPt.y = pastePoint.y;
  3658.  
  3659.        // xtransform
  3660.  
  3661.        newExternalXForm = new ODTransform;
  3662.        newExternalXForm->MoveBy(ev,  &newTransPt );
  3663.  
  3664.        if (su->Exists(ev, kODPropFrameShape, kODNULL, 0))
  3665.        {
  3666.           su->Focus(ev, kODPropFrameShape, kODPosUndefined, kODNULL, 1,
  3667.              kODPosUndefined);
  3668.           newFrameShape = facet->CreateShape(ev);
  3669.           newFrameShape->ReadShape(ev, su);
  3670.        }
  3671.        else
  3672.        {
  3673.           newFrameShape = kODNULL;     // use default size {80,80}
  3674.        } /* endif */
  3675.  
  3676.        ODPart *newPart         = theDraft->AcquirePart(ev, newPartID);
  3677.  
  3678.        Proxy* p = somSelf->CreateProxyObject(ev,
  3679.                                              newFrameShape,
  3680.                                              newExternalXForm,
  3681.                                              newPart,
  3682.                                              kODFalse);
  3683.        newPart->Release(ev);
  3684.  
  3685.     CATCH_ALL
  3686.        if (key!=kODNULL)
  3687.        {
  3688.           fromDraft->AbortClone(ev, key);
  3689.           clipboard->Clear( ev );
  3690.        } /* endif */
  3691.        WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Clipboard error!",
  3692.           NULL, 0, MB_ENTER | MB_ERROR);
  3693.     ENDTRY
  3694.  
  3695.     clipboard->Clear( ev );
  3696.     arbitrator->RelinquishFocus( ev, clipboardFocus, frame );
  3697.  
  3698.     SOM_CATCH_ALL
  3699.     SOM_ENDTRY
  3700. }
  3701.   /****
  3702.   *****                             128682 - faa - ends
  3703.   ****/
  3704.  
  3705. SOM_Scope ODBoolean  SOMLINK ContainerPartDoPaste(ContainerPart *somSelf,
  3706.                                                    Environment *ev,
  3707.                                                   ODFrame* frame)
  3708. {
  3709.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3710.     ContainerPartMethodDebug("ContainerPart","ContainerPartDoPaste");
  3711.  
  3712.     return kODFalse;
  3713. }
  3714.  
  3715.  
  3716. SOM_Scope ODBoolean  SOMLINK ContainerPartDoPasteLink(ContainerPart *somSelf,
  3717.                                                        Environment *ev,
  3718.                                                       ODFrame* frame)
  3719. {
  3720.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3721.     ContainerPartMethodDebug("ContainerPart","ContainerPartDoPasteLink");
  3722.  
  3723.     return kODFalse;
  3724. }
  3725.  
  3726. SOM_Scope ODBoolean  SOMLINK ContainerPartDoDeSelectAll(ContainerPart *somSelf,
  3727.                                                         Environment *ev,
  3728.                                                         ODFrame* frame)
  3729. {
  3730.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3731.     ContainerPartMethodDebug("ContainerPart","ContainerPartDoDeSelectAll");
  3732.  
  3733.     SOM_TRY
  3734.  
  3735.     if (frame && frame == _fSelectionFrame)
  3736.     {
  3737.        TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  3738.        if (frame == activeFrame)
  3739.           somSelf->InvalidateSelection(ev, frame);
  3740.  
  3741.        somSelf->UnClipSelectionFromEmbeddedFrames(ev, frame);
  3742.        somSelf->EmptySelection(ev);
  3743.     }
  3744.  
  3745.     SOM_CATCH_ALL
  3746.     SOM_ENDTRY
  3747.  
  3748.     return kODTrue;
  3749. }
  3750.  
  3751. SOM_Scope ODBoolean  SOMLINK ContainerPartDoClear(ContainerPart *somSelf,
  3752.                                                    Environment *ev,
  3753.                                                   ODFrame* frame)
  3754. {
  3755.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3756.     ContainerPartMethodDebug("ContainerPart","ContainerPartDoClear");
  3757.  
  3758.     SOM_TRY
  3759.  
  3760.     if (frame == _fSelectionFrame)
  3761.     {
  3762.        Proxy* p;
  3763.        ODULong seqnum;
  3764.        ODULong frgrp;
  3765.        ODxOrderedCollectionIterator i(_fSelection);
  3766.  
  3767.        /* copy the selection list */
  3768.        ODxOrderedCollection s;
  3769.        for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
  3770.           s.AddLast(p);
  3771.  
  3772.        somSelf->InvalidateSelection(ev, frame);
  3773.        somSelf->EmptySelection(ev);
  3774.  
  3775.        ODxOrderedCollectionIterator iter(&s);
  3776.        for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
  3777.        {
  3778.           somSelf->RemoveProxyObject(ev, p);
  3779.        }
  3780.        somSelf->ClipEmbeddedFrames(ev, kODNULL);
  3781.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  3782.  
  3783.        // clear the undo actions list  Defect 122707
  3784.        ODUndo * theUndo =      _fSession->GetUndo(ev);
  3785.        theUndo->ClearActionHistory (ev,kODRespectMarks);
  3786.     }
  3787.                                               
  3788.     SOM_CATCH_ALL
  3789.     SOM_ENDTRY
  3790.  
  3791.     return kODTrue;
  3792. }
  3793.  
  3794. SOM_Scope ODBoolean  SOMLINK ContainerPartDoSelectAll(ContainerPart *somSelf,
  3795.                                                       Environment *ev,
  3796.                                                       ODFrame* ContFrame)
  3797. {
  3798.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3799.     ContainerPartMethodDebug("ContainerPart","ContainerPartDoSelectAll");
  3800.  
  3801.     SOM_TRY
  3802.  
  3803.     ODFrame*   embFrame;                     // contains embedded frames
  3804.     USHORT     NumSelected = 0;
  3805.  
  3806.     if (_fSelectionFrame != ContFrame)
  3807.        somSelf->DoDeSelectAll(ev, _fSelectionFrame);
  3808.  
  3809.     ODxOrderedCollectionIterator i(_fEmbeddedFrames);
  3810.     for (embFrame = (ODFrame*) i.First();
  3811.                   i.IsNotComplete();
  3812.                   embFrame = (ODFrame*) i.Next() )
  3813.     {
  3814.        TempODFrame contFrame = embFrame->AcquireContainingFrame(ev);
  3815.        if (contFrame == ContFrame)
  3816.        {
  3817.           Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
  3818.           somSelf->SetFrameSelected(ev, embFrame, kODTrue);
  3819.           _fSelection->AddFirst(ElementType(p));
  3820.        }
  3821.     }
  3822.     somSelf->CreateProxySelectionBorder(ev);
  3823.     somSelf->ClipSelectionFromEmbeddedFrames(ev, ContFrame);
  3824.     somSelf->InvalidateSelection(ev, ContFrame);
  3825.  
  3826.     SOM_CATCH_ALL
  3827.     SOM_ENDTRY
  3828.  
  3829.     return kODTrue;
  3830. }
  3831.  
  3832.  
  3833. SOM_Scope ODBoolean  SOMLINK ContainerPartActivateFrame(ContainerPart *somSelf,
  3834.                                                         Environment *ev,
  3835.                                                         ODFrame* frame)
  3836. {
  3837.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3838.     ContainerPartMethodDebug("ContainerPart","ContainerPartActivateFrame");
  3839.  
  3840.     ODBoolean succeeded = kODFalse;
  3841.  
  3842.     SOM_TRY
  3843.  
  3844.     succeeded = _fSession->GetArbitrator(ev)->RequestFocusSet(ev, _fFocusSet,frame);
  3845.     if (succeeded)
  3846.       somSelf->PartActivated(ev, frame);
  3847.  
  3848.     SOM_CATCH_ALL
  3849.       succeeded = kODFalse;
  3850.     SOM_ENDTRY
  3851.  
  3852.     return succeeded;
  3853. }
  3854.  
  3855. SOM_Scope void  SOMLINK ContainerPartPartActivated(ContainerPart *somSelf,
  3856.                                                    Environment *ev,
  3857.                                                    ODFrame* frame)
  3858. {
  3859.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3860.     ContainerPartMethodDebug("ContainerPart","ContainerPartPartActivated");
  3861.  
  3862.     // Display our menu bar.
  3863.     _fMenuBar->Display(ev);
  3864.  
  3865.     // And set our "active" state.
  3866.     PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  3867.     pInfo->fIsActive = kODTrue;
  3868.  
  3869.     if (frame == _fSelectionFrame)
  3870.        somSelf->ShowSelection(ev, frame, kODTrue);
  3871. }
  3872.  
  3873. SOM_Scope void  SOMLINK ContainerPartActivatingWindow(ContainerPart *somSelf,
  3874.                                                        Environment *ev,
  3875.                                                       ODFrame* frame)
  3876. {
  3877.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3878.     ContainerPartMethodDebug("ContainerPart","ContainerPartActivatingWindow");
  3879.  
  3880.     SOM_TRY
  3881.  
  3882.     PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  3883.     if (pInfo->fNeedsActivating)
  3884.     {
  3885.        somSelf->ActivateFrame(ev, frame);
  3886.        //somSelf->ShowPalette(ev);
  3887.        pInfo->fNeedsActivating = kODFalse;
  3888.     }
  3889.  
  3890.     SOM_CATCH_ALL
  3891.     SOM_ENDTRY
  3892. }
  3893.  
  3894. SOM_Scope void  SOMLINK ContainerPartDeActivatingWindow(ContainerPart *somSelf,
  3895.                                                          Environment *ev,
  3896.                                                         ODFrame* frame)
  3897. {
  3898.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3899.     ContainerPartMethodDebug("ContainerPart","ContainerPartDeActivatingWindow");
  3900.  
  3901.     SOM_TRY
  3902.  
  3903.     PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  3904.          TempODFrame tempFrame =
  3905.                         _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  3906.     if (frame == tempFrame)
  3907.     {
  3908.        pInfo->fNeedsActivating = kODTrue;
  3909.        if (_fMouseMode != kNormal)
  3910.          somSelf->ResetMouseMode(ev);
  3911.     }
  3912.     else
  3913.        pInfo->fNeedsActivating = kODFalse;
  3914.  
  3915.     SOM_CATCH_ALL
  3916.     SOM_ENDTRY
  3917. }
  3918.  
  3919.  
  3920.  
  3921.  
  3922. SOM_Scope void  SOMLINK ContainerPartInstallMenus(ContainerPart *somSelf,
  3923.                                                    Environment *ev)
  3924. {
  3925.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  3926.     ContainerPartMethodDebug("ContainerPart","ContainerPartInstallMenus");
  3927.  
  3928.     SOM_TRY
  3929.  
  3930.     HMODULE hmod = NULLHANDLE;
  3931.     HWND hwndMenu = NULLHANDLE;
  3932.     HWND hwndMenu2 = NULLHANDLE;
  3933.     HWND hwndMoveSubmenu = NULLHANDLE;
  3934.     ODPlatformMenuItem mi;
  3935.     ODACCEL PartAccel;
  3936.  
  3937.     memset((PCH)&PartAccel, 0, sizeof(ODACCEL));
  3938.  
  3939.  
  3940.     //load up our background color menu
  3941.     hwndMenu = WinLoadMenu(HWND_OBJECT,
  3942.                            _hmod,
  3943.                            RESID_BACKGROUNDMENU);
  3944.  
  3945.     _fMenuBar->AddMenuLast(ev, RESID_BACKGROUNDMENU, hwndMenu, somSelf);
  3946.     _fMenuBar->SetMenuItemText(ev, RESID_BACKGROUNDMENU, kODNULL, "Background");
  3947.  
  3948.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3949.     mi.id = IDMA_TOGGLE_GRID;
  3950.     mi.afStyle = MIS_TEXT;
  3951.     _fMenuBar->AddMenuItemLast(ev, IDMS_VIEW, kODNULL, &mi);
  3952.     _fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid on");
  3953.  
  3954.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3955.     mi.id = ID_SEPARATOR;
  3956.     mi.afStyle = MIS_SEPARATOR;
  3957.     _fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
  3958.  
  3959.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3960.     mi.id = IDMA_SCALE;
  3961.     mi.afStyle = MIS_TEXT;
  3962.     _fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
  3963.     _fMenuBar->SetMenuItemText(ev, IDMS_EDIT, IDMA_SCALE, "Scale");
  3964.     _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODFalse);
  3965.  
  3966.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3967.     mi.id = IDMA_ROTATE;
  3968.     mi.afStyle = MIS_TEXT;
  3969.     _fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
  3970.     _fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_ROTATE, "Rotate");
  3971.     _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODFalse);
  3972.  
  3973.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3974.     mi.id = IDMA_PRINT;
  3975.     mi.afStyle = MIS_TEXT;
  3976.     _fMenuBar->AddMenuItemLast(ev, IDMS_VIEW, kODNULL, &mi);
  3977.     _fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_PRINT, "Print part");
  3978.  
  3979.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3980.     mi.id = ID_SEPARATOR;
  3981.     mi.afStyle = MIS_SEPARATOR;
  3982.     _fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, &mi);
  3983.  
  3984.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3985.     mi.id = IDMA_PARTINFO;
  3986.     mi.afStyle = MIS_TEXT;
  3987.     _fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, &mi);
  3988.     _fMenuBar->SetMenuItemText(ev, IDMS_HELP, IDMA_PARTINFO,"~Container part information");
  3989.  
  3990.     memset((PCH)&mi, 0, sizeof(MENUITEM));
  3991.     mi.id = IDMA_MOVE;
  3992.     mi.afStyle = MIS_TEXT;
  3993.     _fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
  3994.     _fMenuBar->SetMenuItemText(ev, IDMS_EDIT, IDMA_MOVE,"Move");
  3995.  
  3996.     //now we'll add a submenu to  EDIT->MOVE
  3997.     hwndMoveSubmenu = WinLoadMenu(HWND_OBJECT,
  3998.                            _hmod,
  3999.                            RESID_ARRANGE);
  4000.     _fMenuBar->InsertSubmenu(ev, IDMS_EDIT, IDMA_MOVE, hwndMoveSubmenu);
  4001.  
  4002.  
  4003.  
  4004.     //now lets add an accelerator table for our MOVE menu items.
  4005.     //This can also be done by defining an accelerator table in the resource
  4006.     //file, loading it in, copying it to an ACCELTABLE structure and copying
  4007.     //the ACCEL items in the table to an ODACCEL structure. Then you can use
  4008.     //a FOR loop for copying.  Since we only have 4 accelerators to add, we
  4009.     //will construct our ODACCEL structure like this.
  4010.     PartAccel.aAccel[0].fs  = AF_SHIFT | AF_VIRTUALKEY;
  4011.     PartAccel.aAccel[0].key = VK_UP;
  4012.     PartAccel.aAccel[0].cmd = IDMA_MOVETOFRONT;
  4013.     PartAccel.aAccel[1].fs  = AF_SHIFT | AF_VIRTUALKEY;
  4014.     PartAccel.aAccel[1].key = VK_DOWN;
  4015.     PartAccel.aAccel[1].cmd = IDMA_MOVETOBACK;
  4016.     PartAccel.aAccel[2].fs  = AF_ALT | AF_VIRTUALKEY;
  4017.     PartAccel.aAccel[2].key = VK_UP;
  4018.     PartAccel.aAccel[2].cmd = IDMA_MOVEFORWARD;
  4019.     PartAccel.aAccel[3].fs  = AF_ALT | AF_VIRTUALKEY;
  4020.     PartAccel.aAccel[3].key = VK_DOWN;
  4021.     PartAccel.aAccel[3].cmd = IDMA_MOVEBACKWARD;
  4022.  
  4023.     _fMenuBar->AddToAccelTable(ev, 4, &PartAccel);
  4024.  
  4025.     //insert our print item - on the popup menu
  4026.       memset((PCH)&mi, 0, sizeof(MENUITEM));
  4027.       mi.id = IDMA_PRINT;
  4028.       mi.afStyle = MIS_TEXT;
  4029.       _fPopup->AddMenuItemLast(ev, kODNULL, kODNULL, &mi);
  4030.       _fPopup->SetMenuItemText(ev, kODNULL, IDMA_PRINT, "Print part");
  4031.  
  4032.      _fPopup->AddDefaultMenuItemBefore(ev,
  4033.                                        EDIT_DELETE,
  4034.                                        IDMA_PRINT);
  4035.      // *********************************************************************
  4036.      // ***  130083 -  set statusline text for menu items    ******
  4037.      // *********************************************************************
  4038.  
  4039.      int id []= {      IDMA_SCALE,  IDMA_ROTATE,IDMA_PARTINFO, EDIT_SELPROPERTIES,
  4040.                        IDMA_COLOR_GRAY   , IDMA_COLOR_BLUE   ,IDMA_PRINT,          EDIT_SEL_SAFRAME,
  4041.                        RESID_BACKGROUNDMENU,
  4042.                        IDMA_MOVETOFRONT,IDMA_MOVETOBACK,IDMA_MOVEFORWARD,IDMA_MOVEBACKWARD,
  4043.                        IDMA_COLOR_RED    , IDMA_COLOR_MAGENTA,
  4044.                        IDMA_COLOR_GREEN  , IDMA_COLOR_CYAN   , EDIT_SEL_SASMALLICON,
  4045.                        EDIT_SEL_SALARGEICON, EDIT_SEL_SATHUMBNAIL,EDIT_SEL_SHOWAS,
  4046.                        IDMA_COLOR_YELLOW , IDMA_COLOR_WHITE  , EDIT_OPENSEL };
  4047.      int *p = id;  // ptr to array of menu items having statusline text.
  4048.      char string[256];
  4049.      while(*p) {
  4050.           USHORT rc = WinLoadString( (HAB)0,_hmod,(*p),255,string);// read string table
  4051.           if (rc) { // have sting to load
  4052.              _fMenuBar->SetMenuItemStatusText(ev,*p,string);
  4053.           } /* endif */
  4054.           (*p++);
  4055.      } // endwhile
  4056.      // end 130083 stuff
  4057.  
  4058.      SOM_CATCH_ALL
  4059.      SOM_ENDTRY
  4060. }
  4061.  
  4062. SOM_Scope void  SOMLINK ContainerPartRemoveMenus(ContainerPart *somSelf,
  4063.                                                   Environment *ev,
  4064.                                                  ODFrame* aFrame)
  4065. {
  4066.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4067.     ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveMenus");
  4068.  
  4069. }
  4070.  
  4071. SOM_Scope void  SOMLINK ContainerPartUserSetBGColor(ContainerPart *somSelf,
  4072.                                                      Environment *ev,
  4073.                                                     ODFrame* frame,
  4074.                                                     long whichColor)
  4075. {
  4076.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4077.     ContainerPartMethodDebug("ContainerPart","ContainerPartUserSetBGColor");
  4078.  
  4079.     SOM_TRY
  4080.  
  4081.     if (whichColor != _fBGColor)
  4082.     {
  4083.       ODIText*  undoActionName;
  4084.       ODIText*  redoActionName;
  4085.  
  4086.       undoActionName = CreateITextCString(0,0,"Undo Set Color");
  4087.  
  4088.       redoActionName = CreateITextCString(0,0,"Redo Set Color");
  4089.       SetBGColorRec* undoRec = new SetBGColorRec(_fBGColor, whichColor,
  4090.                             frame);
  4091.  
  4092.       ODActionData *undoer  = (ODActionData *)CreateByteArray(undoRec, sizeof(SetBGColorRec));
  4093.       ODUndo * theUndo =      _fSession->GetUndo(ev);
  4094.       theUndo->AddActionToHistory(ev, somSelf, undoer,
  4095.                           kODSingleAction,
  4096.                           (ODName*)undoActionName,
  4097.                           (ODName*)redoActionName);
  4098.       DisposeByteArray(undoer);  // remove byte array
  4099.       somSelf->SetBGColor2(ev, frame, whichColor);
  4100.  
  4101.     }
  4102.  
  4103.     SOM_CATCH_ALL
  4104.     SOM_ENDTRY
  4105. }
  4106.  
  4107. SOM_Scope long  SOMLINK ContainerPartGetBGColor(ContainerPart *somSelf,
  4108.                                                      Environment *ev)
  4109. {
  4110.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4111.     /* ContainerPartMethodDebug("ContainerPart","ContainerPartGetBGColor"); */
  4112.  
  4113.     return _fBGColor;
  4114. }
  4115.  
  4116. SOM_Scope void  SOMLINK ContainerPartSetBGColor1(ContainerPart *somSelf,
  4117.                                                   Environment *ev,
  4118.                                                  ODFrame* aFrame,
  4119.                                                  long whichColor) //@127858
  4120.                                                  //@127858 ODUShort whichColor)
  4121. {
  4122.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4123.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor1");
  4124.  
  4125.     SOM_TRY
  4126.  
  4127.     PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
  4128.     if (!pInfo)
  4129.     {  pInfo = new PartInfoRec;
  4130.       aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
  4131.     };
  4132.  
  4133.     somSelf->UserSetBGColor(ev, aFrame,whichColor);
  4134.  
  4135.     SOM_CATCH_ALL
  4136.     SOM_ENDTRY
  4137. }
  4138.  
  4139. SOM_Scope void  SOMLINK ContainerPartSetBGColor2(ContainerPart *somSelf,
  4140.                                                   Environment *ev,
  4141.                                                  ODFrame* aFrame,
  4142.                                                  long whichColor)
  4143. {
  4144.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4145.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor2");
  4146.  
  4147.     SOM_TRY
  4148.  
  4149.     if (whichColor != _fBGColor)
  4150.     {
  4151.       _fBGColor = whichColor;
  4152.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4153.       aFrame->Invalidate(ev, NULL, kODNULL);
  4154.     }
  4155.  
  4156.     SOM_CATCH_ALL
  4157.     SOM_ENDTRY
  4158. }
  4159.  
  4160. SOM_Scope void  SOMLINK ContainerPartEmbed(ContainerPart *somSelf,
  4161.                                             Environment *ev,
  4162.                                            short item, ODFrame* frame,
  4163.                                            ODPart** newPart)
  4164. {
  4165.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4166.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmbed");
  4167. }
  4168.  
  4169.  
  4170.  
  4171. SOM_Scope Proxy*  SOMLINK ContainerPartCreateProxyObject(ContainerPart *somSelf,
  4172.                                                          Environment *ev,
  4173.                                                          ODShape* frameShape,
  4174.                                                          ODTransform* externalTransform,
  4175.                                                          ODPart* embedPart,
  4176.                                                          ODBoolean isOverlaid)
  4177. {
  4178.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4179.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateProxyObject");
  4180.  
  4181.     Proxy* p = kODNULL;
  4182.  
  4183.     SOM_TRY
  4184.  
  4185.     ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  4186.  
  4187.     ODShape* newShape = kODNULL;
  4188.     // decide what newShape should be - for now, give it what it asked for
  4189.     if (frameShape)
  4190.     {
  4191.       newShape = frameShape;
  4192.       newShape->Acquire(ev);
  4193.     }
  4194.     else
  4195.     {  // no frameShape specified, use a default size
  4196.       ODRect rect(0, MAKEFIXED(200,0), MAKEFIXED(200,0), 0);
  4197.       newShape = ((ODFrame*)dispFrames.First())->CreateShape(ev);
  4198.       newShape->SetRectangle(ev, &rect);
  4199.     };
  4200.     externalTransform->Acquire(ev);
  4201.     embedPart->Acquire(ev);
  4202.     p = new Proxy(externalTransform, newShape, embedPart);
  4203.     _fContents->AddFirst(p);
  4204.  
  4205.     // create the new frame
  4206.     // kODNullTypeToken
  4207.  
  4208.     for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  4209.          dispFrames.IsNotComplete();
  4210.          dispFrame = (ODFrame*)dispFrames.Next())
  4211.     {
  4212.  
  4213.        ODFrame* newFrame = somSelf->MakeEmbeddedFrame(ev, dispFrame, p, isOverlaid);
  4214.        ODReleaseObject(ev, newFrame);
  4215.     }
  4216.  
  4217.     if (somSelf->NormalizeProxyGeometry(ev, p))
  4218.        somSelf->SetProxyFrameShapes(ev, p);
  4219.  
  4220.     SOM_CATCH_ALL
  4221.     SOM_ENDTRY
  4222.  
  4223.     return p;
  4224. }
  4225.  
  4226. SOM_Scope ODFrame*  SOMLINK ContainerPartMakeEmbeddedFrame(ContainerPart *somSelf,
  4227.                                                            Environment *ev,
  4228.                                                            ODFrame* containingFrame,
  4229.                                                            Proxy* p,
  4230.                                                            ODBoolean isOverlaid)
  4231. {
  4232.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4233.     ContainerPartMethodDebug("ContainerPart","ContainerPartMakeEmbeddedFrame");
  4234.  
  4235.     ODFrame* newFrame = kODNULL;
  4236.  
  4237.     SOM_TRY
  4238.  
  4239.     newFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->
  4240.        CreateFrame(ev,
  4241.              (containingFrame->GetStorageUnit(ev)) ? kODFrameObject :
  4242.                        kODNonPersistentFrameObject,
  4243.              containingFrame, p->shape, (ODCanvas*)kODNULL,
  4244.              p->part,
  4245.              _fSession->Tokenize(ev, kODViewAsFrame),
  4246.              _fSession->Tokenize(ev, kODPresDefault),
  4247.              kODFalse, isOverlaid);
  4248.  
  4249.     newFrame->Acquire(ev);
  4250.     _fEmbeddedFrames->AddFirst(newFrame);
  4251.     p->AddFirst(newFrame);
  4252.  
  4253.     newFrame->SetPropagateEvents(ev, kODTrue);
  4254.     TempODFrameFacetIterator facets = containingFrame->CreateFacetIterator(ev);
  4255.     for (ODFacet* facet = facets->First(ev);
  4256.                                facets->IsNotComplete(ev);
  4257.                                      facet = facets->Next(ev))
  4258.     {
  4259.        ODFacet* newFacet = facet->CreateEmbeddedFacet(ev,
  4260.                                   newFrame,
  4261.                                   p->shape,
  4262.                                   p->transform,
  4263.                                   kODNULL,
  4264.                                   kODNULL,
  4265.                                   kODNULL,
  4266.                                   kODFrameInFront);
  4267.  
  4268.        ODHighlight highlight = facet->GetHighlight(ev);
  4269.        if( highlight != kODNoHighlight)
  4270.           newFacet->ChangeHighlight(ev, highlight);
  4271.     }
  4272.     somSelf->ClipEmbeddedFrames(ev, containingFrame);
  4273.     newFrame->Invalidate(ev, kODNULL, kODNULL);
  4274.     _fNeedToExternalize = kODTrue;
  4275.  
  4276.     SOM_CATCH_ALL
  4277.     SOM_ENDTRY
  4278.  
  4279.     return newFrame;
  4280. }
  4281.  
  4282. SOM_Scope ODWindow*  SOMLINK ContainerPartCreateWindow(ContainerPart *somSelf,
  4283.                                                         Environment *ev,
  4284.                                                        ODFrame* sourceFrame)
  4285. {
  4286.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4287.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateWindow");
  4288.  
  4289.     ODWindow* window = kODNULL;
  4290.  
  4291.     SOM_TRY
  4292.  
  4293.     Rect windRect;
  4294.     ODPlatformWindow platformWindow = kODNULL;
  4295.  
  4296.     // need to check if root frame
  4297.     if (sourceFrame && !sourceFrame->IsRoot(ev)) {
  4298.        SWP swp;
  4299.        swp.x = 100;
  4300.        swp.y = 100;
  4301.        swp.cx = 400;
  4302.        swp.cy = 400;
  4303.        platformWindow = _fSession->CreatePlatformWindow(ev, ODPlatformWindowDefaultCreateOptions | FCF_HORZSCROLL | FCF_VERTSCROLL);
  4304.        WinSetWindowPos(platformWindow, HWND_TOP,
  4305.                        swp.x, swp.y, swp.cx, swp.cy,
  4306.                        SWP_SIZE | SWP_MOVE);
  4307.  
  4308.      } else {
  4309.         platformWindow = _fSession->CreatePlatformWindow(ev, ODPlatformWindowDefaultCreateOptions);
  4310.     } /* endif */
  4311.  
  4312.     window =  _fSession->GetWindowState(ev)->
  4313.           RegisterWindow(ev, platformWindow,
  4314.                 kODFrameObject,
  4315.                 (sourceFrame==kODNULL),  // is root
  4316.                 kODTrue,      // Is resizable
  4317.                 kODFalse,      // Is floating
  4318.                 kODTrue,      // should save
  4319.                 kODTrue,      // should dispose
  4320.                 _fPartWrapper,
  4321.                  _fSession->Tokenize(ev, kODViewAsFrame),
  4322.                  _fSession->Tokenize(ev, kODPresDefault),
  4323.                 sourceFrame);
  4324.  
  4325.     SOM_CATCH_ALL
  4326.     SOM_ENDTRY
  4327.  
  4328.     return window;
  4329. }
  4330.  
  4331. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveToFront(ContainerPart *somSelf,
  4332.                                                        Environment *ev,
  4333.                                                       ODFrame* frame)
  4334. {
  4335.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4336.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToFront");
  4337.  
  4338.     SOM_TRY
  4339.  
  4340.     if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
  4341.     {
  4342.        ODxOrderedCollectionIterator i(_fSelection);
  4343.        Proxy* p = (Proxy*) i.First();
  4344.  
  4345.        _fContents->Remove(p);
  4346.        _fContents->AddFirst(p);
  4347.        ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  4348.        for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  4349.             dispFrames.IsNotComplete();
  4350.             dispFrame = (ODFrame*)dispFrames.Next())
  4351.        {
  4352.           ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
  4353.           
  4354.           ODxOrderedCollection tempFacets;
  4355.           TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
  4356.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  4357.           {
  4358.              tempFacets.AddFirst(facet);
  4359.           }
  4360.           ODxOrderedCollectionIterator iter(&tempFacets);
  4361.           for (facet = (ODFacet*)iter.First();
  4362.                iter.IsNotComplete();
  4363.                facet = (ODFacet*)iter.Next())
  4364.           {
  4365.              facet->GetContainingFacet(ev)->MoveBefore(ev, facet, kODNULL);
  4366.           }
  4367.           somSelf->ClipEmbeddedFrames(ev, dispFrame);
  4368.           moveFrame->Invalidate(ev, kODNULL, kODNULL);
  4369.        }
  4370.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4371.        _fNeedToExternalize = kODTrue;
  4372.     }
  4373.     SOM_CATCH_ALL
  4374.     SOM_ENDTRY
  4375.  
  4376.     return kODTrue;
  4377. }
  4378.  
  4379. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveToBack(ContainerPart *somSelf,
  4380.                                                       Environment *ev,
  4381.                                                      ODFrame* frame)
  4382. {
  4383.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4384.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToBack");
  4385.  
  4386.     SOM_TRY
  4387.  
  4388.     if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
  4389.     {
  4390.        ODxOrderedCollectionIterator i(_fSelection);
  4391.        Proxy* p = (Proxy*) i.First();
  4392.  
  4393.        _fContents->Remove(p);
  4394.        _fContents->AddLast(p);
  4395.        ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  4396.        for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  4397.             dispFrames.IsNotComplete();
  4398.             dispFrame = (ODFrame*)dispFrames.Next())
  4399.        {
  4400.           ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
  4401.           
  4402.           moveFrame->Invalidate(ev, kODNULL, kODNULL);
  4403.           ODxOrderedCollection tempFacets;
  4404.           TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
  4405.           for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  4406.           {
  4407.              tempFacets.AddLast(facet);
  4408.           }
  4409.           ODxOrderedCollectionIterator iter(&tempFacets);
  4410.           for (facet = (ODFacet*)iter.First();
  4411.                iter.IsNotComplete();
  4412.                facet = (ODFacet*)iter.Next())
  4413.           {
  4414.              facet->GetContainingFacet(ev)->MoveBehind(ev, facet, kODNULL);
  4415.           }
  4416.           somSelf->ClipEmbeddedFrames(ev, dispFrame);
  4417.        }
  4418.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4419.        _fNeedToExternalize = kODTrue;
  4420.     }
  4421.  
  4422.     SOM_CATCH_ALL
  4423.     SOM_ENDTRY
  4424.  
  4425.     return kODTrue;
  4426. }
  4427.  
  4428. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveForward(ContainerPart *somSelf,
  4429.                                                        Environment *ev,
  4430.                                                       ODFrame* frame)
  4431. {
  4432.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4433.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveForward");
  4434.  
  4435.     SOM_TRY
  4436.  
  4437.     if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
  4438.     {
  4439.        ODxOrderedCollectionIterator i(_fSelection);
  4440.        ODxOrderedCollection tempFacets;
  4441.        Proxy* p = (Proxy*) i.First();
  4442.  
  4443.        Proxy* siblingProxy = (Proxy*)_fContents->Before(p);
  4444.        if (siblingProxy)
  4445.        {
  4446.           _fContents->Remove(p);
  4447.           _fContents->AddBefore(siblingProxy, p);
  4448.           ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  4449.           for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  4450.                dispFrames.IsNotComplete();
  4451.                dispFrame = (ODFrame*)dispFrames.Next())
  4452.           {
  4453.              ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
  4454.              ODFrame* siblingFrame = somSelf->FrameFromProxyForContainingFrame(ev, siblingProxy, dispFrame);
  4455.              
  4456.              TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
  4457.              for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  4458.              {
  4459.                 tempFacets.AddLast(facet);
  4460.              }
  4461.              ODxOrderedCollectionIterator iter(&tempFacets);
  4462.              TempODFrameFacetIterator siblingFacets = siblingFrame->CreateFacetIterator(ev);
  4463.              ODFacet* siblingFacet = siblingFacets->First(ev);
  4464.      
  4465.              for (facet = (ODFacet*)iter.First();
  4466.                   iter.IsNotComplete();
  4467.                   facet = (ODFacet*)iter.Next())
  4468.              {
  4469.                 facet->GetContainingFacet(ev)->MoveBefore(ev, facet, siblingFacet);
  4470.              }
  4471.              somSelf->ClipEmbeddedFrames(ev, dispFrame);
  4472.              moveFrame->Invalidate(ev, kODNULL, kODNULL);
  4473.           }
  4474.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4475.           _fNeedToExternalize = kODTrue;
  4476.        }
  4477.     }
  4478.  
  4479.     SOM_CATCH_ALL
  4480.     SOM_ENDTRY
  4481.  
  4482.     return kODTrue;
  4483. }
  4484.  
  4485.  
  4486. SOM_Scope ODBoolean  SOMLINK ContainerPartMoveBackward(ContainerPart *somSelf,
  4487.                                                         Environment *ev,
  4488.                                                        ODFrame* frame)
  4489. {
  4490.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4491.     ContainerPartMethodDebug("ContainerPart","ContainerPartMoveBackward");
  4492.  
  4493.     SOM_TRY
  4494.  
  4495.     if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
  4496.     {
  4497.        ODxOrderedCollectionIterator i(_fSelection);
  4498.        ODxOrderedCollection tempFacets;
  4499.        Proxy* p = (Proxy*) i.First();
  4500.  
  4501.        Proxy* siblingProxy = (Proxy*)_fContents->After(p);
  4502.        if (siblingProxy)
  4503.        {
  4504.           _fContents->Remove(p);
  4505.           _fContents->AddAfter(siblingProxy, p);
  4506.           ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
  4507.           for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
  4508.                dispFrames.IsNotComplete();
  4509.                dispFrame = (ODFrame*)dispFrames.Next())
  4510.           {
  4511.              ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
  4512.              ODFrame* siblingFrame = somSelf->FrameFromProxyForContainingFrame(ev, siblingProxy, dispFrame);
  4513.              
  4514.              moveFrame->Invalidate(ev, kODNULL, kODNULL);
  4515.              TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
  4516.              for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
  4517.              {
  4518.                 tempFacets.AddLast(facet);
  4519.              }
  4520.              ODxOrderedCollectionIterator iter(&tempFacets);
  4521.              TempODFrameFacetIterator siblingFacets = siblingFrame->CreateFacetIterator(ev);
  4522.              ODFacet* siblingFacet = siblingFacets->First(ev);
  4523.           
  4524.              for (facet = (ODFacet*)iter.First();
  4525.                   iter.IsNotComplete();
  4526.                   facet = (ODFacet*)iter.Next())
  4527.              {
  4528.                 facet->GetContainingFacet(ev)->MoveBehind(ev, facet, siblingFacet);
  4529.              }
  4530.              somSelf->ClipEmbeddedFrames(ev, dispFrame);
  4531.           }
  4532.           somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4533.           _fNeedToExternalize = kODTrue;
  4534.        }
  4535.     }
  4536.  
  4537.     SOM_CATCH_ALL
  4538.     SOM_ENDTRY
  4539.  
  4540.     return kODTrue;
  4541. }
  4542.  
  4543. SOM_Scope void  SOMLINK ContainerPartClearAccelTable(ContainerPart *somSelf,
  4544.                                                       Environment *ev,
  4545.                                                      ODFrame* oldOwner)
  4546. {
  4547.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4548.     ContainerPartMethodDebug("ContainerPart","ContainerPartClearAccelTable");
  4549.  
  4550. }
  4551.  
  4552.  
  4553.  
  4554. SOM_Scope void  SOMLINK ContainerPartSetAccelTable(ContainerPart *somSelf,
  4555.                                                     Environment *ev,
  4556.                                                    ODFrame* newOwner)
  4557. {
  4558.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4559.     ContainerPartMethodDebug("ContainerPart","ContainerPartSetAccelTable");
  4560.  
  4561. }
  4562.  
  4563. SOM_Scope ODBoolean  SOMLINK ContainerPartDisplayStatusLineText(ContainerPart *somSelf, Environment *ev,
  4564.                 string str, ODFrame * curFrame)
  4565. {
  4566.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4567.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayStatusLineText");
  4568.  
  4569.     SOM_TRY
  4570.  
  4571.     ODBoolean haveFocus = kODFalse;
  4572.     if (_fStatusLn)
  4573.     {                      // 139395 start
  4574.           ODArbitrator * arbit = _fSession->GetArbitrator(ev);
  4575.           ODFrame * OwnerFrame = arbit->AcquireFocusOwner(ev,_fStatusFocus);
  4576.           if (OwnerFrame != curFrame) {
  4577.              if (arbit->RequestFocus(ev, _fStatusFocus, curFrame))
  4578.                  haveFocus = kODTrue; // part has focus
  4579.           } else {
  4580.              haveFocus = kODTrue;
  4581.           } /* endif */
  4582.           if (OwnerFrame) {
  4583.               OwnerFrame->Release(ev);
  4584.           } /* endif */
  4585.        if ( haveFocus) {
  4586.               _fStatusLn->SetStatusLineText(ev,str,curFrame);
  4587.               return kODTrue;
  4588.        }
  4589.     }            // 139395 end
  4590.  
  4591.     SOM_CATCH_ALL
  4592.     SOM_ENDTRY
  4593.  
  4594.     return kODFalse;
  4595. }
  4596.  
  4597. SOM_Scope long  SOMLINK ContainerPartGetDemoState(ContainerPart *somSelf,
  4598.                                                    Environment *ev)
  4599. {
  4600.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4601.     ContainerPartMethodDebug("ContainerPart","ContainerPartGetDemoState");
  4602.  
  4603.     /* Return statement to be customized: */
  4604.     return _DemoState;
  4605. }
  4606.  
  4607. SOM_Scope void  SOMLINK ContainerPartsomInit(ContainerPart *somSelf)
  4608. {
  4609.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4610.     ContainerPartMethodDebug("ContainerPart","ContainerPartsomInit");
  4611.  
  4612.     ContainerPart_parent_ODPart_somInit(somSelf);
  4613.     _fDisplayFrames = kODNULL;
  4614.     _fEmbeddedFrames = kODNULL;
  4615.     _fWindowID = 0;
  4616.     _fSequence = 0;   //[pfe] 123945
  4617.  
  4618.     _fContents = kODNULL;
  4619.     _fSelection = kODNULL;
  4620.     _fSelectionFrame = kODNULL;
  4621.     _fPasteFrame = kODNULL;
  4622.     _fNeedToExternalize = kODFalse;
  4623.     _fContainerSU = kODNULL;
  4624.  
  4625.     _fSelectShape = kODNULL;
  4626.  
  4627.     _fFocusSet = kODNULL;
  4628.  
  4629.     _fSemtIntf = kODNULL;
  4630.  
  4631.          _fViewExtension = kODNULL;
  4632.  
  4633.     _fSPEMenuOfSelection = kODNULL;
  4634.     _fRemappedSPEMenuOfSelection = kODNULL;
  4635.  
  4636.  
  4637.     _DemoState = 0;
  4638.     _DemoOpenCount = 0;
  4639.     _fMenuBar = kODNULL;
  4640.     _fBGColor = 0;
  4641.  
  4642.     _fSession = kODNULL;
  4643.  
  4644.     _fPartWrapper = kODNULL;
  4645.     _fPasteOn      = kODFalse;
  4646.     _fPasteESC     = kODFalse;
  4647.  
  4648.     _fMouseMode = kNormal;
  4649.     _fTrackingMode = 0;
  4650.     _fIgnoreContextMenu = kODFalse;
  4651.     _fStatusLn = 0;
  4652.  
  4653. }
  4654.  
  4655. SOM_Scope void  SOMLINK ContainerPartsomUninit(ContainerPart *somSelf)
  4656. {
  4657.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4658.     ContainerPartMethodDebug("ContainerPart","ContainerPartsomUninit");
  4659.  
  4660.     Environment* ev = somGetGlobalEnvironment();
  4661.  
  4662.     SOM_TRY
  4663.  
  4664.     if (_fContents != kODNULL)
  4665.       delete _fContents;
  4666.     if (_fSelection != kODNULL)
  4667.       delete _fSelection;
  4668.  
  4669.     if (_fSavedFacetClipShapes)
  4670.     {
  4671.       while (_fSavedFacetClipShapes->Count())
  4672.       {
  4673.          FacetClip* facetClip = (FacetClip*)_fSavedFacetClipShapes->First();
  4674.          ODReleaseObject(ev, facetClip->clip);
  4675.          _fSavedFacetClipShapes->Remove(facetClip);
  4676.          delete facetClip;
  4677.       }
  4678.       delete _fSavedFacetClipShapes;
  4679.     }
  4680.  
  4681.     ODReleaseObject(ev, _fSelectShape);
  4682.  
  4683.     if (_hpsMem) GpiDestroyPS(_hpsMem);
  4684.     if (_hdcMem) DevCloseDC(_hdcMem);
  4685.  
  4686.          if (_fViewExtension != kODNULL)
  4687.                 delete _fViewExtension;
  4688.  
  4689.     if (_fDisplayFrames != kODNULL)
  4690.       delete _fDisplayFrames;    // make sure it's empty first
  4691.     if (_fEmbeddedFrames != kODNULL)
  4692.       delete _fEmbeddedFrames;    // make sure it's empty first
  4693.  
  4694.     #define SEMANTIC_INTERFACES_NOT_DONE
  4695.     #ifndef SEMANTIC_INTERFACES_NOT_DONE
  4696.        if (_fSemtIntf != kODNULL)
  4697.            delete _fSemtIntf;
  4698.     #endif
  4699.  
  4700.     ODReleaseObject(ev, _fStatusLn);
  4701.     ODReleaseObject(ev, _fSelectionFrame);
  4702.     ODReleaseObject(ev, _fContainerSU);
  4703.  
  4704.     if (_hmod)
  4705.       DosFreeModule(_hmod);
  4706.  
  4707.     SOM_CATCH_ALL
  4708.     SOM_ENDTRY
  4709.  
  4710.     ContainerPart_parent_ODPart_somUninit(somSelf);
  4711. }
  4712.  
  4713. SOM_Scope void  SOMLINK ContainerPartFulfillPromise(ContainerPart *somSelf,
  4714.                                                      Environment *ev,
  4715.                                                     ODStorageUnitView* promiseSUView)
  4716. {
  4717.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4718.     ContainerPartMethodDebug("ContainerPart","ContainerPartFulfillPromise");
  4719.  
  4720. }
  4721.  
  4722. SOM_Scope void  SOMLINK ContainerPartDropCompleted(ContainerPart *somSelf,
  4723.                                                     Environment *ev,
  4724.                                                    ODPart* destPart,
  4725.                                                    ODDropResult dropResult)
  4726. {
  4727.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4728.     ContainerPartMethodDebug("ContainerPart","ContainerPartDropCompleted");
  4729.  
  4730.     ODUnused(destPart);
  4731.     ODUnused(dropResult);
  4732. }
  4733.  
  4734. void InvertDragHilite( Environment * ev, ODFacet* facet)
  4735. {
  4736.  
  4737.    SOM_TRY
  4738.  
  4739.    HPS hps;
  4740.  
  4741.    CFocusWindow f(ev, facet, (ODShape*)kODNULL, &hps, (HWND*)kODNULL, CFocusWindow::DragPS);
  4742.  
  4743.    ODTempPolygon poly;
  4744.    POLYGON polygon;
  4745.    ODContour *pContour;
  4746.    int i;
  4747.    TempODShape clipShape = facet->AcquireAggregateClipShape(ev, kODNULL);
  4748.    clipShape->CopyPolygon(ev,&poly);    // [137664]
  4749.  
  4750.    GpiSetMix( hps, FM_INVERT );
  4751.    GpiBeginPath(hps, 1);
  4752.    for (pContour = poly.FirstContour(), i = 0;
  4753.         i < poly.GetNContours();
  4754.         pContour = pContour->NextContour(), i++)
  4755.    {
  4756.       pContour->AsPOLYGON(polygon);
  4757.       GpiMove(hps, &polygon.aPointl[polygon.ulPoints-1]);
  4758.       GpiPolyLine(hps, polygon.ulPoints, polygon.aPointl);
  4759.       SOMFree(polygon.aPointl);
  4760.    }
  4761.    GpiEndPath(hps);
  4762.    GpiSetLineWidthGeom(hps, 8);
  4763.    GpiStrokePath(hps, 1, 0);
  4764.  
  4765.    SOM_CATCH_ALL
  4766.    SOM_ENDTRY
  4767. }
  4768.  
  4769. SOM_Scope ODDragResult  SOMLINK ContainerPartDragEnter(ContainerPart *somSelf,
  4770.                                                         Environment *ev,
  4771.                                                        ODDragItemIterator* dragInfo,
  4772.                                                        ODFacet* facet,
  4773.                                                        ODPoint* where)
  4774. {
  4775.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4776.     ContainerPartMethodDebug("ContainerPart","ContainerPartDragEnter");
  4777.  
  4778.     SOM_TRY
  4779.  
  4780. // [140007] :
  4781.     ODStorageUnit* dragSU;
  4782.     _fDropAccepted = kODTrue;
  4783.  
  4784.     PartInfoRec* pInfo = (PartInfoRec*)facet->GetFrame(ev)->GetPartInfo(ev);
  4785.     if (!pInfo->fAcceptDrop)
  4786.        _fDropAccepted = kODFalse;
  4787.     else
  4788.     {
  4789.        for (dragSU = dragInfo->First(ev); dragSU ; dragSU = dragInfo->Next(ev))
  4790.        {
  4791.           if ( ! _fSession->GetDragAndDrop(ev)->CanEmbed(ev,dragSU)) {
  4792.                _fDropAccepted = kODFalse;
  4793.                break;
  4794.           }
  4795.        }
  4796.     }
  4797.  
  4798.     if(_fDropAccepted) {
  4799.        InvertDragHilite( ev, facet );
  4800.        return MRFROM2SHORT (DOR_DROP, DO_MOVE);
  4801.     }
  4802.  
  4803.     SOM_CATCH_ALL
  4804.     SOM_ENDTRY
  4805.  
  4806.     return MRFROM2SHORT (DOR_NODROP, 0);
  4807. }
  4808.  
  4809. SOM_Scope ODDragResult  SOMLINK ContainerPartDragWithin(ContainerPart *somSelf,
  4810.                                                          Environment *ev,
  4811.                                                         ODDragItemIterator* dragInfo,
  4812.                                                         ODFacet* facet,
  4813.                                                         ODPoint* where)
  4814. {
  4815.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4816.     ContainerPartMethodDebug("ContainerPart","ContainerPartDragWithin");
  4817.  
  4818. // [140007] :
  4819.     if(_fDropAccepted)
  4820.        return MRFROM2SHORT (DOR_DROP, DO_MOVE);
  4821.     return MRFROM2SHORT (DOR_NODROP, 0);
  4822. }
  4823.  
  4824. SOM_Scope void  SOMLINK ContainerPartDragLeave(ContainerPart *somSelf,
  4825.                                                 Environment *ev,
  4826.                                                ODFacet* facet,
  4827.                                                ODPoint* where)
  4828. {
  4829.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4830.     ContainerPartMethodDebug("ContainerPart","ContainerPartDragLeave");
  4831.  
  4832.     SOM_TRY
  4833.  
  4834. // [140007] :
  4835.     if(_fDropAccepted)
  4836.       InvertDragHilite( ev, facet );
  4837.  
  4838.     SOM_CATCH_ALL
  4839.     SOM_ENDTRY
  4840. }
  4841.  
  4842.  
  4843. SOM_Scope ODDropResult  SOMLINK ContainerPartDrop(ContainerPart *somSelf,
  4844.                                                    Environment *ev,
  4845.                                                   ODDragItemIterator* dropInfo,
  4846.                                                   ODFacet* facet,
  4847.                                                   ODPoint* where)
  4848. {
  4849.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  4850.     ContainerPartMethodDebug("ContainerPart","ContainerPartDrop");
  4851.  
  4852.     ODDropResult  dropResult = kODDropMove;
  4853.  
  4854.     SOM_TRY
  4855.  
  4856.     ODDraft       *theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  4857.     ODULong        attributes;
  4858.     ODPoint           delta;
  4859.     ODStorageUnit *dropSU;
  4860.     ODID           draggedFrameID;
  4861.     ODPart        *newPart;
  4862.     ODShape       *clipShape;
  4863.     ODTransform   *newExternalXForm;
  4864.     short         movePart;
  4865.     ODStorageUnitView   *dropView;
  4866.     ODStorageUnit       *renderedSU;
  4867.     ODBoolean  notDone = kODTrue;
  4868.  
  4869.     InvertDragHilite(ev, facet);  // presumably I've highlighted myself, so turn it off now.
  4870.  
  4871.     for (dropSU = dropInfo->First(ev); dropSU && notDone; dropSU = dropInfo->Next(ev))
  4872.     {
  4873.        // first thing is to check for dragitem value, can't do anything
  4874.        // more if it is not present...
  4875.        if ( !dropSU->Exists(ev, kODPropContents, (ODValueType)kODDragitem, 0))
  4876.           {
  4877.           // nothing to process... (bug)
  4878.           continue;
  4879.           }
  4880.  
  4881.        // get the dragitem (actual pm structure)
  4882.        dropSU->Focus(ev, kODPropContents, kODPosUndefined,
  4883.                              (ODValueType)kODDragitem,   0, kODPosUndefined);
  4884.        // create a view of our focused value for the drag manager
  4885.        ODStorageUnitView *dropView = dropSU->CreateView(ev);
  4886.  
  4887.        // ask the drag manager to get it for us
  4888.        ODBoolean success =
  4889.               _fSession->GetDragAndDrop(ev)->
  4890.                      GetDataFromDragManager(ev,
  4891.                                             dropView,
  4892.                                             /* szSelectedRMF, */          // [140007]
  4893.                                             &renderedSU );
  4894. //     ODDeleteObject(dropView);    // We should be able to do this, but it causes a trap.
  4895.                                     // This problem is under investigation.
  4896.        if (!success)
  4897.           {
  4898.           continue;
  4899.           }
  4900.  
  4901.        // NOTE: the target part must not free / release the renderedSU.
  4902.        // it will be cleaned up when we return from Drop() by the drag
  4903.        // manager.
  4904.  
  4905.        // Determine whether this is a Move/Copy operation. The drag manager
  4906.        // will have checked with PM to determine if the CTL key was depressed.
  4907.        attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
  4908.        movePart = (attributes & kODDropIsInSourceFrame) &&
  4909.                                         (attributes & kODDropIsMove);        // 132586 - allow copy op.
  4910.  
  4911.        if (movePart)
  4912.        {
  4913.           // Get where drag started and tweak our own structures to do the move.
  4914.           TempODTransform tempTrans = facet->AcquireWindowFrameTransform(ev, kODNULL); // [121802]
  4915.           ODPoint ms = _mouseStart;     // [137664]
  4916.           tempTrans->InvertPoint(ev, &ms);
  4917.           delta.x = where->x - ms.x;
  4918.           delta.y = where->y - ms.y;
  4919.           renderedSU->Focus(ev, kPropFrameInfo, kODPosUndefined, kFrameRef,
  4920.               0, kODPosFirstSib);
  4921.           StorageUnitGetValue(renderedSU, ev, sizeof(ODID), (ODValue) &draggedFrameID);
  4922.           Proxy* p = somSelf->ProxyForFrameID(ev, draggedFrameID);
  4923.  
  4924.           somSelf->InvalidateProxy(ev, p);
  4925.           p->transform->MoveBy(ev, &delta);
  4926.           _fNeedToExternalize = kODTrue;
  4927.           somSelf->CreateProxySelectionBorder(ev);
  4928.           somSelf->ClipEmbeddedFrames(ev, kODNULL );
  4929.           somSelf->InvalidateProxy(ev, p);
  4930.        }
  4931.        else
  4932.        {
  4933.           ODDraft *fromDraft = renderedSU->GetDraft( ev );
  4934.           ODDraftKey key;
  4935.           ODID newPartID;
  4936.           ODCloneKind        cloneKind;
  4937.  
  4938.           if (attributes & kODDropIsMove) {
  4939.              cloneKind = kODCloneDropMove;
  4940.              dropResult = kODDropMove;
  4941.           }
  4942.           else {
  4943.              cloneKind = kODCloneDropCopy;
  4944.              dropResult = kODDropCopy;
  4945.           }
  4946.  
  4947.           TRY 
  4948.              key = fromDraft->BeginClone(ev, theDraft,
  4949.                                          facet->GetFrame(ev), cloneKind);
  4950.              newPartID = fromDraft->Clone(ev, key, renderedSU->GetID(ev), 0, 0);
  4951.              fromDraft->EndClone(ev, key);
  4952.           CATCH_ALL       
  4953.              fromDraft->AbortClone(ev, key);
  4954.              RERAISE;
  4955.           ENDTRY
  4956.  
  4957.           ODPoint newTransPt = *where;
  4958.           // 146814 - use kODPropMouseDownOffset
  4959.           if (renderedSU->Exists(ev, kODPropMouseDownOffset, kODPoint, 0))
  4960.           {
  4961.              ODPoint offset;
  4962.              renderedSU->Focus(ev, kODPropMouseDownOffset, kODPosUndefined, kODPoint, 0, kODPosFirstSib);
  4963.              StorageUnitGetValue(renderedSU, ev, sizeof(offset), (ODValue) &offset);
  4964.              newTransPt.x -= offset.x;
  4965.              newTransPt.y -= offset.y;
  4966.           }
  4967.  
  4968.           newExternalXForm = facet->GetFrame(ev)->CreateTransform(ev);
  4969.           newExternalXForm->MoveBy(ev,  &newTransPt );
  4970.  
  4971.           TempODShape newFrameShape = kODNULL;
  4972.           if (renderedSU->Exists(ev, kODPropFrameShape, NULL, 0))
  4973.           {
  4974.  
  4975.              renderedSU->Focus(ev, kODPropFrameShape, kODPosUndefined, NULL, 1, kODPosUndefined);
  4976.              newFrameShape = facet->CreateShape(ev);
  4977.              newFrameShape->ReadShape(ev, renderedSU);
  4978.           }
  4979.           newPart = theDraft->AcquirePart(ev, newPartID );
  4980.  
  4981.           // We should be internalizing the frame from the storage unit
  4982.           somSelf->CreateProxyObject(ev,
  4983.                                      newFrameShape,
  4984.                                      newExternalXForm,
  4985.                                      newPart,
  4986.                                      kODFalse);
  4987.           newPart->Release(ev);
  4988.        }
  4989.     }
  4990.     somSelf->InvalidateSelection(ev, _fSelectionFrame);
  4991.     somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  4992.  
  4993.     SOM_CATCH_ALL
  4994.     SOM_ENDTRY
  4995.  
  4996.     return dropResult;
  4997. }
  4998.  
  4999. SOM_Scope ODExtension*  SOMLINK ContainerPartAcquireExtension(ContainerPart *somSelf,
  5000.                                                            Environment *ev,
  5001.                                                           ODType extensionName)
  5002. {
  5003.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5004.     ContainerPartMethodDebug("ContainerPart","ContainerPartAcquireExtension");
  5005.  
  5006.     SOM_TRY
  5007.  
  5008.     if(!strcmp(extensionName, kODSettingsExtension) ){
  5009.        if (!_fNotebook) {
  5010.           _fNotebook = new CNNotebook;
  5011.           _fNotebook->InitSettingsExtension( ev, _fPartWrapper);
  5012.        } /* endif */
  5013.        _fNotebook->Acquire(ev);
  5014.        return _fNotebook;
  5015.     }
  5016.     else if(!strcmp(extensionName, kODExtSemanticInterface) ){ //@127858
  5017.             _fSemtIntf->Acquire(ev);
  5018.             return _fSemtIntf;                                 //@127858
  5019.          }                                                     //@127858
  5020.     else {
  5021.        return ContainerPart_parent_ODPart_AcquireExtension(somSelf, ev, extensionName);
  5022.     } /* endif */
  5023.  
  5024.     SOM_CATCH_ALL
  5025.     SOM_ENDTRY
  5026.  
  5027.     return kODNULL;
  5028. }
  5029.  
  5030. SOM_Scope void  SOMLINK ContainerPartReleaseExtension(ContainerPart *somSelf,
  5031.                                                        Environment *ev,
  5032.                                                       ODExtension* extension)
  5033. {
  5034.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5035.     ContainerPartMethodDebug("ContainerPart","ContainerPartReleaseExtension");
  5036.  
  5037.     SOM_TRY
  5038.  
  5039.     if ( !extension ) return;
  5040.  
  5041.     if(_fNotebook == extension) {
  5042.        _fNotebook->Release( ev);
  5043.        _fNotebook = 0;
  5044.     }
  5045.  
  5046.     SOM_CATCH_ALL
  5047.     SOM_ENDTRY
  5048. }
  5049.  
  5050. SOM_Scope ODBoolean  SOMLINK ContainerPartHasExtension(ContainerPart *somSelf,
  5051.                                                         Environment *ev,
  5052.                                                        ODType extensionName)
  5053. {
  5054.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5055.     ContainerPartMethodDebug("ContainerPart","ContainerPartHasExtension");
  5056.  
  5057.     SOM_TRY
  5058.  
  5059.     if( !strcmp(extensionName, kODSettingsExtension) ||     //@127858
  5060.         !strcmp(extensionName, kODExtSemanticInterface) ) { //@127858
  5061.        return kODTrue;
  5062.     }
  5063.     else {
  5064.        return ContainerPart_parent_ODPart_HasExtension(somSelf, ev, extensionName);
  5065.     } /* endif */
  5066.  
  5067.     SOM_CATCH_ALL
  5068.     SOM_ENDTRY
  5069.  
  5070.     return kODFalse;
  5071. }
  5072.  
  5073. SOM_Scope void  SOMLINK ContainerPartContainingPartPropertiesUpdated(ContainerPart *somSelf,
  5074.                                                                       Environment *ev,
  5075.                                                                      ODFrame* frame,
  5076.                                                                      ODStorageUnit* propertyUnit)
  5077. {
  5078.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5079.     ContainerPartMethodDebug("ContainerPart","ContainerPartContainingPartPropertiesUpdated");
  5080.  
  5081.     // nothing to do yet
  5082. }
  5083.  
  5084. SOM_Scope ODStorageUnit*  SOMLINK ContainerPartAcquireContainingPartProperties(ContainerPart *somSelf,
  5085.                                                                             Environment *ev,
  5086.                                                                            ODFrame* frame)
  5087. {
  5088.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5089.     ContainerPartMethodDebug("ContainerPart","ContainerPartAcquireContainingPartProperties");
  5090.  
  5091.     // this part has no properties to return
  5092.     return kODNULL;
  5093.  
  5094. }
  5095.  
  5096. SOM_Scope ODMenuBar*  SOMLINK ContainerPartCreateRootMenuBar(ContainerPart *somSelf,
  5097.                                                               Environment *ev,
  5098.                                                              ODFrame* frame)
  5099. {
  5100.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5101.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateRootMenuBar");
  5102.  
  5103.     ODMenuBar * mb = new ODMenuBar;
  5104.     mb = kODNULL;
  5105.     return mb;
  5106.  
  5107. }
  5108.  
  5109. SOM_Scope ODBoolean  SOMLINK ContainerPartRevealFrame(ContainerPart *somSelf,
  5110.                                                        Environment *ev,
  5111.                                                       ODFrame* embeddedFrame,
  5112.                                                       ODShape* revealShape)
  5113. {
  5114.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5115.     ContainerPartMethodDebug("ContainerPart","ContainerPartRevealFrame");
  5116.  
  5117.     ODUnused(embeddedFrame);
  5118.     ODUnused(revealShape);
  5119.  
  5120.     return kODFalse;
  5121. }
  5122.  
  5123. SOM_Scope void  SOMLINK ContainerPartEmbeddedFrameSpec(ContainerPart *somSelf,
  5124.                                                         Environment *ev,
  5125.                                                        ODFrame* embeddedFrame,
  5126.                                                        ODObjectSpec* spec)
  5127. {
  5128.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5129.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameSpec");
  5130.  
  5131.     SOM_TRY
  5132.  
  5133.       ODUnused(embeddedFrame);
  5134.       ODUnused(spec);
  5135.       THROW(kODErrCannotEmbed);
  5136.  
  5137.     SOM_CATCH_ALL
  5138.     SOM_ENDTRY
  5139. }
  5140.  
  5141. SOM_Scope ODEmbeddedFramesIterator*  SOMLINK ContainerPartCreateEmbeddedFramesIterator(ContainerPart *somSelf,
  5142.                                                                                         Environment *ev,
  5143.                                                                                        ODFrame* frame)
  5144. {
  5145.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5146.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateEmbeddedFramesIterator");
  5147.  
  5148.     XEmbeddedFramesIterator *xefi = kODNULL;
  5149.  
  5150.     SOM_TRY
  5151.  
  5152.     xefi = new XEmbeddedFramesIterator();
  5153.     xefi->InitXEmbeddedFramesIterator( ev, _fEmbeddedFrames );
  5154.     return xefi;
  5155.  
  5156.     SOM_CATCH_ALL
  5157.        delete xefi;
  5158.     SOM_ENDTRY
  5159.  
  5160.     return kODNULL;
  5161. }
  5162.  
  5163. SOM_Scope void  SOMLINK ContainerPartDisplayFrameAdded(ContainerPart *somSelf,
  5164.                                                         Environment *ev,
  5165.                                                        ODFrame* frame)
  5166. {
  5167.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5168.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameAdded");
  5169.  
  5170.     SOM_TRY
  5171.  
  5172.     TempODPart tempPart = frame->AcquirePart(ev);
  5173.     if (tempPart == _fPartWrapper)    // frame belongs to me
  5174.     {
  5175.       // make an ebmedded frame in our new display frame for each proxy object.  
  5176.       // Since MakeEmbeddedFrame always puts the new frame at the top in the 
  5177.       // Z-order,  we'll create a collection with proxie elements in reverse
  5178.       // order and iterate through that.
  5179.  
  5180.       ODxOrderedCollection proxies;
  5181.       ODxOrderedCollectionIterator aIter(_fContents);
  5182.       for (Proxy* p = (Proxy*)aIter.First(); aIter.IsNotComplete(); p = (Proxy*)aIter.Next())
  5183.       {
  5184.          proxies.AddFirst(p);
  5185.       }
  5186.       ODxOrderedCollectionIterator bIter(&proxies);
  5187.       for (p = (Proxy*)bIter.First(); bIter.IsNotComplete(); p = (Proxy*)bIter.Next())
  5188.       {
  5189.          ODFrame* newFrame = somSelf->MakeEmbeddedFrame(ev, frame, p, kODFalse);
  5190.          ODReleaseObject(ev, newFrame);
  5191.       }
  5192.  
  5193.       // !!! do something with viewType and partInfo...
  5194.       PartInfoRec* pInfo = new PartInfoRec;
  5195.       pInfo->fGridOn = kODFalse;      //Default is grid off
  5196.       pInfo->partwindowID = (ODID)kODNULL;
  5197.       if (frame->IsRoot(ev))
  5198.         pInfo->fNeedsActivating = kODTrue;
  5199.  
  5200.       frame->SetPartInfo(ev, (ODInfoType) pInfo);
  5201.       _fDisplayFrames->AddLast(frame);
  5202.       frame->Acquire(ev);
  5203.       frame->SetDroppable(ev, kODTrue);
  5204.  
  5205.       _fNeedToExternalize = kODTrue;
  5206.  
  5207.       if (frame->GetViewType(ev) == kODNullTypeToken)            // if frame view is set don't change it
  5208.          frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));    // if not, make it viewasframe
  5209.       if (frame->GetPresentation(ev) == kODNullTypeToken)
  5210.          frame->SetPresentation(ev, _fSession->Tokenize(ev, kODPresDefault ));
  5211.     }
  5212.     else
  5213.     {
  5214.        THROW(kODErrInvalidFrame);
  5215.     }
  5216.  
  5217.     SOM_CATCH_ALL
  5218.     SOM_ENDTRY
  5219. }
  5220.  
  5221. SOM_Scope void  SOMLINK ContainerPartAttachSourceFrame(ContainerPart *somSelf,
  5222.                                                         Environment *ev,
  5223.                                                        ODFrame* frame,
  5224.                                                        ODFrame* sourceFrame)
  5225. {
  5226.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5227.     ContainerPartMethodDebug("ContainerPart","ContainerPartAttachSourceFrame");
  5228.  
  5229.     SOM_TRY
  5230.  
  5231.     if (_fDisplayFrames->Contains(frame)
  5232.        && sourceFrame && _fDisplayFrames->Contains(sourceFrame))
  5233.     {
  5234.         ODxOrderedCollectionIterator i(_fContents);
  5235.         for (Proxy* p = (Proxy*)i.First();
  5236.              i.IsNotComplete();
  5237.              p = (Proxy*)i.Next())
  5238.         {
  5239.            ODFrame* embFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, frame);
  5240.            ODFrame* embSourceFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, sourceFrame);
  5241.            p->part->AttachSourceFrame(ev, embFrame, embSourceFrame);
  5242.         }
  5243.     }
  5244.     else
  5245.       THROW(kODErrInvalidFrame);
  5246.  
  5247.     SOM_CATCH_ALL
  5248.     SOM_ENDTRY
  5249. }
  5250.  
  5251. SOM_Scope void  SOMLINK ContainerPartDisplayFrameRemoved(ContainerPart *somSelf,
  5252.                                                           Environment *ev,
  5253.                                                          ODFrame* frame)
  5254. {
  5255.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5256.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameRemoved");
  5257.  
  5258.     SOM_TRY
  5259.  
  5260.     if (frame != kODNULL ) {
  5261.       if (_fDisplayFrames->Contains(frame))
  5262.       {
  5263.         if (frame == _fSelectionFrame)
  5264.            somSelf->EmptySelection(ev);
  5265.  
  5266.         ODxOrderedCollection embeddedFrames;
  5267.         {
  5268.           ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
  5269.           for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  5270.               iter.IsNotComplete();
  5271.               embeddedFrame = (ODFrame*) iter.Next())
  5272.           {
  5273.             embeddedFrames.AddLast(embeddedFrame);
  5274.           }
  5275.         }
  5276.         ODxOrderedCollectionIterator iter(&embeddedFrames);
  5277.         for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  5278.             iter.IsNotComplete();
  5279.             embeddedFrame = (ODFrame*) iter.Next())
  5280.         {
  5281.           TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
  5282.           if (tempFrame == frame)
  5283.           {
  5284.             somSelf->RemoveEmbeddedFrame(ev, embeddedFrame);
  5285.           }
  5286.         }
  5287.  
  5288.         _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame);
  5289.  
  5290.         TempODFrame tempFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
  5291.         if ( frame == tempFrame )
  5292.         {
  5293.           _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
  5294.           somSelf->FocusLost(ev, _fClipboardFocus, frame);
  5295.         }
  5296.         TempODFrame tempF = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fStatusFocus);
  5297.         if ( frame == tempF ) // if have focus release it.
  5298.         {
  5299.            somSelf->FocusLost(ev, _fStatusFocus, frame);
  5300.         }
  5301.  
  5302.         PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  5303.         frame->SetPartInfo(ev, (ODInfoType) kODNULL);
  5304.         delete pInfo;
  5305.         _fDisplayFrames->Remove(frame);
  5306.         ODReleaseObject(ev, frame);
  5307.  
  5308.         _fNeedToExternalize = kODTrue;
  5309.  
  5310.         ODxOrderedCollectionIterator dIter(_fDisplayFrames);
  5311.         ODFrame*  displayFrame = (ODFrame*) dIter.First();
  5312.         if (dIter.IsNotComplete() == kODFalse) {
  5313.           //somSelf->DestroyPalette(ev);
  5314.         }
  5315.       }
  5316.       else
  5317.         THROW(kODErrInvalidFrame);
  5318.     }
  5319.     // any display frames left?
  5320.  
  5321.     SOM_CATCH_ALL
  5322.     SOM_ENDTRY
  5323. }
  5324.  
  5325. SOM_Scope void  SOMLINK ContainerPartDisplayFrameConnected(ContainerPart *somSelf,
  5326.                                                             Environment *ev,
  5327.                                                            ODFrame* frame)
  5328. {
  5329.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5330.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameConnected");
  5331.  
  5332.     SOM_TRY
  5333.  
  5334.   // $$$$$ add frame to fDisplayFrames if reference lazily internalized
  5335. // 137097 - aml
  5336.   if ( !_fDisplayFrames->Contains(frame) )
  5337.   {
  5338.     _fDisplayFrames->AddLast(frame);
  5339.     frame->Acquire(ev);
  5340.     frame->SetDroppable(ev, kODTrue);
  5341.  
  5342.   }
  5343.   PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  5344.   if (frame->IsRoot(ev))
  5345.     pInfo->fNeedsActivating = kODTrue;
  5346. // end 137097
  5347.  
  5348.     SOM_CATCH_ALL
  5349.     SOM_ENDTRY
  5350. }
  5351.  
  5352. SOM_Scope void  SOMLINK ContainerPartDisplayFrameClosed(ContainerPart *somSelf,
  5353.                                                          Environment *ev,
  5354.                                                         ODFrame* frame)
  5355. {
  5356.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5357.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameClosed");
  5358.  
  5359.     SOM_TRY
  5360.  
  5361.     if (_fDisplayFrames->Contains(frame))
  5362.     {
  5363.       if (frame == _fSelectionFrame)
  5364.          somSelf->EmptySelection(ev);
  5365.   
  5366.       ODxOrderedCollection embeddedFrames;
  5367.       {
  5368.         ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
  5369.         for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  5370.             iter.IsNotComplete();
  5371.             embeddedFrame = (ODFrame*) iter.Next())
  5372.         {
  5373.           embeddedFrames.AddLast(embeddedFrame);
  5374.         }
  5375.       }
  5376.  
  5377.       ODxOrderedCollectionIterator iter(&embeddedFrames);
  5378.       for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
  5379.           iter.IsNotComplete();
  5380.           embeddedFrame = (ODFrame*) iter.Next())
  5381.       {
  5382.         TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
  5383.         if (tempFrame == frame)
  5384.         {
  5385.            somSelf->CloseEmbeddedFrame(ev, embeddedFrame);
  5386.         }
  5387.       }
  5388.  
  5389.       _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
  5390.  
  5391.       TempODFrame tempFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
  5392.       if ( frame == tempFrame )
  5393.       {
  5394.         _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
  5395.         somSelf->FocusLost(ev, _fClipboardFocus, frame);
  5396.       }
  5397.  
  5398.       PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  5399.       delete pInfo;
  5400.       _fDisplayFrames->Remove(frame);
  5401.       ODReleaseObject(ev,frame);
  5402.       _fNeedToExternalize = kODTrue;
  5403.     }
  5404.     else
  5405.       THROW(kODErrInvalidFrame);
  5406.  
  5407.     SOM_CATCH_ALL
  5408.     SOM_ENDTRY
  5409. }
  5410.  
  5411. SOM_Scope void  SOMLINK ContainerPartFrameShapeChanged(ContainerPart *somSelf,
  5412.                                                         Environment *ev,
  5413.                                                        ODFrame* frame)
  5414. {
  5415.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5416.     ContainerPartMethodDebug("ContainerPart","ContainerPartFrameShapeChanged");
  5417.  
  5418.     SOM_TRY
  5419.  
  5420.     if (_fDisplayFrames->Contains(frame))
  5421.     {
  5422.        /// !!! should leave UsedShape and ActiveShape null to inherit FrameShape
  5423.        frame->ChangeUsedShape(ev, kODNULL, kODNULL);
  5424.     }
  5425.     else
  5426.       THROW(kODErrInvalidFrame);
  5427.  
  5428.     SOM_CATCH_ALL
  5429.     SOM_ENDTRY
  5430. }
  5431.  
  5432. SOM_Scope void  SOMLINK ContainerPartViewTypeChanged(ContainerPart *somSelf,
  5433.                                                       Environment *ev,
  5434.                                                      ODFrame* frame)
  5435. {
  5436.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5437.     ContainerPartMethodDebug("ContainerPart","ContainerPartViewTypeChanged");
  5438.  
  5439.     SOM_TRY
  5440.  
  5441.     if (_fDisplayFrames->Contains(frame))
  5442.       { /* $$$$$ change viewType of frame */ }
  5443.     else
  5444.       THROW(kODErrInvalidFrame);
  5445.  
  5446.     SOM_CATCH_ALL
  5447.     SOM_ENDTRY
  5448. }
  5449.  
  5450. SOM_Scope void  SOMLINK ContainerPartPresentationChanged(ContainerPart *somSelf,
  5451.                                                           Environment *ev,
  5452.                                                          ODFrame* frame)
  5453. {
  5454.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5455.     ContainerPartMethodDebug("ContainerPart","ContainerPartPresentationChanged");
  5456.  
  5457.     SOM_TRY
  5458.  
  5459.     if (_fDisplayFrames->Contains(frame))
  5460.       { /* $$$$$ change presentation of frame */ }
  5461.     else
  5462.       THROW(kODErrInvalidFrame);
  5463.  
  5464.     SOM_CATCH_ALL
  5465.     SOM_ENDTRY
  5466. }
  5467.  
  5468. SOM_Scope void  SOMLINK ContainerPartSequenceChanged(ContainerPart *somSelf,
  5469.                                                       Environment *ev,
  5470.                                                      ODFrame* frame)
  5471. {
  5472.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5473.     ContainerPartMethodDebug("ContainerPart","ContainerPartSequenceChanged");
  5474.  
  5475.     SOM_TRY
  5476.  
  5477.     ContainerPart_parent_ODPart_SequenceChanged(somSelf, ev,
  5478.                                                 frame);
  5479.  
  5480.     SOM_CATCH_ALL
  5481.     SOM_ENDTRY
  5482. }
  5483.  
  5484. SOM_Scope void  SOMLINK ContainerPartWritePartInfo(ContainerPart *somSelf,
  5485.                                                     Environment *ev,
  5486.                                                    ODInfoType partInfo,
  5487.                                                    ODStorageUnitView* storageUnitView)
  5488. {
  5489.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5490.     ContainerPartMethodDebug("ContainerPart","ContainerPartWritePartInfo");
  5491.  
  5492.     SOM_TRY
  5493.  
  5494.     if (partInfo)
  5495.     {
  5496.       ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  5497.       ODPropertyName propName = storageUnitView->GetProperty(ev);
  5498.  
  5499.       ODSUForceFocus(ev, su, propName, kKindTestContainer);
  5500.  
  5501.       ODBoolean needsGrid = ((PartInfoRec*)partInfo)->fGridOn;
  5502.       StorageUnitSetValue(su, ev, sizeof(ODBoolean),
  5503.                     (ODValue)&needsGrid);
  5504.     }
  5505.  
  5506.     SOM_CATCH_ALL
  5507.     SOM_ENDTRY
  5508. }
  5509.  
  5510. SOM_Scope ODInfoType SOMLINK ContainerPartReadPartInfo(ContainerPart *somSelf,
  5511.                                                     Environment *ev,
  5512.                                                    ODFrame* frame,
  5513.                                                    ODStorageUnitView* storageUnitView)
  5514. {
  5515.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5516.     ContainerPartMethodDebug("ContainerPart","ContainerPartReadPartInfo");
  5517.  
  5518.     PartInfoRec* partInfo = kODNULL;
  5519.  
  5520.     SOM_TRY
  5521.  
  5522.     ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  5523.     ODPropertyName propName = storageUnitView->GetProperty(ev);
  5524.  
  5525.     partInfo = new PartInfoRec;
  5526.     ODBoolean needsGrid = kODTrue;
  5527.  
  5528.     if ( ODSUExistsThenFocus(ev, su, propName, kKindTestContainer) )
  5529.     {
  5530.       StorageUnitGetValue(su, ev, sizeof(ODBoolean),
  5531.                     (ODValue)&(needsGrid));
  5532.     }
  5533.     else
  5534.     {
  5535.       WARN("Persistent partInfo is missing from this frame. Making one up.");
  5536.     }
  5537.     partInfo->fGridOn = needsGrid;
  5538.  
  5539.     SOM_CATCH_ALL
  5540.        ODDeleteObject(partInfo);
  5541.     SOM_ENDTRY
  5542.  
  5543.     return (ODInfoType) partInfo;
  5544. }
  5545.  
  5546. SOM_Scope void  SOMLINK ContainerPartClonePartInfo(ContainerPart *somSelf, Environment *ev,
  5547.     ODDraftKey key,
  5548.     ODInfoType partInfo,
  5549.     ODStorageUnitView* storageUnitView,
  5550.     ODFrame* scopeFrame)
  5551. {
  5552.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5553.     ContainerPartMethodDebug("ContainerPart","ContainerPartClonePartInfo");
  5554.  
  5555.     SOM_TRY
  5556.  
  5557.   if (partInfo)
  5558.   {
  5559.     ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  5560.     ODPropertyName propName = storageUnitView->GetProperty(ev);
  5561.  
  5562.     ODSUForceFocus(ev, su, propName, kKindTestContainer);
  5563.  
  5564.       ODBoolean needsGrid = ((PartInfoRec*)partInfo)->fGridOn;
  5565.  
  5566.       StorageUnitSetValue(su, ev, sizeof(ODBoolean),
  5567.                     (ODValue)&needsGrid);
  5568.   }
  5569.  
  5570.     SOM_CATCH_ALL
  5571.     SOM_ENDTRY
  5572. }
  5573.  
  5574. SOM_Scope ODID  SOMLINK ContainerPartOpen(ContainerPart *somSelf,
  5575.                                            Environment *ev, ODFrame* frame)
  5576. {
  5577.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5578.     ContainerPartMethodDebug("ContainerPart","ContainerPartOpen");
  5579.  
  5580.     ODID windowID = 0;
  5581.  
  5582.     SOM_TRY
  5583.  
  5584.     TempODWindow window = kODNULL;
  5585.     if (frame) // Doing a View As Window or Open Root
  5586.     {
  5587.       if (frame->IsRoot(ev))  // Create Window For Root Frame
  5588.       {
  5589.          WindowProperties props;
  5590.          BeginGetWindowProperties(ev, frame, &props);
  5591.  
  5592.          ODULong flCreateFlags = props.createFlags ? props.createFlags :
  5593.                                                        ODPlatformWindowDefaultCreateOptions;
  5594.  
  5595.          HWND hwndFrame = _fSession->CreatePlatformWindow(ev, flCreateFlags);
  5596.          // position the window to shape it was closed in
  5597.          // defect 117197 open from file in some position/properties as was saved
  5598.          WinSetWindowPos(hwndFrame, HWND_TOP, props.boundsRect.xLeft,
  5599.                                            props.boundsRect.yBottom,
  5600.                                            props.boundsRect.xRight,
  5601.                                            props.boundsRect.yTop,(SWP_SIZE | SWP_MOVE|props.swpFlags ));
  5602.          // defect 117197 end code added
  5603.  
  5604.          window =  _fSession->GetWindowState(ev)->RegisterWindowForFrame(ev, hwndFrame,
  5605.                                              frame,
  5606.                                               props.isRootWindow, // Keeps draft open
  5607.                                               kODTrue,   // Is resizable
  5608.                                               kODFalse,  // Is floating
  5609.                                              kODTrue, // should save
  5610.                                              kODTrue, // should dispose
  5611.                                              props.sourceFrame);
  5612.          EndGetWindowProperties(ev, &props); // Release source frame
  5613.          window->Open(ev);
  5614.          window->Show(ev);
  5615.       }
  5616.       else  // View In Window
  5617.       {
  5618.          window = _fSession->GetWindowState(ev)->AcquireWindow(ev, _fWindowID);
  5619.          if (window)
  5620.             window->Select(ev);
  5621.          else
  5622.          {
  5623.             window = somSelf->CreateWindow(ev, frame);
  5624.             _fWindowID = window->GetID(ev);
  5625.             window->Open(ev);
  5626.             window->Show(ev);
  5627.             window->Select(ev);
  5628.          }
  5629.       }
  5630.     }
  5631.     else
  5632.     {
  5633.       window = somSelf->CreateWindow(ev, frame);
  5634.       _fWindowID = window->GetID(ev);
  5635.       window->Open(ev);
  5636.       window->Show(ev);
  5637.       window->Select(ev);
  5638.     }
  5639.     windowID = window->GetID(ev);
  5640.  
  5641.     SOM_CATCH_ALL
  5642.     SOM_ENDTRY
  5643.  
  5644.     return windowID;
  5645. }
  5646.  
  5647. SOM_Scope ODFrame*  SOMLINK ContainerPartRequestEmbeddedFrame(ContainerPart *somSelf,
  5648.                                                                Environment *ev,
  5649.                                                               ODFrame* containingFrame,
  5650.                                                               ODFrame* baseFrame,
  5651.                                                               ODShape* frameShape,
  5652.                                                               ODPart* embedPart,
  5653.                                                               ODTypeToken viewType,
  5654.                                                               ODTypeToken presentation,
  5655.                                                               ODBoolean isOverlaid)
  5656. {
  5657.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5658.     ContainerPartMethodDebug("ContainerPart","ContainerPartRequestEmbeddedFrame");
  5659.  
  5660.     return kODNULL;
  5661. }
  5662.  
  5663. SOM_Scope void  SOMLINK ContainerPartRemoveEmbeddedFrame(ContainerPart *somSelf,
  5664.                                                           Environment *ev,
  5665.                                                          ODFrame* embeddedFrame)
  5666. {
  5667.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5668.     ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveEmbeddedFrame");
  5669.  
  5670.     SOM_TRY
  5671.  
  5672.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  5673.     {
  5674.  
  5675.        TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
  5676.        Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  5677.        if (p)
  5678.        {
  5679.           _fNeedToExternalize = kODTrue;
  5680.           _fEmbeddedFrames->Remove(embeddedFrame);
  5681.           p->Remove(embeddedFrame);
  5682.           embeddedFrame->Remove(ev);
  5683.        }
  5684.        if (containingFrame) {
  5685.           containingFrame->Invalidate(ev,NULL,kODNULL);
  5686.        } /* endif */
  5687.     }
  5688.     else
  5689.       THROW(kODErrInvalidFrame);
  5690.  
  5691.     SOM_CATCH_ALL
  5692.     SOM_ENDTRY
  5693. }
  5694.  
  5695. SOM_Scope void  SOMLINK ContainerPartCloseEmbeddedFrame(ContainerPart *somSelf,
  5696.                                                         Environment *ev,
  5697.                                                         ODFrame* embeddedFrame)
  5698. {
  5699.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5700.     ContainerPartMethodDebug("ContainerPart","ContainerPartCloseEmbeddedFrame");
  5701.  
  5702.     SOM_TRY
  5703.  
  5704.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  5705.     {
  5706.  
  5707.        TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
  5708.        Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  5709.        if (p)
  5710.        {
  5711.           _fNeedToExternalize = kODTrue;
  5712.           _fEmbeddedFrames->Remove(embeddedFrame);
  5713.           p->Remove(embeddedFrame);
  5714.           embeddedFrame->Close(ev);
  5715.        }
  5716.        if (containingFrame) {
  5717.           containingFrame->Invalidate(ev,NULL,kODNULL);
  5718.        } /* endif */
  5719.     }
  5720.     else
  5721.       THROW(kODErrInvalidFrame);
  5722.  
  5723.     SOM_CATCH_ALL
  5724.     SOM_ENDTRY
  5725. }
  5726.  
  5727. SOM_Scope ODShape*  SOMLINK ContainerPartRequestFrameShape(ContainerPart *somSelf,
  5728.                                                             Environment *ev,
  5729.                                                            ODFrame* embeddedFrame,
  5730.                                                            ODShape* frameShape)
  5731. {
  5732.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5733.     ContainerPartMethodDebug("ContainerPart","ContainerPartRequestFrameShape");
  5734.  
  5735.     SOM_TRY
  5736.  
  5737.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  5738.     {  // find frame proxy
  5739.       Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  5740.       if (p && !p->settingFrameShapes)  
  5741.       {
  5742.          p->shape->CopyFrom(ev, frameShape);
  5743.          if (somSelf->NormalizeProxyGeometry(ev, p))
  5744.             frameShape->CopyFrom(ev, p->shape);
  5745.       }
  5746.     }
  5747.     else
  5748.       THROW(kODErrInvalidFrame);
  5749.  
  5750.     SOM_CATCH_ALL
  5751.     SOM_ENDTRY
  5752.  
  5753.     return frameShape;
  5754. }
  5755.  
  5756. SOM_Scope void  SOMLINK ContainerPartUsedShapeChanged(ContainerPart *somSelf,
  5757.                                                        Environment *ev,
  5758.                                                       ODFrame* embeddedFrame)
  5759. {
  5760.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5761.     ContainerPartMethodDebug("ContainerPart","ContainerPartUsedShapeChanged");
  5762.  
  5763.     SOM_TRY
  5764.  
  5765.     if (_fEmbeddedFrames->Contains(embeddedFrame))
  5766.     {
  5767.         Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
  5768.         if (p->settingFrameShapes == kODFalse)
  5769.         {
  5770.            // prevent recursion problems in case part tries
  5771.            // to engage in frame negotiation.
  5772.            p->settingFrameShapes = kODTrue;
  5773.  
  5774.            ODxOrderedCollectionIterator i(p);
  5775.            for (ODFrame* frame = (ODFrame*)i.First();
  5776.                 i.IsNotComplete();
  5777.                 frame = (ODFrame*)i.Next())
  5778.            {
  5779.               TempODShape shape = frame->AcquireFrameShape(ev, kODNULL);
  5780.               if (!shape->IsSameAs(ev, p->shape))
  5781.                  frame->ChangeFrameShape(ev, p->shape, kODNULL);
  5782.            }
  5783.            p->settingFrameShapes = kODFalse;
  5784.         }
  5785.         embeddedFrame->Invalidate(ev, kODNULL, kODNULL);
  5786. // AML: [108305]
  5787.         if (_fSelection->Contains(p)) {
  5788.            TempODFrame ownerFrame = embeddedFrame->AcquireContainingFrame(ev);
  5789.            somSelf->InvalidateSelection(ev, ownerFrame);
  5790.            somSelf->CreateProxySelectionBorder(ev);
  5791.            somSelf->InvalidateSelection(ev, ownerFrame);
  5792.         }
  5793. // end [108305]
  5794.         TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
  5795.         somSelf->ClipEmbeddedFrames(ev, kODNULL);
  5796.         somSelf->Invalidate(ev);
  5797.     }
  5798.     else
  5799.       THROW(kODErrInvalidFrame);
  5800.  
  5801.     SOM_CATCH_ALL
  5802.     SOM_ENDTRY
  5803.  
  5804. }
  5805.  
  5806. SOM_Scope ODShape*  SOMLINK ContainerPartAdjustBorderShape(ContainerPart *somSelf,
  5807.                                                             Environment *ev,
  5808.                                                            ODFacet* embeddedFacet,
  5809.                                                            ODShape* shape)
  5810. {
  5811.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5812.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustBorderShape");
  5813.  
  5814.     SOM_TRY
  5815.  
  5816.     ODFacet* containingFacet = embeddedFacet->GetContainingFacet(ev);
  5817.     ODFacetIterator* facets = containingFacet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  5818.  
  5819.     TempODTransform transform = embeddedFacet->AcquireFrameTransform(ev, kODNULL);
  5820.     shape->Transform(ev, transform);
  5821.     ODBoolean above = kODFalse;
  5822.  
  5823.     for (ODFacet* embFacet = facets->First(ev);
  5824.           facets->IsNotComplete(ev) && embFacet != embeddedFacet;
  5825.           embFacet = facets->Next(ev))
  5826.     {
  5827.        TempODShape usedShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL));
  5828.        TempODTransform xform = embFacet->AcquireFrameTransform(ev, kODNULL);
  5829.        usedShape->Transform(ev, xform);
  5830.        shape->Subtract(ev, usedShape);
  5831.     }
  5832.     delete facets;
  5833.  
  5834.     shape->InverseTransform(ev, transform);
  5835.  
  5836.     shape->Acquire(ev);
  5837.  
  5838.     SOM_CATCH_ALL
  5839.     SOM_ENDTRY
  5840.  
  5841.     return shape;
  5842. }
  5843.  
  5844. SOM_Scope void  SOMLINK ContainerPartFacetAdded(ContainerPart *somSelf,
  5845.                                                  Environment *ev,
  5846.                                                 ODFacet* facet)
  5847. {
  5848.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5849.     ContainerPartMethodDebug("ContainerPart","ContainerPartFacetAdded");
  5850.  
  5851.     SOM_TRY
  5852.  
  5853.     ODFrame* dispFrame = facet->GetFrame(ev);
  5854.     if (!_fDisplayFrames->Contains(dispFrame))
  5855.       THROW(kODErrInvalidFacet);
  5856.  
  5857. // 121161 :
  5858.     FacetInfoRec* pInfo = new FacetInfoRec(); // 124243
  5859.     pInfo->fClipShape = facet->CreateShape(ev);
  5860.     ODRect emptyRect(0,0,0,0);
  5861.     pInfo->fClipShape->SetRectangle(ev,&emptyRect);
  5862.     facet->SetPartInfo(ev, (ODInfoType)pInfo);
  5863. // end 121161
  5864.  
  5865.     ODxOrderedCollectionIterator frames(_fEmbeddedFrames);
  5866.     for (ODFrame* frame = (ODFrame*) frames.First();
  5867.         frames.IsNotComplete();
  5868.         frame = (ODFrame*) frames.Next())
  5869.     {
  5870.       TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
  5871.  
  5872.       if (tempFrame == dispFrame)
  5873.       {
  5874.         TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
  5875.         TempODShape clip = frameShape->Copy(ev);
  5876.         TempODTransform xform = somSelf->ProxyForFrame(ev, frame)->transform->Copy(ev);
  5877.         ODFacet * newFacet = facet->CreateEmbeddedFacet(ev, frame, clip, xform,
  5878.                       kODNULL, kODNULL, kODNULL, kODFrameBehind);
  5879.  
  5880.         ODHighlight highlight = facet->GetHighlight(ev);
  5881.         if( highlight != kODNoHighlight)
  5882.            newFacet->ChangeHighlight(ev, highlight);
  5883.       }
  5884.     }
  5885.  
  5886.     SOM_CATCH_ALL
  5887.     SOM_ENDTRY
  5888. }
  5889.  
  5890. SOM_Scope void  SOMLINK ContainerPartFacetRemoved(ContainerPart *somSelf,
  5891.                                                    Environment *ev,
  5892.                                                   ODFacet* facet)
  5893. {
  5894.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5895.     ContainerPartMethodDebug("ContainerPart","ContainerPartFacetRemoved");
  5896.  
  5897.     SOM_TRY
  5898.  
  5899.     ODFrame* dispFrame = facet->GetFrame(ev);
  5900.     if (!_fDisplayFrames->Contains(dispFrame))
  5901.       THROW(kODErrInvalidFacet);
  5902.  
  5903. // 121161 :
  5904.     FacetInfoRec *pInfo = (FacetInfoRec *)facet->GetPartInfo(ev); // 124243
  5905.     if(pInfo) {
  5906.         ODReleaseObject(ev,pInfo->fClipShape);
  5907.         delete pInfo;
  5908.         facet->SetPartInfo(ev, (ODInfoType) kODNULL);
  5909.     }
  5910. // end 121161
  5911.     ODxOrderedCollection children;
  5912.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  5913.     for (ODFacet* childFacet = facets->First(ev);
  5914.       facets->IsNotComplete(ev);
  5915.       childFacet = facets->Next(ev))
  5916.     {
  5917.       children.AddLast(childFacet);
  5918.     }
  5919.     delete facets;
  5920.     ODxOrderedCollectionIterator iter(&children);
  5921.     for (childFacet = (ODFacet*)iter.First();
  5922.         iter.IsNotComplete();
  5923.         childFacet = (ODFacet*)iter.Next())
  5924.     {
  5925.       facet->RemoveFacet(ev, childFacet);
  5926.       delete childFacet;
  5927.     }
  5928.  
  5929.     SOM_CATCH_ALL
  5930.     SOM_ENDTRY
  5931. }
  5932.  
  5933. SOM_Scope void  SOMLINK ContainerPartCanvasChanged(ContainerPart *somSelf,
  5934.                                                     Environment *ev,
  5935.                                                    ODFacet* facet)
  5936. {
  5937.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5938.     ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasChanged");
  5939.  
  5940. }
  5941.  
  5942. SOM_Scope void  SOMLINK ContainerPartGeometryChanged(ContainerPart *somSelf,
  5943.                                                       Environment *ev,
  5944.                                                      ODFacet* facet,
  5945.                                                      ODBoolean clipShapeChanged,
  5946.                                                      ODBoolean externalTransformChanged)
  5947. {
  5948.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5949.     ContainerPartMethodDebug("ContainerPart","ContainerPartGeometryChanged");
  5950.  
  5951. }
  5952.  
  5953. SOM_Scope void  SOMLINK ContainerPartDraw(ContainerPart *somSelf,
  5954.                                            Environment *ev, ODFacet* facet,
  5955.                                           ODShape* invalidShape)
  5956. {
  5957.  
  5958.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  5959.     ContainerPartMethodDebug("ContainerPart","ContainerPartDraw");
  5960.  
  5961.     SOM_TRY
  5962.  
  5963.     ODFrame* displayFrame = facet->GetFrame(ev);
  5964.     if (_fDisplayFrames->Contains(displayFrame))
  5965.     {
  5966.       PartInfoRec* pInfo = (PartInfoRec*) displayFrame->GetPartInfo(ev);
  5967.  
  5968.       if (facet->GetFrame(ev)->GetPresentation(ev) == _fSession->Tokenize(ev, kODPresDefault))
  5969.       {
  5970.          ODTypeToken curView = displayFrame->GetViewType(ev);
  5971.  
  5972.          if (curView == _fSession->Tokenize(ev, kODViewAsFrame)  ||
  5973.                 curView == _fSession->Tokenize(ev, kODViewAsThumbnail ))
  5974.          {
  5975.             // Get the frame rectangle
  5976.  
  5977.             ODRect rect;
  5978.             TempODShape shape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev)); // [121801]
  5979.             shape->GetBoundingBox(ev, &rect);
  5980.             RECTL frameRect;
  5981.             rect.AsRECTL(frameRect);
  5982.  
  5983.             // Set up the drawing environment
  5984.             // 121161:
  5985.             FacetInfoRec *facetInfo = (FacetInfoRec *)facet->GetPartInfo(ev); // 124243
  5986.             // end 121161
  5987.  
  5988.             ODBoolean bActive = kODFalse;       // [131094] starts
  5989.             PartInfoRec* pInfo1 = (PartInfoRec*) facet->GetFrame(ev)->GetPartInfo(ev);
  5990.             if ( pInfo1->fIsActive )
  5991.                 bActive = kODTrue;              // [131094] ends
  5992.  
  5993.             HPS hpsDraw;
  5994.             HRGN hrgnClip, hrgnOld, hrgnAggClip;
  5995.             CFocus f(ev, facet, invalidShape, &hpsDraw, &hrgnAggClip);
  5996.  
  5997.             ODShape* clipShape = (facetInfo) ? facetInfo->fClipShape : kODNULL;
  5998.             hrgnClip = GpiCreateRegion(hpsDraw, 0, 0);
  5999.             GpiCombineRegion(hpsDraw, hrgnClip, hrgnAggClip, 0, CRGN_COPY);
  6000.             if (clipShape)
  6001.             {
  6002.                TempODTransform xform = facet->AcquireContentTransform(ev, kODNULL);
  6003.                TempODShape tempShape = clipShape->Copy(ev);
  6004.                tempShape->Transform(ev, xform);
  6005.                GpiCombineRegion(hpsDraw, hrgnClip, hrgnClip, tempShape->GetRegion(ev), CRGN_DIFF);
  6006.             }
  6007.             GpiSetClipRegion(hpsDraw, hrgnClip, &hrgnOld);
  6008.  
  6009.  
  6010.             // paint the background
  6011.  
  6012.             GpiSetColor(hpsDraw, _fBGColor);
  6013.             POINTL ptl = {0, 0};
  6014.             GpiMove(hpsDraw, &ptl);
  6015.             ptl.x = frameRect.xRight;
  6016.             ptl.y = frameRect.yTop;
  6017.             GpiBox(hpsDraw, DRO_FILL, &ptl, 0, 0);
  6018.             GpiSetLineType(hpsDraw, LINETYPE_DOT);
  6019.             GpiSetColor(hpsDraw, CLR_BLACK);
  6020.             GpiBox(hpsDraw, DRO_OUTLINE, &ptl, 0, 0);
  6021.  
  6022.             if (pInfo->fGridOn){
  6023.                for (int y = YGRID / 2; y < frameRect.yTop; y += YGRID) {
  6024.                   ptl.y = y;
  6025.                   ptl.x = 0;
  6026.                   GpiMove(hpsDraw, &ptl);
  6027.                   ptl.x = frameRect.xRight;
  6028.                   GpiLine(hpsDraw, &ptl);
  6029.                }
  6030.  
  6031.                for (int x = XGRID / 2; x < frameRect.xRight; x += XGRID) {
  6032.                   ptl.x = x;
  6033.                   ptl.y = 0;
  6034.                   GpiMove(hpsDraw, &ptl);
  6035.                   ptl.y = frameRect.yTop;
  6036.                   GpiLine(hpsDraw, &ptl);
  6037.                }
  6038.             } /* endif fGridOn    (rlt) 4-26-95 */
  6039.             // highlite the selected frame.
  6040.  
  6041.             if (displayFrame == _fSelectionFrame )
  6042.             {  // drawing active frame - highlight selection
  6043.                if ( bActive )            
  6044.                {
  6045.                   GpiSetClipRegion(hpsDraw, hrgnAggClip, &hrgnOld);
  6046.                   ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODBackToFront);
  6047.                   for (ODFacet* embFacet = facets->First(ev);
  6048.                        facets->IsNotComplete(ev);
  6049.                        embFacet = facets->Next(ev))
  6050.                   {
  6051.                      embFacet->Update(ev, kODNULL, kODNULL);
  6052.                   }
  6053.                   somSelf->HighlightSelection(ev, facet);
  6054.                }                                      
  6055.             }
  6056.             else
  6057.             {  // drawing inactive frame - do nothing for now
  6058.             }
  6059.             GpiSetClipRegion(hpsDraw, 0, &hrgnOld);
  6060.             GpiDestroyRegion(hpsDraw, hrgnClip);
  6061.             GpiDestroyRegion(hpsDraw, hrgnAggClip);
  6062.          }
  6063.          else if (curView == _fSession->Tokenize(ev, kODViewAsLargeIcon))
  6064.          {
  6065.             /* Render as large Icon */
  6066.          }
  6067.          else if (curView == _fSession->Tokenize(ev, kODViewAsSmallIcon))
  6068.          {
  6069.             /* Render as small icon */
  6070.          }
  6071.       }
  6072.     }
  6073.     else
  6074.     {
  6075.       // !!! signal error: invalid frame
  6076.     }
  6077.  
  6078.     SOM_CATCH_ALL
  6079.     SOM_ENDTRY
  6080. }
  6081.  
  6082. SOM_Scope void  SOMLINK ContainerPartCanvasUpdated(ContainerPart *somSelf,
  6083.                                                     Environment *ev,
  6084.                                                    ODCanvas* canvas)
  6085. {
  6086.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6087.     ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasUpdated");
  6088.  
  6089. }
  6090.  
  6091. SOM_Scope void  SOMLINK ContainerPartHighlightChanged(ContainerPart *somSelf,
  6092.                                                        Environment *ev,
  6093.                                                       ODFacet* facet)
  6094. {
  6095.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6096.     ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightChanged");
  6097.  
  6098.     SOM_TRY
  6099.  
  6100.     ODHighlight highlight = facet->GetHighlight(ev);
  6101.  
  6102.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  6103.     for (ODFacet* embFacet = facets->First(ev);
  6104.           facets->IsNotComplete(ev);
  6105.           embFacet = facets->Next(ev))
  6106.     {
  6107.         embFacet->ChangeHighlight(ev, highlight);
  6108.     }
  6109.     /*
  6110.      * cause ourselves to be redrawn.  FocusLib will take care of setting the
  6111.      * default mix mode so that we paint properly.
  6112.      */
  6113.     facet->Invalidate(ev, kODNULL, kODNULL);
  6114.  
  6115.     SOM_CATCH_ALL
  6116.     SOM_ENDTRY
  6117. }
  6118.  
  6119. SOM_Scope ODULong  SOMLINK ContainerPartGetPrintResolution(ContainerPart *somSelf, Environment *ev,
  6120.     ODFrame* frame)
  6121. {
  6122.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6123.     ContainerPartMethodDebug("ContainerPart","GetPrintResolution");
  6124.  
  6125.   ODUnused(frame);
  6126.  
  6127.   return 0;
  6128. }
  6129.  
  6130. SOM_Scope ODLinkSource*  SOMLINK ContainerPartCreateLink(ContainerPart *somSelf,
  6131.                                                     Environment *ev,
  6132.                                                    ODByteArray* data)
  6133. {
  6134.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6135.     ContainerPartMethodDebug("ContainerPart","ContainerPartCreateLink");
  6136.  
  6137.     return kODNULL;
  6138.  
  6139. }
  6140.  
  6141. SOM_Scope void  SOMLINK ContainerPartLinkUpdated(ContainerPart *somSelf,
  6142.                                                   Environment *ev,
  6143.                                                  ODLink* updatedLink,
  6144.                                                  ODUpdateID id)
  6145. {
  6146.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6147.     ContainerPartMethodDebug("ContainerPart","ContainerPartLinkUpdated");
  6148.  
  6149. }
  6150.  
  6151. SOM_Scope void  SOMLINK ContainerPartRevealLink(ContainerPart *somSelf,
  6152.                                                  Environment *ev,
  6153.                                                 ODLinkSource* linkSource)
  6154. {
  6155.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6156.     ContainerPartMethodDebug("ContainerPart","ContainerPartRevealLink");
  6157.  
  6158. }
  6159.  
  6160. SOM_Scope void  SOMLINK ContainerPartBreakLink(ContainerPart *somSelf,
  6161.                                                Environment *ev,
  6162.                                               ODLink* link)
  6163. {
  6164.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6165.     ContainerPartMethodDebug("ContainerPart","ContainerPartBreakLink");
  6166.  
  6167. }
  6168.  
  6169. SOM_Scope void  SOMLINK ContainerPartBreakLinkSource(ContainerPart *somSelf,
  6170.                                                      Environment *ev,
  6171.                                                     ODLinkSource* linkSource)
  6172. {
  6173.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6174.     ContainerPartMethodDebug("ContainerPart","ContainerPartBreakLinkSource");
  6175.  
  6176. }
  6177.  
  6178. SOM_Scope void  SOMLINK ContainerPartLinkBroken(ContainerPart *somSelf,
  6179.                                                 Environment *ev,
  6180.                                                ODLink* link)
  6181. {
  6182.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6183.     ContainerPartMethodDebug("ContainerPart","ContainerPartLinkBroken");
  6184.  
  6185. }
  6186.  
  6187. SOM_Scope void  SOMLINK ContainerPartUpdateFromLinkSource(ContainerPart *somSelf,
  6188.                                                           Environment *ev,
  6189.                                                          ODLinkSource* linkSource)
  6190. {
  6191.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6192.     ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateFromLinkSource");
  6193.  
  6194. }
  6195.  
  6196. SOM_Scope void  SOMLINK ContainerPartShowLink(ContainerPart *somSelf,
  6197.                                               Environment *ev,
  6198.                                              ODLink* link)
  6199. {
  6200.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6201.     ContainerPartMethodDebug("ContainerPart","ContainerPartShowLink");
  6202.  
  6203. }
  6204.  
  6205.  
  6206. SOM_Scope void  SOMLINK ContainerPartEmbeddedFrameUpdated(ContainerPart *somSelf,
  6207.                                                            Environment *ev,
  6208.                                                           ODFrame* frame,
  6209.                                                           ODUpdateID change)
  6210. {
  6211.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6212.     ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameUpdated");
  6213.  
  6214. }
  6215.  
  6216. SOM_Scope void  SOMLINK ContainerPartLinkStatusChanged(ContainerPart *somSelf,
  6217.                                                         Environment *ev,
  6218.                                                        ODFrame* frame)
  6219. {
  6220.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6221.     ContainerPartMethodDebug("ContainerPart","ContainerPartLinkStatusChanged");
  6222.  
  6223. }
  6224.  
  6225. SOM_Scope ODBoolean  SOMLINK ContainerPartBeginRelinquishFocus(ContainerPart *somSelf,
  6226.                                                                 Environment *ev,
  6227.                                                                ODTypeToken focus,
  6228.                                                                ODFrame* ownerFrame,
  6229.                                                                ODFrame* proposedFrame)
  6230. {
  6231.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6232.     ContainerPartMethodDebug("ContainerPart","ContainerPartBeginRelinquishFocus");
  6233.  
  6234.     return kODTrue;
  6235.  
  6236. }
  6237.  
  6238. SOM_Scope void  SOMLINK ContainerPartCommitRelinquishFocus(ContainerPart *somSelf,
  6239.                                                             Environment *ev,
  6240.                                                            ODTypeToken focus,
  6241.                                                            ODFrame* ownerFrame,
  6242.                                                            ODFrame* proposedFrame)
  6243. {
  6244.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6245.     ContainerPartMethodDebug("ContainerPart","ContainerPartCommitRelinquishFocus");
  6246.  
  6247.     SOM_TRY
  6248.  
  6249.     somSelf->FocusLost(ev, focus, ownerFrame);
  6250.  
  6251.     SOM_CATCH_ALL
  6252.     SOM_ENDTRY
  6253. }
  6254.  
  6255. SOM_Scope void  SOMLINK ContainerPartAbortRelinquishFocus(ContainerPart *somSelf,
  6256.                                                            Environment *ev,
  6257.                                                           ODTypeToken focus,
  6258.                                                           ODFrame* ownerFrame,
  6259.                                                           ODFrame* proposedFrame)
  6260. {
  6261.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6262.     ContainerPartMethodDebug("ContainerPart","ContainerPartAbortRelinquishFocus");
  6263.  
  6264. }
  6265.  
  6266. SOM_Scope void  SOMLINK ContainerPartFocusAcquired(ContainerPart *somSelf,
  6267.                                                     Environment *ev,
  6268.                                                    ODTypeToken focus,
  6269.                                                    ODFrame* ownerFrame)
  6270. {
  6271.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6272.     ContainerPartMethodDebug("ContainerPart","ContainerPartFocusAcquired");
  6273.  
  6274.     SOM_TRY
  6275.  
  6276.    ODArbitrator* arbitrator =  somSelf->GetStorageUnit(ev)->GetSession(ev)
  6277.                   ->GetArbitrator(ev);
  6278.  
  6279.    if ( focus == _fMenuFocus || focus == _fSelectionFocus )
  6280.    {
  6281.       if ( arbitrator->RequestFocusSet(ev, _fFocusSet, ownerFrame) )
  6282.       {
  6283.          somSelf->PartActivated(ev, ownerFrame);
  6284.       }
  6285.    }
  6286.  
  6287.     SOM_CATCH_ALL
  6288.     SOM_ENDTRY
  6289. }
  6290.  
  6291. SOM_Scope void  SOMLINK ContainerPartFocusLost(ContainerPart *somSelf,
  6292.                                                 Environment *ev,
  6293.                                                ODTypeToken focus,
  6294.                                                ODFrame* ownerFrame)
  6295. {
  6296.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6297.     ContainerPartMethodDebug("ContainerPart","ContainerPartFocusLost");
  6298.  
  6299.     SOM_TRY
  6300.  
  6301.     if (focus == _fSelectionFocus)
  6302.     {
  6303.       if (_fMouseMode != kNormal)
  6304.          somSelf->ResetMouseMode(ev);
  6305.  
  6306.       PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
  6307.       pInfo->fIsActive = kODFalse;
  6308.       somSelf->InvalidateSelection(ev, ownerFrame);
  6309.  
  6310.       if (_fSelection->Count())              // [131094] starts
  6311.       {
  6312.         if (ownerFrame == _fSelectionFrame)
  6313.            somSelf->ShowSelection(ev, ownerFrame, kODFalse);
  6314.       }
  6315.                                              // [131094] ends
  6316.        _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fStatusFocus, ownerFrame);
  6317.     }
  6318.     else if (focus == _fMouseFocus)
  6319.     {
  6320.       somSelf->MouseFocusLost(ev, ownerFrame);
  6321.     }
  6322.  
  6323.     SOM_CATCH_ALL
  6324.     SOM_ENDTRY
  6325. }
  6326.  
  6327. SOM_Scope void  SOMLINK ContainerPartCloneInto(ContainerPart *somSelf,
  6328.                                                 Environment *ev,
  6329.                                                ODDraftKey key,
  6330.                                                ODStorageUnit* toSU,
  6331.                                                ODFrame* scope)
  6332. {
  6333.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6334.     ContainerPartMethodDebug("ContainerPart","ContainerPartCloneInto");
  6335.  
  6336.     SOM_TRY
  6337.  
  6338.  
  6339.     ODID scopeFrameID = 0;
  6340.  
  6341.     ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  6342.     ODDraft* toDraft = toSU->GetDraft(ev);
  6343.  
  6344.     ODStorageUnitRef aSURef;
  6345.     ODULong offset;
  6346.     ODFrame* frame;
  6347.     Proxy* proxy;
  6348.     ODxOrderedCollectionIterator aIter(_fDisplayFrames);
  6349.     ODxOrderedCollectionIterator cIter(_fContents);
  6350.  
  6351.     ODSUAddPropValue(ev, toSU, kODPropContents, kKindTestContainer);
  6352.     ODStorageUnit* su = toSU->GetDraft(ev)->CreateStorageUnit(ev);
  6353.  
  6354. // [129011] - aml:
  6355. // Use the destination storage unit to store display frames and embedded frames references
  6356.     ODSUAddPropValue(ev, toSU, kODPropDisplayFrames, kODWeakStorageUnitRef);
  6357.     offset = 0;
  6358.     for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
  6359.         frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
  6360.     {
  6361.       ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
  6362.       if (suFrame)
  6363.       {
  6364.          ODID toFrameID = fromDraft->WeakClone(ev, key, frame->GetID(ev), 0, 0);
  6365.          toSU->GetWeakStorageUnitRef(ev, toFrameID, aSURef);
  6366.          toSU->SetOffset(ev, offset);
  6367.          StorageUnitSetValue(toSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  6368.       }
  6369.     }
  6370.  
  6371.     ODSetULongProp(ev, su, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
  6372.  
  6373.     ODSUAddPropValue(ev, su, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
  6374.     // $$$$$ should be something DrawPart specific, not kODStrongStorageUnitRef
  6375.     // since it is storing StorageUnitRefs and xforms in the same stream.
  6376.     offset = 0;
  6377.  
  6378.  
  6379.     for (Proxy* p = (Proxy*)cIter.First();
  6380.          cIter.IsNotComplete();
  6381.          p = (Proxy*)cIter.Next())
  6382.     {
  6383.        ODxOrderedCollectionIterator i(p);
  6384.        for (frame = (ODFrame*)i.First();
  6385.             i.IsNotComplete();
  6386.             frame = (ODFrame*)i.Next())
  6387.        {
  6388.           ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
  6389.           if (suFrame)
  6390.           {
  6391.              Proxy* proxy = somSelf->ProxyForFrame(ev, frame);
  6392.              ODID toFrameID = fromDraft->Clone(ev, key, frame->GetID(ev), 0, 0);
  6393.              su->GetStrongStorageUnitRef(ev, toFrameID, aSURef);
  6394.              su->SetOffset(ev, offset);
  6395.              StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  6396.              offset += sizeof(ODStorageUnitRef);
  6397.              ODMatrix mtx;
  6398.              proxy->transform->GetMatrix(ev, &mtx);
  6399.              su->SetOffset(ev,offset);
  6400.              StorageUnitSetValue(su, ev, sizeof(ODMatrix), (ODValue)&mtx);
  6401.              offset += sizeof(ODMatrix);
  6402.           }
  6403.        }
  6404.     }
  6405. // end [129011]
  6406.    ODSetULongProp(ev, su, kPropBGColor, kODULong, _fBGColor);
  6407.  
  6408.    ODSetStrongSURefProp(ev, toSU, kODPropContents, kKindTestContainer, su->GetID(ev));
  6409.  
  6410.    SOM_CATCH_ALL
  6411.    SOM_ENDTRY
  6412. }
  6413.  
  6414. SOM_Scope void  SOMLINK ContainerPartExternalizeKinds(ContainerPart *somSelf,
  6415.                                                        Environment *ev,
  6416.                                                       ODTypeList* kindset)
  6417. {
  6418.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6419.     ContainerPartMethodDebug("ContainerPart","ContainerPartExternalizeKinds");
  6420.  
  6421.     SOM_TRY
  6422.  
  6423.     // This part only supports one kind and always externalizes it
  6424.  
  6425.     somSelf->Externalize(ev);
  6426.  
  6427.     SOM_CATCH_ALL
  6428.     SOM_ENDTRY
  6429. }
  6430.  
  6431. SOM_Scope void  SOMLINK ContainerPartExternalize(ContainerPart *somSelf,
  6432.                                                   Environment *ev)
  6433. {
  6434.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6435.     ContainerPartMethodDebug("ContainerPart","ContainerPartExternalize");
  6436.  
  6437.     SOM_TRY
  6438.  
  6439.     ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  6440.     ODStorageUnitRef aSURef;
  6441.     ODULong offset;
  6442.     ODFrame* frame;
  6443.     Proxy* proxy;
  6444.     ODxOrderedCollectionIterator aIter(_fDisplayFrames);
  6445.     ODxOrderedCollectionIterator cIter(_fContents);
  6446.     POINTL xform;
  6447.     if ( _fNeedToExternalize ) {
  6448.  
  6449.        ODSetULongProp(ev, _fContainerSU, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
  6450.    
  6451.    // iterate through the embedded display frames and store a strong reference to them
  6452.        if (_fNeedToExternalize) {    // 145687
  6453.          ODSURemoveProperty(ev, _fContainerSU, kPropEmbeddedFrames);
  6454.          ODSUAddPropValue(ev, _fContainerSU, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
  6455.    
  6456.          // $$$$$ should be something DrawPart specific, not kODStrongStorageUnitRef
  6457.          // since it is storing StorageUnitRefs and xforms in the same stream.
  6458.    
  6459.          offset = 0;
  6460.          ODMatrix mtx;
  6461.          for (Proxy* p = (Proxy*)cIter.First();
  6462.               cIter.IsNotComplete();
  6463.               p = (Proxy*)cIter.Next())
  6464.          {
  6465.             ODxOrderedCollectionIterator i(p);
  6466.             for (ODFrame* frame = (ODFrame*)i.First();
  6467.                  i.IsNotComplete();
  6468.                  frame = (ODFrame*)i.Next())
  6469.             {
  6470.                ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
  6471.                if (suFrame)
  6472.                {
  6473.                   Proxy* proxy = somSelf->ProxyForFrame(ev, frame);
  6474.                   frame->Externalize(ev);
  6475.                   _fContainerSU->GetStrongStorageUnitRef(ev, suFrame->GetID(ev), aSURef);
  6476.                   
  6477.                   _fContainerSU->SetOffset(ev, offset);
  6478.                   StorageUnitSetValue(_fContainerSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  6479.                   offset += sizeof(ODStorageUnitRef);
  6480.                   proxy->transform->GetMatrix(ev, &mtx);
  6481.                   _fContainerSU->SetOffset(ev, offset);
  6482.                   StorageUnitSetValue(_fContainerSU, ev, sizeof(ODMatrix), (ODValue)&mtx);
  6483.                   offset += sizeof(ODMatrix);
  6484.                }
  6485.             }
  6486.          }
  6487.        }
  6488.    
  6489.        ODSetULongProp(ev, _fContainerSU, kPropBGColor, kODULong, _fBGColor);
  6490.    
  6491.        ODSetStrongSURefProp(ev, su, kODPropContents, kKindTestContainer, _fContainerSU->GetID(ev));
  6492.    
  6493.    // iterate through our  displayframes and store a the weak reference to them
  6494.        ODSURemoveProperty(ev, su, kODPropDisplayFrames);
  6495.        ODSUAddPropValue(ev, su, kODPropDisplayFrames, kODWeakStorageUnitRef);
  6496.        offset = 0;
  6497.        for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
  6498.            frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
  6499.        {
  6500.          ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
  6501.          if (suFrame)
  6502.          {
  6503.             frame->Externalize(ev);
  6504.             su->GetWeakStorageUnitRef(ev, suFrame->GetID(ev), aSURef);
  6505.             su->SetOffset(ev, offset);
  6506.             StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  6507.          }
  6508.        }
  6509.    
  6510.        _fNeedToExternalize = kODFalse;
  6511.     }
  6512.     SOM_CATCH_ALL
  6513.     SOM_ENDTRY
  6514. }
  6515.  
  6516. SOM_Scope void  SOMLINK ContainerPartChangeKind(ContainerPart *somSelf,
  6517.                                                  Environment *ev,
  6518.                                                 ODType kind)
  6519. {
  6520.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6521.     ContainerPartMethodDebug("ContainerPart","ContainerPartChangeKind");
  6522.  
  6523. }
  6524.  
  6525. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleEvent(ContainerPart *somSelf,
  6526.                                                        Environment *ev,
  6527.                                                       ODEventData* event,
  6528.                                                       ODFrame* frame,
  6529.                                                       ODFacet* facet,
  6530.                                                       ODEventInfo* eventInfo)
  6531. {
  6532.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6533.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEvent");
  6534.  
  6535.     ODBoolean handled = kODFalse;
  6536.  
  6537.     SOM_TRY
  6538.  
  6539.     switch (event->msg)
  6540.     {
  6541.        case WM_BUTTON1MOTIONSTART:
  6542.           if (!eventInfo->flags)
  6543.           {
  6544.              ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6545.                               ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6546.              handled = somSelf->HandleButton1MotionStart(ev, facet, &windowPt, event);
  6547.              break;
  6548.           }
  6549.  
  6550.        case WM_BUTTON1DOWN:
  6551.           {
  6552.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6553.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6554.           handled = somSelf->HandleButton1Down(ev, facet, &windowPt, event);
  6555.           break;
  6556.           }
  6557.  
  6558.        case WM_BUTTON1CLICK:
  6559.         {
  6560.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6561.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6562.           if (eventInfo->flags == kODInEmbedded)
  6563.           {
  6564.                 handled = somSelf->HandleButton1ClickInEmbeddedFrame(ev, facet,
  6565.                                   eventInfo->embeddedFacet, &windowPt, event);
  6566.           }
  6567.           else if (eventInfo->flags == kODInBorder)
  6568.           {
  6569.                 handled = somSelf->HandleButton1ClickInBorder(ev, facet,
  6570.                                   eventInfo->embeddedFacet, &windowPt, event);
  6571.           }
  6572.           else
  6573.           {
  6574.                 handled = somSelf->HandleButton1Click(ev, facet, &windowPt, event);
  6575.           }
  6576.           break;
  6577.         }
  6578.  
  6579.        case WM_BEGINDRAG:
  6580.           {
  6581.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6582.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6583.           return somSelf->HandleMouseDrag(ev, facet,
  6584.                     (eventInfo->flags == kODInEmbedded || eventInfo->flags == kODPropagated) ?
  6585.                         eventInfo->embeddedFacet : kODNULL,
  6586.                     &windowPt, event);
  6587.           }
  6588.        case WM_CONTEXTMENU:
  6589.  
  6590.           handled = kODTrue;
  6591.           if (_fIgnoreContextMenu && !SHORT2FROMMP(event->mp2))
  6592.              break;                // ignore if mouse event
  6593.  
  6594.           else
  6595.           {
  6596.  
  6597.              PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  6598.              if (!(pInfo->fIsActive))
  6599.                    somSelf->ActivateFrame(ev, frame);
  6600.              _fPopup->Display(ev);
  6601.           }
  6602.           break;
  6603.  
  6604.        case WM_MOUSEMOVE:
  6605.           {
  6606.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6607.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6608.           handled = somSelf->HandleMouseMove(ev, facet, frame, &windowPt, event);
  6609.           }
  6610.           break;
  6611.  
  6612.        case WM_BUTTON1MOTIONEND:
  6613.           {
  6614.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6615.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6616.           handled = somSelf->HandleButton1MotionEnd(ev, facet, frame, &windowPt, event);
  6617.           }
  6618.           break;
  6619.  
  6620.        case WM_BUTTON2DOWN:
  6621.  
  6622.           if (_fMouseMode != kNormal)
  6623.           {
  6624.              somSelf->ResetMouseMode(ev);
  6625.              _fIgnoreContextMenu = kODTrue;
  6626.              handled = TRUE;
  6627.           }
  6628.           else
  6629.              _fIgnoreContextMenu = kODFalse;
  6630.  
  6631.           break;
  6632.  
  6633.        case WM_BUTTON1UP:
  6634.           {
  6635.           ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
  6636.                            ODIntToFixed(SHORT2FROMMP(event->mp1)));
  6637.           handled = somSelf->HandleButton1Up(ev, facet, frame, &windowPt, event);
  6638.           }
  6639.           break;
  6640.  
  6641.        case WM_CHAR:
  6642.           if (!((SHORT1FROMMP(event->mp1) & KC_KEYUP)))
  6643.           {
  6644.             handled = somSelf->HandleKeyDown(ev, frame, event);
  6645.           }
  6646.           break;
  6647.  
  6648.        case WM_ACTIVATE:
  6649.           handled = kODTrue; // actually ignored by dispatcher
  6650.           if (SHORT1FROMMP(event->mp1) != 0)
  6651.              somSelf->ActivatingWindow(ev, frame);
  6652.           else
  6653.              somSelf->DeActivatingWindow(ev, frame);
  6654.           break;
  6655.        case OD_HELP:
  6656.  
  6657.       {
  6658.                     ODHelp * helpme = _fSession->GetHelp(ev);
  6659.                     SHORT con = SHORT1FROMMP(event->mp1);
  6660.                     USHORT  idTopic= SHORT1FROMMP(event->mp2);
  6661.                     USHORT  idSubTopic = SHORT2FROMMP(event->mp2);
  6662.                     // help panel ids now defined in cntnrhlp.h - if menu ids
  6663.                     // change help will still work.  panels in .hlp file hard coded.
  6664.                     if( (idSubTopic >= IDMA_COLOR_GRAY) && (idSubTopic<=IDMA_COLOR_WHITE)){
  6665.                        handled = kODTrue;
  6666.                        switch (idSubTopic) {
  6667.                        case IDMA_COLOR_GRAY:
  6668.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_GRAY_PANEL);
  6669.                           break;
  6670.                        case IDMA_COLOR_RED:
  6671.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_RED_PANEL);
  6672.                           break;
  6673.                        case IDMA_COLOR_GREEN:
  6674.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_GREEN_PANEL);
  6675.                           break;
  6676.                        case IDMA_COLOR_YELLOW:
  6677.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_YELLOW_PANEL);
  6678.                           break;
  6679.                        case IDMA_COLOR_BLUE:
  6680.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_BLUE_PANEL);
  6681.                           break;
  6682.                        case IDMA_COLOR_MAGENTA:
  6683.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_MAGENTA_PANEL);
  6684.                           break;
  6685.                        case IDMA_COLOR_CYAN:
  6686.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_CYAN_PANEL);
  6687.                           break;
  6688.                        case IDMA_COLOR_WHITE:
  6689.                             helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_WHITE_PANEL);
  6690.                           break;
  6691.                        default:
  6692.                          handled = kODFalse;
  6693.                          break;
  6694.                        } /* endswitch */
  6695.                     } else {
  6696.                        handled = kODFalse;
  6697.                     } /* endif */
  6698.                     break;
  6699.       }
  6700.  
  6701.        case WM_COMMAND:
  6702.           if (SHORT1FROMMP(event->mp2) & CMDSRC_MENU ||
  6703.               SHORT1FROMMP(event->mp2) & CMDSRC_ACCELERATOR)
  6704.           {
  6705.             handled = somSelf->HandleMenuEvent(ev, frame, event);
  6706.           }
  6707.           break;
  6708.  
  6709.        case OD_PRINT:
  6710.  
  6711.           somSelf->HandlePrinting(ev,  frame, (char *)event->mp1 );
  6712.           handled = kODTrue;
  6713.           break;
  6714.  
  6715.        default:
  6716.           return kODFalse;
  6717.     }
  6718.  
  6719.     SOM_CATCH_ALL
  6720.     SOM_ENDTRY
  6721.  
  6722.     return handled;
  6723. }
  6724.  
  6725. SOM_Scope ODBoolean  SOMLINK ContainerPartHandleEventInEmbedded(ContainerPart *somSelf,
  6726.                                                                  Environment *ev,
  6727.                                                                 ODEventData* event,
  6728.                                                                 ODFrame* frame,
  6729.                                                                 ODFacet* facet,
  6730.                                                                 ODFrame* embeddedFrame,
  6731.                                                                 ODFacet* embeddedFacet)
  6732. {
  6733.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6734.     ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEventInEmbedded");
  6735.  
  6736.     return kODFalse;
  6737.  
  6738. }
  6739.  
  6740. SOM_Scope void  SOMLINK ContainerPartAdjustMenus(ContainerPart *somSelf,
  6741.                                                   Environment *ev,
  6742.                                                  ODFrame* frame)
  6743. {
  6744.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6745.     ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustMenus");
  6746.  
  6747.     SOM_TRY
  6748.  
  6749.     PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
  6750.  
  6751.     /**********************************************************************
  6752.     *  Be careful what you do in this method.  AdjustMenus gets called
  6753.     *  everytime the user presses MB1 down on the menu control.
  6754.     *  This method is more for adjusting the current menu.  If you want
  6755.     *  to add items, surround them with a flag so they only get added once.
  6756.     *  Also, if you are the root part, but not the active part, you will
  6757.     *  also get called to adjust the current menubar for items on the
  6758.     *  Document menu (like Open as) if you support them.
  6759.     **********************************************************************/
  6760.  
  6761.  
  6762.     //if we are the root part, but not active ,
  6763.     //get the current active menu and adjust for Open As
  6764.     TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
  6765.     if ((tempFrame == kODNULL) && (!pInfo->fIsActive))
  6766.     {
  6767.      ODMenuBar  *TempMenu = (_fSession->GetWindowState(ev))->AcquireCurrentMenuBar(ev);
  6768.      TempMenu->EnableMenuItem(ev,IDMS_DOCUMENT,DOC_OPENAS,kODTrue);
  6769.      TempMenu->Release(ev);
  6770.     }
  6771.  
  6772.     if (pInfo->fIsActive) {
  6773.     char string[256];
  6774.  
  6775.     //enable the menu items that we support
  6776.  
  6777.     if (frame->IsRoot(ev)) {
  6778.        _fMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_OPENAS, kODTrue);
  6779.     } /* endif */
  6780.  
  6781.     //enable the VIEW->Show as
  6782.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SHOWAS,kODTrue);
  6783.  
  6784.     //we enable these only IFF we are not the root part
  6785.     //views we don't support yet
  6786.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SASMALLICON, !(frame->IsRoot(ev)));
  6787.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SALARGEICON, !(frame->IsRoot(ev)));
  6788.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SATHUMBNAIL, !(frame->IsRoot(ev)));
  6789.  
  6790.     //put a check next to our default (and only) view type
  6791.     _fMenuBar->CheckMenuItem(ev,IDMS_VIEW,VIEW_SAFRAME,kODTrue);
  6792.  
  6793.     //enable the view properties menu item
  6794.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW, VIEW_PROPERTIES, kODTrue);
  6795.  
  6796.     //enable the help menu items
  6797.     _fMenuBar->EnableMenuItem(ev,IDMS_HELP, HELP_GENERAL, kODTrue);
  6798.     _fMenuBar->EnableMenuItem(ev,IDMS_HELP, HELP_INDEX, kODTrue);
  6799.  
  6800.     //enable the VIEW->Open As
  6801.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OPENAS,kODTrue);
  6802.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OATREE, kODTrue);
  6803.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OADETAILS, kODTrue);
  6804.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OAICON, kODTrue);
  6805.     _fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OAWINDOW, !(frame->IsRoot(ev)));
  6806.  
  6807.     if (pInfo->fGridOn)  {
  6808.        _fMenuBar->SetMenuItemText(ev,IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid off");
  6809.        if (WinLoadString( (HAB)0,_hmod,IDMA_TOGGLE_GRID_OFF,255,string))// read string table
  6810.           _fMenuBar->SetMenuItemStatusText(ev,IDMA_TOGGLE_GRID,string);
  6811.     }
  6812.     else {
  6813.        _fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid on");
  6814.        if(WinLoadString( (HAB)0,_hmod,IDMA_TOGGLE_GRID_ON,255,string))// read string table
  6815.           _fMenuBar->SetMenuItemStatusText(ev,IDMA_TOGGLE_GRID,string);// have string to load
  6816.     }
  6817.     //enable menu items based on single/multiple/no selection
  6818.     switch (_fSelection->Count() && frame == _fSelectionFrame)
  6819.     {
  6820.        case 0:     // no selection
  6821.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODFalse);
  6822.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODFalse);
  6823.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_SELECTALL, kODTrue);
  6824.         if ( somSelf->AllowPaste(ev, frame) )
  6825.         {
  6826.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTE_MENU, kODTrue); // [144408]
  6827.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTEAS, kODFalse);
  6828.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTELINK, kODFalse);
  6829.         }
  6830.           break;
  6831.  
  6832.        case 1:     // single selection
  6833.           {
  6834.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_COPY, kODTrue);
  6835.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_CUT, kODTrue);
  6836.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DELETE, kODTrue);
  6837.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DESELECTALL, kODTrue);
  6838.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODTrue);
  6839.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODTrue);
  6840.  
  6841.         if ( somSelf->AllowPaste(ev, frame) )
  6842.         {
  6843.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTE_MENU, kODTrue);   // [144408]
  6844.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTEAS, kODFalse);
  6845.             _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTELINK, kODFalse);
  6846.         }
  6847.           };
  6848.           break;
  6849.  
  6850.        default: // multiple selection
  6851.           {
  6852.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DELETE, kODTrue);
  6853.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DESELECTALL, kODTrue);
  6854.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODTrue);
  6855.         _fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODTrue);
  6856.           };
  6857.     };
  6858.   } /* endif fIsActive */
  6859.  
  6860.     SOM_CATCH_ALL
  6861.     SOM_ENDTRY
  6862. }
  6863.  
  6864. SOM_Scope void  SOMLINK ContainerPartUndoAction(ContainerPart *somSelf,
  6865.                                                  Environment *ev,
  6866.                                                 ODActionData* actionState)
  6867. {
  6868.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6869.     ContainerPartMethodDebug("ContainerPart","ContainerPartUndoAction");
  6870.  
  6871.     SOM_TRY
  6872.  
  6873.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  6874.     SetBGColorRec*  undoRec = (SetBGColorRec*)actionState->_buffer;
  6875.  
  6876.     somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fOldColor);
  6877.  
  6878.     SOM_CATCH_ALL
  6879.     SOM_ENDTRY
  6880. }
  6881.  
  6882. SOM_Scope void  SOMLINK ContainerPartRedoAction(ContainerPart *somSelf,
  6883.                                                  Environment *ev,
  6884.                                                 ODActionData* actionState)
  6885. {
  6886.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6887.     ContainerPartMethodDebug("ContainerPart","ContainerPartRedoAction");
  6888.  
  6889.     SOM_TRY
  6890.  
  6891.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  6892.     SetBGColorRec*  undoRec = (SetBGColorRec*)actionState->_buffer;
  6893.  
  6894.     somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fNewColor);
  6895.  
  6896.     SOM_CATCH_ALL
  6897.     SOM_ENDTRY
  6898. }
  6899.  
  6900. SOM_Scope void  SOMLINK ContainerPartDisposeActionState(ContainerPart *somSelf,
  6901.                                                          Environment *ev,
  6902.                                                         ODActionData* actionState,
  6903.                                                         ODDoneState doneState)
  6904. {
  6905.     /* ContainerPartData *somThis = ContainerPartGetData(somSelf); */
  6906.     ContainerPartMethodDebug("ContainerPart","ContainerPartDisposeActionState");
  6907.  
  6908.     // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
  6909.     delete (SetBGColorRec*)actionState->_buffer;
  6910. }
  6911.  
  6912. SOM_Scope void  SOMLINK ContainerPartWriteActionState(ContainerPart *somSelf,
  6913.                                                        Environment *ev,
  6914.                                                       ODActionData* actionState,
  6915.                                                       ODStorageUnitView* storageUnitView)
  6916. {
  6917.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6918.     ContainerPartMethodDebug("ContainerPart","ContainerPartWriteActionState");
  6919.  
  6920. }
  6921. SOM_Scope ODActionData SOMLINK ContainerPartReadActionState(ContainerPart *somSelf,
  6922.                                                             Environment *ev,
  6923.                                                             ODStorageUnitView* storageUnitView)
  6924. {
  6925.     /* ContainerPartData *somThis = ContainerPartGetData(somSelf); */
  6926.     ContainerPartMethodDebug("ContainerPart","ContainerPartReadActionState");
  6927.     ODActionData data;
  6928.     data._maximum = 0;
  6929.     data._length = 0;
  6930.     data._buffer = kODNULL;
  6931.     return data;
  6932.  
  6933. }
  6934.  
  6935. SOM_Scope void  SOMLINK ContainerPartInitPart(ContainerPart *somSelf,
  6936.                                                Environment *ev,
  6937.                                               ODStorageUnit* storageUnit,
  6938.                                               ODPart* partWrapper)
  6939. {
  6940.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6941.     ContainerPartMethodDebug("ContainerPart","ContainerPartInitPart");
  6942.  
  6943.     SOM_TRY
  6944.  
  6945.     parent_InitPart(somSelf, ev, storageUnit, partWrapper);
  6946.     _fPartWrapper = partWrapper;
  6947.  
  6948.     somSelf->CommonInitContainerPart(ev);
  6949.  
  6950.     ODStorageUnit* msu = somSelf->GetStorageUnit(ev);
  6951.     ODSUAddPropValue(ev, msu, kODPropContents, kKindTestContainer);
  6952.     _fContainerSU = msu->GetDraft(ev)->CreateStorageUnit(ev);
  6953.  
  6954.     ODSUAddPropValue(ev, msu, kODPropDisplayFrames, kODWeakStorageUnitRefs);
  6955.     ODSUAddPropValue(ev, _fContainerSU, kODPropFrameGroup, kODULong);
  6956.     ODSUAddPropValue(ev, _fContainerSU, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
  6957.     ODSUAddPropValue(ev, _fContainerSU, kPropBGColor, kODULong);
  6958.     // $$$$$ The type should be something ContainerPart specific, not kODStrongStorageUnitRefs
  6959.     // since it is storing StorageUnitRefs and xforms in the same stream.
  6960.  
  6961.     static int defcolor = 0;
  6962.     _fBGColor = (defcolor++) % 8;  // pick semi random color
  6963.  
  6964.     _fNeedToExternalize = kODTrue;
  6965.  
  6966.     SOM_CATCH_ALL
  6967.     SOM_ENDTRY
  6968. }
  6969.  
  6970. SOM_Scope void  SOMLINK ContainerPartInitPartFromStorage(ContainerPart *somSelf,
  6971.                                                           Environment *ev,
  6972.                                                          ODStorageUnit* storageUnit,
  6973.                                                          ODPart* partWrapper)
  6974. {
  6975.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  6976.     ContainerPartMethodDebug("ContainerPart","ContainerPartInitPartFromStorage");
  6977.  
  6978.     SOM_TRY
  6979.  
  6980.     parent_InitPartFromStorage(somSelf, ev, storageUnit, partWrapper);
  6981.  
  6982.    _fPartWrapper = partWrapper;
  6983.  
  6984.     somSelf->CommonInitContainerPart(ev);
  6985.  
  6986.     ODStorageUnit* su;
  6987.     ODStorageUnitRef aSURef;
  6988.     ODULong offset, offsetLimit;
  6989.     ODMatrix  mtx;
  6990.  
  6991.     su = somSelf->GetStorageUnit(ev);
  6992.  
  6993.     _fContainerSU = su->GetDraft(ev)->AcquireStorageUnit(ev,
  6994.              ODGetStrongSURefProp(ev, su, kODPropContents, kKindTestContainer));
  6995.  
  6996.     su->Focus(ev, kODPropDisplayFrames, kODPosSame, 0, 1, kODPosFirstSib);
  6997.     offsetLimit = su->GetSize(ev);
  6998.     for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
  6999.     {
  7000.       su->SetOffset(ev, offset);
  7001.       StorageUnitGetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  7002.  
  7003.       if (su->IsValidStorageUnitRef(ev, aSURef))
  7004.       {
  7005.         ODFrame* frame = su->GetDraft(ev)->AcquireFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
  7006.         frame->SetDroppable(ev, kODTrue);
  7007.       }
  7008.     }
  7009.  
  7010.     _fFrameGroupIDCounter = ODGetULongProp(ev, _fContainerSU, kODPropFrameGroup, kODULong);
  7011.  
  7012.     _fContainerSU->Focus(ev, kPropEmbeddedFrames,kODPosSame,0,1,kODPosFirstSib);
  7013.  
  7014.     offsetLimit = _fContainerSU->GetSize(ev);
  7015.  
  7016.     for (offset = 0; offset < offsetLimit;)
  7017.     {
  7018.       _fContainerSU->SetOffset(ev, offset);
  7019.       StorageUnitGetValue(_fContainerSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
  7020.       offset += sizeof(ODStorageUnitRef);
  7021.       ODFrame *frame = _fContainerSU->GetDraft(ev)->AcquireFrame(ev, _fContainerSU->GetIDFromStorageUnitRef(ev, aSURef));
  7022.       _fEmbeddedFrames->AddLast((ElementType)frame);
  7023.  
  7024.       _fContainerSU->SetOffset(ev, offset);
  7025.       StorageUnitGetValue(_fContainerSU, ev, sizeof(ODMatrix), (ODValue)&mtx);
  7026.       offset += sizeof(ODMatrix);
  7027.  
  7028.       Proxy* p = somSelf->ProxyForFrame(ev, frame);
  7029.       if (!p)
  7030.       {
  7031.          ODTransform* transform = frame->CreateTransform(ev)->SetMatrix(ev, &mtx);
  7032.          ODShape* shape = frame->AcquireFrameShape(ev, kODNULL);
  7033.          ODPart* part = frame->AcquirePart(ev);
  7034.          p = new Proxy(transform, shape, part);
  7035.          _fContents->AddLast(p);
  7036.       }
  7037.       p->AddFirst(frame);
  7038.     }
  7039.     _fBGColor = ODGetULongProp(ev, _fContainerSU, kPropBGColor, kODULong);
  7040.  
  7041.     SOM_CATCH_ALL
  7042.     SOM_ENDTRY
  7043. }
  7044.  
  7045. SOM_Scope void  SOMLINK ContainerPartRelease(ContainerPart *somSelf,
  7046.                                               Environment *ev)
  7047. {
  7048.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  7049.     ContainerPartMethodDebug("ContainerPart","ContainerPartRelease");
  7050.  
  7051.     SOM_TRY
  7052.  
  7053.     ContainerPart_parent_ODPart_Release(somSelf, ev);
  7054.     if (somSelf->GetRefCount(ev) == 0) 
  7055.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart(ev, somSelf);
  7056.  
  7057.     SOM_CATCH_ALL
  7058.     SOM_ENDTRY
  7059. }
  7060. SOM_Scope void  SOMLINK ContainerPartReleaseAll(ContainerPart *somSelf,
  7061.                                               Environment *ev)
  7062. {
  7063.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  7064.     ContainerPartMethodDebug("ContainerPart","ContainerPartReleaseAll");
  7065.  
  7066.     SOM_TRY
  7067.  
  7068.     Proxy*    p;
  7069.     ODFrame*  frame;
  7070.  
  7071.     frame = (ODFrame*) _fDisplayFrames->First();
  7072.     while (frame != kODNULL) {
  7073.       _fDisplayFrames->Remove(frame);
  7074.       ODReleaseObject(ev,frame);
  7075.       frame = (ODFrame*) _fDisplayFrames->First();
  7076.     }
  7077.     frame = (ODFrame*) _fEmbeddedFrames->First();
  7078.     while (frame != kODNULL) {
  7079.       p = somSelf->ProxyForFrame(ev, frame);
  7080.       p->Remove(frame);
  7081.       _fEmbeddedFrames->Remove(frame);
  7082.       ODReleaseObject(ev,frame);
  7083.       frame = (ODFrame*) _fEmbeddedFrames->First();
  7084.     }
  7085.     p = (Proxy*) _fContents->First();
  7086.     while (p != kODNULL) {
  7087.        _fContents->Remove(p);
  7088.        ODReleaseObject(ev, p->transform);
  7089.        ODReleaseObject(ev, p->shape);
  7090.        ODReleaseObject(ev, p->part);
  7091.        delete p;
  7092.        p = (Proxy*) _fContents->First();
  7093.     }
  7094.  
  7095.  
  7096.     SOM_CATCH_ALL
  7097.     SOM_ENDTRY
  7098. }
  7099.  
  7100.  
  7101. SOMEXTERN void SOMLINK SOMInitModule (long majorVersion, long minorVersion,
  7102.                                  string className)
  7103. {
  7104.    SOM_IgnoreWarning (majorVersion);  /* This function makes   */
  7105.    SOM_IgnoreWarning (minorVersion);  /* no use of the passed  */
  7106.    SOM_IgnoreWarning (className);     /* arguments.            */
  7107.  
  7108.    ContainerPartNewClass ( ContainerPart_MajorVersion, ContainerPart_MinorVersion);
  7109. }
  7110.  
  7111. void EXPENTRY AddMenuResourceLast( Environment *ev, HMODULE hmodDLL, long resid, ODMenuBar *menubar, ODMenuID menuid)
  7112. {
  7113. }
  7114.  
  7115.  
  7116. SOM_Scope ISOString  SOMLINK M_ContainerPartclsGetODPartHandlerName(M_ContainerPart *somSelf,
  7117.                                                                      Environment *ev)
  7118. {
  7119.     /* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
  7120.     M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartHandlerName");
  7121.  
  7122.     string handlerName = kPartHandlerName;
  7123.     return (ISOString) handlerName;
  7124.  
  7125. }
  7126.  
  7127. SOM_Scope string  SOMLINK M_ContainerPartclsGetODPartHandlerDisplayName(M_ContainerPart *somSelf,
  7128.                                                                          Environment *ev)
  7129. {
  7130.     /* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
  7131.     M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartHandlerDisplayName");
  7132.     char str[256];              // 123248
  7133.     CHAR  Error[256] = "";                    //used in DosLoadModule
  7134.     HMODULE hmod = NULLHANDLE;
  7135.     string handleDisplayName;
  7136.     USHORT rc = DosLoadModule(Error,sizeof(Error),"CNTMRI",&hmod);
  7137.     if(rc != 0) // 141477
  7138.     {
  7139.        #ifdef ODDebug
  7140.        beepprintf("Unable to load Container Part's resources!");
  7141.        #endif
  7142.     }
  7143.  
  7144.     rc = WinLoadString( (HAB)0,hmod,IDMA_PARTHANDLERDISPLAYNAME,255,str);// read string table  123248
  7145.     if(rc)  // 141477 - We have a valid string
  7146.     {
  7147.       handleDisplayName = (string)SOMMalloc(strlen(str)+1);
  7148.       strcpy(handleDisplayName, str);
  7149.     }
  7150.     else
  7151.     {
  7152.       handleDisplayName = (string)SOMMalloc(strlen("Container Part")+1);
  7153.       strcpy(handleDisplayName, "Container Part");
  7154.     }
  7155.  
  7156.     if(hmod);
  7157.       DosFreeModule(hmod);
  7158.     return handleDisplayName; //   123248   displayName;
  7159. }
  7160.  
  7161. SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_ContainerPartclsGetODPartKinds(M_ContainerPart *somSelf,
  7162.                                                                                 Environment *ev)
  7163. {
  7164.     /* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
  7165.     M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartKinds");
  7166.  
  7167.     _IDL_SEQUENCE_PartKindInfo ContainerPartInfo;
  7168.  
  7169.     CHAR  Error[256] = "";                    //used in DosLoadModule
  7170.     HMODULE hmod = NULLHANDLE;
  7171.     DosLoadModule(Error,sizeof(Error),"CNTMRI",&hmod);
  7172.     // Create structure PartKindInfo  and allocate memory for variable
  7173.     PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
  7174.  
  7175.     // ******************************************************************
  7176.     // 123248 load part kind displayname and part category from rc file
  7177.     // *****************************************************************
  7178.      char str[256];   //
  7179.      char emptystring[2] = {' ', '\0'};
  7180.      char *pempty;
  7181.      pempty = &emptystring[0];
  7182.     USHORT rc = WinLoadString( (HAB)0,hmod,IDMA_PARTKINDDISPLAYSTRING,255,str);// read string table
  7183.     if (rc) { // have sting to load
  7184.        info->partKindDisplayName = (string)SOMMalloc(strlen(str)+1);
  7185.        strcpy(info->partKindDisplayName, str);
  7186.     } else {
  7187.        info->partKindDisplayName = (string)SOMMalloc(strlen(emptystring)+1);
  7188.        strcpy(info->partKindDisplayName, pempty);
  7189.     } // endif
  7190.     rc =  WinLoadString( (HAB)0,hmod,IDMA_PARTCATEGORYSTRING,255,str);// read string table
  7191.     if (rc) {
  7192.        info->categoryDisplayName =  (string)SOMMalloc(strlen(str)+1);
  7193.        strcpy(info->categoryDisplayName, str);
  7194.     } else {   // 141477
  7195.        info->categoryDisplayName =  (string)SOMMalloc(strlen(emptystring)+1);
  7196.        strcpy(info->categoryDisplayName,pempty);
  7197.     } /* endif */
  7198. // ***********************************************************************
  7199. // **  end 123248 code
  7200. // ***********************************************************************
  7201.     info->partKindName = (ISOString) SOMMalloc(strlen(kKindTestContainer) + 1);
  7202.     info->categories =  (string)SOMMalloc(strlen(kODCategoryDrawing)+1);
  7203.     info->filenameFilters =  (string)SOMMalloc(strlen("")+1);
  7204.     info->filenameTypes =  (string)SOMMalloc(strlen("")+1);
  7205.     info->objectID =  (string)SOMMalloc(strlen("")+1);
  7206.     // Copy the information into the structure
  7207.     strcpy(info->partKindName , kKindTestContainer);
  7208.     strcpy(info->categories ,  kODCategoryDrawing);
  7209.     strcpy(info->filenameFilters, "");
  7210.     strcpy(info->filenameTypes, "");
  7211.     strcpy(info->objectID, "");
  7212.  
  7213.     ContainerPartInfo._maximum = 1;
  7214.     ContainerPartInfo._length = 1;
  7215.     ContainerPartInfo._buffer = info;
  7216.     DosFreeModule(hmod);
  7217.     return ContainerPartInfo;
  7218. }
  7219.  
  7220. SOM_Scope string  SOMLINK M_ContainerPartclsGetOLE2ClassId(M_ContainerPart *somSelf,
  7221.                                                             Environment *ev)
  7222. {
  7223.     /* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
  7224.     M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetOLE2ClassId");
  7225.  
  7226.     string classID = "";
  7227.     return classID;
  7228. }
  7229.  
  7230. SOM_Scope string  SOMLINK M_ContainerPartclsGetWindowsIconFileName(M_ContainerPart *somSelf,
  7231.                                                                     Environment *ev)
  7232. {
  7233.     /* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
  7234.     M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetWindowsIconFileName");
  7235.  
  7236.     string fileName = "";
  7237.     return fileName;
  7238. }
  7239.  
  7240. MRESULT EXPENTRY CntnrPartInfoDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  7241. {
  7242.    switch(msg)
  7243.    {
  7244.       case WM_INITDLG:
  7245.          SetSysMenu(hwnd);     /*   system menu for this dialog  */
  7246.          return MRFROMSHORT(FALSE);
  7247.  
  7248.       case WM_COMMAND:
  7249.          /*
  7250.           * No matter what the command, close the dialog
  7251.           */
  7252.          WinDismissDlg(hwnd, TRUE);
  7253.          break;
  7254.  
  7255.       default:
  7256.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  7257.    }
  7258.    return (MRESULT)NULL;
  7259. }   /*  end of ODProdInfoDlgProc()  */
  7260.  
  7261. /* We only want Move and Close in the system menu.  */
  7262.  
  7263. VOID SetSysMenu(HWND hDlg)
  7264. {
  7265.     HWND     hSysMenu;
  7266.     MENUITEM Mi;
  7267.     ULONG    Pos;
  7268.     MRESULT  Id;
  7269.     SHORT    cItems;
  7270.  
  7271.     hSysMenu = WinWindowFromID(hDlg, FID_SYSMENU);
  7272.     WinSendMsg( hSysMenu, MM_QUERYITEM
  7273.               , MPFROM2SHORT(SC_SYSMENU, FALSE), MPFROMP((PCH) & Mi));
  7274.     Pos = 0L;
  7275.     cItems=SHORT1FROMMR(WinSendMsg(Mi.hwndSubMenu, MM_QUERYITEMCOUNT, MPVOID, MPVOID));
  7276.     while (cItems--)
  7277.     {
  7278.         Id = WinSendMsg( Mi.hwndSubMenu, MM_ITEMIDFROMPOSITION
  7279.                           , MPFROMLONG(Pos), MPVOID);
  7280.         switch (SHORT1FROMMR(Id))
  7281.         {
  7282.         case SC_MOVE:
  7283.         case SC_CLOSE:
  7284.             Pos++;  /* Don't delete that one. */
  7285.             break;
  7286.         default:
  7287.             WinSendMsg( Mi.hwndSubMenu, MM_DELETEITEM
  7288.                       ,  MPARAM(Id), MPVOID);
  7289.         }
  7290.     }
  7291. }   /*  End of SetSysMenu  */
  7292.  
  7293.  
  7294. // This is a test routine to check the implementation of additional
  7295. // columns in the details view. --> UI Team.
  7296.  
  7297. ODBoolean Test_AddDetailsColumns(ContainerPart *somSelf, Environment *ev,
  7298.                 ODViewExtension *ViewExt)
  7299. {
  7300.     SOM_TRY
  7301.  
  7302.         ODEmbeddedFramesIterator *CurrentFrameIter = kODNULL;
  7303.         ODFrame *ChildFrame = kODNULL;
  7304.         ODType kind;
  7305.         ODBoolean bInLoop = TRUE ; // 128689  // flag for embeddeds all simple parts.
  7306.         ODStorageUnit* su; //   128689
  7307.         ULONG cnt = 0;  // 128689 - Z-Ordering counter.
  7308.         CurrentFrameIter=somSelf->CreateEmbeddedFramesIterator(ev,kODNULL);
  7309.          if (CurrentFrameIter) {
  7310.  
  7311.             ChildFrame=CurrentFrameIter->First(ev);
  7312.             if (!ChildFrame) {
  7313.                delete CurrentFrameIter;
  7314.                return kODFalse;
  7315.             } /* endif */
  7316.  
  7317.             while (ChildFrame) {
  7318.                TempODPart tempPart = ChildFrame->AcquirePart( ev );
  7319.                 kind = GetPartKind(tempPart);
  7320.                su = tempPart->GetStorageUnit(ev);       //   128689
  7321.                cnt++;                                    //   "
  7322. // add Z-Order property to each embedded parts Storage unit - Numeric. 128689
  7323.                if(!su->Exists(ev, kZOrderProp, kZOrder, 0))  {
  7324.                   ODStorageUnit* tst = su->AddProperty(ev,kZOrderProp);
  7325.                   su->Focus(ev, kZOrderProp, kODPosUndefined, kODNULL, 0, kODPosUndefined);
  7326.                   su->AddValue(ev,kZOrder);
  7327.                   StorageUnitSetValue(su, ev, sizeof(ODULong) ,&cnt);
  7328.                }
  7329.                 if (strcmp(kind, kSimplePartKind)) {
  7330.                    bInLoop = FALSE;
  7331.                 }
  7332.  
  7333.                 ChildFrame = kODNULL;
  7334.                 if (CurrentFrameIter->IsNotComplete(ev))
  7335.                         ChildFrame = CurrentFrameIter->Next(ev);
  7336.             }
  7337.             if (bInLoop) {
  7338.                // We add columns one by one.
  7339.                char *PropName, *ValName, *ColDataType;
  7340.                ODFIELDINFO fInf;
  7341.  
  7342.                PropName = new char[256];
  7343.                strcpy(PropName, kSimplePartAddProps);
  7344.                ValName = new char[256];
  7345.                strcpy(ValName, kSimplePartAddProp1);
  7346.                ColDataType = new char[256];
  7347.                strcpy(ColDataType, kODISOStr);
  7348.  
  7349.                fInf.cb = sizeof(ODFIELDINFO);
  7350.                fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_LEFT | CFA_SEPARATOR | CFA_STRING;
  7351.                fInf.flTitleAttrs = CFA_CENTER;
  7352.                fInf.sTitleText = new char[20];
  7353.                strcpy(fInf.sTitleText, "My Column1");
  7354.                ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
  7355.  
  7356.                delete ValName;
  7357.                delete ColDataType;
  7358.                ValName = new char[256];
  7359.                strcpy(ValName, kSimplePartAddProp2);
  7360.                ColDataType = new char[256];
  7361.                strcpy(ColDataType, kODULong);
  7362.  
  7363.                fInf.sTitleText = new char[20];
  7364.                fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_ULONG;
  7365.                strcpy(fInf.sTitleText, "My Column2");
  7366.                ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
  7367.  
  7368.                delete ValName;
  7369.                delete ColDataType;
  7370.                ValName = new char[256];
  7371.                strcpy(ValName, kSimplePartAddProp3);
  7372.                ColDataType = new char[256];
  7373.                strcpy(ColDataType, kODTime_T);
  7374.  
  7375.                fInf.sTitleText = new char[20];
  7376.                fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_TIME;
  7377.                strcpy(fInf.sTitleText, "My Column3");
  7378.                ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
  7379.  
  7380.                delete ValName;
  7381.                delete ColDataType;
  7382.                ValName = new char[256];
  7383.                strcpy(ValName, kSimplePartAddProp3);
  7384.                ColDataType = new char[256];
  7385.                strcpy(ColDataType, kODDate);
  7386.  
  7387.                fInf.sTitleText = new char[20];
  7388.                fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_LEFT | CFA_SEPARATOR | CFA_DATE;
  7389.                strcpy(fInf.sTitleText, "My Column4");
  7390.                ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
  7391.                delete PropName;                    // added
  7392.                delete ValName;                     //    by
  7393.                delete ColDataType;                 //   BLG
  7394.            }
  7395. // add a column for the Z-order to details container view - 128689
  7396.             {
  7397.                char *PropName, *ValName, *ColDataType;
  7398.                ODFIELDINFO fInf;
  7399.                PropName = new char[256];
  7400.                strcpy(PropName,  kZOrderProp );
  7401.                ValName = new char[256];
  7402.                strcpy(ValName, kZOrder );
  7403.                ColDataType = new char[256];
  7404.                strcpy(ColDataType, kODULong);
  7405.                fInf.cb = sizeof(ODFIELDINFO);
  7406.                fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_ULONG;
  7407.                fInf.flTitleAttrs = CFA_CENTER;
  7408.                fInf.sTitleText = new char[20];
  7409.                strcpy(fInf.sTitleText, "Z-order");
  7410.                ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
  7411.                delete PropName;
  7412.                delete ValName;
  7413.                delete ColDataType;
  7414.             }
  7415. // end adding additional column to Container View detail - 128689
  7416.          }
  7417.          delete CurrentFrameIter;
  7418.  
  7419.     SOM_CATCH_ALL
  7420.     SOM_ENDTRY
  7421.  
  7422.     return TRUE;
  7423. }
  7424.  
  7425. ODType  GetPartKind(ODPart* part)
  7426. {
  7427.   Environment* ev = somGetGlobalEnvironment();
  7428.  
  7429.   SOM_TRY
  7430.  
  7431.   ODStorageUnit*  su = part->GetStorageUnit(ev);
  7432.   if (su->Exists(ev, kODPropContents,(ODValueType)kODNULL,1))
  7433.   {
  7434.     su->Focus(ev, kODPropContents,kODPosSame,(ODValueType)kODNULL,1,kODPosSame);
  7435.     return(su->GetType(ev));
  7436.   }
  7437.  
  7438.   SOM_CATCH_ALL
  7439.   SOM_ENDTRY
  7440.  
  7441.   return kODNULL;
  7442. }
  7443. //@127858 begin
  7444.  
  7445. SOM_Scope void SOMLINK ContainerPartHandleColorMenu(ContainerPart *somSelf,
  7446.                                                       Environment *ev,
  7447.                                                       ODFrame* frame,
  7448.                                                       ODCommandID command)
  7449. {
  7450.  
  7451.   SOM_TRY
  7452.  
  7453.   AEDesc    objspec = {typeNull, kODNULL}; //@140231
  7454.   AEDesc    color   = {typeNull, kODNULL}; //@140231
  7455.   long  newColor;
  7456.   ODError   err = noErr;
  7457.   ContainerPartData *somThis = ContainerPartGetData(somSelf);
  7458.   ContainerPartMethodDebug("ContainerPart","ContainerPartHandleColorMenu");
  7459.  
  7460.   // Convert menu id to color index
  7461.   newColor = ColorIndexFromMenuColor(command);
  7462.  
  7463.   // Create a desc for the color
  7464.   THROW_IF_ERROR( AECreateDesc(typeInteger, &newColor, sizeof(long), &color) );
  7465.  
  7466.   // create objspec
  7467.   CreatePropObjSpec(somSelf, ev, frame, formUniqueID, pBackgroundColor, objspec);
  7468.   TRY
  7469.     // Send the SetData event to change background color to "color"
  7470.     SendSetDataEvent(somSelf, ev, objspec, color);
  7471.   CATCH_ALL
  7472.     err = ErrorCode();
  7473.   ENDTRY
  7474.   AEDisposeDesc(&color);
  7475.   AEDisposeDesc(&objspec);
  7476.   THROW_IF_ERROR(err);
  7477.  
  7478.   SOM_CATCH_ALL
  7479.   SOM_ENDTRY
  7480. }
  7481.  
  7482.  
  7483. void GetDirectParam(ODSession* session, OSAEvent* message, AEDesc* evtDp)
  7484. {
  7485.   Environment* ev = somGetGlobalEnvironment();
  7486.  
  7487.   SOM_TRY
  7488.  
  7489.   AEDesc localDP = {typeNull, kODNULL}; //@140231
  7490.   THROW_IF_ERROR(AEGetParamDesc(message, keyDirectObject, typeWildCard,
  7491.       &localDP));
  7492.  
  7493.   ODNameResolver* resolver = session->GetNameResolver(ev);
  7494.  
  7495.   ODOSLToken* tmpWrapper = new ODOSLToken();
  7496.   tmpWrapper->InitODOSLToken(ev);
  7497.   THROW_IF_ERROR( AEDescToODDesc(&localDP, tmpWrapper ) );
  7498.  
  7499.   ODBoolean isToken = resolver->IsODToken(ev, tmpWrapper);
  7500.   ODDeleteObject( tmpWrapper );
  7501.   if ( isToken )
  7502.   {
  7503.     *evtDp = localDP;
  7504.   }
  7505.   else
  7506.   {
  7507.     THROW( errAEEventNotHandled );
  7508.   }
  7509.  
  7510.   SOM_CATCH_ALL
  7511.   SOM_ENDTRY
  7512.  
  7513. }  // GetDirectParam()
  7514.  
  7515. void CreatePropObjSpec(ContainerPart *somSelf, Environment* ev, ODFrame* frame,
  7516.             DescType form, DescType prop, AEDesc& objSpec)
  7517. {
  7518.   AEDesc          nullDesc = {typeNull, kODNULL};
  7519.   AEDesc          id = {typeNull, kODNULL}; //@140231
  7520.   AEDesc          pr = {typeNull, kODNULL}; //@140231
  7521.  
  7522.   SOM_TRY
  7523.  
  7524.     ODPersistentObjectID  foo;
  7525.  
  7526.     ODDraft* draft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  7527.     foo = draft->GetPersistentObjectID( ev, frame, kODFrameObject);
  7528.  
  7529.     THROW_IF_ERROR( AECreateDesc(typeInteger, (Ptr) &foo, sizeof(foo), &id) );
  7530.  
  7531.     THROW_IF_ERROR( AECreateDesc(typeType, (Ptr) &prop, sizeof(prop), &pr) );
  7532.  
  7533.     // Create object specifier for this part
  7534.     THROW_IF_ERROR( AECreateObjSpecifier(cPart, &nullDesc, form, &id, kODTrue, &objSpec) );
  7535.     // Create object specifier for background color
  7536.     THROW_IF_ERROR( AECreateObjSpecifier(cProperty, &objSpec, formPropertyID, &pr, kODTrue, &objSpec) );
  7537.   SOM_CATCH_ALL
  7538.     AEDisposeDesc(&id);
  7539.     AEDisposeDesc(&pr);
  7540.   SOM_ENDTRY
  7541. }
  7542.  
  7543. void SendSetDataEvent(ContainerPart *somSelf, Environment *ev, AEDesc& objSpec, AEDesc& data)
  7544. {
  7545.  
  7546.     ODOSAEvent*   event = kODNULL;
  7547.  
  7548.   SOM_TRY
  7549.  
  7550.     ODSession*           session = somSelf->GetStorageUnit(ev)->GetSession(ev);
  7551.     ODMessageInterface*  msg = session->GetMessageInterface(ev);
  7552.     AEDesc        tempReply = {typeNull, kODNULL}; //@140231
  7553.     ODOSAEvent*   reply = new ODOSAEvent;
  7554.     OSAEvent      tempEvent = {typeNull, kODNULL}; //@140231
  7555.     ODAddressDesc*  address;
  7556.  
  7557.  
  7558.     // Create an address descriptor for this document
  7559.     msg->CreatePartAddrDesc(ev,&address, somSelf);
  7560.  
  7561.     // Create the OSA event
  7562.     msg->CreateEvent(ev, kAECoreSuite, kAESetData, address, kAnyTransactionID, &event);
  7563.     ODDeleteObject(address);
  7564.  
  7565.     // Add parms to event
  7566.     ODDescToAEDesc(event, &tempEvent);
  7567.     AEPutParamDesc(&tempEvent, keyDirectObject, &objSpec);
  7568.     AEPutParamDesc(&tempEvent, keyAEData, &data);
  7569.  
  7570.     // Update event with tempEvent
  7571.     AEDescToODDesc(&tempEvent, (ODDesc *) event);
  7572.  
  7573.     // Reply must have an AEDesc even though were not using it
  7574.     AEDescToODDesc(&tempReply, (ODDesc *) reply);
  7575.  
  7576.     // Send the event
  7577.     msg->Send(ev, kODNULL, somSelf, event, reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout);
  7578.  
  7579.     // Delete the event
  7580.     ODDeleteObject(event);
  7581.  
  7582.   SOM_CATCH_ALL
  7583.  
  7584.     // Delete the event
  7585.     ODDeleteObject(event);
  7586.  
  7587.   SOM_ENDTRY
  7588. }
  7589.  
  7590. //------------------------------------------------------------------------------
  7591. // GetPropertyFromNULL
  7592. //------------------------------------------------------------------------------
  7593.  
  7594. static ODError APIENTRY GetPropertyFromNULL(  ODPart*        part,
  7595.                       DescType      desiredClass,
  7596.                       ODOSLToken*      container,
  7597.                       DescType      containerClass,
  7598.                       DescType      form,
  7599.                       ODDesc*        selectionData,
  7600.                       ODOSLToken*      value,
  7601.                       ODSLong        refCon)
  7602. {
  7603.  
  7604.   ODError           error = noErr;
  7605.  
  7606.   TRY
  7607.     Environment*      ev = somGetGlobalEnvironment();
  7608.     ODSession*        session = ((ODPart *)refCon)->GetStorageUnit(ev)->GetSession(ev);
  7609.     ODNameResolver*   resolver = session->GetNameResolver(ev);
  7610.     DescType          propID;
  7611.     ContainerPropAccessor*    accessorObj;
  7612.  
  7613.     if (form != formPropertyID)
  7614.       THROW(errAEWrongDataType);
  7615.  
  7616.     AEDesc      realData = {typeNull, kODNULL}; //@140231
  7617.     DescType    typeCode;
  7618.     Size        dataSize = sizeof(DescType);
  7619.     THROW_IF_ERROR( ODDescToAEDesc( selectionData, &realData ) );
  7620.  
  7621.     AEGetDescData(&realData, &typeCode, (Ptr) &propID,
  7622.                   (Size)sizeof(DescType), &dataSize);
  7623.  
  7624.     switch(propID)
  7625.     {
  7626.       case pBackgroundColor:
  7627.        {
  7628.         if ( !resolver->IsODToken( ev, value ) )
  7629.           THROW( errAENoSuchObject );
  7630.  
  7631.         AEDesc tokenDesc = {typeNull, kODNULL}; //@140231
  7632.  
  7633.         accessorObj = new ContainerPropAccessor(propID, (ContainerPart *)refCon);
  7634.         THROW_IF_ERROR( AECreateDesc(cProperty, &accessorObj, sizeof(accessorObj), &tokenDesc) );
  7635.  
  7636.         ODDesc *userODDesc;
  7637.         userODDesc = resolver->GetUserToken(ev, value);
  7638.         THROW_IF_ERROR( AEDescToODDesc( &tokenDesc, userODDesc ) );
  7639.         AEDisposeDesc(&tokenDesc);
  7640.        }
  7641.         break;
  7642.       default:
  7643.         THROW(errAECantSupplyType);
  7644.         break;
  7645.     }
  7646.  
  7647.   CATCH_ALL
  7648.     error = ErrorCode();
  7649.   ENDTRY
  7650.  
  7651.   return error;
  7652. }  // GetPropertyFromNULL()
  7653.  
  7654.  
  7655.  
  7656. //------------------------------------------------------------------------------
  7657. // HandleSetData
  7658. //------------------------------------------------------------------------------
  7659.  
  7660. static ODError APIENTRY HandleSetData(ODPart*      part,
  7661.                   ODOSAEvent*  message,
  7662.                   ODOSAEvent*  reply,
  7663.                   ODSLong      handlerRefcon)
  7664. {
  7665.  
  7666.   ODError  error = noErr;
  7667.   ODOSLToken* tmpWrapper = kODNULL;
  7668.  
  7669.   TRY
  7670.  
  7671.     AEDesc theData = {typeNull, kODNULL}; //@140231
  7672.     Environment*      ev = somGetGlobalEnvironment();
  7673.     ODSession*        session = ((ODPart *)handlerRefcon)->GetStorageUnit(ev)->GetSession(ev);
  7674.     ODNameResolver*   resolver = session->GetNameResolver(ev);
  7675.  
  7676.     OSAEvent realMessage = {typeNull, kODNULL}; //@140231
  7677.     OSAEvent realReply   = {typeNull, kODNULL}; //@140231
  7678.     THROW_IF_ERROR( ODDescToAEDesc(message, &realMessage) );
  7679.     THROW_IF_ERROR( ODDescToAEDesc(reply, &realReply ));
  7680.  
  7681.  
  7682.     THROW_IF_ERROR(AEGetKeyDesc(&realMessage, keyAEData,
  7683.                 typeWildCard, &theData));
  7684.  
  7685.     AEDesc evtDp = {typeNull, kODNULL}; //@140231
  7686.     GetDirectParam( session, &realMessage, &evtDp);
  7687.     tmpWrapper = new ODOSLToken();
  7688.     tmpWrapper->InitODOSLToken(ev);
  7689.     THROW_IF_ERROR( AEDescToODDesc(&evtDp, tmpWrapper ) );
  7690.     if ( !resolver->IsODToken( ev, tmpWrapper ) )
  7691.       THROW( errAENoSuchObject );
  7692.     ODDesc* myTokenODDesc;
  7693.     myTokenODDesc = resolver->GetUserToken(ev, tmpWrapper);
  7694.     AEDesc theToken = {typeNull, kODNULL}; //@140231
  7695.     error = ODDescToAEDesc(myTokenODDesc, &theToken );
  7696.  
  7697.     if (error == noErr)
  7698.     {
  7699.       switch (theToken.descriptorType)
  7700.       {
  7701.           case typeProperty:
  7702.           {
  7703.             DescType typeCode;
  7704.             ContainerPropAccessor* embedPropAccessorObj;
  7705.             Size     dataSize = sizeof(embedPropAccessorObj);
  7706.  
  7707.             // get prop accessor obj ptr
  7708.             AEGetDescData(&theToken, &typeCode, (Ptr) &embedPropAccessorObj,
  7709.                           (Size)sizeof(embedPropAccessorObj), &dataSize);
  7710.  
  7711.             embedPropAccessorObj->SetData(&theData);
  7712.             delete embedPropAccessorObj;
  7713.           }
  7714.           break;
  7715.       }
  7716.     }
  7717.     AEDisposeDesc(&theData);
  7718.     THROW_IF_ERROR(error);
  7719.  
  7720.   CATCH_ALL
  7721.     error = ErrorCode();
  7722.   ENDTRY
  7723.  
  7724.   ODDeleteObject( tmpWrapper );
  7725.   return error;
  7726. }  // HandleSetData()
  7727.  
  7728.  
  7729. //------------------------------------------------------------------------------
  7730. // HandleGetData
  7731. //------------------------------------------------------------------------------
  7732.  
  7733. static ODError APIENTRY HandleGetData(ODPart*      part,
  7734.                   ODOSAEvent*  message,
  7735.                   ODOSAEvent*  reply,
  7736.                   ODSLong      handlerRefcon)
  7737. {
  7738.   ODError          error = noErr;
  7739.   ODOSLToken* tmpWrapper = kODNULL;
  7740.  
  7741.   TRY
  7742.  
  7743.     DescType        reqType;
  7744.     Size          theSize;
  7745.     AEDesc          objectData = {typeNull, kODNULL}; //@140231
  7746.     Environment*      ev = somGetGlobalEnvironment();
  7747.     ODSession*        session = ((ODPart *)handlerRefcon)->GetStorageUnit(ev)->GetSession(ev);
  7748.     ODNameResolver*     resolver = session->GetNameResolver(ev);
  7749.  
  7750.     OSAEvent realMessage = {typeNull, kODNULL}; //@140231
  7751.     OSAEvent realReply   = {typeNull, kODNULL}; //@140231
  7752.     THROW_IF_ERROR( ODDescToAEDesc(message, &realMessage));
  7753.     THROW_IF_ERROR( ODDescToAEDesc(reply, &realReply));
  7754.  
  7755.     AEDesc evtDp = {typeNull, kODNULL}; //@140231
  7756.     GetDirectParam( session, &realMessage, &evtDp);
  7757.     tmpWrapper = new ODOSLToken();
  7758.     tmpWrapper->InitODOSLToken(ev);
  7759.     THROW_IF_ERROR( AEDescToODDesc(&evtDp, tmpWrapper ) );
  7760.     if ( !resolver->IsODToken( ev, tmpWrapper ) )
  7761.       THROW( errAENoSuchObject );
  7762.     ODDesc* myTokenODDesc;
  7763.     myTokenODDesc = resolver->GetUserToken(ev, tmpWrapper);
  7764.     AEDesc token = {typeNull, kODNULL}; //@140231
  7765.     THROW_IF_ERROR( ODDescToAEDesc(myTokenODDesc, &token ) );
  7766.  
  7767.         //  Next, get the requested return type, if it exists.
  7768.     error = AEGetParamPtr(&realMessage, keyAERequestedType, typeType,
  7769.             &reqType, (Ptr)&reqType, sizeof(reqType), &theSize);
  7770.     if (error == errAEDescNotFound)    // Not an error if return type is not found.
  7771.     {
  7772.       error = noErr;
  7773.       reqType = typeWildCard;
  7774.     }
  7775.     THROW_IF_ERROR(error);
  7776.  
  7777.     switch (token.descriptorType)
  7778.     {
  7779.           case typeProperty:
  7780.           {
  7781.             DescType typeCode;
  7782.             ContainerPropAccessor* embedPropAccessorObj;
  7783.             Size     dataSize = sizeof(embedPropAccessorObj);
  7784.  
  7785.             AEGetDescData(&token, &typeCode, (Ptr) &embedPropAccessorObj,
  7786.                           (Size)sizeof(embedPropAccessorObj), &dataSize);
  7787.             embedPropAccessorObj->GetData(&objectData);
  7788.             delete embedPropAccessorObj;
  7789.           }
  7790.           break;
  7791.     }
  7792.  
  7793.     error = AEPutParamDesc( &realReply, keyAEResult, &objectData );
  7794.     AEDisposeDesc( &objectData );
  7795.     THROW_IF_ERROR(error);
  7796.     THROW_IF_ERROR( AEDescToODDesc( &realReply, reply ) );
  7797.  
  7798.   CATCH_ALL
  7799.     error = ErrorCode();
  7800.   ENDTRY
  7801.  
  7802.   ODDeleteObject( tmpWrapper );
  7803.   return error;
  7804. }  // HandleGetData()
  7805.  
  7806. //==============================================================================
  7807. // ContainerPropAccessor
  7808. //==============================================================================
  7809.  
  7810. //------------------------------------------------------------------------------
  7811. // ContainerPropAccessor::ContainterPropAccessor
  7812. //------------------------------------------------------------------------------
  7813.  
  7814. ContainerPropAccessor::ContainerPropAccessor(DescType property, ContainerPart* part)
  7815. {
  7816.   fProperty = property;
  7817.   fPart = part;
  7818. }
  7819.  
  7820.  
  7821. //------------------------------------------------------------------------------
  7822. // ContainerPropAccessor::SetData
  7823. //------------------------------------------------------------------------------
  7824.  
  7825. void ContainerPropAccessor::SetData(AEDesc* data)
  7826. {
  7827.   Environment*  ev = somGetGlobalEnvironment();
  7828.  
  7829.   SOM_TRY
  7830.  
  7831.   ContainerPartData *somThis = ContainerPartGetData(fPart);
  7832.  
  7833.   switch(fProperty)
  7834.   {
  7835.     case pBackgroundColor:
  7836.     {
  7837.       DescType    typeCode;
  7838.       AEDesc      numDesc = {typeNull, kODNULL}; //@140231 ;
  7839.       long    newColor;
  7840.       Size        dataSize = sizeof(long);
  7841.  
  7842.       THROW_IF_ERROR( AECoerceDesc(data, typeInteger, &numDesc) );
  7843.  
  7844.       AEGetDescData(&numDesc, &typeCode, (Ptr) &newColor,
  7845.                     (Size)sizeof(long), &dataSize);
  7846.  
  7847.       //!!! This whole method do with some cleanup
  7848.       // Change SetBGColor to use a command number
  7849.       ODxOrderedCollectionIterator aIter(_fDisplayFrames);
  7850.       for (ODFrame *frame = (ODFrame*)aIter.First();aIter.IsNotComplete() ;frame = (ODFrame*)aIter.Next() )
  7851.       {
  7852.           fPart->SetBGColor1(ev, frame, newColor);
  7853.           frame->Invalidate(ev,NULL,kODNULL);
  7854.       }
  7855.       THROW_IF_ERROR( AEDisposeDesc(&numDesc) );
  7856.       break;
  7857.     }
  7858.  
  7859.     default:
  7860.       THROW(errAENotModifiable);
  7861.       break;
  7862.   }
  7863.  
  7864.   SOM_CATCH_ALL
  7865.   SOM_ENDTRY
  7866.  
  7867. }  // ContainerPropAccessor::SetData
  7868.  
  7869.  
  7870. //------------------------------------------------------------------------------
  7871. // ContainerPropAccessor::GetData
  7872. //------------------------------------------------------------------------------
  7873.  
  7874. void ContainerPropAccessor::GetData(AEDesc* objectData)
  7875. {
  7876.   Environment*  ev = somGetGlobalEnvironment();
  7877.  
  7878.   SOM_TRY
  7879.  
  7880.     ContainerPartData *somThis = ContainerPartGetData(fPart);
  7881.     ODError      result;
  7882.  
  7883.  
  7884.     switch(fProperty)
  7885.     {
  7886.       case pBackgroundColor:
  7887.       {
  7888.         THROW_IF_ERROR( AECreateDesc(typeInteger, &_fBGColor, sizeof(long), objectData) );
  7889.         break;
  7890.       }
  7891.  
  7892.       default:
  7893.         THROW(errAENoSuchObject);
  7894.         break;
  7895.     }
  7896.  
  7897.   SOM_CATCH_ALL
  7898.   SOM_ENDTRY
  7899.  
  7900. }  // ContainerPropAccessor::GetData
  7901.  
  7902. //@127858 end
  7903.  
  7904.  
  7905. //  [131094] starts
  7906. SOM_Scope void  SOMLINK ContainerPartShowSelection(ContainerPart *somSelf,
  7907.                                                    Environment *ev,
  7908.                                                    ODFrame* ownerFrame,
  7909.                                                    ODBoolean show)
  7910. {
  7911.     ContainerPartData *somThis = ContainerPartGetData(somSelf);
  7912.     ContainerPartMethodDebug("ContainerPart","ContainerPartShowSelection");
  7913.  
  7914.   SOM_TRY
  7915.  
  7916.     ODFacet* facet;
  7917.  
  7918.     if (_fSelection->Count() && ownerFrame == _fSelectionFrame)
  7919.     {
  7920.        ODxOrderedCollectionIterator i(_fEmbeddedFrames);
  7921.        for (ODFrame* frame = (ODFrame*)i.First();
  7922.            i.IsNotComplete();
  7923.            frame = (ODFrame*)i.Next())
  7924.        {
  7925.           TempODFrame containingFrame = frame->AcquireContainingFrame(ev);
  7926.           if (containingFrame == ownerFrame)
  7927.           {
  7928.              Proxy* p = somSelf->ProxyForFrame(ev, frame);
  7929.              if (_fSelection->Contains(p))
  7930.              {
  7931.                 somSelf->SetFrameSelected(ev, frame, show);
  7932.                 frame->Invalidate(ev, kODNULL, kODNULL);
  7933.              }
  7934.           }
  7935.        }
  7936.     }
  7937.     somSelf->InvalidateSelection(ev, ownerFrame);
  7938.  
  7939.     if (show)
  7940.        somSelf->ClipSelectionFromEmbeddedFrames(ev, ownerFrame);
  7941.     else
  7942.        somSelf->UnClipSelectionFromEmbeddedFrames(ev, ownerFrame);
  7943.  
  7944.   SOM_CATCH_ALL
  7945.   SOM_ENDTRY
  7946. }
  7947.  
  7948. //  [131094] ends
  7949.