//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: oddynamicpart
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//

/*
 *  This file was generated by the SOM Compiler.
 *  Generated using:
 *     SOM incremental update: 2.24
 */


// @(#) 1.19 com/src/samples/dynamicp/ioddynam.cpp, oddynamicpart, od96nt, odnt9712d 2/18/97 13:54:26 [3/21/97 17:36:58]

//
//  File:      ioddynam.cpp
//  Contains:  Demonstration of the use of the internal transform.
//  $Source:   com/src/samples/dynamic/ioddynam.cpp $
//  $Revision: 1.0 $
//
// ************************************************************************



// ---- Dynamic Part ------------------------------------------------------
//
//      The embeddable Dynamic Part demonstrates the use of the OpenDoc
//      internal transformation matrix to affect rotation, horizontal shear
//      and vertical shear in a part.  It also demonstrates the
//      cross-platform development capabilities of OpenDoc when combined
//      with the IBM OpenClass libraries.
//
//      This code requires the IBM VisualAge C++ compiler with the
//      OpenClas libraries.
//
//

/*
 *  This file was generated by the SOM Compiler and Emitter Framework.
 *  Generated using:
 *      SOM Emitter emitxtm: 2.43
 */

#ifndef SOM_Module_dynamicp_Source
#define SOM_Module_dynamicp_Source
#endif

#define DynamicPart_Class_Source
#define M_DynamicPart_Class_Source

#include "ioddynam.xih"
#include "bregist/rtypestr.h"
#include "resource.h"
#include "ODResrc.h"

#include <math.h>

// OpenDoc includes
#include <arbitrat.xh>
#include <canvas.xh>
#include <clipbd.xh>
#include <CmdDefs.xh>
#include <draft.xh>
#include <facet.xh>
#include <FacetItr.xh>
#include <foci.xh>
#include <frame.xh>
#include <FrFaItr.xh>
#include <MenuBar.xh>
#include <ODSessn.xh>
#include <PlatCanv.xh>
#include <popup.xh>
#include <settings.xh>
#include <shape.xh>
#include <StdExts.xh>
#include <StdDefs.xh>
#include <StdProps.xh>
#include <StdTypes.xh>
#include <StorageU.xh>
#include <translt.xh>
#include <trnsform.xh>
#include <window.xh>
#include <WinIter.xh>
#include <WinStat.xh>

#include <ioddyext.xh>          // for ScriptableDynamicPartScrExt

// OpenDoc sample includes
#include <barray.h>
#ifdef _PLATFORM_OS2_
#include <focuslib.h>
#elif defined(_PLATFORM_WIN32_)
#include "myfocus.h"
#endif
#include <odmath.h>
#include <iodlink.xh>
#include <stdtypio.h>
#include <storutil.h>
#include <winutils.h>
#include <oddsemgr.xh>
#include <oddsconn.h>
#include <somtc.h>
#include <ODExcept.h>

// For menubar id
#ifdef _PLATFORM_AIX_
#include <odres.h>
#else
#include <ODRes.h>
#endif

#ifdef _PLATFORM_OS2_
#include <ODos2.h>
#elif defined(_PLATFORM_WIN32_)
  #include <windows.h>
  // override these OS/2 calls and macros
  // with their windows equivalents
  #define WinCreateMenu(parent, mtmpl) \
            CreateMenu()
  #define SHORT1FROMMP(mp) LOWORD(mp)
  #define HPS HDC
#endif

// OpenClass includes
#include <iexcbase.hpp>
#include <igrafctx.hpp>
#include <igrect.hpp>
#include <igregion.hpp>
#include <igstring.hpp>
#include <imsgbox.hpp>
#include <iwindow.hpp>

/*
*******************************************************************
** Name: static void Log(char *x, char *y)
**
** And redefine of: DynamicPartMethodDebug
**                  M_DynamicPartMethodDebug
**
** Description:  This function will output a message to the
**               utility MSGDISP.EXE (Windows) or PMprintf (OS/2)
**               for every call to the MethodDebug macros.  This
**               allows the developer to see the method calls
**               being made to this part in real-time.
**
** Parameters:   char *x;   //description of class
**               char *y;  //description of method
**
** Returns:      none
**
** Caution:      This function only exists if DEBUG is defined.
**
*******************************************************************
*/

// If debug is defined

