home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / simple / iodsimpl.cpp next >
C/C++ Source or Header  |  1997-04-02  |  93KB  |  2,764 lines

  1. /* @(#)Z 1.52 com/src/samples/simple/iodsimpl.cpp, odsimplepart, od96os2, odos29714c 97/04/02 17:19:33 (97/03/20 10:15:59) */
  2. //====START_GENERATED_PROLOG======================================
  3. //
  4. //
  5. //   COMPONENT_NAME: odsamples
  6. //
  7. //   CLASSES: none
  8. //
  9. //   ORIGINS: 82,27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28.  
  29. /*
  30.  *      File:           SimplPrt.cpp
  31.  *
  32.  *   Contains:  Implementation of Simple Part
  33.  *
  34.  *   Copyright: (c) 1993-1994 by IBM Corp., all rights reserved.
  35.  *
  36.  */
  37.  
  38. /*
  39.  *  This file was generated by the SOM Compiler and Emitter Framework.
  40.  *  Generated using:
  41.  *      SOM Emitter emitxtm: 2.38
  42.  */
  43.  
  44. #ifdef __IBMC__
  45.   #pragma linkage (SOMInitModule, system)
  46. #endif
  47.  
  48. #ifndef SOM_Module_iodsimpl_Source
  49. #define SOM_Module_iodsimpl_Source
  50. #endif
  51.  
  52. #ifdef _PLATFORM_UNIX_
  53. #include <Xm/XmAll.h>
  54. #endif
  55.  
  56. #ifdef _PLATFORM_OS2_
  57. #include <stdio.h>
  58. #endif //_PLATFORM_OS2_
  59.  
  60. #ifndef _ODEXCEPT_
  61. #include "ODExcept.h"
  62. #endif
  63.  
  64. #ifndef _FOCUSLIB_
  65. #include <FocusLib.h>
  66. #endif
  67.  
  68. #ifndef _ODMATH_
  69. #include "ODMath.h"
  70. #endif
  71.  
  72. #ifndef _WINUTILS_
  73. #include "WinUtils.h"
  74. #endif
  75.  
  76. #ifndef _STORUTIL_
  77. #include "StorUtil.h"
  78. #endif
  79.  
  80. #ifndef _IODLINK_
  81. #include "iodlink.xh"
  82. #endif
  83.  
  84. #ifndef _ODDEBUG_
  85. #include "ODDebug.h"
  86. #endif
  87.  
  88. #ifndef _TEMPOBJ_
  89. #include <TempObj.h>
  90. #endif
  91.  
  92. #ifndef _ODRES_
  93. #ifdef _PLATFORM_UNIX_
  94. #include <odres.h>
  95. #else
  96. #include <ODRes.h>
  97. #endif
  98. #endif
  99.  
  100. #ifndef _STDTYPIO_
  101. #include <StdTypIO.h>
  102. #endif
  103.  
  104. #include <string.h>
  105.  
  106. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_)
  107. #include "CmdDefs.xh"
  108. #include "ODSessn.xh"
  109. #include "WinStat.xh"
  110. #include "Shape.xh"
  111. #include "MenuBar.xh"
  112. #include "Popup.xh"
  113. #include "Foci.xh"
  114. #include "Info.xh"
  115. #include "FocusSet.xh"
  116. #include "FocusItr.xh"
  117. #include "Arbitrat.xh"
  118. #include "Draft.xh"
  119. #include "FacetItr.xh"
  120. #include "Frame.xh"
  121. #include "Facet.xh"
  122. #include "FrFaItr.xh"
  123. #include "Window.xh"
  124. #include "StdTypes.xh"
  125. #include "StdProps.xh"
  126. #include "StorageU.xh"
  127. #include "ODResrc.h"
  128. #elif defined(_PLATFORM_UNIX_)
  129. #include <odall.h>
  130. #endif
  131.  
  132. #ifndef SOM_ODHelp_xh
  133. #include <odhelp.xh>
  134. #endif
  135.  
  136. // definition for class name; use it for adding HELP menu
  137. #define kSimpleClassName "SimplePart"
  138.  
  139. #define SimplePart_Class_Source
  140. #define VARIABLE_MACROS
  141. #include "iodsimpl.xih"
  142.  
  143.  
  144. const ODType   kPartHandlerName           = "SimplePart";
  145. const ODType   kSimplePartPresNormal      = "SimplePart:Presentation:Normal";
  146. const ODType   kSimplePartPresPalette     = "SimplePart:Presentation:Palette";
  147. const ODType   kSimplePartKind            = "SimplePart";
  148. const ODType   kSimplePartKindDisplayName = "Simple Part Kind";
  149. const ODType   kSimplePartCategory        = "OpenDoc:Category:Sample";
  150.  
  151. // Define InitPropVal Storage Unit utility to focus on a propName.
  152. inline void InitPropVal (Environment *ev, ODStorageUnit *su,
  153.                          ODPropertyName propName, ODValueType valName)
  154. {
  155.     if (ODSUExistsThenFocus (ev, su, propName, valName))
  156.          su->Remove (ev);
  157.  
  158.     ODSUAddPropValue (ev, su, propName, valName);
  159.  
  160. }
  161.  
  162. /******************************************************************
  163. The following messages are defined in ODPart and changed in SimplePart.
  164.  ******************************************************************/
  165.  
  166. SOM_Scope void  SOMLINK SimplePartsomInit(SimplePart *somSelf)
  167. {
  168.     SimplePartData *somThis = SimplePartGetData(somSelf);
  169.     SimplePartMethodDebug("SimplePart","SimplePartsomInit");
  170.  
  171.     SimplePart_parent_ODPart_somInit(somSelf);
  172.  
  173.     _fPartWrapper = kODNULL;
  174.     _fFocusSet = kODNULL;
  175.     _fSession = kODNULL;
  176.     _fWindowID = kODNULL;
  177.  
  178.     _fDisplayFrames = 0;
  179.     _fIsInitialized = kODFalse;
  180.     _fMenuBar = kODNULL;
  181.     _fPopup = kODNULL;
  182.  
  183.     _hSmallIcon = kODNULL;
  184.     _hLargeIcon = kODNULL;
  185.     _hThumbnail = kODNULL;
  186.     _hResModule = kODNULL;
  187. }
  188.  
  189. SOM_Scope void  SOMLINK SimplePartsomUninit(SimplePart *somSelf)
  190. {
  191.     SimplePartData *somThis = SimplePartGetData(somSelf);
  192.     SimplePartMethodDebug("SimplePart","SimplePartsomUninit");
  193.  
  194.  
  195.     if (_fDisplayFrames != kODNULL)
  196.       delete _fDisplayFrames;    // make sure it's empty first
  197.  
  198.     Environment * ev = somGetGlobalEnvironment();
  199.  
  200.  
  201.     try
  202.     {
  203.       // Release the resource module
  204.       somSelf->FreeResModule(ev);
  205.  
  206.       SimplePart_parent_ODPart_somUninit(somSelf);
  207.  
  208.     }
  209.  
  210.     catch(ODException _exception)
  211.     {
  212.     }
  213. }
  214.  
  215. SOM_Scope void  SOMLINK SimplePartDisplayFrameAdded(SimplePart *somSelf,
  216.                                                    Environment *ev,
  217.                                                   ODFrame* frame)
  218. {
  219.     SimplePartData *somThis = SimplePartGetData(somSelf);
  220.     SimplePartMethodDebug("SimplePart","SimplePartDisplayFrameAdded");
  221.    try
  222.    {
  223.  
  224.       _fDisplayFrames->AddLast(ev, frame);
  225.       frame->Acquire(ev);
  226.  
  227.  
  228.       if (!frame->IsRoot(ev))
  229.       {
  230.         // Store the frame shape to be used later if we change view types.
  231.         TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
  232.         frameShape->GetBoundingBox(ev, &_lastFrameRect);
  233.       }
  234.  
  235.      PartInfoRec* pInfo = (PartInfoRec*)frame->GetPartInfo(ev);
  236.      if (!pInfo)
  237.      {
  238.         pInfo = somSelf->CreateFramePartInfo(ev);
  239.         if (frame->IsRoot(ev))
  240.           pInfo->fNeedsActivating = kODTrue;
  241.  
  242.         frame->SetPartInfo(ev, (ODInfoType) pInfo);
  243.      }
  244.    }
  245.    catch(ODException _exception)
  246.    {
  247.    }
  248. }
  249.  
  250. SOM_Scope void  SOMLINK SimplePartDisplayFrameConnected(SimplePart *somSelf,
  251.                                                         Environment *ev,
  252.                                                         ODFrame* frame)
  253. {
  254.     SimplePartData *somThis = SimplePartGetData(somSelf);
  255.     SimplePartMethodDebug("SimplePart","SimplePartDisplayFrameConnected");
  256.    try
  257.    {
  258.  
  259.      _fDisplayFrames->AddLast(ev, frame);
  260.      frame->Acquire(ev);
  261.  
  262.      PartInfoRec* pInfo = (PartInfoRec*)frame->GetPartInfo(ev);
  263.      if (!pInfo)
  264.      {
  265.         pInfo = somSelf->CreateFramePartInfo(ev);
  266.         if (frame->IsRoot(ev))
  267.            pInfo->fNeedsActivating = kODTrue;
  268.         frame->SetPartInfo(ev, (ODInfoType) pInfo);
  269.      }
  270.  
  271.    }
  272.    catch(ODException _exception)
  273.    {
  274.    }
  275.  
  276. }
  277.  
  278. SOM_Scope void  SOMLINK SimplePartDisplayFrameRemoved(SimplePart *somSelf,
  279.                                                       Environment *ev,
  280.                                                      ODFrame* frame)
  281. {
  282.     SimplePartData *somThis = SimplePartGetData(somSelf);
  283.     SimplePartMethodDebug("SimplePart","SimplePartDisplayFrameRemoved");
  284.    try
  285.    {
  286.      if (frame  != kODNULL)
  287.      {
  288.         if (_fDisplayFrames->Contains(ev, frame))
  289.         {
  290.            _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame );
  291.  
  292.            PartInfoRec* pInfo = (PartInfoRec*) frame ->GetPartInfo(ev);
  293.            frame ->SetPartInfo(ev, (ODInfoType) kODNULL);
  294.            somSelf->DeleteFramePartInfo(ev, pInfo);
  295.  
  296.            _fDisplayFrames->Remove(ev, frame);
  297.  
  298.            // Release the frame acquired during DisplayFrameAdded/Connected
  299.            frame->Release(ev);
  300.         }
  301.         else
  302.            THROW(kODErrInvalidFrame);
  303.      }
  304.    }
  305.    catch(ODException _exception)
  306.    {
  307.    }
  308. }
  309.  
  310. SOM_Scope void  SOMLINK SimplePartDisplayFrameClosed(SimplePart *somSelf,
  311.                                                      Environment *ev,
  312.                                                      ODFrame* frame)
  313. {
  314.     SimplePartData *somThis = SimplePartGetData(somSelf);
  315.     SimplePartMethodDebug("SimplePart","SimplePartDisplayFrameClosed");
  316.    try
  317.    {
  318.  
  319.      if (frame  != kODNULL)
  320.      {
  321.         if (_fDisplayFrames->Contains(ev, frame))
  322.         {
  323.            _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame );
  324.  
  325.            PartInfoRec* pInfo = (PartInfoRec*) frame ->GetPartInfo(ev);
  326.            somSelf->DeleteFramePartInfo(ev, pInfo);
  327.  
  328.            _fDisplayFrames->Remove(ev, frame);
  329.  
  330.            // Release the frame acquired during DisplayFrameAdded/Connected
  331.            frame->Release(ev);
  332.         }
  333.         else
  334.            THROW(kODErrInvalidFrame);
  335.      }
  336.    }
  337.    catch(ODException _exception)
  338.    {
  339.    }
  340.  
  341. }
  342.  
  343. SOM_Scope ODID  SOMLINK SimplePartOpen(SimplePart *somSelf,  Environment *ev,
  344.                                        ODFrame* frame)
  345. {
  346.   SimplePartData *somThis = SimplePartGetData(somSelf);
  347.   SimplePartMethodDebug("SimplePart","SimplePartOpen");
  348.  
  349.   try
  350.   {
  351.  
  352.     TempODWindow window = kODNULL;
  353.  
  354.     ODWindowState* winState=_fSession->GetWindowState(ev);
  355.  
  356.     if (frame)
  357.     {
  358.         if (frame->IsRoot(ev))
  359.         {
  360.             // There are two situations in which this code will be executed:
  361.             // 1) This is the root part of a stored document that is being reopened, or
  362.             // 2) This is an embedded part of a document that was saved (by
  363.             //    closing the document or by creating a draft) while this part was
  364.             //    Opened-As-Window. And now the document is reopened.
  365.             // In both cases the frame is marked as a root frame, but in the second
  366.             // case the isRootWindow property is FALSE.
  367.  
  368.             WindowProperties props;
  369.             BeginGetWindowProperties(ev, frame, &props);
  370.  
  371.             ODPlatformWindow platwin = winState->CreatePlatformWindow(ev, kODFalse);
  372.  
  373. #if defined(_PLATFORM_WIN32_)
  374.             SetWindowPos(platwin,
  375.                          HWND_TOP,
  376.                          props.boundsRect.left,
  377.                          props.boundsRect.top,
  378.                          props.boundsRect.right,
  379.                          props.boundsRect.bottom,
  380.                          SWP_NOACTIVATE | SWP_NOREDRAW);
  381.  
  382. #elif defined(_PLATFORM_OS2_)
  383.             WinSetWindowPos(platwin,
  384.                          HWND_TOP,
  385.                          props.boundsRect.xLeft,
  386.                          props.boundsRect.yBottom,
  387.                          props.boundsRect.xRight,
  388.                          props.boundsRect.yTop,
  389.                          SWP_SIZE|SWP_MOVE|SWP_NOREDRAW);
  390.  
  391. #elif defined(_PLATFORM_UNIX_)
  392.             Display *display = winState->GetDisplay(ev);
  393.  
  394.             Widget shellWidget = XtWindowToWidget(display,
  395.                                                   platwin);
  396.  
  397.             XtVaSetValues(shellWidget,
  398.                           XmNx, props.boundsRect.x,
  399.                           XmNy, props.boundsRect.y,
  400.                           XmNwidth, props.boundsRect.width,
  401.                           XmNheight, props.boundsRect.height,
  402.                           NULL);
  403. #endif
  404.             window = winState->RegisterWindowForFrame(ev,
  405.                                                       platwin,
  406.                                                       frame,    //  kODFrameObject
  407.                                                       props.isRootWindow,
  408.                                                       props.isResizable,
  409.                                                       props.isFloating,
  410.                                                       kODTrue,  // shouldSave
  411.                                                       kODTrue,  // shouldDispose
  412.                                                       props.sourceFrame);
  413.  
  414.  
  415.             EndGetWindowProperties(ev, &props);     // release source frame
  416.             window->Open(ev);
  417.             window->Show(ev);
  418.         }
  419.         else
  420.         {
  421.             // This is a request to Open-As-Window when this is an embedded frame
  422.             window=winState->AcquireWindow(ev, _fWindowID);
  423.             if (window)
  424.             {
  425.                 // Window was created previously. Just bring it to the front.
  426.                 window->Select(ev);
  427.             }
  428.             else
  429.             {
  430.                 // First time we get an Open-As-Window request for this embedded part.
  431.                 window = somSelf->MakeWindow(ev,frame);
  432.                 window->Open(ev);
  433.                 window->Show(ev);
  434.                 window->Select(ev);
  435.             }
  436.  
  437.         } // end of frame->IsRoot
  438.     } // end of frame
  439.     else
  440.     {
  441.        // Opening document for the first time. Create initial root window.
  442.         window = somSelf->MakeWindow(ev, frame);
  443.         window->Open(ev);
  444.         window->Show(ev);
  445.         window->Select(ev);
  446.     }
  447.     _fWindowID = window->GetID(ev);
  448.   }
  449.   catch(ODException _exception)
  450.   {
  451.   }
  452.  
  453.   return _fWindowID;
  454. }
  455.  
  456. SOM_Scope ODWindow* SOMLINK   SimplePartMakeWindow(SimplePart *somSelf, Environment *ev, ODFrame *sourceFrame)
  457. {
  458.   SimplePartData *somThis = SimplePartGetData(somSelf);
  459.   SimplePartMethodDebug("SimplePart","SimplePartMakeWindow");
  460.   ODPlatformWindow platwin = kODNULL;
  461.   ODWindow* window         = kODNULL;
  462.  
  463.   try
  464.   {
  465.  
  466.     ODWindowState* winState=_fSession->GetWindowState(ev);
  467.  
  468.     platwin = winState->CreatePlatformWindow(ev, kODFalse);
  469.  
  470.     window = winState->RegisterWindow(ev,
  471.                                       platwin,
  472.                                       kODFrameObject,                          // frameType
  473.                                       sourceFrame==kODNULL,                    // isRootWindow
  474.                                       kODTrue,                                 // isResizable
  475.                                       kODFalse,                                // isFloating
  476.                                       kODTrue,                                 // shouldSave
  477.                                       kODTrue,                                 // shouldDispose
  478.                                       _fPartWrapper,                           // rootPart
  479.                                       _fSession->Tokenize(ev, kODViewAsFrame), // ViewType
  480.                                       _fSession->Tokenize(ev, kODPresDefault), // presentation
  481.                                       sourceFrame                              // sourceFrame
  482.                                       );
  483.   }
  484.   catch(ODException _exception)
  485.   {
  486.   }
  487.  
  488.   return window;
  489. }
  490.  
  491. SOM_Scope ODShape*  SOMLINK SimplePartAdjustBorderShape(SimplePart *somSelf,
  492.                                                          Environment *ev,
  493.                                                         ODFacet* embeddedFacet,
  494.                                                         ODShape* shape)
  495. {
  496.     SimplePartData *somThis = SimplePartGetData(somSelf);
  497.     SimplePartMethodDebug("SimplePart","SimplePartAdjustBorderShape");
  498.  
  499.    try
  500.    {
  501.  
  502.      if ( shape == kODNULL )
  503.        return kODNULL;
  504.      shape->Acquire(ev);
  505.    }
  506.    catch(ODException _exception)
  507.    {
  508.    }
  509.  
  510.     return shape;
  511. }
  512.  
  513. SOM_Scope void  SOMLINK SimplePartDraw(SimplePart *somSelf,  Environment *ev,
  514.                                        ODFacet* facet, ODShape* invalidShape)
  515. {
  516.     SimplePartData *somThis = SimplePartGetData(somSelf);
  517.     SimplePartMethodDebug("SimplePart","SimplePartDraw");
  518.  
  519.    try
  520.    {
  521.  
  522.      ODTypeToken viewType = facet->GetFrame(ev)->GetViewType(ev);
  523.  
  524.      if(viewType == _fSession->Tokenize(ev,kODViewAsSmallIcon))
  525.      {
  526.        somSelf->DrawIcon(ev, facet, invalidShape, SmallIconView);
  527.      }
  528.      else if(viewType == _fSession->Tokenize(ev,kODViewAsLargeIcon))
  529.      {
  530.        somSelf->DrawIcon(ev, facet, invalidShape, LargeIconView);
  531.      }
  532.      else if(viewType == _fSession->Tokenize(ev,kODViewAsThumbnail))
  533.      {
  534.        somSelf->DrawThumbnail(ev, facet, invalidShape);
  535.      }
  536.      else
  537.      {
  538.        somSelf->DrawFrame(ev, facet, invalidShape);
  539.      }
  540.    }
  541.    catch(...)
  542.    {
  543.    }
  544. }
  545.  
  546. SOM_Scope void  SOMLINK SimplePartHighlightChanged(SimplePart *somSelf,
  547.                                                     Environment *ev,
  548.                                                    ODFacet* facet)
  549. {
  550.     SimplePartData *somThis = SimplePartGetData(somSelf);
  551.     SimplePartMethodDebug("SimplePart","SimplePartHighlightChanged");
  552.  
  553.    try
  554.    {
  555.  
  556.      /*
  557.       * cause ourselves to be redrawn.  FocusLib will take care of setting the
  558.       * default mix mode so that we paint properly.
  559.       */
  560.      facet->Invalidate(ev, kODNULL, kODNULL);
  561.    }
  562.    catch(ODException _exception)
  563.    {
  564.    }
  565. }
  566.  
  567.  
  568. SOM_Scope void  SOMLINK SimplePartCommitRelinquishFocus(SimplePart *somSelf,
  569.                                                          Environment *ev,
  570.                                                         ODTypeToken focus,
  571.                                                         ODFrame* ownerFrame,
  572.                                                         ODFrame* proposedFrame)
  573. {
  574.     SimplePartData *somThis = SimplePartGetData(somSelf);
  575.     SimplePartMethodDebug("SimplePart","SimplePartCommitRelinquishFocus");
  576.  
  577.    try
  578.    {
  579.  
  580.      somSelf->FocusLost(ev, focus, ownerFrame);
  581.    }
  582.    catch(ODException _exception)
  583.    {
  584.    }
  585. }
  586.  
  587. SOM_Scope void  SOMLINK SimplePartFocusAcquired(SimplePart *somSelf,
  588.                                                 Environment *ev,
  589.                                                 ODTypeToken focus,
  590.                                                 ODFrame* ownerFrame)
  591. {
  592.     SimplePartData *somThis = SimplePartGetData(somSelf);
  593.     SimplePartMethodDebug("SimplePart","SimplePartFocusAcquired");
  594.  
  595.    try
  596.    {
  597.  
  598.      if (focus == _fSelectionFocus)
  599.      {
  600.        PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
  601.        pInfo->fIsActive = kODTrue;
  602.      } else if (focus == _fMenuFocus) {
  603.           _fMenuBar->Display(ev);
  604.      }
  605.    }
  606.    catch(ODException _exception)
  607.    {
  608.    }
  609.  
  610. }
  611.  
  612. SOM_Scope void  SOMLINK SimplePartFocusLost(SimplePart *somSelf,
  613.                                              Environment *ev,
  614.                                             ODTypeToken focus,
  615.                                             ODFrame* ownerFrame)
  616. {
  617.     SimplePartData *somThis = SimplePartGetData(somSelf);
  618.     SimplePartMethodDebug("SimplePart","SimplePartFocusLost");
  619.  
  620.    try
  621.    {
  622.  
  623.      if (focus == _fSelectionFocus)
  624.      {
  625.        PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
  626.        pInfo->fIsActive = kODFalse;
  627.      }
  628.    }
  629.    catch(ODException _exception)
  630.    {
  631.    }
  632. }
  633.  
  634. SOM_Scope void  SOMLINK SimplePartCloneInto(SimplePart *somSelf, Environment *ev,
  635.                                             ODDraftKey key,
  636.                                             ODStorageUnit* storageUnit,
  637.                                             ODFrame* scopeFrame)
  638. {
  639.     SimplePartData *somThis = SimplePartGetData(somSelf);
  640.     SimplePartMethodDebug("SimplePart","SimplePartCloneInto");
  641.  
  642.   try
  643.   {
  644.     SimplePart_parent_ODPart_CloneInto(somSelf, ev, key, storageUnit, scopeFrame);
  645.     InitPropVal (ev, storageUnit, kODPropContents, kSimplePartKind);
  646.  
  647. #ifdef _PLATFORM_OS2_
  648.  
  649. // Customized icon support for OS2.
  650.  
  651.      ULONG cbIconSize;
  652.      PBYTE pIconData = NULL;
  653.  
  654.      // We need to load the icons if we haven't already
  655.      if(!_hLargeIcon) somSelf->CreateIcons(ev);
  656.  
  657.      if (!DosQueryResourceSize( _hResModule, RT_POINTER, kODIcon, &cbIconSize) &&
  658.          !DosGetResource( _hResModule, RT_POINTER, kODIcon, (PPVOID)&pIconData)  )
  659.      {
  660.         InitPropVal (ev, storageUnit, kODPropIconFamily, kODIconFamily);
  661.         StorageUnitSetValue( storageUnit, ev, cbIconSize, (ODValue)pIconData );
  662.         DosFreeResource(pIconData);
  663.      }
  664.      else
  665.         PRINT("SimplePrt DosGetResource failed!\n");
  666.  
  667. // End customized icon support
  668. #endif // _PLATFORM_OS2_
  669.   }
  670.   catch(ODException _exception)
  671.   {
  672.   }
  673. }
  674.  
  675.  
  676. SOM_Scope void  SOMLINK SimplePartExternalizeKinds(SimplePart *somSelf,
  677.                                                     Environment *ev,
  678.                                                    ODTypeList* kindset)
  679. {
  680.     SimplePartData *somThis = SimplePartGetData(somSelf);
  681.     SimplePartMethodDebug("SimplePart","SimplePartExternalizeKinds");
  682.  
  683.    try
  684.    {
  685.  
  686.      somSelf->Externalize(ev);
  687.    }
  688.    catch(ODException _exception)
  689.    {
  690.    }
  691. }
  692.  
  693. SOM_Scope void  SOMLINK SimplePartExternalize(SimplePart *somSelf,
  694.                                                Environment *ev)
  695. {
  696.     SimplePartData *somThis = SimplePartGetData(somSelf);
  697.     SimplePartMethodDebug("SimplePart","SimplePartExternalize");
  698.  
  699.    try
  700.    {
  701.  
  702.      ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  703.  
  704.      if(su->Exists(ev, kODPropContents, kSimplePartKind, 0))
  705.      {
  706.          su->Focus(ev, kODPropContents, kODPosUndefined, kSimplePartKind,
  707.                    0, kODPosUndefined);
  708.          su->Remove(ev);
  709.          su->AddValue(ev, kSimplePartKind);
  710.      }
  711.      else
  712.      {
  713.          su->AddProperty(ev, kODPropContents)->AddValue(ev, kSimplePartKind);
  714.      }
  715.  
  716.      su->Focus(ev, kODPropContents, kODPosUndefined, kSimplePartKind, 0, kODPosUndefined);
  717.      ODSetRectProp(ev, su, kODNULL, kODNULL, &_lastFrameRect);
  718.    }
  719.    catch(ODException _exception)
  720.    {
  721.    }
  722. }
  723.  
  724. SOM_Scope void  SOMLINK SimplePartChangeKind(SimplePart *somSelf,
  725.                                               Environment *ev,
  726.                                              ODType kind)
  727. {
  728.     SimplePartData *somThis = SimplePartGetData(somSelf);
  729.     SimplePartMethodDebug("SimplePart","SimplePartChangeKind");
  730.     ODStorageUnit * su = somSelf->GetStorageUnit(ev);
  731.     su->Focus(ev, kODPropContents, kODPosUndefined, kODTypeAll, 0, kODPosUndefined);
  732.     su->Remove(ev);
  733.     su->AddProperty(ev, kODPropContents)->AddValue(ev, kSimplePartKind);
  734.  
  735. }
  736.  
  737. SOM_Scope ODBoolean  SOMLINK SimplePartHandleEvent(SimplePart *somSelf,
  738.                                                     Environment *ev,
  739.                                                     ODEventData* event,
  740.                                                     ODFrame* frame,
  741.                                                     ODFacet* facet,
  742.                                                     ODEventInfo* eventInfo)
  743. {
  744.     SimplePartData *somThis = SimplePartGetData(somSelf);
  745.     SimplePartMethodDebug("SimplePart","SimplePartHandleEvent");
  746.  
  747.     ODBoolean handled = kODFalse;
  748.  
  749.    try
  750.    {
  751.       ODEventType theEventType;
  752.  
  753. #ifdef _PLATFORM_OS2_
  754.       theEventType = event->msg;
  755. #elif defined(_PLATFORM_WIN32_)
  756.       theEventType = event->message;
  757. #elif defined(_PLATFORM_UNIX_)
  758.       theEventType = event->type;
  759. #endif
  760.  
  761.     switch (theEventType)
  762.     {
  763. #ifdef _PLATFORM_WIN32_
  764.       case WM_LBUTTONDBLCLK:
  765.       case WM_MBUTTONDBLCLK:
  766.       case WM_RBUTTONDBLCLK:
  767. #elif defined(_PLATFORM_OS2_)
  768.       case WM_BUTTON1DBLCLK:
  769.       case WM_BUTTON2DBLCLK:
  770. #endif
  771. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_)  // Not supported on AIX
  772.           {
  773.            if(!frame->IsRoot(ev))
  774.            {
  775.               somSelf->Open(ev, frame);
  776.               handled = kODTrue;
  777.            }
  778.           }
  779.           break;
  780. #endif
  781.  
  782.       case kODEvtMouseDown:
  783.           {
  784.  
  785.              somSelf->Activate(ev, facet);
  786.              handled = kODTrue;
  787. #ifdef _PLATFORM_UNIX_
  788.              // Display the Popup menu when the third mouse button is pressed.
  789.              XButtonEvent *xbutton = (XButtonEvent *)event;
  790.              if(xbutton->button == Button3)
  791.              {
  792.                 handled = somSelf->DisplayPopupMenu(ev, event, frame, facet, eventInfo);
  793.              }
  794. #endif
  795.           }
  796.           break;
  797.  
  798. #ifdef _PLATFORM_WIN32_
  799.       case WM_RBUTTONDOWN:
  800. #elif defined(_PLATFORM_OS2_)
  801.       case WM_CONTEXTMENU:
  802. #endif
  803. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_)
  804.           // Display the Popup menu when this event arrives.
  805.           handled = somSelf->DisplayPopupMenu(ev, event, frame, facet, eventInfo);
  806.           break;
  807. #endif
  808.  
  809.        case kODEvtActivate:
  810.           {
  811.             handled = kODTrue; // actually ignored by dispatcher
  812. #ifdef _PLATFORM_WIN32_
  813.             if ((LOWORD(event->wParam) == WA_ACTIVE) ||
  814.                 (LOWORD(event->wParam) == WA_CLICKACTIVE))
  815. #elif defined(_PLATFORM_OS2_)
  816.             if (SHORT1FROMMP(event->mp1) != 0)
  817. #elif defined(_PLATFORM_UNIX_)
  818.             if (eventInfo->originalType == FocusIn)
  819. #endif
  820.                somSelf->ActivatingWindow(ev, frame);
  821.             else
  822.                somSelf->DeActivatingWindow(ev, frame);
  823.           }
  824.           break;
  825.  
  826.        case kODEvtMenu:
  827. #ifdef _PLATFORM_WIN32_
  828.           if ((HIWORD(event->wParam) == 1) ||        // From MENU
  829.               (HIWORD(event->wParam) == 0))          // From ACCELERATOR  (other values are from control
  830. #elif defined(_PLATFORM_OS2_)
  831.           if (SHORT1FROMMP(event->mp2) & CMDSRC_MENU ||
  832.               SHORT1FROMMP(event->mp2) & CMDSRC_ACCELERATOR)
  833. #endif //_PLATFORM_OS2_
  834.           {
  835.              handled = somSelf->HandleMenuEvent(ev, frame, event);
  836.           }
  837.           break;
  838.  
  839.        default:
  840.           return kODFalse;
  841.     }
  842.    }
  843.    catch(ODException _exception)
  844.    {
  845.    }
  846.  
  847.     return handled;
  848. }
  849.  
  850. SOM_Scope void  SOMLINK SimplePartAdjustMenus(SimplePart *somSelf,
  851.                                                Environment *ev,
  852.                                               ODFrame* frame)
  853. {
  854.     SimplePartData *somThis = SimplePartGetData(somSelf);
  855.     SimplePartMethodDebug("SimplePart","SimplePartAdjustMenus");
  856.  
  857.    try
  858.    {
  859.      if (frame->IsRoot(ev))
  860.      {
  861.         // Disable menu items which are unsupported only when root
  862.         _fMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_SETUP, kODFalse);
  863.         _fMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_PRINT, kODFalse);
  864.      }else{
  865.         // Enable menu items which are supported only when embedded
  866.         _fMenuBar->EnableMenuItem(ev, IDMS_VIEW, VIEW_VIEWINWINDOW, kODTrue);
  867.         _fMenuBar->EnableMenuItem(ev, IDMS_VIEW, VIEW_SHOWAS, kODTrue);
  868.      }
  869.  
  870.      // Enable supported menu items
  871.      _fMenuBar->EnableMenuItem(ev, IDMS_VIEW, VIEW_PROPERTIES, kODTrue);
  872.  
  873.  
  874.      // Disable unsupported menu items
  875.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CREATE, kODFalse);
  876.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CUT, kODFalse);
  877.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_COPY, kODFalse);
  878.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTE, kODFalse);
  879.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTEAS, kODFalse);
  880.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_LINK_MENU, kODFalse);
  881.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DELETE, kODFalse);
  882.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELECTALL, kODFalse);
  883.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DESELECTALL, kODFalse);
  884.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_OPENSEL, kODFalse);
  885.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELPROPERTIES, kODFalse);
  886.      _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_INSERT, kODFalse);
  887.    }
  888.    catch(ODException _exception)
  889.    {
  890.    }
  891.  
  892. }
  893.  
  894.  
  895. SOM_Scope ODActionData  SOMLINK SimplePartReadActionState(SimplePart *somSelf,
  896.                                                           Environment *ev,
  897.                                                           ODStorageUnitView* storageUnitView)
  898. {
  899.     SimplePartData *somThis = SimplePartGetData(somSelf);
  900.     SimplePartMethodDebug("SimplePart","SimplePartReadActionState");
  901.     ODActionData data;
  902.     data._maximum = 0;
  903.     data._length = 0;
  904.     data._buffer = kODNULL;
  905.     return data;
  906. }
  907.  
  908. SOM_Scope void  SOMLINK SimplePartInitPart(SimplePart *somSelf,
  909.                                             Environment *ev,
  910.     ODStorageUnit* storageUnit, ODPart* partWrapper)
  911. {
  912.     SimplePartData *somThis = SimplePartGetData(somSelf);
  913.     SimplePartMethodDebug("SimplePart","SimplePartInitPart");
  914.  
  915.    try
  916.    {
  917.  
  918.      if (_fIsInitialized)
  919.        return;
  920.  
  921.      _fIsInitialized = kODTrue;
  922.  
  923.      parent_InitPart(somSelf, ev, storageUnit, partWrapper);
  924.  
  925.      somSelf->CommonInit(ev, partWrapper);
  926.  
  927.    }
  928.    catch(ODException _exception)
  929.    {
  930.    }
  931.  
  932. }
  933.  
  934. SOM_Scope void  SOMLINK SimplePartInitPartFromStorage(SimplePart *somSelf,
  935.                                                        Environment *ev,
  936.                                                        ODStorageUnit* storageUnit, ODPart* partWrapper)
  937. {
  938.     SimplePartData *somThis = SimplePartGetData(somSelf);
  939.     SimplePartMethodDebug("SimplePart","SimplePartInitPartFromStorage");
  940.  
  941.    try
  942.    {
  943.  
  944.      if (_fIsInitialized)
  945.        return;
  946.  
  947.      _fIsInitialized = kODTrue;
  948.  
  949.      parent_InitPartFromStorage(somSelf, ev, storageUnit, partWrapper);
  950.  
  951.      somSelf->CommonInit(ev, partWrapper);
  952.  
  953.      // Read in the value of the last frame's bounding rectangle.
  954.      if (ODSUExistsThenFocus (ev, storageUnit, kODPropContents, kSimplePartKind)) {
  955.        ODGetRectProp(ev, storageUnit, kODNULL, kODNULL, &_lastFrameRect);
  956.      } else {
  957.        _lastFrameRect.left = 0;
  958.        _lastFrameRect.right = IntToFixed(200);
  959.        #ifdef _PLATFORM_OS2_
  960.        _lastFrameRect.top = IntToFixed(200);
  961.        _lastFrameRect.bottom = 0;
  962.        #else
  963.        _lastFrameRect.top = 0;
  964.        _lastFrameRect.bottom = IntToFixed(200);
  965.        #endif
  966.      }
  967.    }
  968.    catch(ODException _exception)
  969.    {
  970.    }
  971.  
  972. }
  973.  
  974. SOM_Scope void  SOMLINK SimplePartRelease(SimplePart *somSelf,
  975.                                            Environment *ev)
  976. {
  977.     SimplePartData *somThis = SimplePartGetData(somSelf);
  978.     SimplePartMethodDebug("SimplePart","SimplePartRelease");
  979.  
  980.    try
  981.    {
  982.  
  983.      SimplePart_parent_ODPart_Release(somSelf, ev);
  984.      if (somSelf->GetRefCount(ev) == 0)
  985.         somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart(ev, somSelf);
  986.    }
  987.    catch(ODException _exception)
  988.    {
  989.    }
  990.  
  991. }
  992.  
  993. SOM_Scope void  SOMLINK SimplePartViewTypeChanged(SimplePart *somSelf,
  994.                                                   Environment *ev,
  995.                                                   ODFrame* frame)
  996. {
  997.     SimplePartData *somThis = SimplePartGetData(somSelf);
  998.     SimplePartMethodDebug("SimplePart","SimplePartViewTypeChanged");
  999.  
  1000.     try
  1001.     {
  1002.  
  1003.       if(frame->IsRoot(ev))
  1004.       {
  1005.          // When this is a root part, only support frame view.
  1006.          frame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsFrame));
  1007.          return;
  1008.       }
  1009.       else
  1010.       {
  1011.         // Set frame shape according to view type
  1012.         somSelf->AdjustViewTypeShapes(ev, frame);
  1013.  
  1014.         // Get the new frame shape to be invalidated.
  1015.         TempODShape newShape = frame->AcquireFrameShape(ev,kODNULL);
  1016.  
  1017.         // Force the display of our new view type
  1018.         frame->Invalidate(ev, newShape, kODNULL);
  1019.       }
  1020.     }
  1021.     catch(ODException _exception)
  1022.     {
  1023.     }
  1024. }
  1025.  
  1026. SOM_Scope void  SOMLINK SimplePartFrameShapeChanged(SimplePart *somSelf,
  1027.                                                      Environment *ev,
  1028.                                                     ODFrame* frame)
  1029. {
  1030.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1031.     SimplePartMethodDebug("SimplePart","SimplePartFrameShapeChanged");
  1032.  
  1033.     // Set frame shape according to view type
  1034.     somSelf->AdjustViewTypeShapes(ev, frame);
  1035.  
  1036. }
  1037.  
  1038. SOM_Scope void  SOMLINK SimplePartFacetAdded(SimplePart *somSelf,
  1039.                                               Environment *ev,
  1040.                                              ODFacet* facet)
  1041. {
  1042.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1043.     SimplePartMethodDebug("SimplePart","SimplePartFacetAdded");
  1044.  
  1045.     try
  1046.     {
  1047.       // Set frame shape according to view type
  1048.       somSelf->AdjustViewTypeShapes(ev, facet->GetFrame(ev));
  1049.  
  1050.     }
  1051.     catch(ODException _exception)
  1052.     {
  1053.     }
  1054.  
  1055. }
  1056.  
  1057. /******************************************************************
  1058. The following messages are defined in ODPart and not changed in SimplePart.
  1059.  ******************************************************************/
  1060.  
  1061. SOM_Scope void  SOMLINK SimplePartFulfillPromise(SimplePart *somSelf,
  1062.                                                   Environment *ev,
  1063.                                                  ODStorageUnitView* promiseSUView)
  1064. {
  1065.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1066.     SimplePartMethodDebug("SimplePart","SimplePartFulfillPromise");
  1067.  
  1068. }
  1069.  
  1070. SOM_Scope void  SOMLINK SimplePartDropCompleted(SimplePart *somSelf,
  1071.                                                  Environment *ev,
  1072.                                                 ODPart* destPart,
  1073.                                                 ODDropResult dropResult)
  1074. {
  1075.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1076.     SimplePartMethodDebug("SimplePart","SimplePartDropCompleted");
  1077.  
  1078. }
  1079.  
  1080. SOM_Scope ODDropResult  SOMLINK SimplePartDrop(SimplePart *somSelf,
  1081.                                                 Environment *ev,
  1082.                                                ODDragItemIterator* dropInfo,
  1083.                                                ODFacet* facet,
  1084.                                                ODPoint* where)
  1085. {
  1086.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1087.     SimplePartMethodDebug("SimplePart","SimplePartDrop");
  1088.  
  1089.     return kODDropFail;
  1090.  
  1091.  
  1092. }
  1093.  
  1094. SOM_Scope void  SOMLINK SimplePartContainingPartPropertiesUpdated(SimplePart *somSelf,
  1095.                                                                    Environment *ev,
  1096.                                                                   ODFrame* frame,
  1097.                                                                   ODStorageUnit* propertyUnit)
  1098. {
  1099.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1100.     SimplePartMethodDebug("SimplePart","SimplePartContainingPartPropertiesUpdated");
  1101.  
  1102.  
  1103. }
  1104.  
  1105. SOM_Scope ODStorageUnit*  SOMLINK SimplePartAcquireContainingPartProperties(SimplePart *somSelf,
  1106.                                                                          Environment *ev,
  1107.                                                                         ODFrame* frame)
  1108. {
  1109.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1110.     SimplePartMethodDebug("SimplePart","SimplePartAcquireContainingPartProperties");
  1111.  
  1112.     return kODNULL;
  1113.  
  1114. }
  1115.  
  1116. SOM_Scope ODBoolean  SOMLINK SimplePartRevealFrame(SimplePart *somSelf,
  1117.                                                Environment *ev,
  1118.                                               ODFrame* embeddedFrame,
  1119.                                               ODShape* revealShape)
  1120. {
  1121.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1122.     SimplePartMethodDebug("SimplePart","SimplePartRevealFrame");
  1123.     return kODFalse;
  1124. }
  1125.  
  1126. SOM_Scope void  SOMLINK SimplePartEmbeddedFrameSpec(SimplePart *somSelf,
  1127.                                                      Environment *ev,
  1128.                                                     ODFrame* embeddedFrame,
  1129.                                                     ODObjectSpec* spec)
  1130. {
  1131.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1132.     SimplePartMethodDebug("SimplePart","SimplePartEmbeddedFrameSpec");
  1133.  
  1134. }
  1135.  
  1136. SOM_Scope ODEmbeddedFramesIterator*  SOMLINK SimplePartCreateEmbeddedFramesIterator(SimplePart *somSelf,
  1137.                                                                                      Environment *ev,
  1138.                                                                                     ODFrame* frame)
  1139. {
  1140.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1141.     SimplePartMethodDebug("SimplePart","SimplePartCreateEmbeddedFramesIterator");
  1142.     return (ODEmbeddedFramesIterator *) kODNULL;
  1143. }
  1144.  
  1145. SOM_Scope void  SOMLINK SimplePartAttachSourceFrame(SimplePart *somSelf,
  1146.                                                      Environment *ev,
  1147.                                                     ODFrame* frame,
  1148.                                                     ODFrame* sourceFrame)
  1149. {
  1150.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1151.     SimplePartMethodDebug("SimplePart","SimplePartAttachSourceFrame");
  1152.  
  1153. }
  1154.  
  1155. SOM_Scope void  SOMLINK SimplePartPresentationChanged(SimplePart *somSelf,
  1156.                                                        Environment *ev,
  1157.                                                       ODFrame* frame)
  1158. {
  1159.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1160.     SimplePartMethodDebug("SimplePart","SimplePartPresentationChanged");
  1161. }
  1162.  
  1163. SOM_Scope void  SOMLINK SimplePartSequenceChanged(SimplePart *somSelf,
  1164.                                                    Environment *ev,
  1165.                                                   ODFrame* frame)
  1166. {
  1167.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1168.     SimplePartMethodDebug("SimplePart","SimplePartSequenceChanged");
  1169. }
  1170.  
  1171. SOM_Scope void  SOMLINK SimplePartWritePartInfo(SimplePart *somSelf,
  1172.                                                  Environment *ev,
  1173.                                                 ODInfoType partInfo,
  1174.                                                 ODStorageUnitView* storageUnitView)
  1175. {
  1176.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1177.     SimplePartMethodDebug("SimplePart","SimplePartWritePartInfo");
  1178.  
  1179. }
  1180. SOM_Scope ODInfoType  SOMLINK SimplePartReadPartInfo(SimplePart *somSelf, Environment *ev,
  1181.     ODFrame* frame,
  1182.     ODStorageUnitView* storageUnitView)
  1183. {
  1184.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1185.     SimplePartMethodDebug("SimplePart","SimplePartReadPartInfo");
  1186.  
  1187.     return ((ODInfoType)kODNULL);
  1188.  
  1189. }
  1190.  
  1191. SOM_Scope void  SOMLINK SimplePartClonePartInfo(SimplePart *somSelf, Environment *ev,
  1192.     ODDraftKey key,
  1193.     ODInfoType partInfo,
  1194.     ODStorageUnitView* storageUnitView,
  1195.     ODFrame* scopeFrame)
  1196. {
  1197.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1198.     SimplePartMethodDebug("SimplePart","SimplePartClonePartInfo");
  1199.  
  1200. }
  1201. SOM_Scope ODFrame*  SOMLINK SimplePartRequestEmbeddedFrame(SimplePart *somSelf,
  1202.                                                             Environment *ev,
  1203.                                                            ODFrame* containingFrame,
  1204.                                                            ODFrame* baseFrame,
  1205.                                                            ODShape* frameShape,
  1206.                                                            ODPart* embedPart,
  1207.                                                            ODTypeToken viewType,
  1208.                                                            ODTypeToken presentation,
  1209.                                                            ODBoolean isOverlaid)
  1210. {
  1211.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1212.     SimplePartMethodDebug("SimplePart","SimplePartRequestEmbeddedFrame");
  1213.     return baseFrame;
  1214. }
  1215.  
  1216. SOM_Scope void  SOMLINK SimplePartRemoveEmbeddedFrame(SimplePart *somSelf,
  1217.                                                        Environment *ev,
  1218.                                                       ODFrame* embeddedFrame)
  1219. {
  1220.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1221.     SimplePartMethodDebug("SimplePart","SimplePartRemoveEmbeddedFrame");
  1222.  
  1223. }
  1224.  
  1225. SOM_Scope ODShape*  SOMLINK SimplePartRequestFrameShape(SimplePart *somSelf,
  1226.                                                          Environment *ev,
  1227.                                                         ODFrame* embeddedFrame,
  1228.                                                         ODShape* frameShape)
  1229. {
  1230.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1231.     SimplePartMethodDebug("SimplePart","SimplePartRequestFrameShape");
  1232.  
  1233.     return frameShape;
  1234. }
  1235. SOM_Scope void  SOMLINK SimplePartUsedShapeChanged(SimplePart *somSelf,
  1236.                                                     Environment *ev,
  1237.                                                    ODFrame* embeddedFrame)
  1238. {
  1239.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1240.     SimplePartMethodDebug("SimplePart","SimplePartUsedShapeChanged");
  1241.  
  1242. }
  1243.  
  1244. SOM_Scope void  SOMLINK SimplePartFacetRemoved(SimplePart *somSelf,
  1245.                                                 Environment *ev,
  1246.                                                ODFacet* facet)
  1247. {
  1248.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1249.     SimplePartMethodDebug("SimplePart","SimplePartFacetRemoved");
  1250.  
  1251. }
  1252.  
  1253. SOM_Scope void  SOMLINK SimplePartCanvasChanged(SimplePart *somSelf,
  1254.                                                  Environment *ev,
  1255.                                                 ODFacet* facet)
  1256. {
  1257.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1258.     SimplePartMethodDebug("SimplePart","SimplePartCanvasChanged");
  1259.  
  1260. }
  1261.  
  1262. SOM_Scope void  SOMLINK SimplePartGeometryChanged(SimplePart *somSelf,
  1263.                                                    Environment *ev,
  1264.     ODFacet* facet, ODBoolean clipShapeChanged, ODBoolean externalTransformChanged)
  1265. {
  1266.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1267.     SimplePartMethodDebug("SimplePart","SimplePartGeometryChanged");
  1268.  
  1269. }
  1270.  
  1271. SOM_Scope void  SOMLINK SimplePartCanvasUpdated(SimplePart *somSelf,
  1272.                                                  Environment *ev,
  1273.                                                 ODCanvas* canvas)
  1274. {
  1275.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1276.     SimplePartMethodDebug("SimplePart","SimplePartCanvasUpdated");
  1277.  
  1278. }
  1279.  
  1280. SOM_Scope ODLinkSource*  SOMLINK SimplePartCreateLink(SimplePart *somSelf,
  1281.                                                  Environment *ev,
  1282.                                                 ODByteArray* data)
  1283. {
  1284.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1285.     SimplePartMethodDebug("SimplePart","SimplePartCreateLink");
  1286.  
  1287.     return 0;
  1288.  
  1289. }
  1290.  
  1291. SOM_Scope void  SOMLINK SimplePartLinkUpdated(SimplePart *somSelf,
  1292.                                                Environment *ev,
  1293.                                               ODLink* updatedLink,
  1294.                                               ODUpdateID id)
  1295. {
  1296.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1297.     SimplePartMethodDebug("SimplePart","SimplePartLinkUpdated");
  1298.  
  1299. }
  1300.  
  1301. SOM_Scope void  SOMLINK SimplePartRevealLink(SimplePart *somSelf,
  1302.                                               Environment *ev,
  1303.                                              ODLinkSource* linkSource)
  1304. {
  1305.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1306.     SimplePartMethodDebug("SimplePart","SimplePartRevealLink");
  1307.  
  1308. }
  1309.  
  1310. SOM_Scope void  SOMLINK SimplePartEmbeddedFrameUpdated(SimplePart *somSelf,
  1311.                                                         Environment *ev,
  1312.                                                        ODFrame* frame,
  1313.                                                        ODUpdateID change)
  1314. {
  1315.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1316.     SimplePartMethodDebug("SimplePart","SimplePartEmbeddedFrameUpdated");
  1317.  
  1318. }
  1319.  
  1320. SOM_Scope void  SOMLINK SimplePartLinkStatusChanged(SimplePart *somSelf,
  1321.                                                      Environment *ev,
  1322.                                                     ODFrame* frame)
  1323. {
  1324.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1325.     SimplePartMethodDebug("SimplePart","SimplePartLinkStatusChanged");
  1326.  
  1327. }
  1328.  
  1329. SOM_Scope ODBoolean  SOMLINK SimplePartBeginRelinquishFocus(SimplePart *somSelf,
  1330.                                                              Environment *ev,
  1331.                                                             ODTypeToken focus,
  1332.                                                             ODFrame* ownerFrame,
  1333.                                                             ODFrame* proposedFrame)
  1334. {
  1335.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1336.     SimplePartMethodDebug("SimplePart","SimplePartBeginRelinquishFocus");
  1337.  
  1338.  
  1339.     ODBoolean rc=kODTrue;
  1340.  
  1341.     try {
  1342.  
  1343.         ODTypeToken modalFocus  = _fSession->Tokenize(ev, kODModalFocus);
  1344.         if ( focus == modalFocus ) {
  1345.             ODPart *proposedFramePart = proposedFrame->AcquirePart(ev);
  1346.  
  1347.             // if proposedFramePart is not this part then
  1348.             //   Another part is trying to put up a Modal dialog
  1349.             //   while we are currently displaying ours.
  1350.             //
  1351.             //   Deny the request.
  1352.  
  1353.             rc= (proposedFramePart==somSelf) ? kODTrue : kODFalse;
  1354.  
  1355.             proposedFramePart->Release(ev);
  1356.         }
  1357.  
  1358.     }  // end try block
  1359.     catch (...) {}
  1360.  
  1361.     return rc;
  1362.  
  1363. }
  1364.  
  1365. SOM_Scope void  SOMLINK SimplePartAbortRelinquishFocus(SimplePart *somSelf,
  1366.                                                         Environment *ev,
  1367.                                                        ODTypeToken focus,
  1368.                                                        ODFrame* ownerFrame,
  1369.                                                        ODFrame* proposedFrame)
  1370. {
  1371.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1372.     SimplePartMethodDebug("SimplePart","SimplePartAbortRelinquishFocus");
  1373.  
  1374. }
  1375.  
  1376. SOM_Scope void  SOMLINK SimplePartUndoAction(SimplePart *somSelf,
  1377.                                               Environment *ev,
  1378.                                              ODActionData* actionState)
  1379. {
  1380.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1381.     SimplePartMethodDebug("SimplePart","SimplePartUndoAction");
  1382.  
  1383. }
  1384.  
  1385. SOM_Scope void  SOMLINK SimplePartRedoAction(SimplePart *somSelf,
  1386.                                               Environment *ev,
  1387.                                              ODActionData* actionState)
  1388. {
  1389.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1390.     SimplePartMethodDebug("SimplePart","SimplePartRedoAction");
  1391.  
  1392.     // not much to redo yet
  1393. }
  1394.  
  1395. SOM_Scope void  SOMLINK SimplePartDisposeActionState(SimplePart *somSelf,
  1396.                                                       Environment *ev,
  1397.                                                      ODActionData* actionState,
  1398.                                                      ODDoneState doneState)
  1399. {
  1400.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1401.     SimplePartMethodDebug("SimplePart","SimplePartDisposeActionState");
  1402.  
  1403. }
  1404.  
  1405. SOM_Scope void  SOMLINK SimplePartWriteActionState(SimplePart *somSelf,
  1406.                                                     Environment *ev,
  1407.                                                    ODActionData* actionState,
  1408.                                                    ODStorageUnitView* storageUnitView)
  1409. {
  1410.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1411.     SimplePartMethodDebug("SimplePart","SimplePartWriteActionState");
  1412.  
  1413. }
  1414.  
  1415. SOM_Scope ODBoolean  SOMLINK SimplePartHasExtension(SimplePart *somSelf,
  1416.                                                      Environment *ev,
  1417.                                                     ODType extensionName)
  1418. {
  1419.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1420.     SimplePartMethodDebug("SimplePart","SimplePartHasExtension");
  1421.  
  1422.    try
  1423.    {
  1424.  
  1425.      return (SimplePart_parent_ODPart_HasExtension(somSelf, ev,
  1426.                                                    extensionName));
  1427.    }
  1428.    catch(ODException _exception)
  1429.    {
  1430.    }
  1431.  
  1432.     return kODFalse;
  1433. }
  1434.  
  1435. SOM_Scope ODExtension*  SOMLINK SimplePartAcquireExtension(SimplePart *somSelf,
  1436.                                                         Environment *ev,
  1437.                                                        ODType extensionName)
  1438. {
  1439.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1440.     SimplePartMethodDebug("SimplePart","SimplePartAcquireExtension");
  1441.  
  1442.     try
  1443.     {
  1444.  
  1445.        return (SimplePart_parent_ODPart_AcquireExtension(somSelf, ev,
  1446.                                                   extensionName));
  1447.     }
  1448.     catch(ODException _exception)
  1449.     {
  1450.     }
  1451.  
  1452.     return kODNULL;
  1453. }
  1454.  
  1455. SOM_Scope void  SOMLINK SimplePartReleaseExtension(SimplePart *somSelf,
  1456.                                                     Environment *ev,
  1457.                                                    ODExtension* extension)
  1458. {
  1459.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1460.     SimplePartMethodDebug("SimplePart","SimplePartReleaseExtension");
  1461.  
  1462.     try
  1463.     {
  1464.  
  1465.        SimplePart_parent_ODPart_ReleaseExtension(somSelf, ev, extension);
  1466.     }
  1467.     catch(ODException _exception)
  1468.     {
  1469.     }
  1470. }
  1471.  
  1472. /******************************************************************
  1473. The following messages belong to DLL and Metaclass.
  1474.  ******************************************************************/
  1475.  
  1476. SOMEXTERN void SOMLINK SOMInitModule (long majorVersion, long minorVersion,
  1477.                                  string className)
  1478. {
  1479.    SOM_IgnoreWarning (majorVersion);  /* This function makes   */
  1480.    SOM_IgnoreWarning (minorVersion);  /* no use of the passed  */
  1481.    SOM_IgnoreWarning (className);     /* arguments.            */
  1482.  
  1483.    SimplePartNewClass ( SimplePart_MajorVersion, SimplePart_MinorVersion);
  1484. }
  1485. #ifdef _PLATFORM_WIN32_
  1486. int CALLBACK LibMain(HINSTANCE inst, WORD ds, WORD Heapsize, LPSTR cmdLine)
  1487. {
  1488.   SOM_ClassLibrary("iodsimpl.dll");
  1489.   return 1;
  1490. }
  1491. #endif
  1492.  
  1493. SOM_Scope ISOString  SOMLINK M_SimplePartclsGetODPartHandlerName(M_SimplePart *somSelf,
  1494.                                                                   Environment *ev)
  1495. {
  1496.     /* M_SimplePartData *somThis = M_SimplePartGetData(somSelf); */
  1497.     M_SimplePartMethodDebug("M_SimplePart","M_SimplePartclsGetODPartHandlerName");
  1498.  
  1499.     string handlerName =  (string) SOMMalloc(strlen(kPartHandlerName) + 1);
  1500.     strcpy(handlerName, kPartHandlerName);
  1501.  
  1502.     return (ISOString) handlerName;
  1503. }
  1504.  
  1505.  
  1506. SOM_Scope string  SOMLINK M_SimplePartclsGetODPartHandlerDisplayName(M_SimplePart *somSelf,
  1507.                                                                       Environment *ev)
  1508. {
  1509.     /* M_SimplePartData *somThis = M_SimplePartGetData(somSelf); */
  1510.     M_SimplePartMethodDebug("M_SimplePart","M_SimplePartclsGetODPartHandlerDisplayName");
  1511.  
  1512.     string tempName = "Simple Part";
  1513.     string displayName =  (string) SOMMalloc(strlen(tempName) + 1);
  1514.     strcpy(displayName, tempName);
  1515.     return displayName;
  1516.  
  1517. }
  1518.  
  1519. SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_SimplePartclsGetODPartKinds(M_SimplePart *somSelf,
  1520.                                                                              Environment *ev)
  1521. {
  1522.     /* M_SimplePartData *somThis = M_SimplePartGetData(somSelf); */
  1523.     M_SimplePartMethodDebug("M_SimplePart","M_SimplePartclsGetODPartKinds");
  1524.  
  1525.     _IDL_SEQUENCE_PartKindInfo SimplePartInfo;
  1526.     // Create structure PartKindInfo  and allocate memory for variable
  1527.     PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
  1528.     info->partKindName = (ISOString) SOMMalloc(strlen(kSimplePartKind) + 1);
  1529.     info->partKindDisplayName = (string)SOMMalloc(strlen(kSimplePartKindDisplayName)+1);
  1530.     info->filenameFilters =  (string)SOMMalloc(strlen("")+1);
  1531.     info->filenameTypes =  (string)SOMMalloc(strlen("")+1);
  1532.     info->categories =  (string)SOMMalloc(strlen(kSimplePartCategory) + 1);
  1533.     info->categoryDisplayName =  (string)SOMMalloc(strlen("Sample") + 1);
  1534.     info->objectID =  (string)SOMMalloc(strlen("") + 1);
  1535.     // Copy the information into the structure
  1536.     strcpy(info->partKindName , kSimplePartKind);
  1537.     strcpy(info->partKindDisplayName, kSimplePartKindDisplayName);
  1538.     strcpy(info->filenameFilters, "");
  1539.     strcpy(info->filenameTypes, "");
  1540.     strcpy(info->categories, kSimplePartCategory);
  1541.     strcpy(info->categoryDisplayName, "Sample");
  1542.     strcpy(info->objectID, "");
  1543.  
  1544.  
  1545.     SimplePartInfo._maximum = 1;
  1546.     SimplePartInfo._length = 1;
  1547.     SimplePartInfo._buffer = info;
  1548.  
  1549.     return SimplePartInfo;
  1550.  
  1551.  
  1552.  
  1553. }
  1554.  
  1555. SOM_Scope string  SOMLINK M_SimplePartclsGetOLE2ClassId(M_SimplePart *somSelf,
  1556.                                                          Environment *ev)
  1557. {
  1558.     /* M_SimplePartData *somThis = M_SimplePartGetData(somSelf); */
  1559.     M_SimplePartMethodDebug("M_SimplePart","M_SimplePartclsGetOLE2ClassId");
  1560.  
  1561.     string tempClassID = "{8ffbed80-caaa-11cf-9935-08005a88688b}";
  1562.     string classID = (string) SOMMalloc(strlen(tempClassID) + 1);
  1563.     strcpy(classID, tempClassID);
  1564.     return classID;
  1565. }
  1566.  
  1567. SOM_Scope string  SOMLINK M_SimplePartclsGetWindowsIconFileName(M_SimplePart *somSelf,
  1568.                                                                  Environment *ev)
  1569. {
  1570.     /* M_SimplePartData *somThis = M_SimplePartGetData(somSelf); */
  1571.     M_SimplePartMethodDebug("M_SimplePart","M_SimplePartclsGetWindowsIconFileName");
  1572.  
  1573.     string kWindowsIcon = "iodsimpl.ico";
  1574.     string WindowsIconFileName = (string)SOMMalloc(strlen(kWindowsIcon)+1);
  1575.     strcpy(WindowsIconFileName,kWindowsIcon);
  1576.  
  1577.     return WindowsIconFileName;
  1578. }
  1579.  
  1580.  
  1581. /******************************************************************
  1582. The following messages are defined in Simple Part itself and are not
  1583. inherited from ODPart.
  1584. ******************************************************************/
  1585.  
  1586. SOM_Scope void  SOMLINK SimplePartCommonInit(SimplePart *somSelf,
  1587.                                              Environment *ev,
  1588.                                              ODPart *partWrapper)
  1589. {
  1590.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1591.     SimplePartMethodDebug("SimplePart","SimplePartCommonInit");
  1592.  
  1593.    try
  1594.    {
  1595.  
  1596.      ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  1597.      _fPartWrapper = partWrapper;
  1598.      _fDisplayFrames = new IODLinkedList;
  1599.      _fSession = su->GetSession(ev);
  1600.      _fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
  1601.      _fMenuFocus = _fSession->Tokenize(ev, kODMenuFocus);
  1602.      _fKeyFocus = _fSession->Tokenize(ev, kODKeyFocus);
  1603.      _fFocusSet = _fSession->GetArbitrator(ev)->CreateFocusSet(ev);
  1604.      _fFocusSet->Add(ev, _fSelectionFocus);
  1605.      _fFocusSet->Add(ev, _fMenuFocus);
  1606.      _fFocusSet->Add(ev, _fKeyFocus);
  1607.      _fInFrameNegotiation = kODFalse;
  1608.      _fPrevViewType = FrameView;
  1609.  
  1610.  
  1611.      _fMenuBar = _fSession->GetWindowState(ev)->CopyBaseMenuBar(ev);
  1612.      // It is required that parts instantiate their menu bars from
  1613.      // the base OpenDoc menu bar. This maintains consistency in the
  1614.      // default menu items and their placement.
  1615.      // Since the object is a copy, we can add and subtract menus and
  1616.      // items without affecting other running parts.
  1617.      if ( _fMenuBar ){
  1618.         _fPopup = _fSession->GetWindowState(ev)->CopyBasePopup(ev);
  1619.         somSelf->InstallMenus(ev);
  1620.      }
  1621.  
  1622.    }
  1623.    catch(ODException _exception)
  1624.    {
  1625.    }
  1626. }
  1627.  
  1628. SOM_Scope void  SOMLINK SimplePartActivateFrame(SimplePart *somSelf,
  1629.                                                  Environment *ev,
  1630.                                                 ODFrame* frame)
  1631. {
  1632.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1633.     SimplePartMethodDebug("SimplePart","SimplePartActivateFrame");
  1634.  
  1635.     try
  1636.     {
  1637.  
  1638.       if (frame != kODNULL) {
  1639.  
  1640.         ODBoolean succeeded = kODFalse;
  1641.  
  1642.         succeeded = _fSession->GetArbitrator(ev)->RequestFocusSet(ev, _fFocusSet,frame);
  1643.  
  1644.         if (succeeded)
  1645.         {
  1646.            somSelf->FocusAcquired(ev, _fSelectionFocus, frame);
  1647.            somSelf->FocusAcquired(ev, _fMenuFocus, frame);
  1648.            somSelf->FocusAcquired(ev, _fKeyFocus, frame);
  1649.         }
  1650.       }
  1651.     }
  1652.     catch(ODException _exception)
  1653.     {
  1654.     }
  1655. }
  1656.  
  1657. // Private method
  1658. SOM_Scope void  SOMLINK SimplePartActivatingWindow(SimplePart *somSelf,
  1659.                                                     Environment *ev,
  1660.                                                    ODFrame* frame)
  1661. {
  1662.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1663.     SimplePartMethodDebug("SimplePart","SimplePartActivatingWindow");
  1664.  
  1665.     try
  1666.     {
  1667.  
  1668.       PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  1669.       if (pInfo->fNeedsActivating)
  1670.       {
  1671.          somSelf->ActivateFrame(ev, frame);
  1672.          pInfo->fNeedsActivating = kODFalse;
  1673.       }
  1674.     }
  1675.     catch(ODException _exception)
  1676.     {
  1677.     }
  1678.  
  1679. }
  1680.  
  1681. // Private method
  1682. SOM_Scope void  SOMLINK SimplePartDeActivatingWindow(SimplePart *somSelf,
  1683.                                                       Environment *ev,
  1684.                                                      ODFrame* frame)
  1685. {
  1686.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1687.     SimplePartMethodDebug("SimplePart","SimplePartDeActivatingWindow");
  1688.  
  1689.     try
  1690.     {
  1691.  
  1692.       PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  1693.       TempODFrame tempFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
  1694.       if (frame == tempFrame)
  1695.       {
  1696.          if (!pInfo->fNeedsActivating)
  1697.          {
  1698.             pInfo->fNeedsActivating = kODTrue;
  1699.          }
  1700.       }
  1701.       else
  1702.       {
  1703.          if (pInfo->fNeedsActivating)
  1704.          {
  1705.             pInfo->fNeedsActivating = kODFalse;
  1706.          }
  1707.       }
  1708.     }
  1709.     catch(ODException _exception)
  1710.     {
  1711.     }
  1712.  
  1713. }
  1714.  
  1715.  
  1716. SOM_Scope void  SOMLINK SimplePartActivate(SimplePart *somSelf,
  1717.                                                 Environment *ev,
  1718.                                                 ODFacet* facet)
  1719. {
  1720.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1721.     SimplePartMethodDebug("SimplePart","SimplePartActivate");
  1722.  
  1723.    try
  1724.    {
  1725.  
  1726.      if (!facet->GetWindow(ev)->IsActive(ev))
  1727.         facet->GetWindow(ev)->Select(ev);
  1728.      else {
  1729.         PartInfoRec* pInfo = (PartInfoRec*) facet->GetFrame(ev)->GetPartInfo(ev);
  1730.         if (!pInfo->fIsActive) {
  1731.            somSelf->ActivateFrame(ev, facet->GetFrame(ev));
  1732.         } /* endif */
  1733.      } /* endif */
  1734.    }
  1735.    catch(ODException _exception)
  1736.    {
  1737.    }
  1738.  
  1739. }
  1740.  
  1741. SOM_Scope ODBoolean  SOMLINK SimplePartHandleMenuEvent(SimplePart *somSelf,
  1742.                                                        Environment *ev,
  1743.                                                        ODFrame* focusFrame,
  1744.                                                        ODEventData* event)
  1745. {
  1746.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1747.     SimplePartMethodDebug("SimplePart","SimplePartHandleMenuEvent");
  1748.  
  1749.     ODBoolean handled = kODFalse;
  1750.  
  1751.     try
  1752.     {
  1753.  
  1754. #ifdef _PLATFORM_WIN32_
  1755.     ODCommandID command = event->wParam;
  1756. #elif defined(_PLATFORM_OS2_)
  1757.     ODCommandID command = LONGFROMMP(event->mp1);
  1758. #elif defined(_PLATFORM_UNIX_)
  1759.     ODMenuItemID command = ((ODMenuEventData *)event)->item;
  1760. #endif
  1761.  
  1762.       switch (command)
  1763.       {
  1764.          case VIEW_PROPERTIES:
  1765.             {
  1766.               ODFrameFacetIterator* facets = focusFrame->CreateFacetIterator(ev);
  1767.               _fSession->GetInfo(ev)->ShowPartFrameInfo(ev,facets->First(ev), kODTrue);
  1768.               delete facets;
  1769.               handled = kODTrue;
  1770.             }
  1771.             break;
  1772.          case VIEW_SASMALLICON:
  1773.             focusFrame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsSmallIcon));
  1774.             somSelf->ViewTypeChanged(ev, focusFrame);
  1775.             break;
  1776.          case VIEW_SALARGEICON:
  1777.             focusFrame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsLargeIcon));
  1778.             somSelf->ViewTypeChanged(ev, focusFrame);
  1779.             break;
  1780.          case VIEW_SATHUMBNAIL:
  1781.             focusFrame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsThumbnail));
  1782.             somSelf->ViewTypeChanged(ev, focusFrame);
  1783.             break;
  1784.          case VIEW_SAFRAME:
  1785.             focusFrame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsFrame));
  1786.             somSelf->ViewTypeChanged(ev, focusFrame);
  1787.             break;
  1788.          case VIEW_OAWINDOW:
  1789.          case kODCommandViewAsWin:
  1790.             {
  1791.               somSelf->Open(ev, focusFrame);
  1792.               handled = kODTrue;
  1793.             }
  1794.             break;
  1795.          case kSimplePartHelpMenu:
  1796.             {
  1797.                ODHelp *help = _fSession->GetHelp(ev);
  1798.                help->DisplayHelp(ev, SP_HELP_FILE, SP_HELP_PANEL);
  1799.                handled = kODTrue;
  1800.             }
  1801.             break;
  1802.          case kSimplePartInfoMenu:
  1803.             {
  1804.                ODTypeToken modalFocus  = _fSession->Tokenize(ev, kODModalFocus);
  1805.                // rrk 10 jan 97 defect 27352
  1806.                // Save current modal focus owner
  1807.                ODFrame * saveModalOwner = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, modalFocus);
  1808.                PRINT("SimplePartHandleMenuEvent; kSimplePartInfoMenu entered. saveModalOwner is %x.\n", saveModalOwner);
  1809.                // Acquire modal focus
  1810.                if (_fSession->GetArbitrator(ev)->RequestFocus(ev, modalFocus, focusFrame)) {
  1811.                    somSelf->DisplayInfoDialog(ev,
  1812.                                               SP_MSG_CATALOG,
  1813.                                               SP_MSG_SET,
  1814.                                               SPMSG_INFOTITLE,
  1815.                                               SP_DEFMSG_INFOTITLE,
  1816.                                               SPMSG_INFO,
  1817.                                               SP_DEFMSG_INFO);
  1818.                     // Restore modal focus
  1819.                     _fSession->GetArbitrator(ev)->TransferFocus(ev, modalFocus, focusFrame, saveModalOwner);
  1820.                     if(saveModalOwner)
  1821.                        saveModalOwner->Release(ev);
  1822.                } /* endif */
  1823.                handled = kODTrue;
  1824.             }
  1825.             break;
  1826.          default:
  1827.             break;
  1828.       }
  1829.     }
  1830.     catch(...)
  1831.     {
  1832.     }
  1833.  
  1834.     return handled;
  1835.  
  1836. }
  1837.  
  1838. SOM_Scope void  SOMLINK SimplePartInstallMenus(SimplePart *somSelf,
  1839.                                                 Environment *ev)
  1840. {
  1841.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1842.     SimplePartMethodDebug("SimplePart","SimplePartInstallMenus");
  1843.  
  1844.     try
  1845.     {
  1846.       if(_fPopup)
  1847.       {
  1848.         _fPopup->RemoveMenuItem(ev, kODNULL, VIEW_OAICON);
  1849.         _fPopup->RemoveMenuItem(ev, kODNULL, VIEW_OATREE);
  1850.         _fPopup->RemoveMenuItem(ev, kODNULL, VIEW_OADETAILS);
  1851.       }
  1852.  
  1853.       //let's add help menu items ONLY if this is simple part
  1854.       // and not its subclass
  1855.       if (!strcmp (somSelf->somGetClassName(), kSimpleClassName))
  1856.       {
  1857.  
  1858. #if defined(__IBMCPP__) || defined(_IBMR2)
  1859.       nl_catd spCatalog;       // NLS message catalog handle
  1860.       char *menuText;           // pointer for NLS message
  1861.  
  1862.       setlocale(LC_MESSAGES, NULL);
  1863.       spCatalog = catopen(SP_MSG_CATALOG, 0);
  1864.       if(spCatalog == CATD_ERR)
  1865.       {
  1866.         PRINT("Could not open message catalog %s\n", SP_MSG_CATALOG);
  1867.       }
  1868. #else
  1869.       char menuText[256];
  1870. #endif
  1871.  
  1872.       _fMenuBar->Acquire(ev);
  1873.  
  1874.       ODPlatformMenuItem *mi = new ODPlatformMenuItem;
  1875.  
  1876.       // add a menu separator line to the HELP menu
  1877.       mi->id = kSimplePartMenuSeparator;
  1878. #if defined(_PLATFORM_WIN32_)
  1879.       mi->afAttribute=MF_SEPARATOR;
  1880. #elif defined(_PLATFORM_OS2_)
  1881.       mi->afAttribute=CA_TITLESEPARATOR;
  1882. #endif
  1883.       _fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, mi);
  1884.  
  1885.  
  1886.       // add SimplePart Help item to the HELP menu
  1887.       mi->id = kSimplePartHelpMenu;
  1888. #if (defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_))
  1889.       mi->afAttribute=0;           // use default attributes
  1890. #endif
  1891.       _fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, mi);
  1892. #if defined(__IBMCPP__) || defined(_IBMR2)
  1893.       menuText=catgets(spCatalog, SP_MSG_SET, SPMSG_HELPMENU, SP_DEFMSG_HELPMENU);
  1894. #else
  1895.       strcpy (menuText, SP_DEFMSG_HELPMENU);
  1896. #endif
  1897.       _fMenuBar->SetMenuItemText(ev, IDMS_HELP, mi->id, menuText);
  1898.  
  1899.       // add SimplePart Information item to the HELP menu
  1900.       mi->id = kSimplePartInfoMenu;
  1901. #if (defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_))
  1902.       mi->afAttribute=0;           // use default attributes
  1903. #endif
  1904.       _fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, mi);
  1905. #if defined(__IBMCPP__) || defined(_IBMR2)
  1906.       menuText=catgets(spCatalog, SP_MSG_SET, SPMSG_INFOMENU, SP_DEFMSG_INFOMENU);
  1907. #else
  1908.       strcpy (menuText, SP_DEFMSG_INFOMENU);
  1909. #endif
  1910.       _fMenuBar->SetMenuItemText(ev, IDMS_HELP, mi->id, menuText);
  1911.  
  1912.     // we can now release the MenuBar
  1913.     _fMenuBar->Release(ev);
  1914.  
  1915.     delete mi;                        // cleanup menuitem buffer
  1916.  
  1917. #if defined(__IBMCPP__) || defined(_IBMR2)
  1918.     catclose(spCatalog);             // close the message catalog
  1919. #endif
  1920.  
  1921.     } // end if this is a subclass
  1922.  
  1923.     }
  1924.     catch(...)
  1925.     {
  1926.     }
  1927. }
  1928.  
  1929. SOM_Scope ODMenuBar*  SOMLINK SimplePartGetMenuBar(SimplePart *somSelf,
  1930.                                                     Environment *ev)
  1931. {
  1932.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1933.     SimplePartMethodDebug("SimplePart","SimplePartGetMenuBar");
  1934.  
  1935.     return _fMenuBar;
  1936. }
  1937.  
  1938. SOM_Scope ODPopup*  SOMLINK SimplePartGetPopupMenu(SimplePart *somSelf,
  1939.                                                     Environment *ev)
  1940. {
  1941.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1942.     SimplePartMethodDebug("SimplePart","SimplePartGetPopupMenu");
  1943.  
  1944.     return _fPopup;
  1945. }
  1946.  
  1947. SOM_Scope void  SOMLINK SimplePartSetViewTypeRect(SimplePart *somSelf,
  1948.                                                   Environment *ev,
  1949.                                                   ViewTypeEnum viewType,
  1950.                                                   ODRect* rect)
  1951. {
  1952.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1953.     SimplePartMethodDebug("SimplePart","SimplePartSetViewTypeRect");
  1954.  
  1955.     int viewSize;
  1956.  
  1957.     switch(viewType)
  1958.     {
  1959.        case SmallIconView:
  1960.           viewSize = kODSmallIconSize;
  1961.           break;
  1962.        case LargeIconView:
  1963.           viewSize = kODLargeIconSize;
  1964.           break;
  1965.        case ThumbnailView:
  1966.           viewSize = kODThumbnailSize;
  1967.           break;
  1968.        case FrameView:
  1969.        default:
  1970.           *rect = _lastFrameRect;
  1971.           return;
  1972.           break;
  1973.     }
  1974.  
  1975.     rect->right = IntToFixed((FixedToInt(rect->left)) + viewSize);
  1976. #ifdef _PLATFORM_OS2_
  1977.     rect->bottom = IntToFixed(0);
  1978.     rect->top    = IntToFixed(viewSize);
  1979. #else
  1980.     rect->bottom = IntToFixed(viewSize);
  1981.     rect->top = IntToFixed(0);
  1982. #endif
  1983. }
  1984.  
  1985. SOM_Scope void  SOMLINK SimplePartAdjustViewTypeShapes(SimplePart *somSelf,
  1986.                                                        Environment *ev,
  1987.                                                        ODFrame* frame)
  1988. {
  1989.     SimplePartData *somThis = SimplePartGetData(somSelf);
  1990.     SimplePartMethodDebug("SimplePart","SimplePartAdjustViewTypeShapes");
  1991.  
  1992.     try
  1993.     {
  1994.  
  1995.       // Do not change frame shape if this is a root frame
  1996.       if(frame->IsRoot(ev)) return;
  1997.  
  1998.       // Prevent infinite recursion of frame negotiation
  1999.       if(_fInFrameNegotiation) return;
  2000.  
  2001.       ViewTypeEnum newViewType;
  2002.  
  2003.       ODRect rect;
  2004.       ODTypeToken viewType = frame->GetViewType(ev);
  2005.       TempODShape newShape = frame->CreateShape(ev);
  2006.  
  2007.       TempODShape currShape = frame->AcquireFrameShape(ev, kODNULL);
  2008.       currShape->GetBoundingBox(ev, &rect);
  2009.  
  2010.       // Determine the new shape we must present
  2011.       if(viewType == _fSession->Tokenize(ev,kODViewAsSmallIcon))
  2012.       {
  2013.          newViewType = SmallIconView;
  2014.       }
  2015.       else if(viewType ==  _fSession->Tokenize(ev,kODViewAsLargeIcon))
  2016.       {
  2017.          newViewType = LargeIconView;
  2018.       }
  2019.       else if(viewType == _fSession->Tokenize(ev,kODViewAsThumbnail))
  2020.       {
  2021.          newViewType = ThumbnailView;
  2022.       }
  2023.       else
  2024.       {
  2025.          frame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsFrame));
  2026.          if(_fPrevViewType == FrameView)
  2027.          {
  2028.             // This is an adjustment due to a resize or reconnect.
  2029.             // Just store the new frame shape.
  2030.             _lastFrameRect = rect;
  2031.  
  2032.             // Do not attempt any frame negotiation.
  2033.             return;
  2034.          }
  2035.          else
  2036.          {
  2037.             newViewType = FrameView;
  2038.          }
  2039.       }
  2040.       somSelf->SetViewTypeRect(ev, newViewType, &rect);
  2041.       newShape->SetRectangle(ev, &rect);
  2042.  
  2043.  
  2044.       // Get the facet from the frame
  2045.       ODFrameFacetIterator  *facetIter = frame->CreateFacetIterator(ev);
  2046.       ODFacet *facet = facetIter->First(ev);
  2047.       delete facetIter;
  2048.  
  2049.       _fInFrameNegotiation = kODTrue;
  2050.  
  2051.       // Change the frame shape
  2052.       TempODShape finalShape = frame->RequestFrameShape(ev, newShape, kODNULL);
  2053.  
  2054.       _fInFrameNegotiation = kODFalse;
  2055.  
  2056.       // Container has the last word on frame shape. If the returned frame
  2057.       // is not the one requested, reset the lastFrameRect.
  2058.       if(!finalShape->IsSameAs(ev, newShape) && (newViewType == FrameView))
  2059.       {
  2060.          finalShape->GetBoundingBox(ev, &_lastFrameRect);
  2061.       }
  2062.  
  2063.       _fPrevViewType = newViewType;
  2064.     }
  2065.     catch(ODException _exception)
  2066.     {
  2067.     }
  2068. }
  2069.  
  2070. SOM_Scope void  SOMLINK SimplePartDrawFrame(SimplePart *somSelf,
  2071.                                             Environment *ev,
  2072.                                             ODFacet* facet,
  2073.                                             ODShape* invalidShape)
  2074. {
  2075.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2076.     SimplePartMethodDebug("SimplePart","SimplePartDrawFrame");
  2077.  
  2078.     ODRect frameODRect;
  2079.     TempODShape frameShape = facet->GetFrame(ev)->AcquireFrameShape(ev,kODNULL);
  2080.     frameShape->GetBoundingBox(ev, &frameODRect);
  2081.     HDraw hDraw;
  2082.  
  2083.     CFocus f(facet, invalidShape, &hDraw);     // Set up drawing environment
  2084. #if defined(_PLATFORM_OS2_)||defined(_PLATFORM_WIN32_)
  2085.  
  2086.     Rect frameRect;
  2087. #endif
  2088. #ifdef _PLATFORM_OS2_
  2089.     HAB hab = WinInitialize(0);
  2090.     WinSetRect(hab,&frameRect, FixedToInt(frameODRect.left),
  2091.                                FixedToInt(frameODRect.bottom),
  2092.                                FixedToInt(frameODRect.right),
  2093.                                FixedToInt(frameODRect.top));
  2094.     Point orig = {0, 0};
  2095.     Point pt = {frameRect.xRight, frameRect.yTop};
  2096.     GpiSetColor(hDraw, CLR_RED);                  // Set the drawing color
  2097.     GpiMove(hDraw, &orig);                        // Set the origin from which to draw
  2098.     GpiBox(hDraw, DRO_FILL, &pt, 0, 0);           // Draw a color filled rectangle
  2099.     GpiSetColor(hDraw, CLR_BLACK);                // Set the drawing color
  2100.  
  2101.     // Draw diagonal lines
  2102.     Point pt1, pt2;
  2103.  
  2104.     int height = frameRect.yTop - frameRect.yBottom;
  2105.     int width  = frameRect.xRight;
  2106.  
  2107.     pt1.x = 0;
  2108.     pt2.x = width;
  2109.     for (int y = 0; y <= height; y += DELTA)
  2110.     {
  2111.       pt1.y = y;
  2112.       pt2.y = pt1.y + width;
  2113.       GpiMove(hDraw, &pt1);
  2114.       GpiLine(hDraw, &pt2);
  2115.     }
  2116.  
  2117.     pt1.y = 0;
  2118.     pt2.y =  height;
  2119.     for (int x = DELTA; x <= width; x += DELTA)
  2120.     {
  2121.       pt1.x = x;
  2122.       pt2.x = pt1.x + height;
  2123.       GpiMove(hDraw, &pt1);
  2124.       GpiLine(hDraw, &pt2);
  2125.     }
  2126.  
  2127. #elif defined(_PLATFORM_WIN32_)
  2128.     SetRect(&frameRect, FixedToInt(frameODRect.left),
  2129.                         FixedToInt(frameODRect.top),
  2130.                         FixedToInt(frameODRect.right),
  2131.                         FixedToInt(frameODRect.bottom));
  2132.  
  2133.     HBRUSH hbr = CreateSolidBrush (RGB(255,0,0)); // Create a solid brush
  2134.     FillRect (hDraw, &frameRect, hbr);             // Fill the rectangle with the brush
  2135.     DeleteObject (hbr);                           // Delete the brush
  2136.  
  2137.     // Draw diagonal lines
  2138.     Point pt1, pt2;
  2139.  
  2140.     int height = frameRect.bottom - frameRect.top;
  2141.     int width  = frameRect.right;
  2142.  
  2143.     pt1.x = 0;
  2144.     pt2.x = width;
  2145.     for (int y = 0; y <= height; y += DELTA)
  2146.     {
  2147.       pt1.y = y;
  2148.       pt2.y = pt1.y + width;
  2149.       MoveToEx(hDraw, pt1.x, pt1.y, NULL);
  2150.       LineTo(hDraw, pt2.x, pt2.y);
  2151.     }
  2152.  
  2153.     pt1.y = 0;
  2154.     pt2.y =  height;
  2155.     for (int x = DELTA; x <= width; x += DELTA)
  2156.     {
  2157.       pt1.x = x;
  2158.       pt2.x = pt1.x + height;
  2159.       MoveToEx(hDraw, pt1.x, pt1.y, NULL);
  2160.       LineTo(hDraw, pt2.x, pt2.y);
  2161.     }
  2162.  
  2163. #elif defined(_PLATFORM_UNIX_)
  2164.  
  2165.     // Get the AIX Window canvas
  2166.     ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *) (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  2167.  
  2168.     // Get the canvas widget
  2169.     Widget widget = aixwincanvas->GetWidget(ev);
  2170.  
  2171.     // Get the canvas window
  2172.     Window window = aixwincanvas->GetWindow(ev);
  2173.  
  2174.     // Get the canvas display
  2175.     Display *display = aixwincanvas->GetDisplay(ev);
  2176.  
  2177.     // Get the widget's dimensions
  2178.     Position x, y;
  2179.     Dimension width, height;
  2180.  
  2181.     // Set the width and height according to the widget size.
  2182.     XtVaGetValues(widget,
  2183.                   XmNwidth, &width,
  2184.                   XmNheight, &height,
  2185.                   NULL);
  2186.  
  2187.     x = 0;
  2188.     y = 0;
  2189.  
  2190.     // Ensure the fill style is solid
  2191.     XSetFillStyle(display, hDraw, FillSolid);
  2192.  
  2193.     // Get the screen
  2194.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  2195.  
  2196.     // Get the default colormap for the screen
  2197.     Colormap map = XDefaultColormapOfScreen(screen);
  2198.  
  2199.     XColor def, def2;
  2200.  
  2201.     // For loop to create filled rectangles
  2202.     for (int index = 0;
  2203.          index < 4;
  2204.          index++)
  2205.     {
  2206.         Status stat;
  2207.  
  2208.         // Switch on the loop pass
  2209.         switch (index)
  2210.         {
  2211.           case 0:
  2212.             width--;
  2213.             height--;
  2214.  
  2215.             // Background is purple
  2216.             stat = XAllocNamedColor(display, map, "purple", &def, &def2);
  2217.             break;
  2218.  
  2219.           case 1:
  2220.             // Set the frame rectangle for the shadow
  2221.             x += 20;
  2222.             width -= 25;
  2223.             height -= 25;
  2224.             y += 20;
  2225.  
  2226.             // Just use the standard black pixel
  2227.             def.pixel = BlackPixelOfScreen(screen);
  2228.  
  2229.             break;
  2230.  
  2231.           case 2:
  2232.             // Set the frame rectangle for the inner rectangle's border
  2233.             x -= 10;
  2234.             y -= 10;
  2235.             break;
  2236.  
  2237.           case 3:
  2238.             // Set the frame rectangle for the inner rectangle
  2239.             x++;
  2240.             width -= 2;
  2241.             height -= 2;
  2242.             y++;
  2243.  
  2244.             // Color is dark red
  2245.             stat = XAllocNamedColor(display, map, "red" , &def, &def2);
  2246.  
  2247.             break;
  2248.         }
  2249.  
  2250.         // Set foreground color
  2251.         XSetForeground(display, hDraw, def.pixel);
  2252.  
  2253.         // Fill the rectangle
  2254.         XFillRectangle(display,
  2255.                        window,
  2256.                        hDraw,
  2257.                        x, y,
  2258.                        width, height);
  2259.  
  2260.  
  2261.     }
  2262.  
  2263.     // Change color to standard black pixel
  2264.     def.pixel = BlackPixelOfScreen(screen);
  2265.     XSetForeground(display, hDraw, def.pixel);
  2266.  
  2267.     // Set the clip rectangle to prevent diagonal
  2268.     // lines to draw over shadow and background rectangle.
  2269.     XRectangle innerRect = {x, y, width, height};
  2270.     XSetClipRectangles(display, hDraw, 0, 0, &innerRect, 1, Unsorted);
  2271.  
  2272.     // Draw diagonal lines
  2273.     int ymax = y + height;
  2274.     int xmax = x + width;
  2275.  
  2276.     for (int y1=y; y1 <= ymax; y1 += DELTA)
  2277.     {
  2278.       XDrawLine(display, window, hDraw, x, y1, xmax, (y1+width));
  2279.     }
  2280.  
  2281.     for (int x1 = x+DELTA; x1 <= xmax; x1 += DELTA)
  2282.     {
  2283.       XDrawLine(display, window, hDraw, x1, y, (x1+height), ymax);
  2284.     }
  2285.  
  2286.     // Undo clipping
  2287.     XSetClipMask(display, hDraw, None);
  2288.  
  2289. #endif
  2290. }
  2291.  
  2292. SOM_Scope void  SOMLINK SimplePartDrawThumbnail(SimplePart *somSelf,
  2293.                                             Environment *ev,
  2294.                                             ODFacet* facet,
  2295.                                             ODShape* invalidShape)
  2296. {
  2297.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2298.     SimplePartMethodDebug("SimplePart","SimplePartDrawThumbnail");
  2299.  
  2300.     // Not yet implemented
  2301.     somSelf->DrawFrame(ev, facet, invalidShape);
  2302. }
  2303.  
  2304. SOM_Scope void  SOMLINK SimplePartLoadIconsFromModule(SimplePart *somSelf,
  2305.                                                           Environment *ev,
  2306.                                                           string moduleName,
  2307.                                                           long iconID)
  2308. {
  2309.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2310.     SimplePartMethodDebug("SimplePart","SimpleLoadIconsFromModule");
  2311.  
  2312. #ifdef _PLATFORM_OS2_
  2313.     CHAR errBuffer[CCHMAXPATH];
  2314.     if(moduleName)
  2315.     {
  2316.       DosLoadModule(errBuffer,
  2317.                     sizeof(errBuffer),
  2318.                     moduleName,
  2319.                     &_hResModule);
  2320.     }
  2321.  
  2322.     HPOINTER hptr = WinLoadPointer(HWND_DESKTOP,
  2323.                                    _hResModule,
  2324.                                    iconID);
  2325.  
  2326.     POINTERINFO pi;
  2327.     WinQueryPointerInfo( hptr, &pi );
  2328.     _hLargeIcon = pi.hbmColor;
  2329.     _hSmallIcon = pi.hbmMiniColor;
  2330.  
  2331. #elif defined(_PLATFORM_WIN32_)
  2332.     if(moduleName)
  2333.     {
  2334.       _hResModule = LoadLibrary(moduleName);
  2335.     }
  2336.  
  2337.     _hSmallIcon = LoadImage(_hResModule,
  2338.                        MAKEINTRESOURCE(iconID),
  2339.                        IMAGE_ICON,
  2340.                        kODSmallIconSize,
  2341.                        kODSmallIconSize,
  2342.                        LR_DEFAULTCOLOR);
  2343.     _hLargeIcon = LoadImage(_hResModule,
  2344.                        MAKEINTRESOURCE(iconID),
  2345.                        IMAGE_ICON,
  2346.                        kODLargeIconSize,
  2347.                        kODLargeIconSize,
  2348.                        LR_DEFAULTCOLOR);
  2349. #endif
  2350.  
  2351. }
  2352.  
  2353. SOM_Scope void  SOMLINK SimplePartCreateIcons(SimplePart *somSelf,
  2354.                                               Environment *ev)
  2355. {
  2356.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2357.     SimplePartMethodDebug("SimplePart","SimplePartCreateIcons");
  2358.  
  2359. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  2360.     somSelf->LoadIconsFromModule(ev,
  2361.                                  "iodsimpl",
  2362.                                  kODIcon);
  2363. #endif
  2364. }
  2365.  
  2366. SOM_Scope void  SOMLINK SimplePartFreeResModule(SimplePart *somSelf,
  2367.                                                 Environment *ev)
  2368. {
  2369.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2370.     SimplePartMethodDebug("SimplePart","SimplePartFreeResModule");
  2371.  
  2372.     if(_hResModule)
  2373.     {
  2374. #ifdef _PLATFORM_OS2_
  2375.       DosFreeModule(_hResModule);
  2376. #elif defined(_PLATFORM_WIN32_)
  2377.       FreeLibrary(_hResModule);
  2378. #endif
  2379.     }
  2380. }
  2381.  
  2382. SOM_Scope void  SOMLINK SimplePartDrawIcon(SimplePart *somSelf,
  2383.                                            Environment *ev,
  2384.                                            ODFacet* facet,
  2385.                                            ODShape* invalidShape,
  2386.                                            ViewTypeEnum viewType)
  2387. {
  2388.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2389.     SimplePartMethodDebug("SimplePart","SimplePartDrawIcon");
  2390.  
  2391.  
  2392.     HIconView *hIcon;
  2393.     short iconSize;
  2394.  
  2395.     if(viewType == SmallIconView)
  2396.     {
  2397.       hIcon = &_hSmallIcon;
  2398.       iconSize = kODSmallIconSize;
  2399.     }
  2400.     else
  2401.     {
  2402.       hIcon = &_hLargeIcon;
  2403.       iconSize = kODLargeIconSize;
  2404.     }
  2405.  
  2406.     HDraw hDraw;
  2407.     CFocus f(facet, invalidShape, &hDraw);     // Set up drawing environment
  2408.  
  2409. #if defined(_PLATFORM_OS2_)||defined(_PLATFORM_WIN32_)
  2410.  
  2411.     if(*hIcon == kODNULL) somSelf->CreateIcons(ev);
  2412.  
  2413.     ODRect iconODRect;
  2414.     Rect iconRect;
  2415.     TempODShape frameShape = facet->GetFrame(ev)->AcquireFrameShape(ev,kODNULL);
  2416.     frameShape->GetBoundingBox(ev, &iconODRect);
  2417.  
  2418. #endif
  2419. #ifdef _PLATFORM_OS2_
  2420.     HAB hab = WinInitialize(0);
  2421.     WinSetRect(hab,&iconRect, FixedToInt(iconODRect.left),
  2422.                               FixedToInt(iconODRect.bottom),
  2423.                               FixedToInt(iconODRect.right),
  2424.                               FixedToInt(iconODRect.top));
  2425.  
  2426.     ODFixed xscale, yscale;
  2427.     Get72DPIToScreenScale( _fSession, &xscale, &yscale);
  2428.  
  2429.     Point aPoints[4] = {{iconRect.xLeft,iconRect.yBottom},
  2430.                         {iconRect.xRight,iconRect.yTop},
  2431.                         {0,0},
  2432.                         {FixedToInt(ODFixedMultiply(xscale, IntToFixed(iconSize))),
  2433.                          FixedToInt(ODFixedMultiply(yscale, IntToFixed(iconSize)))}};
  2434.  
  2435.     LONG lHits = GpiWCBitBlt(hDraw,
  2436.                              *hIcon,
  2437.                              4,
  2438.                              aPoints,
  2439.                              ROP_SRCCOPY,
  2440.                              BBO_IGNORE);
  2441.  
  2442. #elif defined(_PLATFORM_WIN32_)
  2443.     SetRect(&iconRect, FixedToInt(iconODRect.left),
  2444.                        FixedToInt(iconODRect.top),
  2445.                        FixedToInt(iconODRect.right),
  2446.                        FixedToInt(iconODRect.bottom));
  2447.     BOOL success = DrawIconEx(hDraw,
  2448.                               iconRect.left,
  2449.                               iconRect.top,
  2450.                               *hIcon,
  2451.                               iconSize,
  2452.                               iconSize,
  2453.                               0,
  2454.                               NULL,
  2455.                               DI_NORMAL);
  2456.  
  2457. #elif defined(_PLATFORM_UNIX_)
  2458.  
  2459.     // Get the AIX Window canvas
  2460.     ODAIXWindowCanvas *aixwincanvas =
  2461.       (ODAIXWindowCanvas *)(facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  2462.  
  2463.     // Get the canvas window
  2464.     Window window = aixwincanvas->GetWindow(ev);
  2465.  
  2466.     // Get the canvas display
  2467.     Display *display = aixwincanvas->GetDisplay(ev);
  2468.  
  2469.     // Get the screen
  2470.     Screen *screen = _fSession->GetWindowState(ev)->GetScreen(ev);
  2471.  
  2472.     // Get the default colormap for the screen
  2473.     Colormap map = XDefaultColormapOfScreen(screen);
  2474.  
  2475.     // Create red color structure
  2476.     XColor def, def2;
  2477.     Status stat = XAllocNamedColor(display, map, "red" , &def, &def2);
  2478.  
  2479.     // Set foreground color
  2480.     XSetForeground(display, hDraw, def.pixel);
  2481.  
  2482.     // Create the icon if it doesn't exist
  2483.     if(*hIcon == kODNULL)
  2484.     {
  2485.       // On AIX we may not create both icons at the same time.
  2486.       // Create the bitmaps separately because they depend
  2487.       // on the window attributes which are different
  2488.       // for each viewtype.
  2489.       if(viewType ==  SmallIconView)
  2490.       {
  2491.         _hSmallIcon = XCreateBitmapFromData(display,
  2492.                                             window,
  2493.                                             simpl16_bits,
  2494.                                             iconSize,
  2495.                                             iconSize);
  2496.       }
  2497.       else
  2498.       {
  2499.         _hLargeIcon = XCreateBitmapFromData(display,
  2500.                                             window,
  2501.                                             simpl32_bits,
  2502.                                             iconSize,
  2503.                                             iconSize);
  2504.       }
  2505.     }
  2506.  
  2507.     // Display the bitmap
  2508.     XCopyPlane(display, *hIcon, window, hDraw, 0, 0, iconSize, iconSize, 1, 1, 0x01);
  2509.  
  2510. #endif
  2511. }
  2512.  
  2513. SOM_Scope PartInfoRec* SOMLINK SimplePartCreateFramePartInfo(SimplePart *somSelf,
  2514.                                                           Environment *ev)
  2515. {
  2516.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2517.     SimplePartMethodDebug("SimplePart","SimplePartCreateFramePartInfo");
  2518.  
  2519.     PartInfoRec* pInfo = (PartInfoRec *) SOMMalloc(sizeof(PartInfoRec));
  2520.     pInfo->fIsActive        = kODFalse;
  2521.     pInfo->fNeedsActivating = kODFalse;
  2522.     pInfo->fIsPopupMenu     = kODFalse;
  2523.     pInfo->fIsSelected      = kODFalse;
  2524.     pInfo->pOther           = kODNULL;
  2525.     return pInfo;
  2526. }
  2527.  
  2528. SOM_Scope void SOMLINK SimplePartDeleteFramePartInfo(SimplePart *somSelf,
  2529.                                                      Environment *ev,
  2530.                                                      PartInfoRec *pInfo)
  2531. {
  2532.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2533.     SimplePartMethodDebug("SimplePart","SimplePartDeleteFramePartInfo");
  2534.  
  2535.     SOMFree(pInfo);
  2536. }
  2537.  
  2538. SOM_Scope IODLinkedList* SOMLINK SimplePartGetDisplayFrames(SimplePart *somSelf,
  2539.                                                 Environment *ev)
  2540. {
  2541.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2542.     SimplePartMethodDebug("SimplePart","SimplePartGetDisplayFrames");
  2543.  
  2544.     return _fDisplayFrames;
  2545. }
  2546.  
  2547. SOM_Scope ODBoolean SOMLINK SimplePartDisplayPopupMenu(SimplePart *somSelf,
  2548.                                                       Environment *ev,
  2549.                                                       ODEventData* event,
  2550.                                                       ODFrame* frame,
  2551.                                                       ODFacet* facet,
  2552.                                                       ODEventInfo* eventInfo)
  2553. {
  2554.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2555.     SimplePartMethodDebug("SimplePart","SimplePartDisplayPopupMenu");
  2556.  
  2557.     try
  2558.     {
  2559.        PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
  2560.        if (!(pInfo->fIsActive))
  2561.              somSelf->ActivateFrame(ev, frame);
  2562.  
  2563.        if(_fPopup)
  2564.        {
  2565.           if(frame->IsRoot(ev))
  2566.           {
  2567.             _fPopup->EnableMenuItem(ev, ID_BASEPOPUP, VIEW_VIEWINWINDOW, kODFalse);
  2568.             _fPopup->EnableMenuItem(ev, ID_BASEPOPUP, VIEW_SHOWAS, kODFalse);
  2569.           }
  2570.           else
  2571.           {
  2572.             _fPopup->EnableMenuItem(ev, ID_BASEPOPUP, VIEW_VIEWINWINDOW, kODTrue);
  2573.             _fPopup->EnableMenuItem(ev, ID_BASEPOPUP, VIEW_SHOWAS, kODTrue);
  2574.           }
  2575.           _fPopup->Display(ev);
  2576.        }
  2577.  
  2578.        return kODTrue;
  2579.     }
  2580.     catch(...)
  2581.     {
  2582.        return kODFalse;
  2583.     }
  2584. }
  2585.  
  2586. #ifdef _PLATFORM_UNIX_
  2587. //------------------------------------------------------------------------------
  2588. // infoCallBack - callback for information dialog box with OK button
  2589. //------------------------------------------------------------------------------
  2590. SOMEXTERN void infoCallBack(Widget widget, XtPointer client_data, XtPointer call_data)
  2591. {
  2592.     // remove dialog
  2593.     XtUnmanageChild(widget);
  2594.     XtDestroyWidget(widget);
  2595. }
  2596.  
  2597. //------------------------------------------------------------------------------
  2598. // SetDispatchModal - call dispatcher to set up modality for the application
  2599. //------------------------------------------------------------------------------
  2600. SOMEXTERN void SOMLINK SetDispatchModal(ODBoolean setModality, ODSession *session)
  2601. {
  2602.     Environment  *ev = somGetGlobalEnvironment();
  2603.  
  2604.     try
  2605.     {
  2606.        ODDispatcher *dispatcher = kODNULL;
  2607.  
  2608.        if(session)
  2609.           dispatcher = session->GetDispatcher(ev);
  2610.  
  2611.        if (dispatcher)
  2612.           dispatcher->SetXtDispatchMode(ev, setModality);
  2613.     }
  2614.     catch (...)
  2615.     {
  2616.     }
  2617. }
  2618.  
  2619. //------------------------------------------------------------------------------
  2620. // DialogPopupCallBack - callback to setup modality when dialog pops up
  2621. //------------------------------------------------------------------------------
  2622. SOMEXTERN void SOMLINK DialogPopupCallBack(Widget widget,
  2623.                                      XtPointer client_data,
  2624.                                      XtPointer call_data)
  2625. {
  2626.     SetDispatchModal(kODTrue, (ODSession*)client_data);
  2627. }
  2628.  
  2629. //------------------------------------------------------------------------------
  2630. // DialogPopdownCallBack - callback to reset modality when dialog pops down
  2631. //------------------------------------------------------------------------------
  2632. SOMEXTERN void SOMLINK DialogPopdownCallBack(Widget widget,
  2633.                                      XtPointer client_data,
  2634.                                      XtPointer call_data)
  2635. {
  2636.     SetDispatchModal(kODFalse, (ODSession*)client_data);
  2637. }
  2638.  
  2639. #endif //_PLATFORM_UNIX_
  2640.  
  2641. SOM_Scope void SOMLINK SimplePartDisplayInfoDialog(SimplePart *somSelf,
  2642.                                                    Environment *ev,
  2643.                                                    string catalog,
  2644.                                                    long  msgSet,
  2645.                                                    long infoTitle,
  2646.                                                    string defaultInfoTitle,
  2647.                                                    long infoMsg,
  2648.                                                    string defaultInfoMsg)
  2649. {
  2650.     SimplePartData *somThis = SimplePartGetData(somSelf);
  2651.     SimplePartMethodDebug("SimplePart","SimplePartDisplayInfoDialog");
  2652.  
  2653.     // Create the strings to be displayed in the dialog box
  2654. #if defined(__IBMCPP__) || defined(_IBMR2)
  2655.     nl_catd msgCatalog;          // NLS message catalog handle
  2656.     char *message, *title;    // pointer for NLS message
  2657.  
  2658.     setlocale(LC_MESSAGES, NULL);
  2659.     msgCatalog = catopen(catalog, 0);
  2660.     if(msgCatalog == CATD_ERR)
  2661.     {
  2662.       PRINT("Could not open message catalog %s\n", catalog);
  2663.     }
  2664.     title = catgets(msgCatalog, SP_MSG_SET, SPMSG_INFOTITLE, defaultInfoTitle);
  2665.     message = catgets(msgCatalog, SP_MSG_SET, SPMSG_INFO, defaultInfoMsg);
  2666.  
  2667. #else
  2668.     char message[256], title[256];
  2669.     strcpy (title, defaultInfoTitle);
  2670.     strcpy (message, defaultInfoMsg);
  2671. #endif
  2672.  
  2673.      // Display the strings in the dialog box
  2674. #ifdef _PLATFORM_WIN32_
  2675.      MessageBox(NULL,
  2676.                 message,
  2677.                 title,
  2678.                 MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
  2679. #elif defined(_PLATFORM_OS2_)
  2680.      ODWindowState* winState=_fSession->GetWindowState(ev);
  2681.      ODWindow *window = winState->AcquireActiveWindow(ev);
  2682.      ODPlatformWindow hwnd = window->GetPlatformWindow(ev);
  2683.      window->Release(ev);
  2684.      WinMessageBox(HWND_DESKTOP, hwnd,
  2685.                    message,
  2686.                    title,
  2687.                    0, MB_OK | MB_INFORMATION | MB_APPLMODAL);
  2688. #elif defined(_PLATFORM_UNIX_)
  2689.     Widget shellWidget;
  2690.     Display *display;
  2691.     try
  2692.     {
  2693.       ODWindowState* winState=_fSession->GetWindowState(ev);
  2694.       TempODWindow window = winState->AcquireActiveWindow(ev);
  2695.       ODPlatformWindow platwin = window->GetPlatformWindow(ev);
  2696.  
  2697.       display = winState->GetDisplay(ev);
  2698.       shellWidget = XtWindowToWidget(display,
  2699.                                      platwin);
  2700.  
  2701.     }
  2702.     catch(...)
  2703.     {
  2704.        return;
  2705.     }
  2706.  
  2707.     // Override default behavior for system close and set to modal
  2708.     Arg args[2];
  2709.     XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
  2710.     XtSetArg(args[1], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
  2711.  
  2712.     // create dialog, it will be destroyed in the callback routine.
  2713.     Widget dialog = XmCreateInformationDialog(shellWidget,
  2714.                                               "info", args, 2);
  2715.  
  2716.     // set values for dialog
  2717.     XmString xTitle = XmStringCreateLocalized(title);
  2718.     XmString xMessage = XmStringCreateLocalized(message);
  2719.     XtVaSetValues(dialog,
  2720.                   XmNdialogTitle, xTitle,
  2721.                   XmNmessageString, xMessage,
  2722.                   NULL);
  2723.     XmStringFree(xMessage);
  2724.     XmStringFree(xTitle);
  2725.  
  2726.     // add callbacks for button
  2727.     XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)infoCallBack,
  2728.                   (XtPointer)NULL);
  2729.  
  2730.     // add callbacks for popup and popdown
  2731.     XtAddCallback(XtParent(dialog), XmNpopupCallback,
  2732.                   (XtCallbackProc)DialogPopupCallBack,
  2733.                   (XtPointer)_fSession);
  2734.     XtAddCallback(XtParent(dialog), XmNpopdownCallback,
  2735.                   (XtCallbackProc)DialogPopdownCallBack,
  2736.                   (XtPointer)_fSession);
  2737.  
  2738.     // add callback for WM_DELETE_WINDOW protocol
  2739.     Atom WM_DELETE_WINDOW = XmInternAtom(display,
  2740.                                          "WM_DELETE_WINDOW",
  2741.                                          FALSE);
  2742.     XmAddWMProtocolCallback(XtParent(dialog), WM_DELETE_WINDOW,
  2743.                             (XtCallbackProc)infoCallBack,
  2744.                             (XtPointer)NULL);
  2745.  
  2746.     // remove cancel and help buttons from dialog.
  2747.     Widget cancel_button = XmMessageBoxGetChild(dialog,
  2748.                                                 XmDIALOG_CANCEL_BUTTON);
  2749.     XtUnmanageChild(cancel_button);
  2750.     Widget help_button = XmMessageBoxGetChild(dialog,
  2751.                                               XmDIALOG_HELP_BUTTON);
  2752.     XtUnmanageChild(help_button);
  2753.  
  2754.     // display dialog
  2755.     XtManageChild(dialog);
  2756.  
  2757. #endif  // _PLATFORM_UNIX_
  2758.  
  2759. #if defined(__IBMCPP__) || defined(_IBMR2)
  2760.     catclose(msgCatalog);             // close the message catalog
  2761. #endif
  2762. }
  2763.  
  2764.