home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CADSP 1.0 / Demo / CADSPInPane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  1.7 KB  |  93 lines  |  [TEXT/KAHL]

  1. /****
  2.  * CADSPInPane.c
  3.  *
  4.  *    Methods for a pane which gets input from ADSP
  5.  *
  6.  *  Copyright © 1992 Bernie Bernstein.  All rights reserved.
  7.  *
  8.  ****/
  9.  
  10. #include "CADSPInPane.h"
  11. #include "CMessenger.h"
  12.  
  13. /***
  14.  * IADSPInPane
  15.  *
  16.  *        Setup the pane
  17.  ***/
  18. void CADSPInPane::IADSPInPane(
  19.                 CView            *anEnclosure,
  20.                 CBureaucrat        *aSupervisor,
  21.                 CMessenger        *aMessenger)
  22. {
  23.     CEditText::IEditText(anEnclosure, aSupervisor,
  24.                      10, 10, 0, 0, sizELASTIC, sizELASTIC, -1);
  25.                      
  26.     itsMessenger = aMessenger;
  27. }
  28.  
  29. /***
  30.  * GetData
  31.  *
  32.  *        Read the data from the buffer and put it into the window
  33.  *        this gets called from a Dawdle in the document
  34.  ***/
  35. void CADSPInPane::GetData(void)
  36. {
  37.     EventRecord anEvent;
  38.     short size;
  39.  
  40.     itsMessenger->ReceiveMessage((Ptr)&anEvent, sizeof(EventRecord), &size);
  41.     if (size == sizeof(EventRecord))
  42.         {
  43.         HandleInEvent(&anEvent);
  44.         }
  45.     else
  46.         {
  47.         DebugStr("\pLost some stuff");
  48.         }
  49. }
  50.  
  51. /***
  52.  * HandleInEvent
  53.  *
  54.  *        Deal with the event passed in from the other end.
  55.  *        The event will be in local coordinates so that
  56.  *        they can work in the local pane.
  57.  ***/
  58. void CADSPInPane::HandleInEvent(EventRecord *anEvent)
  59. {
  60.     switch(anEvent->what)
  61.         {
  62. //        case mouseDown:
  63. //            HandleInMouseDown(anEvent);
  64. //            break;
  65. //        case mouseUp:
  66. //            HandleInMouseUp(anEvent);
  67. //            break;
  68.         case keyDown:
  69. //        case keyUp:
  70.         case autoKey:
  71.             HandleInKey(anEvent);
  72.             break;
  73.         }
  74. }
  75.  
  76. /***
  77.  * HandleInKey
  78.  *
  79.  *        A key was pressed
  80.  ***/
  81. void CADSPInPane::HandleInKey(EventRecord *anEvent)
  82. {
  83.     char theChar = anEvent->message & charCodeMask;
  84.     Byte keyCode = (anEvent->message & keyCodeMask) >> 8;
  85.     if (!(anEvent->modifiers & cmdKey))
  86.         {
  87.         Specify(TRUE, TRUE, TRUE);
  88.         DoKeyDown(theChar, keyCode, anEvent);
  89.         Specify(FALSE, TRUE, FALSE);
  90.         }
  91. }
  92.  
  93.