#ifdef DEBUG
   #undef DynamicPartMethodDebug
   #undef M_DynamicPartMethodDebug

   #define DynamicPartMethodDebug(x,y) Log(x,y)
   #define M_DynamicPartMethodDebug(x,y) Log(x,y)
#endif // DEBUG

#ifdef _PLATFORM_WIN32_
   #include <qprintf.h>  // output to MSGDISP.EXE
#elif defined(_PLATFORM_OS2_)
   #include <stdio.h>
#endif

static void Log (char *x, char *y)
{
#ifdef DEBUG
   #ifdef _PLATFORM_WIN32_
      qprintf ("%s:%s\n", x, y);
   #elif defined(_PLATFORM_OS2_)
      printf ("%s:%s\n", x, y);
   #endif
#else
    static FILE *fp = fopen ("Dynamicp.log", "w");
    if (fp != NULL)
     {
        fprintf (fp, "%s:%s\n", x, y);
        fflush (fp);

        if (strcmp (y, "somUninit") == 0)
         {
            fclose (fp);
            fp = NULL;
         }
     }
#endif
}

// include constant definitions for calculating rotation transforms
#include "bxform/circonst.h"
const int drawXdimension = 500;
const int drawYdimension = 500;

#include "bdynamic/timerfns.h"

/*
*******************************************************************
** Name: void displayException
**
** Description:  This is a non-SOM function to trap exceptions
**               in OPENCLASS operations and display the exception
**               in a message box.
**
** Parameters:   the OpenClass exception object
**
*******************************************************************
*/

void displayException(IException &exc)
{
  const IExceptionLocation        *excLoc;
  IString                         fnString;
  IString                         msgTitle("IException caught in " +IString(__FILE__));
  ULONG                           maxLoc = exc.locationCount();

  //create string containing info from each of the function locations
  for (ULONG loop = 0;loop < maxLoc;++loop)
  {
    excLoc = exc.locationAtIndex(loop);
    fnString += "\n (" + IString(loop) + ") " + IString(excLoc->functionName()) + " LINE #" + IString(excLoc->lineNumber());
  }

  //create message string from exception text and function locations
  IString msgString(IString(exc.text()) + fnString);

  //display message box containing exception string
  if (exc.isRecoverable()) {
    Log(msgTitle, msgString);
  } else {
    IMessageBox aMessageBox(IWindow::desktopWindow());
    aMessageBox.setTitle(msgTitle);
    aMessageBox.show(msgString,IMessageBox::okButton | IMessageBox::errorIcon | IMessageBox::moveable);
  } /* endif */
}
#define reportIException(exc) \
     exc.addLocation(IEXCEPTION_LOCATION()),\
     exc.logExceptionData(),\
     displayException(exc)
#define reportAnyException(ev) \
     IException exc("Anonymous exception caught ", ev->_major, IException::recoverable);\
     if (ev->_major != NO_EXCEPTION) {exc.appendText(ev->exception._exception_name); somExceptionFree(ev);}\
     exc.addLocation(IEXCEPTION_LOCATION()),\
     exc.logExceptionData(),\
     displayException(exc)

//=====================================================================================
// Private Methods
//=====================================================================================

/*
*******************************************************************
** Name: void _set_xRotAngle
**
** Description:  Update the current rotation angle and modify
**               the internal transform to reflect new angle.
**
** Parameters:   xRotAngle - new angle of rotation .
**
*******************************************************************
*/
/*
 * current angle of rotation
 */

/*
 *Method from the IDL attribute statement:
 *"attribute ODFloat xRotAngle"
 */

SOM_Scope void  SOMLINK DynamicPart___set_xRotAngle(DynamicPart *somSelf,
                                                     Environment *ev,
                                                    ODFloat xRotAngle)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_xRotAngle");

    #include "bxform/xrotangl.c"
}

/*
*******************************************************************
** Name: void _set_hShearAngle
**
** Description:  Update the current horizontal shear angle and
**               modify the internal transform to reflect new angle.
**
** Parameters:   hShearAngle - new horizontal shear angle.
**
*******************************************************************
*/
/*
 *Method from the IDL attribute statement:
 *"attribute ODFloat hShearAngle"
 */

SOM_Scope void  SOMLINK DynamicPart___set_hShearAngle(DynamicPart *somSelf,
                                                       Environment *ev,
                                                      ODFloat hShearAngle)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_hShearAngle");

    #include "bxform/hshrangl.c"
}

