home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / clock / iodclock.cpp next >
Text File  |  1997-04-02  |  20KB  |  644 lines

  1. //====START_GENERATED_PROLOG======================================
  2. //
  3. //
  4. //   COMPONENT_NAME: odclockpart
  5. //
  6. //   CLASSES: none
  7. //
  8. //   ORIGINS: 82,27
  9. //
  10. //
  11. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12. //   All Rights Reserved
  13. //   Licensed Materials - Property of IBM
  14. //   US Government Users Restricted Rights - Use, duplication or
  15. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16. //
  17. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23. //   OR PERFORMANCE OF THIS SOFTWARE.
  24. //
  25. //====END_GENERATED_PROLOG========================================
  26. //
  27. /* @(#) 1.25 com/src/samples/clock/iodclock.cpp, odclockpart, od96os2, odos29712d 2/25/97 16:42:53 [3/21/97 17:45:35] */
  28. /*
  29.  *  This file was generated by the SOM Compiler.
  30.  *  Generated using:
  31.  *     SOM incremental update: 2.41
  32.  */
  33.  
  34. /*
  35.  *      File:           Clock.CPP
  36.  *
  37.  *   Contains:  Implementation of Clock Part
  38.  *
  39.  *   Copyright: (c) 1996 by IBM Corp., all rights reserved.
  40.  *
  41.  */
  42.  
  43. /******************************************************************
  44.    Implementation of Clock as subclassed from ShapePart requires
  45.    changes in the following methods:
  46.    1) CommonInit
  47.    2) Draw
  48.    3) Externalize
  49.    4) HandleEvent
  50.   ******************************************************************/
  51.  
  52. #ifndef SOM_Module_Clock_Source
  53. #define SOM_Module_Clock_Source
  54. #endif
  55.  
  56. #define Clock_Class_Source
  57. #define VARIABLE_MACROS
  58. #include "iodclock.xih"
  59.  
  60.  
  61. #define INCL_ODAPI
  62. #define INCL_ODARBITRATOR
  63. #define INCL_ODCANVAS
  64. #define INCL_ODDRAGANDDROP
  65. #define INCL_ODDRAFT
  66. #define INCL_ODERRORS
  67. #define INCL_ODFACET
  68. #define INCL_ODFOCUSSET
  69. #define INCL_ODFRAME
  70. #define INCL_ODINFO
  71. #define INCL_ODSHAPE
  72. #define INCL_ODSESSION
  73. #define INCL_ODSTORAGEUNIT
  74. #define INCL_ODSTORAGEUNITVIEW
  75. #define INCL_ODTRANSFORM
  76. #define INCL_ODUI
  77. #define INCL_ODUNDO
  78. #define INCL_ODWINDOW
  79. #define INCL_ODWINDOWSTATE
  80.  
  81.  
  82. #ifndef _ODEXCEPT_
  83. #include "ODExcept.h"
  84. #endif
  85.  
  86. #ifndef _FOCUSLIB_
  87. #include <focuslib.h>
  88. #endif
  89.  
  90. #ifndef _ODMATH_
  91. #include "ODMath.h"
  92. #endif
  93.  
  94. #ifndef _MATH_
  95. #include "Math.h"
  96. #endif
  97.  
  98. #ifndef _TIME_
  99. #include "Time.h"
  100. #endif
  101.  
  102. #ifndef _STORUTIL_
  103. #include <storutil.h>
  104. #endif
  105.  
  106. #ifndef _TEMPOBJ_
  107. #include "TempObj.h"
  108. #endif
  109.  
  110. #ifndef _WINUTILS_
  111. #include "winutils.h"
  112. #endif
  113.  
  114. #ifndef  __string_h
  115. #include <string.h>
  116. #endif
  117.  
  118. #ifndef _STDTYPIO_
  119. #include "stdtypio.h"
  120. #endif
  121.  
  122. #ifdef ODDebug
  123. #include <qprintf.h>       // MSGDISP.EXE qprintf's
  124. #endif
  125.  
  126. #ifndef _ODALL_
  127. #include <odall.h>
  128. #endif
  129.  
  130. #ifndef _ITEXT_
  131. #include <IText.h>
  132. #endif
  133.  
  134. #ifndef _StorUtil_
  135. #include <StorUtil.h>
  136. #endif
  137.  
  138. #ifndef _IBASE_                         //  Make sure ibase.hpp is included
  139. #include <ibase.hpp>                    //  since that is where IC_<environ>
  140. #include <igrafctx.hpp>
  141. #include <igbundle.hpp>
  142. #include <igrect.hpp>
  143. #include <igline.hpp>
  144. #endif
  145.  
  146. const ODType   kClockKind            = "Clock";
  147. const ODType   kClockKindDisplayName = "Clock Part Kind";
  148. const ODType   kClockPartHandlerName  =  "Clock";
  149. const ODType   kClockPartHandlerDisplayName  =  "Clock Part";
  150. const ODType   kClockIconFileName  =  "iodclock.ico";
  151. const ODType   kClockCategory         =  "OpenDoc:Category:Sample";
  152.  
  153. char* kClockPartPropertyName  =  "Clock";
  154.  
  155. /*******************************************************************
  156.  The following methods is defined by ClockPart to invalidate
  157.  the interior regions of its face.
  158.  *******************************************************************/
  159.  
  160. SOM_Scope void  SOMLINK ClockInvalidateHands(Clock* somSelf,
  161.                                             Environment* ev,
  162.                                             ODFacet* facet,
  163.                                             ODFrame* frame)
  164. {
  165.     ClockData *somThis = ClockGetData(somSelf);
  166.     ClockMethodDebug("Clock","ClockInvalidateHands");
  167. #ifdef ODDebug
  168.    qprintf("Invoked Clock::InvalidateHands\n");
  169. #endif
  170.  
  171.    try {
  172.  
  173.            if ((facet != kODNULL) && (frame != kODNULL))
  174.            {
  175.                int width;
  176.                int height;
  177.                ODRgnHandle hrgnToInval;
  178.                ODRect box;
  179.                TempODShape tempShape = frame->AcquireFrameShape(ev, facet->GetCanvas(ev));
  180.                tempShape->GetBoundingBox(ev, &box);
  181.  
  182.                width  = FixedToInt(box.right) - FixedToInt(box.left);        // shape to be
  183.                height = abs(FixedToInt(box.top) - FixedToInt(box.bottom));   // invalidated
  184.  
  185.                // create the region to be invalidated
  186. #ifdef _PLATFORM_WIN32_
  187.                hrgnToInval = CreateEllipticRgn(width*.15,height*.15,width*.85,height*.85);
  188. #elif defined(_PLATFORM_OS2_)
  189.  
  190.                POINTL center;
  191.                ODPlatformCanvas* canvas = facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODPM);
  192.                HPS hps = ((ODOS2WindowCanvas*)canvas)->GetPS(ev);
  193.                int rad = (width < height) ? width : height;       // get radius
  194.                center.x = width/2;
  195.                center.y = height/2;
  196.                GpiBeginPath(hps,1L);                              // Define GPI
  197.                GpiSetCurrentPosition(hps , ¢er);              // for circle
  198.                GpiFullArc(hps,DRO_OUTLINE,MAKEFIXED((rad*0.4),0));
  199.                GpiEndPath(hps);
  200.                hrgnToInval = GpiPathToRegion(hps, 1, FPATH_ALTERNATE);  // Convert path
  201. #endif
  202.                // Ensure that the region to invalidate is not null before proceeding
  203.                // (CreateEllipticRegion on Win95 returns null region if we're minimized)
  204.                if (hrgnToInval) {
  205.                   // get the shape of the region and call invalidate
  206.                   ODShape *MyShape= frame->CreateShape(ev);
  207.                   MyShape->SetRegion(ev,hrgnToInval);
  208.  
  209.                   frame->Invalidate(ev,MyShape,kODNULL);          // invalidate clock hands
  210.  
  211. #ifdef _PLATFORM_OS2_
  212.                   ((ODOS2WindowCanvas *)canvas)->ReleasePS(ev);   // Release the canvas
  213. #endif
  214.                   MyShape->Release(ev);
  215.                } // endif hrgnToInval
  216.            }
  217.    }
  218.    catch(...){}
  219. }
  220.  
  221. /*******************************************************************
  222.   The following 4 Methods are defined in Clocks parents and overridden
  223.   here.
  224.  *******************************************************************/
  225.  
  226. SOM_Scope void  SOMLINK ClockCommonInit(Clock *somSelf,
  227.                                            Environment *ev,
  228.                                            ODPart        *partWrapper)
  229. {
  230.     ClockData *somThis = ClockGetData(somSelf);
  231.     ClockMethodDebug("Clock","ClockCommonInit");
  232. #ifdef ODDebug
  233.    qprintf("Invoked Clock::CommonInit\n");
  234. #endif
  235.  
  236.    try {
  237.  
  238.     Clock_parent_ShapePart_CommonInit(somSelf,  ev, partWrapper);
  239.  
  240.  
  241.     double pi=4.*atan(1.);   // set pi
  242.     double d2r=pi/180. ;     // set degrees to radians
  243.  
  244.     // Calculate the points on the outside of the clock
  245.     for (int i=0;(i<359);(i=i+6))
  246.       {
  247.        _ClockPtx[i]=sin(d2r*i);
  248.        _ClockPty[i]=-cos(d2r*i);
  249.       }
  250.  
  251.    }
  252.    catch(...){}
  253. }
  254.  
  255. SOM_Scope void  SOMLINK ClockDraw(Clock *somSelf,  Environment *ev,
  256.                                        ODFacet* facet, ODShape* invalidShape)
  257. {
  258.     ClockData *somThis = ClockGetData(somSelf);
  259.     ClockMethodDebug("Clock","ClockDraw");
  260. #ifdef ODDebug
  261.    qprintf("Invoked Clock::Draw\n");
  262. #endif
  263.  
  264.    try {
  265.  
  266.    // Let ShapePart fill in the background color.
  267.    Clock_parent_ShapePart_Draw(somSelf,  ev, facet, invalidShape);
  268.  
  269.    ODRect rect;
  270.    POINTL pttmp;
  271.    POINTL MidPt;
  272.    ODBoolean printing = kODFalse;
  273.  
  274.    // If we are printing, we will always set our pen width to 1
  275. #ifdef _PLATFORM_OS2_
  276.    if (facet->GetCanvas(ev)->HasPlatformPrintJob(ev,kODPM))
  277. #elif defined(_PLATFORM_WIN32_)
  278.    if (facet->GetCanvas(ev)->HasPlatformPrintJob(ev,kODWin32))
  279. #endif
  280.           printing = kODTrue;
  281.  
  282.    ODFrame* displayFrame = facet->GetFrame(ev);
  283.    TempODShape tempShape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev));
  284.    tempShape->GetBoundingBox(ev, &rect);
  285.  
  286. #if defined(_PLATFORM_WIN32_)
  287.    HDC hdcDraw;
  288. #elif defined(_PLATFORM_OS2_)
  289.    HPS hdcDraw;
  290. #endif
  291.  
  292.    // Set up drawing environment
  293.    CFocus f(facet, invalidShape, &hdcDraw);
  294.  
  295.  
  296.  
  297.    IPresSpaceHandle ipsh(hdcDraw);
  298.    IGraphicContext gc(ipsh);
  299.    gc.setPenType(IGraphicBundle::solid);
  300.    gc.setPenWidth(1);
  301.    gc.setPenColor(IColor::black);
  302.  
  303.    // Draw the Clock Face
  304.    POINTL ptl1 = {FixedToInt(rect.left),  FixedToInt(rect.bottom)};
  305.    POINTL ptl2 = {FixedToInt(rect.right), FixedToInt(rect.top)};
  306.  
  307.    // Calculate the points of the clock
  308.    float MidxPoint = ((float)(ptl1.x + ptl2.x)/2);
  309.    float MidyPoint = ((float)(ptl1.y + ptl2.y)/2);
  310.    float radius;
  311.    int linesub;
  312.  
  313.    // Get the smallest radius of the bounding box
  314.    if ((MidxPoint - FixedToInt(rect.left)) <=
  315.         abs(MidyPoint - FixedToInt(rect.top)) )
  316.      radius = (MidxPoint - FixedToInt(rect.left));
  317.    else
  318.      radius = abs(MidyPoint - FixedToInt(rect.top));
  319.  
  320.    MidPt.x   = MidxPoint;
  321.    MidPt.y   = MidyPoint;
  322.  
  323.    double pi=4.*atan(1.);   // set pi
  324.    double d2r=pi/180. ;     // set degrees to radians
  325.  
  326.    POINTL ClockPts[359];
  327.  
  328.    for  (int i=0;(i<359);(i=i+6))
  329.       {
  330.        ClockPts[i].x=((radius*_ClockPtx[i])+(MidxPoint));
  331.        ClockPts[i].y=((radius*_ClockPty[i])+(MidyPoint));
  332.  
  333.        // Calculate the 15 minute marks
  334.        if ((i%90) == 0)
  335.          {
  336.             if (printing) {
  337.               gc.setPenWidth(1);
  338.             } else {
  339.               gc.setPenWidth(3);
  340.             } /* endif */
  341.           linesub = ((radius*2)*.08);
  342.          }
  343.        // Calculate the 5 minute marks
  344.        else if ((i%30) == 0)
  345.          {
  346.             if (printing) {
  347.               gc.setPenWidth(1);
  348.             } else {
  349.               gc.setPenWidth(2);
  350.             } /* endif */
  351.           linesub = ((radius*2)*.05);
  352.          }
  353.        // Otherwise, set up the 1 minute mark
  354.        else
  355.          {
  356.           gc.setPenWidth(1);
  357.           linesub = ((radius*2)*.025);
  358.          }
  359.  
  360.        pttmp.x=(((radius-linesub)*_ClockPtx[i])+(MidxPoint));
  361.        pttmp.y=(((radius-linesub)*_ClockPty[i])+(MidyPoint));
  362.  
  363.        // Draw the marks on the clock face
  364.        IGLine(IPoint(ClockPts[i]), IPoint(pttmp)).drawOn(gc);
  365.  
  366.       }  // end of for (i=0;(i<359);(i=i+6))
  367.  
  368.   time_t tm;
  369.   time (&tm);
  370.   struct tm *ltime = localtime(&tm);    // get the time from the system
  371.  
  372.   int secpt =  (ltime->tm_sec * 6);
  373.   int minpt =  (ltime->tm_min * 6);
  374.   int hourpt;
  375.  
  376. // adjust the hour hand every 12 min.  ------------------------------------
  377.   int hradjust = 0;
  378.       if ((minpt>71)&&(minpt<144))
  379.         hradjust = 6;
  380.  
  381.       else if ((minpt>143)&&(minpt<216))
  382.         hradjust = 12;
  383.  
  384.       else if ((minpt>215)&&(minpt<288))
  385.         hradjust = 18;
  386.  
  387.       else if ((minpt>287)&&(minpt<360))
  388.         hradjust = 24;
  389.  
  390.  
  391.   if ((ltime->tm_hour) >= 12)
  392.     hourpt = ((((ltime->tm_hour)-12)*30)+hradjust);
  393.   else
  394.     hourpt = ((ltime->tm_hour *30)+hradjust);
  395. //  endof adjust the hour hand every 12 min. ------------------------------
  396.  
  397. // draw the second hand  --------------------------------------------------
  398.   POINTL tmpsec;
  399.   linesub = (radius*2) * .15;
  400.   tmpsec.x = ((radius-linesub)*_ClockPtx[secpt]) + MidxPoint;
  401. #if defined(_PLATFORM_WIN32_)
  402.   tmpsec.y = MidyPoint + ((radius-linesub)*_ClockPty[secpt]);
  403. #elif defined(_PLATFORM_OS2_)
  404.   tmpsec.y = MidyPoint - ((radius-linesub)*_ClockPty[secpt]);
  405. #endif
  406.  
  407.   gc.setPenWidth(1);
  408.   IGLine(IPoint(MidPt), IPoint(tmpsec)).drawOn(gc);
  409.  
  410. // draw the minute hand  --------------------------------------------------
  411.    POINTL tmpmin;
  412.    linesub = ((radius*2)*.20);
  413.    tmpmin.x=(((radius-linesub)*_ClockPtx[minpt])+(MidxPoint));
  414. #if defined(_PLATFORM_WIN32_)
  415.   tmpmin.y = MidyPoint + ((radius-linesub)*_ClockPty[minpt]);
  416. #elif defined(_PLATFORM_OS2_)
  417.   tmpmin.y = MidyPoint - ((radius-linesub)*_ClockPty[minpt]);
  418. #endif
  419.  
  420.    if (printing) {
  421.      gc.setPenWidth(1);
  422.    } else {
  423.      gc.setPenWidth(2);
  424.    } /* endif */
  425.    IGLine(IPoint(MidPt), IPoint(tmpmin)).drawOn(gc);
  426.  
  427. // draw the hour hand  --------------------------------------------------
  428.    POINTL tmphour;
  429.    linesub = ((radius*2)*.27);
  430.    tmphour.x=(((radius-linesub)*_ClockPtx[hourpt])+(MidxPoint));
  431. #if defined(_PLATFORM_WIN32_)
  432.   tmphour.y = MidyPoint + ((radius-linesub)*_ClockPty[hourpt]);
  433. #elif defined(_PLATFORM_OS2_)
  434.   tmphour.y = MidyPoint - ((radius-linesub)*_ClockPty[hourpt]);
  435. #endif
  436.  
  437.    if (printing) {
  438.      gc.setPenWidth(1);
  439.    } else {
  440.      gc.setPenWidth(3);
  441.    } /* endif */
  442.    IGLine(IPoint(MidPt), IPoint(tmphour)).drawOn(gc);
  443.  
  444.  
  445. // call the system timer it will send back a timer event in one second
  446.    HWND hwndFacet = facet->GetFacetHWND(ev);
  447. #if defined(_PLATFORM_WIN32_)
  448.    SetTimer(hwndFacet,100,1000,(TIMERPROC)NULL);
  449. #elif defined(_PLATFORM_OS2_)
  450.    WinStartTimer(WinQueryAnchorBlock(hwndFacet), hwndFacet, 0, 1000);
  451. #endif
  452.  
  453.    }
  454.    catch(...){}
  455. }
  456.  
  457.  
  458.  
  459. SOM_Scope void  SOMLINK ClockExternalize(Clock *somSelf,
  460.                                                Environment *ev)
  461. {
  462.     ClockData *somThis = ClockGetData(somSelf);
  463.     ClockMethodDebug("Clock","ClockExternalize");
  464.  
  465. #ifdef ODDebug
  466.    qprintf("Invoked Clock::Externalize\n");
  467. #endif
  468.  
  469.     // call the parent's method
  470.     Clock_parent_ShapePart_Externalize(somSelf, ev);
  471.  
  472.     try{
  473.  
  474.       ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  475.  
  476.       // Add the kind name to this part's storageUnit
  477.       if (ODSUExistsThenFocus (ev, su, kODPropContents, kClockKind))
  478.          su->Remove (ev);
  479.  
  480.       su->AddProperty(ev, kODPropContents)->AddValue(ev, kClockKind);
  481.  
  482.       // Add a default kODPropName to this part's storageUnit for the
  483.       // document properties notebook.  The notebook will maintain
  484.       // it's persistence.
  485.       if (ODSUExistsThenFocus (ev, su, kODPropName, kODIntlText)) {
  486.          if (su->GetSize(ev) == 0) {
  487.             // create string to place in kODPropName property
  488.             ODIText* iClockPropName = CreateITextFromCharPtr(kClockPartPropertyName);
  489.  
  490.             // write the name into the kODPropName property
  491.             ODSetITextProp(ev, su, kODPropName, kODIntlText, iClockPropName);
  492.          }
  493.       }
  494.    } catch (...) {
  495.    } /* end catch */
  496. }
  497.  
  498.  
  499.  
  500.  
  501. SOM_Scope ODBoolean  SOMLINK ClockHandleEvent(Clock *somSelf,
  502.                                                     Environment *ev,
  503.                                                     ODEventData* event,
  504.                                                     ODFrame* frame,
  505.                                                     ODFacet* facet,
  506.                                                     ODEventInfo* eventInfo)
  507. {
  508.     ClockData *somThis = ClockGetData(somSelf);
  509.     ClockMethodDebug("Clock","ClockHandleEvent");
  510.  
  511. // call the parents method
  512.     Clock_parent_ShapePart_HandleEvent(somSelf, ev, event, frame, facet, eventInfo);
  513.  
  514.  
  515.     ODBoolean handled = kODFalse;
  516.  
  517.     try {
  518.  
  519. #if defined(_PLATFORM_WIN32_)
  520.     switch (event->message)
  521. #elif defined(_PLATFORM_OS2_)
  522.     switch (event->msg)
  523. #endif
  524.     {
  525.  
  526.        case WM_TIMER:
  527.        // Invalidate the clock hands, so that OpenDoc redraws only
  528.        // the Clock hands and not the Clock face.
  529.        {
  530.            somSelf->InvalidateHands(ev, facet, frame);
  531.            handled = kODTrue;
  532.            break;
  533.        } // end WM_TIMER
  534.  
  535.        default:
  536.             handled = kODFalse;
  537.             break;
  538.     } // end switch
  539.  
  540.     } catch(...) {}
  541.  
  542.     return handled;
  543. }
  544.  
  545. /******************************************************************
  546.   The following 5 messages belong to the Clock Part's Metaclass.
  547.  ******************************************************************/
  548.  
  549. SOM_Scope ISOString  SOMLINK M_ClockclsGetODPartHandlerName(M_Clock *somSelf,
  550.                                                                   Environment *ev)
  551. {
  552.     /* M_ClockData *somThis = M_ClockGetData(somSelf); */
  553.     M_ClockMethodDebug("M_Clock","M_ClockclsGetODPartHandlerName");
  554.  
  555.     string handlerName = (string)SOMMalloc(strlen(kClockPartHandlerName)+1);
  556.     strcpy(handlerName,kClockPartHandlerName);
  557.  
  558.     return (ISOString) handlerName;
  559. }
  560.  
  561.  
  562. SOM_Scope string  SOMLINK M_ClockclsGetODPartHandlerDisplayName(M_Clock *somSelf,
  563.                                                                       Environment *ev)
  564. {
  565.     /* M_ClockData *somThis = M_ClockGetData(somSelf); */
  566.     M_ClockMethodDebug("M_Clock","M_ClockclsGetODPartHandlerDisplayName");
  567.  
  568.     string displayName = (string)SOMMalloc(strlen(kClockPartHandlerDisplayName)+1);
  569.     strcpy(displayName,kClockPartHandlerDisplayName);
  570.  
  571.     return displayName;
  572.  
  573. }
  574.  
  575. SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_ClockclsGetODPartKinds(M_Clock *somSelf,
  576.                                                                              Environment *ev)
  577. {
  578.     /* M_ClockData *somThis = M_ClockGetData(somSelf); */
  579.     M_ClockMethodDebug("M_Clock","M_ClockclsGetODPartKinds");
  580.  
  581.     _IDL_SEQUENCE_PartKindInfo ClockInfo;
  582.     // Create structure PartKindInfo  and allocate memory for variable
  583.     PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
  584.     info->partKindName = (ISOString) SOMMalloc(strlen(kClockKind) + 1);
  585.     info->partKindDisplayName = (string)SOMMalloc(strlen(kClockKindDisplayName)+1);
  586.     info->filenameFilters =  (string)SOMMalloc(strlen("")+1);
  587.     info->filenameTypes =  (string)SOMMalloc(strlen("")+1);
  588.     info->categories =  (string)SOMMalloc(strlen(kClockCategory) + 1);
  589.     info->categoryDisplayName =  (string)SOMMalloc(strlen("Sample") + 1);
  590.     info->objectID =  (string)SOMMalloc(strlen("") + 1);
  591.     // Copy the information into the structure
  592.     strcpy(info->partKindName , kClockKind);
  593.     strcpy(info->partKindDisplayName, kClockKindDisplayName);
  594.     strcpy(info->filenameFilters, "");
  595.     strcpy(info->filenameTypes, "");
  596.     strcpy(info->categories, kClockCategory);
  597.     strcpy(info->categoryDisplayName, "Sample");
  598.     strcpy(info->objectID, "");
  599.  
  600.  
  601.     ClockInfo._maximum = 1;
  602.     ClockInfo._length = 1;
  603.     ClockInfo._buffer = info;
  604.  
  605.     return ClockInfo;
  606.  
  607.  
  608.  
  609. }
  610.  
  611. SOM_Scope string  SOMLINK M_ClockclsGetOLE2ClassId(M_Clock *somSelf,
  612.                                                          Environment *ev)
  613. {
  614.     /* M_ClockData *somThis = M_ClockGetData(somSelf); */
  615.     M_ClockMethodDebug("M_Clock","M_ClockclsGetOLE2ClassId");
  616.  
  617.     // OLE2 Class ID is determined by running the tool UUIDGEN.EXE
  618.     // or GUIDGEN.EXE found in the IBM VAC++ SDK\BIN directory
  619.     // this tool is guaranteed to generate a unique ID based on your
  620.     // network address and the time of day (DCE Standard)
  621.  
  622.  
  623.     string classID = "{f135e430-de1a-11cf-9937-08005a88688b}";
  624.     string OLE2ClassId = (string)SOMMalloc(strlen(classID)+1);
  625.     strcpy(OLE2ClassId,classID);
  626.  
  627.     return classID;
  628. }
  629.  
  630. SOM_Scope string  SOMLINK M_ClockclsGetWindowsIconFileName(M_Clock *somSelf,
  631.                                                                  Environment *ev)
  632. {
  633.     /* M_ClockData *somThis = M_ClockGetData(somSelf); */
  634.     M_ClockMethodDebug("M_Clock","M_ClockclsGetWindowsIconFileName");
  635.  
  636.     string fileName = (string) SOMMalloc (strlen(kClockIconFileName)+1);
  637.     strcpy(fileName,kClockIconFileName);
  638.     return fileName;
  639. }
  640.  
  641.  
  642.  
  643.  
  644.