home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / basecntr / iodbasec.cpp < prev    next >
C/C++ Source or Header  |  1997-04-02  |  166KB  |  4,871 lines

  1. /* @(#) 1.127 com/src/samples/basecntr/iodbasec.cpp, odbasepart, od96os2, odos29714c 4/2/97 07:36:43 [4/2/97 17:20:01] */
  2.  
  3. //====START_GENERATED_PROLOG======================================
  4. //
  5. //
  6. //   COMPONENT_NAME: odsamples
  7. //
  8. //   CLASSES: none
  9. //
  10. //   ORIGINS: 82,27
  11. //
  12. //
  13. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  14. //   All Rights Reserved
  15. //   Licensed Materials - Property of IBM
  16. //   US Government Users Restricted Rights - Use, duplication or
  17. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  18. //
  19. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  22. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  23. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  24. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  25. //   OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. //
  28. //====END_GENERATED_PROLOG========================================
  29. //
  30.  
  31. #define SOM_Module_iodbasec_Source
  32. #define BaseContainer_Class_Source
  33.  
  34. #define VARIABLE_MACROS
  35. #define SOM_DONT_IMPORT_CLASS_ALink
  36. #define SOM_DONT_IMPORT_CLASS_ALinkedList
  37. #define SOM_DONT_IMPORT_CLASS_BCIterator
  38. #define SOM_DONT_IMPORT_CLASS_ContentObject
  39. #define SOM_DONT_IMPORT_CLASS_ContentFrame
  40.  
  41.  
  42. // definition for class name; use it for adding HELP menu
  43. #define kBCClassName "BaseContainer"
  44.  
  45. #ifdef _PLATFORM_OS2_
  46. /* One of the #include's below must be including <os2.h>, because by the time */
  47. /* we try to include it, it has already been included, so we don't get into   */
  48. /* the INCL_DEV portion, causing the structures referred to in IODPRINT.HPP   */
  49. /* to be unknown.  If we ever need to add any other INCL_???'s, they should   */
  50. /* go here also.  Probably all of the INCL_???'s should go here (but not the  */
  51. /* #include <os2.h> itself, since the headers below might define additional   */
  52. /* INCL_???'s, which would need to be done before the #include <os2.h>).      */
  53. #define INCL_DEV
  54. #endif
  55.  
  56. #include <AltPoint.h>
  57. #include <BArray.h>
  58. #include <FocusLib.h>
  59. #include <ODMath.h>
  60.  
  61. #ifdef _PLATFORM_UNIX_
  62. #include <odres.h>
  63. #else
  64. #include <ODRes.h>
  65. #endif
  66.  
  67. #include <ODTypes.h>
  68. #include <StorUtil.h>
  69. #include <TempObj.h>
  70. #include <WinUtils.h>
  71.  
  72. #ifndef  SOM_BCIterator_xh
  73. #include <iodbcitr.xh>
  74. #endif
  75.  
  76. #ifndef SOM_ODArbitrator_xh
  77. #include <Arbitrat.xh>
  78. #endif
  79.  
  80. #ifndef SOM_ODCanvas_xh
  81. #include <Canvas.xh>
  82. #endif
  83.  
  84. #ifndef SOM_ODClipboard_xh
  85. #include <Clipbd.xh>
  86. #endif
  87.  
  88. #ifndef SOM_ODDragItemIterator_xh
  89. #include <DgItmIt.xh>
  90. #endif
  91.  
  92. #ifndef SOM_ODDragAndDrop_xh
  93. #include <DragDrp.xh>
  94. #endif
  95.  
  96. #ifndef SOM_ODFacet_xh
  97. #include <Facet.xh>
  98. #endif
  99.  
  100. #ifndef SOM_ODFocus_xh
  101. #include <Foci.xh>
  102. #endif
  103.  
  104. #ifndef SOM_ODFocusSet_xh
  105. #include <FocusSet.xh>
  106. #endif
  107.  
  108. #ifndef SOM_ODFrame_xh
  109. #include <Frame.xh>
  110. #endif
  111.  
  112. #ifndef SOM_ODFrameFacetIterator_xh
  113. #include <FrFaItr.xh>
  114. #endif
  115.  
  116. #ifndef SOM_ODFacetIterator_xh
  117. #include <FacetItr.xh>
  118. #endif
  119.  
  120. #ifndef SOM_ODMenubar_xh
  121. #include <MenuBar.xh>
  122. #endif
  123.  
  124. #ifndef SOM_ODSession_xh
  125. #include <ODSessn.xh>
  126. #endif
  127.  
  128. #ifndef SOM_ODShape_xh
  129. #include <Shape.xh>
  130. #endif
  131.  
  132. #ifndef SOM_Module_xh5cStdProps_OpenDoc_StdProps_defined
  133. #include <StdProps.xh>
  134. #endif
  135.  
  136. #ifndef SOM_Module_xh5cStdTypes_OpenDoc_StdTypes_defined
  137. #include <StdTypes.xh>
  138. #endif
  139.  
  140. #ifndef SOM_ODStorageUnit_xh
  141. #include <StorageU.xh>
  142. #endif
  143.  
  144. #ifndef SOM_ODStorageUnitCursor_xh
  145. #include <SUCursor.xh>
  146. #endif
  147.  
  148. #ifndef SOM_ODTransform_xh
  149. #include <Trnsform.xh>
  150. #endif
  151.  
  152. #ifndef SOM_ODWindow_xh
  153. #include <Window.xh>
  154. #endif
  155.  
  156. #if defined(_PLATFORM_WIN32_)
  157.  
  158. #ifndef SOM_ODWin32Canvas_xh
  159. #include <WinPCanv.xh>
  160. #endif
  161. #endif // defined win32
  162.  
  163.  
  164. #if defined(_PLATFORM_OS2_)
  165. #ifndef SOM_ODOS2Canvas_xh
  166. #include <OS2PCanv.xh>
  167. #endif
  168. #endif // defined OS2
  169.  
  170. #ifdef _PLATFORM_UNIX_
  171. #include <AIXPCanv.xh>
  172. #include <AIXWCanv.xh>
  173. #endif
  174.  
  175. #ifndef SOM_ODWindowState_xh
  176. #include <WinStat.xh>
  177. #endif
  178.  
  179. #if defined(_PLATFORM_UNIX_)
  180. #   define QPRINTF printf
  181. #   include <Xm/XmAll.h>
  182. #   include <X11/cursorfont.h>
  183.  
  184. #elif defined(_PLATFORM_OS2_)
  185. #   define QPRINTF qprintf
  186.  
  187. #   define INCL_DOS
  188. #   define INCL_DEV
  189. #   define INCL_GPI
  190. #   define INCL_GPIPOLYGON
  191. #   define INCL_WIN
  192. #   define INCL_WINFRAMEMGR
  193. #   define INCL_WINPOINTERS
  194. #   define INCL_WINWINDOWMGR
  195. #   define INCL_WINHELP
  196. #   include <os2.h>
  197.  
  198. #elif defined(_PLATFORM_WIN32_)
  199. #   include <windows.h>
  200. #   include <winuser.h>
  201. #   include <wingdi.h>
  202.  
  203. #endif
  204.  
  205. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  206. #ifndef SOM_ODPrintExtension_xh
  207. #include <IODPrint.hpp> //must come after #include <os2.h> - requires INCL_DEV
  208. #include <IODPrint.xh>
  209. #endif
  210.  
  211. #ifndef SOM_ODScrollExtension_xh
  212. #include <IODScrol.hpp>
  213. #include <IODScrol.xh>
  214. #endif
  215. #endif //defined OS2 || WIN32
  216.  
  217. // This is the Base Container's subclass of the ODSettingsExtension class.
  218. #ifndef SOM_BCSettingsExt_xh
  219. #include <iodbcset.xh>
  220. #endif
  221.  
  222. // Need to include this since this part creates a Settings Extension.
  223. #include <StdExts.xh>
  224.  
  225. #ifndef _PLATFORM_AIX_
  226. #include <ODResrc.h>
  227. #endif
  228.  
  229. #include <iostream.h>
  230. #include <ODRegApi.h>
  231. #include <locale.h>
  232. #include <wchar.h>
  233. #include <ODDebug.h>
  234. #include <StdTypIO.h>
  235.  
  236. #include <iodbasec.xih>
  237.  
  238. #ifdef _PLATFORM_UNIX_
  239. String colors[]={
  240.        "gray","orange","plum","white","turquoise",
  241.        "red","green","yellow","aquamarine","SkyBlue",
  242.        "cyan","brown","blue","maroon","purple"};
  243. #endif
  244.  
  245.  
  246. // ------------------------------------------------------------------------
  247. // ------------------------------------------------------------------------
  248. //           INLINE FUNCTIONS FOR RELEASING AND DELETING OBJECTS
  249. // ------------------------------------------------------------------------
  250. // ------------------------------------------------------------------------
  251. inline ODTransform* ODCopyAndRelease( Environment *ev, ODTransform *t )
  252. {
  253.         ASSERT(t!=kODNULL, kODErrIllegalNullInput);
  254.         if( t->GetRefCount(ev) == 1 )
  255.                 return t;
  256.         TempODTransform tempT = t;              // Ensures that t gets released
  257.         ODTransform *copy = t->Copy(ev);
  258.         return copy;
  259. }
  260.  
  261. inline ODShape* ODCopyAndRelease( Environment *ev, ODShape *s )
  262. {
  263.         ASSERT(s!=kODNULL, kODErrIllegalNullInput);
  264.         if( s->GetRefCount(ev) == 1 )
  265.                 return s;
  266.         TempODShape tempS = s;          // Ensures that s gets released
  267.         ODShape *copy = s->Copy(ev);
  268.         return copy;
  269. }
  270.  
  271.  
  272. inline void ODRelease( Environment *ev, ODRefCntObject* obj )
  273. {
  274.         if( obj )
  275.                 obj->Release(ev);
  276. }
  277.  
  278. inline void ODSafeReleaseObject( ODRefCntObject *obj )
  279. {
  280.         if( obj ) {
  281.         try{
  282.                 obj->Release(somGetGlobalEnvironment());
  283.             }
  284.         catch (...) {}
  285.         }
  286. }
  287.  
  288. extern ContentFrame *GetContentObjectForFrame(ODFrame *frame, ALinkedList *l);
  289.  
  290. #if defined(_PLATFORM_OS2_)
  291. void InflateRect( ODRect *prectl, long dx, long dy )
  292. {
  293.  prectl->left   -= dx;
  294.  prectl->right  += dx;
  295.  prectl->bottom -= dy;
  296.  prectl->top    += dy;
  297. }
  298. #elif (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  299. void InflateRect( ODRect *prectl, long dx, long dy )
  300. {
  301.  prectl->left   -= dx;
  302.  prectl->right  += dx;
  303.  prectl->bottom += dy;
  304.  prectl->top    -= dy;
  305. }
  306. #endif
  307.  
  308. #define ODReleaseObject(EV,OBJ)          \
  309.      do{ ODRefCntObject *temp = (OBJ);   \
  310.           (OBJ) = kODNULL;               \
  311.           ODRelease((EV),temp); } while(0)
  312.  
  313.  
  314. #ifdef _PLATFORM_OS2_
  315. #include <os2plat.cpp>
  316. #endif
  317.  
  318. #include <bcxfer.cpp>
  319. #include <iodbcvwt.cpp>
  320.  
  321. extern ODFacet* FirstFacet (Environment *ev, ODFrame *frame);
  322.  
  323. // -------------------------------------------------------------------------
  324. // -----                                                               -----
  325. // -----                BaseContainer MetaClass                        -----
  326. // -----                                                               -----
  327. // -----              Overriding Inherited Methods                     -----
  328. // -----                                                               -----
  329. /* The methods are divided into 9 groups
  330.    Group 1: Initialization code: Metaclass methods, Init/UnInit, Release,
  331.             BuildMenu, Embed, Open, CreateWindow, ColorSelection
  332.    Group 2: RequestEmbeddedFrame, RequestFrameShape, GetEmbeddedFrames,
  333.             CreateEmbeddedFramesIter
  334.    Group 3: Draw code: Draw, GetPrintResolution, AdjustBorderShape,
  335.             SelectionBorderCode
  336.    Group 4: Facet/Frame: FacetAdded/Removed, DisplayFrameAdded/Removed/Closed
  337.                                              /Connected
  338.    Group 5: Focus code: Commit/Begin/AbortRelinquishFocus, FocusAcquired/Lost
  339.             ActivateFrame/Window
  340.    Group 6: Linking code
  341.    Group 7: Extensions
  342.    Group 8: Undo/Redo
  343.    Group 9: Notification methods: ViewTypeChaged/FrameShapeChanged/GeometryChanged
  344.             SequenceChanged/PresChanged etc..
  345. */
  346. // -------------------------------------------------------------------------
  347.  
  348. // ** Group 1
  349. #ifdef __IBMC__
  350. #pragma linkage (SOMInitModule, system)
  351. #endif
  352.  
  353. SOMEXTERN void SOMLINK SOMInitModule (long majorversion, long minorversion,
  354.                                         string className)
  355. {
  356.     SOM_IgnoreWarning (majorversion);
  357.     SOM_IgnoreWarning (minorversion);
  358.     SOM_IgnoreWarning (className);
  359.     BaseContainerNewClass(BaseContainer_MajorVersion,BaseContainer_MinorVersion);
  360. }
  361.  
  362. #ifdef _PLATFORM_OS2_
  363. #pragma export (SOMInitModule)
  364. #endif
  365.  
  366.  
  367. // -------------------------------------------------------------------------
  368. // M_BaseContainer --> clsGetODPartHandlerName
  369. //
  370. //      Returns the BaseContainer internal Part Handler name.
  371. //
  372. //      -> public method of BaseContainer MetaClass
  373. // -------------------------------------------------------------------------
  374.  
  375. SOM_Scope       ISOString
  376. SOMLINK         M_BaseContainerPartclsGetODPartHandlerName
  377.                 (
  378.                 M_BaseContainer *somSelf,       // in
  379.                 Environment *ev                 // in
  380.                 )
  381.  
  382. {
  383. //  M_BaseContainerData *somThis = M_BaseContainerGetData(somSelf);
  384.     M_BaseContainerMethodDebug("M_BaseContainer","M_BaseContainerPartclsGetODPartHandlerName");
  385.  
  386.  
  387.     string handlerName = (string)SOMMalloc(strlen(kBaseContainerPartHandlerName)+1);
  388.     strcpy(handlerName,kBaseContainerPartHandlerName);
  389.  
  390.     return (ISOString) handlerName;
  391. }
  392.  
  393.  
  394.  
  395. // -------------------------------------------------------------------------
  396. // M_BaseContainer --> clsGetODPartHandlerDisplayName
  397. //
  398. //      Defines and returns the BaseContainer displayable name.
  399. //
  400. //      -> public method of BaseContainer MetaClass
  401. //      -> Part Handler name is hard coded in this example
  402. // -------------------------------------------------------------------------
  403.  
  404. SOM_Scope       string
  405. SOMLINK         M_BaseContainerPartclsGetODPartHandlerDisplayName
  406.                 (
  407.                 M_BaseContainer *somSelf,       // in
  408.                 Environment *ev                 // in
  409.                 )
  410. {
  411. //  M_BaseContainerData *somThis = M_BaseContainerGetData(somSelf);
  412.     M_BaseContainerMethodDebug("M_BaseContainer","M_BaseContainerPartclsGetODPartHandlerDisplayName") ;
  413.  
  414.  
  415.     string displayName = (string)SOMMalloc(strlen(kBaseContainerPartHandlerDisplayName)+1);
  416.     strcpy(displayName,kBaseContainerPartHandlerDisplayName);
  417.  
  418.     return displayName;
  419. }
  420.  
  421.  
  422.  
  423. // -------------------------------------------------------------------------
  424. // M_BaseContainer --> clsGetODPartKinds
  425. //
  426. //      Queries the OpenDoc registry for PartKind info.
  427. //
  428. //      -> public method of BaseContainer MetaClass
  429. // -------------------------------------------------------------------------
  430.  
  431. SOM_Scope       _IDL_SEQUENCE_PartKindInfo
  432. SOMLINK         M_BaseContainerPartclsGetODPartKinds
  433.                 (
  434.                 M_BaseContainer *somSelf,       // in
  435.                 Environment *ev                 // in
  436.                 )
  437. {
  438. //  M_BaseContainerData *somThis = M_BaseContainerGetData(somSelf);
  439.     M_BaseContainerMethodDebug("M_BaseContainer","M_BaseContainerPartclsGetODPartKinds");
  440.  
  441.  
  442.  
  443.     _IDL_SEQUENCE_PartKindInfo BaseContainerPartInfo;
  444.  
  445.     // Create array of PartKindInfo structures
  446.     PartKindInfo * info = (PartKindInfo *)SOMCalloc(2, sizeof(PartKindInfo));
  447.  
  448.     // Allocate memory for the first PartKindInfo's fields
  449.     info[0].partKindName = (ISOString) SOMMalloc(strlen(kBaseContainerPartKind) + 1);
  450.     info[0].partKindDisplayName = (string)SOMMalloc(strlen(kBaseContainerPartKindDisplayName)+1);
  451.     info[0].filenameFilters =  (string)SOMMalloc(strlen("")+1);
  452.     info[0].filenameTypes =  (string)SOMMalloc(strlen("")+1);
  453.     info[0].categories =  (string)SOMMalloc(strlen(kBaseContainerPartCategory)+1);
  454.     info[0].categoryDisplayName =  (string)SOMMalloc(strlen("")+1);
  455.     info[0].objectID =  (string)SOMMalloc(strlen("")+1);
  456.  
  457.     // Copy the information into the structure
  458.     strcpy(info[0].partKindName , kBaseContainerPartKind);
  459.     strcpy(info[0].partKindDisplayName, kBaseContainerPartKindDisplayName);
  460.     strcpy(info[0].filenameFilters, "");
  461.     strcpy(info[0].filenameTypes, "");
  462.     strcpy(info[0].categories, kBaseContainerPartCategory);
  463.     strcpy(info[0].categoryDisplayName, "");
  464.     strcpy(info[0].objectID, "");
  465.  
  466.     // Allocate memory for the second PartKindInfo's fields
  467.     info[1].partKindName = (ISOString) SOMMalloc(strlen(kODFrameList) + 1);
  468.     info[1].partKindDisplayName = (string)SOMMalloc(strlen(kODFrameListUserString)+1);
  469.     info[1].filenameFilters =  (string)SOMMalloc(strlen("")+1);
  470.     info[1].filenameTypes =  (string)SOMMalloc(strlen("")+1);
  471.     info[1].categories =  (string)SOMMalloc(strlen("")+1);
  472.     info[1].categoryDisplayName =  (string)SOMMalloc(strlen("")+1);
  473.     info[1].objectID =  (string)SOMMalloc(strlen("")+1);
  474.  
  475.     // Copy the information into the structure
  476.     strcpy(info[1].partKindName , kODFrameList);
  477.     strcpy(info[1].partKindDisplayName, kODFrameListUserString);
  478.     strcpy(info[1].filenameFilters, "");
  479.     strcpy(info[1].filenameTypes, "");
  480.     strcpy(info[1].categories, "");
  481.     strcpy(info[1].categoryDisplayName, "");
  482.     strcpy(info[1].objectID, "");
  483.  
  484.     BaseContainerPartInfo._maximum = 2;
  485.     BaseContainerPartInfo._length = 2;
  486.     BaseContainerPartInfo._buffer = info;
  487.  
  488.  
  489.  
  490.     return BaseContainerPartInfo;
  491. }
  492.  
  493.  
  494.  
  495. // -------------------------------------------------------------------------
  496. // M_BaseContainer --> clsGetOLE2ClassId
  497. //
  498. //      Returns the OLE2 Class ID defined for this part.
  499. //
  500. //      -> public method of BaseContainer MetaClass
  501. // -------------------------------------------------------------------------
  502.  
  503. SOM_Scope       string
  504. SOMLINK         M_BaseContainerPartclsGetOLE2ClassId
  505.                 (
  506.                 M_BaseContainer *somSelf,       // in
  507.                 Environment *ev                 // in
  508.                 )
  509. {
  510. //  M_BaseContainerData *somThis = M_BaseContainerGetData(somSelf);
  511.     M_BaseContainerMethodDebug("M_BaseContainer","M_BaseContainerPartclsGetOLE2ClassId");
  512.  
  513.  
  514.     // OLE2 Class ID is determined by running the tool UUIDGEN.EXE
  515.     // or GUIDGEN.EXE found in the IBM VAC++ SDK\BIN directory
  516.     // this tool is gauranteed to generate a unique ID based on your
  517.     // network address and the time of day (DCE Standard)
  518.  
  519.  
  520.     string OLE2 = "{e2c13b60-a403-11cf-973b-0004ac77f242}";
  521.     string OLE2ClassId = (string)SOMMalloc(strlen(OLE2)+1);
  522.     strcpy(OLE2ClassId,OLE2);
  523.  
  524.  
  525.     return OLE2ClassId;
  526. }
  527.  
  528.  
  529.  
  530. // -------------------------------------------------------------------------
  531. // M_BaseContainer --> clsGetWindowsIconFileName
  532. //
  533. //      Returns the Windows Icon Filename defined for this part.
  534. //
  535. //      -> public method of BaseContainer MetaClass
  536. // -------------------------------------------------------------------------
  537.  
  538. SOM_Scope       string
  539. SOMLINK         M_BaseContainerPartclsGetWindowsIconFileName
  540.                 (
  541.                 M_BaseContainer *somSelf,       // in
  542.                 Environment *ev                 // in
  543.                 )
  544. {
  545. //  M_BaseContainerData *somThis = M_BaseContainerGetData(somSelf);
  546.     M_BaseContainerMethodDebug("M_BaseContainer","M_BaseContainerPartclsGetWindowsIconFileName");
  547.  
  548.  
  549.  
  550.     string kWindowsIcon = "iodbasec.ico";
  551.     string WindowsIconFileName = (string)SOMMalloc(strlen(kWindowsIcon)+1);
  552.     strcpy(WindowsIconFileName,kWindowsIcon);
  553.  
  554.  
  555.     return WindowsIconFileName;
  556. }
  557.  
  558.  
  559. // -------------------------------------------------------------------------
  560. /*                  BaseContainer Class
  561. */
  562. // -------------------------------------------------------------------------
  563.  
  564. // -------------------------------------------------------------------------
  565. // SOMObject --> somInit
  566. //
  567. //      Initializes the instance variables in the SOMObject of this part.
  568. //
  569. //      -> somInit must NOT fail (code that might fail goes to InitPart)
  570. // -------------------------------------------------------------------------
  571.  
  572. SOM_Scope       void
  573. SOMLINK         BaseContainersomInit
  574.                 (
  575.                 BaseContainer   *somSelf        // in
  576.                 )
  577. {
  578.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  579.     BaseContainerMethodDebug("BaseContainer","BaseContainersomInit");
  580.  
  581.  
  582.  
  583.     //  (1) call parent's method before starting
  584.     BaseContainer_parent_ODPart_somInit(somSelf);
  585.  
  586.  
  587.  
  588.     //  (2) initialize BaseContainer attributes
  589.     _fSession         = kODNULL;
  590.     _fDisplayFrames   = kODNULL;
  591.     _fEmbeddedObjects  = kODNULL;
  592.     _fSelectedObjects  = kODNULL;
  593.  
  594.     _fFocusSet          = kODNULL;
  595.     _fSelectionFocus    = kODNULL;
  596.     _fMenuFocus         = kODNULL;
  597.     _fKeyFocus          = kODNULL;
  598.     _fModalFocus        = kODNULL;
  599.     _fMouseFocus        = kODNULL;
  600.     _fMouseFocusOutside = kODNULL;
  601.     _fFrameView         = kODNULL;
  602.     _fLargeIconView     = kODNULL;
  603.     _fSmallIconView     = kODNULL;
  604.     _fThumbnailView     = kODNULL;
  605.     _fMainPresentation  = kODNULL;
  606.     _fPartSU            = kODNULL;
  607.  
  608.     _fDirty             = kODFalse;
  609.  
  610.     _fMenuBar           = kODNULL;
  611.     _fEditMenu          = kODNULL;
  612.     _fEmbedMenu         = kODNULL;
  613.     _fColorMenu         = kODNULL;
  614.     _fWindowID          = kODNULL;
  615.     _fFrameViewWindow   = kODNULL;
  616.     _fPartWrapper       = kODNULL;
  617.  
  618.     _fPartToEmbed       = kODNULL;
  619.     _usMouseMode        = kMouseModeNull;
  620.  
  621. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  622.     _fScrollExt = kODNULL;
  623.     _fScrollingEnabled = kODFalse;
  624.  
  625.     _fPrintExt = kODNULL;
  626.     _fPrintingEnabled = kODFalse;
  627.  
  628. #endif //defined OS2 || WIN32
  629.  
  630.     _fSettingsExt = kODNULL ;
  631. }
  632.  
  633.  
  634.  
  635.  
  636. // -------------------------------------------------------------------------
  637. // SOMObject --> somUninit
  638. //
  639. //      Disposes of storage for SOMObject of this part.
  640. //
  641. //      -> does not call parent method (called automatically by SOM)
  642. //      -> optional for all parts
  643. //
  644. //      -> somUninit must NOT fail
  645. // -------------------------------------------------------------------------
  646.  
  647. SOM_Scope       void
  648. SOMLINK         BaseContainersomUninit
  649.                 (
  650.                 BaseContainer   *somSelf        // in
  651.                 )
  652. {
  653.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  654.     BaseContainerMethodDebug("BaseContainer","BaseContainersomUninit");
  655.  
  656.  
  657.     Environment* ev = somGetGlobalEnvironment();
  658.  
  659.     if (_fFocusSet)       delete _fFocusSet;
  660.  
  661.     if (_fDisplayFrames)  delete _fDisplayFrames;
  662.     if (_fEmbeddedObjects) delete _fEmbeddedObjects;
  663.     if (_fSelectedObjects) delete _fSelectedObjects;
  664.  
  665.     if (_fMouseStart)
  666.       delete _fMouseStart;
  667.  
  668.     // call parent's method after you're finished and before you exit
  669.     BaseContainer_parent_ODPart_somUninit(somSelf);
  670.  
  671.  
  672.  
  673. }
  674.  
  675. //--------------------------------------------------------------------------
  676. // ODPart ----> Release
  677. //--------------------------------------------------------------------------
  678.  
  679. SOM_Scope       void
  680. SOMLINK         BaseContainerRelease
  681.                 (
  682.                 BaseContainer   *somSelf,       // in
  683.                 Environment     *ev            // in
  684.                 )
  685. {
  686.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  687.     BaseContainerMethodDebug("BaseContainer","BaseContainerRelease");
  688.  
  689.     BaseContainer_parent_ODPart_Release(somSelf, ev);
  690.     if (somSelf->GetRefCount(ev) == 0) {
  691.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart (ev, _fPartWrapper);
  692.     }
  693. }
  694.  
  695. //--------------------------------------------------------------------------
  696. // ODPart ----> ReleaseAll
  697. //--------------------------------------------------------------------------
  698.  
  699. SOM_Scope       void
  700. SOMLINK         BaseContainerReleaseAll
  701.                 (
  702.                 BaseContainer   *somSelf,       // in
  703.                 Environment     *ev            // in
  704.                 )
  705. {
  706.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  707.     BaseContainerMethodDebug("BaseContainer","BaseContainerReleaseAll");
  708.  
  709.     ODSafeReleaseObject((ODRefCntObject *)_fMenuBar);
  710.     ODSafeReleaseObject((ODRefCntObject *)_fEditMenu);
  711.     ODSafeReleaseObject((ODRefCntObject *)_fEmbedMenu);
  712.  
  713.     ODReleaseObject (ev, _fSelectShape);
  714.     ODReleaseObject (ev, _fCornerHandleShape);
  715.     ODReleaseObject (ev, _fEdgeHandleShape);
  716.  
  717. #ifdef _PLATFORM_OS2_
  718.  
  719.     if( _hSmallIcon ) WinDestroyPointer(_hSmallIcon);
  720.     if( _hLargeIcon ) WinDestroyPointer(_hLargeIcon);
  721.     if( _hThumbnail ) WinDestroyPointer(_hThumbnail);
  722.  
  723. #elif defined(_PLATFORM_UNIX_)
  724.  
  725.     if (_iconWidget) {
  726.        XtUnmanageChild(_iconWidget);
  727.        XtDestroyWidget(_iconWidget);
  728.     }
  729.  
  730.     // Get the screen
  731.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  732.  
  733.     if( _hSmallIcon ) XmDestroyPixmap(screen, _hSmallIcon);
  734.     if( _hLargeIcon ) XmDestroyPixmap(screen, _hLargeIcon);
  735.     if( _hThumbnail ) XmDestroyPixmap(screen, _hThumbnail);
  736.  
  737. #endif
  738.  
  739.     // Free the resource module.
  740.     somSelf->FreeResModule(ev);
  741.  
  742.     BaseContainer_parent_ODPart_ReleaseAll(somSelf, ev);
  743.  
  744.     //----------------------------------------------------------------------
  745.     // The references to the extension objects in our instance data, are not
  746.     // reference counted.  The extension will invoke our ReleaseExtension
  747.     // method (because we are the registered BaseObject) when the reference
  748.     // count goes to zero (meaning no OTHER references to the extension object
  749.     // are being retained and no other user exists for the extension).
  750.     // ReleaseExtension will delete the object and clear our instance pointer.
  751.     // Here we address the case of perhaps removing the extension's baseObject
  752.     // before all other references are released.  In that case we need to inform
  753.     // the Extension that we are no longer available as the BaseObject, by
  754.     // invoking BaseRemoved of the extension.
  755.     //----------------------------------------------------------------------
  756. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  757.     if (_fScrollExt != kODNULL) {
  758.        _fScrollExt->BaseRemoved(ev);
  759.     }
  760.     if (_fPrintExt != kODNULL) {
  761.        _fPrintExt->BaseRemoved(ev);
  762.     }
  763. #endif // OS/2 or Win95/NT
  764.  
  765.     if (_fSettingsExt != kODNULL) {
  766.        _fSettingsExt->BaseRemoved(ev) ;
  767.     }
  768. }
  769.  
  770. // -------------------------------------------------------------------------
  771. // BaseContainer --> Initialize
  772. //
  773. //      Common code needed by the InitPart* methods.
  774. //
  775. //      -> private method of BaseContainer
  776. // -------------------------------------------------------------------------
  777.  
  778. SOM_Scope       void
  779. SOMLINK         BaseContainerInitialize
  780.                 (
  781.                 BaseContainer   *somSelf,       // in
  782.                 Environment     *ev,             // in
  783.                 ODPart          *partWrapper    // in
  784.                 )
  785. {
  786.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  787.     BaseContainerMethodDebug("BaseContainer", "BaseContainerInitialize");
  788.  
  789.  
  790.  
  791.     try {
  792.  
  793.         // Cache references to Session object and other global values
  794.         _fSession    =   somSelf->GetStorageUnit(ev)
  795.                                 ->GetSession(ev);
  796.         _fDraftReadOnly = (somSelf->GetStorageUnit(ev)->GetDraft(ev)->GetPermissions(ev) == kODDPReadOnly);
  797.         _fNeedToInternalize = kODFalse;
  798.  
  799. #ifdef _PLATFORM_UNIX_
  800.         _fDisplay = _fSession->GetWindowState(ev)->GetDisplay(ev);
  801. #endif
  802.  
  803.  
  804.         // Tokenize Foci
  805.         _fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
  806.         _fMenuFocus      = _fSession->Tokenize(ev, kODMenuFocus);
  807.         _fKeyFocus       = _fSession->Tokenize(ev, kODKeyFocus);
  808.         _fModalFocus     = _fSession->Tokenize(ev, kODModalFocus);
  809.  
  810.         // for clipboard menuitem enable/disable in AdjustMenus method
  811.         _fClipboardFocus = _fSession->Tokenize(ev,kODClipboardFocus);
  812.  
  813.         // for tracking mouse events for click and drag
  814.         _fMouseFocus        = _fSession->Tokenize(ev,kODMouseFocus);
  815.         _fMouseFocusOutside = _fSession->Tokenize(ev, kODMouseUpOutsideFocus);
  816.         if (_fSession->GetArbitrator(ev)->IsFocusRegistered (ev, _fMouseFocusOutside) == kODFalse)
  817.            _fSession->GetArbitrator (ev)->RegisterFocus (ev, _fMouseFocusOutside, kODNULL);
  818.  
  819.         // Create a Focus Set for this Part Handler
  820.         _fFocusSet = _fSession->GetArbitrator(ev)
  821.                               ->CreateFocusSet(ev);
  822.         _fFocusSet->Add(ev, _fKeyFocus);
  823.         _fFocusSet->Add(ev, _fMenuFocus);
  824.         _fFocusSet->Add(ev, _fSelectionFocus);
  825.  
  826.         // Set up linked lists of Frames
  827.         _fDisplayFrames  = new ALinkedList;
  828.         _fEmbeddedObjects = new ALinkedList;
  829.         _fSelectedObjects = new ALinkedList;
  830.  
  831.         //
  832.         _fMouseStart = new ODPoint;
  833.  
  834.         // Tokenize ViewTypes and presentation strings
  835.         _fFrameView     = _fSession->Tokenize(ev, kODViewAsFrame);
  836.         _fSmallIconView = _fSession->Tokenize(ev, kODViewAsSmallIcon);
  837.         _fLargeIconView = _fSession->Tokenize(ev, kODViewAsLargeIcon);
  838.         _fThumbnailView = _fSession->Tokenize(ev, kODViewAsThumbnail);
  839.  
  840.         // Initialize value of previous viewtype variable
  841.         _fPrevViewType = _fFrameView;
  842.  
  843.         // initialize background color (arbitrary choices)
  844.         _fBackgroundColor = somSelf->ColorSelection(ev,_fBackgroundColor,0);
  845.  
  846.  
  847.  
  848.         // Create shapes for storing selection border
  849.         // We do not have frame or facet here, so cannot use factory methods
  850.         _fSelectShape = new ODShape();
  851.         _fSelectShape->InitShape(ev);
  852.         _fSelectShape->Acquire(ev);
  853.         _fCornerHandleShape = new ODShape();
  854.         _fCornerHandleShape->InitShape(ev);
  855.         _fCornerHandleShape->Acquire(ev);
  856.         _fEdgeHandleShape = new ODShape();
  857.         _fEdgeHandleShape->InitShape(ev);
  858.         _fEdgeHandleShape->Acquire(ev);
  859.  
  860.         _moveData = _resizeData = _lassoData = kODNULL;
  861.  
  862.          //-------//   Create MenuBar for BaseContainer Part   //------//
  863.  
  864.  
  865.         _fMenuBar = somSelf->GetStorageUnit(ev)
  866.                            ->GetSession(ev)
  867.                            ->GetWindowState(ev)->CopyBaseMenuBar(ev);
  868.  
  869.         if (_fMenuBar)
  870.             somSelf->InstallMenuItems (ev, _fMenuBar);
  871.  
  872. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  873.         somSelf->AcquireExtension(ev, kODPrintExtension) ;
  874. #endif
  875.     }  // end of try block
  876.     catch (...) {}
  877.  
  878. }
  879.  
  880.  
  881. // -------------------------------------------------------------------------
  882. // BaseContainer --> InstallMenuItems
  883. // -------------------------------------------------------------------------
  884.  
  885.  
  886. SOM_Scope       void
  887. SOMLINK         BaseContainerInstallMenuItems
  888.                 (
  889.                 BaseContainer   *somSelf,       // in
  890.                 Environment     *ev,             // in
  891.                 ODMenuBar       *menuBar
  892.                 )
  893. {
  894.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  895.     BaseContainerMethodDebug("BaseContainer", "BaseContainerInstallMenuItems");
  896.  
  897. #if defined(__IBMCPP__) || defined(_IBMR2)
  898.     nl_catd bcNLSCat;       // NLS message catalog handle
  899.     char *bcText;           // pointer for NLS message
  900.     setlocale(LC_MESSAGES, NULL);
  901.     bcNLSCat = catopen("iodbasec.cat", 0);
  902.     if (bcNLSCat == CATD_ERR)
  903.            {
  904.               PRINT("Could not open BaseContainer Message catalog!\n");
  905.            }
  906. #else
  907.     char bcText[256];
  908. #endif
  909.  
  910.     menuBar->Acquire(ev);
  911.  
  912.     ODPlatformMenuItem *mi = new ODPlatformMenuItem;
  913.  
  914.     // clear the memory
  915.     memset (mi, 0, sizeof(ODPlatformMenuItem));
  916.  
  917.     // add a menu separator line to EDIT menu
  918.     somSelf->AddSeparatorToMenu(ev, menuBar, IDMS_EDIT, CMD(Dash));
  919.  
  920.     // add MOVE selection item to EDIT menu
  921.     mi->id=CMD(Move);
  922.     somSelf->CreateMenuItemFromCatalog(ev,
  923.                                        menuBar,
  924.                                        IDMS_EDIT,
  925.                                        mi,
  926.                                        bcNLSCat,
  927.                                        BCMSG_SET,
  928.                                        PLATFORMSTRID(BC_MOVE),
  929.                                        "Move");
  930.  
  931.     // add MOVEFRONT selection item to EDIT menu
  932.     mi->id=CMD(MoveFront);
  933.     somSelf->CreateMenuItemFromCatalog(ev,
  934.                                        menuBar,
  935.                                        IDMS_EDIT,
  936.                                        mi,
  937.                                        bcNLSCat,
  938.                                        BCMSG_SET,
  939.                                        PLATFORMSTRID(BC_MOVE2FRONT),
  940.                                        "Move To Front");
  941.  
  942.     // add MOVEBACK selection item to EDIT menu
  943.     mi->id=CMD(MoveBack);
  944.     somSelf->CreateMenuItemFromCatalog(ev,
  945.                                        menuBar,
  946.                                        IDMS_EDIT,
  947.                                        mi,
  948.                                        bcNLSCat,
  949.                                        BCMSG_SET,
  950.                                        PLATFORMSTRID(BC_MOVE2BACK),
  951.                                        "Move To Back");
  952.  
  953.     // add RESIZE selection item to EDIT menu
  954.     mi->id=CMD(Resize);
  955.     somSelf->CreateMenuItemFromCatalog(ev,
  956.                                        menuBar,
  957.                                        IDMS_EDIT,
  958.                                        mi,
  959.                                        bcNLSCat,
  960.                                        BCMSG_SET,
  961.                                        PLATFORMSTRID(BC_RESIZE),
  962.                                        "Resize");
  963.  
  964.  
  965.     // add EMBED menu to MenuBar line
  966.     somSelf->CreateNewMenu(ev, menuBar, kODEmbedMenuID);
  967.     mi->id=kODEmbedMenuID;
  968.     somSelf->SetMenuItemTextFromCatalog(ev,
  969.                                        menuBar,
  970.                                        ID_BASEMENUBAR,
  971.                                        mi,
  972.                                        bcNLSCat,
  973.                                        BCMSG_SET,
  974.                                        PLATFORMSTRID(BC_EMBED),
  975.                                        "Embed");
  976.  
  977.  
  978.     somSelf->BuildEmbedMenu(ev, mi);
  979.  
  980.     //  Add color menu item
  981.     somSelf->CreateNewMenu(ev, menuBar, kODOptionsMenuID);
  982.     mi->id=kODOptionsMenuID;
  983.     somSelf->SetMenuItemTextFromCatalog(ev,
  984.                                        menuBar,
  985.                                        ID_BASEMENUBAR,
  986.                                        mi,
  987.                                        bcNLSCat,
  988.                                        BCMSG_SET,
  989.                                        PLATFORMSTRID(BC_OPTIONS),
  990.                                        "Options");
  991.  
  992.  
  993.     // add COLOR CHANGE selection item to COLOR menu
  994.     mi->id=kODCommandColorCHANGE;
  995.     somSelf->CreateMenuItemFromCatalog(ev,
  996.                                        menuBar,
  997.                                        kODOptionsMenuID,
  998.                                        mi,
  999.                                        bcNLSCat,
  1000.                                        BCMSG_SET,
  1001.                                        PLATFORMSTRID(BC_COLOR_CHG),
  1002.                                        "Change Background");
  1003.  
  1004.    //let's add help menu items ONLY if this is base container
  1005.    // and not its subclass
  1006.    if (!strcmp (somSelf->somGetClassName(), kBCClassName))
  1007.    {
  1008.  
  1009.     // add a menu separator line to HELP menu
  1010.     somSelf->AddSeparatorToMenu(ev, menuBar, IDMS_HELP, CMD(Dash));
  1011.  
  1012.     // add a menu item Base Container Help to HELP menu
  1013.     mi->id=CMD(Help);
  1014.     somSelf->CreateMenuItemFromCatalog(ev,
  1015.                                        menuBar,
  1016.                                        IDMS_HELP,
  1017.                                        mi,
  1018.                                        bcNLSCat,
  1019.                                        BCMSG_SET,
  1020.                                        PLATFORMSTRID(BC_HELP),
  1021.                                        "Base Container Help");
  1022.  
  1023.    } // end if this is a subclass
  1024.  
  1025.     // we can now release the MenuBar
  1026.     menuBar->Release(ev);
  1027.  
  1028.     delete mi;                      // cleanup menuitem buffer
  1029.  
  1030. #if defined(__IBMCPP__) || defined(_IBMR2)
  1031.     catclose(bcNLSCat);             // close the message catalog
  1032. #endif
  1033.  
  1034. }
  1035.  
  1036.  
  1037.  
  1038. //--------------------------------------------------------------------------
  1039. // BaseContainer -->  BuildEmbedMenu
  1040. //
  1041. //      Change the color of a container part background
  1042. //--------------------------------------------------------------------------
  1043.  
  1044. SOM_Scope       void
  1045. SOMLINK         BaseContainerBuildEmbedMenu
  1046.                 (
  1047.                 BaseContainer   *somSelf,       // in
  1048.                 Environment     *ev,            // in
  1049.                 ODPlatformMenuItem *mi          // in
  1050.                 )
  1051. {
  1052.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1053.     BaseContainerMethodDebug("BaseContainer","BaseContainerBuildEmbedMenu");
  1054.  
  1055.     char    *list;                       // list of registered part handlers
  1056.     char    *dlist;                      // list of part handler display name
  1057.     wchar_t *wlist;                      // list of registered part handlers
  1058.     wchar_t *delimiter=0;                // delimiter (",") between names in list
  1059.     wchar_t *end;                        // pointer to end of list
  1060.     wchar_t *cursor;                     // pointer to char in list
  1061.     wchar_t *wEmbedItem = new wchar_t[256]; // embed menu item
  1062.  
  1063.     unsigned long emptysize=1;           // size of 1 to get actual size
  1064.     unsigned long goodsize=0;            // actual size of the list (above)
  1065.     int i=0;                             // counter
  1066.     int rc;
  1067.  
  1068.     list=new char[emptysize];
  1069.     rc=ODQueryPartHandlerList(0, (char *)list, (ODULong) &goodsize);
  1070.  
  1071.  
  1072.     list=new char[goodsize];             // get list based on the size returned
  1073.     rc=ODQueryPartHandlerList(0, (char*)list, (ODULong) &goodsize);
  1074.  
  1075.     wlist=new wchar_t[goodsize];         // convert to wchar_t for NLS processing
  1076.     mbstowcs(wlist,list,sizeof(wchar_t)*goodsize);
  1077.  
  1078.     end = wlist + wcslen(wlist) + 1;     // set pointer to the end of the list
  1079.  
  1080.     _fEmbedTableParts=0;                 // assume zero parts in the list
  1081.     int nCommas = 0;
  1082.  
  1083.     if (wcslen(wlist)>0)
  1084.        nCommas++;                        // something in list, at least one part
  1085.  
  1086.                                        // count commas for number of editors
  1087.                                        // then allocate fEmbedTable to count
  1088.     for (cursor=wlist; (cursor < end); cursor++) if(*cursor==L',') nCommas++;
  1089.         _fEmbedTable=new char *[nCommas];
  1090.  
  1091.     for (cursor=wlist, i=0; (cursor < end); i++)
  1092.     {
  1093.         delimiter = wcschr(cursor, L','); // find first/next occurence
  1094.         if(delimiter==NULL) delimiter=end;
  1095.  
  1096.                                        // copy part handler name from list
  1097.         memcpy(wEmbedItem, cursor, sizeof(wchar_t)*(delimiter-cursor));
  1098.         *(wEmbedItem + (delimiter - cursor)) = NULL;
  1099.  
  1100.  
  1101.         if(wcslen(wEmbedItem)>0)       // skip empty fields (NULL parthandler)
  1102.         {
  1103.                                        // allocate mbs string to hold handler
  1104.             _fEmbedTable[_fEmbedTableParts] = new char[wcslen(wEmbedItem) + 1];
  1105.             wcstombs(_fEmbedTable[_fEmbedTableParts],wEmbedItem,wcslen(wEmbedItem)+1);
  1106. // -----------------  Display PartHandlerDisplayName in Embed menu -----------
  1107.             goodsize = 0;
  1108.             dlist=new char[emptysize]; // get size of name from query
  1109.             rc=ODQueryHandlerDisplayName(0, (char *)dlist, (ODULong) &goodsize);
  1110.             dlist=new char[goodsize];  // new dlist and then get display name
  1111.             rc=ODQueryHandlerDisplayName(_fEmbedTable[_fEmbedTableParts], (char *)dlist, (ODULong) &goodsize);
  1112. // -----------------  dlist is PartHandlerDisplayName ------------------------
  1113.             mi->id=CMD(Parts)+_fEmbedTableParts;
  1114.             _fMenuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  1115.             _fMenuBar->SetMenuItemText(ev, kODEmbedMenuID, mi->id, dlist);
  1116.             _fEmbedTableParts++;
  1117.           // now go to next part handler
  1118.         } // if null parthandler received
  1119.  
  1120.         cursor = delimiter +1;
  1121.  
  1122.     } // for loop parsing comma-separated PartHandlerList
  1123.  
  1124. } // end of BuildEmbedMenu
  1125.  
  1126.  
  1127. //--------------------------------------------------------------------------
  1128. // BaseContainer --> Embed
  1129. //
  1130. //      Should perform the actual embed of a new embedded part ?
  1131. //
  1132. //      ->
  1133. //--------------------------------------------------------------------------
  1134.  
  1135. SOM_Scope       ContentObject*
  1136. SOMLINK         BaseContainerEmbed
  1137.                 (
  1138.                 BaseContainer   *somSelf,           // in
  1139.                 Environment     *ev,                // in
  1140.                 ODType          part,               // in
  1141.                 ODFrame         *containingFrame,   // in
  1142.                 ODTransform     *newEmbedTransform  // in
  1143.                 )
  1144. {
  1145.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1146.     BaseContainerMethodDebug("BaseContainer", "BaseContainerEmbed");
  1147.  
  1148.     try {
  1149.  
  1150.         // have the Draft instantiate the part
  1151.         // call CreatePart with parthandler name as optional editor, this
  1152.         // keeps binding from loading only the preferred editor.
  1153.         TempODPart embeddedPart =
  1154.                        _fPartSU->GetDraft(ev)->CreatePart(ev, kODNULL, part );
  1155.  
  1156.         if (embeddedPart == kODNULL)
  1157.            return kODNULL;
  1158.  
  1159.         // create a shape for the new part using default dimensions
  1160.         ODShape* newShape = containingFrame->CreateShape(ev);
  1161.         ODRect* rect = new ODRect;
  1162. #if defined(_PLATFORM_OS2_)
  1163.         rect->left    = 0;
  1164.         rect->top     = ODIntToFixed(DEFAULT_EMBED_HEIGHT);;
  1165.         rect->right   = ODIntToFixed(DEFAULT_EMBED_WIDTH);
  1166.         rect->bottom  = 0;
  1167. #elif (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  1168.         rect->left    = 0;
  1169.         rect->top     = 0;
  1170.         rect->right   = ODIntToFixed(DEFAULT_EMBED_WIDTH);
  1171.         rect->bottom  = ODIntToFixed(DEFAULT_EMBED_HEIGHT);
  1172. #endif
  1173. //        newShape->NewShape(ev);
  1174.         newShape->SetRectangle(ev, rect);
  1175.         delete rect;
  1176.  
  1177.         // create the new frame using this shape
  1178.         ODFrame* newFrame = _fPartSU->GetDraft(ev)->CreateFrame(ev,
  1179.                                         kODFrameObject,     // frameType
  1180.                                         containingFrame,    // containingFrame
  1181.                                         newShape,           // frameShape
  1182.                                         (ODCanvas*)kODNULL, // biasCanvas
  1183.                                         embeddedPart,       // part
  1184.                                         _fFrameView,        // viewType
  1185.                                         _fSession->Tokenize(ev, kODPresDefault),
  1186.                                         kODFalse,           // isRoot
  1187.                                         kODFalse);          // isOverlaid
  1188.  
  1189.         // add new frame to the container's list of Embedded Frames
  1190.         ContentFrame *contFrame = new ContentFrame();
  1191.         contFrame->_set_myFrame(ev, newFrame);
  1192.         _fEmbeddedObjects->AddLast(ev, contFrame);
  1193.  
  1194.         // get the clip shape of the newly created frame
  1195.         // (the part may have changed it from the default 100x100 shape)
  1196.         TempODShape clipShape = newFrame->AcquireFrameShape(ev, kODNULL);
  1197.  
  1198. #if defined (_PLATFORM_OS2_)
  1199.          // make sure that the new part appears so that its top left is at hotspot
  1200.          ODRect frameRect;
  1201.          clipShape->GetBoundingBox (ev, &frameRect);
  1202.          ODPoint offset(0,0);
  1203.          offset.y = frameRect.bottom - frameRect.top;
  1204.          newEmbedTransform->MoveBy (ev, &offset);
  1205. #endif
  1206.  
  1207.         // create an embedded facet for the embedded frame
  1208.         ODFrameFacetIterator *facets = containingFrame->CreateFacetIterator(ev);
  1209.         for (ODFacet* containingFacet = facets->First(ev);
  1210.                                facets->IsNotComplete(ev);
  1211.                                      containingFacet = facets->Next(ev))
  1212.         {
  1213.  
  1214.             ODFacet* embeddedFacet = containingFacet->CreateEmbeddedFacet(ev,
  1215.                               newFrame,          // frame
  1216.                               clipShape,         // clipShape
  1217.                               newEmbedTransform, // externalTransform
  1218.                               kODNULL,           // canvas
  1219.                               kODNULL,           // biasCanvas
  1220.                               kODNULL,           // siblingFacet
  1221.                               kODFrameInFront);  // position
  1222.  
  1223. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  1224. /* Move scroll bars above newly embedded part in Z-order */
  1225.             if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  1226.                _fScrollExt->GeometryChanged(ev, containingFacet, kODFalse, kODTrue);
  1227.             } /* endif */
  1228. #endif //defined OS2 || WIN32
  1229.  
  1230.             embeddedFacet->Invalidate(ev, kODNULL, kODNULL);
  1231.         }
  1232.         delete facets;
  1233.  
  1234.         somSelf->ChangeNotification (ev, BCC_EMBED, containingFrame,
  1235.                                      (ContentObject *)contFrame, kODTrue, kODNULL);
  1236.         return (ContentObject *) contFrame;
  1237.  
  1238.     }  // end of try block
  1239.  
  1240.     catch (ODException _exception) {
  1241.  
  1242.        int Error = ErrorCode();
  1243.        PRINT("Clearing exception %d\n", Error);
  1244.        SetErrorCodeEv (ev, kODNoError);
  1245.     }
  1246.  
  1247.     return kODNULL;
  1248. }
  1249.  
  1250.  
  1251. //--------------------------------------------------------------------------
  1252. // ODPart --> Open
  1253. //
  1254. //      Should create or activate a window in which a frame of this part
  1255. //      is the root frame.
  1256. //
  1257. //      ->
  1258. //--------------------------------------------------------------------------
  1259.  
  1260. SOM_Scope       ODID
  1261. SOMLINK         BaseContainerOpen
  1262.                 (
  1263.                 BaseContainer   *somSelf,       // in
  1264.                 Environment     *ev,            // in
  1265.                 ODFrame         *frame          // in
  1266.                 )
  1267. {
  1268.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1269.     BaseContainerMethodDebug("BaseContainer","BaseContainerOpen");
  1270.  
  1271.  
  1272.     ODID windowID = 0;
  1273.  
  1274.     TempODWindow window = kODNULL;
  1275.  
  1276.     try {
  1277.  
  1278.     ODWindowState* winState=_fSession->GetWindowState(ev);
  1279.  
  1280.     if (frame) {
  1281.         if (frame->IsRoot(ev)) {
  1282.             WindowProperties props;
  1283.             BeginGetWindowProperties(ev, frame, &props);
  1284.  
  1285.             ODULong flCreateFlags = props.createFlags;
  1286.  
  1287.  
  1288.             ODPlatformWindow platwin = winState->CreatePlatformWindow(ev, kODFalse);
  1289.  
  1290. #if defined(_PLATFORM_WIN32_)
  1291.             SetWindowPos(platwin,
  1292.                          HWND_TOP,
  1293.                          props.boundsRect.left,
  1294.                          props.boundsRect.top,
  1295.                          props.boundsRect.right,
  1296.                          props.boundsRect.bottom,
  1297.                          SWP_NOACTIVATE | SWP_NOREDRAW);
  1298. #elif defined(_PLATFORM_OS2_)
  1299.          WinSetWindowPos(platwin,
  1300.                          HWND_TOP,
  1301.                          props.boundsRect.xLeft,
  1302.                          props.boundsRect.yBottom,
  1303.                          props.boundsRect.xRight,
  1304.                          props.boundsRect.yTop,
  1305.                          props.swpFlags | SWP_SIZE | SWP_MOVE);
  1306.  
  1307. #elif defined(_PLATFORM_UNIX_)
  1308.             Widget TopLevelShellWidget = XtWindowToWidget(winState->GetDisplay(ev), platwin);
  1309.             XtVaSetValues(TopLevelShellWidget,
  1310.                           XmNx, props.boundsRect.x,
  1311.                           XmNy, props.boundsRect.y,
  1312.                           XmNwidth, props.boundsRect.width,
  1313.                           XmNheight, props.boundsRect.height,
  1314.                           NULL);
  1315. #endif
  1316.             window = _fSession->GetWindowState(ev)
  1317.                               ->RegisterWindowForFrame( ev,
  1318.                                                         platwin,
  1319.                                                         frame,
  1320.                                                         props.isRootWindow,
  1321.                                                         props.isResizable,
  1322.                                                         props.isFloating,
  1323.                                                         kODTrue,
  1324.                                                         kODTrue,
  1325.                                                         props.sourceFrame);
  1326.  
  1327.             EndGetWindowProperties(ev, &props);     // release source frame
  1328.  
  1329.             window->Open(ev);
  1330.             window->Show(ev);
  1331.             }
  1332.  
  1333.         else {
  1334. // This is commented out to temporarily disable the Open As Window capability
  1335.             //window=winState->AcquireWindow(ev, _fWindowID);
  1336.             //if (window) {
  1337.             //    window->Select(ev);
  1338.             //    }
  1339.             //else {
  1340.             //    window = somSelf->MakeWindow(ev,frame);
  1341.             //   _fWindowID= window->GetID(ev);
  1342.             //    window->Open(ev);
  1343.             //    window->Show(ev);
  1344.             //    window->Select(ev);
  1345.             //    }
  1346.  
  1347.             } // end of frame->IsRoot
  1348.         } // end of frame
  1349.  
  1350.     else {
  1351.         window = somSelf->MakeWindow(ev, frame);
  1352.         _fWindowID=window->GetID(ev);
  1353.         window->Open(ev);
  1354.         window->Show(ev);
  1355.         window->Select(ev);
  1356.  
  1357.  
  1358.         }
  1359.  
  1360.     if (window)
  1361.        windowID= window->GetID(ev);
  1362.  
  1363.    }  // end of try block
  1364.    catch (...) {}
  1365.  
  1366.  
  1367.     return windowID;
  1368. }
  1369.  
  1370.  
  1371.  
  1372. //--------------------------------------------------------------------------
  1373. // BaseContainer --> CreateWindow
  1374. //
  1375. //      Should create or activate a window in which a frame of this part
  1376. //      is the root frame.
  1377. //
  1378. //      ->
  1379. //--------------------------------------------------------------------------
  1380.  
  1381. SOM_Scope       ODWindow*
  1382. SOMLINK         BaseContainerMakeWindow
  1383.                 (
  1384.                 BaseContainer   *somSelf,       // in
  1385.                 Environment     *ev,            // in
  1386.                 ODFrame         *sourceFrame    // in
  1387.                 )
  1388. {
  1389.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1390.     BaseContainerMethodDebug("BaseContainer","BaseContainerMakeWindow");
  1391.  
  1392.     ODPlatformWindow platwin = kODNULL;
  1393.  
  1394.     ODWindow* window         = kODNULL;
  1395.  
  1396.  
  1397.     try {
  1398.  
  1399.     ODWindowState* winState=_fSession->GetWindowState(ev);
  1400.  
  1401.     platwin = winState->CreatePlatformWindow(ev, kODFalse);
  1402.  
  1403.     window = winState->RegisterWindow(ev,
  1404.                     platwin,
  1405.                     kODFrameObject,       // frameType
  1406.                     sourceFrame==kODNULL, // isRootWindow
  1407.                     kODTrue,              // isResizable
  1408.                     kODFalse,             // isFloating
  1409.                     kODTrue,              // shouldSave
  1410.                     kODTrue,              // shouldDispose
  1411.                     _fPartWrapper,        // rootPart
  1412.                     _fSession->Tokenize(ev, kODViewAsFrame), // ViewType
  1413.                     _fSession->Tokenize(ev, kODPresDefault), // presentation
  1414.                     sourceFrame           // sourceFrame
  1415.                     );
  1416.  
  1417.     }  // end of try block
  1418.     catch (...) {}
  1419.  
  1420.  
  1421.     return window;
  1422. }
  1423.  
  1424.  
  1425. //--------------------------------------------------------------------------
  1426. // BaseContainer --> ColorSelection
  1427. //
  1428. //      Change the color of a container part background
  1429. //--------------------------------------------------------------------------
  1430.  
  1431. SOM_Scope       COLORREF
  1432. SOMLINK         BaseContainerColorSelection
  1433.                 (
  1434.                 BaseContainer   *somSelf,       // in
  1435.                 Environment     *ev,            // in
  1436.                 COLORREF        origColor,      // in
  1437.                 long            theflag         // in
  1438.                 )
  1439. {
  1440.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1441.     BaseContainerMethodDebug("BaseContainer","BaseContainerColorSelection");
  1442.  
  1443. #if defined(_PLATFORM_WIN32_)
  1444.     HDC hdc;
  1445.     CHOOSECOLOR colorstruct;
  1446.     COLORREF clrCustom[16];
  1447. #elif defined(_PLATFORM_OS2_)
  1448.     HPS hps;
  1449. #elif defined(_PLATFORM_UNIX_)
  1450.     static int fColorIndex = 0;
  1451.     XColor clrcell, rgbdef;
  1452. #endif
  1453.     int rc;
  1454.     COLORREF newColor;
  1455.  
  1456.     static int fColor = 0;
  1457.     static int fDelta = 64;
  1458.  
  1459.     static int fRed   = 96;
  1460.     static int fGreen = 96;
  1461.     static int fBlue  = 96;
  1462.  
  1463. //----------------------------------------------------------------------------
  1464. // --------- this is used during part initialization -------------------------
  1465. // --------- cycles through a range of colors, cycles embedded frame's colors-
  1466. //----------------------------------------------------------------------------
  1467. try {
  1468. if (theflag == 0)
  1469. {
  1470.     // cycle through the color spectrum
  1471.     fColor=(fColor+1)%3;
  1472.     switch (fColor)
  1473.     {
  1474.     case 0:
  1475.          fRed=(fRed+fDelta)%256;
  1476.          break;
  1477.  
  1478.     case 1:
  1479.          fBlue=(fBlue+fDelta)%256;
  1480.          break;
  1481.  
  1482.     case 2:
  1483.          fGreen=(fGreen+fDelta)%256;
  1484.          break;
  1485.     }
  1486. #if defined(_PLATFORM_UNIX_)
  1487.     // cycle through colors using above
  1488.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  1489.     Colormap cmap = XDefaultColormapOfScreen(screen);
  1490.     clrcell.flags = DoRed | DoGreen | DoBlue;
  1491.     clrcell.red = fRed * 256;
  1492.     clrcell.green = fGreen * 256;
  1493.     clrcell.blue = fBlue * 256;
  1494.     rc = XAllocColor(_fDisplay, cmap, &clrcell);
  1495.     if (rc == 0)   // Alloc failed
  1496.        {
  1497.           PRINT("OPENDOC couldn't get a color\n");
  1498.           newColor = origColor;
  1499.        }
  1500.     else newColor = clrcell.pixel;
  1501.  
  1502. #elif defined(_PLATFORM_OS2_)
  1503.     newColor = fBlue + (256L   * (long) fGreen) + (65536L * (long) fRed);
  1504. #elif defined(_PLATFORM_WIN32_)
  1505.     newColor = RGB(fRed,fGreen,fBlue);
  1506. #endif
  1507. } // end of cycle thru color spectrum
  1508.  
  1509.  
  1510. //----------------------------------------------------------------------------
  1511. //---- this is used when OPTION/ChangeBackground Menu is selected ------------
  1512. //---- WIN and OS2 use dialog boxes. UNIX currently just reads array of color-
  1513. //----------------------------------------------------------------------------
  1514. else
  1515. {
  1516. #if defined(_PLATFORM_OS2_)
  1517.      CHAR  Error[256] = "";
  1518.      HMODULE hmod;
  1519.      // Array of binary values for RGB value
  1520.      SHORT NewColors[3] = {0, 0, 0};
  1521.  
  1522.      ODWindowState* WinStat =  _fSession->GetWindowState(ev);
  1523.      // Use TempODWindow so this object won't have to be released.
  1524.      TempODWindow Window = WinStat->AcquireFrontRootWindow(ev);
  1525.      HWND hwnd = Window->GetPlatformWindow(ev);
  1526.      DosLoadModule( Error, sizeof(Error), "iodbasec", &hmod );
  1527.  
  1528.      // calculate from a long in the format of 0x--RRGGBB where -- not used
  1529.      // to shorts in the form of 0-255 for each RGB
  1530.      NewColors[RED]   = (SHORT) ((origColor / 65536L) & 0x000000FF);
  1531.      NewColors[GREEN] = (SHORT) ((origColor / 256L) & 0x000000FF);
  1532.      NewColors[BLUE]  = (SHORT) (origColor & 0x000000FF);
  1533.  
  1534.      // call procedures for bringing up rc file and user changing colors
  1535.      rc = ColorWindow(hmod, hwnd, NewColors);
  1536.  
  1537.      // calculate back to a long in the format of 0x--RRGGBB where -- not used
  1538.      newColor = NewColors[BLUE] +
  1539.                     (256L   * (long) NewColors[GREEN]) +
  1540.                     (65536L * (long) NewColors[RED]);
  1541.  
  1542. #elif defined(_PLATFORM_WIN32_)
  1543.  
  1544.       ODWindowState* WinStat =  _fSession->GetWindowState(ev);
  1545.       // Use TempODWindow so this object won't have to be released.
  1546.       TempODWindow Window = WinStat->AcquireActiveWindow(ev);
  1547.       HWND hwnd = Window->GetPlatformWindow(ev);
  1548.       // set up structure to pass to color dialog routine
  1549.       memset(&colorstruct, 0, sizeof(colorstruct));
  1550.       colorstruct.lStructSize = sizeof(colorstruct);
  1551.       colorstruct.hwndOwner = hwnd;
  1552.       colorstruct.rgbResult = RGB(0, 0, 0);
  1553.       colorstruct.Flags = CC_RGBINIT;
  1554.       for (fColor=0; fColor<16; fColor++)
  1555.         clrCustom[fColor] = RGB(255, 255, 255);
  1556.       colorstruct.lpCustColors = clrCustom;
  1557.       if (ChooseColor(&colorstruct))
  1558.           newColor = colorstruct.rgbResult;
  1559.        else
  1560.           newColor = origColor;
  1561.  
  1562. #elif defined(_PLATFORM_UNIX_)
  1563.     // cycle through color array defined at top of file for now
  1564.     // no color selection dialog set up yet
  1565.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  1566.     Colormap cmap = XDefaultColormapOfScreen(screen);
  1567.     fColorIndex=(fColorIndex+1)%15;
  1568.     rc=XAllocNamedColor(_fDisplay,cmap, colors[fColorIndex], &clrcell, &rgbdef);
  1569.     if (rc == 0)   // Alloc failed
  1570.        {
  1571.           PRINT("OPENDOC couldn't get %s color\n",colors[fColorIndex]);
  1572.           newColor = origColor;
  1573.        }
  1574.     else  newColor = clrcell.pixel;
  1575.  
  1576. #endif
  1577. } // end resource files use
  1578.  
  1579.  
  1580. return newColor;
  1581.  
  1582. }  // end of try block
  1583. catch (...) {
  1584.    PRINT("Exception occurred during color selection\n");
  1585.    PRINT("Please check color availability and try again\n");
  1586.    return origColor;
  1587.    }  // end catch block
  1588.  
  1589. } // end of ColorSelection
  1590.  
  1591.  
  1592. // ** Group 2
  1593. //--------------------------------------------------------------------------
  1594. // ODPart --> RequestEmbeddedFrame
  1595. //
  1596. //      Should create a new display frame for the specified embedded part.
  1597. //
  1598. //      ->
  1599. //--------------------------------------------------------------------------
  1600.  
  1601. SOM_Scope       ODFrame*
  1602. SOMLINK         BaseContainerRequestEmbeddedFrame
  1603.                 (
  1604.                 BaseContainer   *somSelf,           // in
  1605.                 Environment     *ev,                // in
  1606.                 ODFrame         *containingFrame,   // in
  1607.                 ODFrame         *baseFrame,         // in
  1608.                 ODShape         *frameShape,        // in
  1609.                 ODPart          *embedPart,         // in
  1610.                 ODTypeToken      viewType,          // in
  1611.                 ODTypeToken      presentation,      // in
  1612.                 ODBoolean        isOverlaid         // in
  1613.                 )
  1614. {
  1615.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1616.     BaseContainerMethodDebug("BaseContainer", "BaseContainerRequestEmbeddedFrame");
  1617.     ODFrame *newFrame = NULL;
  1618.  
  1619.     try {
  1620.  
  1621.         // Invert the mouse coords (placing it in the containing frame coords)
  1622.         //xform->InvertPoint(ev, _fCrossHair);
  1623.  
  1624.         // create new external transform to this location
  1625.         ODTransform* newEmbedTransform = containingFrame->CreateTransform(ev);
  1626.         //newEmbedTransform->SetOffset(ev, _fCrossHair);
  1627.  
  1628.         // create a shape for the new part (default to 100x100)
  1629.         ODShape* newShape = containingFrame->CreateShape(ev);
  1630.  
  1631.         ODRect* rect = new ODRect;
  1632.  
  1633. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  1634.         rect->left    = 0;
  1635.         rect->top     = 0;
  1636.         rect->right   = ODIntToFixed(100);
  1637.         rect->bottom  = ODIntToFixed(100);
  1638. #elif defined(_PLATFORM_OS2_)
  1639.         rect->left    = 0;
  1640.         rect->top     = ODIntToFixed(100);
  1641.         rect->right   = ODIntToFixed(100);
  1642.         rect->bottom  = 0;
  1643. #endif
  1644.  
  1645. //        newShape->NewShape(ev);
  1646.         newShape->SetRectangle(ev, rect);
  1647.  
  1648.         delete rect;
  1649.  
  1650.         // create the new frame using this shape
  1651.         newFrame = _fPartSU->GetDraft(ev)->CreateFrame(ev,
  1652.                                         kODFrameObject,     // frameType
  1653.                                         containingFrame,    // containingFrame
  1654.                                         newShape,           // frameShape
  1655.                                         (ODCanvas*)kODNULL, // biasCanvas
  1656.                                         embedPart,         // part
  1657.                                         _fFrameView,        // viewType
  1658.                                         _fSession->Tokenize(ev, kODPresDefault),
  1659.                                         kODFalse,           // isRoot
  1660.                                         kODFalse);          // isOverlaid
  1661.  
  1662.         // add new frame to the container's list of Embedded Frames
  1663.         ContentFrame *contFrame = new ContentFrame();
  1664.         contFrame->_set_myFrame(ev, newFrame);
  1665.         _fEmbeddedObjects->AddLast(ev, contFrame);
  1666.  
  1667.         // get the clip shape of the newly created frame
  1668.         // (the part may have changed it from the default 100x100 shape)
  1669.         TempODShape clipShape = newFrame->AcquireFrameShape(ev, kODNULL);
  1670.  
  1671.         // create an embedded facet for the embedded frame
  1672.         ODFacet *containingFacet = FirstFacet(ev, containingFrame);
  1673.         ODFacet* embeddedFacet = containingFacet->CreateEmbeddedFacet(ev,
  1674.                               newFrame,          // frame
  1675.                               clipShape,         // clipShape
  1676.                               newEmbedTransform, // externalTransform
  1677.                               kODNULL,           // canvas
  1678.                               kODNULL,           // biasCanvas
  1679.                               kODNULL,           // siblingFacet
  1680.                               kODFrameInFront);  // position
  1681.  
  1682.         embeddedFacet->Invalidate(ev, newShape, kODNULL);
  1683.  
  1684.     }  // end of try block
  1685.     catch (...) {}
  1686.  
  1687.  
  1688.     return newFrame;
  1689. }
  1690.  
  1691.  
  1692.  
  1693. //--------------------------------------------------------------------------
  1694. // ODPart --> RequestFrameShape
  1695. //
  1696. //      Should negotiate a new frame shape for the specified frame
  1697. //      embedded part.
  1698. //
  1699. //      ->
  1700. //--------------------------------------------------------------------------
  1701.  
  1702. SOM_Scope       ODShape*
  1703. SOMLINK         BaseContainerRequestFrameShape
  1704.                 (
  1705.                 BaseContainer   *somSelf,       // in
  1706.                 Environment     *ev,            // in
  1707.                 ODFrame         *embeddedFrame, // in
  1708.                 ODShape         *frameShape     // in
  1709.                 )
  1710. {
  1711.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1712.     BaseContainerMethodDebug("BaseContainer","BaseContainerRequestFrameShape");
  1713.  
  1714.     try {
  1715.  
  1716.        // look for bad parameters
  1717.        if (embeddedFrame == kODNULL)
  1718.           return frameShape;
  1719.  
  1720.        if (frameShape == kODNULL)
  1721.        {
  1722.           // we use ODShape so that we increment the shape ref count
  1723.           ODShape *shape = embeddedFrame->AcquireFrameShape (ev, kODNULL);
  1724.           return shape;
  1725.        }
  1726.  
  1727.        // Store old embedded frame shape for future invalidation
  1728.        TempODShape currentShape = embeddedFrame->AcquireFrameShape (ev, kODNULL);
  1729.        TempODShape invalidShape = currentShape->Copy(ev);
  1730.  
  1731.        // Convert invalidShape from embedded frame coordinates to container's content coordinates.
  1732.        TempODTransform extXform = FirstFacet(ev, embeddedFrame)->AcquireExternalTransform(ev, kODNULL);
  1733.        invalidShape->Transform(ev, extXform);
  1734.  
  1735.        // tell the embed what the new shape is
  1736.        TempODShape tShape = frameShape->Copy (ev);
  1737.        embeddedFrame->ChangeFrameShape(ev, tShape, kODNULL);
  1738.  
  1739.        ODFrameFacetIterator* i = embeddedFrame->CreateFacetIterator(ev);
  1740.        ODFacet* facet = kODNULL;
  1741.        ODFacet* firstFacet;
  1742.  
  1743.        for (firstFacet = facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  1744.        {
  1745.           // Update the clipshape of each embedded facet
  1746.           TempODShape newFrameShape = frameShape->Copy (ev);
  1747.           facet->ChangeGeometry(ev, newFrameShape, kODNULL, kODNULL);
  1748.        }
  1749.  
  1750.        delete i;
  1751.  
  1752.        // Acquire the shape so that it will be released by the caller
  1753.        frameShape->Acquire(ev);
  1754.  
  1755.        // If the frame is selected...
  1756.        if( firstFacet && (firstFacet->IsSelected(ev) == kODTrue) )
  1757.        {
  1758.           // Account for selection border of old shape
  1759.           invalidShape->Outset(ev, kODBorderWidth);
  1760.  
  1761.           // Recalculate selection border
  1762.           somSelf->CreateSelectionBorderShapes (ev, kODNULL);
  1763.  
  1764.           // Include new selection border in invalid shape
  1765.           TempODShape newSelectShape = _fSelectShape->Copy(ev);
  1766.           invalidShape->Union(ev, newSelectShape);
  1767.        }
  1768.  
  1769.        TempODFrame myFrame = embeddedFrame->AcquireContainingFrame (ev);
  1770.        i = myFrame->CreateFacetIterator(ev);
  1771.        ODFacet* myFacet = i->First(ev);
  1772.        delete i;
  1773.  
  1774.        // Transform invalidShape from content coordinates to frame coordinates
  1775.        TempODTransform intXForm = myFrame->AcquireInternalTransform(ev, kODNULL);
  1776.        invalidShape->Transform(ev, intXForm);
  1777.  
  1778.        // Invalidate this part's facet
  1779.        myFacet->Invalidate(ev, invalidShape, kODNULL);
  1780.  
  1781.        // call change notification
  1782.        somSelf->ChangeNotification (ev, BCC_EMBEDSHAPECHANGED, myFrame,
  1783.                                     GetContentObjectForFrame(embeddedFrame, _fEmbeddedObjects),
  1784.                                     kODTrue, kODNULL);
  1785.  
  1786.     }  // end of try block
  1787.     catch (...) {}
  1788.  
  1789.  
  1790.     return frameShape;
  1791. }
  1792.  
  1793. //--------------------------------------------------------------------------
  1794. // ODPart --> CreateEmbeddedFramesIterator
  1795. //
  1796. //      Should create an embedded frames iterator to give callers
  1797. //      access to all embedded frames of this part.
  1798. //
  1799. //      ->
  1800. //--------------------------------------------------------------------------
  1801.  
  1802. SOM_Scope       ODEmbeddedFramesIterator*
  1803. SOMLINK         BaseContainerCreateEmbeddedFramesIterator
  1804.                 (
  1805.                 BaseContainer   *somSelf,       // in
  1806.                 Environment     *ev,            // in
  1807.                 ODFrame         *frame          // in
  1808.                 )
  1809. {
  1810.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1811.     BaseContainerMethodDebug("BaseContainer", "BaseContainerCreateEmbeddedFramesIterator");
  1812.  
  1813.  
  1814.     // Create the Iterator object
  1815.     BCIterator *embeddedFramesIterator = new BCIterator;
  1816.  
  1817.     try {
  1818.  
  1819.     // we then initialize it
  1820.     embeddedFramesIterator->InitEmbeddedFramesIterator(ev,_fPartWrapper);
  1821.  
  1822.     }  // end of try block
  1823.     catch (...) {}
  1824.  
  1825.     // lastly, return it to the caller
  1826.     return embeddedFramesIterator;
  1827. }
  1828.  
  1829.  
  1830.  
  1831. //--------------------------------------------------------------------------
  1832. // ODPart --> RemoveEmbeddedFrame
  1833. //
  1834. //      Should remove the specified embedded frame from this part's
  1835. //      content.
  1836. //
  1837. //      ->
  1838. //--------------------------------------------------------------------------
  1839.  
  1840. SOM_Scope       void
  1841. SOMLINK         BaseContainerRemoveEmbeddedFrame
  1842.                 (
  1843.                 BaseContainer   *somSelf,       // in
  1844.                 Environment     *ev,            // in
  1845.                 ODFrame         *embeddedFrame  // in
  1846.                 )
  1847. {
  1848.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1849.     BaseContainerMethodDebug("BaseContainer", "BaseContainerRemoveEmbeddedFrame");
  1850.  
  1851.    ALink *itr;
  1852.    ContentFrame *theObj;
  1853.    for(itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  1854.        ContentFrame *cobj = (ContentFrame *) itr->Content(ev);
  1855.        if ((cobj->_get_objType(ev) == COBJ_FRAMECLASS) && (cobj->_get_myFrame(ev) == embeddedFrame)) {
  1856.           theObj = cobj;
  1857.           break;
  1858.        }
  1859.    }
  1860.    _fEmbeddedObjects->Remove(ev, theObj);
  1861.  
  1862. }
  1863.  
  1864.  
  1865. //--------------------------------------------------------------------------
  1866. // BaseContainer --> GetDisplayFrames
  1867. //
  1868. //      Get the DisplayFrames list value for ODEmbeddedFramesIterator
  1869. //
  1870. //      ->
  1871. //--------------------------------------------------------------------------
  1872.  
  1873. SOM_Scope       ALinkedList *
  1874. SOMLINK         BaseContainerGetDisplayFrames
  1875.                 (
  1876.                 BaseContainer   *somSelf,       // in
  1877.                 Environment     *ev             // in
  1878.                 )
  1879. {
  1880.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1881.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetDisplayFrames");
  1882.  
  1883.     return _fDisplayFrames;
  1884.  
  1885. }
  1886.  
  1887.  
  1888. //--------------------------------------------------------------------------
  1889. // BaseContainer --> GetEmbeddedObjects
  1890. //
  1891. //      Get the EmbeddedObjects list value for ODEmbeddedFramesIterator
  1892. //
  1893. //      ->
  1894. //--------------------------------------------------------------------------
  1895.  
  1896. SOM_Scope       ALinkedList *
  1897. SOMLINK         BaseContainerGetEmbeddedObjects
  1898.                 (
  1899.                 BaseContainer   *somSelf,       // in
  1900.                 Environment     *ev             // in
  1901.                 )
  1902. {
  1903.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1904.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetEmbeddedObjects");
  1905.  
  1906.     return _fEmbeddedObjects;
  1907.  
  1908. }
  1909.  
  1910.  
  1911. //--------------------------------------------------------------------------
  1912. // BaseContainer --> GetSelectedObjects
  1913. //
  1914. //      Get the SelectedObjects list value
  1915. //
  1916. //      ->
  1917. //--------------------------------------------------------------------------
  1918.  
  1919. SOM_Scope       ALinkedList *
  1920. SOMLINK         BaseContainerGetSelectedObjects
  1921.                 (
  1922.                 BaseContainer   *somSelf,       // in
  1923.                 Environment     *ev             // in
  1924.                 )
  1925. {
  1926.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1927.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetSelectedObjects");
  1928.  
  1929.     return _fSelectedObjects;
  1930.  
  1931. }
  1932.  
  1933.  
  1934. //--------------------------------------------------------------------------
  1935. // BaseContainer --> GetMenuBar
  1936. //
  1937. //--------------------------------------------------------------------------
  1938.  
  1939. SOM_Scope       ODMenuBar *
  1940. SOMLINK         BaseContainerGetMenuBar
  1941.                 (
  1942.                 BaseContainer   *somSelf,       // in
  1943.                 Environment     *ev             // in
  1944.                 )
  1945. {
  1946.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1947.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetMenuBar");
  1948.  
  1949.     return _fMenuBar;
  1950.  
  1951. }
  1952.  
  1953. //--------------------------------------------------------------------------
  1954. // BaseContainer --> GetBackgroundColor
  1955. //
  1956. //--------------------------------------------------------------------------
  1957.  
  1958. SOM_Scope       COLORREF
  1959. SOMLINK         BaseContainerGetBackgroundColor
  1960.                 (
  1961.                 BaseContainer   *somSelf,       // in
  1962.                 Environment     *ev             // in
  1963.                 )
  1964. {
  1965.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1966.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetBackgroundColor");
  1967.  
  1968.     return _fBackgroundColor;
  1969.  
  1970. }
  1971.  
  1972.  
  1973. //--------------------------------------------------------------------------
  1974. // BaseContainer --> SetBackgroundColor
  1975. //
  1976. //--------------------------------------------------------------------------
  1977.  
  1978. SOM_Scope       void
  1979. SOMLINK         BaseContainerSetBackgroundColor
  1980.                 (
  1981.                 BaseContainer   *somSelf,       // in
  1982.                 Environment     *ev,            // in
  1983.                 COLORREF        color           // in
  1984.                 )
  1985. {
  1986.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1987.     BaseContainerMethodDebug("BaseContainer","BaseContainerSetBackgroundColor");
  1988.  
  1989.     _fBackgroundColor = color;
  1990.  
  1991. #ifdef _PLATFORM_UNIX_
  1992. // In X, an expose event will cause a redraw of any widgets.  Normally in
  1993. // Opendoc, setting an invalidate will do the same (by calling DrawContents),
  1994. // but in BaseContainer, our DrawContents only draws if it is off screen.
  1995. // Therefore, if the background color has changed, we need to reset the
  1996. // background color resource of our frames & facets.  This will avoid X
  1997. // defaulting to the desktop's background color instead of the new color.
  1998.  
  1999.        ALink *itr = kODNULL;
  2000.        for (itr = _fDisplayFrames->First (ev); itr->Content(ev); itr = itr->Next(ev))
  2001.          {
  2002.              // Loop through all the frame's facets and if they have
  2003.              // widgets, set the widgets' background colors.
  2004.              ODFrameFacetIterator* i = ((ODFrame *) itr->Content(ev))->CreateFacetIterator(ev);
  2005.              ODFacet* facet = kODNULL;
  2006.  
  2007.              for (facet = i->First(ev);
  2008.                   i->IsNotComplete(ev);
  2009.                   facet = i->Next(ev))
  2010.              {
  2011.                  // If the facet has a widget.  It won't if the facet
  2012.                  // is non-dynamic or is offscreen
  2013.                  Widget widget = facet->GetFacetWidget(ev);
  2014.                  if (widget)
  2015.                  {
  2016.                      XtVaSetValues(widget,
  2017.                                    XmNbackground, _fBackgroundColor,
  2018.                                    NULL);
  2019.                  }
  2020.              }
  2021.  
  2022.              delete i;
  2023.          } // end for
  2024. #endif
  2025.  
  2026.  
  2027.  
  2028. }
  2029.  
  2030.  
  2031. // ** Group 3
  2032. // -------------------------------------------------------------------------
  2033. // ODPart --> Draw
  2034. //
  2035. //      Should draw this part within the area that needs updating in the
  2036. //      specified facet.
  2037. //
  2038. //      ->
  2039. // -------------------------------------------------------------------------
  2040.  
  2041. SOM_Scope       void
  2042. SOMLINK         BaseContainerDraw
  2043.                 (
  2044.                 BaseContainer   *somSelf,       // in
  2045.                 Environment     *ev,            // in
  2046.                 ODFacet         *facet,         // in
  2047.                 ODShape         *invalidShape   // in
  2048.                 )
  2049. {
  2050.    BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2051.    BaseContainerMethodDebug("BaseContainer","BaseContainerDraw");
  2052.  
  2053.  
  2054.    try {
  2055.  
  2056.       ODTypeToken viewType = facet->GetFrame(ev)->GetViewType(ev);
  2057.  
  2058.       if(viewType == _fSmallIconView)
  2059.       {
  2060.          somSelf->DrawIcon(ev, facet, invalidShape, _fSmallIconView);
  2061.       }
  2062.       else if(viewType == _fLargeIconView)
  2063.       {
  2064.          somSelf->DrawIcon(ev, facet, invalidShape, _fLargeIconView);
  2065.       }
  2066.       else if(viewType == _fThumbnailView)
  2067.       {
  2068.          somSelf->DrawThumbnail(ev, facet, invalidShape);
  2069.       }
  2070.       else
  2071.       {
  2072.          somSelf->DrawFrame(ev, facet, invalidShape);
  2073.       }
  2074.  
  2075.    }  // end of try block
  2076.    catch (...) {}
  2077.  
  2078.  
  2079. }
  2080.  
  2081.  
  2082. // -------------------------------------------------------------------------
  2083. // BaseContainerPart --> DrawContents
  2084. //
  2085. // -------------------------------------------------------------------------
  2086.  
  2087. SOM_Scope       ODBoolean
  2088. SOMLINK         BaseContainerDrawContents
  2089.                 (
  2090.                 BaseContainer   *somSelf,       // in
  2091.                 Environment     *ev,            // in
  2092.                 ODFacet         *facet,          // in
  2093.                 ODShape         *invalidShape
  2094.                 )
  2095. {
  2096.  
  2097.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2098.     BaseContainerMethodDebug("BaseContainer","BaseContainerDrawContents");
  2099.  
  2100.     ODFrame* displayFrame = facet->GetFrame(ev);
  2101.     ODCanvas *canvas = facet->GetCanvas(ev);
  2102.     TempODShape shape = ODCopyAndRelease(ev,
  2103.        displayFrame->AcquireFrameShape(ev, canvas));
  2104.  
  2105. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  2106. /* Make sure we are drawing the portion of our content that is currently     */
  2107. /* scrolled into view (AcquireFrameShape returns shape in frame coordinates; */
  2108. /* we have to transform that into our content coordinates).                  */
  2109.     if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  2110.        TempODTransform internalXform = displayFrame->AcquireInternalTransform(ev,
  2111.           canvas);
  2112.        shape->InverseTransform(ev, internalXform);
  2113.     } /* endif */
  2114. #endif //defined OS2 || WIN32
  2115.  
  2116.     ODRect rect;
  2117.     shape->GetBoundingBox(ev, &rect);
  2118.     Rect frameRect;
  2119.  
  2120.     // Convert to Window's rectangle
  2121. #if defined(_PLATFORM_OS2_)
  2122.       frameRect.xLeft = FixedToInt(rect.left);
  2123.       frameRect.yTop  = FixedToInt(rect.top);
  2124.       frameRect.xRight  = FixedToInt(rect.right);
  2125.       frameRect.yBottom  = FixedToInt(rect.bottom);
  2126.  
  2127.       HPS hdc;
  2128.       CFocus focus(facet, invalidShape, &hdc);
  2129.  
  2130.      // Clip the facet. This will prevent any children from drawing outside of the
  2131.      // facet. This is a problem when we have overlapping parts and native
  2132.      // controls as children of the facet
  2133.      ODRgnHandle clipRegion = facet->CopyFacetClipRegion(ev,hdc);
  2134.      WinSetClipRegion(facet->GetFacetHWND(ev), clipRegion);
  2135.  
  2136.       GpiCreateLogColorTable (hdc, 0L, LCOLF_RGB, 0L, 0L, 0L);
  2137.       GpiSetColor(hdc, _fBackgroundColor);
  2138.       POINTL orig = {0, 0};
  2139.       GpiMove(hdc, &orig);
  2140.       POINTL ptl = {frameRect.xRight, frameRect.yTop};
  2141.       GpiBox(hdc, DRO_FILL, &ptl, 0, 0);
  2142.  
  2143. #elif defined(_PLATFORM_UNIX_)
  2144. // BaseContainer really only draws it's background color in it's draw method.
  2145. // In AIX, this is really just a no-op, since X draws it's own background
  2146. // color on its widgets when an expose event occurs.  So rather than calling a
  2147. // draw method that isn't necessary we've wrapped it in a check for whether it
  2148. // is offscreen or not.  In that case, X doesn't draw automatically and this
  2149. // background draw is needed.
  2150. // - See comments in SetBackgroundColor method and FacetAdded methods
  2151.  
  2152.     // If the canvas is not dynamic or is offscreen.
  2153.     // We don't need to draw otherwise as the facet will have a
  2154.     // widget and the widget will take care of filling its background
  2155.  if ((!canvas->IsDynamic(ev)) || (canvas->IsOffscreen(ev)))
  2156.    {
  2157.  
  2158.     XRectangle rgnBox;
  2159.  
  2160.     // Get the AIX Window canvas information
  2161.     ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  2162.                       (canvas->GetPlatformCanvas(ev, kODAIX));
  2163.     Window window = aixwincanvas->GetWindow(ev);
  2164.  
  2165.     // Get the canvas graphic context
  2166.     GC gc;
  2167.     CFocus focus(facet, invalidShape, &gc);
  2168.  
  2169.     XSetForeground(_fDisplay, gc, _fBackgroundColor);
  2170.  
  2171.     Region shapeRgn;
  2172.  
  2173.     TempODTransform xform = facet->AcquireContentTransform(ev, canvas);
  2174.     TempODShape tempShape = shape->Copy(ev);
  2175.     tempShape->Transform(ev, xform);
  2176.     shapeRgn = tempShape->GetRegion(ev);
  2177.  
  2178.     XSetRegion(_fDisplay, gc, shapeRgn);
  2179.  
  2180.     XClipBox(shapeRgn, &rgnBox);
  2181.  
  2182.     XFillRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  2183.  
  2184.    }
  2185. #elif defined(_PLATFORM_WIN32_)
  2186.        SetRect(&frameRect, FixedToInt(rect.left),
  2187.                        FixedToInt(rect.top),
  2188.                        FixedToInt(rect.right),
  2189.                        FixedToInt(rect.bottom));
  2190.  
  2191.       HDC hdc;
  2192.       CFocus focus(facet, invalidShape, &hdc);
  2193.  
  2194.        // Create a solid brush
  2195.        HBRUSH hbr = CreateSolidBrush (_fBackgroundColor);
  2196.  
  2197.        // Fill the rectangle with the brush
  2198.        FillRect (hdc, &frameRect, hbr);
  2199.  
  2200.        // Get rid of the brush
  2201.        DeleteObject (hbr);
  2202.  
  2203. #ifdef ODDebug
  2204.        // Set up a font for the text - ensure it doesn't get too small
  2205.        LOGFONT labelFont;
  2206.        memset(&labelFont, 0, sizeof(labelFont));
  2207.        labelFont.lfPitchAndFamily = FF_SCRIPT;
  2208.        labelFont.lfItalic = 1;
  2209.        labelFont.lfHeight = (frameRect.bottom - frameRect.top) / 12;
  2210.        if (labelFont.lfHeight < 16)
  2211.        {
  2212.            labelFont.lfHeight = 16;
  2213.        }
  2214.        labelFont.lfQuality = PROOF_QUALITY;
  2215.        lstrcpy((LPSTR)labelFont.lfFaceName, (LPSTR)"Cursive");
  2216.  
  2217.        // Create the font and select it
  2218.        HFONT hFont = CreateFontIndirect(&labelFont);
  2219.        HFONT hOldFont;
  2220.        hOldFont = SelectObject(hdc, hFont);
  2221.  
  2222.        // Write some text on the screen using a transparent background and
  2223.        // white text
  2224.        SetBkMode(hdc, TRANSPARENT);
  2225.        SetTextColor(hdc, 0x00FFFFFF);
  2226.        char *text = "Base Container part";
  2227.        /* DrawText(hdc,
  2228.                 text,
  2229.                 strlen(text),
  2230.                 &frameRect,
  2231.                 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  2232.        */
  2233.        // Remove the temporary font
  2234.        SelectObject(hdc, hOldFont);
  2235.        DeleteObject(hFont);
  2236. #endif
  2237.  
  2238. #endif  // end WIN32 specific
  2239.  
  2240.        return kODTrue;
  2241. }
  2242.  
  2243.  
  2244. // -------------------------------------------------------------------------
  2245. // ODPart --> GetPrintResolution
  2246. //
  2247. // -------------------------------------------------------------------------
  2248.  
  2249. SOM_Scope       ODULong
  2250. SOMLINK         BaseContainerGetPrintResolution
  2251.                 (
  2252.                 BaseContainer   *somSelf,       // in
  2253.                 Environment     *ev,            // in
  2254.                 ODFrame         *frame          // in
  2255.                 )
  2256. {
  2257.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2258.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetPrintResolution");
  2259.  
  2260.     return kODNULL;
  2261. }
  2262.  
  2263. //--------------------------------------------------------------------------
  2264. // ODPart --> AdjustBorderShape
  2265. //
  2266. //      Should adjust the shape of an embedded frame's active frame
  2267. //      border.
  2268. //
  2269. //      ->
  2270. //--------------------------------------------------------------------------
  2271. SOM_Scope       ODShape*
  2272. SOMLINK         BaseContainerAdjustBorderShape
  2273.                 (
  2274.                 BaseContainer   *somSelf,       // in
  2275.                 Environment     *ev,            // in
  2276.                 ODFacet         *embeddedFacet, // in
  2277.                 ODShape         *shape          // in
  2278.                 )
  2279. {
  2280.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2281.     BaseContainerMethodDebug("BaseContainer","BaseContainerAdjustBorderShape");
  2282.  
  2283.  
  2284.  
  2285.     try {
  2286.  
  2287.     // we increment the ref count so that the shape doesn't go away too soon
  2288.     // fix from JRB
  2289.     if (shape)
  2290.        shape->Acquire(ev);
  2291.  
  2292.     }  // end of try block
  2293.     catch (...) {}
  2294.  
  2295.     return shape;
  2296. }
  2297.  
  2298.  
  2299. //--------------------------------------------------------------------------
  2300. // BaseContainer --> CreateSelectionBorderShapes
  2301. //
  2302. //      Creates border shapes and adds them to the instance variables
  2303. //      fSelectShape, fCornerHandleShape, fEdgeHandleShape
  2304. //      If ODFrame is passed in, then shapes are computed for that
  2305. //      particular frame and are added to the existing ones.
  2306. //      if frame == kODNULL then shapaes are computed for all the
  2307. //      frames in the list of selected frames.
  2308. //
  2309. //--------------------------------------------------------------------------
  2310.  
  2311. SOM_Scope       ODBoolean
  2312. SOMLINK         BaseContainerCreateSelectionBorderShapes
  2313.                 (
  2314.                 BaseContainer   *somSelf,       // in
  2315.                 Environment     *ev,            // in
  2316.                 ContentObject   *contentObject    // in
  2317.                 )
  2318. {
  2319.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2320.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateSelectionBorderShapes");
  2321.  
  2322.  
  2323.     try {
  2324.  
  2325.     ODFrame *myFrame = (ODFrame*)(_fDisplayFrames->First(ev)->Content(ev));
  2326.  
  2327.     if (contentObject) {
  2328.  
  2329.        // Create and add border
  2330.        TempODShape sShape = myFrame->CreateShape(ev);
  2331.        TempODShape cShape = myFrame->CreateShape(ev);
  2332.        TempODShape eShape = myFrame->CreateShape(ev);
  2333.  
  2334.        // Get the facet and transform
  2335.        ODRect rect = contentObject->_get_boundingRect (ev);
  2336.  
  2337.        somSelf->GetBorderShapes (ev, &rect, sShape, cShape, eShape);
  2338.  
  2339.        // Add these shapes to the existing ones
  2340.        _fSelectShape->Union (ev, sShape);
  2341.        _fCornerHandleShape->Union (ev, cShape);
  2342.        _fEdgeHandleShape->Union (ev, eShape);
  2343.     }
  2344.  
  2345.     else {
  2346.  
  2347.        // Need to create shapes for all the objects in selected list
  2348.  
  2349.        _fSelectShape->Reset (ev);
  2350.        _fCornerHandleShape->Reset (ev);
  2351.        _fEdgeHandleShape->Reset (ev);
  2352.  
  2353.        for(ALink *link=_fSelectedObjects->First(ev); link->Content(ev); link=link->Next(ev))
  2354.        {
  2355.             ContentObject *cObj = (ContentObject *)link->Content(ev);
  2356.  
  2357.             TempODShape sShape = myFrame->CreateShape(ev);
  2358.             TempODShape cShape = myFrame->CreateShape(ev);
  2359.             TempODShape eShape = myFrame->CreateShape(ev);
  2360.  
  2361.             // Get the rect
  2362.             ODRect rect = cObj->_get_boundingRect (ev);
  2363.  
  2364.             somSelf->GetBorderShapes (ev, &rect, sShape, cShape, eShape);
  2365.  
  2366.             // Add these shapes to the existing ones
  2367.             _fSelectShape->Union (ev, sShape);
  2368.             _fCornerHandleShape->Union (ev, cShape);
  2369.             _fEdgeHandleShape->Union (ev, eShape);
  2370.        }
  2371.  
  2372.     }
  2373.     } // end try block
  2374.     catch (...) {}
  2375.  
  2376.     return kODTrue;
  2377. }
  2378.  
  2379.  
  2380. //--------------------------------------------------------------------------
  2381. // BaseContainer --> GetBorderShapes
  2382. //
  2383. //      Creates border shapes.
  2384. //
  2385. //--------------------------------------------------------------------------
  2386.  
  2387. SOM_Scope       ODBoolean
  2388. SOMLINK         BaseContainerGetBorderShapes
  2389.                 (
  2390.                 BaseContainer   *somSelf,        // in
  2391.                 Environment     *ev,            // in
  2392.                 ODRect          *rect,
  2393.                 ODShape         *selectShape,    // in
  2394.                 ODShape         *cornerShape,    // in
  2395.                 ODShape         *edgeShape
  2396.                 )
  2397. {
  2398.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2399.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetBorderShapes");
  2400.  
  2401.  
  2402.     try {
  2403.  
  2404.     ODRect bbox = *rect, bboxSave;
  2405.  
  2406.     ODShape *tempShape = new ODShape();
  2407.     tempShape->InitShape(ev);
  2408.     tempShape->Acquire (ev);
  2409.     tempShape->SetRectangle(ev, &bbox);
  2410.  
  2411.     InflateRect(&bbox, kODBorderWidth, kODBorderWidth);
  2412.     bboxSave = bbox;
  2413.     selectShape->SetRectangle(ev, &bbox);
  2414.     selectShape->Subtract(ev, tempShape);
  2415.  
  2416.     // -- corner region --
  2417.  
  2418.     cornerShape->CopyFrom(ev, selectShape);
  2419.     InflateRect(&bbox, -kODHandleLenMultiplier *kODBorderWidth, 0);
  2420.     tempShape->SetRectangle(ev, &bbox);
  2421.     cornerShape->Subtract(ev, tempShape);
  2422.     bbox = bboxSave;
  2423.     InflateRect(&bbox, 0, -kODHandleLenMultiplier *kODBorderWidth);
  2424.     tempShape->SetRectangle(ev, &bbox);
  2425.     cornerShape->Subtract(ev, tempShape);
  2426.  
  2427.     // -- edge region --
  2428.  
  2429.     ODRect arect[4];
  2430.     bbox = bboxSave;
  2431.  
  2432.     arect[0] = arect[1] = arect[2] = arect[3] = bbox;
  2433.     arect[0].right -= (bbox.right-bbox.left)/2;
  2434.     arect[0].top -= (bbox.top-bbox.bottom)/2;
  2435.     arect[1].left = arect[0].right+0x10000;
  2436.     arect[1].top = arect[0].top;
  2437.     arect[2].left = arect[0].right+0x10000;
  2438.     arect[2].bottom = arect[0].top+0x10000;
  2439.     arect[3].right = arect[0].right;
  2440.     arect[3].bottom = arect[0].top+0x10000;
  2441.  
  2442.     if ((bbox.right-bbox.left) >= (5*kODHandleLenMultiplier *kODBorderWidth))
  2443.     {
  2444.         /* top and bottom handles  */
  2445.         long hdist = (kODHandleLenMultiplier *kODBorderWidth)/2;
  2446.  
  2447.         arect[0].right -= hdist;
  2448.         arect[1].left += hdist;
  2449.         arect[2].left = arect[1].left;
  2450.         arect[3].right = arect[0].right;
  2451.     }
  2452.  
  2453. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  2454.     if ((bbox.bottom-bbox.top) >= (5*kODHandleLenMultiplier *kODBorderWidth))
  2455. #elif defined(_PLATFORM_OS2_)
  2456.     if ((bbox.top-bbox.bottom) >= (5*kODHandleLenMultiplier *kODBorderWidth))
  2457. #endif
  2458.     {
  2459.         /* left and right handles */
  2460.         long vdist = (kODHandleLenMultiplier *kODBorderWidth)/2;
  2461.  
  2462. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_))
  2463.         arect[0].top += vdist;
  2464.         arect[2].bottom -= vdist;
  2465. #elif defined(_PLATFORM_OS2_)
  2466.         arect[0].top -= vdist;
  2467.         arect[2].bottom += vdist;
  2468. #endif
  2469.         arect[1].top = arect[0].top;
  2470.         arect[3].bottom = arect[2].bottom;
  2471.     }
  2472.  
  2473.     edgeShape->CopyFrom(ev, selectShape);
  2474.  
  2475.     for (int i = 0; i < 4; i++)
  2476.     {
  2477.         tempShape->SetRectangle(ev, &arect[i]);
  2478.         edgeShape->Subtract(ev, tempShape);
  2479.     }
  2480.  
  2481.     ODReleaseObject (ev, tempShape);
  2482.  
  2483.     }  // end of try block
  2484.     catch (...) {}
  2485.  
  2486.     return kODTrue;
  2487.  
  2488. }
  2489.  
  2490. //--------------------------------------------------------------------------
  2491. // BaseContainer --> DrawSelectionBorder
  2492. //
  2493. //      Draw border shapes.
  2494. //
  2495. //--------------------------------------------------------------------------
  2496.  
  2497. SOM_Scope       ODBoolean
  2498. SOMLINK         BaseContainerDrawSelectionBorder
  2499.                 (
  2500.                 BaseContainer   *somSelf,        // in
  2501.                 Environment     *ev,             // in
  2502.                 ODFacet         *facet,
  2503.                 ODShape         *invalidShape
  2504.                )
  2505. {
  2506.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2507.     BaseContainerMethodDebug("BaseContainer","BaseContainerDrawSelectionBorder");
  2508.  
  2509.  
  2510.     try {
  2511.  
  2512.     if (_fSelectedObjects->Count(ev) == 0)
  2513.        return kODTrue;
  2514.  
  2515. #if defined(_PLATFORM_OS2_)
  2516.  
  2517.     ODBoolean bPrinting = facet->GetCanvas(ev)->HasPlatformPrintJob(ev, kODPM);
  2518.     if (bPrinting)
  2519.        return kODTrue;
  2520.  
  2521.     HPS hDC;
  2522.     CFocus focus(facet, invalidShape, &hDC);
  2523.  
  2524.  
  2525.     HRGN shapeRgn = GpiCreateRegion(hDC, 0, NULL);
  2526.     Rect rect;
  2527.     SIZEL sizlThickness = {1,1} ;
  2528.  
  2529.     GpiSavePS(hDC);
  2530.     GpiSetColor(hDC, CLR_DARKGRAY);
  2531.     TempODTransform xform = facet->AcquireContentTransform(ev, kODNULL);
  2532.     TempODShape tempShape = _fSelectShape->Copy(ev);
  2533.     tempShape->Transform(ev, xform);
  2534.     shapeRgn = tempShape->GetRegion(ev);
  2535.     GpiPaintRegion(hDC, shapeRgn);
  2536.  
  2537.     GpiSetColor(hDC, CLR_BLACK);
  2538.  
  2539.   tempShape->CopyFrom(ev, _fCornerHandleShape);
  2540.   tempShape->Union (ev, _fEdgeHandleShape);
  2541.   tempShape->Transform(ev, xform);
  2542.   shapeRgn = tempShape->GetRegion(ev);
  2543.   GpiPaintRegion(hDC, shapeRgn);
  2544.   GpiSetColor(hDC, CLR_DARKGRAY);
  2545.   GpiFrameRegion(hDC, shapeRgn, &sizlThickness);
  2546.  
  2547.  
  2548. //  GpiDestroyRegion(hDC, shapeRgn);
  2549.   GpiRestorePS(hDC, -1);
  2550.  
  2551.  
  2552. #elif defined(_PLATFORM_WIN32_)
  2553.  
  2554.     ODBoolean bPrinting = facet->GetCanvas(ev)->HasPlatformPrintJob(ev, kODWin32);
  2555.     if (bPrinting)
  2556.        return kODTrue;
  2557.  
  2558.     HDC hDC;
  2559.     CFocus focus(facet, invalidShape, &hDC);
  2560.  
  2561.     //Select Shape
  2562.  
  2563.     ODRgnHandle borderRgn  = _fSelectShape->GetRegion(ev);
  2564.     HBRUSH  hairBrush = CreateSolidBrush(RGB(192, 192, 192));
  2565.     HBRUSH  hbrOld = SelectObject(hDC, hairBrush);
  2566.  
  2567.     FillRgn(hDC, borderRgn, hairBrush);
  2568.     SelectObject(hDC, hbrOld);
  2569.     DeleteObject(hairBrush);
  2570.  
  2571.     //Corner Shape
  2572.  
  2573.     borderRgn  = _fCornerHandleShape->GetRegion(ev);
  2574.     hairBrush = CreateSolidBrush(RGB(36, 36, 36));
  2575.     hbrOld = SelectObject(hDC, hairBrush);
  2576.  
  2577.     FillRgn(hDC, borderRgn, hairBrush);
  2578.     SelectObject(hDC, hbrOld);
  2579.     DeleteObject(hairBrush);
  2580.  
  2581.     //Edge Shape
  2582.  
  2583.     borderRgn  = _fEdgeHandleShape->GetRegion(ev);
  2584.     hairBrush = CreateSolidBrush(RGB(0, 0, 0));
  2585.     hbrOld = SelectObject(hDC, hairBrush);
  2586.  
  2587.     FillRgn(hDC, borderRgn, hairBrush);
  2588.     SelectObject(hDC, hbrOld);
  2589.     DeleteObject(hairBrush);
  2590.  
  2591. #elif defined(_PLATFORM_UNIX_)
  2592.  
  2593.     ODBoolean bPrinting = facet->GetCanvas(ev)->HasPlatformPrintJob(ev, kODAIX);
  2594.     if (bPrinting)
  2595.        return kODTrue;
  2596.  
  2597.     unsigned int height, width;
  2598.     int x, y;
  2599.     XRectangle rgnBox;
  2600.  
  2601.     // Set grey and black colors for using in border
  2602.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  2603.     Colormap cmap = XDefaultColormapOfScreen(screen);
  2604.     XColor clrcell, rgbdef;
  2605.  
  2606.     XAllocNamedColor(_fDisplay, cmap, "black", &clrcell, &rgbdef);
  2607.     unsigned long black = clrcell.pixel;
  2608.     XAllocNamedColor(_fDisplay, cmap, "grey", &clrcell, &rgbdef);
  2609.     unsigned long grey = clrcell.pixel;
  2610.  
  2611.  
  2612.     // Get the AIX Window canvas information
  2613.     ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  2614.                       (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  2615.     Widget widget = aixwincanvas->GetWidget(ev);
  2616.     Window window = aixwincanvas->GetWindow(ev);
  2617.  
  2618.     GC gc;
  2619.     CFocus focus(facet, invalidShape, &gc);
  2620.  
  2621.     Region shapeRgn;
  2622.  
  2623.     TempODTransform xform = facet->AcquireContentTransform(ev, kODNULL);
  2624.     TempODShape tempShape = _fSelectShape->Copy(ev);
  2625.     tempShape->Transform(ev, xform);
  2626.     shapeRgn = tempShape->GetRegion(ev);
  2627.     XSetRegion(_fDisplay, gc, shapeRgn);
  2628.     XClipBox(shapeRgn, &rgnBox);
  2629.     XSetForeground(_fDisplay, gc, grey);
  2630.     XFillRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  2631.  
  2632.     XSetForeground(_fDisplay, gc, black);
  2633.  
  2634.     tempShape->CopyFrom(ev, _fCornerHandleShape);
  2635.     tempShape->Union(ev, _fEdgeHandleShape);
  2636.     tempShape->Transform(ev, xform);
  2637.     shapeRgn = tempShape->GetRegion(ev);
  2638.     XSetRegion(_fDisplay, gc, shapeRgn);
  2639.     XClipBox(shapeRgn, &rgnBox);
  2640.     XFillRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  2641.     XSetForeground(_fDisplay, gc, grey);
  2642.     XDrawRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  2643.  
  2644. #endif
  2645.     }  // end of try block
  2646.     catch (...) {}
  2647.  
  2648.     return kODTrue;
  2649.  
  2650. }
  2651.  
  2652.  
  2653. // ** Group 4
  2654. //--------------------------------------------------------------------------
  2655. // ODPart --> FacetAdded
  2656. //
  2657. //      Should notify this part that a facet has been added to one
  2658. //      of its display frames.
  2659. //
  2660. //      ->
  2661. //--------------------------------------------------------------------------
  2662.  
  2663. SOM_Scope       void
  2664. SOMLINK         BaseContainerFacetAdded
  2665.                 (
  2666.                 BaseContainer   *somSelf,       // in
  2667.                 Environment     *ev,            // in
  2668.                 ODFacet         *facet          // in
  2669.                 )
  2670. {
  2671.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2672.     BaseContainerMethodDebug("BaseContainer","BaseContainerFacetAdded");
  2673.  
  2674. #ifdef ODDebug
  2675.     //PRINT ("Facet added %lx   %d \n", somSelf, somSelf->GetRefCount(ev));
  2676. #endif
  2677.  
  2678.     try {
  2679.  
  2680.     // Since we have not created canvas, no need to set its owner
  2681.     //facet->GetCanvas(ev)->SetOwner(ev,_fPartWrapper);
  2682.  
  2683.     ODFrame *myFrame = facet->GetFrame (ev);
  2684.  
  2685.     somSelf->UpdateContentExtent(ev, myFrame);
  2686.  
  2687. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  2688.     ODCanvas *canvas = facet->GetCanvas(ev);
  2689.     if (canvas && canvas->IsDynamic(ev)) { /* don't do when printing */
  2690.        if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  2691.           _fScrollExt->FacetAdded(ev, facet);
  2692.        } /* endif */
  2693.     } /* endif */
  2694. #endif //defined OS2 || WIN32
  2695.  
  2696.     // internalize embedded stuff now (we had to wait for our facet).
  2697.     BCCloneInfo cloneInfo;
  2698.     memset (&cloneInfo, 0, sizeof(BCCloneInfo));
  2699.     cloneInfo.myFrame = myFrame;
  2700.  
  2701.     if (_fNeedToInternalize) {
  2702.         somSelf-> ReadContents (ev, somSelf->GetStorageUnit(ev), &cloneInfo, INTERNALIZE);
  2703.         _fNeedToInternalize = kODFalse;
  2704.  
  2705.     } else {
  2706.  
  2707.        ODFrame *dispFrame = facet->GetFrame(ev);
  2708.        ALink *itr;
  2709.  
  2710.        for (itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2711.        {
  2712.             ContentFrame *cObj = (ContentFrame *) itr->Content(ev);
  2713.             if ( (cObj->_get_objType(ev) == COBJ_FRAMECLASS) &&
  2714.                          (cObj->_get_containingFrame(ev) == dispFrame))
  2715.             {
  2716.                ODFrame *embeddedFrame = cObj->_get_myFrame(ev);
  2717.                ODFacet *embeddedFacet =  FirstFacet(ev, embeddedFrame);
  2718.                TempODTransform tform = kODNULL;
  2719.                if (embeddedFacet)
  2720.                   tform = embeddedFacet->AcquireExternalTransform(ev, kODNULL);
  2721.                else {
  2722.                   tform = cObj->_get_extTransform(ev);
  2723.                   tform->Acquire(ev); // we have defined tform as Temp
  2724.                   ODPoint offset;
  2725.                   tform->GetOffset(ev, &offset);
  2726.                   PRINT("printing offset %d %d \n", offset.x >> 16, offset.y >> 16);
  2727.                }
  2728.  
  2729.                ODTransform *xform = tform->Copy (ev);
  2730.                TempODShape shape = embeddedFrame->AcquireFrameShape (ev, kODNULL);
  2731.                ODShape *clip = shape->Copy(ev);
  2732.                facet->CreateEmbeddedFacet (ev, embeddedFrame, clip, xform,
  2733.                                      kODNULL, kODNULL, kODNULL, kODFrameInFront);
  2734.  
  2735.             } // if frame object
  2736.  
  2737.         } // end for
  2738.  
  2739.      } // end if
  2740. #ifdef _PLATFORM_UNIX_
  2741. // This is called on AIX only, because AIX is the only platform that will
  2742. // use the default background color (from the desktop) to draw it's background
  2743. // if we don't specify a color
  2744.  
  2745.     // If the facet has a widget, set the widget's background color
  2746.     Widget widget = facet->GetFacetWidget(ev);
  2747.     if (widget)
  2748.     {
  2749.         XtVaSetValues(widget,
  2750.                       XmNbackground, _fBackgroundColor,
  2751.                       NULL);
  2752.     }
  2753. #endif
  2754.     } // end try block
  2755.  
  2756.     catch (...) {}
  2757. }
  2758.  
  2759.  
  2760.  
  2761. //--------------------------------------------------------------------------
  2762. // ODPart --> FacetRemoved
  2763. //
  2764. //      Should notify this part that a facet has been removed from one
  2765. //      of its display frames.
  2766. //
  2767. //      ->
  2768. //--------------------------------------------------------------------------
  2769.  
  2770. SOM_Scope       void
  2771. SOMLINK         BaseContainerFacetRemoved
  2772.                 (
  2773.                 BaseContainer   *somSelf,       // in
  2774.                 Environment     *ev,            // in
  2775.                 ODFacet         *facet          // in
  2776.                 )
  2777. {
  2778.    BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2779.    BaseContainerMethodDebug("BaseContainer","BaseContainerFacetRemoved");
  2780.  
  2781.     try {
  2782.  
  2783. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  2784.     ODCanvas *canvas = facet->GetCanvas(ev);
  2785.     if (canvas && canvas->IsDynamic(ev)) { /* don't do when printing */
  2786.        if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  2787.           _fScrollExt->FacetRemoved(ev, facet);
  2788.        } /* endif */
  2789.     } /* endif */
  2790. #endif //defined OS2 || WIN32
  2791.  
  2792.     ODFrame              *frame = facet->GetFrame(ev);
  2793.     ODFacet              *tempFacet;
  2794.     ODFrameFacetIterator *efitr = frame->CreateFacetIterator(ev);
  2795.     ALinkedList *children = new ALinkedList;
  2796.  
  2797.     ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
  2798.     for (ODFacet* childFacet = facets->First(ev);
  2799.          facets->IsNotComplete(ev);
  2800.          childFacet = facets->Next(ev))
  2801.     {
  2802.       children->AddLast(ev, childFacet);
  2803.     }
  2804.     delete facets;
  2805.  
  2806.     for (ALink *link = children->First(ev);
  2807.          link->Content(ev);
  2808.          link = link->Next(ev))
  2809.     {
  2810.       childFacet = (ODFacet *) link->Content(ev);
  2811.       facet->RemoveFacet(ev, childFacet);
  2812.       delete childFacet;
  2813.     }
  2814.  
  2815.    ODDeleteObject(efitr);
  2816.    delete children;
  2817.  
  2818.  
  2819.     }  // end of try block
  2820.     catch (...) {}
  2821.  
  2822.  
  2823. }
  2824.  
  2825.  
  2826. //--------------------------------------------------------------------------
  2827. // ODPart --> DisplayFrameAdded
  2828. //
  2829. //      Should add the specified frame to this part's internal list of
  2830. //      display frames.
  2831. //
  2832. //      ->
  2833. //--------------------------------------------------------------------------
  2834.  
  2835. SOM_Scope       void
  2836. SOMLINK         BaseContainerDisplayFrameAdded
  2837.                 (
  2838.                 BaseContainer   *somSelf,       // in
  2839.                 Environment     *ev,            // in
  2840.                 ODFrame         *frame          // in
  2841.                 )
  2842. {
  2843.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2844.     BaseContainerMethodDebug("BaseContainer","BaseContainerDisplayFrameAdded");
  2845.  
  2846.     try {
  2847.  
  2848.         ContentObject *contentObject;
  2849.         ALink *itr = kODNULL;
  2850.  
  2851.         // Add this frame to our list if it is not added
  2852.  
  2853.         if (!_fDisplayFrames->Contains(ev, frame)) {
  2854.              _fDisplayFrames->AddLast(ev, frame);    // add to list of frames
  2855.              frame->Acquire(ev);             // pin frame in memory
  2856.         }
  2857. #ifdef ODDebug
  2858.         else
  2859.               PRINT ("Frame already exists \n");
  2860. #endif
  2861.  
  2862.         // Determine the view type
  2863.         _fPrevViewType = frame->GetViewType(ev);
  2864.  
  2865.  
  2866.         if(_fPrevViewType == _fFrameView) {
  2867.            // Store the frame's bounding box for viewtype support
  2868.            TempODShape currShape = frame->AcquireFrameShape(ev, kODNULL);
  2869.            currShape->GetBoundingBox(ev, &_lastFrameRect);
  2870.         }
  2871.  
  2872.         // Allow the paste action
  2873.         frame->SetDroppable(ev,kODTrue);
  2874.  
  2875.         // If we are being embedded into another part, the presentation field
  2876.         // will be NULL, so we need to set it something meaningful.
  2877.         // The view field may also be null. If so, we prefer to be displayed
  2878.         // in a frame view.
  2879.  
  2880.         if ( frame->GetPresentation(ev) == kODNullTypeToken )
  2881.                 frame->SetPresentation(ev, _fMainPresentation);
  2882.  
  2883.         if ( frame->GetViewType(ev) == kODNullTypeToken )
  2884.                 frame->SetViewType(ev, _fFrameView);
  2885.  
  2886.         // Allocate the frame's part info.  new throws an exception if
  2887.         // unable to allocate
  2888.  
  2889.         FramePartInfo *pInfo = new FramePartInfo;
  2890.         pInfo->NeedsActivating = (frame->IsRoot(ev)) ? kODTrue : kODFalse;
  2891.         pInfo->BgndColor = _fBackgroundColor;
  2892.  
  2893. #if defined (_PLATFORM_OS2_)
  2894.         memset (&(pInfo->frameRect), 0, sizeof(ODRect));
  2895.         TempODShape fShape = frame->AcquireFrameShape(ev, kODNULL);
  2896.         if (fShape)
  2897.            fShape->GetBoundingBox (ev, &(pInfo->frameRect));
  2898. #endif
  2899.         frame->SetPartInfo(ev, (ODInfoType) pInfo);
  2900.  
  2901.         // Go through my list of embedded frames and set containing frame
  2902.  
  2903.         for (itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2904.         {
  2905.             contentObject = (ContentObject*) itr->Content(ev);
  2906.             if(!contentObject->_get_containingFrame(ev))
  2907.                contentObject->_set_containingFrame (ev, frame);
  2908.         }
  2909.  
  2910.     } // end try block
  2911.     catch (...) {}
  2912.  
  2913.  
  2914. }
  2915.  
  2916.  
  2917.  
  2918. //--------------------------------------------------------------------------
  2919. // ODPart --> DisplayFrameConnected
  2920. //
  2921. //      Should add the specified frame to this part's internal list of
  2922. //      display frames.
  2923. //
  2924. //      ->
  2925. //--------------------------------------------------------------------------
  2926.  
  2927. SOM_Scope       void
  2928. SOMLINK         BaseContainerDisplayFrameConnected
  2929.                 (
  2930.                 BaseContainer   *somSelf,       // in
  2931.                 Environment     *ev,            // in
  2932.                 ODFrame         *frame          // in
  2933.                 )
  2934. {
  2935.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2936.     BaseContainerMethodDebug("BaseContainer", "BaseContainerDisplayFrameConnected");
  2937.  
  2938.     somSelf->DisplayFrameAdded (ev, frame);
  2939.  
  2940. }
  2941.  
  2942.  
  2943.  
  2944. //--------------------------------------------------------------------------
  2945. // ODPart --> DisplayFrameClosed
  2946. //
  2947. //      Should notify this part that one of its display frames has been
  2948. //      closed.
  2949. //
  2950. //      ->
  2951. //--------------------------------------------------------------------------
  2952.  
  2953. SOM_Scope       void
  2954. SOMLINK         BaseContainerDisplayFrameClosed
  2955.                 (
  2956.                 BaseContainer   *somSelf,       // in
  2957.                 Environment     *ev,            // in
  2958.                 ODFrame         *frame          // in
  2959.                 )
  2960. {
  2961.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2962.     BaseContainerMethodDebug("BaseContainer","BaseContainerDisplayFrameClosed");
  2963.  
  2964.  
  2965.     try {
  2966.  
  2967.         // Relinquish the entire focus set
  2968.  
  2969.         _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
  2970.  
  2971.         // Close all embedded frames
  2972.         ALink *itr;
  2973.         ALinkedList *tempList = new ALinkedList;
  2974.         for(itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  2975.             ContentObject *cobj = (ContentObject *) itr->Content(ev);
  2976.             if (cobj->_get_containingFrame(ev) == frame) {
  2977.                  cobj->DeleteContents(ev, FRAME_CLOSED);
  2978.                  tempList->AddLast(ev, cobj);
  2979.             }
  2980.         }
  2981.  
  2982.         for(itr = tempList->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  2983.             _fEmbeddedObjects->Remove(ev, (ContentObject *) itr->Content(ev));
  2984.            delete (ContentObject *) itr->Content(ev);
  2985.         }
  2986.  
  2987.         //  Remove frame from frame lists and free it
  2988.  
  2989.         _fDisplayFrames->Remove(ev, frame);
  2990.         frame->Release(ev);         // unpin from memory
  2991.         delete tempList;
  2992.  
  2993.     } // end try block
  2994.     catch (...) {}
  2995.  
  2996.  
  2997. }
  2998.  
  2999.  
  3000.  
  3001. //--------------------------------------------------------------------------
  3002. // ODPart --> DisplayFrameRemoved
  3003. //
  3004. //      Should remove the specified frame from this part's internal
  3005. //      list of display frames.
  3006. //
  3007. //      ->
  3008. //--------------------------------------------------------------------------
  3009.  
  3010. SOM_Scope       void
  3011. SOMLINK         BaseContainerDisplayFrameRemoved
  3012.                 (
  3013.                 BaseContainer   *somSelf,       // in
  3014.                 Environment     *ev,            // in
  3015.                 ODFrame         *frame          // in
  3016.                 )
  3017. {
  3018.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3019.     BaseContainerMethodDebug("BaseContainer", "BaseContainerDisplayFrameRemoved");
  3020.  
  3021.  
  3022.     try {
  3023.  
  3024.         // Relinquish the entire focus set
  3025.  
  3026.         _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
  3027.  
  3028.         // Remove/Release embedded frames
  3029.         ALink *itr;
  3030.         ALinkedList *tempList = new ALinkedList;
  3031.         for(itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  3032.             ContentObject *cobj = (ContentObject *) itr->Content(ev);
  3033.             if (cobj->_get_containingFrame(ev) == frame) {
  3034.                  cobj->DeleteContents(ev, FRAME_REMOVED);
  3035.                  tempList->AddLast(ev, cobj);
  3036.             }
  3037.         }
  3038.  
  3039.         for(itr = tempList->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  3040.             _fEmbeddedObjects->Remove(ev, (ContentObject *) itr->Content(ev));
  3041.            delete (ContentObject *) itr->Content(ev);
  3042.         }
  3043.  
  3044.         //  Remove frame from frame lists and free it
  3045.  
  3046.         _fDisplayFrames->Remove(ev, frame);
  3047.         frame->Release(ev);         // unpin from memory
  3048.         delete tempList;
  3049.  
  3050.     } // end try block
  3051.     catch (...) {}
  3052.  
  3053.  
  3054. }
  3055.  
  3056.  
  3057.  
  3058. // ** Group 5
  3059. //--------------------------------------------------------------------------
  3060. // ODPart --> AbortRelinquishFocus
  3061. //
  3062. //      Should reestablish this part's ownership of the focus specified
  3063. //      in a previous call to this part's ODPart->BeginRelinquishFocus
  3064. //      method.
  3065. //
  3066. //      -> must override ODPart, must not call ODPart method
  3067. //      -> focus parameter is a string token == 32 bit kOD*Focus constant
  3068. //--------------------------------------------------------------------------
  3069.  
  3070. SOM_Scope       void
  3071. SOMLINK         BaseContainerAbortRelinquishFocus
  3072.                 (
  3073.                 BaseContainer   *somSelf,       // in
  3074.                 Environment     *ev,            // in
  3075.                 ODTypeToken      focus,         // in string token of kOD*Focus
  3076.                 ODFrame         *ownerFrame,    // in current focus owner
  3077.                 ODFrame         *proposedFrame  // in proposed owner of focus
  3078.                 )
  3079. {
  3080.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3081.     BaseContainerMethodDebug("BaseContainer", "BaseContainerAbortRelinquishFocus");
  3082.  
  3083.     // Another part requested one of the foci we had, but was unable
  3084.     // to acquire all the foci it needed. So, we are being given our
  3085.     // complete set of foci back.
  3086.  
  3087.     somSelf->FocusAcquired(ev, focus, ownerFrame);
  3088.  
  3089. }
  3090.  
  3091.  
  3092.  
  3093. //--------------------------------------------------------------------------
  3094. // ODPart --> BeginRelinquishFocus
  3095. //
  3096. //      Should return a Boolean value that indicates whether this
  3097. //      part is willing to relinquish the requested focus and should
  3098. //      prepare to do so.
  3099. //
  3100. //      -> must override ODPart, must not call ODPart method
  3101. //      -> focus parameter is a string token == 32 bit kOD*Focus constant
  3102. //--------------------------------------------------------------------------
  3103.  
  3104. SOM_Scope       ODBoolean
  3105. SOMLINK         BaseContainerBeginRelinquishFocus
  3106.                 (
  3107.                 BaseContainer   *somSelf,       // in
  3108.                 Environment     *ev,            // in
  3109.                 ODTypeToken      focus,         // in string token of kOD*Focus
  3110.                 ODFrame         *ownerFrame,    // in current focus owner
  3111.                 ODFrame         *proposedFrame  // in requesting frame
  3112.                 )
  3113. {
  3114.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3115.     BaseContainerMethodDebug("BaseContainer", "BaseContainerBeginRelinquishFocus");
  3116.  
  3117.  
  3118.     ODBoolean rc=kODTrue;
  3119.  
  3120.     try {
  3121.  
  3122.         if ( focus == _fModalFocus ) {
  3123.             ODPart *proposedFramePart = proposedFrame->AcquirePart(ev);
  3124.  
  3125.             // if proposedFramePart is not this part then
  3126.             //   Another part is trying to put up a Modal dialog
  3127.             //   while we are currently displaying ours.
  3128.             //
  3129.             //   Deny the request.
  3130.  
  3131.             rc= (proposedFramePart==somSelf) ? kODTrue : kODFalse;
  3132.  
  3133.             proposedFramePart->Release(ev);
  3134.         }
  3135.  
  3136.     }  // end try block
  3137.     catch (...) {}
  3138.  
  3139.     return rc;
  3140. }
  3141.  
  3142.  
  3143.  
  3144. //--------------------------------------------------------------------------
  3145. // ODPart --> CommitRelinquishFocus
  3146. //
  3147. //      Should complete this part's relinquishing of the ownership
  3148. //      of the specified focus.
  3149. //
  3150. //      -> must override ODPart, must not call ODPart method
  3151. //      -> focus parameter is a string token == 32 bit kOD*Focus constant
  3152. //--------------------------------------------------------------------------
  3153.  
  3154. SOM_Scope       void
  3155. SOMLINK         BaseContainerCommitRelinquishFocus
  3156.                 (
  3157.                 BaseContainer   *somSelf,       // in
  3158.                 Environment     *ev,            // in
  3159.                 ODTypeToken      focus,         // in string token of kOD*Focus
  3160.                 ODFrame         *ownerFrame,    // in current focus owner
  3161.                 ODFrame         *proposedFrame  // in requesting frame
  3162.                 )
  3163. {
  3164.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3165.     BaseContainerMethodDebug("BaseContainer", "BaseContainerCommitRelinquishFocus");
  3166.  
  3167.  
  3168.     // We previously agreed to give up our FocusSet and
  3169.     // now we are being asked to really do so.
  3170.  
  3171.  
  3172.  
  3173.     try {
  3174.  
  3175.         somSelf->FocusLost(ev, focus, ownerFrame);
  3176.  
  3177.     }  // end of try block
  3178.     catch (...) {}
  3179.  
  3180. }
  3181.  
  3182.  
  3183.  
  3184. //--------------------------------------------------------------------------
  3185. // ODPart --> FocusAcquired
  3186. //
  3187. //      Should notify this part that one of its display frames has
  3188. //      acquired the specified focus.
  3189. //
  3190. //      Called by OpenDoc when containing part transfers focus to this part.
  3191. //      BaseContainer->ActivateFrame will also call this method.
  3192. //
  3193. //      Not called when this part used RequestFocus* methods to get focus.
  3194. //
  3195. //      -> must override ODPart, must not call ODPart method
  3196. //      -> focus parameter is a string token == 32 bit kOD*Focus constant
  3197. //--------------------------------------------------------------------------
  3198.  
  3199. SOM_Scope       void
  3200. SOMLINK         BaseContainerFocusAcquired
  3201.                 (
  3202.                 BaseContainer   *somSelf,       // in
  3203.                 Environment     *ev,            // in
  3204.                 ODTypeToken      focus,         // in string token of kOD*Focus
  3205.                 ODFrame         *ownerFrame     // in display frame that owns focus
  3206.                 )
  3207. {
  3208.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3209.     BaseContainerMethodDebug("BaseContainer","BaseContainerFocusAcquired");
  3210.  
  3211.  
  3212.     try {
  3213.  
  3214.  
  3215.     if ( focus == _fMenuFocus ) _fMenuBar->Display(ev);
  3216.  
  3217.     else if ( focus == _fSelectionFocus )
  3218.     {
  3219.         ALink* itr = kODNULL;
  3220.         // Iterate over SelectedFrames and turn on selection highlight
  3221.         //for(itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  3222.         //  ((ContentObject *) itr->Content(ev))->SetSelectionState(kODTrue);
  3223.  
  3224.     } //end if
  3225.  
  3226.     } // end try block
  3227.     catch (...) {}
  3228.  
  3229.  
  3230.  
  3231. }
  3232.  
  3233.  
  3234.  
  3235. //--------------------------------------------------------------------------
  3236. // ODPart --> FocusLost
  3237. //
  3238. //      Should notify this part that one of its display frames has
  3239. //      lost the specified focus.
  3240. //
  3241. //      Called by OpenDoc when focus is lost to a containing part request
  3242. //      (TransferFocus) or because of some user/system event.
  3243. //
  3244. //      Not called when another part has requested focus (ie called this
  3245. //      part's BeginRelinquishFocus method (since you already know).
  3246. //
  3247. //      -> must override ODPart, must not call ODPart method
  3248. //      -> focus parameter is a string token == 32 bit kOD*Focus constant
  3249. //--------------------------------------------------------------------------
  3250.  
  3251. SOM_Scope       void
  3252. SOMLINK         BaseContainerFocusLost
  3253.                 (
  3254.                 BaseContainer   *somSelf,       // in
  3255.                 Environment     *ev,            // in
  3256.                 ODTypeToken      focus,         // in string token of kOD*Focus
  3257.                 ODFrame         *ownerFrame     // in frame which lost focus
  3258.                 )
  3259. {
  3260.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3261.     BaseContainerMethodDebug("BaseContainer","BaseContainerFocusLost");
  3262.  
  3263.  
  3264.  
  3265.     try {
  3266.  
  3267.     if ( focus == _fSelectionFocus )
  3268.     {
  3269.         // Iterate over SelectedFrames and turn on selection highlight
  3270.         if (_fSelectedObjects->Count(ev) != 0)
  3271.            somSelf->DeselectAll(ev);
  3272.  
  3273.         // Reset the Mouse Mode if it is set. This way mouse tracking is lost once the part is deactivated.
  3274.         _usMouseMode = kMouseModeNull;
  3275.     }
  3276.  
  3277.     // who owns the clipboard focus
  3278.     TempODFrame clipboardOwner = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
  3279.  
  3280.     // we no longer need the clipboard focus
  3281.     if(ownerFrame == clipboardOwner) {
  3282.         _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, ownerFrame);
  3283.     }
  3284.  
  3285.     } // end try block
  3286.     catch (...) {}
  3287.  
  3288. }
  3289.  
  3290.  
  3291.  
  3292. //--------------------------------------------------------------------------
  3293. // BaseContainer --> ActivateFrame
  3294. //
  3295. //      Should request the focus set, and notify ourselves that we
  3296. //      got it.
  3297. //
  3298. //      Called when the enduser clicks within the content area of a part
  3299. //      which causes an event to be sent to the HandleEvent method.
  3300. //
  3301. //      -> private method of BaseContainer
  3302. //--------------------------------------------------------------------------
  3303.  
  3304. SOM_Scope       ODBoolean
  3305. SOMLINK         BaseContainerActivateFrame
  3306.                 (
  3307.                 BaseContainer   *somSelf,       // in
  3308.                 Environment     *ev,            // in
  3309.                 ODFrame         *frame          // in frame to activate
  3310.                 )
  3311. {
  3312.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3313.     BaseContainerMethodDebug("BaseContainer","BaseContainerActivateFrame");
  3314.  
  3315.  
  3316.     ODBoolean rc = kODFalse;
  3317.  
  3318.  
  3319.     try {
  3320.  
  3321.     // Do not activate if we already are active
  3322.     TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  3323.     if (frame == activeFrame)
  3324.     {
  3325.         // Get the frame's partinfo
  3326.         FramePartInfo *pInfo = (FramePartInfo *) frame->GetPartInfo(ev);
  3327.  
  3328.         // If the frame doesn't need activating due to window deactivation/reactivation
  3329.         if (!pInfo->NeedsActivating)
  3330.         {
  3331.             rc = kODTrue;
  3332.         }
  3333.     }
  3334.  
  3335.     // If all necessary activation is complete
  3336.     if (rc == kODTrue)
  3337.     {
  3338.         // The frame is already active and doesn't need activation because of window
  3339.         // deactivation/reactivation
  3340.     }
  3341.     // Request the set of foci necessary to become active.
  3342.     else if ( somSelf->GetStorageUnit(ev)
  3343.                 ->GetSession(ev)
  3344.                 ->GetArbitrator(ev)
  3345.                 ->RequestFocusSet(ev, _fFocusSet, frame) )
  3346.     {
  3347.         // Notify ourself that we acquired the selection, menu,
  3348.         // and keyboard foci.
  3349.         somSelf->FocusAcquired(ev, _fSelectionFocus, frame);
  3350.         somSelf->FocusAcquired(ev, _fMenuFocus, frame);
  3351.         somSelf->FocusAcquired(ev, _fKeyFocus, frame);
  3352.  
  3353.         // We sucessfully acquired the foci we need to be active.
  3354.         rc=kODTrue;
  3355.     }
  3356.     else
  3357.         // We were unable to acquire the foci we need to be active.
  3358.         rc=kODFalse;
  3359.  
  3360.     } // end try block
  3361.     catch (...) {}
  3362.  
  3363.     return rc;
  3364. }
  3365.  
  3366.  
  3367.  
  3368. //--------------------------------------------------------------------------
  3369. // BaseContainer --> ActivatingWindow
  3370. //
  3371. //      Delayed activation of frame until WM_ACTIVATE is passed to
  3372. //      ODPart->HandleEvent method.
  3373. //
  3374. //      ->
  3375. //--------------------------------------------------------------------------
  3376.  
  3377. SOM_Scope       void
  3378. SOMLINK         BaseContainerActivatingWindow
  3379.                 (
  3380.                 BaseContainer *somSelf,
  3381.                 Environment *ev,
  3382.                 ODFrame* frame
  3383.                 )
  3384. {
  3385.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3386.     BaseContainerMethodDebug("BaseContainer","BaseContainerActivatingWindow");
  3387.  
  3388.  
  3389.     try {
  3390.  
  3391.     // Get the frame's partinfo
  3392.     FramePartInfo *pInfo = (FramePartInfo *) frame->GetPartInfo(ev);
  3393.  
  3394.  
  3395.  
  3396.     // If the frame needs activating
  3397.     if (pInfo->NeedsActivating)
  3398.     {
  3399.         // Activate the frame
  3400.         somSelf->ActivateFrame(ev, frame);
  3401.  
  3402.         // Signify the frame no longer needs activating
  3403.         pInfo->NeedsActivating = kODFalse;
  3404.     }
  3405.  
  3406.  
  3407.     } // end try block
  3408.     catch (...) {}
  3409.  
  3410.  
  3411. }
  3412.  
  3413.  
  3414. //--------------------------------------------------------------------------
  3415. // BaseContainer --> DeactivatingWindow
  3416. //
  3417. //      Delayed activation of frame until WM_ACTIVATE is passed to
  3418. //      ODPart->HandleEvent method.
  3419. //
  3420. //      ->
  3421. //--------------------------------------------------------------------------
  3422.  
  3423. SOM_Scope       void
  3424. SOMLINK         BaseContainerDeactivatingWindow
  3425.                 (
  3426.                 BaseContainer *somSelf,
  3427.                 Environment *ev,
  3428.                 ODFrame* frame
  3429.                 )
  3430. {
  3431.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3432.     BaseContainerMethodDebug("BaseContainer","BaseContainerDeactivatingWindow");
  3433.  
  3434.  
  3435.  
  3436.     try {
  3437.  
  3438.     // Get the frame's partinfo
  3439.     FramePartInfo *pInfo = (FramePartInfo *) frame->GetPartInfo(ev);
  3440.  
  3441.     // Get the frame which has the selection focus
  3442.     TempODFrame tempFrame = _fSession->GetArbitrator(ev)->
  3443.                             AcquireFocusOwner(ev, _fSelectionFocus);
  3444.  
  3445.  
  3446.  
  3447.     // If the frame with the selection focus is this frame
  3448.     if (frame == tempFrame)
  3449.     {
  3450.         // We will need to be activated when the window gets
  3451.         // activated again
  3452.         pInfo->NeedsActivating = kODTrue;
  3453.     }
  3454.     else
  3455.     {
  3456.         // We won't need to be activated when the window gets
  3457.         // activated again
  3458.         if(pInfo!=kODNULL) pInfo->NeedsActivating = kODFalse;
  3459.     }
  3460.  
  3461.  
  3462.     } // end try block
  3463.     catch (...) {}
  3464.  
  3465. }
  3466.  
  3467.  
  3468. // ** Group 6
  3469. //--------------------------------------------------------------------------
  3470. // ODPart --> CreateLink
  3471. //
  3472. //      Should create a link-source object for this part.
  3473. //
  3474. //      ->
  3475. //--------------------------------------------------------------------------
  3476.  
  3477. SOM_Scope       ODLinkSource*
  3478. SOMLINK         BaseContainerCreateLink
  3479.                 (
  3480.                 BaseContainer   *somSelf,       // in
  3481.                 Environment     *ev,            // in
  3482.                 ODByteArray     *data           // in
  3483.                 )
  3484. {
  3485.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3486.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateLink");
  3487.  
  3488.    return (ODLinkSource *)kODNULL;
  3489. }
  3490.  
  3491.  
  3492.  
  3493. //--------------------------------------------------------------------------
  3494. // ODPart --> EmbeddedFrameUpdated
  3495. //
  3496. //      Should update any of the part's link-source objects affected
  3497. //      by a change to the specified embedded frame.
  3498. //
  3499. //      ->
  3500. //--------------------------------------------------------------------------
  3501.  
  3502. SOM_Scope       void
  3503. SOMLINK         BaseContainerEmbeddedFrameUpdated
  3504.                 (
  3505.                 BaseContainer   *somSelf,       // in
  3506.                 Environment     *ev,            // in
  3507.                 ODFrame         *frame,         // in
  3508.                 ODUpdateID       change         // in
  3509.                 )
  3510. {
  3511.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3512.     BaseContainerMethodDebug("BaseContainer", "BaseContainerEmbeddedFrameChanged");
  3513.  
  3514.  
  3515.     try {
  3516.  
  3517.         BaseContainer_parent_ODPart_EmbeddedFrameUpdated(somSelf,ev,frame,change);
  3518.  
  3519.         ContentObject *cObj = (ContentObject *) GetContentObjectForFrame (frame, _fEmbeddedObjects);
  3520.         somSelf->ChangeNotification (ev, BCC_EMBEDUPDATED, kODNULL, cObj, kODFalse, change);
  3521.  
  3522.     }  // end of try block
  3523.     catch (...) {}
  3524. }
  3525.  
  3526.  
  3527. //--------------------------------------------------------------------------
  3528. // ODPart --> LinkStatusChanged
  3529. //
  3530. //      Should notify this part that the link status of one of its display
  3531. //      frames has changed.
  3532. //
  3533. //      ->
  3534. //--------------------------------------------------------------------------
  3535.  
  3536. SOM_Scope       void
  3537. SOMLINK         BaseContainerLinkStatusChanged
  3538.                 (
  3539.                 BaseContainer   *somSelf,       // in
  3540.                 Environment     *ev,            // in
  3541.                 ODFrame         *frame          // in
  3542.                 )
  3543. {
  3544.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3545.     BaseContainerMethodDebug("BaseContainer","BaseContainerLinkStatusChanged");
  3546.  
  3547.  
  3548. }
  3549.  
  3550.  
  3551.  
  3552. //--------------------------------------------------------------------------
  3553. // ODPart --> LinkUpdated
  3554. //
  3555. //      Should replace the content at each destination of a link
  3556. //      with new content from the updated link object.
  3557. //
  3558. //      ->
  3559. //--------------------------------------------------------------------------
  3560.  
  3561. SOM_Scope       void
  3562. SOMLINK         BaseContainerLinkUpdated
  3563.                 (
  3564.                 BaseContainer   *somSelf,       // in
  3565.                 Environment     *ev,            // in
  3566.                 ODLink          *updatedLink,   // in
  3567.                 ODUpdateID       id             // in
  3568.                 )
  3569. {
  3570.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3571.     BaseContainerMethodDebug("BaseContainer","BaseContainerLinkUpdated");
  3572.  
  3573.  
  3574. }
  3575.  
  3576.  
  3577.  
  3578. //--------------------------------------------------------------------------
  3579. // ODPart --> RevealLink
  3580. //
  3581. //      Should show the content at the source of a link.
  3582. //
  3583. //      ->
  3584. //--------------------------------------------------------------------------
  3585.  
  3586. SOM_Scope       void
  3587. SOMLINK         BaseContainerRevealLink
  3588.                 (
  3589.                 BaseContainer   *somSelf,       // in
  3590.                 Environment     *ev,            // in
  3591.                 ODLinkSource    *linkSource     // in
  3592.                 )
  3593. {
  3594.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3595.     BaseContainerMethodDebug("BaseContainer","BaseContainerRevealLink");
  3596.  
  3597.  
  3598. }
  3599.  
  3600.  
  3601. // ** Group 7
  3602. // -------------------------------------------------------------------------
  3603. // ODObject --> HasExtension
  3604. //
  3605. //      Queries whether this part supports the specified extension.
  3606. //
  3607. //      -> if overridden it must call the parent method for unsupported
  3608. //         extensions.
  3609. //      -> it must return kODTrue if extension is supported else kODFalse
  3610. //         note query answers 'is it supported?' not 'is there one attached?'
  3611. // -------------------------------------------------------------------------
  3612.  
  3613. SOM_Scope       ODBoolean
  3614. SOMLINK         BaseContainerHasExtension
  3615.                 (
  3616.                 BaseContainer   *somSelf,       // in
  3617.                 Environment     *ev,            // in
  3618.                 ODType          extensionName   // in
  3619.                 )
  3620. {
  3621.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3622.     BaseContainerMethodDebug("BaseContainer","BaseContainerHasExtension");
  3623.  
  3624.     ODBoolean ReturnValue = kODFalse;
  3625.  
  3626.     if (strcmp(extensionName, kODSettingsExtension)==0) {
  3627.        ReturnValue = kODTrue;
  3628.     } /* endif */
  3629.  
  3630. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  3631.     else if (strcmp(extensionName, kODPrintExtension)==0) {
  3632.        ReturnValue = kODTrue;
  3633.     }
  3634.  
  3635.     else if (strcmp(extensionName, kODScrollExtension)==0) {
  3636.        ReturnValue = kODTrue;
  3637.     }
  3638. #endif //defined OS2 || WIN32
  3639.  
  3640.     else {
  3641.        try {                 // if needed invoke parent if we don't have answer
  3642.           ReturnValue = BaseContainer_parent_ODPart_HasExtension(
  3643.                               somSelf, ev, extensionName);
  3644.        }
  3645.        catch(ODException _exception) {
  3646.           SetErrorCodeEv (ev, kODNoError);
  3647.        }
  3648.     }
  3649.     return ReturnValue;
  3650. }
  3651.  
  3652.  
  3653.  
  3654. // -------------------------------------------------------------------------
  3655. // ODObject --> AcquireExtension
  3656. //
  3657. //      Returns a reference to the specified extension object.
  3658. //
  3659. //      -> if overridden it must call the parent method for unsupported
  3660. //         extensions.
  3661. //      -> it must return a reference if extension is supported else ???
  3662. // -------------------------------------------------------------------------
  3663.  
  3664. SOM_Scope       ODExtension*
  3665. SOMLINK         BaseContainerAcquireExtension
  3666.                 (
  3667.                 BaseContainer   *somSelf,       // in
  3668.                 Environment     *ev,            // in
  3669.                 ODType           extensionName  // in
  3670.                 )
  3671. {
  3672.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3673.     BaseContainerMethodDebug("BaseContainer","BaseContainerAcquireExtension");
  3674.  
  3675.     ODExtension* ReturnValue = kODNULL;
  3676.  
  3677.     //-----------------------------------------------------------
  3678.     // For each extension we support we maintain a pointer to the extension
  3679.     // object if one has been created.  If the object exists, we will simply
  3680.     // increment its reference count and return the existing object.  If no
  3681.     // existing extension object is available, we will attempt to create and
  3682.     // initialize the requested extension, save a copy of the object reference,
  3683.     // and return that reference to the caller.
  3684.     //
  3685.     // Note that the reference we retain is NOT reflected in the reference count
  3686.     // of the extension.  Initialization provides a pointer to this object
  3687.     // to the Extension object, the BaseObject.  When the reference count of
  3688.     // the extension becomes zero, the extension will call the ReleaseExtension
  3689.     // method of the BaseObject (us).  That routine will clear the local reference
  3690.     // to the extension and delete the extension object.
  3691.     //-----------------------------------------------------------
  3692.  
  3693.     //-----------------------------------------------------------
  3694.     // Settings Extension
  3695.     //-----------------------------------------------------------
  3696.     if (strcmp(extensionName, kODSettingsExtension)==0) {
  3697.        if (_fSettingsExt!=kODNULL) {    // for existing extension, step ref count
  3698.           _fSettingsExt->Acquire(ev);
  3699.        }
  3700.        else {
  3701.           _fSettingsExt = (BCPartSettingsExt *)somSelf->CreateSettingsExtension(ev) ; //create new if needed
  3702.        }
  3703.        ReturnValue = _fSettingsExt ;
  3704.     } /* end if settings extension */
  3705.  
  3706. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  3707.     //-----------------------------------------------------------
  3708.     // print extension
  3709.     //-----------------------------------------------------------
  3710.     else if (strcmp(extensionName, kODPrintExtension)==0) {
  3711.  
  3712.        if (_fPrintExt != kODNULL) {         // have existing extension
  3713.               _fPrintExt->Acquire(ev);      // step ref count and return reference
  3714.               ReturnValue = _fPrintExt;
  3715.        }
  3716.        else {
  3717.           _fPrintExt = (ODPrintExtension *)somSelf->CreatePrintExtension(ev);  // create ext if needed
  3718.           if (_fPrintExt) {                   //  then initialize it.
  3719.              somSelf->EnablePrinting(ev, kODTrue, kODNULL) ;
  3720.              ReturnValue = _fPrintExt ;
  3721.           }
  3722.        }
  3723.     }
  3724.     //-----------------------------------------------------------
  3725.     // Scroll Extension
  3726.     //-----------------------------------------------------------
  3727.     else if (strcmp(extensionName, kODScrollExtension)==0) {
  3728.  
  3729.        if (_fScrollExt != kODNULL) {        // have existing exten.
  3730.           _fScrollExt->Acquire(ev);         // step ref count and return ref
  3731.           ReturnValue = _fScrollExt;
  3732.        }
  3733.  
  3734.        else {
  3735.           _fScrollExt = (ODScrollExtension *)somSelf->CreateScrollExtension(ev) ;  // create new ext
  3736.           if (_fScrollExt) {                    //  then intialize it.
  3737.              PRINT("BaseContainer::AcquireExtension somself=0x%x\n",somSelf);
  3738.              somSelf->EnableScrolling(ev, kODFalse, 0, 0);
  3739.              ReturnValue = _fScrollExt;
  3740.           }
  3741.        }
  3742.     }
  3743. #endif  //OS/2 or Win95/NT
  3744.  
  3745.     //-----------------------------------------------------------
  3746.     // AcquireExtension throws a kODErrUnsupportedExtension if the
  3747.     // specified extension is not supported by the parent object.
  3748.     // We catch the exception and just return a null pointer.
  3749.     //-----------------------------------------------------------
  3750.     else {
  3751.        try {
  3752.           ReturnValue=BaseContainer_parent_ODPart_AcquireExtension(
  3753.           somSelf, ev, extensionName);
  3754.        }
  3755.        catch(ODException _exception) {
  3756.        }
  3757.     }
  3758.  
  3759.     return ReturnValue;
  3760. }
  3761.  
  3762.  
  3763.  
  3764. // -------------------------------------------------------------------------
  3765. // ODObject --> ReleaseExtension
  3766. //
  3767. //      -> if overridden it must call the parent method for unsupported
  3768. //         extensions.
  3769. // Note this routine is invoked from the extension class when the reference
  3770. // count of the extension object reaches zero (if the base object is not null).
  3771. // -------------------------------------------------------------------------
  3772.  
  3773. SOM_Scope       void
  3774. SOMLINK         BaseContainerReleaseExtension
  3775.                 (
  3776.                 BaseContainer   *somSelf,       // in
  3777.                 Environment     *ev,            // in
  3778.                 ODExtension     *extension      // in
  3779.                 )
  3780. {
  3781.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3782.     BaseContainerMethodDebug("BaseContainer","BaseContainerReleaseExtension");
  3783.  
  3784. //    PRINT("Entering BaseContainer::ReleaseExtension\n");
  3785.  
  3786.     if (extension != kODNULL) {
  3787.  
  3788.        if (extension == _fSettingsExt) {  // clear Settings Extension
  3789.           delete _fSettingsExt ;
  3790.           _fSettingsExt = kODNULL ;
  3791.        }
  3792.  
  3793. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  3794.        else if (extension == _fPrintExt) {    // clear Print Extension
  3795.           delete _fPrintExt;
  3796.           _fPrintExt = kODNULL;
  3797.        }  /* endif */
  3798.  
  3799.        else if (extension == _fScrollExt) {   // clear Scroll Extension
  3800.           delete _fScrollExt;
  3801.           _fScrollExt = kODNULL;
  3802.        }  /* endif */
  3803. #endif //  OS/2 or Win95/NT
  3804.  
  3805.        else {                            // let parent check
  3806.           // the following code is currently removed.  It should be correct
  3807.           // but the code in ODPart::ReleaseExtension which tries to raise an
  3808.           // exception for some reason does not succeed and the exception is not
  3809.           // raised/caught.  The code in the .xh file that normally detects the
  3810.           // exception is not even involved in the call, but the ev block gets
  3811.           // set to a non-zero value hence, on return from this call the exception
  3812.           // is caught! Wrong timing.
  3813.           //try {
  3814.           //   BaseContainer_parent_ODPart_ReleaseExtension(
  3815.           //           somSelf, ev, extension);
  3816.           //}
  3817.           //catch(ODException _exception) {
  3818.           //}
  3819.        }
  3820.  
  3821.     } /* endif  extension not null */
  3822. }
  3823.  
  3824.  
  3825. // ** Group 8
  3826. //--------------------------------------------------------------------------
  3827. // ODPart --> RedoAction
  3828. //
  3829. //      Should redo the specified action.
  3830. //
  3831. //      ->
  3832. //--------------------------------------------------------------------------
  3833.  
  3834. SOM_Scope       void
  3835. SOMLINK         BaseContainerRedoAction
  3836.                 (
  3837.                 BaseContainer   *somSelf,       // in
  3838.                 Environment     *ev,            // in
  3839.                 ODActionData    *actionState    // in
  3840.                 )
  3841. {
  3842.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3843.     BaseContainerMethodDebug("BaseContainer","BaseContainerRedoAction");
  3844.  
  3845.  
  3846.  
  3847. }
  3848.  
  3849.  
  3850. //--------------------------------------------------------------------------
  3851. // ODPart --> UndoAction
  3852. //
  3853. //      Should undo the specified action.
  3854. //
  3855. //      ->
  3856. //--------------------------------------------------------------------------
  3857.  
  3858. SOM_Scope       void
  3859. SOMLINK         BaseContainerUndoAction
  3860.                 (
  3861.                 BaseContainer   *somSelf,       // in
  3862.                 Environment     *ev,            // in
  3863.                 ODActionData    *actionState    // in
  3864.                 )
  3865. {
  3866.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3867.     BaseContainerMethodDebug("BaseContainer","BaseContainerUndoAction");
  3868.  
  3869.  
  3870.  
  3871. }
  3872.  
  3873.  
  3874.  
  3875. //--------------------------------------------------------------------------
  3876. // ODPart --> DisposeActionState
  3877. //
  3878. //      Should dispose of the undo action data.
  3879. //
  3880. //
  3881. //      ->
  3882. //--------------------------------------------------------------------------
  3883.  
  3884. SOM_Scope       void
  3885. SOMLINK         BaseContainerDisposeActionState
  3886.                 (
  3887.                 BaseContainer   *somSelf,       // in
  3888.                 Environment     *ev,            // in
  3889.                 ODActionData    *actionState,   // in
  3890.                 ODDoneState      doneState      // in
  3891.                 )
  3892. {
  3893.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3894.     BaseContainerMethodDebug("BaseContainer","BaseContainerDisposeActionState");
  3895.  
  3896. }
  3897.  
  3898.  
  3899.  
  3900. //--------------------------------------------------------------------------
  3901. // ODPart --> ReadActionState
  3902. //
  3903. //      Should read the undo action data from the specified storage-unit
  3904. //      view object.
  3905. //
  3906. //      ->
  3907. //--------------------------------------------------------------------------
  3908.  
  3909. SOM_Scope       ODActionData
  3910. SOMLINK         BaseContainerReadActionState
  3911.                 (
  3912.                 BaseContainer       *somSelf,       // in
  3913.                 Environment         *ev,            // in
  3914.                 ODStorageUnitView   *storUnitView   // in
  3915.                 )
  3916. {
  3917.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3918.     BaseContainerMethodDebug("BaseContainer","BaseContainerReadActionState");
  3919.  
  3920.     return CreateByteArrayStruct(kODNULL, sizeof(kODNULL));
  3921. }
  3922.  
  3923.  
  3924.  
  3925. //--------------------------------------------------------------------------
  3926. // ODPart --> WriteActionState
  3927. //
  3928. //      Should write the undo action data into the specified storage-unit
  3929. //      view object.
  3930. //
  3931. //
  3932. //      ->
  3933. //--------------------------------------------------------------------------
  3934.  
  3935. SOM_Scope       void
  3936. SOMLINK         BaseContainerWriteActionState
  3937.                 (
  3938.                 BaseContainer       *somSelf,       // in
  3939.                 Environment         *ev,            // in
  3940.                 ODActionData        *actionState,   // in
  3941.                 ODStorageUnitView   *storUnitView   // in
  3942.                 )
  3943. {
  3944.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3945.     BaseContainerMethodDebug("BaseContainer","BaseContainerWriteActionState");
  3946.  
  3947.  
  3948. }
  3949.  
  3950.  
  3951. // ** Group 9
  3952. //--------------------------------------------------------------------------
  3953. // ODPart --> EmbeddedFrameSpec
  3954. //
  3955. //      Should create an object specifier for the specified embedded frame
  3956. //      in this part.
  3957. //
  3958. //      ->
  3959. //--------------------------------------------------------------------------
  3960.  
  3961. SOM_Scope       void
  3962. SOMLINK         BaseContainerEmbeddedFrameSpec
  3963.                 (
  3964.                 BaseContainer   *somSelf,       // in
  3965.                 Environment     *ev,            // in
  3966.                 ODFrame         *embeddedFrame, // in
  3967.                 ODObjectSpec    *spec           // in
  3968.                 )
  3969. {
  3970.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3971.     BaseContainerMethodDebug("BaseContainer","BaseContainerEmbeddedFrameSpec");
  3972.  
  3973. }
  3974.  
  3975.  
  3976.  
  3977. //--------------------------------------------------------------------------
  3978. // ODPart --> RevealFrame
  3979. //
  3980. //      Should make the specified embedded frame visible by scrolling
  3981. //      it into view.
  3982. //
  3983. //      ->
  3984. //--------------------------------------------------------------------------
  3985.  
  3986. SOM_Scope       ODBoolean
  3987. SOMLINK         BaseContainerRevealFrame
  3988.                 (
  3989.                 BaseContainer   *somSelf,       // in
  3990.                 Environment     *ev,            // in
  3991.                 ODFrame         *embeddedFrame, // in
  3992.                 ODShape         *revealShape    // in
  3993.                 )
  3994. {
  3995.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  3996.     BaseContainerMethodDebug("BaseContainer","BaseContainerRevealFrame");
  3997.  
  3998.  
  3999.    return kODFalse;
  4000. }
  4001.  
  4002.  
  4003.  
  4004. //--------------------------------------------------------------------------
  4005. // ODPart --> UsedShapeChanged
  4006. //
  4007. //      Should notify this part that the used frame of one of its
  4008. //      embedded frames has changed.
  4009. //
  4010. //      ->
  4011. //--------------------------------------------------------------------------
  4012.  
  4013. SOM_Scope       void
  4014. SOMLINK         BaseContainerUsedShapeChanged
  4015.                 (
  4016.                 BaseContainer   *somSelf,       // in
  4017.                 Environment     *ev,            // in
  4018.                 ODFrame         *embeddedFrame  // in
  4019.                 )
  4020. {
  4021.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4022.     BaseContainerMethodDebug("BaseContainer","BaseContainerUsedShapeChanged");
  4023. /*
  4024.     TempODShape newFrameShape = embeddedFrame->AcquireUsedShape (ev, kODNULL);
  4025.  
  4026.     if(newFrameShape)
  4027.     {
  4028.       ODFrameFacetIterator* i = embeddedFrame->CreateFacetIterator(ev);
  4029.  
  4030.       ODFacet* facet = kODNULL;
  4031.       for (facet = i->First(ev); i->IsNotComplete(ev); facet = i->Next(ev))
  4032.          facet->ChangeGeometry(ev, newFrameShape, kODNULL, kODNULL);
  4033.       delete i;
  4034.     }
  4035. */
  4036. }
  4037.  
  4038.  
  4039. //--------------------------------------------------------------------------
  4040. // ODPart --> GeometryChanged
  4041. //
  4042. //      Should notify this part that the clip shape or external
  4043. //      transform (or both) of one of this part's facets has changed.
  4044. //
  4045. //      ->
  4046. //--------------------------------------------------------------------------
  4047.  
  4048. SOM_Scope       void
  4049. SOMLINK         BaseContainerGeometryChanged
  4050.                 (
  4051.                 BaseContainer   *somSelf,             // in
  4052.                 Environment     *ev,                  // in
  4053.                 ODFacet         *facet,               // in
  4054.                 ODBoolean        clipShapeChanged,    // in
  4055.                 ODBoolean        extTransformChanged  // in
  4056.                 )
  4057. {
  4058.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4059.     BaseContainerMethodDebug("BaseContainer","BaseContainerGeometryChanged");
  4060.  
  4061. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4062.     ODCanvas *canvas = facet->GetCanvas(ev);
  4063.     if (canvas && canvas->IsDynamic(ev)) { /* don't do when printing */
  4064.        if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  4065.           _fScrollExt->GeometryChanged(ev, facet, clipShapeChanged,
  4066.              extTransformChanged);
  4067.        } /* endif */
  4068.     } /* endif */
  4069. #endif //defined OS2 || WIN32
  4070. }
  4071.  
  4072.  
  4073.  
  4074. //--------------------------------------------------------------------------
  4075. // ODPart --> AttachSourceFrame
  4076. //
  4077. //      Should associate a source frame with a display frame for this part.
  4078. //
  4079. //      ->
  4080. //--------------------------------------------------------------------------
  4081.  
  4082. SOM_Scope       void
  4083. SOMLINK         BaseContainerAttachSourceFrame
  4084.                 (
  4085.                 BaseContainer   *somSelf,       // in
  4086.                 Environment     *ev,            // in
  4087.                 ODFrame         *frame,         // in
  4088.                 ODFrame         *sourceFrame    // in
  4089.                 )
  4090. {
  4091.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4092.     BaseContainerMethodDebug("BaseContainer","BaseContainerAttachSourceFrame");
  4093.  
  4094.     if (_fDisplayFrames->Contains (ev, frame) &&
  4095.         sourceFrame &&
  4096.         _fDisplayFrames->Contains (ev, sourceFrame))
  4097.     {
  4098. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4099. // Cause printouts to have parts scrolled to same position as they are onscreen
  4100. // Note we only do this for embedded parts - if you're the root part, and you
  4101. // support scrolling, and you want to support printing, you will need to take
  4102. // care of preparing the root printing frame yourself (based on your total
  4103. // content shape), rather than relying on the ODPrintExtension to take care of
  4104. // everything for you.  See the Page Layout sample part's override of the
  4105. // ODPrintExtension (in iodpgprn.cpp) for further details.
  4106.        if ((_fScrollExt!=kODNULL) && _fScrollingEnabled && !frame->IsRoot(ev)) {
  4107.           TempODTransform sourceXform = sourceFrame->AcquireInternalTransform(ev, kODNULL);
  4108.           ODTransform *newXform = sourceXform->Copy(ev);
  4109.           frame->ChangeInternalTransform(ev, newXform, kNoBias);
  4110.        } /* endif */
  4111. #endif //defined OS2 || WIN32
  4112.  
  4113.        ODULong count = _fEmbeddedObjects->Count(ev);
  4114.        ALink *itr = _fEmbeddedObjects->First(ev);
  4115.  
  4116.        for (int i = 0; i < count; i++)
  4117.        {
  4118.           ContentObject *cObj = (ContentObject *)itr->Content (ev);
  4119.  
  4120.           if (cObj->_get_containingFrame(ev) == sourceFrame) {
  4121.              ContentObject *newObj = cObj->CreateNewView (ev, frame);
  4122.              _fEmbeddedObjects->AddLast(ev, newObj);
  4123.           }
  4124.           itr = itr->Next(ev);
  4125.  
  4126.        } // end for
  4127.  
  4128.     }  // end if
  4129.  
  4130.  
  4131. }
  4132.  
  4133.  
  4134. //--------------------------------------------------------------------------
  4135. // ODPart --> PresentationChanged
  4136. //
  4137. //      Should notify this part that the presentation of one of its
  4138. //      display frames has changed.
  4139. //
  4140. //      ->
  4141. //--------------------------------------------------------------------------
  4142.  
  4143. SOM_Scope       void
  4144. SOMLINK         BaseContainerPresentationChanged
  4145.                 (
  4146.                 BaseContainer   *somSelf,       // in
  4147.                 Environment     *ev,            // in
  4148.                 ODFrame         *frame          // in
  4149.                 )
  4150. {
  4151.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4152.     BaseContainerMethodDebug("BaseContainer", "BaseContainerPresentationChanged");
  4153.  
  4154. }
  4155.  
  4156.  
  4157.  
  4158. //--------------------------------------------------------------------------
  4159. // ODPart --> ViewTypeChanged
  4160. //
  4161. //      Should notify this part that the view type  of one of its
  4162. //      display frames has changed.
  4163. //
  4164. //      ->
  4165. //--------------------------------------------------------------------------
  4166.  
  4167. SOM_Scope       void
  4168. SOMLINK         BaseContainerViewTypeChanged
  4169.                 (
  4170.                 BaseContainer   *somSelf,       // in
  4171.                 Environment     *ev,            // in
  4172.                 ODFrame         *frame          // in
  4173.                 )
  4174. {
  4175.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4176.     BaseContainerMethodDebug("BaseContainer","BaseContainerViewTypeChanged");
  4177.  
  4178.     try
  4179.     {
  4180.  
  4181.       if(frame->IsRoot(ev))
  4182.       {
  4183.          // When this is a root part, only support frame view.
  4184.          frame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsFrame));
  4185.       }
  4186.       else
  4187.       {
  4188. #ifdef _PLATFORM_AIX_
  4189.         ODTypeToken viewType = frame->GetViewType(ev);
  4190.  
  4191.         // Destroy the iconWidget if changing to a frame view.
  4192.         if(viewType == _fSession->Tokenize(ev, kODViewAsFrame)) {
  4193.            if(_iconWidget != NULL) {
  4194.               XtUnmanageChild(_iconWidget);
  4195.               XtDestroyWidget(_iconWidget);
  4196.               _iconWidget = NULL;
  4197.            }
  4198.         }
  4199. #endif
  4200.  
  4201.         // Set frame shape according to view type
  4202.         somSelf->AdjustViewTypeShapes(ev, frame);
  4203.  
  4204.         // Get the new frame shape to be invalidated.
  4205.         TempODShape newShape = frame->AcquireFrameShape(ev,kODNULL);
  4206.  
  4207.         // Force the display of our new view type
  4208.         frame->Invalidate(ev, newShape, kODNULL);
  4209.       }
  4210.     }
  4211.     catch(...)
  4212.     {
  4213.     }
  4214.  
  4215. }
  4216.  
  4217.  
  4218.  
  4219. //--------------------------------------------------------------------------
  4220. // ODPart --> SequenceChanged
  4221. //
  4222. //      Should notify this part that the sequencing of this part's
  4223. //      display frame within its frame group has changed.
  4224. //
  4225. //      ->
  4226. //--------------------------------------------------------------------------
  4227.  
  4228. SOM_Scope       void
  4229. SOMLINK         BaseContainerSequenceChanged
  4230.                 (
  4231.                 BaseContainer   *somSelf,       // in
  4232.                 Environment     *ev,            // in
  4233.                 ODFrame         *frame          // in
  4234.                 )
  4235. {
  4236.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4237.     BaseContainerMethodDebug("BaseContainer","BaseContainerSequenceChanged");
  4238.  
  4239. }
  4240.  
  4241. //--------------------------------------------------------------------------
  4242. // ODPart --> FrameShapeChanged
  4243. //
  4244. //      Should notify this part that the frame shape of one of its
  4245. //      display frames has changed.
  4246. //
  4247. //      ->
  4248. //--------------------------------------------------------------------------
  4249.  
  4250. SOM_Scope       void
  4251. SOMLINK         BaseContainerFrameShapeChanged
  4252.                 (
  4253.                 BaseContainer   *somSelf,       // in
  4254.                 Environment     *ev,            // in
  4255.                 ODFrame         *frame          // in
  4256.                 )
  4257. {
  4258.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4259.     BaseContainerMethodDebug("BaseContainer","BaseContainerFrameShapeChanged");
  4260.  
  4261. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4262.     if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  4263.        _fScrollExt->FrameShapeChanged(ev, frame);
  4264.     } /* endif */
  4265. #endif //defined OS2 || WIN32
  4266.  
  4267.     // Do not allow resize if displaying as icon/thumbnail.
  4268.     somSelf->AdjustViewTypeShapes(ev, frame);
  4269.  
  4270.     // Update the content extent
  4271.     somSelf->UpdateContentExtent(ev, frame);
  4272.  
  4273. #if defined (_PLATFORM_OS2_)
  4274.  
  4275.     FramePartInfo *pInfo = (FramePartInfo *) frame->GetPartInfo(ev);
  4276.     if (!pInfo)
  4277.        return;
  4278.  
  4279.     ODRect oldRect = pInfo->frameRect;
  4280.     ODRect newRect;
  4281.     TempODShape fShape = frame->AcquireFrameShape (ev, kODNULL);
  4282.     fShape->GetBoundingBox (ev, &newRect);
  4283.  
  4284.     if ((newRect.top - newRect.bottom == 0) || (newRect.right - newRect.left == 0))
  4285.        return;
  4286.  
  4287.     if (oldRect.top - oldRect.bottom == 0) {
  4288.        pInfo->frameRect = newRect;
  4289.        return;
  4290.     }
  4291.  
  4292.     pInfo->frameRect = newRect;
  4293.  
  4294.     if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  4295.        /* We don't want to adjust the embed position to simulate a top-left based */
  4296.        /* coordinate system when scrolling is enabled - in that case, we take the */
  4297.        /* much more elegant approach of simply adjusting the internal transform,  */
  4298.        /* which scrolls our embeds, achieving the same effect without actually    */
  4299.        /* messing with the external transforms of the embeds themselves.          */
  4300.        return;
  4301.     } /* endif */
  4302.  
  4303.     // now let's do some coordinate computation
  4304.     ODPoint offset(0, 0);
  4305.     offset.y = newRect.top - oldRect.top;
  4306.  
  4307.     ALink *itr;
  4308.     for (itr = _fEmbeddedObjects->First(ev); itr->Content(ev); itr = itr->Next(ev)) {
  4309.        ContentObject *cObj = (ContentObject *) itr->Content(ev);
  4310.        cObj->MoveBy (ev, &offset);
  4311.     } /* endfor */
  4312.  
  4313.     if (_fSelectedObjects->Count(ev))
  4314.        somSelf->CreateSelectionBorderShapes (ev, kODNULL);
  4315.  
  4316. #endif
  4317. }
  4318.  
  4319. // -------------------------------------------------------------------------
  4320. // ODPart --> CanvasChanged
  4321. // -------------------------------------------------------------------------
  4322.  
  4323. SOM_Scope       void
  4324. SOMLINK         BaseContainerCanvasChanged
  4325.                 (
  4326.                 BaseContainer   *somSelf,       // in
  4327.                 Environment     *ev,            // in
  4328.                 ODFacet         *facet          // in
  4329.                 )
  4330. {
  4331.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4332.     BaseContainerMethodDebug("BaseContainer","BaseContainerCanvasChanged");
  4333.  
  4334.  
  4335. }
  4336.  
  4337.  
  4338.  
  4339. //--------------------------------------------------------------------------
  4340. // ODPart --> CanvasUpdated
  4341. //
  4342. //--------------------------------------------------------------------------
  4343.  
  4344. SOM_Scope       void
  4345. SOMLINK         BaseContainerCanvasUpdated
  4346.                 (
  4347.                 BaseContainer   *somSelf,       // in
  4348.                 Environment     *ev,            // in
  4349.                 ODCanvas        *canvas         // in
  4350.                 )
  4351. {
  4352.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4353.     BaseContainerMethodDebug("BaseContainer","BaseContainerCanvasUpdated");
  4354.  
  4355.  
  4356. }
  4357.  
  4358.  
  4359. // -------------------------------------------------------------------------
  4360. // ODPart --> HighlightChanged
  4361. //
  4362. // -------------------------------------------------------------------------
  4363.  
  4364. SOM_Scope       void
  4365. SOMLINK         BaseContainerHighlightChanged
  4366.                 (
  4367.                 BaseContainer   *somSelf,       // in
  4368.                 Environment     *ev,            // in
  4369.                 ODFacet         *facet          // in
  4370.                 )
  4371. {
  4372.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4373.     BaseContainerMethodDebug("BaseContainer","BaseContainerHighlightChanged");
  4374.  
  4375.  
  4376. }
  4377.  
  4378. // -------------------------------------------------------------------------
  4379. // ODPart --> ChangeKind
  4380. //
  4381. //      Changes this part's preferred kind.
  4382. // -------------------------------------------------------------------------
  4383.  
  4384. SOM_Scope       void
  4385. SOMLINK         BaseContainerChangeKind
  4386.                 (
  4387.                 BaseContainer   *somSelf,       // in
  4388.                 Environment     *ev,            // in
  4389.                 ODType           kind           // in
  4390.                 )
  4391. {
  4392.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4393.     BaseContainerMethodDebug("BaseContainer","BaseContainerChangeKind");
  4394.  
  4395.  
  4396.  
  4397. }
  4398.  
  4399. // -------------------------------------------------------------------------
  4400. // BaseContainer --> SetupPrinting
  4401. // -------------------------------------------------------------------------
  4402.  
  4403. SOM_Scope       ODBoolean
  4404. SOMLINK         BaseContainerSetupPrinting
  4405.                 (
  4406.                 BaseContainer   *somSelf,       // in
  4407.                 Environment     *ev,            // in
  4408.                 ODFrame         *frame,         // in
  4409.                 ODEventData     *event          // in
  4410.                 )
  4411. {
  4412.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4413.     BaseContainerMethodDebug("BaseContainer","BaseContainerSetupPrinting");
  4414.  
  4415.     ODBoolean paperSizeChanged = kODFalse;
  4416.  
  4417. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4418.     if ((_fPrintExt!=kODNULL) && _fPrintingEnabled) {
  4419.        paperSizeChanged = _fPrintExt->PrinterSetup(ev, event->hwnd);
  4420.     } /* endif */
  4421. #endif //defined OS2 || WIN32
  4422.  
  4423.     return(paperSizeChanged);
  4424. }
  4425.  
  4426. // -------------------------------------------------------------------------
  4427. // BaseContainer --> HandlePrinting
  4428. // -------------------------------------------------------------------------
  4429.  
  4430. SOM_Scope       ODBoolean
  4431. SOMLINK         BaseContainerHandlePrinting
  4432.                 (
  4433.                 BaseContainer   *somSelf,       // in
  4434.                 Environment     *ev,            // in
  4435.                 ODFrame         *frame,         // in
  4436.                 ODEventData     *event          // in
  4437.                 )
  4438. {
  4439.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4440.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandlePrinting");
  4441.  
  4442.     ODBoolean handled = kODFalse;
  4443.  
  4444. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4445.     if ((_fPrintExt!=kODNULL) && _fPrintingEnabled) {
  4446.        handled = _fPrintExt->PrintDocument(ev, frame, event);
  4447.     } /* endif */
  4448. #endif //defined OS2 || WIN32
  4449.  
  4450.     return(handled);
  4451. }
  4452.  
  4453. // -------------------------------------------------------------------------
  4454. // BaseContainer --> HandleScrollEvent
  4455. // -------------------------------------------------------------------------
  4456.  
  4457. SOM_Scope       ODBoolean
  4458. SOMLINK         BaseContainerHandleScrollEvent
  4459.                 (
  4460.                 BaseContainer   *somSelf,       // in
  4461.                 Environment     *ev,            // in
  4462.                 ODFrame         *frame,         // in
  4463.                 ODEventData     *event          // in
  4464.                 )
  4465. {
  4466.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4467.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleScrollEvent");
  4468.  
  4469.     ODBoolean handled = kODFalse;
  4470.  
  4471. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4472.     if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  4473.        handled = _fScrollExt->HandleScrollEvent(ev, frame, event);
  4474.     } /* endif */
  4475. #endif //defined OS2 || WIN32
  4476.  
  4477.     return(handled);
  4478. }
  4479.  
  4480. // -------------------------------------------------------------------------
  4481. // BaseContainer --> CreatePrintExtension
  4482. //
  4483. // This method could be overridden by a subclass if for example a different
  4484. // class is to be used for the PrintExtension (it would of course have to provide
  4485. // the interfaces of an ODPrintExtension which are used elsewhere in this
  4486. // class)
  4487. // -------------------------------------------------------------------------
  4488.  
  4489. SOM_Scope       ODExtension*
  4490. SOMLINK         BaseContainerCreatePrintExtension
  4491.                 (
  4492.                 BaseContainer   *somSelf,       // in
  4493.                 Environment     *ev             // in
  4494.                 )
  4495. {
  4496.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4497.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreatePrintExtension");
  4498.  
  4499.     ODExtension *printExtension = kODNULL;
  4500.  
  4501. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4502.  
  4503.     // create and intialize the ODPrintExtension object.
  4504.     printExtension = new ODPrintExtension;
  4505.     if (printExtension != kODNULL) {
  4506.        ((ODPrintExtension *)printExtension)->Initialize(ev, somSelf, kODNULL);
  4507.     }
  4508. #endif //defined OS2 || WIN32
  4509.  
  4510.     return printExtension;
  4511. }
  4512.  
  4513. // -------------------------------------------------------------------------
  4514. // BaseContainer --> CreateScrollExtension
  4515. //
  4516. // This method could be overridden by a subclass to provide a different
  4517. // implementation object for the Scroll Extension.
  4518. // -------------------------------------------------------------------------
  4519.  
  4520. SOM_Scope       ODExtension*
  4521. SOMLINK         BaseContainerCreateScrollExtension
  4522.                 (
  4523.                 BaseContainer   *somSelf,       // in
  4524.                 Environment     *ev             // in
  4525.                 )
  4526. {
  4527.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4528.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateScrollExtension");
  4529.  
  4530.     ODExtension *scrollExtension = kODNULL;
  4531.  
  4532. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4533.  
  4534.     // create and initialize the ODScrollExtension Object.
  4535.     scrollExtension = new ODScrollExtension;
  4536.     if (scrollExtension != kODNULL) {
  4537.        ((ODScrollExtension *)scrollExtension)->Initialize(ev, somSelf, 0, 0);
  4538.     }
  4539. #endif //defined OS2 || WIN32
  4540.  
  4541.     return scrollExtension;
  4542. }
  4543.  
  4544. // -------------------------------------------------------------------------
  4545. // BaseContainer --> CreateSettingsExtension
  4546. //
  4547. // This method could be overridden by a subclass to provide a different
  4548. // object to support the SettingsExtension.
  4549. // -------------------------------------------------------------------------
  4550.  
  4551. SOM_Scope       ODExtension*
  4552. SOMLINK         BaseContainerCreateSettingsExtension
  4553.                 (
  4554.                 BaseContainer   *somSelf,       // in
  4555.                 Environment     *ev             // in
  4556.                 )
  4557. {
  4558.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4559.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateScrollExtension");
  4560.  
  4561.     BCPartSettingsExt *settingsExtension = kODNULL;
  4562.  
  4563.     // create and initialize the BCPartSettingsExt object.
  4564.     settingsExtension = new BCPartSettingsExt;
  4565.     if (settingsExtension != kODNULL) {
  4566.        settingsExtension->InitSettingsExtension(ev, somSelf) ;
  4567.     }
  4568.  
  4569.     return settingsExtension;
  4570. }
  4571.  
  4572. // -------------------------------------------------------------------------
  4573. // BaseContainer --> EnablePrinting
  4574. //
  4575. //
  4576. // -------------------------------------------------------------------------
  4577.  
  4578. SOM_Scope       ODExtension*
  4579. SOMLINK         BaseContainerEnablePrinting
  4580.                 (
  4581.                 BaseContainer   *somSelf,       // in
  4582.                 Environment     *ev,            // in
  4583.                 ODBoolean        enable,        // in
  4584.                 char            *QueueName      // in
  4585.                 )
  4586. {
  4587.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4588.     BaseContainerMethodDebug("BaseContainer","BaseContainerEnablePrinting");
  4589.  
  4590.     ODExtension *printExtension = kODNULL;
  4591.  
  4592. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4593.     _fPrintingEnabled = enable;
  4594.     if ((_fPrintExt != kODNULL) && enable) {
  4595.        printExtension = _fPrintExt ;
  4596.        _fPrintExt->QuerySelectedPrinter(ev, QueueName, kODFalse);
  4597.     }
  4598. #endif // OS/2 or Win95/NT
  4599.  
  4600.     return(printExtension);
  4601. }
  4602.  
  4603. // -------------------------------------------------------------------------
  4604. // BaseContainer --> EnableScrolling
  4605. //
  4606. //
  4607. // -------------------------------------------------------------------------
  4608.  
  4609. SOM_Scope       ODExtension*
  4610. SOMLINK         BaseContainerEnableScrolling
  4611.                 (
  4612.                 BaseContainer   *somSelf,       // in
  4613.                 Environment     *ev,            // in
  4614.                 ODBoolean        enable,        // in
  4615.                 long             totalWidth,    // in
  4616.                 long             totalHeight    // in
  4617.                 )
  4618. {
  4619.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4620.     BaseContainerMethodDebug("BaseContainer","BaseContainerEnableScrolling");
  4621.  
  4622.     ODExtension *scrollExtension = kODNULL;
  4623.  
  4624. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4625.  
  4626.     _fScrollingEnabled = enable;
  4627.     somSelf->SetScrollableDimensions(ev, kODNULL /* frame */,
  4628.                                      totalWidth, totalHeight);
  4629.     scrollExtension = _fScrollExt ;
  4630. #endif // OS/2 or Win95/NT
  4631.  
  4632.     return(scrollExtension);
  4633. }
  4634.  
  4635. // -------------------------------------------------------------------------
  4636. // BaseContainer --> SetScrollableDimensions
  4637. //
  4638. //
  4639. // -------------------------------------------------------------------------
  4640.  
  4641. SOM_Scope       void
  4642. SOMLINK         BaseContainerSetScrollableDimensions
  4643.                 (
  4644.                 BaseContainer   *somSelf,       // in
  4645.                 Environment     *ev,            // in
  4646.                 ODFrame         *frame,
  4647.                 long             totalWidth,    // in
  4648.                 long             totalHeight    // in
  4649.                 )
  4650. {
  4651.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4652.     BaseContainerMethodDebug("BaseContainer","BaseContainerSetScrollableDimensions");
  4653.  
  4654. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  4655.     if ((_fScrollExt!=kODNULL) && _fScrollingEnabled) {
  4656.        _fScrollExt->SetScrollableDimensions(ev, frame, totalWidth, totalHeight);
  4657.     } /* endif */
  4658. #endif //defined OS2 || WIN32
  4659. }
  4660.  
  4661. // -------------------------------------------------------------------------
  4662. // BaseContainer --> ChangeNotification
  4663. // This is a hook for subclasses so that they can know when anything
  4664. // changes in base container.
  4665. // -------------------------------------------------------------------------
  4666.  
  4667. SOM_Scope       void
  4668. SOMLINK         BaseContainerChangeNotification
  4669.                 (
  4670.                 BaseContainer   *somSelf,       // in
  4671.                 Environment     *ev,            // in
  4672.                 ODULong          reason,
  4673.                 ODFrame         *frame,
  4674.                 ContentObject  *content,        // in
  4675.                 ODBoolean       bPropagate,     // in
  4676.                 ODUpdateID      updateID
  4677.                 )
  4678. {
  4679.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4680.     BaseContainerMethodDebug("BaseContainer","BaseContainerChangeNotification");
  4681.  
  4682.     if (bPropagate)
  4683.     {
  4684.        // get change
  4685.        ODFrame * myFrame = frame;
  4686.        if (!frame)
  4687.           myFrame = (ODFrame *) _fDisplayFrames->First(ev)->Content(ev);
  4688.  
  4689.        // get ID
  4690.        ODUpdateID change = updateID;
  4691.        if (!updateID)
  4692.           change = _fSession->UniqueUpdateID(ev);
  4693.  
  4694.        myFrame->ContentUpdated (ev, change);
  4695.     }
  4696. }
  4697.  
  4698. // -------------------------------------------------------------------------
  4699. // BaseContainer --> GetMouseMode
  4700. // -------------------------------------------------------------------------
  4701.  
  4702. SOM_Scope       unsigned short
  4703. SOMLINK         BaseContainerGetMouseMode
  4704.                 (
  4705.                 BaseContainer   *somSelf,       // in
  4706.                 Environment     *ev            // in
  4707.                 )
  4708. {
  4709.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4710.     BaseContainerMethodDebug("BaseContainer","BaseContainerGetMouseMode");
  4711.  
  4712.     return _usMouseMode;
  4713. }
  4714.  
  4715. // -------------------------------------------------------------------------
  4716. // BaseContainer --> UpdateContentExtent
  4717. // -------------------------------------------------------------------------
  4718.  
  4719. SOM_Scope       void
  4720. SOMLINK         BaseContainerUpdateContentExtent
  4721.                 (
  4722.                 BaseContainer   *somSelf,       // in
  4723.                 Environment     *ev,            // in
  4724.                 ODFrame         *myFrame        // in
  4725.                 )
  4726. {
  4727.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4728.     BaseContainerMethodDebug("BaseContainer","BaseContainerUpdateContentExtent");
  4729.  
  4730.     try {
  4731.        TempODShape frameShape = myFrame->AcquireFrameShape(ev, kODNULL);
  4732.        ODRect frameRect;
  4733.        frameShape->GetBoundingBox(ev, &frameRect);
  4734. #ifdef _PLATFORM_OS2_
  4735.        ODPoint extent(frameRect.right, frameRect.top);
  4736. #else
  4737.        ODPoint extent(frameRect.right, frameRect.bottom);
  4738. #endif
  4739.        myFrame->ChangeContentExtent(ev, &extent);
  4740.     } /* endtry */
  4741.     catch (...) {
  4742.     } /* endcatch */
  4743.  
  4744. }
  4745.  
  4746. // -------------------------------------------------------------------------
  4747. // BaseContainer --> CreateNewMenu
  4748. // -------------------------------------------------------------------------
  4749.  
  4750. SOM_Scope       ODPlatformMenu
  4751. SOMLINK         BaseContainerCreateNewMenu (
  4752.                 BaseContainer       *somSelf,       // in
  4753.                 Environment         *ev,            // in
  4754.                 ODMenuBar           *menuBar,
  4755.                 ODULong             menuID)
  4756. {
  4757.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4758.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateNewMenu");
  4759.  
  4760.     ODPlatformMenu newMenu;
  4761.  
  4762. #if defined(_PLATFORM_WIN32_)
  4763.     newMenu = (ODPlatformMenu)CreateMenu();
  4764. #elif defined(_PLATFORM_OS2_)
  4765.     newMenu = WinCreateMenu(HWND_OBJECT,kODNULL);
  4766. #elif defined(_PLATFORM_UNIX_)
  4767.     newMenu = menuBar->CreateX11PlatformMenu(ev, menuID);
  4768. #endif
  4769.  
  4770.     menuBar->AddMenuLast(ev, menuID, newMenu, _fPartWrapper);
  4771.  
  4772.     return newMenu;
  4773. }
  4774.  
  4775. // -------------------------------------------------------------------------
  4776. // BaseContainer --> CreateMenuItemFromCatalog
  4777. // -------------------------------------------------------------------------
  4778.  
  4779. SOM_Scope       void
  4780. SOMLINK         BaseContainerCreateMenuItemFromCatalog (
  4781.                 BaseContainer       *somSelf,       // in
  4782.                 Environment         *ev,            // in
  4783.                 ODMenuBar           *menuBar,
  4784.                 ODULong             parentMenuID,
  4785.                 ODPlatformMenuItem  *menuItem,
  4786.                 ODPtr               nlsCat,         // Catalog previously opened
  4787.                 ODULong             msgSet,
  4788.                 ODULong             msgID,
  4789.                 string              defaultText)
  4790. {
  4791.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4792.     BaseContainerMethodDebug("BaseContainer","BaseContainerCreateMenuItemFromCatalog");
  4793.  
  4794.     menuBar->AddMenuItemLast(ev, parentMenuID, menuItem->id, menuItem);
  4795.  
  4796.     somSelf->SetMenuItemTextFromCatalog ( ev,
  4797.                                           menuBar,
  4798.                                           parentMenuID,
  4799.                                           menuItem,
  4800.                                          (nl_catd) nlsCat,
  4801.                                           msgSet,
  4802.                                           msgID,
  4803.                                           defaultText);
  4804. }
  4805.  
  4806. // -------------------------------------------------------------------------
  4807. // BaseContainer --> SetMenuItemTextFromCatalog
  4808. // -------------------------------------------------------------------------
  4809.  
  4810. SOM_Scope       void
  4811. SOMLINK         BaseContainerSetMenuItemTextFromCatalog (
  4812.                 BaseContainer       *somSelf,       // in
  4813.                 Environment         *ev,            // in
  4814.                 ODMenuBar           *menuBar,
  4815.                 ODULong             parentMenuID,
  4816.                 ODPlatformMenuItem  *menuItem,
  4817.                 ODPtr               nlsCat,         // Catalog previously opened
  4818.                 ODULong             msgSet,
  4819.                 ODULong             msgID,
  4820.                 string              defaultText)
  4821. {
  4822.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4823.     BaseContainerMethodDebug("BaseContainer","BaseContainerSetMenuItemTextFromCatalog");
  4824.  
  4825.  
  4826. #if defined(__IBMCPP__) || defined(_IBMR2)
  4827.     char *bcText;           // pointer for NLS message
  4828.     bcText=catgets((nl_catd) nlsCat, msgSet, msgID, defaultText);
  4829. #else
  4830.     char bcText[256];
  4831.     strcpy (bcText, defaultText);
  4832. #endif
  4833.     menuBar->SetMenuItemText(ev, parentMenuID, menuItem->id, bcText);
  4834.  
  4835. }
  4836.  
  4837. // -------------------------------------------------------------------------
  4838. // BaseContainer --> AddSeparatorToMenu
  4839. // -------------------------------------------------------------------------
  4840.  
  4841. SOM_Scope       void
  4842. SOMLINK         BaseContainerAddSeparatorToMenu
  4843.                 (
  4844.                 BaseContainer   *somSelf,       // in
  4845.                 Environment     *ev,            // in
  4846.                 ODMenuBar       *menuBar,
  4847.                 ODULong         menuID,
  4848.                 ODULong         separatorID
  4849.                 )
  4850. {
  4851.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  4852.     BaseContainerMethodDebug("BaseContainer","BaseContainerAddSeparatorToMenu");
  4853.  
  4854.     ODPlatformMenuItem *mi = new ODPlatformMenuItem;
  4855.  
  4856.     // clear the memory
  4857.     memset (mi, 0, sizeof(ODPlatformMenuItem));
  4858.  
  4859.     // add a menu separator line to the menu
  4860.     mi->id = separatorID;
  4861. #if defined(_PLATFORM_WIN32_)
  4862.     mi->afAttribute=MF_SEPARATOR;
  4863. #elif defined(_PLATFORM_OS2_)
  4864.     mi->afAttribute=CA_TITLESEPARATOR;
  4865. #endif
  4866.     menuBar->AddMenuItemLast(ev, menuID, mi->id, mi);
  4867.  
  4868.     delete mi;
  4869. }
  4870.  
  4871.