/*
*******************************************************************
** Name: void _set_vShearAngle
**
** Description:  Update the current vertical shear angle and
**               modify the internal transform to reflect new angle.
**
** Parameters:   vShearAngle - new vertical shear angle.
**
*******************************************************************
*/
/*
 *Method from the IDL attribute statement:
 *"attribute ODFloat vShearAngle"
 */

SOM_Scope void  SOMLINK DynamicPart___set_vShearAngle(DynamicPart *somSelf,
                                                       Environment *ev,
                                                      ODFloat vShearAngle)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_vShearAngle");

    #include "bxform/vshrangl.c"
}

/*
 * are we scrolling?
 */

/*
 *Method from the IDL attribute statement:
 *"attribute ODBoolean scrolling"
 */

SOM_Scope void  SOMLINK DynamicPart___set_scrolling(DynamicPart *somSelf,
                                                     Environment *ev,
                                                    ODBoolean scrolling)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_scrolling");

    #include "bxform/setscrol.c"
}

/*
*******************************************************************
** Name: void _set_xRotateActive
**
** Description:  Update the flag that determines whether the
**               part will rotate.
**
** Parameters:   xRotateActive - should part rotate?
**
*******************************************************************
*/
/*
 * are we rotating?
 */

/*
 *Method from the IDL attribute statement:
 *"attribute ODBoolean xRotateActive"
 */

SOM_Scope void  SOMLINK DynamicPart___set_xRotateActive(DynamicPart *somSelf,
                                                         Environment *ev,
                                                        ODBoolean xRotateActive)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_xRotateActive");

    #include "bxform/rotactiv.c"
}

/*
*******************************************************************
** Name: void _set_hShearActive
**
** Description:  Update the flag that determines whether the
**               part will shear horizontally.
**
** Parameters:   hShearActive - should part shear?
**
*******************************************************************
*/
/*
 * are we changing horiz shear?
 */

/*
 *Method from the IDL attribute statement:
 *"attribute ODBoolean hShearActive"
 */

SOM_Scope void  SOMLINK DynamicPart___set_hShearActive(DynamicPart *somSelf,
                                                        Environment *ev,
                                                       ODBoolean hShearActive)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_hShearActive");

    #include "bxform/hshractv.c"
}

/*
*******************************************************************
** Name: void _set_vShearActive
**
** Description:  Update the flag that determines whether the
**               part will shear vertically.
**
** Parameters:   vShearActive - should part shear?
**
*******************************************************************
*/
/*
 * are we changing vert shear?
 */

/*
 *Method from the IDL attribute statement:
 *"attribute ODBoolean vShearActive"
 */

SOM_Scope void  SOMLINK DynamicPart___set_vShearActive(DynamicPart *somSelf,
                                                        Environment *ev,
                                                       ODBoolean vShearActive)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart___set_vShearActive");

    #include "bxform/vshractv.c"
}

