home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / DspUtilM.cpp < prev    next >
C/C++ Source or Header  |  1997-03-21  |  6KB  |  217 lines

  1. /* @(#)Z 1.3 com/src/ui/DspUtilM.cpp, odui, od96os2, odos29712d 97/03/21 17:20:18 (96/07/15 18:26:20) */
  2. //====START_GENERATED_PROLOG======================================
  3. //
  4. //
  5. //   COMPONENT_NAME: odui
  6. //
  7. //   CLASSES: none
  8. //
  9. //   ORIGINS: 82,27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28. /*
  29.     File:           DspUtilM.cpp
  30.  
  31.     Contains:       xxx put contents here xxx
  32.  
  33.     Owned by:       Richard Rodseth
  34.  
  35.     Copyright:      ⌐ 1995 by Apple Computer, Inc., all rights reserved.
  36.  
  37.     Change History (most recent first):
  38.  
  39.          <7>     9/13/95        DM              1277216 GM:API return no ODPoints nor
  40.                                     ODPolygons
  41.          <6>     8/29/95        RR              #1267251 Remove ODLogEvents #define
  42.          <5>     6/20/95        JBS             1257315 change Facet::AcquireWindow to
  43.                                     GetWindow
  44.          <4>     5/26/95        RR              #1251403: Multithreading naming support
  45.          <3>     5/25/95        jpa             Fixed usage of ODDebug. [1253321]
  46.          <2>     5/10/95        RR              # 1239139 Added LogEvent, and
  47.                                     GetActiveFacetWithBorderUnderPoint
  48.  
  49.     To Do:
  50.     In Progress:
  51. */
  52.  
  53. #ifndef _DSPUTILM_
  54. #include "DspUtilM.h" 
  55. #endif
  56.  
  57. #ifndef SOM_ODFacet_xh
  58. #include "Facet.xh"
  59. #endif
  60.  
  61. #ifndef SOM_ODFrame_xh
  62. #include "Frame.xh"
  63. #endif
  64.  
  65. #ifndef SOM_ODFrameFacetIterator_xh
  66. #include "FrFaItr.xh"
  67. #endif
  68.  
  69. #ifndef SOM_ODPart_xh
  70. #include "Part.xh"
  71. #endif
  72.  
  73. #ifndef SOM_ODTransform_xh
  74. #include "Trnsform.xh"
  75. #endif
  76.  
  77. #ifndef _TEMPOBJ_
  78. #include "TempObj.h"
  79. #endif
  80.  
  81. #ifndef _ODUTILS_
  82. #include "ODUtils.h"
  83. #endif
  84.  
  85. void WindowToLocal(Environment* ev, ODPoint& point, ODFacet* facet)
  86. {
  87.     TempODTransform xform = facet->AcquireWindowFrameTransform(ev, facet->GetCanvas(ev));
  88.     xform->InvertPoint(ev, &point);
  89. }
  90.  
  91. ODFacet* GetActiveFacetWithBorderUnderPoint(Environment* ev, ODFrame* frame, ODWindow* window, ODPoint& windowPoint)
  92. {
  93.     ODFacet* foundFacet = kODNULL;
  94.     ODPoint framePoint;
  95.  
  96.     if ( frame && window )
  97.     {
  98.         ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  99.         for ( ODFacet* facet = facets->First(ev);
  100.                 facets->IsNotComplete(ev);
  101.                 facet = facets->Next(ev) )
  102.         {
  103.             // get windowPoint in frame coords for hit-testing
  104.             { TempODTransform winToFrame = facet->AcquireWindowFrameTransform(ev, kODNULL);
  105.               framePoint = windowPoint;
  106.               winToFrame->InvertPoint(ev, &framePoint);
  107.             }
  108.             
  109.             if (ODObjectsAreEqual(ev, facet->GetWindow(ev), window)
  110.                 && (facet->ActiveBorderContainsPoint(ev, &framePoint, kODNULL)) )
  111.             {
  112.                 foundFacet = facet;
  113.                 break;
  114.             }
  115.         }
  116.         delete facets;
  117.     }
  118.     return foundFacet;
  119. }
  120.  
  121. #if defined(ODDebug) && defined(_PLATFORM_MACINTOSH_)
  122.  
  123. void LogEvent(ODEventData* event, ODEventInfo* eventInfo, ODFrame* frame, ODFacet* facet)
  124. {
  125.     char eventType[30];
  126.     switch (event->what)
  127.     {
  128.         case kODEvtNull:                 
  129.             strcpy(eventType,"NULL");
  130.             break;
  131.         case kODEvtMouseDown: 
  132.             strcpy(eventType,"kODEvtMouseDown");
  133.             break;
  134.         case kODEvtMouseUp:      
  135.             strcpy(eventType,"kODEvtMouseUp");
  136.             break;
  137.         case kODEvtKeyDown: 
  138.             strcpy(eventType,"kODEvtKeyDown");
  139.             break;
  140.         case kODEvtKeyUp: 
  141.             strcpy(eventType,"kODEvtKeyUp");
  142.             break;
  143.         case kODEvtAutoKey: 
  144.             strcpy(eventType,"kODEvtAutoKey");
  145.             break;
  146.         case kODEvtUpdate: 
  147.             strcpy(eventType,"kODEvtUpdate");
  148.             break;
  149.         case kODEvtDisk: 
  150.             strcpy(eventType,"kODEvtDisk");
  151.             break;
  152.         case kODEvtActivate: 
  153.             strcpy(eventType,"kODEvtActivate");
  154.             break;
  155.         case kODEvtOS: 
  156.             strcpy(eventType,"kODEvtOS");
  157.             break;
  158.         case kODEvtBGMouseDown: 
  159.             strcpy(eventType,"kODEvtBGMouseDown");
  160.             break;
  161.         case kODEvtMenu: strcpy(eventType,"kODEvtMenu");
  162.             break;
  163.         case kODEvtMouseDownEmbedded: 
  164.             strcpy(eventType,"kODEvtMouseDownEmbedded");    
  165.             break;
  166.         case kODEvtMouseUpEmbedded: 
  167.             strcpy(eventType,"kODEvtMouseUpEmbedded");
  168.             break;
  169.         case kODEvtMouseDownBorder: 
  170.             strcpy(eventType,"kODEvtMouseDownBorder");
  171.             break;
  172.         case kODEvtMouseUpBorder: 
  173.             strcpy(eventType,"kODEvtMouseUpBorder");
  174.             break;
  175.         case kODEvtWindow: 
  176.             strcpy(eventType,"kODEvtWindow");
  177.             break;
  178.         case kODEvtMouseEnter: 
  179.             strcpy(eventType,"kODEvtMouseEnter");
  180.             break;
  181.         case kODEvtMouseWithin: 
  182.             strcpy(eventType,"kODEvtMouseWithin");
  183.             break;
  184.         case kODEvtMouseLeave: 
  185.             strcpy(eventType,"kODEvtMouseLeave");
  186.             break;
  187.         case kODEvtBGMouseDownEmbedded: 
  188.             strcpy(eventType,"kODEvtBGMouseDownEmbedded");
  189.             break;
  190.         default:         
  191.             strcpy(eventType,"UNKNOWN");
  192.             break;
  193.     }
  194.     somPrintf("Event: %3d %-25s Facet: %x, Frame: %x", event->what, eventType, facet, frame);
  195.     somPrintf(" Coords: %3d,%3d",eventInfo->where.IntX(),eventInfo->where.IntY());
  196.     if ((event->modifiers & shiftKey) != 0)
  197.         somPrintf(" Shift");
  198.     if ((event->modifiers & cmdKey) != 0)
  199.         somPrintf(" Cmd");
  200.     if ((event->modifiers & optionKey) != 0)
  201.         somPrintf(" Opt");
  202.     if ((event->modifiers & controlKey) != 0)
  203.         somPrintf(" Ctl");
  204.     if (eventInfo->propagated)
  205.         somPrintf(" PROPAGATED");
  206.     somPrintf("\n");
  207.     if ((event->what == kODEvtMouseDownEmbedded) ||
  208.         (event->what == kODEvtMouseUpEmbedded) ||
  209.         (event->what == kODEvtBGMouseDownEmbedded) ||
  210.         (event->what == kODEvtMouseDownBorder))
  211.     {
  212.         somPrintf("        Embedded Facet: %x Embedded Frame: %x\n", eventInfo->embeddedFacet, eventInfo->embeddedFrame);
  213.     }
  214. }
  215.  
  216. #endif // ODDebug & _PLATFORM_MACHINTOSH_
  217.