home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / grafpart / graph_cm.cpp next >
Text File  |  1997-04-02  |  77KB  |  1,836 lines

  1. // @(#) 1.5 com/src/samples/grafpart/graph_cm.cpp, odgrafpart, od96os2, odos29712d 2/7/97 17:41:33 [3/21/97 17:49:31]
  2. /*====START_GENERATED_PROLOG======================================
  3. */
  4. /*
  5.  *   COMPONENT_NAME: odgrafpart
  6.  *
  7.  *   CLASSES: GrafPart
  8.  *
  9.  *   ORIGINS: 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. //  Contains:  Class implementation for a 2D-Drawing Container Part
  31. // ************************************************************************
  32.  
  33. // Part Developers NOTE:
  34. //   This file contains the kernel of the implementation for a
  35. // GrafPart class, but is extended to be used in two ways:
  36. //   It may be included into the source with the preprocessor symbol
  37. // "_Scriptable_GP_" not defined, (e.g., by iodgraph.cpp),
  38. // where it will produce the GrafPart class; or
  39. //   It may be included into the source with the preprocessor symbol
  40. // "_Scriptable_GP_" defined, (e.g., by iodscrgp.cpp),
  41. // where it will produce the ScriptableGraphPart class.
  42. //
  43. // The following macros must be defined in one of the two ways to
  44. // generate the correct classname in the method declarations and output.
  45. //      GP_P(x) used when <classname> is a prefix of x
  46. //      GP_Pq(x) used when <classname> is a prefix of x in a quoted string
  47. //      GP_C the classname
  48. //      GP_Cq the classname in quotes
  49. #ifndef _Scriptable_GP_
  50.     #define GP_P(n)    GrafPart##n
  51.     #define GP_Pq(n)  "GrafPart##n"
  52.     #define GP_C       GrafPart
  53.     #define GP_Cq     "GrafPart"
  54. #else
  55.     #define GP_P(n)    ScriptableGraphPart##n
  56.     #define GP_Pq(n)  "ScriptableGraphPart##n"
  57.     #define GP_C       ScriptableGraphPart
  58.     #define GP_Cq     "ScriptableGraphPart"
  59. #endif
  60.  
  61.  
  62.  
  63. #ifndef SOM_Module_GrafPart_Source
  64.     #define SOM_Module_GrafPart_Source
  65. #endif   // SOM_Module_GrafPart_Source
  66.  
  67. // GrafPart's includes
  68. #ifndef _IODGCOMM_CPP_
  69.    #include <iodgcomm.cpp>
  70. #endif   // _IODGCOMM_CPP_
  71.  
  72. // GrafPart's defines & constants
  73. #ifndef _IODGRAPH_HPP_
  74.    #include <iodgraph.hpp>
  75. #endif   // _IODGRAPH_HPP_
  76.  
  77. // support use of temporary objects (DrawContents, HandleMouse*)
  78. #ifndef _TEMPOBJ_
  79.     #include <TempObj.h>
  80. #endif // _TEMPOBJ_
  81.  
  82. // support CFocus (DrawContents)
  83. #ifndef _FOCUSLIB_
  84.     #include <FocusLib.h>
  85. #endif // _FOCUSLIB_
  86.  
  87. // support Storage Units (Read/WriteKindInfo)
  88. #ifndef _STORUTIL_
  89.     #include <StorUtil.h>
  90. #endif // _STORUTIL_
  91.  
  92. // includes for native drawing functions
  93. #if defined(_PLATFORM_WIN32_)
  94.     #include <windows.h>
  95.     #include <winuser.h>
  96.     #include <wingdi.h>
  97. #elif defined(_PLATFORM_OS2_)
  98.     #include <ODos2.h>
  99. #endif // _PLATFORM_???_
  100.  
  101.  
  102. // local function support includes
  103. #ifndef SOM_ContentGrafPartFigr_xh
  104.     #include "iodgfigr.xh"
  105. #endif // SOM_ContentGrafPartFigr_xh
  106.  
  107. #ifndef SOM_ContentGrafPartPoin_xh
  108.     #include "iodgpoin.xh"
  109. #endif // SOM_ContentGrafPartPoin_xh
  110.  
  111. #ifndef SOM_ContentGrafPartLine_xh
  112.     #include "iodgline.xh"
  113. #endif // SOM_ContentGrafPartLine_xh
  114.  
  115. #ifndef SOM_ContentGrafPartRect_xh
  116.     #include "iodgrect.xh"
  117. #endif // SOM_ContentGrafPartRect_xh
  118.  
  119. #ifndef SOM_ContentGrafPartText_xh
  120.     #include "iodgtext.xh"
  121. #endif // SOM_ContentGrafPartText_xh
  122.  
  123.  
  124. // =========================================================================
  125. //
  126. //     Global helper Functions: GrafPart
  127. //
  128. // =========================================================================
  129.  
  130. // -------------------------------------------------------------------------
  131. // FirstFacet
  132. //
  133. //     Global helper function: return the first facet associated with a frame
  134. // -------------------------------------------------------------------------
  135. ODFacet*    FirstFacet( Environment*    ev,
  136.                         ODFrame*        frame)
  137. {
  138.     SQUAWK("> Invoked %s(Global)::FirstFacet()\n", GP_Cq);
  139.  
  140.     ODFacet*    facet;
  141.  
  142.     try
  143.     {
  144.         ODFrameFacetIterator *ffitr  = frame->CreateFacetIterator(ev);
  145.         facet = (ODFacet *)ffitr->First(ev);
  146.         ODDeleteObject(ffitr);
  147.     }   // try
  148.  
  149.     catch(...)
  150.     {
  151.         SQUAWK("\t%s(Global)::FirstFacet(): CAUGHT EXCEPTION\n", GP_Cq);
  152.     }
  153.  
  154.     SQUAWK("< Leaving %s(Global)::FirstFacet()\n", GP_Cq);
  155.     return facet;
  156. }   // FirstFacet()
  157.  
  158.  
  159. // -------------------------------------------------------------------------
  160. //  FluffRect
  161. //
  162. //     Global helper function: expand a rectangle by one pixel in each direction
  163. // -------------------------------------------------------------------------
  164. ODRect* FluffRect(  ODRect*  rect)
  165. {
  166.     SQUAWK("> Invoked %s(Global)::FluffRect()\n", GP_Cq);
  167.  
  168.     ODFixed one   = ODIntToFixed(1);
  169.  
  170. #ifdef _PLATFORM_OS2_                   // OS2 origin is LLC
  171.     rect->top    += one;
  172.     rect->bottom -= one;
  173. #else                                   // everyone else's origin is ULC
  174.     rect->top    -= one;
  175.     rect->bottom += one;
  176. #endif  // _PLATFORM_OS2_
  177.     rect->left   -= one;
  178.     rect->right  += one;
  179.  
  180.     SQUAWK("< Leaving %s(Global)::FluffRect()\n", GP_Cq);
  181.     return rect;
  182. }   // FluffRect()
  183.  
  184.  
  185. // -------------------------------------------------------------------------
  186. //  GetPoint
  187. //
  188. //     Global helper function: update a point with current cursor position
  189. // -------------------------------------------------------------------------
  190. void    GetPoint(   Environment*    ev,
  191.                     ODFacet*        facet,
  192.                     ODEventData*    event,
  193.                     ODPoint*        point)
  194. {
  195.     SQUAWK("> Invoked %s(Global)::GetPoint()\n", GP_Cq);
  196.  
  197.     // Get the containing frame's windowframe transform
  198.     TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  199.  
  200.     try
  201.     {
  202.         // collect the current point (in HDraw coords)
  203. #ifdef _PLATFORM_OS2_
  204.         point->x = ODIntToFixed(SHORT1FROMMP(event->mp1));
  205.         point->y = ODIntToFixed(SHORT2FROMMP(event->mp1));
  206. #else
  207.         point->x = ODIntToFixed(LOWORD(event->lParam));
  208.         point->y = ODIntToFixed(HIWORD(event->lParam));
  209. #endif  // _PLATFORM_OS2_
  210.  
  211.         // Invert the HDraw coords into containing frame coords
  212.         xform->InvertPoint(ev, point);
  213.  
  214.     }   // try
  215.  
  216.     catch(...)
  217.     {
  218.         SQUAWK("\t%s(Global)::GetPoint(): CAUGHT EXCEPTION\n", GP_Cq);
  219.     }
  220.  
  221.     SQUAWK("< Leaving %s(Global)::GetPoint()\n", GP_Cq);
  222.  
  223. }   // GetPoint()
  224.  
  225.  
  226. // *************************************************************************
  227. //
  228. //  Class implementation:
  229. //
  230. // *************************************************************************
  231.  
  232.  
  233. // =========================================================================
  234. //
  235. //     Public override methods: GrafPart
  236. //
  237. // =========================================================================
  238.  
  239. // -------------------------------------------------------------------------
  240. // GrafPart --> somInit
  241. //
  242. //     Initialization used at registration time
  243. //
  244. //     -> public override method
  245. //     -> calls parent first
  246. // -------------------------------------------------------------------------
  247. SOM_Scope   void    SOMLINK GP_P(somInit) (GP_C *somSelf )
  248. {
  249.     SQUAWK("> Invoked %s::somInit()\n", GP_Cq);
  250.  
  251.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  252.     GP_P(MethodDebug) (GP_Cq , GP_Pq(somInit) );
  253.  
  254.     // call parent method
  255.     parent_somInit(somSelf) ;
  256.  
  257.     // initialize attributes
  258.     _fMenuBar     = kODNULL;
  259.     _fSession     = kODNULL;
  260.     _fPartWrapper = kODNULL;
  261.  
  262.     // initalize instance data (these are repeated in Reset() )
  263.     _fAction      = kODCommandGrafPartSelect;
  264.     _fActionType  = kODSingleAction;
  265.     _fCurrObj     = kODNULL;
  266.     _fCurrObjType = kODNULL;
  267.     _fCurrShape   = kODNULL;
  268.     _fTempShape   = kODNULL;
  269.     memset(&_fPt, 0, sizeof(ODPoint) );
  270.  
  271.     SQUAWK("< Leaving %s::somInit()\n", GP_Cq);
  272. }   // somInit()
  273.  
  274.  
  275. // -------------------------------------------------------------------------
  276. // GrafPart --> somUninit
  277. //
  278. //     Uninitialization used at registration time
  279. //
  280. //     -> public override method
  281. //     -> calls parent last, after intrinsics are deleted
  282. // -------------------------------------------------------------------------
  283. SOM_Scope   void    SOMLINK GP_P(somUninit) (  GP_C  *somSelf )
  284. {
  285.     SQUAWK("> Invoked %s::somUninit()\n", GP_Cq);
  286.  
  287.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  288.     GP_P(MethodDebug) ( GP_Cq , GP_Pq(somUninit) );
  289.  
  290.     // delete all intrinsic content
  291.  
  292.     Environment* ev = somGetGlobalEnvironment();            // get the environment into a buffer
  293.     ALinkedList* sList = somSelf->GetSelectedObjects(ev);   // get the list of selected objects
  294.     ALinkedList* eList = somSelf->GetEmbeddedObjects(ev);   // get the list of embedded objects
  295.     ALink *eIter;                                           // define an iterator on the embedded list
  296.     ContentGrafPartFigr*    figr;                           // declare a buffer for a intrinsic object
  297.     ODULong                 coType;                         // declare a buffer for a intrinsic type
  298.  
  299.     for(eIter = eList->First(ev);                           // for each object in the embedded list
  300.         eIter->Content(ev);
  301.         eIter = eIter->Next(ev) )
  302.     {
  303.         figr = (ContentGrafPartFigr *) eIter->Content(ev);  // treat it as intrinsic object
  304.         coType = figr->_get_objType(ev);                    // store the specific type
  305.  
  306.         if ( ( coType >  COBJ_GRAFPART_FIGR ) &&            // if it is GP-intrinsic content
  307.              ( coType <= COBJ_GRAFPART_LAST ) )
  308.         {
  309.             figr->Uninitialize(ev);                         // unsetup the figure
  310.             delete figr;                                    // deallocate the figure
  311.         }   // if: intrinsic content?
  312.         else
  313.         {
  314.             SQUAWK("\t%s::somUninit(): unrecognized content object type: %d\n", GP_Cq, coType );
  315.         }   // else: intrinsic content?
  316.     }   // for: each embedded object
  317.  
  318.     // all intrinsics are gone, so call parent last
  319.     parent_somUninit(somSelf);
  320.  
  321.     SQUAWK("< Leaving %s::somUninit()\n", GP_Cq);
  322.     return;
  323. }   // somUninit()
  324.  
  325.  
  326. // -------------------------------------------------------------------------
  327. // GrafPart --> Initialize
  328. //
  329. //     Class-specific initialization used at run time
  330. //
  331. //     -> public override method
  332. //     -> calls parent first
  333. // -------------------------------------------------------------------------
  334. SOM_Scope   void    SOMLINK GP_P(Initialize) ( GP_C    *somSelf,
  335.                                                 Environment *ev,
  336.                                                 ODPart      *partWrapper )
  337. {
  338.     SQUAWK("> Invoked %s::Initialize()\n", GP_Cq);
  339.  
  340.     // initialize self pointers
  341.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  342.     GP_P(MethodDebug) ( GP_Cq , GP_Pq(Initialize) );
  343.  
  344.     // call parent's Initialization
  345.     parent_Initialize(somSelf,ev,partWrapper);
  346.  
  347.     // Cache references to Session object and other global values
  348.     _fSession = somSelf->GetStorageUnit(ev)->GetSession(ev);
  349.  
  350.     // Create MenuBar  Part
  351.     _fMenuBar = somSelf->GetMenuBar(ev);
  352.  
  353.     SQUAWK("< Leaving %s::Initialize()\n", GP_Cq);
  354.     return;
  355. }   // Initialize()
  356.  
  357.  
  358. // -------------------------------------------------------------------------
  359. // GrafPart --> WriteIconToSU
  360. //
  361. //     Write the Icon to the storage unit for display in stationery
  362. //
  363. //     -> public override method
  364. //     -> does not call parent
  365. // -------------------------------------------------------------------------
  366. SOM_Scope   void    SOMLINK GP_P(WriteIconToSU) ( GP_C *somSelf,
  367.                                                         Environment*    ev,
  368.                                                         ODStorageUnit*  toSU )
  369. {
  370.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  371.     GP_P(MethodDebug) (GP_Cq , GP_Pq(WritePartInfo) );
  372.  
  373.     SQUAWK("> Invoked %s::WriteIconToSU()\n", GP_Cq);
  374.  
  375.     // Customized icon support for OS2.
  376. #ifdef _PLATFORM_OS2_
  377.     SQUAWK("\t%s::WriteIconToSU(): performing OS/2-specific icon setup\n", GP_Cq);
  378.     HMODULE hmod;
  379.     ULONG cbIconSize;
  380.     PBYTE pIconData = NULL;
  381.     CHAR Error[256] = "";
  382.  
  383.     DosLoadModule(Error, sizeof(Error), "iodgraph", &hmod);
  384.  
  385.     if ( !DosQueryResourceSize( hmod, RT_POINTER, kODIcon, &cbIconSize) &&
  386.          !DosGetResource( hmod, RT_POINTER, kODIcon, (PPVOID)&pIconData)  )
  387.     {
  388.         if ( ODSUExistsThenFocus (ev, toSU, kODPropIconFamily, kODIconFamily) )
  389.             toSU->Remove (ev);
  390.         ODSUAddPropValue (ev, toSU, kODPropIconFamily, kODIconFamily);
  391.         StorageUnitSetValue( toSU, ev, cbIconSize, (ODValue)pIconData );
  392.         DosFreeResource(pIconData);
  393.     }
  394.     else
  395.     {
  396.         SQUAWK("\t%s::WriteIconToSU(): DosGetResource failed!\n", GP_Cq);
  397.     }
  398. #endif // _PLATFORM_OS2_
  399.  
  400.     SQUAWK("< Leaving %s::WriteIconToSU()\n", GP_Cq);
  401.     return;
  402. }   // WriteIconToSU()
  403.  
  404.  
  405. // -------------------------------------------------------------------------
  406. // GrafPart --> InstallMenuItems
  407. //
  408. //     Install additional items in pull-down menu.
  409. //
  410. //     -> public override method
  411. //     -> calls parent last, if not handled locally
  412. // -------------------------------------------------------------------------
  413. SOM_Scope   void    SOMLINK GP_P(InstallMenuItems) (   GP_C    *somSelf,
  414.                                                         Environment *ev,
  415.                                                         ODMenuBar   *menuBar )
  416. {
  417.     SQUAWK("> Invoked %s::InstallMenuItems()\n", GP_Cq);
  418.  
  419.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  420.     GP_P(MethodDebug) (GP_Cq,GP_Pq(InstallMenuItems) );
  421.  
  422.     nl_catd GrafPartNLSCat;         // handle to NLS message catalog
  423.     char*   GrafPartText;           // pointer for NLS message
  424.     ODPlatformMenuItem* mi = new ODPlatformMenuItem;    // menuitem buffer
  425.     memset(mi, 0, sizeof(ODPlatformMenuItem) );         // initialize menu item attributes
  426.  
  427.     // call parent method first
  428.     parent_InstallMenuItems(somSelf,
  429.                                                    ev,
  430.                                                    menuBar);
  431.     // set up catalog
  432. #ifdef _NLS_
  433.     setlocale(LC_MESSAGES, NULL);
  434.  
  435.     /* Open the catalog (using LC_MESSAGES, not LANG via the second argument) */
  436.     GrafPartNLSCat = catopen(GRAFPART_NLS_CATALOG, 0);
  437.  
  438.     if (GrafPartNLSCat != CATD_ERR)
  439.         SQUAWK("\t%s::InstallMenuItems(): Opened NLS catalog: %s with handle: %lX\n", GP_Cq, GRAFPART_NLS_CATALOG, GrafPartNLSCat);
  440.     else
  441.         SQUAWK("\t%s::InstallMenuItems(): Could not open NLS catalog: %s\n", GP_Cq, GRAFPART_NLS_CATALOG);
  442. #endif
  443.  
  444.     // Allocate temporary menuitem buffer
  445.  
  446.     // use default attributes
  447.     mi->afAttribute = 0;
  448.  
  449.  
  450.     // add "Refresh" selection item to options menu
  451.     mi->id = kODCommandGrafPartRefresh;
  452.     menuBar->AddMenuItemLast(ev, kODOptionsMenuID, mi->id, mi);
  453.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_REFRESH);
  454.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_REFRESH,
  455. #ifdef GPDebug
  456.         "REFRESH WINDOW"
  457. #else
  458.         "Refresh Window"
  459. #endif // GPDebug
  460.     );
  461.     menuBar->SetMenuItemText(ev, kODOptionsMenuID, kODCommandGrafPartRefresh, GrafPartText);
  462.  
  463.  
  464.     // add a menu separator line to Embed menu
  465.     mi->id = CMD(Dash);
  466.     mi->afAttribute = MB_SEPARATOR;
  467.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, kODNULL, mi);
  468.     mi->afAttribute = 0;                // reset attribute to normal
  469.  
  470.     // add "Point" selection item to Embed menu
  471.     mi->id = kODCommandGrafPartAddPoin;
  472.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  473.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_POIN);
  474.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_POIN,
  475. #ifdef GPDebug
  476.         "POINT"
  477. #else
  478.         "Point"
  479. #endif // GPDebug
  480.     );
  481.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddPoin, GrafPartText);
  482.  
  483.  
  484.     // add "Line" selection item to Embed menu
  485.     mi->id = kODCommandGrafPartAddLine;
  486.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  487.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_LINE);
  488.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_LINE,
  489. #ifdef GPDebug
  490.         "LINE"
  491. #else
  492.         "Line"
  493. #endif // GPDebug
  494.     );
  495.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddLine, GrafPartText);
  496.  
  497.  
  498.     // add "Rectangle" selection item to Embed menu
  499.     mi->id = kODCommandGrafPartAddRect;
  500.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  501.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_RECT);
  502.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_RECT,
  503. #ifdef GPDebug
  504.         "RECTANGLE"
  505. #else
  506.         "Rectangle"
  507. #endif // GPDebug
  508.     );
  509.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddRect, GrafPartText);
  510.  
  511.  
  512. /*  add these sections to enable additional figure type support from the GP GUI
  513.     // add "Text" selection item to Embed menu
  514.     mi->id = kODCommandGrafPartAddText;
  515.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  516.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_TEXT);
  517.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_TEXT,
  518. #ifdef GPDebug
  519.         "TEXT"
  520. #else
  521.         "Text"
  522. #endif // GPDebug
  523.     );
  524.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddText, GrafPartText);
  525.  
  526.  
  527.     // add "Text" selection item to Embed menu
  528.     mi->id = kODCommandGrafPartAddText;
  529.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  530.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_TEXT);
  531.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_TEXT,
  532. #ifdef GPDebug
  533.         "TEXT"
  534. #else
  535.         "Text"
  536. #endif // GPDebug
  537.     );
  538.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddText, GrafPartText);
  539.  
  540.  
  541.     // add "Elli" selection item to Embed menu
  542.     mi->id = kODCommandGrafPartAddElli;
  543.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  544.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_ELLI);
  545.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_ELLI,
  546. #ifdef GPDebug
  547.         "ELLIPSE"
  548. #else
  549.         "Ellipse"
  550. #endif // GPDebug
  551.     );
  552.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddElli, GrafPartText);
  553.  
  554.  
  555.     // add "Circ" selection item to Embed menu
  556.     mi->id = kODCommandGrafPartAddCirc;
  557.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  558.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_CIRC);
  559.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_CIRC,
  560. #ifdef GPDebug
  561.         "CIRCLE"
  562. #else
  563.         "Circle"
  564. #endif // GPDebug
  565.     );
  566.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddCirc, GrafPartText);
  567.  
  568.  
  569.     // add "Plin" selection item to Embed menu
  570.     mi->id = kODCommandGrafPartAddPlin;
  571.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  572.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_PLIN);
  573.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_PLIN,
  574. #ifdef GPDebug
  575.         "POLYLINE
  576. #else
  577.         "Polyline"
  578. #endif // GPDebug
  579.     );
  580.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddPlin, GrafPartText);
  581.  
  582.  
  583.     // add "Pgon" selection item to Embed menu
  584.     mi->id = kODCommandGrafPartAddPgon;
  585.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  586.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_PGON);
  587.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_PGON,
  588. #ifdef GPDebug
  589.         "POLYGON"
  590. #else
  591.         "Polygon"
  592. #endif // GPDebug
  593.     );
  594.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddPgon, GrafPartText);
  595.  
  596.  
  597.     // add "Free" selection item to Embed menu
  598.     mi->id = kODCommandGrafPartAddFree;
  599.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  600.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_FREE);
  601.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_FREE,
  602. #ifdef GPDebug
  603.         "FREEHAND"
  604. #else
  605.         "Freehand"
  606. #endif // GPDebug
  607.     );
  608.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddFree, GrafPartText);
  609.  
  610.  
  611.     // add "Imag" selection item to Embed menu
  612.     mi->id = kODCommandGrafPartAddImag;
  613.     menuBar->AddMenuItemLast(ev, kODEmbedMenuID, mi->id, mi);
  614.     SQUAWK("\t%s::InstallMenuItems(): getting NLS catalog: %lX, set: %d, command: %d\n", GP_Cq, GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_IMAG);
  615.     GrafPartText = catgets(GrafPartNLSCat, GRAFPART_MSG_SET, GRAFPART_ADD_IMAG,
  616. #ifdef GPDebug
  617.         "IMAGE"
  618. #else
  619.         "Image"
  620. #endif // GPDebug
  621.     );
  622.     menuBar->SetMenuItemText(ev, kODEmbedMenuID, kODCommandGrafPartAddImag, GrafPartText);
  623.  
  624.  
  625. */
  626.  
  627.  
  628.     // cleanup menuitem buffer
  629.     delete mi;
  630.  
  631.     // close the message catalog
  632.     catclose(GrafPartNLSCat);
  633.     SQUAWK("\t%s::InstallMenuItems(): closed NLS catalog handle: %lX\n", GP_Cq, GrafPartNLSCat);
  634.  
  635.  
  636.     SQUAWK("< Leaving %s::InstallMenuItems()\n", GP_Cq);
  637.     return;
  638. }   // InstallMenuItems()
  639.  
  640.  
  641. // -------------------------------------------------------------------------
  642. // GrafPart --> HandleMenuEvent
  643. //
  644. //      Handle a menubar or pulldown menu selection event.
  645. //
  646. //     -> public override method
  647. //     -> calls parent last, if event not handled locally
  648. // -------------------------------------------------------------------------
  649. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleMenuEvent) ( GP_C    *somSelf,
  650.                                                         Environment *ev,
  651.                                                         ODFrame     *frame,
  652.                                                         ODEventData *event )
  653. {
  654.     SQUAWK("> Invoked %s::HandleMenuEvent()\n", GP_Cq);
  655.  
  656.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  657.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleMenuEvent) );
  658.  
  659.     ODBoolean   eventHandled = kODFalse;    // flag to track whether event was handled locally
  660.  
  661.     try
  662.     {
  663.         // determine which menu pulldown it was
  664.         switch(
  665. #if defined(_PLATFORM_WIN32_)
  666.         LOWORD(event->wParam)
  667. #elif defined(_PLATFORM_OS2_)
  668.         LONGFROMMP(event->mp1)
  669. #endif  // _PLATFORM_???_
  670.                )    // switch condition
  671.         {
  672.             // User selected menu item to Refresh the screen
  673.             case CMD(GrafPartRefresh):
  674.                 SQUAWK("\t%s::HandleMenuEvent(): calling HandleRefresh()\n", GP_Cq);
  675.                 eventHandled = somSelf->HandleRefresh(ev);
  676.                 break;
  677.  
  678.             // User selected menu item to Add a Point
  679.             case CMD(GrafPartAddPoin):
  680.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Poin)\n", GP_Cq);
  681.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_POIN);
  682.                 break;
  683.  
  684.             // User selected menu item to Add a Line
  685.             case CMD(GrafPartAddLine):
  686.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Line)\n", GP_Cq);
  687.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_LINE);
  688.                 break;
  689.  
  690.             // User selected menu item to Add a Rectangle
  691.             case CMD(GrafPartAddRect):
  692.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Rect)\n", GP_Cq);
  693.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_RECT);
  694.                 break;
  695.  
  696. /*  add these sections to enable additional figure type support from the GP GUI
  697.             // User selected menu item to Add Text
  698.             case CMD(GrafPartAddText):
  699.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Text)\n", GP_Cq);
  700.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  701.                 break;
  702.  
  703.             // User selected menu item to Add Elli
  704.             case CMD(GrafPartAddElli):
  705.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Elli)\n", GP_Cq);
  706.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  707.                 break;
  708.  
  709.             // User selected menu item to Add Circ
  710.             case CMD(GrafPartAddCirc):
  711.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Circ)\n", GP_Cq);
  712.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  713.                 break;
  714.  
  715.             // User selected menu item to Add Pgon
  716.             case CMD(GrafPartAddPgon):
  717.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Pgon)\n", GP_Cq);
  718.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  719.                 break;
  720.  
  721.             // User selected menu item to Add Plin
  722.             case CMD(GrafPartAddPlin):
  723.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Plin)\n", GP_Cq);
  724.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  725.                 break;
  726.  
  727.             // User selected menu item to Add Free
  728.             case CMD(GrafPartAddFree):
  729.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Free)\n", GP_Cq);
  730.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  731.                 break;
  732.  
  733.             // User selected menu item to Add Imag
  734.             case CMD(GrafPartAddImag):
  735.                 SQUAWK("\t%s::HandleMenuEvent(): calling AddIntrinsic(Imag)\n", GP_Cq);
  736.                 eventHandled = somSelf->AddIntrinsic(ev, frame, COBJ_GRAFPART_TEXT);
  737.                 break;
  738. */
  739.  
  740.             default:
  741.                 SQUAWK("\t%s::HandleMenuEvent(): Unknown menu event: %d\n", GP_Cq, event);
  742.                 eventHandled = kODFalse;
  743.                 break;
  744.  
  745.         }   // switch: which menu pulldown?
  746.     }   // try
  747.     catch(...)
  748.     {
  749.         SQUAWK("\t%s::HandleMenuEvent(): CAUGHT EXCEPTION\n", GP_Cq);
  750.     }   // catch
  751.  
  752.     // if event not handled locally, pass on to parent
  753.     if (!eventHandled)
  754.     {
  755.         // pass event to parent
  756.         SQUAWK("\t%s::HandleMenuEvent(): passing event to parent\n", GP_Cq);
  757.         eventHandled = (parent_HandleMenuEvent(  somSelf,
  758.                                                                         ev,
  759.                                                                         frame,
  760.                                                                         event ) );
  761.         SQUAWK("< Leaving %s::HandleMenuEvent() with parent's result (%d)\n", GP_Cq, eventHandled);
  762.         return(eventHandled);
  763.     }
  764.     else
  765.     {
  766.         SQUAWK("< Leaving %s::HandleMenuEvent() with event handled locally\n", GP_Cq);
  767.         return(eventHandled);    // should always be true here
  768.     }   // else
  769. }   // HandleMenuEvent()
  770.  
  771.  
  772. // -------------------------------------------------------------------------
  773. // GrafPart --> HandleMouseMotionStart
  774. //
  775. //     Event handler: begin moving mouse with MB1 down
  776. //
  777. //     -> public override method
  778. //     -> calls parent
  779. // -------------------------------------------------------------------------
  780. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleMouseMotionStart) ( GP_C    *somSelf,
  781.                                                                 Environment *ev,
  782.                                                                 ODEventData *event,
  783.                                                                 ODFrame     *frame,
  784.                                                                 ODFacet     *facet,
  785.                                                                 ODEventInfo *eventInfo )
  786. {
  787.     SQUAWK("> Invoked %s::HandleMouseMotionStart()\n", GP_Cq);
  788.  
  789.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  790.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleMouseMotionStart) );
  791.  
  792.  
  793.     // Because mouse movement is handled with platform-specific events and not OpenDoc events,
  794.     //   and that the dispatcher will return a null facet for a plat-spec event, we must check
  795.     //   the incoming facet and correct it before using.
  796.     if (facet == NULL)                          // if the facet it null
  797.         facet = FirstFacet(ev, frame);          // assign it to the first facet for the current frame
  798.  
  799.     // flag to track if event was handled locally
  800.     ODBoolean       eventHandled = kODFalse;
  801.  
  802.     // Get the containing frame's windowframe transform
  803.     TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  804.  
  805.     // _fActionType was set initially by HandleMenuEvent,
  806.     //     or by a previous click in the GrafPartAdd sequence
  807.     switch (_fActionType)
  808.     {
  809.         // Single not defined
  810.         case kODSingleAction:
  811.             SQUAWK("\t%s::HandleMouseMotionStart(): undefined ActionType: kODSingleAction\n", GP_Cq);
  812.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  813.             break;
  814.  
  815.         // Begin -> select first point
  816.         case kODBeginAction:
  817.  
  818.             // create and cache the intrinsic object with current point
  819.             SQUAWK("\t%s::HandleMouseMotionStart(): state: kODCommandGrafPartAdd, kODBeginAction\n", GP_Cq);
  820.             GetPoint(ev, facet, event, &_fPt);                  // get the current point
  821.             ( (ContentGrafPartFigr *)_fCurrObj )
  822.                 ->Initialize(ev, frame, &_fPt);                 // set up new object with origin point
  823.             _fCurrShape = frame->CreateShape(ev);               // create temp shapes for rubberbanding
  824.             _fTempShape = frame->CreateShape(ev);               // create temp shapes for rubberbanding
  825.  
  826.             // set local handling flags
  827.             _fActionType = kODEndAction;    // set the action type for the next action
  828.             eventHandled = kODTrue;         // the click was handled locally, do not pass on
  829.             break;
  830.  
  831.         // End undefined
  832.         case kODEndAction:
  833.             SQUAWK("\t%s::HandleMouseMotionStart(): ActionType: kODEndAction\n", GP_Cq);
  834.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  835.             break;
  836.  
  837.         // unknown action type
  838.         default:
  839.             SQUAWK("\t%s::HandleMouseMotionStart(): kODCommandGrafPartAddLine: undefined ActionType: %d\n", GP_Cq, _fActionType);
  840.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  841.             break;
  842.  
  843.     }   // switch: ActionType
  844.  
  845.     // termination: if click not handled locally, pass on to parent
  846.     if (!eventHandled)
  847.     {
  848.         SQUAWK("< Leaving %s::HandleMouseMotionStart(): calling parent\n", GP_Cq);
  849.         return (parent_HandleMouseMotionStart(  somSelf,
  850.                                                 ev,
  851.                                                 event,
  852.                                                 frame,
  853.                                                 facet,
  854.                                                 eventInfo));
  855.     }
  856.     else
  857.     {
  858.         SQUAWK("< Leaving %s::HandleMouseMotionStart(): returning True\n", GP_Cq);
  859.         return(eventHandled);           // should always be true here
  860.     }
  861. }   // HandleMouseMotionStart()
  862.  
  863.  
  864. // -------------------------------------------------------------------------
  865. // GrafPart --> HandleMouseMotionLBDown
  866. //
  867. //     Event handler: mouse movement with MB1 down
  868. //
  869. //     -> public override method
  870. //     -> calls parent
  871. // -------------------------------------------------------------------------
  872. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleMouseMotionLBDown) ( GP_C        *somSelf,
  873.                                                                 Environment *ev,
  874.                                                                 ODEventData *event,
  875.                                                                 ODFrame     *frame,
  876.                                                                 ODFacet     *facet,
  877.                                                                 ODEventInfo *eventInfo )
  878. {
  879.     SQUAWK("> Invoked %s::HandleMouseMotionLBDown()\n", GP_Cq);
  880.  
  881.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  882.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleMouseMotionLBDown) );
  883.  
  884.     ODBoolean   eventHandled = kODFalse;        // flag to track whether event was handled locally
  885.  
  886.  
  887.     // Because mouse movement is handled with platform-specific events and not OpenDoc events,
  888.     //   and that the dispatcher will return a null facet for a plat-spec event, we must check
  889.     //   the incoming facet and correct it before using.
  890.     if (facet==kODNULL)                         // if the facet it null
  891.         facet = FirstFacet(ev, frame);          // assign it to the first facet for the current frame
  892.  
  893.     // _fActionType was set initially by HandleMenuEvent,
  894.     //     or by a previous click in the sequence
  895.     switch (_fActionType)
  896.     {
  897.         // Single not defined
  898.         case kODSingleAction:
  899.             SQUAWK("\t%s::HandleMouseMotionLBDown(): undefined ActionType: kODSingleAction\n", GP_Cq);
  900.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  901.             break;
  902.  
  903.         // Begin not defined
  904.         case kODBeginAction:
  905.             SQUAWK("\t%s::HandleMouseMotionLBDown(): undefined ActionType: kODBeginAction\n", GP_Cq);
  906.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  907.             break;
  908.  
  909.         // End -> rubberband the line
  910.         case kODEndAction:
  911.             SQUAWK("\t%s::HandleMouseMotionLBDown(): state: kODGrafPartAddLine, kODBeginAction\n", GP_Cq);
  912.  
  913.             // update the intrinsic object
  914.             GetPoint(ev, facet, event, &_fPt);                      // get the current point
  915.             _fBBox = _fCurrObj->_get_boundingRect(ev);              // get boundry before update
  916.             _fCurrShape->SetRectangle(ev, FluffRect(&_fBBox) );     // save the shape of it
  917.             somSelf->UpdateIntrinsic(ev, frame, &_fPt);             // update the object in progress
  918.             _fBBox = _fCurrObj->_get_boundingRect(ev);              // get boundry after update
  919.             _fTempShape->SetRectangle(ev, FluffRect(&_fBBox) );     // save the shape of it
  920.             _fCurrShape->Union(ev, _fTempShape);                    // add the shapes
  921.  
  922.             // set local handling flags
  923. //          _fAction     = kODCommandGrafPartSelect;    // Action: reset to Select (default)
  924. //          _fActionType = kODSingleAction;             // ActionType: reset to default
  925.             eventHandled = kODTrue;                     // the MouseUp was handled locally, do not pass on
  926.  
  927.             // refresh the image of the intrinsic object
  928.             char* refMeth;
  929.             refMeth = getenv("GP_REFRESH");
  930.             if ( refMeth==NULL )
  931.                 refMeth = "1";        // default refresh method is 1
  932.             switch( atoi(refMeth) )
  933.             {
  934.                 case 3:
  935.                     // update the facet to make it render the line
  936.                     SQUAWK("\t%s::HandleMouseMotionLBDown(): refresh method 3\n", GP_Cq);
  937.                     facet->Update(ev, _fCurrShape, kODNULL);
  938.                     break;
  939.  
  940.                 case 2:
  941.                     // invalidate the line's shape to make it render
  942.                     SQUAWK("\t%s::HandleMouseMotionLBDown(): refresh method 2\n", GP_Cq);
  943.                     frame->Invalidate(ev, _fCurrShape, kODNULL);
  944.                     break;
  945.  
  946.                 case 1:
  947.                 case 0:
  948.                 default:
  949.                     // invalidate the frame to make it all render
  950.                     SQUAWK("\t%s::HandleMouseMotionLBDown(): refresh method 1\n", GP_Cq);
  951.                     frame->Invalidate(ev, kODNULL, kODNULL);
  952.                     break;
  953.             }   // switch refMeth
  954.  
  955.             // set local handling flags
  956.             eventHandled = kODTrue;         // the click was handled locally, do not pass on
  957.             break;
  958.  
  959.         // unknown action type
  960.         default:
  961.             SQUAWK("\t%s::HandleMouseMotionLBDown(): kODCommandGrafPartAdd: undefined ActionType: %d\n", GP_Cq, _fActionType);
  962.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  963.             break;
  964.  
  965.     }   // switch: ActionType
  966.  
  967.     // termination: if click not handled locally, pass on to parent
  968.     if (!eventHandled)
  969.     {
  970.         SQUAWK("< Leaving %s::HandleMouseMotionLBDown(): calling parent\n", GP_Cq);
  971.         return (parent_HandleMouseMotionLBDown(  somSelf,
  972.                                                                         ev,
  973.                                                                         event,
  974.                                                                         frame,
  975.                                                                         facet,
  976.                                                                         eventInfo));
  977.     }
  978.     else
  979.     {
  980.         SQUAWK("< Leaving %s::HandleMouseMotionLBDown(): returning True\n", GP_Cq);
  981.         return(eventHandled);           // should always be true here
  982.     }
  983. }   // HandleMouseMotionLBDown()
  984.  
  985.  
  986. // -------------------------------------------------------------------------
  987. // GrafPart --> HandleMouseMotionEnd
  988. //
  989. //     Event handler: end moving mouse and MB1 up
  990. //
  991. //     -> public override method
  992. //     -> calls parent
  993. // -------------------------------------------------------------------------
  994. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleMouseMotionEnd) (    GP_C        *somSelf,
  995.                                                                 Environment *ev,
  996.                                                                 ODEventData *event,
  997.                                                                 ODFrame     *frame,
  998.                                                                 ODFacet     *facet,
  999.                                                                 ODEventInfo *eventInfo )
  1000. {
  1001.     SQUAWK("> Invoked %s::HandleMouseMotionEnd()\n", GP_Cq);
  1002.  
  1003.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1004.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleMouseMotionEnd) );
  1005.  
  1006.     ODBoolean       eventHandled = kODFalse;    // flag to track whether event was handled locally
  1007.     ContentGrafPartFigr*    figr;                           // declare a buffer for a intrinsic object
  1008.  
  1009.     // Because mouse movement is handled with platform-specific events and not OpenDoc events,
  1010.     //   and that the dispatcher will return a null facet for a plat-spec event, we must check
  1011.     //   the incoming facet and correct it before using.
  1012.     if (facet == NULL)                          // if the facet it null
  1013.         facet = FirstFacet(ev, frame);          // assign it to the first facet for the current frame
  1014.  
  1015.     // Get the containing frame's windowframe transform
  1016.     TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  1017.  
  1018.     // _fActionType was set initially by HandleMenuEvent,
  1019.     //     or by a previous click in the GrafPartAddLine sequence
  1020.     switch (_fActionType)
  1021.     {
  1022.         // Single not defined
  1023.         case kODSingleAction:
  1024.             SQUAWK("\t%s::HandleMouseMotionEnd(): undefined state: kODCommandGrafPartAdd, kODSingleAction\n", GP_Cq);
  1025.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  1026.             break;
  1027.  
  1028.         // Begin not defined
  1029.         case kODBeginAction:
  1030.             SQUAWK("\t%s::HandleMouseMotionEnd(): undefined state: kODCommandGrafPartAdd, kODBeginAction\n", GP_Cq);
  1031.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  1032.             break;
  1033.  
  1034.         // End -> finalize the new intrinsic object at this point
  1035.         case kODEndAction:
  1036.             SQUAWK("\t%s::HandleMouseMotionEnd(): state: kODCommandGrafPartAdd, kODEndAction\n", GP_Cq);
  1037.  
  1038.             // update the intrinsic object
  1039.             GetPoint(ev, facet, event, &_fPt);          // get the current point
  1040.             somSelf->UpdateIntrinsic(ev, frame, &_fPt); // update the object in progress
  1041.  
  1042.             // set local handling flags
  1043.             _fAction     = kODCommandGrafPartSelect;    // Action: reset to Select (default)
  1044.             _fActionType = kODSingleAction;             // ActionType: reset to default
  1045.             eventHandled = kODTrue;                     // the MouseUp was handled locally, do not pass on
  1046.  
  1047.             // redraw: shape handling not needed because the whole frame will be invalidated by HandleRefresh()
  1048.             _fCurrShape->Release(ev);                               // delete temp shapes for rubberbanding
  1049.             _fTempShape->Release(ev);                               // delete temp shapes for rubberbanding
  1050.             somSelf->Reset(ev);                         // reset all editor state to defaults
  1051.             somSelf->HandleRefresh(ev);                 // refresh the whole content area
  1052.             break;
  1053.  
  1054.         // unknown action type
  1055.         default:
  1056.             SQUAWK("\t%s::HandleMouseMotionEnd(): kODCommandGrafPartAdd: undefined ActionType: %d\n", GP_Cq, _fActionType);
  1057.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  1058.             break;
  1059.  
  1060.     }   // switch: ActionType
  1061.  
  1062.     // termination: if click not handled locally, pass on to parent
  1063.     if (!eventHandled)
  1064.     {
  1065.         SQUAWK("< Leaving %s::HandleMouseMotionEnd(): calling parent\n", GP_Cq);
  1066.         return (parent_HandleMouseMotionEnd( somSelf,
  1067.                                                                     ev,
  1068.                                                                     event,
  1069.                                                                     frame,
  1070.                                                                     facet,
  1071.                                                                     eventInfo));
  1072.     }
  1073.     else
  1074.     {
  1075.         SQUAWK("< Leaving %s::HandleMouseMotionEnd(): returning True\n", GP_Cq);
  1076.         return(eventHandled);           // should always be true here
  1077.     }
  1078. }   // HandleMouseMotionEnd()
  1079.  
  1080.  
  1081. // -------------------------------------------------------------------------
  1082. // GrafPart --> HandleMouseClick
  1083. //
  1084. //     Event handler: mouse click
  1085. //
  1086. //     -> public override method
  1087. //     -> calls parent last, if not handled locally
  1088. // -------------------------------------------------------------------------
  1089. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleMouseClick)  (   GP_C        *somSelf,
  1090.                                                             Environment *ev,
  1091.                                                             ODEventData *event,
  1092.                                                             ODFrame     *frame,
  1093.                                                             ODFacet     *facet,
  1094.                                                             ODEventInfo *eventInfo )
  1095. {
  1096.     SQUAWK("> Invoked %s::HandleMouseClick()\n", GP_Cq);
  1097.  
  1098.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1099.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleMouseClick) );
  1100.  
  1101.     ODBoolean   eventHandled = kODFalse;                    // flag to track whether event was handled locally
  1102.     ALinkedList *eList = somSelf->GetEmbeddedObjects(ev);   // get the list of embedded objects
  1103.     ALink       *eIter;                                     // declare an iterator on the emedded list
  1104.     ALinkedList *sList = somSelf->GetSelectedObjects(ev);   // get the list of selected objects
  1105.     ALink       *sIter;                                     // declare an iterator on the selected list
  1106.     ContentGrafPartFigr*    figr;                           // declare a buffer for a intrinsic object
  1107.     COType                  coType;                         // declare a buffer for a intrinsic type
  1108.  
  1109.     // Because mouse movement is handled with platform-specific events and not OpenDoc events,
  1110.     //   and that the dispatcher will return a null facet for a plat-spec event, we must check
  1111.     //   the incoming facet and correct it before using.
  1112.     if (!facet)                                 // if the facet it null
  1113.         facet = FirstFacet(ev, frame);          // assign it to the first facet for the current frame
  1114.  
  1115.     switch (_fAction)
  1116.     {
  1117.         // SELECTION
  1118.         case CMD(GrafPartSelect):
  1119.  
  1120.             // _fActionType is not used, as GrafPartSelect is a single-stage action
  1121.             SQUAWK("\t%s::HandleMouseClick():state: kODCommandGrafPartSelect\n", GP_Cq);
  1122.  
  1123.             GetPoint(ev, facet, event, &_fPt);                  // get the current point
  1124.  
  1125.             // is the cursor on a contained object?
  1126.             for(eIter = eList->First(ev);                       // for each object in the embedded list
  1127.                 eIter->Content(ev) && !eventHandled;            // until something happens
  1128.                 eIter = eIter->Next(ev) )
  1129.             {
  1130.                 figr = (ContentGrafPartFigr *) eIter->Content(ev);  // treat it as intrinsic object
  1131.                 coType = figr->_get_objType(ev);                    // store the specific type
  1132.  
  1133.                 if ( ( coType >  COBJ_GRAFPART_FIGR ) &&        // if it is GP-intrinsic content
  1134.                      ( coType <= COBJ_GRAFPART_LAST ) )
  1135.                 {
  1136.                     if (figr->ContainsPoint(ev, &_fPt) )        // then if the point is on the object
  1137.                     {                                           // then toggle the object's selection
  1138.                         if (figr->_get_selectionState(ev) )     // is it already selected?
  1139.                         {                                       // then deselect it
  1140.                             SQUAWK("\t%s::HandleMouseClick(): deselected intrinsic object\n", GP_Cq);
  1141.                             figr->_set_selectionState(ev, kODFalse);    // tell it is not selected
  1142.                             sList->Remove(ev, figr);            // delete it from the selected list
  1143.                         }   // if: already selected?
  1144.                         else                                    // else select it
  1145.                         {
  1146.                             SQUAWK("\t%s::HandleMouseClick(): selected intrinsic object\n", GP_Cq);
  1147.                             figr->_set_selectionState(ev, kODTrue);     // tell it is selected
  1148.                             sList->AddLast(ev, figr);                   // add it to the selected list
  1149.                         }   // else: already selected?
  1150.  
  1151.                         SQUAWK("\t%s::HandleMouseClick(): recalculating selected figure shape\n", GP_Cq);
  1152.                         somSelf->CreateSelectionBorderShapes(ev, figr); // recalculate borders
  1153.                         if (figr != _fCurrObj)
  1154.                         {
  1155.                             SQUAWK("\t%s::HandleMouseClick(): recalculating current figure shape\n", GP_Cq);
  1156.                             somSelf->CreateSelectionBorderShapes(ev, _fCurrObj);
  1157.                         }
  1158.                         eventHandled = kODTrue;                 // click handled locally
  1159.                         somSelf->Reset(ev);                     // reset all editor state to defaults
  1160.                         somSelf->HandleRefresh(ev);             // refresh the whole content area
  1161.                         break;                                  // don't keep looking
  1162.  
  1163.                     }   // if: contains point?
  1164.                     else                                        // else it does not contain this point
  1165.                         SQUAWK("\t%s::HandleMouseClick(): not this one...\n", GP_Cq);
  1166.                 }   // if: intrinsic content?
  1167.                 else                                            // else it is embedded content
  1168.                 {
  1169.                     SQUAWK("\t%s::HandleMouseClick(): selected item was not intrinsic\n", GP_Cq);
  1170.                     eventHandled = kODFalse;                // click not handled locally, pass it on
  1171.                 }   // else: intrinsic content?
  1172.             }   // for: each embedded object
  1173.             break;  // end of case: CMD(GrafPartSelect)
  1174.  
  1175.         // INTRINSIC EMBED (ADD)
  1176.         case CMD(GrafPartAdd):
  1177.             if (_fCurrObjType == COBJ_GRAFPART_POIN)
  1178.             {
  1179.                 // create and cache the point object with current point
  1180.                 SQUAWK("\t%s::HandleMouseClick(): state: kODCommandGrafPartAdd, kODBeginAction\n", GP_Cq);
  1181.                 GetPoint(ev, facet, event, &_fPt);          // get the current point
  1182.                 ( (ContentGrafPartFigr *) _fCurrObj )
  1183.                     ->Initialize(ev, frame, &_fPt);         // set up new object with origin point
  1184.                 ( (ContentGrafPartFigr *) _fCurrObj )
  1185.                     ->AdjustBoundingRect(ev);               // update object's boundry
  1186.  
  1187.                 // set local handling flags
  1188.                 _fAction     = kODCommandGrafPartSelect;    // Action: reset to Select (default)
  1189.                 _fActionType = kODSingleAction;             // ActionType: reset to default
  1190.                 eventHandled = kODTrue;                     // the MouseUp was handled locally, do not pass on
  1191.  
  1192.                 // redraw: shape handling not needed because the whole frame will be invalidated by HandleRefresh()
  1193.                 somSelf->Reset(ev);                         // reset all editor state to defaults
  1194.                 somSelf->HandleRefresh(ev);                 // refresh the whole content area
  1195.             }   // if add point
  1196.             else
  1197.                 SQUAWK("\t%s::HandleMouseClick() does not handle kODCommandGrafPartAdd for ContentObjectTypes other than Point\n", GP_Cq);
  1198.             break;
  1199.  
  1200.         // unknown action
  1201.         default:
  1202.             SQUAWK("\t%s::HandleMouseClick(): undefined Action\n", GP_Cq);
  1203.             eventHandled = kODFalse;    // this state is undefined in our context, pass it on
  1204.  
  1205.     }   // switch: Action
  1206.  
  1207.     // termination: if click not handled locally, pass on to parent
  1208.     if (!eventHandled)
  1209.     {
  1210.         SQUAWK("< Leaving %s::HandleMouseClick(), calling parent\n", GP_Cq);
  1211.         return (parent_HandleMouseClick( somSelf,
  1212.                                                                 ev,
  1213.                                                                 event,
  1214.                                                                 frame,
  1215.                                                                 facet,
  1216.                                                                 eventInfo ) );
  1217.     }   // if !eventHandled
  1218.     else
  1219.     {
  1220.         SQUAWK("< Leaving %s::HandleMouseClick(), handled locally\n", GP_Cq);
  1221.         return(eventHandled);           // should always be true here
  1222.     }   // else !eventHandled
  1223. }   // HandleMouseClick()
  1224.  
  1225.  
  1226. // -------------------------------------------------------------------------
  1227. // GrafPart --> DrawContents
  1228. //
  1229. //     DrawContents method, part of Draw method
  1230. //         with DrawSelectionBorder (which is not overridden)
  1231. //
  1232. //     -> public override method
  1233. //     -> does NOT call parent
  1234. // -------------------------------------------------------------------------
  1235. SOM_Scope   ODBoolean   SOMLINK GP_P(DrawContents)(   GP_C    *somSelf,
  1236.                                                         Environment *ev,
  1237.                                                         ODFacet     *facet,
  1238.                                                         ODShape     *invalidShape )
  1239. {
  1240.     SQUAWK("> Invoked %s::DrawContents()\n", GP_Cq);
  1241.  
  1242.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1243.     GP_P(MethodDebug) (GP_Cq,GP_Pq(DrawContents) );
  1244.  
  1245.     try
  1246.     {
  1247.         // Get the frame for this facet
  1248.         ODFrame* displayFrame = facet->GetFrame(ev);
  1249.  
  1250.         // Get the frame bounding rectangle and convert to Window's rectangle
  1251.         ODRect rect;
  1252.         TempODShape shape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev));
  1253.  
  1254.         shape->GetBoundingBox(ev, &rect);
  1255.         Rect frameRect;
  1256.  
  1257.         // Define the drawing context
  1258.         HDraw hDraw;
  1259.  
  1260.         // Use the focuslib code to set up transforms and clipping
  1261.         CFocus Focus(facet, invalidShape, &hDraw);
  1262.  
  1263. #if defined(_PLATFORM_WIN32_)
  1264.         SetRect(&frameRect, FixedToInt(rect.left),
  1265.                             FixedToInt(rect.top),
  1266.                             FixedToInt(rect.right),
  1267.                             FixedToInt(rect.bottom));
  1268. #elif defined(_PLATFORM_OS2_)
  1269.         WinSetRect( WinQueryAnchorBlock(HWND_DESKTOP),
  1270.                     &frameRect, FixedToInt(rect.left),
  1271.                                 FixedToInt(rect.bottom),
  1272.                                 FixedToInt(rect.right),
  1273.                                 FixedToInt(rect.top));
  1274. #endif // _PLATFORM_???_
  1275.  
  1276.         // fill the backgound
  1277. #if defined(_PLATFORM_WIN32_)
  1278.         SQUAWK("\t%s::DrawContents(): Filling background for WIN32\n", GP_Cq);
  1279.         // Create a solid brush
  1280.         HBRUSH hbr = CreateSolidBrush (somSelf->GetBackgroundColor(ev));
  1281.  
  1282.         // Fill the rectangle with the brush
  1283.         FillRect (hDraw, &frameRect, hbr);
  1284.  
  1285.         // Get rid of the brush
  1286.         DeleteObject (hbr);
  1287. #elif defined(_PLATFORM_OS2_)
  1288.         SQUAWK("\t%s::DrawContents(): Filling background for OS2\n", GP_Cq);
  1289.         POINTL orig = {0, 0};
  1290.         POINTL exnt = {frameRect.xRight, frameRect.yTop};
  1291.         GpiCreateLogColorTable (hDraw, 0L, LCOLF_RGB, 0L, 0L, 0L);
  1292.         GpiSetColor(hDraw, somSelf->GetBackgroundColor(ev));
  1293.         GpiMove(hDraw, &orig);
  1294.         GpiBox(hDraw, DRO_FILL, &exnt, 0, 0);
  1295. #endif // _PLATFORM_???_
  1296.  
  1297.  
  1298.         // place label on window
  1299. #if defined(_PLATFORM_WIN32_) && defined(ODDebug) && 0
  1300.         SQUAWK("\t%s::DrawContents(): Labelling background for WIN32\n", GP_Cq);
  1301.  
  1302.         // Set up a font for the text - ensure it doesn't get too small
  1303.         LOGFONT labelFont;
  1304.         memset(&labelFont, 0, sizeof(labelFont));
  1305.         labelFont.lfPitchAndFamily = FF_SCRIPT;
  1306.         labelFont.lfItalic = 1;
  1307.         labelFont.lfHeight = (frameRect.bottom - frameRect.top) / 12;
  1308.         if (labelFont.lfHeight < 16)
  1309.         {
  1310.             labelFont.lfHeight = 16;
  1311.         }
  1312.         labelFont.lfQuality = PROOF_QUALITY;
  1313.         lstrcpy((LPSTR)labelFont.lfFaceName, (LPSTR)"Cursive");
  1314.  
  1315.         // Create the font and select it
  1316.         HFONT hFont = CreateFontIndirect(&labelFont);
  1317.         HFONT hOldFont;
  1318.         hOldFont = SelectObject(hDraw, hFont);
  1319.  
  1320.         // Write some text on the screen using a transparent background and white text
  1321.         SetBkMode(hDraw, TRANSPARENT);
  1322.         SetTextColor(hDraw, 0x00FFFFFF);
  1323.  
  1324.         char *text = kGrafPartDisplayName;
  1325.         DrawText(hDraw,
  1326.                  text,
  1327.                  strlen(text),
  1328.                  &frameRect,
  1329.                  DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  1330.  
  1331.         // Remove the temporary font
  1332.         SelectObject(hDraw, hOldFont);
  1333.         DeleteObject(hFont);
  1334. #elif defined(_PLATFORM_OS2_) && defined(ODDebug)
  1335.         SQUAWK("\t%s::DrawContents(): No defined background labelling for OS2\n", GP_Cq);
  1336. #endif // _PLATFORM_???_ & ODDebug, label on background
  1337.  
  1338.  
  1339.         // Tell my contents to draw
  1340.         ALinkedList*    eList = somSelf->GetEmbeddedObjects(ev);    // Get the list of embedded objects
  1341.         ALink*          eIter;                              // declare an iterator on the linked list
  1342.         ContentGrafPartFigr*    figr;                       // declare a buffer for a intrinsic object
  1343.         ODULong                 coType;                     // declare a buffer for a intrinsic type
  1344.  
  1345.         for(eIter = eList->First(ev);                       // for each Content Object in the list
  1346.             eIter->Content(ev);
  1347.             eIter = eIter->Next(ev) )
  1348.         {
  1349.             figr = (ContentGrafPartFigr *) eIter->Content(ev);  // treat it as intrinsic object
  1350.             coType = figr->_get_objType(ev);                    // store the specific type
  1351.  
  1352.             if ( ( coType >  COBJ_GRAFPART_FIGR ) &&            // if it is GP-intrinsic content
  1353.                  ( coType <= COBJ_GRAFPART_LAST ) )
  1354.             {
  1355.                 figr->Draw(ev, hDraw);                          // explicitly send Draw message
  1356.             }   // if: GP-intrinsic?
  1357.             else
  1358.             {
  1359.                 SQUAWK("\t%s::DrawContents(): unrecognized content object type: %d\n", GP_Cq, coType);
  1360.             }   // else: GP-intrinsic?
  1361.         }   // for: each embedded object
  1362.     }   // try
  1363.     catch(...)
  1364.     {
  1365.         SQUAWK("\t%s::DrawContents(): CAUGHT EXCEPTION, returning False\n", GP_Cq);
  1366.         return kODTrue;
  1367.     }
  1368.  
  1369.     SQUAWK("< Leaving %s::DrawContents(): returning True\n", GP_Cq);
  1370.     return kODTrue;
  1371. }  // GrafPartDrawContents()
  1372.  
  1373.  
  1374. // -------------------------------------------------------------------------
  1375. // GrafPart --> ReadKindInfo
  1376. //
  1377. //      Reads kind info from the storage unit.
  1378. //
  1379. //     -> public override method
  1380. //     -> does NOT call parent
  1381. // -------------------------------------------------------------------------
  1382. SOM_Scope   ODBoolean   SOMLINK GP_P(ReadKindInfo) (   GP_C        *somSelf,
  1383.                                                         Environment     *ev,
  1384.                                                         ODStorageUnit   *fromSU )
  1385. {
  1386.     SQUAWK("> Invoked %s::ReadKindInfo()\n", GP_Cq);
  1387.  
  1388.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1389.     GP_P(MethodDebug) (GP_Cq, GP_Pq(ReadKindInfo) );
  1390.  
  1391.     ODBoolean bExists = kODFalse;
  1392.  
  1393.     try
  1394.     {
  1395.         bExists = fromSU->Exists (ev, kODPropContents, kGrafPartPartKind, 0);
  1396.         if (!bExists) {
  1397.           bExists = parent_ReadKindInfo(somSelf, ev, fromSU);
  1398.         }
  1399.     }
  1400.     catch(...)
  1401.     {
  1402.         SQUAWK("\t%s::ReadKindInfo(): CAUGHT EXCEPTION\n", GP_Cq);
  1403.     }
  1404.  
  1405.     SQUAWK("< Leaving %s::ReadKindInfo()\n", GP_Cq);
  1406.     return bExists;
  1407. }   // ReadKindInfo()
  1408.  
  1409.  
  1410. // -------------------------------------------------------------------------
  1411. // GrafPart --> WriteKindInfo
  1412. //
  1413. //     Writes kind into the storage unit.
  1414. //
  1415. //     -> public override method
  1416. //     -> does NOT call parent
  1417. // -------------------------------------------------------------------------
  1418.  
  1419. SOM_Scope   void    SOMLINK     GP_P(WriteKindInfo) (  GP_C        *somSelf,
  1420.                                                         Environment     *ev,
  1421.                                                         ODStorageUnit   *toSU )
  1422. {
  1423.     SQUAWK("> Invoked %s::WriteKindInfo()\n", GP_Cq);
  1424.  
  1425.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1426.     GP_P(MethodDebug) (GP_Cq, GP_Pq(WriteKindInfo) );
  1427.  
  1428.     try
  1429.      {
  1430.         // write the part kind info attribute
  1431.         ODSUAddPropValue(ev, toSU, kODPropContents, kGrafPartPartKind);
  1432.  
  1433. #if defined(_PLATFORM_OS2_)
  1434. //      somSelf->StorageUnitSetValue(toSU, ev, sizeof(somSelf), somSelf);
  1435. #endif  // _PLATFORM_OS2_
  1436.  
  1437.  
  1438.         parent_WriteKindInfo(somSelf, ev, toSU);
  1439.  
  1440.     }
  1441.     catch(...)
  1442.     {
  1443.         SQUAWK("\t%s::WriteKindInfo(): CAUGHT EXCEPTION\n", GP_Cq);
  1444.     }
  1445.  
  1446.     SQUAWK("< Leaving %s::WriteKindInfo()\n", GP_Cq);
  1447.     return;
  1448. }   // WriteKindInfo()
  1449.  
  1450.  
  1451. // -------------------------------------------------------------------------
  1452. // ContentGrafPartLine --> GetContentObjectFromObjType
  1453. //
  1454. //      Override ContentObject::GetContentObjectFromObjType to create dummy
  1455. //          Line object for CloneInto
  1456. //
  1457. //     -> public override method
  1458. //     -> calls parent last, if not handled locally
  1459. // -------------------------------------------------------------------------
  1460. SOM_Scope   void    SOMLINK GP_P(GetContentObjectFromObjType) (    GP_C *somSelf,
  1461.                                                                     Environment*    ev,
  1462.                                                                     COType          objType,
  1463.                                                                     ContentObject** contentObject )
  1464. {
  1465.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1466.     GP_P(MethodDebug) (GP_Cq,GP_Pq(GetContentObjectFromObjType) );
  1467.  
  1468.     SQUAWK("> Invoked %s::GrafPartGetContentObjectFromObjType()\n", GP_Cq);
  1469.  
  1470.     switch ( objType )
  1471.     {
  1472.  
  1473.         // is type intrinsic Point?
  1474.         case COBJ_GRAFPART_POIN:
  1475.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Poin\n", GP_Cq);
  1476.             *contentObject = (ContentObject*) new ContentGrafPartPoin();
  1477.             break;
  1478.  
  1479.         // is type intrinsic Line?
  1480.         case COBJ_GRAFPART_LINE:
  1481.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Line\n", GP_Cq);
  1482.             *contentObject = (ContentObject*) new ContentGrafPartLine();
  1483.             break;
  1484.  
  1485.         // is type intrinsic Rectangle?
  1486.         case COBJ_GRAFPART_RECT:
  1487.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Rect\n", GP_Cq);
  1488.             *contentObject = (ContentObject*) new ContentGrafPartRect();
  1489.             break;
  1490.  
  1491.         // is type intrinsic Text?
  1492.         case COBJ_GRAFPART_TEXT:
  1493.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Text\n", GP_Cq);
  1494.             *contentObject = (ContentObject*) new ContentGrafPartText();
  1495.             break;
  1496.  
  1497.  
  1498. /*  Handling clauses for additional figure types, uncomment as they are implemented
  1499.         // is type intrinsic Ellipse?
  1500.         case COBJ_GRAFPART_ELLI:
  1501.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Elli\n", GP_Cq);
  1502.             *contentObject = (ContentObject*) new ContentGrafPartElli();
  1503.             break;
  1504.  
  1505.         // is type intrinsic Circle?
  1506.         case COBJ_GRAFPART_CIRC:
  1507.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Circ\n", GP_Cq);
  1508.             *contentObject = (ContentObject*) new ContentGrafPartCirc();
  1509.             break;
  1510.  
  1511.         // is type intrinsic Polyline?
  1512.         case COBJ_GRAFPART_PLIN:
  1513.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Plin\n", GP_Cq);
  1514.             *contentObject = (ContentObject*) new ContentGrafPartPlin();
  1515.             break;
  1516.  
  1517.         // is type intrinsic Polygon?
  1518.         case COBJ_GRAFPART_PGON:
  1519.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Pgon\n", GP_Cq);
  1520.             *contentObject = (ContentObject*) new ContentGrafPartPgon();
  1521.             break;
  1522.  
  1523.         // is type intrinsic Freehand?
  1524.         case COBJ_GRAFPART_FREE:
  1525.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Free\n", GP_Cq);
  1526.             *contentObject = (ContentObject*) new ContentGrafPartFree();
  1527.             break;
  1528.  
  1529.         // is type intrinsic Text?
  1530.         case COBJ_GRAFPART_TEXT:
  1531.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Text\n", GP_Cq);
  1532.             *contentObject = (ContentObject*) new ContentGrafPartText();
  1533.             break;
  1534.  
  1535.         // is type intrinsic Image?
  1536.         case COBJ_GRAFPART_IMAG:
  1537.             SQUAWK("\t%s::GrafPartGetContentObjectFromObjType(): creating new Imag\n", GP_Cq);
  1538.             *contentObject = (ContentObject*) new ContentGrafPartImag();
  1539.             break;
  1540. */
  1541.  
  1542.         // none of the above, pass on to parent
  1543.         default:
  1544.             parent_GetContentObjectFromObjType(  somSelf,
  1545.                                                                         ev,
  1546.                                                                         objType,
  1547.                                                                         contentObject);
  1548.             break;
  1549.     }   // switch: which ContentObject type?
  1550.     SQUAWK("< Leaving %s::GrafPartGetContentObjectFromObjType()\n", GP_Cq);
  1551.     return;
  1552. }   // GrafPartGetContentObjectFromObjType()
  1553.  
  1554.  
  1555. // -------------------------------------------------------------------------
  1556. // GrafPart --> MoveSelectionToFront
  1557. //
  1558. //     Wraps a call to Parent's MoveSelectionToFront().
  1559. //
  1560. //     -> public override method
  1561. //     -> calls parent first
  1562. // -------------------------------------------------------------------------
  1563.  
  1564. SOM_Scope   void    SOMLINK GP_P(MoveSelectionToFront) (   GP_C *somSelf,
  1565.                                                             Environment*    ev )
  1566. {
  1567.     SQUAWK("> Invoked %s::MoveSelectionToFront()\n", GP_Cq);
  1568.  
  1569.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1570.     GP_P(MethodDebug) (GP_Cq, GP_Pq(MoveSelectionToFront) );
  1571.  
  1572.     try
  1573.     {
  1574.         parent_MoveSelectionToFront( somSelf, ev);   // call parent
  1575.         somSelf->HandleRefresh(ev);                                         // refresh the screen
  1576.     }
  1577.     catch(...)
  1578.     {
  1579.         SQUAWK("\t%s::MoveSelectionToFront(): CAUGHT EXCEPTION\n", GP_Cq);
  1580.     }
  1581.  
  1582.     SQUAWK("< Leaving %s::MoveSelectionToFront()\n", GP_Cq);
  1583.     return;
  1584. }   // MoveSelectionToFront()
  1585.  
  1586.  
  1587. // -------------------------------------------------------------------------
  1588. // GrafPart --> MoveSelectionToBack
  1589. //
  1590. //     Wraps a call to Parent's MoveSelectionToBack().
  1591. //
  1592. //     -> public override method
  1593. //     -> calls parent first
  1594. // -------------------------------------------------------------------------
  1595.  
  1596. SOM_Scope   void    SOMLINK GP_P(MoveSelectionToBack) (    GP_C *somSelf,
  1597.                                                             Environment*    ev )
  1598. {
  1599.     SQUAWK("> Invoked %s::MoveSelectionToBack()\n", GP_Cq);
  1600.  
  1601.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1602.     GP_P(MethodDebug) (GP_Cq, GP_Pq(MoveSelectionToBack) );
  1603.  
  1604.     try
  1605.     {
  1606.         parent_MoveSelectionToBack( somSelf, ev);    // call parent
  1607.         somSelf->HandleRefresh(ev);                                         // refresh the screen
  1608.     }
  1609.     catch(...)
  1610.     {
  1611.         SQUAWK("\t%s::MoveSelectionToBack(): CAUGHT EXCEPTION\n", GP_Cq);
  1612.     }
  1613.  
  1614.     SQUAWK("< Leaving %s::MoveSelectionToBack()\n", GP_Cq);
  1615.     return;
  1616. }   // MoveSelectionToBack()
  1617.  
  1618.  
  1619. // -------------------------------------------------------------------------
  1620. // GrafPart --> PasteSelection
  1621. //
  1622. //     Wraps a call to Parent's PasteSelection().
  1623. //
  1624. //     -> public override method
  1625. //     -> calls parent first
  1626. // -------------------------------------------------------------------------
  1627.  
  1628. SOM_Scope   void    SOMLINK GP_P(PasteSelection) ( GP_C *somSelf,
  1629.                                                     Environment*    ev,
  1630.                                                     ODFacet*        facet,
  1631.                                                     ODPoint*        point )
  1632. {
  1633.     SQUAWK("> Invoked %s::PasteSelection()\n", GP_Cq);
  1634.  
  1635.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1636.     GP_P(MethodDebug) (GP_Cq, GP_Pq(PasteSelection) );
  1637.  
  1638.     try
  1639.     {
  1640.         parent_PasteSelection( somSelf, ev, facet, point);   // call parent
  1641.         somSelf->HandleRefresh(ev);                                         // refresh the screen
  1642.     }
  1643.     catch(...)
  1644.     {
  1645.         SQUAWK("\t%s::PasteSelection(): CAUGHT EXCEPTION\n", GP_Cq);
  1646.     }
  1647.  
  1648.     SQUAWK("< Leaving %s::PasteSelection()\n", GP_Cq);
  1649.     return;
  1650. }   // PasteSelection()
  1651.  
  1652.  
  1653. // =========================================================================
  1654. //
  1655. //     Public local methods: GrafPart
  1656. //
  1657. // =========================================================================
  1658.  
  1659. // -------------------------------------------------------------------------
  1660. // GrafPart --> HandleRefresh
  1661. //
  1662. //      Event handler: menu selection "Refresh screen", invalidate all frames
  1663. //          associated with this instance of GrafPart
  1664. //
  1665. //     -> public local method
  1666. // -------------------------------------------------------------------------
  1667. SOM_Scope   ODBoolean   SOMLINK GP_P(HandleRefresh) (  GP_C *somSelf,
  1668.                                                         Environment*    ev )
  1669. {
  1670.     SQUAWK("> Invoked %s::HandleRefresh()\n", GP_Cq);
  1671.  
  1672.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1673.     GP_P(MethodDebug) (GP_Cq,GP_Pq(HandleRefresh) );
  1674.  
  1675.     ALinkedList* frameList = somSelf->GetDisplayFrames(ev); // get the list of display frames
  1676.     ALink*       frameIter;                                 // define an iterator on the frame list
  1677.  
  1678.     try
  1679.     {
  1680.         for(frameIter = frameList->First(ev);   // for each object in the frame list
  1681.             frameIter->Content(ev);
  1682.             frameIter = frameIter->Next(ev) )
  1683.         {
  1684.             // invalidate each frame to make it redraw everything
  1685.             ( (ODFrame*) (frameIter->Content(ev) ) )->Invalidate(ev, kODNULL, kODNULL);
  1686.         }   // for: each frame link
  1687.     }       // try
  1688.     catch(...)
  1689.     {
  1690.         SQUAWK("\t%s::HandleRefresh(): CAUGHT EXCEPTION, returning False\n", GP_Cq);
  1691.         return( kODTrue );
  1692.     }
  1693.  
  1694.     SQUAWK("< Leaving %s::HandleRefresh(): returning True\n", GP_Cq);
  1695.     return( kODTrue );
  1696. }   // HandleRefresh()
  1697.  
  1698.  
  1699. // =========================================================================
  1700. //
  1701. //     Private local methods: GrafPart
  1702. //
  1703. // =========================================================================
  1704.  
  1705. // -------------------------------------------------------------------------
  1706. // GrafPart --> Reset
  1707. //
  1708. //      Terminate current action and reset editor state to default
  1709. //
  1710. //      -> private local method
  1711. // -------------------------------------------------------------------------
  1712. SOM_Scope   ODBoolean   SOMLINK GP_P(Reset) (  GP_C *somSelf,
  1713.                                                 Environment*    ev )
  1714. {
  1715.     SQUAWK("> Invoked %s::Reset()\n", GP_Cq);
  1716.  
  1717.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1718.     GP_P(MethodDebug) (GP_Cq,GP_Pq(Reset) );
  1719.  
  1720.     try
  1721.     {
  1722.         // check that we're not in the middle of an action
  1723.         if ( _fAction==CMD(GrafPartAdd) )
  1724.         {
  1725.             SQUAWK("\t%s::Reset(): terminating Add action for type: %d\n", GP_Cq, _fCurrObjType);
  1726.             _fCurrShape->Release(ev);                               // delete temp shapes for rubberbanding
  1727.             _fTempShape->Release(ev);                               // delete temp shapes for rubberbanding
  1728.             ( (ContentGrafPartFigr *)_fCurrObj )
  1729.                     ->Uninitialize(ev);                             // unset up object in progrss
  1730.             delete _fCurrObj;                                       // deallocate the object
  1731.         }
  1732.  
  1733.         // reset all local instance variables to default values
  1734.         _fAction      = kODCommandGrafPartSelect;   // Action: Select (default)
  1735.         _fActionType  = kODSingleAction;            // ActionType: single action
  1736.         _fCurrObj     = kODNULL;                    // reset current object buffer in progress
  1737.         _fCurrObjType = kODNULL;                    // reset current object type buffer in progress
  1738.         _fCurrShape   = kODNULL;                    // reset current object shape buffer
  1739.         _fTempShape   = kODNULL;                    // reset current object shape buffer
  1740.         memset(&_fPt, 0, sizeof(ODPoint) );         // zero out temp point
  1741.  
  1742.     }       // try
  1743.     catch(...)
  1744.     {
  1745.         SQUAWK("\t%s::Reset(): CAUGHT EXCEPTION, returning False\n", GP_Cq);
  1746.         return( kODTrue );
  1747.     }
  1748.  
  1749.     SQUAWK("< Leaving %s::Reset(): returning True\n", GP_Cq);
  1750.     return( kODTrue );
  1751. }   // Reset()
  1752.  
  1753.  
  1754. // -------------------------------------------------------------------------
  1755. // GrafPart --> AddIntrinsic
  1756. //
  1757. //     Create and cache a new intrinsic object
  1758. //
  1759. //     -> private local method
  1760. // -------------------------------------------------------------------------
  1761. SOM_Scope   ODBoolean   SOMLINK GP_P(AddIntrinsic)  (   GP_C        *somSelf,
  1762.                                                         Environment *ev,
  1763.                                                         ODFrame     *frame,
  1764.                                                         COType      cotype )
  1765. {
  1766.     SQUAWK("> Invoked %s::AddIntrinsic()\n", GP_Cq);
  1767.  
  1768.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1769.     GP_P(MethodDebug) (GP_Cq,GP_Pq(AddIntrinsic) );
  1770.  
  1771.     SQUAWK("\t%s::AddIntrinsic(): received  Frame: %lX\n", GP_Cq, frame);
  1772.     SQUAWK("\t%s::AddIntrinsic(): received COType: %d\n", GP_Cq, cotype);
  1773.  
  1774.  
  1775.     try
  1776.     {
  1777.         // create and cache a new intrinsic object
  1778.         _fAction      = CMD(GrafPartAdd);                       // Action: add and intrinsic object
  1779.         _fActionType  = kODBeginAction;                         // begin multipart action
  1780.         _fCurrObjType = cotype;                                 // cache the new object's COtype
  1781.         somSelf->GetContentObjectFromObjType(ev, cotype, &_fCurrObj);   // create a new object
  1782.     }   // try
  1783.  
  1784.     catch(...)
  1785.     {
  1786.         SQUAWK("< Leaving %s::AddIntrinsic(): CAUGHT EXCEPTION, returning False\n", GP_Cq);
  1787.         return( kODFalse );
  1788.     }   // catch
  1789.  
  1790.     SQUAWK("< Leaving %s::AddIntrinsic(): returning True\n", GP_Cq);
  1791.     return( kODTrue );
  1792. }   // AddIntrinsic()
  1793.  
  1794.  
  1795. // -------------------------------------------------------------------------
  1796. // GrafPart --> UpdateIntrinsic
  1797. //
  1798. //     Update a new intrinsic object in progress with a new point
  1799. //
  1800. //     -> private local method
  1801. // -------------------------------------------------------------------------
  1802. SOM_Scope   ODBoolean   SOMLINK GP_P(UpdateIntrinsic) (    GP_C *somSelf,
  1803.                                                             Environment*    ev,
  1804.                                                             ODFrame*        frame,
  1805.                                                             ODPoint*        point )
  1806. {
  1807.     SQUAWK("> Invoked %s::UpdateIntrinsic()\n", GP_Cq);
  1808.  
  1809.     GP_P(Data) *somThis = GP_P(GetData) (somSelf);
  1810.     GP_P(MethodDebug) (GP_Cq,GP_Pq(UpdateIntrinsic) );
  1811.  
  1812.     SQUAWK("\t%s::UpdateIntrinsic(): received Frame: %lX\n", GP_Cq, frame);
  1813.     SQUAWK("\t%s::UpdateIntrinsic(): received Point: %d,%d\n", GP_Cq, ODFixedToInt(point->x), ODFixedToInt(point->y) );
  1814.  
  1815.     try
  1816.     {
  1817.         // pass the point to the intrinsic object
  1818.         ( (ContentGrafPartFigr *) _fCurrObj )->Update(ev, point);       // update object with point
  1819.         ( (ContentGrafPartFigr *) _fCurrObj )->AdjustBoundingRect(ev);  // update object's boundry
  1820.     }   // try
  1821.  
  1822.     catch(...)
  1823.     {
  1824.         SQUAWK("< Leaving %s::UpdateIntrinsic(): CAUGHT EXCEPTION, returning False\n", GP_Cq);
  1825.         return( kODFalse );
  1826.     }   // catch
  1827.  
  1828.     SQUAWK("< Leaving %s::UpdateIntrinsic(): returning True\n", GP_Cq);
  1829.     return( kODTrue );
  1830. }   // UpdateIntrinsic()
  1831.  
  1832.  
  1833. // =========================================================================
  1834. // End of file: iodgraph.cpp
  1835. // =========================================================================
  1836.