/*
*******************************************************************
** Name: void CommonInit
**
** Description:  Common initialization code common to InitPart and
**               InitPartFromStorage
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CommonInit(DynamicPart *somSelf,
                                                 Environment *ev,
                                                ODPart* partWrapper)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CommonInit");

    #include "binit/icominit.c"
    #include "bdraw/dcominit.c"
    #include "bxform/xcominit.c"
    #include "bdynamic/ycominit.c"
    #include "bscript/scominit.c"

    DynamicPart_parent_SimplePart_CommonInit(somSelf, ev,partWrapper);
}

/*
*******************************************************************
** Name: void ScrollTicker
**
** Description:  Scrolls the message across the bottom of the
**               part in response to timer message.
**
** Parameters:   facet - the facet for which the message should
**                       scroll.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__ScrollTicker(DynamicPart *somSelf,
                                                   Environment *ev)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
//  DynamicPartMethodDebug("DynamicPart","DynamicPart__ScrollTicker");

    #include "bdraw/scroll.c"

}

/*
*******************************************************************
** Name: void RotateContent
**
** Description:  Modified the internal transform for all display
**               frames to affect rotation
**               and shearing within the part.
**
** Parameters:   byAngle - the (additional) angle by which to
**                         rotate the contents in all frames
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__RotateContent(DynamicPart *somSelf,
                                                    Environment *ev,
                                                   ODFloat byAngle)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__RotateContent");

    #include "bxform/hrotate.c"
    #include "bscript/notfyrot.c"
}

/*
*******************************************************************
** Name: void SetInternalXform
**
** Description:  Modified the internal transform to affect rotation
**               and shearing within the part
**
** Parameters:   facet - the facet which should be transformed
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__SetInternalXform(DynamicPart *somSelf,
                                                       Environment *ev,
                                                      ODFrame* frame)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__SetInternalXform");

    #include "bxform/setxform.c"

}

/*
*******************************************************************
** Name: void Reset
**
** Description:  Reset all transformations to default value
**               and stop rotation timer.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__Reset(DynamicPart *somSelf,
                                            Environment *ev)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__Reset");

    #include "bxform/xreset.c"
}

/*
*******************************************************************
** Name: void CloneContents
**
** Description:  Write the part's data into the given storage unit.
**               Called by Externalize and CloneInto.
**
** Parameters:   toSU - storage unit to write to.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CloneContents(DynamicPart *somSelf,
                                                    Environment *ev,
                                                   ODStorageUnit* toSU)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CloneContents");

    #include "binit/iexternz.c"
}

/*
*******************************************************************
** Name: ODFloat UpdateTransformAngles
**
** Description:  Updates _xRotAngle, _hShearAngle, and vShearAngle
**               as appropriate by angleDelta radians.
**
** Parameters:   angleDelta - the amount by which to update the
**                            rotation angle.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__UpdateTransformAngles(DynamicPart *somSelf,
                                                            Environment *ev,
                                                           ODFloat angleDelta)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__UpdateTransformAngles");

    #include "bxform/updxangl.c"
}

/*
*******************************************************************
** Name: void CalcNewShape
**
** Description:  Recalculate the active shape and used shape
**               to match the new internal transform.
**
** Parameters:   The facet, frame, and canvas for which
**               the active and used shapes must be computed.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CalcNewShape(DynamicPart *somSelf,
                                                   Environment *ev,
                                                  ODFrame* frame)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CalcNewShape");

    #include "bxform/xchgshap.c"
}

/*
*******************************************************************
** Name: void CalcRotationFactors
**
** Description:  Updates _xRotAngle, _hShearAngle, and vShearAngle
**               as appropriate by angleDelta radians.
**
** returns       sin and cos of rotation angle,
**               tangent of horizontal and vertical shear angles.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CalcRotationFactors(DynamicPart *somSelf,
                                                          Environment *ev,
                                                         ODFloat* rotSin,
                                                         ODFloat* rotCos,
                                                         ODFloat* hshTan,
                                                         ODFloat* vshTan)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CalcRotationFactors");

    #include "bxform/calcrotf.c"
}

/*
*******************************************************************
** Name: void AdjustSize
**
** Description:  Frame negotiation
**
** Parameters:   The frame and facet whose size is being
**               updated.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__AdjustSize(DynamicPart *somSelf,
                                                 Environment *ev,
                                                ODFrame* frame,
                                                ODFacet* facet)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__AdjustSize");

    #include "bimaglay/dchgsize.c"
}

//=====================================================================================
// end Private Methods
//=====================================================================================




//=====================================================================================
// Override of ODPart Methods
//=====================================================================================

/*
*******************************************************************
** Name: void InstallMenus
**
** Description:  Override method to Install Menus
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__InstallMenus(DynamicPart *somSelf,
                                                   Environment *ev)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__InstallMenus");

    #include "bmenu/instlmnu.c"

}

/*
*******************************************************************
** Name: void AdjustMenus
**
** Description:  override method to update menus before displaying
**               them.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__AdjustMenus(DynamicPart *somSelf,
                                                  Environment *ev,
                                                 ODFrame* frame)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__AdjustMenus");

    #include "bmenu/madjmenu.c"
    #include "bclipbrd/cladjmnu.c"
}

/*
*******************************************************************
** Name: ODBoolean HandleMenuEvent
**
** Description:  override (SimplePart) of method to handle events
**               from menu commands.
**
** Returns:      kODTRUE if the event was handled, otherwise kODFALSE.
**
*******************************************************************
*/
SOM_Scope ODBoolean  SOMLINK DynamicPart__HandleMenuEvent(DynamicPart *somSelf,
                                                           Environment *ev,
                                                          ODFrame* FocusFrame,
                                                          ODEventData* event)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__HandleMenuEvent");

    ODBoolean handled = kODFalse;

    // Check for Dynamic Transform menu events (Rotate, VerticalShear, HorizontalShear)
    #include "bmenu/mnuevt.c"

    // If it wasn't a transform event, check for clipboard events.
    if (!handled) {
    #include "bclipbrd/clpmnuev.c"
    } /* endif */

    // We don't handle this menu event - send the event to our parent.
    if (!handled) {
       handled=DynamicPart_parent_SimplePart_HandleMenuEvent(somSelf,
                                                         ev,
                                                         FocusFrame,
                                                         event);
    } /* endif */

    return handled;

}

