home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / UI / DspUtilM.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  4.7 KB  |  193 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DspUtilM.cpp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Owned by:    Richard Rodseth
  7.  
  8.     Copyright:    © 1995 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     6/12/96    eeh        1314732: use containing frame of subframe
  13.          <7>     9/13/95    DM        1277216 GM:API return no ODPoints nor
  14.                                     ODPolygons
  15.          <6>     8/29/95    RR        #1267251 Remove ODLogEvents #define
  16.          <5>     6/20/95    JBS        1257315 change Facet::AcquireWindow to
  17.                                     GetWindow
  18.          <4>     5/26/95    RR        #1251403: Multithreading naming support
  19.          <3>     5/25/95    jpa        Fixed usage of ODDebug. [1253321]
  20.          <2>     5/10/95    RR        # 1239139 Added LogEvent, and
  21.                                     GetActiveFacetWithBorderUnderPoint
  22.  
  23.     To Do:
  24.     In Progress:
  25. */
  26.  
  27. #ifndef _DSPUTILM_
  28. #include "DspUtilM.h" 
  29. #endif
  30.  
  31. #ifndef SOM_ODFacet_xh
  32. #include "Facet.xh"
  33. #endif
  34.  
  35. #ifndef SOM_ODFrame_xh
  36. #include "Frame.xh"
  37. #endif
  38.  
  39. #ifndef SOM_ODFrameFacetIterator_xh
  40. #include "FrFaItr.xh"
  41. #endif
  42.  
  43. #ifndef SOM_ODPart_xh
  44. #include "Part.xh"
  45. #endif
  46.  
  47. #ifndef _TEMPOBJ_
  48. #include "TempObj.h"
  49. #endif
  50.  
  51. void WindowToLocal(Environment* ev, ODPoint& point, ODFacet* facet)
  52. {
  53.     TempODTransform xform = facet->AcquireWindowFrameTransform(ev, facet->GetCanvas(ev));
  54.     xform->InvertPoint(ev, &point);
  55. }
  56.  
  57. ODFacet* GetActiveFacetWithBorderUnderPoint(Environment* ev, ODFrame* frame, ODWindow* window,
  58.         ODPoint& windowPoint)
  59. {
  60.     ODFacet* foundFacet = kODNULL;
  61.     ODPoint framePoint;
  62.  
  63.     if ( frame && window )
  64.     {
  65.         TempODFrame containingFrame( kODNULL );
  66.         if ( frame->IsSubframe(ev) )
  67.         {
  68.             containingFrame = frame->AcquireContainingFrame( ev );
  69.             if ( containingFrame )
  70.                 frame = containingFrame;
  71.         }
  72.  
  73.         ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
  74.         for ( ODFacet* facet = facets->First(ev);
  75.                 facets->IsNotComplete(ev);
  76.                 facet = facets->Next(ev) )
  77.         {
  78.             // get windowPoint in frame coords for hit-testing
  79.             { TempODTransform winToFrame = facet->AcquireWindowFrameTransform(ev, kODNULL);
  80.               framePoint = windowPoint;
  81.               winToFrame->InvertPoint(ev, &framePoint);
  82.             }
  83.             
  84.             if (ODObjectsAreEqual(ev, facet->GetWindow(ev), window)
  85.                 && (facet->ActiveBorderContainsPoint(ev, &framePoint, kODNULL)) )
  86.             {
  87.                 foundFacet = facet;
  88.                 break;
  89.             }
  90.         }
  91.         delete facets;
  92.     }
  93.     return foundFacet;
  94. }
  95.  
  96. #if ODDebug
  97.  
  98. void LogEvent(ODEventData* event, ODEventInfo* eventInfo, ODFrame* frame, ODFacet* facet)
  99. {
  100.     char eventType[30];
  101.     switch (event->what)
  102.     {
  103.         case kODEvtNull:         
  104.             strcpy(eventType,"NULL");
  105.             break;
  106.         case kODEvtMouseDown: 
  107.             strcpy(eventType,"kODEvtMouseDown");
  108.             break;
  109.         case kODEvtMouseUp:      
  110.             strcpy(eventType,"kODEvtMouseUp");
  111.             break;
  112.         case kODEvtKeyDown: 
  113.             strcpy(eventType,"kODEvtKeyDown");
  114.             break;
  115.         case kODEvtKeyUp: 
  116.             strcpy(eventType,"kODEvtKeyUp");
  117.             break;
  118.         case kODEvtAutoKey: 
  119.             strcpy(eventType,"kODEvtAutoKey");
  120.             break;
  121.         case kODEvtUpdate: 
  122.             strcpy(eventType,"kODEvtUpdate");
  123.             break;
  124.         case kODEvtDisk: 
  125.             strcpy(eventType,"kODEvtDisk");
  126.             break;
  127.         case kODEvtActivate: 
  128.             strcpy(eventType,"kODEvtActivate");
  129.             break;
  130.         case kODEvtOS: 
  131.             strcpy(eventType,"kODEvtOS");
  132.             break;
  133.         case kODEvtBGMouseDown: 
  134.             strcpy(eventType,"kODEvtBGMouseDown");
  135.             break;
  136.         case kODEvtMenu: strcpy(eventType,"kODEvtMenu");
  137.             break;
  138.         case kODEvtMouseDownEmbedded: 
  139.             strcpy(eventType,"kODEvtMouseDownEmbedded");    
  140.             break;
  141.         case kODEvtMouseUpEmbedded: 
  142.             strcpy(eventType,"kODEvtMouseUpEmbedded");
  143.             break;
  144.         case kODEvtMouseDownBorder: 
  145.             strcpy(eventType,"kODEvtMouseDownBorder");
  146.             break;
  147.         case kODEvtMouseUpBorder: 
  148.             strcpy(eventType,"kODEvtMouseUpBorder");
  149.             break;
  150.         case kODEvtWindow: 
  151.             strcpy(eventType,"kODEvtWindow");
  152.             break;
  153.         case kODEvtMouseEnter: 
  154.             strcpy(eventType,"kODEvtMouseEnter");
  155.             break;
  156.         case kODEvtMouseWithin: 
  157.             strcpy(eventType,"kODEvtMouseWithin");
  158.             break;
  159.         case kODEvtMouseLeave: 
  160.             strcpy(eventType,"kODEvtMouseLeave");
  161.             break;
  162.         case kODEvtBGMouseDownEmbedded: 
  163.             strcpy(eventType,"kODEvtBGMouseDownEmbedded");
  164.             break;
  165.         default:     
  166.             strcpy(eventType,"UNKNOWN");
  167.             break;
  168.     }
  169.     somPrintf("Event: %3d %-25s Facet: %x, Frame: %x", event->what, eventType, facet, frame);
  170.     somPrintf(" Coords: %3d,%3d",eventInfo->where.IntX(),eventInfo->where.IntY());
  171.     if ((event->modifiers & shiftKey) != 0)
  172.         somPrintf(" Shift");
  173.     if ((event->modifiers & cmdKey) != 0)
  174.         somPrintf(" Cmd");
  175.     if ((event->modifiers & optionKey) != 0)
  176.         somPrintf(" Opt");
  177.     if ((event->modifiers & controlKey) != 0)
  178.         somPrintf(" Ctl");
  179.     if (eventInfo->propagated)
  180.         somPrintf(" PROPAGATED");
  181.     somPrintf("\n");
  182.     if ((event->what == kODEvtMouseDownEmbedded) ||
  183.         (event->what == kODEvtMouseUpEmbedded) ||
  184.         (event->what == kODEvtBGMouseDownEmbedded) ||
  185.         (event->what == kODEvtMouseDownBorder))
  186.     {
  187.         somPrintf("        Embedded Facet: %x Embedded Frame: %x\n", eventInfo->embeddedFacet, eventInfo->embeddedFrame);
  188.     }
  189. }
  190.  
  191.  
  192. #endif
  193.