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

  1. /* @(#) 1.86 com/src/samples/basecntr/bcevent.cpp, odbasepart, od96os2, odos29712d 3/17/97 21:34:35 [3/21/97 17:37:47] */
  2.  
  3. //====START_GENERATED_PROLOG======================================
  4. //
  5. //
  6. //   COMPONENT_NAME: odsamples
  7. //
  8. //   CLASSES: none
  9. //
  10. //   ORIGINS: 82,27
  11. //
  12. //
  13. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  14. //   All Rights Reserved
  15. //   Licensed Materials - Property of IBM
  16. //   US Government Users Restricted Rights - Use, duplication or
  17. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  18. //
  19. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  22. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  23. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  24. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  25. //   OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. //====END_GENERATED_PROLOG========================================
  28. //
  29. //
  30. // -------------------------------------------------------------------------
  31. // -----                                                               -----
  32. // -----                  BaseContainer Class                          -----
  33. // -----                                                               -----
  34. // -----                 Event Handling Methods                        -----
  35. // -----                                                               -----
  36. // -------------------------------------------------------------------------
  37.  
  38. #ifndef BaseContainerMethodDebug
  39.    #define BaseContainerMethodDebug(c,m) SOMMethodDebug(c,m)
  40. #endif
  41. #define VARIABLE_MACROS
  42. #define SOM_DONT_IMPORT_CLASS_ALink
  43. #define SOM_DONT_IMPORT_CLASS_ALinkedList
  44. #define SOM_DONT_IMPORT_CLASS_BaseContainer
  45. #define SOM_DONT_IMPORT_CLASS_BCIterator
  46. #define SOM_DONT_IMPORT_CLASS_ContentObject
  47. #define SOM_DONT_IMPORT_CLASS_ContentFrame
  48.  
  49. // This MUST be the first include to override ODPoint and ODRect defs
  50. #include <AltPoint.h>
  51.  
  52. #include <BArray.h>
  53. #include <FocusLib.h>
  54. #include <ODMath.h>
  55. #ifdef _PLATFORM_AIX_
  56. #include <odres.h>
  57. #else
  58. #include <ODRes.h>
  59. #endif
  60. #include <ODTypes.h>
  61. #include <StorUtil.h>
  62. #include <TempObj.h>
  63. #include <WinUtils.h>
  64.  
  65.  
  66. #ifndef  SOM_BCIterator_xh
  67. #include <iodbcitr.xh>
  68. #endif
  69.  
  70. #ifndef SOM_ODArbitrator_xh
  71. #include <Arbitrat.xh>
  72. #endif
  73.  
  74. #ifndef SOM_ODCanvas_xh
  75. #include <Canvas.xh>
  76. #endif
  77.  
  78. #ifndef SOM_ODClipboard_xh
  79. #include <Clipbd.xh>
  80. #endif
  81.  
  82. #ifndef SOM_ODDragItemIterator_xh
  83. #include <DgItmIt.xh>
  84. #endif
  85.  
  86. #ifndef SOM_ODDragAndDrop_xh
  87. #include <DragDrp.xh>
  88. #endif
  89.  
  90. #ifndef SOM_ODFacet_xh
  91. #include <Facet.xh>
  92. #endif
  93.  
  94. #ifndef SOM_ODFocus_xh
  95. #include <Foci.xh>
  96. #endif
  97.  
  98. #ifndef SOM_ODFocusSet_xh
  99. #include <FocusSet.xh>
  100. #endif
  101.  
  102. #ifndef SOM_ODFrame_xh
  103. #include <Frame.xh>
  104. #endif
  105.  
  106. #ifndef SOM_ODFrameFacetIterator_xh
  107. #include <FrFaItr.xh>
  108. #endif
  109.  
  110. #ifndef SOM_ODFacetIterator_xh
  111. #include <FacetItr.xh>
  112. #endif
  113.  
  114. #ifndef SOM_ODMenubar_xh
  115. #include <MenuBar.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODSession_xh
  119. #include <ODSessn.xh>
  120. #endif
  121.  
  122. #ifndef SOM_ODPlatformCanvas_xh
  123. #include <PlatCanv.xh>
  124. #endif
  125.  
  126. #ifndef SOM_ODShape_xh
  127. #include <Shape.xh>
  128. #endif
  129.  
  130. #ifndef SOM_Module_xh5cStdProps_OpenDoc_StdProps_defined
  131. #include <StdProps.xh>
  132. #endif
  133.  
  134. #ifndef SOM_Module_xh5cStdTypes_OpenDoc_StdTypes_defined
  135. #include <StdTypes.xh>
  136. #endif
  137.  
  138. #ifndef SOM_ODStorageUnit_xh
  139. #include <StorageU.xh>
  140. #endif
  141.  
  142. #ifndef SOM_ODTransform_xh
  143. #include <Trnsform.xh>
  144. #endif
  145.  
  146. #ifndef SOM_ODInfo_xh
  147. #include <Info.xh>
  148. #endif
  149.  
  150. #ifndef SOM_ODWindow_xh
  151. #include <Window.xh>
  152. #endif
  153.  
  154. #if defined(_PLATFORM_WIN32_)
  155.  
  156. #ifndef SOM_ODWin32Canvas_xh
  157. #include <WinPCanv.xh>
  158. #endif
  159.  
  160. #endif // defined win32
  161.  
  162.  
  163. #if defined(_PLATFORM_OS2_)
  164.  
  165. #ifndef SOM_ODOS2Canvas_xh
  166. #include <OS2PCanv.xh>
  167. #endif
  168.  
  169. #endif // defined OS2
  170.  
  171. #ifdef _PLATFORM_UNIX_
  172. #include <AIXPCanv.xh>
  173. #include <AIXWCanv.xh>
  174. #endif
  175.  
  176. #ifndef SOM_ODWindowState_xh
  177. #include <WinStat.xh>
  178. #endif
  179.  
  180. #ifndef _ODHELP_
  181. #include <odhelp.xh>
  182. #endif
  183.  
  184. #if defined(_PLATFORM_AIX_)
  185. #   define QPRINTF printf
  186. #   include <Xm/XmAll.h>
  187. #   include <X11/cursorfont.h>
  188.  
  189. #elif defined(_PLATFORM_OS2_)
  190. #   define QPRINTF qprintf
  191.  
  192. #   define INCL_DOS
  193. #   define INCL_GPI
  194. #   define INCL_GPIPOLYGON
  195. #   define INCL_WIN
  196. #   define INCL_WINFRAMEMGR
  197. #   define INCL_WINPOINTERS
  198. #   define INCL_WINWINDOWMGR
  199. #   define INCL_WINHELP
  200. #   include <os2.h>
  201.  
  202. #elif defined(_PLATFORM_WIN32_)
  203. #   include <windows.h>
  204. #   include <winuser.h>
  205. #   include <wingdi.h>
  206.  
  207. #endif
  208.  
  209. #include <iostream.h>
  210. #include <stdio.h>
  211. #include <string.h>
  212. #include <ODRegApi.h>
  213. #include <locale.h>
  214. #include <wchar.h>
  215. #include <ODDebug.h>
  216.  
  217.  
  218. #include <iodbasec.xih>
  219.  
  220. #ifndef OD_PRINT //This isn't defined on WIN32 for some reason???
  221.                  //Even though we now get the menu event directly for a
  222.                  //DOC_PRINT, we should still get an OD_PRINT when a
  223.                  //document is dragged to a printer.
  224. #define OD_PRINT DOC_PRINT
  225. #endif
  226.  
  227.  
  228. /********************************************************************
  229.   STRUCTURES FOR MOVE/RESIZE/LASSO
  230. ********************************************************************/
  231.  
  232. typedef struct bc_movedata {
  233.  
  234.    ODShape *shape;
  235.    ODTransform *transform;
  236.    CFocus *focus;
  237. #if defined(_PLATFORM_WIN32_)
  238.    HDC dc;
  239. #elif defined(_PLATFORM_OS2_)
  240.    HPS dc;
  241.    ODTransform *contentXform;
  242. #elif defined(_PLATFORM_UNIX_)
  243.    GC dc;
  244.    Window win;
  245.    ODTransform *contentXform;
  246. #endif
  247.    ODPoint lastPoint;
  248.    ODPoint firstPoint;
  249.  
  250. } BC_MoveData;
  251.  
  252.  
  253. typedef struct bc_lassodata {
  254.  
  255.    CFocus *focus;
  256. #if defined(_PLATFORM_WIN32_)
  257.    HDC dc;
  258. #elif defined(_PLATFORM_OS2_)
  259.    HPS dc;
  260. #elif defined(_PLATFORM_UNIX_)
  261.    GC dc;
  262.    Window win;
  263.    ODTransform *contentXform;
  264. #endif
  265.    ODPoint lastPoint;
  266.    ODPoint firstPoint;
  267.    ODShape *shape;
  268.  
  269. } BC_LassoData;
  270.  
  271.  
  272. typedef struct resizedata {
  273.  
  274.    CFocus *focus;
  275. #if defined(_PLATFORM_WIN32_)
  276.    HDC dc;
  277. #elif defined(_PLATFORM_OS2_)
  278.    HPS dc;
  279.    ODTransform *contentXform;
  280. #elif defined(_PLATFORM_UNIX_)
  281.    GC dc;
  282.    Window win;
  283.    ODTransform *contentXform;
  284. #endif
  285.    ODRect bbox;
  286.    ODPoint firstPoint;
  287.    ODPoint lastPoint;
  288.    ODPoint anchorPoint;
  289.    ODShape *shape;
  290.    ContentObject *cobj;
  291.    ODULong resizeFlags;
  292.  
  293. } BC_ResizeData;
  294.  
  295.  
  296. /********************************************************************
  297.   HELPER FUNCTIONS
  298. ********************************************************************/
  299. ContentFrame *GetContentObjectForFrame(ODFrame *frame, ALinkedList *l)
  300. {
  301.  
  302.    ALink *itr;
  303.    ContentFrame *cobj;
  304.    Environment *ev = somGetGlobalEnvironment();
  305.    for(itr = l->First(ev); itr->Content(ev); itr=itr->Next(ev)) {
  306.        cobj = (ContentFrame *) itr->Content(ev);
  307.        if ((cobj->_get_objType(ev) == COBJ_FRAMECLASS) && (cobj->_get_myFrame(ev) == frame))
  308.           return cobj;
  309.    }
  310.    return kODNULL;
  311. }
  312.  
  313. void WinPt2FramePt (Environment *ev, ODEventData *event, ODEventInfo *eventinfo,
  314.                                ODPoint *cursorLocation, ODFacet *facet)
  315. {
  316.  
  317. #if defined(_PLATFORM_WIN32_)
  318.       cursorLocation->x = ODIntToFixed(LOWORD(event->lParam));
  319.       cursorLocation->y = ODIntToFixed(HIWORD(event->lParam));
  320. #elif defined(_PLATFORM_OS2_)
  321.       cursorLocation->x = ODIntToFixed(SHORT1FROMMP(event->mp1));
  322.       cursorLocation->y = ODIntToFixed(SHORT2FROMMP(event->mp1));
  323. #elif defined(_PLATFORM_UNIX_)
  324.       cursorLocation->x = eventinfo->where.x;
  325.       cursorLocation->y = eventinfo->where.y;
  326. #endif
  327.  
  328.       TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
  329.       xform->InvertPoint (ev, cursorLocation);
  330.  
  331. }
  332.  
  333. #define x_between(val, left, right) ((val > left) && (val < right))
  334.  
  335. void dumpRect(char *str, ODRect r)
  336. {
  337.    PRINT("%s l:%d r:%d t:%d b:%d\n", str, r.left >> 16, r.right >> 16, r.top >> 16, r.bottom >> 16);
  338. }
  339.  
  340. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  341.    #define y_between(val, top, bottom) ((val > top) && (val < bottom))
  342. #elif defined(_PLATFORM_OS2_)
  343.    #define y_between(val, top, bottom) ((val > bottom) && (val < top))
  344. #endif
  345.  
  346. #if defined(_PLATFORM_UNIX_)
  347. #define min(a,b) (a)<(b) ? (a) : (b)
  348. #define max(a,b) (a)>(b) ? (a) : (b)
  349. #endif
  350.  
  351. extern ODFacet* FirstFacet (Environment *ev, ODFrame *frame);
  352.  
  353.  
  354. #if defined(_PLATFORM_OS2_)
  355.  
  356. //---------------------------------------------------------------------------
  357. // VK_SHIFT  VK_CTRL  VK_ALT  VK_CAPSLOCK  VK_NUMLOCK  VK_SCRLLOCK VK_ALTGRAF
  358. //---------------------------------------------------------------------------
  359. BOOL  key_shift( SHORT vk_key )
  360. {
  361.   SHORT key_state = WinGetKeyState( HWND_DESKTOP, vk_key );
  362.   return (BOOL)( key_state & 0x8000 );
  363. }
  364.  
  365. #endif // defined OS2
  366.  
  367.  
  368. // -------------------------------------------------
  369. // List of Methods
  370. // -------------------------------------------------
  371. // ODPart --> AdjustMenus
  372. // ODPart --> HandleEvent
  373. //
  374. // BaseContainer --> CompleteMoveOperation
  375. // BaseContainer --> CompleteResizeOperation
  376. // BaseContainer --> HandleMouseUp
  377. // BaseContainer --> HandleMenuEvent
  378. // BaseContainer --> MoveSelectionToFront
  379. // BaseContainer --> MoveSelectionToBack
  380. // BaseContainer --> SelectEmbeddedPart
  381.  
  382.  
  383.  
  384. //--------------------------------------------------------------------------
  385. // ODPart --> AdjustMenus
  386. //
  387. //      Should prepare this part's menus for display.
  388. //
  389. //      ->
  390. //--------------------------------------------------------------------------
  391.  
  392. SOM_Scope       void
  393. SOMLINK         BaseContainerAdjustMenus
  394.                 (
  395.                 BaseContainer   *somSelf,       // in
  396.                 Environment     *ev,            // in
  397.                 ODFrame         *frame          // in
  398.                 )
  399. {
  400.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  401.     BaseContainerMethodDebug("BaseContainer","BaseContainerAdjustMenus");
  402.  
  403.     ODBoolean gotCB;       // can we get clipboard focus from RequestFocus
  404.     ODULong numSelected = _fSelectedObjects->Count(ev);
  405.     ODULong numEmbedded = _fEmbeddedObjects->Count(ev);
  406.     ODBoolean bEnable = kODFalse;
  407.  
  408.     try {
  409.  
  410.       ODBoolean isRoot = frame!=kODNULL ? frame->IsRoot(ev) : kODFalse;
  411.       ODArbitrator *arbitrator = _fSession->GetArbitrator(ev);
  412.       TempODFrame menuFocusOwner = arbitrator->
  413.                                    AcquireFocusOwner(ev, _fSession->Tokenize(ev, kODMenuFocus));
  414.  
  415.       // Check if this frame owns the menu focus.
  416.       if(menuFocusOwner == frame) {
  417.  
  418.         gotCB = arbitrator->RequestFocus(ev,_fClipboardFocus, frame);
  419.  
  420.         // access the menubar object for menuitem enablemment
  421.         _fMenuBar->Acquire(ev);         // enable/disable specific entries
  422.  
  423.         bEnable = (!_fDraftReadOnly) && (numSelected == 1);
  424.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(Move), bEnable);
  425.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(MoveFront), (!_fDraftReadOnly) && numSelected);
  426.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(MoveBack), (!_fDraftReadOnly) && numSelected);
  427.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, CMD(Resize), bEnable);
  428.  
  429.         // or OPEN, DELETE or DESELECT them
  430.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELECTALL, numSelected != numEmbedded);
  431.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DESELECTALL, numSelected);
  432.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_OPENSEL, numSelected);
  433.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_DELETE, numSelected && (!_fDraftReadOnly));
  434.  
  435.         // if we have the CLIPBOARD and things are selected...
  436.         bEnable = numSelected && gotCB;
  437.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CUT, bEnable && (!_fDraftReadOnly));
  438.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_COPY, bEnable);
  439.  
  440.         // can we paste anything? Yes enable PASTE items and disable others
  441.          bEnable = (_fSession->GetClipboard(ev)->CanEmbed(ev)) && (!_fDraftReadOnly);
  442.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTE, bEnable);
  443.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_PASTEAS, kODFalse);
  444.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_SELPROPERTIES, numSelected == 1);
  445.  
  446.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_INSERT,      kODFalse);
  447.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_CREATE,      kODFalse);
  448.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_UNDO,      kODFalse);
  449.         _fMenuBar->EnableMenuItem(ev, IDMS_EDIT, EDIT_REDO,      kODFalse);
  450.         _fMenuBar->EnableMenu(ev, kODCommandLinksMenu, kODFalse);
  451.  
  452.         //enable view properties item
  453.         _fMenuBar->EnableMenuItem(ev, IDMS_VIEW, VIEW_PROPERTIES, kODTrue);
  454.  
  455.         //enable View->Show As items if this is not a root frame.
  456.         if(!isRoot) {
  457.            _fMenuBar->EnableMenuItem(ev, IDMS_VIEW, VIEW_SHOWAS, kODTrue);
  458.         }
  459.  
  460.         //enable our own menu items
  461.         _fMenuBar->EnableMenuItem(ev, kODOptionsMenuID, CMD(ColorCHANGE), !_fDraftReadOnly);
  462.  
  463.         _fMenuBar->EnableMenu(ev, kODEmbedMenuID, !_fDraftReadOnly);
  464.  
  465.         _fMenuBar->Release(ev);
  466.  
  467.         if (gotCB)
  468.            arbitrator->RelinquishFocus(ev, _fClipboardFocus, frame);
  469.  
  470.       } // end if menu focus owner
  471.  
  472.  
  473.       // With or without the menu focus, if this is a root frame it is
  474.       // responsible to enable/disable the Print and PageSetup menu items.
  475.       if (isRoot) {
  476.  
  477.         ODWindowState *winState = _fSession->GetWindowState(ev);
  478.         TempODMenuBar currentMenu = winState->AcquireCurrentMenuBar(ev);
  479.  
  480. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  481.         currentMenu->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_SETUP, _fPrintingEnabled);
  482.         currentMenu->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_PRINT, _fPrintingEnabled);
  483. #else
  484.         currentMenu->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_SETUP, kODFalse);
  485.         currentMenu->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_PRINT, kODFalse);
  486. #endif
  487.       } // end if root
  488.  
  489.     } // end of try block
  490.     catch (...) {}
  491.  
  492. }
  493.  
  494.  
  495.  
  496. //--------------------------------------------------------------------------
  497. // ODPart --> HandleEvent
  498. //
  499. //      Should attempt to handle the specified user event.
  500. //
  501. //      ->
  502. //--------------------------------------------------------------------------
  503.  
  504. SOM_Scope       ODBoolean
  505. SOMLINK         BaseContainerHandleEvent
  506.                 (
  507.                 BaseContainer   *somSelf,       // in
  508.                 Environment     *ev,            // in
  509.                 ODEventData     *event,         // inout
  510.                 ODFrame         *frame,         // in
  511.                 ODFacet         *facet,         // in
  512.                 ODEventInfo     *eventInfo      // inout
  513.                 )
  514. {
  515.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  516.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleEvent");
  517.  
  518.  
  519.     ODBoolean eventHandled = kODFalse;
  520.  
  521.     try {
  522.  
  523. #if  defined(_PLATFORM_WIN32_)
  524.     switch (event->message)
  525. #elif defined(_PLATFORM_OS2_)
  526.     switch (event->msg)
  527. #elif defined(_PLATFORM_UNIX_)
  528.     XButtonEvent* button_struct  = (XButtonEvent*) event;
  529.     switch (event->type)
  530. #endif
  531.         {
  532.         case kODEvtActivate:
  533.                 // If activating
  534. #if  defined(_PLATFORM_WIN32_)
  535.                 if (LOWORD(event->wParam) != WA_INACTIVE)
  536. #elif defined(_PLATFORM_OS2_)
  537.                 if (SHORT1FROMMP(event->mp1) != kODEvtInactive)
  538. #elif defined(_PLATFORM_UNIX_)
  539.                 if (eventInfo->originalType == FocusIn)
  540. #endif
  541.                 {
  542.                     // Handle the window activation
  543.                     somSelf->ActivatingWindow(ev, frame);
  544.                 }
  545.                 else
  546.                 {
  547.                     // Handle the window deactivation
  548.                     somSelf->DeactivatingWindow(ev, frame);
  549.                 }
  550.                 break;
  551.  
  552.         case kODEvtMouseUp:
  553.  
  554.                 eventHandled = somSelf->HandleMouseUp
  555.                                         (ev,event,frame,facet, eventInfo);
  556.                 break;
  557.  
  558.         case kODEvtMouseDown:
  559.  
  560.                 eventHandled = somSelf->HandleMouseDown
  561.                                         (ev, event, frame, facet, eventInfo);
  562.                 break;
  563.  
  564.         case kODEvtMouseDownBorder:
  565.                 // Mouse Down in Embedded facet border - select request
  566.  
  567.                 somSelf->ActivateFrame(ev, frame);
  568.                 somSelf->SelectContentObject(ev,
  569.                                (ContentObject*)GetContentObjectForFrame
  570.                                (eventInfo->embeddedFrame, _fEmbeddedObjects));
  571.                 eventHandled = kODTrue;
  572.                 break;
  573.  
  574.         case kODEvtMouseUpEmbedded:
  575.  
  576.                 {
  577.                    ODTypeToken frameType = _fSession->Tokenize(ev,kODViewAsFrame);
  578.  
  579.                    ODBoolean isIcon = ((eventInfo->embeddedFrame) &&
  580.                              (eventInfo->embeddedFrame->GetViewType(ev) != frameType));
  581.                    somSelf->ActivateFrame(ev, frame);
  582. #if  defined(_PLATFORM_WIN32_)
  583.                    if(isIcon || (event->wParam & MK_SHIFT) || (event->wParam & MK_CONTROL))
  584. #elif defined(_PLATFORM_OS2_)
  585.                    if (isIcon || key_shift(VK_CTRL) || key_shift(VK_SHIFT))
  586. #elif defined(_PLATFORM_UNIX_)
  587.                    if (isIcon ||  (button_struct->state & ShiftMask) ||
  588.                         (button_struct->state & ControlMask) )
  589. #endif
  590.  
  591.                    {
  592.                       somSelf->SelectContentObject(ev,
  593.                                  (ContentObject*)GetContentObjectForFrame
  594.                                  (eventInfo->embeddedFrame,_fEmbeddedObjects));
  595.                    }
  596.                    eventHandled = kODTrue;
  597.                 }
  598.                 break;
  599.  
  600.         case kODEvtMouseDownEmbedded:
  601.                 {
  602.                    somSelf->ActivateFrame(ev, frame);
  603.  
  604.                    // Make sure the frame is selected. This prevents us from 
  605.                    // attempting to drag unselected frames displaying as
  606.                    // icon/thumbnail.
  607.                    ContentObject *selectedObject = (ContentObject*)GetContentObjectForFrame(eventInfo->embeddedFrame, _fSelectedObjects);
  608.  
  609. #if  defined(_PLATFORM_WIN32_)
  610.                    if (!((event->wParam & MK_SHIFT) ||
  611.                          (event->wParam & MK_CONTROL)) &&
  612.                        selectedObject)
  613. #elif defined(_PLATFORM_OS2_)
  614.                    if (!(key_shift(VK_CTRL) || key_shift(VK_SHIFT)) &&
  615.                        (eventInfo->originalType == WM_BEGINDRAG) &&
  616.                        selectedObject)
  617. #elif defined(_PLATFORM_UNIX_)
  618.                    if ( !((button_struct->state & ShiftMask) ||
  619.                           (button_struct->state & ControlMask)) &&
  620.                        selectedObject)
  621. #endif
  622.                       {
  623.                          somSelf->StartDrag(ev, event, eventInfo->embeddedFrame,
  624.                                    facet, eventInfo,
  625.                                    (_fDraftReadOnly)?kODCloneCopy:kODCloneCut);
  626.                       }
  627.                    eventHandled = kODTrue;
  628.                 }
  629.                 break;
  630.  
  631.  
  632.         case kODEvtMenu:
  633.  
  634.                 eventHandled = somSelf->HandleMenuEvent(ev, frame, event);
  635.                 break;
  636.  
  637. #if (defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_))
  638.         case WM_MOUSEMOVE:
  639. #elif defined(_PLATFORM_UNIX_)
  640.         case MotionNotify:
  641. #endif
  642.                 eventHandled = somSelf->HandleMouseMove
  643.                                           (ev, event, frame, facet, eventInfo);
  644.                 break;
  645.  
  646.  
  647.         case kODEvtKeyUp:
  648.  
  649.                 eventHandled = somSelf->HandleKeyEvent (ev, event, frame, facet, eventInfo);
  650.                 break;
  651.  
  652.  
  653.         case OD_HELP:
  654.         {
  655.           ODHelp * help;
  656. #if defined(_PLATFORM_WIN32_)
  657.           if (LOWORD(event->wParam) == HLPM_ODMENU)
  658. #elif defined(_PLATFORM_OS2_)
  659.           if (SHORT1FROMMP(event->mp1) == HLPM_ODMENU)  // if F1 on Menu
  660. #elif defined(_PLATFORM_UNIX_)
  661.           if (event->type == HLPM_ODMENU)  // if F1 on Menu
  662. #endif
  663.           {
  664. #if  defined(_PLATFORM_WIN32_)
  665.             switch  (event->lParam)
  666. #elif defined(_PLATFORM_OS2_)
  667.             switch (SHORT1FROMMP(event->mp2))
  668. #elif defined(_PLATFORM_UNIX_)
  669.             switch (event->type)
  670. #endif
  671.             {
  672.              case kODCommandMoveFront:
  673.                 help = _fSession->GetHelp(ev);
  674.                 help->DisplayHelp(ev,"iodbasec.hlp",200);
  675.                 eventHandled = kODTrue;
  676.                 break;
  677.              case kODCommandMoveBack:
  678.                 help = _fSession->GetHelp(ev);
  679.                 help->DisplayHelp(ev,"iodbasec.hlp",201);
  680.                 eventHandled = kODTrue;
  681.                 break;
  682.              case kODCommandMove:
  683.                 help = _fSession->GetHelp(ev);
  684.                 help->DisplayHelp(ev,"iodbasec.hlp",202);
  685.                 eventHandled = kODTrue;
  686.                 break;
  687.              case kODCommandResize:
  688.                 help = _fSession->GetHelp(ev);
  689.                 help->DisplayHelp(ev,"iodbasec.hlp",203);
  690.                 eventHandled = kODTrue;
  691.                 break;
  692.              case kODCommandColorCHANGE:
  693.                 help = _fSession->GetHelp(ev);
  694.                 help->DisplayHelp(ev,"iodbasec.hlp",205);
  695.                 eventHandled = kODTrue;
  696.                 break;
  697.              case kODOptionsMenuID:
  698.                 help = _fSession->GetHelp(ev);
  699.                 help->DisplayHelp(ev,"iodbasec.hlp",206);
  700.                 eventHandled = kODTrue;
  701.                 break;
  702.              case kODEmbedMenuID:
  703.                 help = _fSession->GetHelp(ev);
  704.                 help->DisplayHelp(ev,"iodbasec.hlp",204);
  705.                 eventHandled = kODTrue;
  706.                 break;
  707.              default:
  708. #if  defined(_PLATFORM_WIN32_)
  709.                 if ((event->lParam >= kODCommandParts) &&
  710.                     (event->lParam < CMD_Offset_Subclass))
  711. #elif defined(_PLATFORM_OS2_)
  712.                 if ((SHORT1FROMMP(event->mp2) >= kODCommandParts) &&
  713.                     (SHORT1FROMMP(event->mp2) < CMD_Offset_Subclass))
  714. #elif defined(_PLATFORM_UNIX_)
  715.                 break;  // no-op
  716. #endif
  717.                 {
  718.                 help = _fSession->GetHelp(ev);
  719.                 help->DisplayHelp(ev,"iodbasec.hlp",204);
  720.                 eventHandled = kODTrue;
  721.                 break;
  722.                 }
  723.                 break;
  724.  
  725.            } // end switch stmt
  726.         } // end if HLPM_ODWINDOW
  727.         else  {}  // HLPM_ODWINDOW  not implemented      if F1 on Part
  728.         } // end OD_HELP
  729.         break;
  730.  
  731.  
  732. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  733.         case OD_PRINT:
  734.                 eventHandled = somSelf->HandlePrinting(ev, frame, event);
  735.                 break;
  736.  
  737. #ifdef _PLATFORM_OS2_
  738.         case WM_CHAR: //below returns FALSE if non-scrolling key
  739. #endif
  740. #ifdef _PLATFORM_WIN32_
  741.         case WM_KEYDOWN: //below returns FALSE if non-scrolling key
  742. #endif
  743.         case WM_HSCROLL:
  744.         case WM_VSCROLL:
  745.                 eventHandled = somSelf->HandleScrollEvent(ev, frame, event);
  746.                 break;
  747. #endif
  748.  
  749. #ifdef _PLATFORM_WIN32_
  750.         case WM_RBUTTONDOWN:
  751.         case WM_MBUTTONDOWN:
  752.         case WM_RBUTTONUP:
  753.         case WM_MBUTTONUP:
  754.         case WM_LBUTTONDBLCLK:
  755.         case WM_RBUTTONDBLCLK:
  756.         case WM_MBUTTONDBLCLK:
  757.                 {
  758.                    TempODFrame mouseOwner = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fMouseFocus);
  759.                    // Capture these messages if we are tracking our
  760.                    // mouse events. This prevents an embedded part from
  761.                    // taking over the mouse focus and eating up the
  762.                    // kODEvtMouseUp event which we must process.
  763.                    if((mouseOwner == frame) && (_usMouseMode != kMouseModeNull)){
  764.                       eventHandled = kODTrue;
  765.                    }
  766.                 }
  767.                 break;
  768. #endif
  769.  
  770.         default:
  771.                 break;
  772.         }                                                      /* endswitch*/
  773.  
  774.  
  775.     } // end of try block
  776.     catch (...) {}
  777.  
  778.     return eventHandled;
  779. }
  780.  
  781.  
  782. //--------------------------------------------------------------------------
  783. // BaseContainer --> CompleteMoveOperation
  784. //
  785. //      Perform the actual movement of an embedded part.
  786. //
  787. //      ->
  788. //--------------------------------------------------------------------------
  789.  
  790. SOM_Scope       void
  791. SOMLINK         BaseContainerCompleteMoveOperation
  792.                 (
  793.                 BaseContainer   *somSelf,           // in
  794.                 Environment     *ev,                // in
  795.                 ODFrame          *containingFrame,   // in
  796.                 ODPoint           *offset              // in
  797.                 )
  798. {
  799.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  800.     BaseContainerMethodDebug("BaseContainer", "BaseContainerCompleteMoveOperation");
  801.  
  802.  
  803.     try {
  804.  
  805.         // get selected object to Move (we only move the 1st one)
  806.         ALink* itr;
  807.         for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr = itr->Next(ev))
  808.         {
  809.              ContentObject* selectedObject = (ContentObject*) itr->Content(ev);
  810.              selectedObject->MoveBy(ev, offset);
  811.         }
  812.  
  813.         containingFrame->Invalidate(ev, kODNULL, kODNULL);
  814.         somSelf->CreateSelectionBorderShapes (ev, kODNULL);
  815.         somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  816.  
  817.         somSelf->ChangeNotification (ev, BCC_MOVE, containingFrame, kODNULL, kODTrue, kODNULL);
  818.  
  819.     } // end of try block
  820.     catch (...) {}
  821.  
  822.  
  823. }
  824.  
  825. //--------------------------------------------------------------------------
  826. // BaseContainer --> CompleteResizeOperation
  827. //
  828. //      Perform the actual resizing of the frame of an embbedded part.
  829. //
  830. //      ->
  831. //--------------------------------------------------------------------------
  832.  
  833. SOM_Scope       void
  834. SOMLINK         BaseContainerCompleteResizeOperation
  835.                 (
  836.                 BaseContainer   *somSelf,           // in
  837.                 Environment     *ev,                // in
  838.                 ContentObject   *contentObject,     // in
  839.                 ODULong         resizeFlags,        // in
  840.                 ODPoint         *winPoint,           // in
  841.                 ODFacet         *facet)
  842. {
  843.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  844.     BaseContainerMethodDebug("BaseContainer", "BaseContainerCompleteResizeOperation");
  845.  
  846.  
  847.     try {
  848.  
  849.         ContentObject *cobj = contentObject;
  850.         if (!cobj)
  851.            cobj = (ContentObject *)_fSelectedObjects->First(ev)->Content(ev);
  852.  
  853.         // get the old shape for invalidation
  854.         ODRect rect = cobj->_get_boundingRect(ev);
  855.         TempODShape oldShape = facet->CreateShape(ev);
  856.         oldShape->SetRectangle (ev, &rect);
  857.         oldShape->Union (ev, _fSelectShape);
  858.         oldShape->Outset(ev, kODBorderWidth);
  859.  
  860.         cobj->Resize(ev, winPoint, resizeFlags);
  861.  
  862.         somSelf->CreateSelectionBorderShapes (ev, kODNULL);
  863.  
  864.         // invalidate the selection shape
  865.         TempODShape tempShape = _fSelectShape->Copy(ev);
  866.         tempShape->Outset(ev, kODBorderWidth);
  867.         tempShape->Union(ev, oldShape);
  868.  
  869.         // get tempShape in frame coordinate from content coordinate
  870.         ODFrame *myFrame = cobj->_get_containingFrame (ev);
  871.         TempODTransform intXform = myFrame->AcquireInternalTransform (ev, kODNULL);
  872.         tempShape->Transform (ev, intXform);
  873.  
  874.         facet->Invalidate(ev, tempShape, kODNULL);
  875.         somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  876.  
  877.         somSelf->ChangeNotification (ev, BCC_RESIZE, facet->GetFrame (ev), cobj, kODTrue, kODNULL);
  878.  
  879.     } // end of try block
  880.     catch (...) {}
  881.  
  882. }
  883.  
  884. //--------------------------------------------------------------------------
  885. // BaseContainer --> HandleMouseUp
  886. //
  887. //      Handle a mouse up event from the user.
  888. //
  889. //      ->
  890. //--------------------------------------------------------------------------
  891.  
  892. SOM_Scope       ODBoolean
  893. SOMLINK         BaseContainerHandleMouseUp
  894.                 (
  895.                 BaseContainer   *somSelf,       // in
  896.                 Environment     *ev,            // in
  897.                 ODEventData     *event,         // in
  898.                 ODFrame         *frame,         // in
  899.                 ODFacet         *facet,          // in
  900.                 ODEventInfo     *eventInfo      // inout
  901.                 )
  902. {
  903.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  904.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseUp");
  905.  
  906.     ODBoolean   eventHandled     = kODTrue;
  907.  
  908.     try {
  909.  
  910.     // let's relinquish mouse focus first
  911.     _fSession->GetArbitrator(ev)->RelinquishFocus (ev, _fMouseFocus, frame);
  912.     _fSession->GetArbitrator(ev)->RelinquishFocus (ev, _fMouseFocusOutside, frame);
  913.  
  914.     if (_bcMouseTrack.simEvent == kBCSingleClick)
  915.        eventHandled = somSelf->HandleMouseClick (ev, event, frame, facet, eventInfo);
  916.  
  917.     else if (_bcMouseTrack.simEvent == kBCMouseDrag)
  918.        eventHandled = somSelf->HandleMouseMotionEnd (ev, event, frame, facet, eventInfo);
  919.  
  920.  
  921.     memset (&_bcMouseTrack, 0, sizeof (BC_MOUSETRACK));
  922.  
  923.     } // end of try block
  924.     catch (...) {}
  925.  
  926.     return eventHandled;
  927. }
  928.  
  929.  
  930. //--------------------------------------------------------------------------
  931. // BaseContainer --> HandleMouseDown
  932. //
  933. //      Handle a mouse down event from the user.
  934. //
  935. //      ->
  936. //--------------------------------------------------------------------------
  937.  
  938. SOM_Scope       ODBoolean
  939. SOMLINK         BaseContainerHandleMouseDown
  940.                 (
  941.                 BaseContainer   *somSelf,       // in
  942.                 Environment     *ev,            // in
  943.                 ODEventData     *event,         // in
  944.                 ODFrame         *frame,         // in
  945.                 ODFacet         *facet,          // in
  946.                 ODEventInfo     *eventInfo      // inout
  947.                 )
  948. {
  949.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  950.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseDown");
  951.  
  952.     ODBoolean   eventHandled     = kODTrue;
  953.  
  954.     try {
  955.  
  956.     if ( !somSelf->ActivateFrame(ev, frame) )
  957.     {
  958.          // We were unable to acquire the necessary focus and activate.
  959.          return kODFalse;
  960.     }
  961.  
  962.         ODBoolean rc  = _fSession->GetArbitrator(ev)->RequestFocus (ev, _fMouseFocus, frame);
  963.         ODBoolean rc1 = _fSession->GetArbitrator(ev)->RequestFocus (ev, _fMouseFocusOutside, frame);
  964.  
  965.     if (rc) {
  966.  
  967.        memset (&_bcMouseTrack, 0, sizeof (BC_MOUSETRACK));
  968.        _bcMouseTrack.hotSpot.x = ODFixedRound(eventInfo->where.x);
  969.        _bcMouseTrack.hotSpot.y = ODFixedRound(eventInfo->where.y);
  970.        _bcMouseTrack.simEvent = kBCSingleClick;
  971.        memcpy(&(_bcMouseTrack.event), event, sizeof(ODEventData));
  972.        memcpy(&(_bcMouseTrack.eventInfo), eventInfo, sizeof(ODEventInfo));
  973.  
  974.        TempODShape fShape = frame->AcquireFrameShape (ev, kODNULL);
  975.        TempODTransform intXform = frame->AcquireInternalTransform (ev, kODNULL);
  976.        TempODShape tempShape = fShape->Copy(ev);
  977.        tempShape->InverseTransform (ev, intXform);
  978.        tempShape->GetBoundingBox (ev, &(_bcMouseTrack.frameRect));
  979.  
  980. #if   defined(_PLATFORM_UNIX_)
  981.        _bcMouseTrack.maxDistance.x = MAX_PIXEL;
  982.        _bcMouseTrack.maxDistance.y = MAX_PIXEL;
  983. #elif defined(_PLATFORM_OS2_)
  984.        _bcMouseTrack.maxDistance.x = WinQuerySysValue(HWND_DESKTOP,SV_CXDBLCLK);
  985.        _bcMouseTrack.maxDistance.y = WinQuerySysValue(HWND_DESKTOP,SV_CYDBLCLK);
  986. #elif defined(_PLATFORM_WIN32_)
  987.        _bcMouseTrack.maxDistance.x = GetSystemMetrics(SM_CXDOUBLECLK);
  988.        _bcMouseTrack.maxDistance.y = GetSystemMetrics(SM_CYDOUBLECLK);
  989. #endif  // PLATFORM SPECIFIC
  990.  
  991.     }  // end of if rc to check for Focus
  992. #ifdef ODDebug
  993.     else
  994.        PRINT("Mouse focus failed\n");
  995. #endif
  996.  
  997.     } // end of try block
  998.     catch (...) {}
  999.  
  1000.     return eventHandled;
  1001. }
  1002.  
  1003.  
  1004. //--------------------------------------------------------------------------
  1005. // BaseContainer --> HandleMouseMove
  1006. //
  1007. //      Handle a mouse move event and set the cursor
  1008. //
  1009. //      ->
  1010. //--------------------------------------------------------------------------
  1011.  
  1012. SOM_Scope       ODBoolean
  1013. SOMLINK         BaseContainerHandleMouseMove
  1014.                 (
  1015.                 BaseContainer   *somSelf,       // in
  1016.                 Environment     *ev,            // in
  1017.                 ODEventData     *event,         // in
  1018.                 ODFrame         *frame,         // in
  1019.                 ODFacet         *facet,          // in
  1020.                 ODEventInfo     *eventInfo      // inout
  1021.                 )
  1022. {
  1023.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1024.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseMove");
  1025.  
  1026.     ODBoolean   eventHandled     = kODTrue;
  1027.  
  1028.     try {
  1029.  
  1030.     POINT  pt;
  1031.  
  1032.           pt.x = ODFixedRound(eventInfo->where.x);
  1033.           pt.y = ODFixedRound(eventInfo->where.y);
  1034.  
  1035.     if ((_bcMouseTrack.simEvent == kBCSingleClick) &&
  1036.        (abs(_bcMouseTrack.hotSpot.x - pt.x) > _bcMouseTrack.maxDistance.x ||
  1037.         abs(_bcMouseTrack.hotSpot.y - pt.y) > _bcMouseTrack.maxDistance.y ))
  1038.     {
  1039.         _bcMouseTrack.simEvent = kBCMouseDrag;
  1040.         eventHandled = somSelf->HandleMouseMotionStart (ev, &(_bcMouseTrack.event), frame, facet, &(_bcMouseTrack.eventInfo));
  1041.     }
  1042.  
  1043.     else if (_bcMouseTrack.simEvent == kBCMouseDrag)
  1044.         eventHandled = somSelf->HandleMouseMotionLBDown (ev, event, frame, facet, eventInfo);
  1045.  
  1046.     } // end of try block
  1047.     catch (...) {}
  1048.  
  1049.     return eventHandled;
  1050. }
  1051.  
  1052.  
  1053.  
  1054. //--------------------------------------------------------------------------
  1055. // BaseContainer --> HandleMouseClick
  1056. //
  1057. //      Handle a mouse click when mouse_up occurs
  1058. //
  1059. //      ->
  1060. //--------------------------------------------------------------------------
  1061.  
  1062. SOM_Scope       ODBoolean
  1063. SOMLINK         BaseContainerHandleMouseClick
  1064.                 (
  1065.                 BaseContainer   *somSelf,       // in
  1066.                 Environment     *ev,            // in
  1067.                 ODEventData     *event,         // in
  1068.                 ODFrame         *frame,         // in
  1069.                 ODFacet         *facet,          // in
  1070.                 ODEventInfo     *eventInfo      // inout
  1071.                 )
  1072. {
  1073.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1074.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseClick");
  1075.  
  1076.     ODBoolean   eventHandled     = kODTrue;
  1077.  
  1078.     try {
  1079.  
  1080. #ifdef ODDebug
  1081.     // PRINT("Mouse Click ..%d \n", somSelf);
  1082. #endif
  1083.     ODFacet* theFacet            = kODNULL;
  1084.  
  1085.     if ( facet != kODNULL )
  1086.     {
  1087.  
  1088.         ODPoint cursorLocation;
  1089.         WinPt2FramePt (ev, event, eventInfo, &cursorLocation, facet);
  1090.  
  1091.         if (_usMouseMode == kMouseModeEmbedFromMenu)
  1092.         {
  1093.              if (_fPartToEmbed) // are we placing a new part?
  1094.              {
  1095.  
  1096.                  ODTransform* newExternalTransform = frame->CreateTransform(ev);
  1097.                  newExternalTransform->SetOffset(ev, &cursorLocation);
  1098.  
  1099.                  // create and embed a new part
  1100.  
  1101.                  somSelf->Embed(ev, _fPartToEmbed, frame,
  1102.                                            newExternalTransform);
  1103.                  // reset _fPartToEmbed for next embed operation
  1104.                  _usMouseMode = kMouseModeNull;
  1105.                  _fPartToEmbed = kODNULL;
  1106.              }
  1107.  
  1108.         }
  1109.  
  1110.         else if (_usMouseMode == kMouseModeTrackMove) // this is the completion of a Move
  1111.         {
  1112.              ODRect bbox;
  1113.              _fSelectShape->GetBoundingBox (ev, &bbox);
  1114.  
  1115.              ODPoint offset(cursorLocation);
  1116.              offset.x -= bbox.left;
  1117.              offset.y -= bbox.top;
  1118.  
  1119.              somSelf->CompleteMoveOperation(ev, frame, &offset);
  1120.         }
  1121.  
  1122.         else if (_usMouseMode == kMouseModeTrackResize) // this is the completion of a Resize
  1123.         {
  1124.  
  1125.              ODULong resizeFlags = 0;
  1126.              resizeFlags = COBJ_RESIZE_BOTTOM | COBJ_RESIZE_RIGHT;
  1127.              somSelf->CompleteResizeOperation(ev, kODNULL, resizeFlags, &cursorLocation, facet);
  1128.         }
  1129.  
  1130.         else if (_usMouseMode == kMouseModeTrackPaste)
  1131.              somSelf->PasteSelection(ev, facet, &cursorLocation);
  1132.  
  1133.         else if (_usMouseMode == kMouseModeTrackPasteAs)
  1134.              somSelf->PasteSelectionAs (ev, facet, &cursorLocation);
  1135.  
  1136.         else if (_fSelectedObjects->Count(ev))
  1137.               somSelf->DeselectAll(ev);
  1138.  
  1139.         _usMouseMode = kMouseModeNull;
  1140.  
  1141.      } // if facet
  1142.  
  1143.     } // end of try block
  1144.     catch (ODException _exception) {
  1145.         _usMouseMode = kMouseModeNull;
  1146.         _fPartToEmbed = kODNULL;
  1147.  
  1148.     } // end of catch block
  1149.  
  1150.     return eventHandled;
  1151. }
  1152.  
  1153. //--------------------------------------------------------------------------
  1154. // BaseContainer --> HandleMouseMotionStart
  1155. //
  1156. //      Handle a mouse_motion_start event when mouse starts moving with MB1 down
  1157. //
  1158. //      ->
  1159. //--------------------------------------------------------------------------
  1160.  
  1161. SOM_Scope       ODBoolean
  1162. SOMLINK         BaseContainerHandleMouseMotionStart
  1163.                 (
  1164.                 BaseContainer   *somSelf,       // in
  1165.                 Environment     *ev,            // in
  1166.                 ODEventData     *event,         // in
  1167.                 ODFrame         *frame,         // in
  1168.                 ODFacet         *facet,          // in
  1169.                 ODEventInfo     *eventInfo      // inout
  1170.                 )
  1171. {
  1172.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1173.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseMotionStart");
  1174.  
  1175.     ODBoolean   eventHandled     = kODTrue;
  1176.  
  1177.     try {
  1178.  
  1179.        // Get the mouse point in frame coordinates
  1180.        ODPoint cursorLocation(ODIntToFixed(_bcMouseTrack.hotSpot.x),
  1181.                                  ODIntToFixed(_bcMouseTrack.hotSpot.y));
  1182.        ODFacet *myFacet = facet;
  1183.        if (!facet)
  1184.           myFacet = FirstFacet (ev, frame);
  1185.  
  1186.        TempODTransform xform = myFacet->AcquireWindowContentTransform (ev, kODNULL);
  1187.        xform->InvertPoint (ev, &cursorLocation);
  1188.  
  1189.        // check for resize
  1190.        ODBoolean cornerResize = _fCornerHandleShape->ContainsPoint (ev, &cursorLocation);
  1191.        ODBoolean edgeResize = _fEdgeHandleShape->ContainsPoint (ev, &cursorLocation);
  1192.  
  1193.        if ((!_fDraftReadOnly) && (cornerResize || edgeResize))
  1194.        {
  1195.           ContentObject *objToResize = kODNULL;
  1196.           ODULong resizeFlags = 0x0000;
  1197.           ALink *itr;
  1198.  
  1199.           // find the contentobject and type of resize
  1200.           for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr = itr->Next(ev))
  1201.           {
  1202.              ContentObject *cobj = (ContentObject *) itr->Content(ev);
  1203.              ODRect bbox = cobj->_get_boundingRect (ev);
  1204.  
  1205.              if (edgeResize)
  1206.              {
  1207.                 if ((abs(bbox.left - cursorLocation.x) <= kODBorderWidth)
  1208.                     && y_between (cursorLocation.y, bbox.top, bbox.bottom))
  1209.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_LEFT;
  1210.  
  1211.                 else if ((abs(bbox.right - cursorLocation.x) <= kODBorderWidth)
  1212.                          && y_between (cursorLocation.y, bbox.top, bbox.bottom))
  1213.                         objToResize=cobj, resizeFlags = COBJ_RESIZE_RIGHT;
  1214.  
  1215.                 else if ((abs(bbox.top - cursorLocation.y) <= kODBorderWidth)
  1216.                          && x_between (cursorLocation.x, bbox.left, bbox.right))
  1217.                         objToResize=cobj, resizeFlags = COBJ_RESIZE_TOP;
  1218.  
  1219.                 else if ((abs(bbox.bottom - cursorLocation.y) <= kODBorderWidth)
  1220.                          && x_between (cursorLocation.x, bbox.left, bbox.right))
  1221.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_BOTTOM;
  1222.               }
  1223.               else
  1224.               {
  1225.                 if ((abs(bbox.left - cursorLocation.x) <= kODBorderWidth)
  1226.                     && (abs(bbox.top - cursorLocation.y) <= kODBorderWidth))
  1227.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_LEFT | COBJ_RESIZE_TOP;
  1228.  
  1229.                 else if ((abs(bbox.left - cursorLocation.x) <= kODBorderWidth)
  1230.                     && (abs(bbox.bottom - cursorLocation.y) <= kODBorderWidth))
  1231.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_LEFT | COBJ_RESIZE_BOTTOM;
  1232.  
  1233.                 else if ((abs(bbox.right - cursorLocation.x) <= kODBorderWidth)
  1234.                     && (abs(bbox.top - cursorLocation.y) <= kODBorderWidth))
  1235.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_RIGHT | COBJ_RESIZE_TOP;
  1236.  
  1237.                 else if ((abs(bbox.right - cursorLocation.x) <= kODBorderWidth)
  1238.                     && (abs(bbox.bottom - cursorLocation.y) <= kODBorderWidth))
  1239.                    objToResize=cobj, resizeFlags = COBJ_RESIZE_RIGHT | COBJ_RESIZE_BOTTOM;
  1240.  
  1241.               }
  1242.  
  1243.              if (objToResize)
  1244.                 break;
  1245.  
  1246.           } // end for
  1247.  
  1248.  
  1249.           if (objToResize)
  1250.           {
  1251.              // fill data struct for resize
  1252.              _usMouseMode = kMouseModeTrackMouseResize;
  1253.              BC_ResizeData *sd = (BC_ResizeData *) SOMMalloc (sizeof (BC_ResizeData));
  1254. #if defined(_PLATFORM_UNIX_)
  1255.              ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  1256.                        (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  1257.              sd->win = aixwincanvas->GetWindow(ev);
  1258. #endif
  1259.  
  1260.              TempODShape frameShape = frame->AcquireFrameShape (ev, kODNULL);
  1261.              sd->focus = new CFocus (myFacet, frameShape, &(sd->dc));
  1262.  
  1263.              sd->bbox = objToResize->_get_boundingRect(ev);
  1264.              sd->firstPoint = sd->lastPoint = cursorLocation;
  1265.              sd->anchorPoint.x = sd->anchorPoint.y = 0;
  1266.  
  1267.              if (resizeFlags & COBJ_RESIZE_LEFT)
  1268.                 sd->anchorPoint.x = sd->bbox.right + kODBorderWidth;
  1269.              if (resizeFlags & COBJ_RESIZE_RIGHT)
  1270.                 sd->anchorPoint.x = sd->bbox.left - kODBorderWidth;
  1271.              if (resizeFlags & COBJ_RESIZE_TOP)
  1272. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  1273.                 sd->anchorPoint.y = sd->bbox.bottom + kODBorderWidth;
  1274. #elif defined(_PLATFORM_OS2_)
  1275.                 sd->anchorPoint.y = sd->bbox.bottom - kODBorderWidth;
  1276. #endif
  1277.              if (resizeFlags & COBJ_RESIZE_BOTTOM)
  1278. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  1279.                 sd->anchorPoint.y = sd->bbox.top - kODBorderWidth;
  1280. #elif defined(_PLATFORM_OS2_)
  1281.                 sd->anchorPoint.y = sd->bbox.top + kODBorderWidth;
  1282. #endif
  1283.              sd->shape = frame->CreateShape(ev);
  1284. #if defined(_PLATFORM_OS2_)
  1285.              sd->contentXform = myFacet->AcquireContentTransform (ev, kODNULL);
  1286. #elif defined(_PLATFORM_UNIX_)
  1287.              sd->contentXform = myFacet->AcquireContentTransform (ev, kODNULL);
  1288. #endif
  1289.              sd->cobj = objToResize;
  1290.              sd->resizeFlags = resizeFlags;
  1291.  
  1292.              _resizeData = (void*)sd;
  1293.  
  1294.           } // end if .. objToResize
  1295.        } // end if .. resize
  1296.  
  1297.        // check for move
  1298.        else if ((!_fDraftReadOnly) && (_fSelectShape->ContainsPoint (ev, &cursorLocation)))
  1299.        {
  1300.           // fill data struct for move
  1301.           _usMouseMode = kMouseModeTrackMouseMove;
  1302.           BC_MoveData *md = (BC_MoveData *) SOMMalloc (sizeof (BC_MoveData));
  1303.  
  1304. #if defined(_PLATFORM_UNIX_)
  1305.              ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  1306.                        (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  1307.              md->win = aixwincanvas->GetWindow(ev);
  1308. #endif
  1309.           TempODShape frameShape = frame->AcquireFrameShape (ev, kODNULL);
  1310.           md->focus = new CFocus (myFacet, frameShape, &(md->dc));
  1311.  
  1312.           md->lastPoint = md->firstPoint = cursorLocation;
  1313.           md->shape = _fSelectShape->Copy (ev);
  1314. #if defined(_PLATFORM_OS2_)
  1315.           md->contentXform = myFacet->AcquireContentTransform (ev, kODNULL);
  1316. #elif defined(_PLATFORM_UNIX_)
  1317.           md->contentXform = myFacet->AcquireContentTransform (ev, kODNULL);
  1318. #endif
  1319.           md->transform = myFacet->CreateTransform (ev);
  1320.  
  1321.           _moveData = (void*)md;
  1322.  
  1323.        } // end if move
  1324.        else
  1325.        {
  1326.           // perform lasso selection
  1327.           _usMouseMode = kMouseModeTrackLassoSelect;
  1328.           BC_LassoData *ld = (BC_LassoData *) SOMMalloc (sizeof (BC_LassoData));
  1329.           TempODShape frameShape = frame->AcquireFrameShape (ev, kODNULL);
  1330.           ld->focus = new CFocus (myFacet, frameShape, &(ld->dc));
  1331.           ld->lastPoint = ld->firstPoint = cursorLocation;
  1332. #if defined(_PLATFORM_UNIX_)
  1333.           ld->contentXform = myFacet->AcquireContentTransform (ev, kODNULL);
  1334.           ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  1335.                        (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  1336.           ld->win = aixwincanvas->GetWindow(ev);
  1337. #endif
  1338.           ld->shape = myFacet->CreateShape(ev);
  1339.  
  1340.           _lassoData = (void*)ld;
  1341.        }
  1342.  
  1343.     } // end of try block
  1344.     catch (...) {}
  1345.  
  1346.     return eventHandled;
  1347. }
  1348.  
  1349.  
  1350. //--------------------------------------------------------------------------
  1351. // BaseContainer --> HandleMouseMotionEnd
  1352. //
  1353. //      Handle a mouse_motion_End event when mouse stops moving with MB1 down
  1354. //
  1355. //      ->
  1356. //--------------------------------------------------------------------------
  1357.  
  1358. SOM_Scope       ODBoolean
  1359. SOMLINK         BaseContainerHandleMouseMotionEnd
  1360.                 (
  1361.                 BaseContainer   *somSelf,       // in
  1362.                 Environment     *ev,            // in
  1363.                 ODEventData     *event,         // in
  1364.                 ODFrame         *frame,         // in
  1365.                 ODFacet         *facet,          // in
  1366.                 ODEventInfo     *eventInfo      // inout
  1367.                 )
  1368. {
  1369.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1370.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseMotionEnd");
  1371.  
  1372.     ODBoolean   eventHandled     = kODTrue;
  1373.  
  1374.     try {
  1375.  
  1376.        // Get the mouse point in frame coordinates
  1377.        ODPoint cursorLocation;
  1378.        ODFacet *myFacet = facet;
  1379.        if (!facet)
  1380.           myFacet = FirstFacet (ev, frame);
  1381.  
  1382.        // check for end of resize operation
  1383.        if (_usMouseMode == kMouseModeTrackMouseResize)
  1384.        {
  1385.           WinPt2FramePt (ev, event, eventInfo, &cursorLocation, myFacet);
  1386.           BC_ResizeData *sd = (BC_ResizeData *) _resizeData;
  1387.  
  1388.           // Erase the last resize rectangle drawn
  1389.           somSelf->DrawResizeRectangle(ev, &cursorLocation, BCR_ERASE);
  1390.  
  1391.           delete sd->focus;
  1392.  
  1393.           // if mouse up is outside frame then use last point
  1394.           if (_bcMouseTrack.frameRect.Contains (cursorLocation) == kODFalse)
  1395.              cursorLocation = sd->lastPoint;
  1396.  
  1397.           // call resize
  1398.           somSelf->CompleteResizeOperation (ev, sd->cobj, sd->resizeFlags,
  1399.                                           &cursorLocation, myFacet);
  1400.  
  1401.           sd->shape->Release(ev);
  1402. #if  defined(_PLATFORM_OS2_)
  1403.           sd->contentXform->Release (ev);
  1404. #elif  defined(_PLATFORM_UNIX_)
  1405.           sd->contentXform->Release (ev);
  1406. #endif
  1407.           SOMFree(sd);
  1408.           _resizeData = kODNULL;
  1409.        }
  1410.  
  1411.        // check for end of move operation
  1412.        else if (_usMouseMode == kMouseModeTrackMouseMove)
  1413.        {
  1414.           WinPt2FramePt (ev, event, eventInfo, &cursorLocation, myFacet);
  1415.           BC_MoveData *md = (BC_MoveData *) _moveData;
  1416.  
  1417.           // if mouse up was outside the frame then use last point
  1418.           if (_bcMouseTrack.frameRect.Contains (cursorLocation) == kODFalse)
  1419.              cursorLocation = md->lastPoint;
  1420.  
  1421.           delete md->focus;
  1422.           md->shape->Release(ev);
  1423.           md->transform->Release(ev);
  1424. #if  defined(_PLATFORM_OS2_)
  1425.           md->contentXform->Release (ev);
  1426. #elif  defined(_PLATFORM_UNIX_)
  1427.           md->contentXform->Release (ev);
  1428. #endif
  1429.  
  1430.           // move the selection
  1431.           ODPoint delta(cursorLocation);
  1432.           delta -= md->firstPoint;
  1433.  
  1434.           somSelf->CompleteMoveOperation (ev, frame, &delta);
  1435.           SOMFree(md);
  1436.           _moveData = kODNULL;
  1437.  
  1438.        } // end if move
  1439.  
  1440.        // check for end of lasso select
  1441.        else if (_usMouseMode == kMouseModeTrackLassoSelect)
  1442.        {
  1443.           BC_LassoData *ld = (BC_LassoData *)_lassoData;
  1444.           delete ld->focus;
  1445.  
  1446.           ODRect lassoRect(ld->firstPoint , ld->lastPoint);
  1447.  
  1448.           // select objects
  1449.           ALink *itr;
  1450.           for (itr= _fEmbeddedObjects->First(ev); itr->Content(ev); itr = itr->Next(ev))
  1451.           {
  1452.              ContentObject *cobj = (ContentObject *) itr->Content(ev);
  1453.              if (cobj->_get_selectionState(ev) == kODFalse)
  1454.              {
  1455.                 ODRect bbox = cobj->_get_boundingRect(ev);
  1456.                 if (lassoRect.Contains(bbox))
  1457.                 {
  1458.                    cobj->_set_selectionState(ev, kODTrue);
  1459.                    _fSelectedObjects->AddLast (ev, cobj);
  1460.                    somSelf->CreateSelectionBorderShapes (ev, cobj);
  1461.  
  1462.                 } // end if .. bbox fits in lasso
  1463.              } // end if .. not selected
  1464.           } // end for
  1465.  
  1466.           ld->shape->SetRectangle (ev, &lassoRect);
  1467.           ld->shape->Outset (ev,kODBorderWidth);
  1468.  
  1469.           // get tempShape in frame coordinate from content coordinate
  1470.           TempODTransform intXform = frame->AcquireInternalTransform (ev, kODNULL);
  1471.           ld->shape->Transform (ev, intXform);
  1472.  
  1473.           frame->Invalidate (ev, ld->shape, kODNULL);
  1474.  
  1475.           ld->shape->Release(ev);
  1476. #if  defined(_PLATFORM_UNIX_)
  1477.           ld->contentXform->Release (ev);
  1478. #endif
  1479.           SOMFree(ld);
  1480.           _lassoData = kODNULL;
  1481.  
  1482.        } // end if lasso select
  1483.  
  1484.     } // end of try block
  1485.     catch (...) {}
  1486.  
  1487.     _usMouseMode = kMouseModeNull;
  1488.  
  1489.     return eventHandled;
  1490. }
  1491.  
  1492.  
  1493. //--------------------------------------------------------------------------
  1494. // BaseContainer --> HandleMouseMotionLBDown
  1495. //
  1496. //      Handle a mouse_motion_LBDown event when a mouse moves with MB1 down
  1497. //
  1498. //      ->
  1499. //--------------------------------------------------------------------------
  1500.  
  1501. SOM_Scope       ODBoolean
  1502. SOMLINK         BaseContainerHandleMouseMotionLBDown
  1503.                 (
  1504.                 BaseContainer   *somSelf,       // in
  1505.                 Environment     *ev,            // in
  1506.                 ODEventData     *event,         // in
  1507.                 ODFrame         *frame,         // in
  1508.                 ODFacet         *facet,          // in
  1509.                 ODEventInfo     *eventInfo      // inout
  1510.                 )
  1511. {
  1512.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1513.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMouseMotionLBDown");
  1514.  
  1515.     ODBoolean   eventHandled     = kODTrue;
  1516.  
  1517. #if defined(_PLATFORM_UNIX_)
  1518.      XRectangle rgnBox;
  1519. #endif
  1520.  
  1521.     try {
  1522.  
  1523.        // Get the mouse point in frame coordinates
  1524.        ODPoint cursorLocation;
  1525.        ODFacet *myFacet = facet;
  1526.        if (!facet)
  1527.           myFacet = FirstFacet (ev, frame);
  1528.  
  1529.        WinPt2FramePt (ev, event, eventInfo, &cursorLocation, myFacet);
  1530.  
  1531.        // if the mouse is outside my frame then return
  1532.        if (_bcMouseTrack.frameRect.Contains (cursorLocation) == kODFalse)
  1533.           return eventHandled;
  1534.  
  1535.        // check for move
  1536.        if (_usMouseMode == kMouseModeTrackMouseMove)
  1537.        {
  1538.           BC_MoveData *md = (BC_MoveData *) _moveData;
  1539.  
  1540.           ODPoint delta(cursorLocation);
  1541.           delta -= md->lastPoint;
  1542.           md->transform->SetOffset (ev, &delta);
  1543.           md->lastPoint = cursorLocation;
  1544.  
  1545.           // delete the old shapes and draw new ones
  1546. #if defined(_PLATFORM_WIN32_)
  1547.  
  1548.           HBRUSH  hairBrush = CreateSolidBrush(RGB(255, 255, 255));
  1549.           HBRUSH  hbrOld = SelectObject(md->dc, hairBrush);
  1550.           int oldROP2 = SetROP2(md->dc, R2_XORPEN);
  1551.  
  1552.           ODRgnHandle borderRgn  = md->shape->GetRegion(ev);
  1553.           FillRgn(md->dc, borderRgn, hairBrush);
  1554.           md->shape->Transform (ev, md->transform);
  1555.           borderRgn  = md->shape->GetRegion(ev);
  1556.           FillRgn(md->dc, borderRgn, hairBrush);
  1557.  
  1558.           SelectObject(md->dc, hbrOld);
  1559.           DeleteObject(hairBrush);
  1560.           SetROP2 (md->dc, oldROP2);
  1561.  
  1562. #elif defined (_PLATFORM_UNIX_)
  1563.          XSetForeground(_fDisplay, md->dc, 1);
  1564.          XSetLineAttributes(_fDisplay,md->dc,6, LineSolid, CapButt, JoinRound);
  1565.          XSetFunction(_fDisplay, md->dc, GXxor);
  1566.  
  1567.           md->shape->Transform (ev, md->contentXform);
  1568.           Region borderRgn  = md->shape->GetRegion(ev);
  1569.           XSetRegion(_fDisplay, md->dc, borderRgn);
  1570.           XClipBox(borderRgn, &rgnBox);
  1571.           XDrawRectangle(_fDisplay, md->win, md->dc,
  1572.                          rgnBox.x-1, rgnBox.y-1, rgnBox.width, rgnBox.height);
  1573.           md->shape->InverseTransform (ev, md->contentXform);
  1574.  
  1575.           md->shape->Transform (ev, md->transform);
  1576.           md->shape->Transform (ev, md->contentXform);
  1577.           borderRgn  = md->shape->GetRegion(ev);
  1578.           XSetRegion(_fDisplay, md->dc, borderRgn);
  1579.           XClipBox(borderRgn, &rgnBox);
  1580.           XDrawRectangle(_fDisplay, md->win, md->dc,
  1581.                          rgnBox.x-1, rgnBox.y-1, rgnBox.width, rgnBox.height);
  1582.           md->shape->InverseTransform (ev, md->contentXform);
  1583.  
  1584.          XSetLineAttributes(_fDisplay,md->dc,1, LineSolid, CapButt, JoinRound);
  1585.          XSetFunction(_fDisplay, md->dc, GXcopy);
  1586.          XFlush(_fDisplay);
  1587.  
  1588. #elif defined (_PLATFORM_OS2_)
  1589.  
  1590.           LONG mixOld = GpiQueryMix( md->dc);
  1591.           GpiSetMix (md->dc, FM_INVERT);
  1592.  
  1593.           md->shape->Transform (ev, md->contentXform);
  1594.           ODRgnHandle borderRgn  = md->shape->GetRegion(ev);
  1595.           GpiPaintRegion(md->dc, borderRgn);
  1596.           md->shape->InverseTransform (ev, md->contentXform);
  1597.           md->shape->Transform (ev, md->transform);
  1598.           md->shape->Transform (ev, md->contentXform);
  1599.           borderRgn  = md->shape->GetRegion(ev);
  1600.           GpiPaintRegion(md->dc, borderRgn);
  1601.           md->shape->InverseTransform (ev, md->contentXform);
  1602.  
  1603.            GpiSetMix (md->dc, mixOld);
  1604. #endif
  1605.  
  1606.        }
  1607.        else if (_usMouseMode == kMouseModeTrackLassoSelect)
  1608.        {
  1609.           BC_LassoData *ld = (BC_LassoData *) _lassoData;
  1610.  
  1611.           // delete the old rect and draw new one
  1612. #if defined(_PLATFORM_WIN32_)
  1613.  
  1614.           HBRUSH  hairBrush = CreateHatchBrush(HS_BDIAGONAL, RGB(255,255,255));
  1615.           HBRUSH  hbrOld = SelectObject(ld->dc, hairBrush);
  1616.           int oldROP2 = SetROP2(ld->dc, R2_XORPEN);
  1617.  
  1618.           for (int i = 0; i < 2; i++)
  1619.           {
  1620.              ODRect rect(ld->firstPoint, ld->lastPoint);
  1621.              ld->shape->SetRectangle (ev, &rect);
  1622.              ODRgnHandle hrgn = ld->shape->GetRegion(ev);
  1623.  
  1624.              FrameRgn(ld->dc, hrgn, hairBrush, 1, 1);
  1625.              ld->lastPoint = cursorLocation;
  1626.  
  1627.           } // end for
  1628.  
  1629.           SelectObject(ld->dc, hbrOld);
  1630.           DeleteObject(hairBrush);
  1631.           SetROP2 (ld->dc, oldROP2);
  1632.  
  1633. #elif defined (_PLATFORM_UNIX_)
  1634.  
  1635.           XSetForeground(_fDisplay, ld->dc, 1);
  1636.           XSetLineAttributes(_fDisplay,ld->dc,6,LineSolid, CapButt, JoinRound);
  1637.           XSetFunction(_fDisplay, ld->dc, GXxor);
  1638.  
  1639.           for (int i = 0; i < 2; i++)
  1640.           {
  1641.              ODRect rect(ld->firstPoint, ld->lastPoint);
  1642.              ld->shape->SetRectangle (ev, &rect);
  1643.  
  1644.              ld->shape->Transform (ev, ld->contentXform);
  1645.              Region hrgn = ld->shape->GetRegion(ev);
  1646.              XSetRegion(_fDisplay, ld->dc, hrgn);
  1647.              XClipBox(hrgn, &rgnBox);
  1648.              XDrawRectangle(_fDisplay, ld->win, ld->dc,
  1649.                           rgnBox.x-1, rgnBox.y-1, rgnBox.width, rgnBox.height);
  1650.              ld->lastPoint = cursorLocation;
  1651.  
  1652.           } // end for
  1653.  
  1654.           XSetLineAttributes(_fDisplay,ld->dc,1,LineSolid, CapButt, JoinRound);
  1655.           XSetFunction(_fDisplay, ld->dc, GXcopy);
  1656.           XFlush(_fDisplay);
  1657.  
  1658. #elif defined (_PLATFORM_OS2_)
  1659.  
  1660.           LONG mixOld = GpiQueryMix( ld->dc);
  1661.           GpiSetMix (ld->dc, FM_INVERT);
  1662.  
  1663.           for (int i = 0; i < 2; i++)
  1664.           {
  1665.              ODRect rect(ld->firstPoint, ld->lastPoint);
  1666.              ld->shape->SetRectangle (ev, &rect);
  1667.  
  1668.              POINTL orig = {FixedToInt (rect.left),  FixedToInt (rect.bottom)};
  1669.              GpiMove (ld->dc, &orig);
  1670.              POINTL ptl =  {FixedToInt (rect.right), FixedToInt (rect.top)};
  1671.              GpiBox(ld->dc, DRO_OUTLINE, &ptl, 0, 0);
  1672.              ld->lastPoint = cursorLocation;
  1673.  
  1674.           } // end for
  1675.  
  1676.           GpiSetMix (ld->dc, mixOld);
  1677. #endif
  1678.  
  1679.        } // end if lasso
  1680.  
  1681.        // check for resize
  1682.        else if (_usMouseMode == kMouseModeTrackMouseResize)
  1683.        {
  1684.  
  1685.           // delete the old shape and draw new one
  1686.           somSelf->DrawResizeRectangle(ev, &cursorLocation, BCR_REDRAW);
  1687.        } // end if ..  resize
  1688.  
  1689.     } // end of try block
  1690.  
  1691.     catch (...) {}
  1692.  
  1693.     return eventHandled;
  1694. }
  1695.  
  1696.  
  1697. //--------------------------------------------------------------------------
  1698. // BaseContainer --> HandleMenuEvent
  1699. //
  1700. //      Handle a menubar or pulldown menu selection event.
  1701. //
  1702. //      ->
  1703. //--------------------------------------------------------------------------
  1704.  
  1705. SOM_Scope       ODBoolean
  1706. SOMLINK         BaseContainerHandleMenuEvent
  1707.                 (
  1708.                 BaseContainer   *somSelf,       // in
  1709.                 Environment     *ev,            // in
  1710.                 ODFrame         *frame,         // in
  1711.                 ODEventData     *event          // in
  1712.                 )
  1713. {
  1714.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  1715.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleMenuEvent");
  1716.  
  1717.     ODBoolean   eventHandled     = kODFalse;
  1718.  
  1719.     try {
  1720.  
  1721.         ALink* itr                   = kODNULL;
  1722.  
  1723. #if   defined(_PLATFORM_UNIX_)
  1724.         ODMenuEventData* menu_event = (ODMenuEventData*) event;
  1725.         switch(menu_event->item)
  1726. #elif defined(_PLATFORM_WIN32_)
  1727.         switch(LOWORD(event->wParam)) // determine which menu pulldown it was
  1728. #elif defined(_PLATFORM_OS2_)
  1729.         switch(LONGFROMMP(event->mp1))
  1730. #endif
  1731.         {
  1732.             case CMD(PageSetup):
  1733.                  // SetupPrinting returns whether the setup changed,
  1734.                  // not whether the event was handled (we assume it was)
  1735.                  somSelf->SetupPrinting(ev, frame, event);
  1736.                  eventHandled=kODTrue;
  1737.                  break;
  1738.  
  1739.             case CMD(Print):
  1740.                  eventHandled=somSelf->HandlePrinting(ev, frame, event);
  1741.                  break;
  1742.  
  1743.             case CMD(Open):
  1744.                  // Open all selected frames into their own window(s)
  1745.                  // We need to copy selected list into a temp list since when
  1746.                  // a new window is opened, it grabs focus which makes us
  1747.                  // deselect everything and delete selected objects list
  1748.                  {
  1749.                     ALinkedList *tempList = new ALinkedList;
  1750.                     for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  1751.                        tempList->AddLast (ev, itr->Content(ev));
  1752.  
  1753.                     for (itr = tempList->First(ev); itr->Content(ev); itr=itr->Next(ev))
  1754.                     {
  1755.                         ContentFrame *selectedObject =
  1756.                              (ContentFrame *) itr->Content(ev);
  1757.                         if (selectedObject->_get_objType(ev) == COBJ_FRAMECLASS) {
  1758.                            ODFrame *selectedFrame = selectedObject->_get_myFrame(ev);
  1759.                            TempODPart tempprt = selectedFrame->AcquirePart(ev);
  1760.                            tempprt->Open(ev, selectedFrame);
  1761.                         }
  1762.                     }
  1763.  
  1764.                     delete tempList;
  1765.                  }
  1766.                  eventHandled=kODTrue;
  1767.                  break;
  1768.  
  1769.             case CMD(Undo):
  1770.                  eventHandled=kODTrue;
  1771.                  break;
  1772.  
  1773.             case CMD(Redo):
  1774.                  eventHandled=kODTrue;
  1775.                  break;
  1776.  
  1777.             case CMD(Cut):
  1778.                  somSelf->CutSelection(ev);
  1779.                  eventHandled=kODTrue;
  1780.                  break;
  1781.  
  1782.             case CMD(Copy):
  1783.                  somSelf->CopySelection(ev, kODCloneCopy);
  1784.                  eventHandled=kODTrue;
  1785.                  break;
  1786.  
  1787.             case CMD(Paste):
  1788.                  _usMouseMode = kMouseModeTrackPaste;
  1789.                  eventHandled=kODTrue;
  1790.                  break;
  1791.  
  1792.             case CMD(PasteAs):
  1793.                  _usMouseMode = kMouseModeTrackPasteAs;
  1794.                  eventHandled=kODTrue;
  1795.                  break;
  1796.  
  1797.             case CMD(Delete):
  1798.                  somSelf->DeleteSelection(ev, OBJECT_DELETED);
  1799.                  eventHandled=kODTrue;
  1800.                  break;
  1801.  
  1802.             case CMD(DeselectAll):
  1803.                  somSelf->DeselectAll (ev);
  1804.                  eventHandled=kODTrue;
  1805.                  break;
  1806.  
  1807.             case CMD(SelectAll):
  1808.                  somSelf->SelectAll(ev);
  1809.                  eventHandled=kODTrue;
  1810.                  break;
  1811.  
  1812.             case CMD(Move):
  1813.                  _usMouseMode = kMouseModeTrackMove;
  1814.                  _fDirty = kODTrue;
  1815.                  eventHandled=kODTrue;
  1816.                  break;
  1817.  
  1818.             case CMD(Resize):
  1819.                  _usMouseMode = kMouseModeTrackResize;
  1820.                  _fDirty = kODTrue;
  1821.                  eventHandled=kODTrue;
  1822.                  break;
  1823.  
  1824.             case CMD(MoveBack):
  1825.                  somSelf->MoveSelectionToBack(ev);
  1826.                  eventHandled=kODTrue;
  1827.                  break;
  1828.  
  1829.             case CMD(MoveFront):
  1830.                  somSelf->MoveSelectionToFront(ev);
  1831.                  eventHandled=kODTrue;
  1832.                  break;
  1833.  
  1834.             case CMD(Help):
  1835.                  {
  1836.                ODHelp *help = _fSession->GetHelp(ev);
  1837.                help->DisplayHelp(ev, "iodbasec.hlp", 100);
  1838.                eventHandled = kODTrue;
  1839.                break;
  1840.                  }
  1841.  
  1842.             case CMD(ColorCHANGE):
  1843.                  {
  1844.                  eventHandled = somSelf->HandleColorChange (ev, frame);
  1845.                  break;
  1846.                  }
  1847.  
  1848.             case CMD(PartInfo):
  1849.                  {
  1850.                      if (_fSelectedObjects->Count(ev) == 1) {
  1851.                          eventHandled = kODTrue;
  1852.                          ODBoolean hasWriteAccess = kODTrue;
  1853.                          ODInfo* info = _fSession->GetInfo(ev);
  1854.                          ContentFrame *cFrame = (ContentFrame *) _fSelectedObjects->First(ev)->Content(ev);
  1855.                          if (cFrame->_get_objType(ev) == COBJ_FRAMECLASS) {
  1856.                              ODFrame *selFrame = cFrame->_get_myFrame(ev);
  1857.                              ODFacet *selFacet = FirstFacet(ev, selFrame);
  1858.                              info->ShowPartFrameInfo(ev, selFacet, hasWriteAccess);
  1859.                          }
  1860.                      }
  1861.                  break;
  1862.                  }
  1863.  
  1864.             case CMD(ViewProperties):
  1865.                  {
  1866.                  _fSession->GetInfo(ev)->ShowPartFrameInfo(ev,FirstFacet(ev,frame), kODTrue);
  1867.                  eventHandled = kODTrue;
  1868.                  break;
  1869.                  }
  1870.  
  1871.             case CMD(ViewSmallIcon):
  1872.                  {
  1873.                  frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsSmallIcon));
  1874.                  somSelf->ViewTypeChanged(ev, frame);
  1875.                  eventHandled = kODTrue;
  1876.                  break;
  1877.                  }
  1878.  
  1879.             case CMD(ViewLargeIcon):
  1880.                  {
  1881.                  frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsLargeIcon));
  1882.                  somSelf->ViewTypeChanged(ev, frame);
  1883.                  eventHandled = kODTrue;
  1884.                  break;
  1885.                  }
  1886.  
  1887.             case CMD(ViewThumbNail):
  1888.                  {
  1889.                  frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsThumbnail));
  1890.                  somSelf->ViewTypeChanged(ev, frame);
  1891.                  eventHandled = kODTrue;
  1892.                  break;
  1893.                  }
  1894.  
  1895.             case CMD(ViewFrame):
  1896.                  {
  1897.                  frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));
  1898.                  somSelf->ViewTypeChanged(ev, frame);
  1899.                  eventHandled = kODTrue;
  1900.                  break;
  1901.                  }
  1902.  
  1903.             default:
  1904. #if defined(_PLATFORM_UNIX_)
  1905.                  int iPart = (menu_event->item)-CMD(Parts);
  1906.                  int mi    = menu_event->item;
  1907. #elif defined(_PLATFORM_WIN32_)
  1908.                  int iPart = LOWORD(event->wParam)-CMD(Parts);
  1909.                  int mi    = LOWORD(event->wParam);
  1910. #elif defined(_PLATFORM_OS2_)
  1911.                  int iPart = SHORT1FROMMP(event->mp1)-CMD(Parts);
  1912.                  int mi    = SHORT1FROMMP(event->mp1);
  1913. #endif
  1914.  
  1915.                  if ( (iPart >=0) &&
  1916.                       (iPart < (CMD_Offset_Subclass - kODCommandParts)) ) {
  1917.  
  1918.                      // store the part to be embedded (for use when the user picks
  1919.                      // the location to place the new embedded part
  1920.                      _fPartToEmbed = _fEmbedTable[iPart];
  1921.                      _usMouseMode = kMouseModeEmbedFromMenu;
  1922.                      eventHandled = kODTrue;
  1923.                      _fDirty = kODTrue;
  1924.  
  1925.                      break;
  1926.                  }
  1927.  
  1928.                  // if menuitem is within the valid range of part ids
  1929.                  // then we flag it as unused, otherwise we assume the
  1930.                  // DocShell will handle it.
  1931.                  else if(((mi>=MENUID_ROOTPART_FIRST) && (mi<=MENUID_ROOTPART_LAST))
  1932.                          || ((mi>=MENUID_ACTIVEPART_FIRST) && (mi<=MENUID_ACTIVEPART_LAST))) {
  1933. #if defined(__IBMCPP__) || defined(_IBMR2)
  1934.                      char *bcText;
  1935.                      nl_catd bcNlsCatalog;
  1936.            setlocale(LC_MESSAGES, NULL);
  1937.            bcNlsCatalog=catopen("iodbasec.cat",0);
  1938.            if (bcNlsCatalog == CATD_ERR)
  1939.            {
  1940.               PRINT("Could not open BaseContainer Message catalog!\n");
  1941.            }
  1942.                      bcText=catgets(bcNlsCatalog,
  1943.                                     BCMSG_SET,
  1944.                                     BC_MENUBAR_WARNING,
  1945.                                     "Don't know how to handle this menu choice: %d!\n");
  1946. #else
  1947.                      char bcText[256];
  1948.                      strcpy(bcText, "Don't know how to handle this menu choice: %d!\n");
  1949. #endif
  1950.  
  1951.                      char *msgText = new char[strlen(bcText)+20];
  1952.  
  1953. #if defined(_PLATFORM_UNIX_)
  1954.                      sprintf(msgText,bcText,event->type);
  1955.                      cout << msgText << endl;
  1956. #elif  defined(_PLATFORM_WIN32_)
  1957.                      sprintf(msgText,bcText,LOWORD(event->wParam));
  1958.                      MessageBox(NULL,msgText,"BaseContainer",MB_OK|MB_ICONWARNING);
  1959. #elif defined(_PLATFORM_OS2_)
  1960.                      sprintf(msgText,bcText,(event->mp2));
  1961.                      WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,msgText,bcText,0,MB_OK|MB_WARNING);
  1962. #endif
  1963.  
  1964.                      delete msgText;
  1965. #if defined(__IBMCPP__) || defined(_IBMR2)
  1966.                      catclose(bcNlsCatalog);
  1967. #endif
  1968.                  }
  1969.                  break;
  1970.  
  1971.         } // endswitch which menu pulldown?
  1972.  
  1973.  
  1974.  
  1975.  
  1976.     } // end of try block
  1977.     catch (...) {}
  1978.  
  1979.  
  1980.     return eventHandled;
  1981. }
  1982.  
  1983.  
  1984. //--------------------------------------------------------------------------
  1985. // BaseContainer --> HandleKeyEvent
  1986. //
  1987. //      Handle keyboard input -- base container handles only ESC key
  1988. //
  1989. //      ->
  1990. //--------------------------------------------------------------------------
  1991.  
  1992. SOM_Scope       ODBoolean
  1993. SOMLINK         BaseContainerHandleKeyEvent
  1994.                 (
  1995.                 BaseContainer   *somSelf,       // in
  1996.                 Environment     *ev,            // in
  1997.                 ODEventData     *event,         // in
  1998.                 ODFrame         *frame,         // in
  1999.                 ODFacet         *facet,          // in
  2000.                 ODEventInfo     *eventInfo      // inout
  2001.                 )
  2002. {
  2003.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2004.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleKeyEvent");
  2005.  
  2006.     ODBoolean   eventHandled     = kODFalse;
  2007.  
  2008.     try {
  2009.  
  2010. #if  defined(_PLATFORM_WIN32_)
  2011.        if (event->wParam == VK_ESCAPE)
  2012. #elif  defined(_PLATFORM_OS2_)
  2013.       if (CHAR1FROMMP(event->mp2) == 0x1B) //Esc key
  2014. #endif
  2015.        {
  2016.           somSelf->AbortMouseTracking (ev, frame);
  2017.           eventHandled = kODTrue;
  2018.        }
  2019.  
  2020.     } // end of try block
  2021.     catch (...) {}
  2022.  
  2023.  
  2024.     return eventHandled;
  2025. }
  2026.  
  2027.  
  2028. //--------------------------------------------------------------------------
  2029. // BaseContainer --> MoveSelectionToFront
  2030. //
  2031. //      Move selected frames to the foreground.
  2032. //
  2033. //      ->
  2034. //--------------------------------------------------------------------------
  2035.  
  2036. SOM_Scope       void
  2037. SOMLINK         BaseContainerMoveSelectionToFront
  2038.                 (
  2039.                 BaseContainer   *somSelf,       // in
  2040.                 Environment     *ev             // in
  2041.                 )
  2042. {
  2043.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2044.     BaseContainerMethodDebug("BaseContainer", "BaseContainerMoveSelectionToFront");
  2045.  
  2046.     try {
  2047.  
  2048.        ALink *itr = kODNULL;
  2049.        for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2050.        {
  2051.            ContentObject *selectedObject = (ContentObject *) itr->Content(ev);
  2052.            selectedObject->MoveToFront(ev);
  2053.            _fEmbeddedObjects->Remove (ev, selectedObject);
  2054.            _fEmbeddedObjects->AddLast (ev, selectedObject);
  2055.        }
  2056.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2057.  
  2058.     } // end of try block
  2059.  
  2060.     catch (...) {}
  2061.  
  2062.  
  2063.  
  2064. }
  2065.  
  2066.  
  2067.  
  2068.  
  2069. //--------------------------------------------------------------------------
  2070. // BaseContainer --> MoveSelectionToBack
  2071. //
  2072. //      Move the selected frames to the background.
  2073. //
  2074. //      ->
  2075. //--------------------------------------------------------------------------
  2076.  
  2077. SOM_Scope       void
  2078. SOMLINK         BaseContainerMoveSelectionToBack
  2079.                 (
  2080.                 BaseContainer   *somSelf,       // in
  2081.                 Environment     *ev             // in
  2082.                 )
  2083. {
  2084.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2085.     BaseContainerMethodDebug("BaseContainer", "BaseContainerMoveSelectionToBack");
  2086.  
  2087.  
  2088.     try {
  2089.  
  2090.        ALink *itr = kODNULL;
  2091.        for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2092.        {
  2093.            ContentObject *selectedObject = (ContentObject *) itr->Content(ev);
  2094.            selectedObject->MoveToBack(ev);
  2095.            _fEmbeddedObjects->Remove (ev, selectedObject);
  2096.            _fEmbeddedObjects->AddFirst (ev, selectedObject);
  2097.        }
  2098.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2099.  
  2100.     } // end of try block
  2101.  
  2102.     catch (...) {}
  2103.  
  2104.  
  2105. }
  2106.  
  2107.  
  2108.  
  2109. //--------------------------------------------------------------------------
  2110. // BaseContainer --> SelectEmbeddedPart
  2111. //
  2112. //      Select a specific embedded part.
  2113. //
  2114. //      ->
  2115. //--------------------------------------------------------------------------
  2116.  
  2117. SOM_Scope       void
  2118. SOMLINK         BaseContainerSelectContentObject
  2119.                 (
  2120.                 BaseContainer   *somSelf,       // in
  2121.                 Environment     *ev,            // in
  2122.                 ContentObject   *contentObject         // in
  2123.                 )
  2124. {
  2125.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2126.     BaseContainerMethodDebug("BaseContainer","BaseContainerSelectContentObject");
  2127.  
  2128.  
  2129.     try {
  2130.  
  2131.         TempODShape tempShape = kODNULL;
  2132.  
  2133.         if (contentObject->_get_selectionState(ev)) {
  2134.  
  2135.             // compute shape for invalidation
  2136.             tempShape = _fSelectShape->Copy(ev);
  2137.             tempShape->Union (ev, _fCornerHandleShape);
  2138.             tempShape->Union (ev, _fEdgeHandleShape);
  2139.  
  2140.             // Deselect this
  2141.             if (_fSelectedObjects->Count(ev) == 1)
  2142.                somSelf->DeselectAll(ev);
  2143.             else {
  2144.                contentObject->_set_selectionState(ev, kODFalse);
  2145.                _fSelectedObjects->Remove(ev, contentObject);
  2146.                somSelf->CreateSelectionBorderShapes(ev, kODNULL);
  2147.             }
  2148.         }
  2149.         else  {
  2150.  
  2151.             // Select this one
  2152.             contentObject->_set_selectionState(ev, kODTrue);
  2153.             _fSelectedObjects->AddLast(ev, contentObject);
  2154.             somSelf->CreateSelectionBorderShapes(ev, contentObject);
  2155.  
  2156.             // compute shape for invalidation
  2157.             tempShape = _fSelectShape->Copy(ev);
  2158.             tempShape->Union (ev, _fCornerHandleShape);
  2159.             tempShape->Union (ev, _fEdgeHandleShape);
  2160.  
  2161.         }
  2162.  
  2163.         // get tempShape in frame coordinate from content coordinate
  2164.         ODFrame *myFrame = contentObject->_get_containingFrame (ev);
  2165.         TempODTransform intXform = myFrame->AcquireInternalTransform (ev, kODNULL);
  2166.         tempShape->Transform (ev, intXform);
  2167.  
  2168.         myFrame->Invalidate(ev, tempShape, kODNULL);
  2169.  
  2170.     } // end of try block
  2171.     catch (...) {}
  2172.  
  2173.  
  2174. }
  2175.  
  2176.  
  2177. //--------------------------------------------------------------------------
  2178. // ODPart --> DragEnter
  2179. //
  2180. //      Should begin tracking a drag operation.
  2181. //
  2182. //      ->
  2183. //--------------------------------------------------------------------------
  2184.  
  2185. SOM_Scope       ODDragResult
  2186. SOMLINK         BaseContainerDragEnter
  2187.                 (
  2188.                 BaseContainer       *somSelf,   // in
  2189.                 Environment         *ev,        // in
  2190.                 ODDragItemIterator  *dragInfo,  // in
  2191.                 ODFacet             *facet,     // in
  2192.                 ODPoint             *where      // in
  2193.                 )
  2194. {
  2195.     BaseContainerData *somThis       = BaseContainerGetData(somSelf);
  2196.     BaseContainerMethodDebug("BaseContainer","BaseContainerDragEnter");
  2197.  
  2198.  
  2199.     ODDragAndDrop     *dad;
  2200.     ODStorageUnit     *dragSU;
  2201.     ODULong           dragAttributes;
  2202.  
  2203.     try {
  2204.  
  2205.     _fDropAccepted = kODTrue;
  2206.     dad            = _fSession->GetDragAndDrop(ev);
  2207.  
  2208.     if (dad)
  2209.       dragAttributes = dad->GetDragAttributes(ev);
  2210.  
  2211.     if((_fDropAccepted) && !(dragAttributes & kODDragIsInSourceFrame)) {
  2212.        somSelf->InvertDragHilite( ev, facet );
  2213.     }
  2214.  
  2215.  
  2216.     } // end of try block
  2217.     catch (...) {}
  2218.  
  2219.  
  2220.     return(_fDropAccepted);
  2221.  
  2222. }
  2223.  
  2224.  
  2225.  
  2226. //--------------------------------------------------------------------------
  2227. // ODPart --> DragWithin
  2228. //
  2229. //      Should track a drag operation and provide graphical feedback
  2230. //      regarding possible drag targets.
  2231. //
  2232. //      ->
  2233. //--------------------------------------------------------------------------
  2234.  
  2235. SOM_Scope       ODDragResult
  2236. SOMLINK         BaseContainerDragWithin
  2237.                 (
  2238.                 BaseContainer       *somSelf,   // in
  2239.                 Environment         *ev,        // in
  2240.                 ODDragItemIterator  *dragInfo,  // in
  2241.                 ODFacet             *facet,     // in
  2242.                 ODPoint             *where      // in
  2243.                 )
  2244. {
  2245.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2246.     BaseContainerMethodDebug("BaseContainer","BaseContainerDragWithin");
  2247.  
  2248.  
  2249.     return(_fDropAccepted);;
  2250. }
  2251.  
  2252.  
  2253.  
  2254. //--------------------------------------------------------------------------
  2255. // ODPart --> DragLeave
  2256. //
  2257. //      Should finish tracking a drag operation and deactivate this part
  2258. //      from drag tracking.
  2259. //
  2260. //      ->
  2261. //--------------------------------------------------------------------------
  2262.  
  2263. SOM_Scope       void
  2264. SOMLINK         BaseContainerDragLeave
  2265.                 (
  2266.                 BaseContainer   *somSelf,       // in
  2267.                 Environment     *ev,            // in
  2268.                 ODFacet         *facet,         // in
  2269.                 ODPoint         *where          // in
  2270.                 )
  2271. {
  2272.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2273.     BaseContainerMethodDebug("BaseContainer","BaseContainerDragLeave");
  2274.  
  2275.  
  2276.  
  2277.   try {
  2278.  
  2279.   if (_fDropAccepted) {
  2280.     somSelf->InvertDragHilite( ev, facet );
  2281.   }
  2282.  
  2283.   } // end of try block
  2284.   catch (...) {}
  2285.  
  2286. }
  2287.  
  2288.  
  2289. //--------------------------------------------------------------------------
  2290. // BaseContainer --> InvertDragHilite( ev, facet );
  2291. //
  2292. //      Inverts the border around the facet
  2293. //
  2294. //
  2295. //      ->
  2296. //--------------------------------------------------------------------------
  2297.  
  2298. SOM_Scope       void
  2299. SOMLINK         BaseContainerInvertDragHilite
  2300.                 (
  2301.                 BaseContainer   *somSelf,       // in
  2302.                 Environment     *ev,            // in
  2303.                 ODFacet         *facet          // in
  2304.                 )
  2305.  
  2306. {
  2307.  
  2308.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2309.     BaseContainerMethodDebug("BaseContainer","BaseContainerInvertDragHilite");
  2310.  
  2311.    try {
  2312.  
  2313. #if defined(_PLATFORM_OS2_)
  2314.      HPS hdc;
  2315.  
  2316.      ODFrame         *frame = facet->GetFrame(ev);
  2317.      TempODShape clip_shape = facet->AcquireAggregateClipShape(ev, kODNULL);
  2318.      TempODShape shape = clip_shape->Copy(ev);
  2319.      TempODTransform tf = facet->AcquireWindowFrameTransform(ev,kODNULL);
  2320.  
  2321.      // transform the clip shape to the Container's coords
  2322.      shape->Transform(ev,tf);
  2323.      ODRgnHandle rgn = shape->GetRegion(ev);
  2324.      ODPoint offset(0,0);
  2325.      tf->TransformPoint(ev, &offset);
  2326.  
  2327.      // get drag drop PS and set it in invert mode
  2328.      HWND hwndFacet = facet->GetFacetHWND(ev);
  2329.      hdc = DrgGetPS(hwndFacet);
  2330.      LONG mixOld = GpiQueryMix( hdc);
  2331.      GpiSetMix (hdc, FM_INVERT);
  2332.  
  2333.      POINTL winPt;
  2334.      winPt.x = -FixedToInt(offset.x);
  2335.      winPt.y = -FixedToInt(offset.y);
  2336.      GpiOffsetRegion(hdc, rgn, &winPt);
  2337.  
  2338.      SIZEL sizlThickness = {5,5} ;
  2339.      GpiFrameRegion (hdc, rgn, &sizlThickness);
  2340.  
  2341.      GpiSetMix( hdc, mixOld );
  2342.      DrgReleasePS(hdc);
  2343.  
  2344. #elif defined(_PLATFORM_WIN32_)
  2345.      HDC hdc;
  2346.  
  2347.      RECT rc;
  2348.      UINT dd = 5;
  2349.      HWND hwndFacet = facet->GetFacetHWND(ev);
  2350.      //hdc = GetWindowDC(hwndFacet);
  2351.      hdc = GetDCEx(hwndFacet, NULL,DCX_CACHE | DCX_LOCKWINDOWUPDATE | DCX_CLIPSIBLINGS);
  2352.      GetClientRect (hwndFacet, &rc);
  2353.  
  2354.      // draw the feedback
  2355.      PatBlt ( hdc, rc.left, rc.top, rc.right-rc.left, dd, DSTINVERT);
  2356.      PatBlt ( hdc, rc.left, rc.top+dd, dd, rc.bottom-rc.top-(2*dd), DSTINVERT);
  2357.      PatBlt ( hdc, rc.left, rc.bottom-dd, rc.right-rc.left, dd, DSTINVERT);
  2358.      PatBlt ( hdc, rc.right-dd, rc.top+dd, dd, rc.bottom-rc.top-(2*dd), DSTINVERT);
  2359.  
  2360.      ReleaseDC (hwndFacet, hdc);
  2361.  
  2362. #elif defined(_PLATFORM_UNIX_)
  2363.  
  2364.      XPoint point;
  2365.      unsigned long valmask;
  2366.      XGCValues vals;
  2367.      unsigned long backgrnd;
  2368.      unsigned long foregrnd;
  2369.      XRectangle rgnBox;
  2370.  
  2371.      ODAIXWindowCanvas *aixwincanvas = (ODAIXWindowCanvas *)
  2372.                        (facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODAIX));
  2373.  
  2374.      Widget widget = aixwincanvas->GetWidget(ev);
  2375.      Window window = aixwincanvas->GetWindow(ev);
  2376.  
  2377. // save off the background and foreground colors and reverse them
  2378.      GC gc = aixwincanvas->GetGC(ev);
  2379.      XGetGCValues(_fDisplay, gc, (GCForeground | GCBackground), &vals);
  2380.      foregrnd = vals.foreground;
  2381.      backgrnd = vals.background;
  2382.      XSetForeground(_fDisplay, gc, backgrnd);
  2383.      XSetBackground(_fDisplay, gc, foregrnd);
  2384.  
  2385. // get region from OpenDoc
  2386.      ODFrame         *frame = facet->GetFrame(ev);
  2387.      TempODShape clip_shape = facet->AcquireAggregateClipShape(ev, kODNULL);
  2388.      TempODShape shape = clip_shape->Copy(ev);
  2389.      TempODTransform tf = facet->AcquireWindowFrameTransform(ev,kODNULL);
  2390.  
  2391. // transform the clip shape to the Container's coords
  2392.      shape->Transform(ev,tf);
  2393.      ODRgnHandle shapeRgn;
  2394.  
  2395.      shapeRgn = shape->GetRegion(ev);
  2396.      XSetRegion(_fDisplay, gc, shapeRgn);
  2397.  
  2398.      ODPoint offset(0,0);
  2399.      tf->TransformPoint(ev, &offset);
  2400.      point.x = -FixedToInt(offset.x);
  2401.      point.y = -FixedToInt(offset.y);
  2402.  
  2403.      XOffsetRegion(shapeRgn, point.x, point.y);
  2404.      XClipBox(shapeRgn, &rgnBox);
  2405.  
  2406.      XDrawRectangle(_fDisplay, window, gc, rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  2407.  
  2408. #endif
  2409.  
  2410.    } // end of try block
  2411.    catch (...) {}
  2412. }
  2413.  
  2414.  
  2415.  
  2416. //--------------------------------------------------------------------------
  2417. // BaseContainer --> CopySelection
  2418. //
  2419. //      Start of Copy/Paste operation
  2420. //
  2421. //      ->
  2422. //--------------------------------------------------------------------------
  2423.  
  2424. SOM_Scope       void
  2425. SOMLINK         BaseContainerCopySelection
  2426.                 (
  2427.                 BaseContainer   *somSelf,       // in
  2428.                 Environment     *ev,            // in
  2429.                 ODCloneKind      cloneKind      // in
  2430.                 )
  2431. {
  2432.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2433.     BaseContainerMethodDebug("BaseContainer","BaseContainerCopySelection");
  2434.  
  2435.     // nothing to copy .. leave
  2436.     ODULong num = _fSelectedObjects->Count(ev);
  2437.     if (!num)
  2438.        return;
  2439.  
  2440.     try {
  2441.  
  2442.     // Acquire clipboard focus
  2443.     TempODFrame clipboardOwner = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
  2444.     ContentFrame *cobj = (ContentFrame *) _fSelectedObjects->First(ev)->Content(ev);
  2445.     ODFrame *frame = cobj->_get_containingFrame (ev);
  2446.     ODBoolean gotCB = kODFalse;
  2447.  
  2448.     if (_fDisplayFrames->Contains (ev, clipboardOwner) == kODFalse) {
  2449.        gotCB=_fSession->GetArbitrator(ev)->RequestFocus(ev,_fClipboardFocus, frame);
  2450.        if (!gotCB) {
  2451.           WARNMSG (WARN_INDEX(-1), "Could not get clipboard focus");
  2452.           return;
  2453.        }
  2454.     }
  2455.     else
  2456.        PRINT("** One of my frames has clipboard focus");
  2457.  
  2458.     // start of a new clip operation so we clear the clipboard
  2459.  
  2460.     ODClipboard*  clipboard = _fSession->GetClipboard(ev);
  2461.     clipboard->Clear(ev);
  2462.     ODStorageUnit* clipSU = clipboard->GetContentStorageUnit(ev);
  2463.  
  2464.     if ((num == 1) && (cobj->_get_objType(ev) == COBJ_FRAMECLASS)) {
  2465.  
  2466.          // special case: copy single embedded frame to clipboard
  2467.          ODFrame *embeddedFrame = cobj->_get_myFrame(ev);
  2468.          somSelf->WriteSingleFrame (ev, embeddedFrame, clipSU, cloneKind);
  2469.  
  2470.     }
  2471.     else {
  2472.  
  2473.          somSelf->WriteKindInfo (ev, clipSU);
  2474.          BCCloneInfo cloneInfo;
  2475.          memset (&cloneInfo, 0, sizeof(BCCloneInfo));
  2476.  
  2477.          ODDraft *fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  2478.          ODDraft *toDraft = clipSU->GetDraft(ev);
  2479.          ODDraftKey key = 0;
  2480.          key = fromDraft->BeginClone (ev, toDraft, kODNULL, cloneKind);
  2481.          cloneInfo.key = key;
  2482.  
  2483.          somSelf->WriteContents (ev, clipSU, &cloneInfo, CLONE_SELECTED);
  2484.  
  2485.          fromDraft->EndClone (ev, key);
  2486.     }
  2487.  
  2488.     // Export data to clipboard
  2489.     clipboard->ExportClipboard(ev);
  2490.  
  2491.     // Relinquish clipboard focus
  2492.     if (gotCB)
  2493.         _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
  2494.  
  2495.     } // end of try block
  2496.     catch (...) {}
  2497. }
  2498.  
  2499.  
  2500.  
  2501. //--------------------------------------------------------------------------
  2502. // BaseContainer --> PasteSelection
  2503. //
  2504. //      Completion of Cut/Copy/Paste operation
  2505. //
  2506. //      ->
  2507. //--------------------------------------------------------------------------
  2508.  
  2509. SOM_Scope       void
  2510. SOMLINK         BaseContainerPasteSelection
  2511.                 (
  2512.                 BaseContainer   *somSelf,       // in
  2513.                 Environment     *ev,             // in
  2514.                 ODFacet         *facet,          // in
  2515.                 ODPoint         *toWhere
  2516.                 )
  2517. {
  2518.  
  2519.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2520.     BaseContainerMethodDebug("BaseContainer","BaseContainerPasteSelection");
  2521.  
  2522.     try {
  2523.  
  2524.       // Acquire clipboard focus
  2525.       TempODFrame clipboardOwner = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
  2526.       ODBoolean gotCB = kODFalse;
  2527.  
  2528.       if (clipboardOwner != facet->GetFrame(ev)) {
  2529.          gotCB=_fSession->GetArbitrator(ev)->RequestFocus(ev,_fClipboardFocus, facet->GetFrame(ev));
  2530.          if (!gotCB) {
  2531.             WARNMSG (WARN_INDEX(-1), "Could not get clipboard focus");
  2532.             return;
  2533.          }
  2534.       }
  2535.       else
  2536.          PRINT("** One of my frames has clipboard focus");
  2537.  
  2538.  
  2539.       ODClipboard*  clipboard = _fSession->GetClipboard(ev);
  2540.       ODStorageUnit* clipSU = clipboard->GetContentStorageUnit(ev);
  2541.  
  2542.       // If a ContentFrame property exists then get single frame
  2543.       if ((clipSU->Exists(ev, kODPropContentFrame, kODWeakStorageUnitRef, 0))
  2544.           || (somSelf->ReadKindInfo(ev, clipSU) == kODFalse))
  2545.       {
  2546.          ODFrame *embeddedFrame = somSelf->ReadSingleFrame (ev, facet,
  2547.                                          clipSU, kODClonePaste, toWhere);
  2548.          ContentFrame *contFrame = new ContentFrame();
  2549.          contFrame->_set_myFrame (ev, embeddedFrame);
  2550.         _fEmbeddedObjects->AddLast(ev, contFrame);
  2551.       }
  2552.       else if (somSelf->ReadKindInfo(ev, clipSU)) {
  2553.  
  2554.          BCCloneInfo cloneInfo;
  2555.          memset (&cloneInfo, 0, sizeof(BCCloneInfo));
  2556.  
  2557.          ODDraft *toDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  2558.          ODDraft *fromDraft = clipSU->GetDraft(ev);
  2559.          ODDraftKey key = 0;
  2560.          key = fromDraft->BeginClone (ev, toDraft, kODNULL, kODClonePaste);
  2561.          cloneInfo.key = key;
  2562.          cloneInfo.refPoint = toWhere;
  2563.          cloneInfo.myFrame = facet->GetFrame (ev);
  2564.  
  2565.          somSelf->ReadContents(ev, clipSU, &cloneInfo, CLONE_ALL);
  2566.  
  2567.          fromDraft->EndClone (ev, key);
  2568.  
  2569.       }
  2570.  
  2571.       // Relinquish clipboard focus
  2572.       if (gotCB)
  2573.           _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, facet->GetFrame(ev));
  2574.  
  2575.       somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2576.       somSelf->ChangeNotification (ev, BCC_PASTE, facet->GetFrame(ev), kODNULL, kODTrue, kODNULL);
  2577.  
  2578.     } // end of try block
  2579.     catch (...) {}
  2580. }
  2581.  
  2582.  
  2583.  
  2584.  
  2585. //--------------------------------------------------------------------------
  2586. // BaseContainer --> PasteSelectionAs
  2587. //
  2588. //      Completion of Cut/Copy/Paste operation
  2589. //
  2590. //      ->
  2591. //--------------------------------------------------------------------------
  2592.  
  2593. SOM_Scope       void
  2594. SOMLINK         BaseContainerPasteSelectionAs
  2595.                 (
  2596.                 BaseContainer   *somSelf,       // in
  2597.                 Environment     *ev,             // in
  2598.                 ODFacet         *facet,          // in
  2599.                 ODPoint         *toWhere
  2600.                 )
  2601. {
  2602.  
  2603.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2604.     BaseContainerMethodDebug("BaseContainer","BaseContainerPasteSelectionAs");
  2605.  
  2606.     try {
  2607.  
  2608.        somSelf->PasteSelection (ev, facet, toWhere);
  2609.  
  2610.     } // end of try block
  2611.     catch (...) {}
  2612.  
  2613. }
  2614.  
  2615.  
  2616. //--------------------------------------------------------------------------
  2617. // BaseContainer --> DeleteSelection
  2618. //
  2619. //      Deletes all user selection from the document.
  2620. //
  2621. //      ->
  2622. //--------------------------------------------------------------------------
  2623.  
  2624. SOM_Scope       void
  2625. SOMLINK         BaseContainerDeleteSelection
  2626.                 (
  2627.                 BaseContainer   *somSelf,       // in
  2628.                 Environment     *ev,             // in
  2629.                 ODULong         type
  2630.                 )
  2631. {
  2632.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2633.     BaseContainerMethodDebug("BaseContainer","BaseContainerDeleteSelection");
  2634.  
  2635.  
  2636.     try {
  2637.         ALink* itr                   = kODNULL;
  2638.         ContentObject *selectedObject = kODNULL;
  2639.         ALinkedList *tempList = new ALinkedList;
  2640.  
  2641.         // We first store the selection in a temp list for deletion
  2642.         // If you don't use a temp list then we run into a strange
  2643.         // problem where if any of the selected parts are opened in
  2644.         // their own windows then while closing those windows I lose
  2645.         // focus and as a result I clear selection when I am in the
  2646.         // middle of iterating over it. So I should copy the selection
  2647.         // in another list and iterate over that list.
  2648.  
  2649.         for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2650.             tempList->AddLast (ev, (ContentObject*) itr->Content(ev));
  2651.  
  2652.         // get rid of the selected objects list
  2653.         delete _fSelectedObjects;
  2654.         _fSelectedObjects=new ALinkedList();
  2655.  
  2656.  
  2657.         for (itr = tempList->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2658.         {
  2659.  
  2660.            selectedObject = (ContentObject *) itr->Content(ev);
  2661.            selectedObject->DeleteContents(ev, type);
  2662.            _fEmbeddedObjects->Remove(ev, selectedObject);
  2663.            delete selectedObject;
  2664.         }
  2665.  
  2666.         delete tempList;
  2667.  
  2668.         // Reset all the selection border shapes
  2669.  
  2670.         _fSelectShape->Reset (ev);
  2671.         _fCornerHandleShape->Reset (ev);
  2672.         _fEdgeHandleShape->Reset (ev);
  2673.  
  2674.         for (itr = _fDisplayFrames->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2675.         {
  2676.             ODFrame *myFrame = (ODFrame *) itr->Content(ev);
  2677.             myFrame->Invalidate(ev, kODNULL, kODNULL);
  2678.         }
  2679.  
  2680.         somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2681.  
  2682.         somSelf->ChangeNotification (ev, BCC_DELETE, kODNULL, kODNULL, kODTrue, kODNULL);
  2683.  
  2684.     } // end of try block
  2685.     catch (...) {}
  2686.  
  2687.  
  2688. }
  2689.  
  2690.  
  2691. //--------------------------------------------------------------------------
  2692. // BaseContainer --> CutSelection(Environment *)
  2693. //
  2694. //      Performs the cut operation (weak comment TBD)
  2695. //
  2696. //
  2697. //      ->
  2698. //--------------------------------------------------------------------------
  2699.  
  2700. SOM_Scope       void
  2701. SOMLINK         BaseContainerCutSelection(BaseContainer *somSelf,
  2702.                                    Environment *ev)
  2703.  
  2704. {
  2705.     somSelf->CopySelection(ev, kODCloneCopy);
  2706.     somSelf->DeleteSelection(ev, OBJECT_DELETED);
  2707. }
  2708.  
  2709.  
  2710. //--------------------------------------------------------------------------
  2711. // BaseContainer --> DeselectAll
  2712. //
  2713. //      Clear all user selection (turn off hilighting...)
  2714. //
  2715. //      ->
  2716. //--------------------------------------------------------------------------
  2717.  
  2718. SOM_Scope       void
  2719. SOMLINK         BaseContainerDeselectAll
  2720.                 (
  2721.                 BaseContainer   *somSelf,       // in
  2722.                 Environment     *ev             // in
  2723.                 )
  2724. {
  2725.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2726.     BaseContainerMethodDebug("BaseContainer","BaseContainerDeselectAll");
  2727.  
  2728.  
  2729.     try {
  2730.         ALink* itr                   = kODNULL;
  2731.  
  2732.         // Iterate over SelectedFrames and turn off selection highlight
  2733.         for (itr = _fSelectedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2734.         {
  2735.             ContentObject *selectedObject = (ContentObject *) itr->Content(ev);
  2736.             selectedObject->_set_selectionState(ev, kODFalse);
  2737.         }
  2738.  
  2739.         // delete selected frames array and reset pointer to a new ALinkedList
  2740.         delete _fSelectedObjects;
  2741.         _fSelectedObjects=new ALinkedList();
  2742.  
  2743.         // compute the shape for invalidation
  2744.         TempODShape tempShape = _fSelectShape->Copy(ev);
  2745.         tempShape->Union (ev, _fCornerHandleShape);
  2746.         tempShape->Union (ev, _fEdgeHandleShape);
  2747.  
  2748.         // Reset all the selection border shapes
  2749.         _fSelectShape->Reset (ev);
  2750.         _fCornerHandleShape->Reset (ev);
  2751.         _fEdgeHandleShape->Reset (ev);
  2752.  
  2753.  
  2754.         for (itr = _fDisplayFrames->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2755.         {
  2756.             ODFrame *myFrame = (ODFrame *) itr->Content(ev);
  2757.  
  2758.             // get tempShape in frame coordinate from content coordinate
  2759.             TempODTransform intXform = myFrame->AcquireInternalTransform (ev, kODNULL);
  2760.             tempShape->Transform (ev, intXform);
  2761.  
  2762.             myFrame->Invalidate(ev, tempShape, kODNULL);
  2763.             tempShape->InverseTransform (ev, intXform);
  2764.         }
  2765.  
  2766.  
  2767.     } // end of try block
  2768.     catch (...) {}
  2769.  
  2770.  
  2771. }
  2772.  
  2773.  
  2774.  
  2775. //--------------------------------------------------------------------------
  2776. // BaseContainer --> SelectAll
  2777. //
  2778. //      Select all embedded parts.
  2779. //
  2780. //      ->
  2781. //--------------------------------------------------------------------------
  2782.  
  2783. SOM_Scope       void
  2784. SOMLINK         BaseContainerSelectAll
  2785.                 (
  2786.                 BaseContainer   *somSelf,       // in
  2787.                 Environment     *ev             // in
  2788.                 )
  2789. {
  2790.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2791.     BaseContainerMethodDebug("BaseContainer","BaseContainerSelectAll");
  2792.  
  2793.  
  2794.     try {
  2795.         ALink* itr                   = kODNULL;
  2796.  
  2797.         // Iterate over all EmbeddedFrames and select each
  2798.  
  2799.         for (itr=_fEmbeddedObjects->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2800.         {
  2801.             ContentObject *embedObject = (ContentObject *) itr->Content(ev);
  2802.             if (!embedObject->_get_selectionState(ev)) {
  2803.                embedObject->_set_selectionState(ev, kODTrue);
  2804.                _fSelectedObjects->AddLast(ev, embedObject);
  2805.                somSelf->CreateSelectionBorderShapes (ev, embedObject);
  2806.             }
  2807.         }
  2808.  
  2809.         // compute the shape for invalidation
  2810.         TempODShape tempShape = _fSelectShape->Copy(ev);
  2811.         tempShape->Union (ev, _fCornerHandleShape);
  2812.         tempShape->Union (ev, _fEdgeHandleShape);
  2813.  
  2814.         for (itr = _fDisplayFrames->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2815.         {
  2816.             ODFrame *myFrame = (ODFrame *) itr->Content(ev);
  2817.  
  2818.             // get tempShape in frame coordinate from content coordinate
  2819.             TempODTransform intXform = myFrame->AcquireInternalTransform (ev, kODNULL);
  2820.             tempShape->Transform (ev, intXform);
  2821.  
  2822.             myFrame->Invalidate(ev, tempShape, kODNULL);
  2823.             tempShape->InverseTransform (ev, intXform);
  2824.         }
  2825.  
  2826.     } // end of try block
  2827.     catch (...) {}
  2828.  
  2829.  
  2830. }
  2831.  
  2832.  
  2833.  
  2834. //--------------------------------------------------------------------------
  2835. // BaseContainer --> HandleColorChange
  2836. //
  2837. //--------------------------------------------------------------------------
  2838.  
  2839. SOM_Scope       ODBoolean
  2840. SOMLINK         BaseContainerHandleColorChange
  2841.                 (
  2842.                 BaseContainer   *somSelf,       // in
  2843.                 Environment     *ev,            // in
  2844.                 ODFrame         *frame         // in
  2845.                 )
  2846. {
  2847.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2848.     BaseContainerMethodDebug("BaseContainer","BaseContainerHandleColorChange");
  2849.  
  2850.  
  2851.     try {
  2852.  
  2853.        FramePartInfo *pInfo =(FramePartInfo *)frame->GetPartInfo(ev);
  2854.        pInfo->NeedsActivating = (frame->IsRoot(ev)) ? kODTrue : kODFalse;
  2855.        somSelf->SetBackgroundColor(ev,somSelf->ColorSelection(ev,_fBackgroundColor, 1));
  2856.  
  2857.        ALink *itr;
  2858.        for (itr = _fDisplayFrames->First(ev); itr->Content(ev); itr=itr->Next(ev))
  2859.        {
  2860.              ODFrame *myFrame = (ODFrame *) itr->Content(ev);
  2861.              myFrame->Invalidate(ev, kODNULL, kODNULL);
  2862.  
  2863.        }
  2864.  
  2865.        somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
  2866.  
  2867.        somSelf->ChangeNotification (ev, BCC_INTRINSIC, kODNULL, kODNULL, kODTrue, kODNULL);
  2868.  
  2869.     } // end of try block
  2870.     catch (...) {}
  2871.  
  2872.     return kODTrue;
  2873. }
  2874.  
  2875.  
  2876. //--------------------------------------------------------------------------
  2877. // BaseContainer --> HandleKeyEvent
  2878. //
  2879. //      Handle keyboard input -- base container handles only ESC key
  2880. //
  2881. //      ->
  2882. //--------------------------------------------------------------------------
  2883. SOM_Scope       void
  2884. SOMLINK         BaseContainerAbortMouseTracking
  2885.                 (
  2886.                 BaseContainer   *somSelf,       // in
  2887.                 Environment     *ev,            // in
  2888.                 ODFrame         *frame
  2889.                 )
  2890. {
  2891.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2892.     BaseContainerMethodDebug("BaseContainer","BaseContainerAbortMouseTracking");
  2893.  
  2894.  
  2895.     try {
  2896.  
  2897.           switch (_usMouseMode)
  2898.           {
  2899.              case kMouseModeTrackLassoSelect:
  2900.                 {
  2901.                    BC_LassoData *ld = (BC_LassoData *)_lassoData;
  2902.                    delete ld->focus;
  2903.  
  2904.                    TempODShape tempShape = ld->shape->Copy(ev);
  2905.                    tempShape->Outset (ev, kODBorderWidth);
  2906.  
  2907.                    // get tempShape in frame coordinate from content coordinate
  2908.                    TempODTransform intXform = frame->AcquireInternalTransform (ev, kODNULL);
  2909.                    tempShape->Transform (ev, intXform);
  2910.                    frame->Invalidate (ev, tempShape, kODNULL);
  2911.  
  2912.                    ld->shape->Release(ev);
  2913.                    SOMFree(ld);
  2914.                    _lassoData = kODNULL;
  2915.                 }
  2916.                 break;
  2917.              case kMouseModeTrackMouseMove:
  2918.                 {
  2919.                    BC_MoveData *md = (BC_MoveData *) _moveData;
  2920.                    delete md->focus;
  2921.  
  2922.                    TempODShape tempShape = md->shape->Copy(ev);
  2923. #if  defined(_PLATFORM_OS2_)
  2924.                     md->contentXform->Release(ev);
  2925. #endif
  2926.                    tempShape->Union (ev, _fSelectShape);
  2927.                    tempShape->Outset (ev, kODBorderWidth);
  2928.  
  2929.                    // get tempShape in frame coordinate from content coordinate
  2930.                    TempODTransform intXform = frame->AcquireInternalTransform (ev, kODNULL);
  2931.                    tempShape->Transform (ev, intXform);
  2932.  
  2933.                    frame->Invalidate (ev, tempShape, kODNULL);
  2934.                    md->shape->Release(ev);
  2935.                    md->transform->Release(ev);
  2936.                    SOMFree(md);
  2937.                    _moveData = kODNULL;
  2938.                 }
  2939.                 break;
  2940.              case kMouseModeTrackMouseResize:
  2941.                 {
  2942.                    BC_ResizeData *rd = (BC_ResizeData *) _resizeData;
  2943.                    delete rd->focus;
  2944.  
  2945.                    TempODShape tempShape = rd->shape->Copy(ev);
  2946. #if  defined(_PLATFORM_OS2_)
  2947.                    tempShape->InverseTransform( ev, rd->contentXform);
  2948.                    rd->contentXform->Release(ev);
  2949. #endif
  2950.                    tempShape->Union (ev, _fSelectShape);
  2951.                    tempShape->Outset (ev, kODBorderWidth);
  2952.  
  2953.                    // get tempShape in frame coordinate from content coordinate
  2954.                    TempODTransform intXform = frame->AcquireInternalTransform (ev, kODNULL);
  2955.                    tempShape->Transform (ev, intXform);
  2956.  
  2957.                    frame->Invalidate (ev, tempShape, kODNULL);
  2958.                    rd->shape->Release(ev);
  2959.                    SOMFree(rd);
  2960.                    _resizeData = kODNULL;
  2961.                 }
  2962.                 break;
  2963.           } // end switch
  2964.  
  2965.           _usMouseMode = kMouseModeNull;
  2966.           _fPartToEmbed = kODNULL;
  2967.  
  2968.     }
  2969.     catch (...) {}
  2970.  
  2971. }
  2972.  
  2973.  
  2974. //--------------------------------------------------------------------------
  2975. // BaseContainer --> DrawResizeRectangle
  2976. //
  2977. //      Erases the last rectangle drawn if drawType is BCR_EERASE. If the
  2978. //      the drawType is BCR_REDRAW, it will draw a new resize rectangle after
  2979. //      erasing the old one.
  2980. //
  2981. //      -> This method is called in HandleMouseMotionLBDown and in
  2982. //         HandleMouseMotionEnd.
  2983. //--------------------------------------------------------------------------
  2984.  
  2985. SOM_Scope       void
  2986. SOMLINK         BaseContainerDrawResizeRectangle
  2987.                 (
  2988.                 BaseContainer   *somSelf,        // in
  2989.                 Environment     *ev,             // in
  2990.                 ODPoint         *cursorLocation, // in
  2991.                 BC_RECTDRAWTYPE drawType         // in
  2992.                 )
  2993. {
  2994.     BaseContainerData *somThis = BaseContainerGetData(somSelf);
  2995.     BaseContainerMethodDebug("BaseContainer","BaseContainerDrawResizeRectangle");
  2996.  
  2997.     BC_ResizeData *sd = (BC_ResizeData *) _resizeData;
  2998.  
  2999.     // Store the current drawing attributes.
  3000.  
  3001. #if defined(_PLATFORM_WIN32_)
  3002.  
  3003.     HBRUSH  hairBrush = CreateHatchBrush(HS_BDIAGONAL, RGB(255,255,255));
  3004.     HBRUSH  hbrOld = SelectObject(sd->dc, hairBrush);
  3005.     int oldROP2 = SetROP2(sd->dc, R2_XORPEN);
  3006.  
  3007. #elif defined(_PLATFORM_UNIX_)
  3008.  
  3009.     XSetForeground(_fDisplay, sd->dc, 1);
  3010.     XSetLineAttributes(_fDisplay,sd->dc,6,LineSolid, CapButt, JoinRound);
  3011.     XSetFunction(_fDisplay, sd->dc, GXxor);
  3012.  
  3013. #elif defined(_PLATFORM_OS2_)
  3014.  
  3015.     LONG mixOld = GpiQueryMix( sd->dc);
  3016.     GpiSetMix (sd->dc, FM_INVERT);
  3017. #endif
  3018.  
  3019.     ODRect rect;
  3020.  
  3021.     // If redrawing, we must draw twice: once to erase the last rectangle,
  3022.     // and a second time to draw the new rectangle. Otherwise, just draw
  3023.     // once in XOR mode over the last rectangle to erase it.
  3024.     int drawMax = (drawType == BCR_REDRAW) ? 2: 1;
  3025.  
  3026.     for (int i = 0; i < drawMax; i++)
  3027.     {
  3028.  
  3029.        if (sd->anchorPoint.x == 0)
  3030.        {
  3031.           rect.left = sd->bbox.left - kODBorderWidth;
  3032.           rect.right = sd->bbox.right + kODBorderWidth;
  3033.        }
  3034.        else
  3035.        {
  3036.           rect.left = min (sd->anchorPoint.x, sd->lastPoint.x);
  3037.           rect.right = max (sd->anchorPoint.x, sd->lastPoint.x);
  3038.        }
  3039.        if (sd->anchorPoint.y == 0)
  3040.        {
  3041. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  3042.           rect.top = sd->bbox.top - kODBorderWidth;
  3043.           rect.bottom = sd->bbox.bottom + kODBorderWidth;
  3044. #elif defined(_PLATFORM_OS2_)
  3045.           rect.top = sd->bbox.top + kODBorderWidth;
  3046.           rect.bottom = sd->bbox.bottom - kODBorderWidth;
  3047. #endif
  3048.        }
  3049.        else
  3050.        {
  3051. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  3052.           rect.top = min (sd->anchorPoint.y, sd->lastPoint.y);
  3053.           rect.bottom = max (sd->anchorPoint.y, sd->lastPoint.y);
  3054. #elif defined(_PLATFORM_OS2_)
  3055.           rect.top = max (sd->anchorPoint.y, sd->lastPoint.y);
  3056.           rect.bottom = min (sd->anchorPoint.y, sd->lastPoint.y);
  3057. #endif
  3058.        }
  3059.  
  3060.        sd->shape->SetRectangle (ev, &rect);
  3061.  
  3062. #if defined(_PLATFORM_WIN32_)
  3063.        ODRgnHandle hrgn = sd->shape->GetRegion(ev);
  3064.        FrameRgn(sd->dc, hrgn, hairBrush, kODBorderWidth >> 16 , kODBorderWidth >> 16);
  3065. #elif defined(_PLATFORM_UNIX_)
  3066.  
  3067.        sd->shape->Transform (ev, sd->contentXform);
  3068.        Region hrgn = sd->shape->GetRegion(ev);
  3069.        XSetRegion(_fDisplay, sd->dc, hrgn);
  3070.        XRectangle rgnBox;
  3071.        XClipBox(hrgn, &rgnBox);
  3072.        XDrawRectangle(_fDisplay, sd->win, sd->dc,
  3073.                       rgnBox.x, rgnBox.y, rgnBox.width, rgnBox.height);
  3074.  
  3075. #elif defined(_PLATFORM_OS2_)
  3076.        sd->shape->Transform (ev, sd->contentXform);
  3077.        ODRgnHandle hrgn = sd->shape->GetRegion(ev);
  3078.        SIZEL thickness = {kODBorderWidth >> 16 , kODBorderWidth >> 16};
  3079.        GpiFrameRegion(sd->dc, hrgn, &thickness);
  3080. #endif
  3081.  
  3082.        sd->lastPoint = *cursorLocation;
  3083.  
  3084.     } // end for
  3085.  
  3086.  
  3087.     // Restore the old drawing attributes
  3088. #if defined(_PLATFORM_WIN32_)
  3089.     SelectObject(sd->dc, hbrOld);
  3090.     DeleteObject(hairBrush);
  3091.     SetROP2 (sd->dc, oldROP2);
  3092.  
  3093. #elif defined (_PLATFORM_UNIX_)
  3094.     XSetLineAttributes(_fDisplay,sd->dc,1,LineSolid, CapButt, JoinRound);
  3095.     XSetFunction(_fDisplay, sd->dc, GXcopy);
  3096.     XFlush(_fDisplay);
  3097.  
  3098. #elif defined (_PLATFORM_OS2_)
  3099.     GpiSetMix (sd->dc, mixOld);
  3100.  
  3101. #endif
  3102. }
  3103.