/*
*******************************************************************
** Name: void CloneInto
**
** Description:  override method to allow the part to clone
**               itself into a specified storage unit.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CloneInto(DynamicPart *somSelf,
                                                Environment *ev,
                                               ODDraftKey key,
                                               ODStorageUnit* toSU,
                                               ODFrame* scope)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CloneInto");

    somSelf->CloneContents(ev, toSU);
    DynamicPart_parent_SimplePart_CloneInto(somSelf, ev, key,
                                            toSU, scope);
}

/*
*******************************************************************
** Name: void ContainingPartPropertiesUpdated
**
** Description:  Notification when one of the containing part's
**               properties changes.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__ContainingPartPropertiesUpdated(DynamicPart *somSelf,
                                                                      Environment *ev,
                                                                     ODFrame* frame,
                                                                     ODStorageUnit* propertyUnit)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__ContainingPartPropertiesUpdated");

    #include "bimaglay/cpropupd.c"
    DynamicPart_parent_SimplePart_ContainingPartPropertiesUpdated(somSelf,
                                                                  ev,
                                                                  frame,
                                                                  propertyUnit);
}

/*
*******************************************************************
** Name: void Draw
**
** Description:  override method to draw the part's content.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__Draw(DynamicPart *somSelf,
                                           Environment *ev, ODFacet* facet,
                                          ODShape* invalidShape)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__Draw");

    #include "bdraw/draw.c"
}

/*
*******************************************************************
** Name: void Externalize
**
** Description:  override method to allow the part to save its
**               intrinsic content to its storage unit.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__Externalize(DynamicPart *somSelf,
                                                  Environment *ev)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__Externalize");

    ODStorageUnit *storageUnit = somSelf->GetStorageUnit(ev);
    somSelf->CloneContents(ev, storageUnit);

    DynamicPart_parent_SimplePart_Externalize(somSelf, ev);
}

/*
*******************************************************************
** Name: void FacetAdded
**
** Description:  override method called when a facet is added to
**               the part.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__FacetAdded(DynamicPart *somSelf,
                                                 Environment *ev,
                                                ODFacet* facet)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__FacetAdded");

    DynamicPart_parent_SimplePart_FacetAdded(somSelf, ev, facet);
    #include "bimaglay/ifacetad.c"
    #include "bimaglay/getcprop.c"
    #include "bdynamic/dfacetad.c"
    #include "bxform/xfacetad.c"
}

/*
*******************************************************************
** Name: void FacetRemoved
**
** Description:  override method called when a facet is removed
**               from the part.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__FacetRemoved(DynamicPart *somSelf,
                                                   Environment *ev,
                                                  ODFacet* facet)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__FacetRemoved");

    DynamicPart_parent_SimplePart_FacetRemoved(somSelf, ev, facet);
    #include "bdynamic/facetrem.c"
}

/*
*******************************************************************
** Name: void FrameShapeChanged
**
** Description:  override method called when the part's frame
**               shape changes.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__FrameShapeChanged(DynamicPart *somSelf,
                                                        Environment *ev,
                                                       ODFrame* frame)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__FrameShapeChanged");

    DynamicPart_parent_SimplePart_FrameShapeChanged(somSelf,
                                                    ev, frame);
    #include "bimaglay/tframchg.c"
}

/*
*******************************************************************
** Name: void InitPart
**
** Description:  Initialize a part when it is created dynamically
**               (i.e. via new).
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__InitPart(DynamicPart *somSelf,
                                               Environment *ev,
                                              ODStorageUnit* storageUnit,
                                              ODPart* partWrapper)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__InitPart");

    DynamicPart_parent_SimplePart_InitPart(somSelf, ev, storageUnit,
                                           partWrapper);
    #include "binit/iintpart.c"
}

/*
*******************************************************************
** Name: void InitPartFromStorage
**
** Description:  Initialize a part from storage.  Allows a part
**               to "read in" its data.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__InitPartFromStorage(DynamicPart *somSelf,
                                                          Environment *ev,
                                                         ODStorageUnit* storageUnit,
                                                         ODPart* partWrapper)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__InitPartFromStorage");

    DynamicPart_parent_SimplePart_InitPartFromStorage(somSelf,
                                                      ev, storageUnit,
                                                      partWrapper);
    #include "binit/iinitpfs.c"
}

/*
*******************************************************************
** Name: void ViewTypeChanged
**
** Description:  Handle the part's viewtype being changed.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__ViewTypeChanged(DynamicPart *somSelf,
                                                      Environment *ev,
                                                     ODFrame* frame)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__ViewTypeChanged");

    ODTypeToken viewType = frame->GetViewType(ev);
    if(viewType != _fSession->Tokenize(ev,kODViewAsFrame)) {
       // DynamicPart currently only supports frame view.
       frame->SetViewType(ev, _fSession->Tokenize(ev,kODViewAsFrame));
       return;
    } /* endif */
}

/*
*******************************************************************
** Name: void CreateIcons
**
** Description:  Load the part's icon from the DLL
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__CreateIcons(DynamicPart *somSelf,
                                                   Environment *ev)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__CreateIcons");

    somSelf->LoadIconsFromModule(ev,
                                 "ioddynam",
                                 kODIcon);
}


/*
*******************************************************************
** Name: void somDefaultInit
**
** Description:  override method to do basic initialization.
**               Equivalent to a c++ default constructor.
**               This method should not perform ANY action that
**               might fail.
**
*******************************************************************
*/
SOM_Scope void SOMLINK DynamicPart__somDefaultInit(DynamicPart *somSelf,
                                                   somInitCtrl* ctrl)
{
    DynamicPartData *somThis; /* set in BeginInitializer */
    somInitCtrl globalCtrl;
    somBooleanVector myMask;
    DynamicPartMethodDebug("DynamicPart","somDefaultInit");
    DynamicPart_BeginInitializer_somDefaultInit;

    DynamicPart_Init_ODDSConnection_somDefaultInit(somSelf, ctrl);
    DynamicPart_Init_SimplePart_somDefaultInit(somSelf, ctrl);

    /*
     * local DynamicPart initialization code added by programmer
     */
    #include "binit/isominit.c"
}


/*
*******************************************************************
** Name: void somDestruct
**
** Description:  override method to deallocate any resources
**               as part of part de-initialization.
**
*******************************************************************
*/
SOM_Scope void SOMLINK DynamicPart__somDestruct(DynamicPart *somSelf,
                                                octet doFree,
                                                somDestructCtrl* ctrl)
{
    DynamicPartData *somThis; /* set in BeginDestructor */
    somDestructCtrl globalCtrl;
    somBooleanVector myMask;
    DynamicPartMethodDebug("DynamicPart","DynamicPart__somDestruct");
    DynamicPart_BeginDestructor;

    /*
     * local DynamicPart deinitialization code added by programmer
     */
    #include "binit/idestrct.c"
    #include "bscript/sdestrct.c"

    DynamicPart_EndDestructor;
}
/*
*******************************************************************
** Name: ODBoolean HasExtension
**
**
*******************************************************************
*/
SOM_Scope ODBoolean  SOMLINK DynamicPart__HasExtension(DynamicPart *somSelf,
                                                       Environment *ev,
                                                       ODType extensionName)
{
   DynamicPartData *somThis = DynamicPartGetData(somSelf);
   DynamicPartMethodDebug("DynamicPart","DynamicPartHasExtension");

   ODBoolean RetVal ;

   try
   {
     if (strcmp(extensionName, kODScriptExtension)== 0)
     {
       RetVal = kODTrue ;
     }
     else
     {
       RetVal = DynamicPart_parent_SimplePart_HasExtension(somSelf,
                                                           ev,
                                                           extensionName);
     }
   }
   catch(ODException _exception)
   {
   }

   return RetVal ;

}
/*
*******************************************************************
** Name: ODBoolean AcquireExtension
**
**
*******************************************************************
*/
SOM_Scope ODExtension*  SOMLINK DynamicPart__AcquireExtension(DynamicPart *somSelf,
                                                              Environment *ev,
                                                              ODType extensionName)
{
    ODExtension *RetVal ;

    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPartAcquireExtension");

    try
    {
      if (strcmp(extensionName, kODScriptExtension)== 0)
      {
         if (_fScriptExtension == kODNULL)
         {
            _fScriptExtension = new ScriptableDynamicPartScrExt ;
            if (_fScriptExtension)
            {
              _fScriptExtension->InitScriptExtension(ev, somSelf) ;
            }
         }
         if (_fScriptExtension != NULL)
         { _fScriptExtension->Acquire(ev) ; }

         RetVal = (ODExtension *) _fScriptExtension ;
      }
      else
      {
        RetVal = DynamicPart_parent_SimplePart_AcquireExtension(somSelf,
                                                                ev,
                                                                extensionName);
      }
    }
    catch(ODException _exception)
    {
    }

    return (RetVal) ;

}
/*
*******************************************************************
** Name: ODBoolean ReleaseExtension
**
**
*******************************************************************
*/

SOM_Scope void  SOMLINK DynamicPart__ReleaseExtension(DynamicPart *somSelf,
                                                      Environment *ev,
                                                      ODExtension* extension)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPartReleaseExtension");

    try
    {
      if (extension == (ODExtension *) _fScriptExtension)
      {
        delete _fScriptExtension ;
        _fScriptExtension = NULL ;
      }
      else
      {
        DynamicPart_parent_SimplePart_ReleaseExtension(somSelf,
                                                       ev,
                                                       extension);
      }
    }
    catch(ODException _exception)
    {
    }
}

/*
*******************************************************************
** Name: void somDumpSelfInt
**
** Description:  override method to dump the part's relevant
**               intrinsic data in a human readable format.
**
*******************************************************************
*/
SOM_Scope void  SOMLINK DynamicPart__somDumpSelfInt(DynamicPart *somSelf,
                                                    long level)
{
    DynamicPartData *somThis = DynamicPartGetData(somSelf);
    DynamicPartMethodDebug("DynamicPart","DynamicPart__somDumpSelfInt");

    DynamicPart_parent_SimplePart_somDumpSelfInt(somSelf, level);

    somLPrintf(level, "{Rotation is ");
    if (_xRotateActive) {
      somPrintf("active ");
    } else {
      somPrintf("inactive ");
    } /* endif */
    if (_xRotateClockwise) {
      somPrintf("turning clockwise ");
    } else {
      somPrintf("turning counter-clockwise ");
    } /* endif */
    somPrintf("at %#3.2f degrees.}\n", _xRotAngle * 180 / pi);

    somLPrintf(level, "{Horizontal shear is ");
    if (_hShearActive) {
      somPrintf("active ");
    } else {
      somPrintf("inactive ");
    } /* endif */
    if (_hShearRight) {
      somPrintf("shearing right ");
    } else {
      somPrintf("shearing left ");
    } /* endif */
    somPrintf("at %#3.2f degrees.}\n", _hShearAngle * 180 / pi);

    somLPrintf(level, "{Vertical shear is ");
    if (_vShearActive)  {
      somPrintf("active ");
    } else {
      somPrintf("inactive ");
    } /* endif */
    if (_vShearUp) {
      somPrintf("shearing up ");
    } else {
      somPrintf("shearing down ");
    } /* endif */
    somPrintf("at %#3.2f degrees.}\n", _vShearAngle * 180 / pi);

    somLPrintf(level, "{Each %ims timer tick advances rotation by %#3.2f degrees}\n", _rotateTimerRate, _xAngleDelta * 180 / pi);

    somLPrintf(level, "{Scrolling text is:'%s'}\n", (char *)_Message->text());
    somLPrintf(level, "{Each %ims timer tick advances text by %i pels}\n", _scrollTimerRate, _JumpRate);
    somLPrintf(level, "{Scrolling is currently ");
    if (_scrolling) {
      somPrintf("active ");
    } else {
      somPrintf("inactive ");
    } /* endif */
    somPrintf("at %i}\n", _ScrollPos);

    if (_customBackground) {
      somLPrintf(level, "{Custom BackColor is ");
    } else {
      somLPrintf(level, "{Default BackColor is ");
    } /* endif */
    somPrintf("(R)%u,(G)%u,(B)%u}\n", _BackColor.redMix(), _BackColor.greenMix(), _BackColor.blueMix());

    if (_customTextColor) {
      somLPrintf(level, "{Custom TextColor is ");
    } else {
      somLPrintf(level, "{Default TextColor is ");
    } /* endif */
    somPrintf("(R)%u,(G)%u,(B)%u}\n", _TextColor.redMix(), _TextColor.greenMix(), _TextColor.blueMix());

    if (_customFont) {
      somLPrintf(level, "{Custom Font is");
    } else {
      somLPrintf(level, "{Default Font is ");
    } /* endif */
    somPrintf("%s}\n", (char *)_Font->name());
}


//=====================================================================================
// End Override of ODPart Methods
//=====================================================================================




//=====================================================================================
// Override of M_ODPart Methods
//=====================================================================================

/*
*******************************************************************
** Name: ISOString clsGetODPartHandlerName
**
** Description:  Override method to get the part handler name from
**               the metaclass.
**
** Returns:      returns the part handler name.
**               It is the caller's responsibility to deallocate
**               the memory used.
**
*******************************************************************
*/

SOM_Scope ISOString  SOMLINK M_DynamicPart__clsGetODPartHandlerName(M_DynamicPart *somSelf,
                                                                     Environment *ev)
{
    /* M_DynamicPartData *somThis = M_DynamicPartGetData(somSelf); */
    M_DynamicPartMethodDebug("M_DynamicPart","M_DynamicPart__clsGetODPartHandlerName");

    #include "bregist/rgetphnm.c"
}

/*
*******************************************************************
** Name: string clsGetODPartHandlerDisplayName
**
** Description:  Override method to get the part handler display
**               name from the metaclass.
**
** Returns:      returns the part handler dispaly name.
**               It is the caller's responsibility to deallocate
**               the memory used.
**
*******************************************************************
*/

SOM_Scope string  SOMLINK M_DynamicPart__clsGetODPartHandlerDisplayName(M_DynamicPart *somSelf,
                                                                         Environment *ev)
{
    /* M_DynamicPartData *somThis = M_DynamicPartGetData(somSelf); */
    M_DynamicPartMethodDebug("M_DynamicPart","M_DynamicPart__clsGetODPartHandlerDisplayName");

    #include "bregist/rgetdspn.c"
}

/*
*******************************************************************
** Name: _IDL_SEQUENCE_PartKindInfo clsGetODPartKinds
**
** Description:  Override method to determine the part kinds this
**               part handler is capable of handling.
**
** Returns:      returns a list of PartKindInfo structures.
**               It is the caller's responsibility to deallocate
**               the memory used.
**
*******************************************************************
*/

SOM_Scope _IDL_SEQUENCE_PartKindInfo  SOMLINK M_DynamicPart__clsGetODPartKinds(M_DynamicPart *somSelf,
                                                                                Environment *ev)
{
    /* M_DynamicPartData *somThis = M_DynamicPartGetData(somSelf); */
    M_DynamicPartMethodDebug("M_DynamicPart","M_DynamicPart__clsGetODPartKinds");

    #include "bregist/rgetkind.c"
}

/*
*******************************************************************
** Name: string clsGetOLE2ClassId
**
** Description:  Override method to get the OLE2 Class id from
**               the metaclass.
**
** Returns:      returns the OLE2 class id.
**               It is the caller's responsibility to deallocate
**               the memory used.
**
*******************************************************************
*/

SOM_Scope string  SOMLINK M_DynamicPart__clsGetOLE2ClassId(M_DynamicPart *somSelf,
                                                            Environment *ev)
{
    /* M_DynamicPartData *somThis = M_DynamicPartGetData(somSelf); */
    M_DynamicPartMethodDebug("M_DynamicPart","M_DynamicPart__clsGetOLE2ClassId");

    #include "bregist/rgetole2.c"
}

/*
*******************************************************************
** Name: string clsGetWindowsIconFileName
**
** Description:  Override method to get the windows icon file name
**               from the metaclass.
**
** Returns:      returns the Windows Icon file name
**               It is the caller's responsibility to deallocate
**               the memory used.
**
*******************************************************************
*/

SOM_Scope string  SOMLINK M_DynamicPart__clsGetWindowsIconFileName(M_DynamicPart *somSelf,
                                                                    Environment *ev)
{
    /* M_DynamicPartData *somThis = M_DynamicPartGetData(somSelf); */
    M_DynamicPartMethodDebug("M_DynamicPart","M_DynamicPart__clsGetWindowsIconFileName");

    #include "bregist/rgeticon.c"
}


//=====================================================================================
// End Override of M_ODPart Methods
//=====================================================================================


//=====================================================================================
//=====================================================================================
// End listing of DynamicP.cpp
//=====================================================================================
//=====================================================================================
