home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / RESPINTR.H < prev    next >
C/C++ Source or Header  |  1994-01-03  |  6KB  |  220 lines

  1. /************************************************************************
  2. **
  3. ** @(#)respintr.h    01/03/93    Chris Ahlstrom
  4. **
  5. ** ---------------------------
  6. **   73340.26!compuserve.com
  7. ** ---------------------------
  8. **
  9. ** C++
  10. **
  11. **    This module supports showing annunciator lights in a TV window.
  12. ** The model is very strict, applicable only to 2- or 3-alternative
  13. ** forced choice tasks in psychoacoustics.  See the CPP file.
  14. **
  15. **    The FACE_TV (and FACE_WIN) versions are a little different from
  16. ** the code extracted from the MODAPP 2AFC-experiment code.
  17. **
  18. *************************************************************************/
  19.  
  20. #if !defined(RESPINTR_h)                // { RESPINTR_h
  21. #define RESPINTR_h
  22.  
  23. #include <dos.h>
  24. #include <conio.h>
  25.  
  26. #if !defined(__TTYPES_H)
  27. #include <ttypes.h>            // "Boolean" Turbo Vision definition
  28. #endif
  29.  
  30. //#define Uses_TDeskTop
  31. #define Uses_TRect
  32. #define Uses_TView
  33. //#define Uses_TWindow
  34. #include <tv.h>                // Turbo Vision code galore!!!
  35.  
  36. // #include "delay.h"
  37.  
  38.  
  39. /************************************************************************
  40. ** Constants for the Turbo Vision implementation of the light panel.
  41. ** The defines are used if it's desired to shift an interval counter
  42. ** to the proper location for a ResponseFlag of the similar name.
  43. *************************************************************************/
  44.  
  45. typedef enum
  46. {
  47.     RESPONSE_NORMAL = 0,
  48.     RESPONSE_QUIT
  49.  
  50. } ResponseSet;
  51.  
  52.  
  53. #define RESP_INTV_BITS    4        /* shift'em 4 bits left for use    */
  54. #define RESP_OFF    0        /* the light is on        */
  55. #define RESP_ON        1        /* the light is on        */
  56.  
  57.  
  58. /************************************************************************
  59. ** ResponseFlag
  60. **
  61. **    This type employs single-bit fields to represent up to sixteen
  62. ** lights.  The bits can be OR'ed to turn on any combination of lights
  63. ** with one call.
  64. **
  65. **    We still need to add support for a 3-interval forced choice
  66. ** task (3AFC or 3IFC task).
  67. **
  68. **
  69. ** ResponseLightIndex
  70. **
  71. **    I'm not sure this type is used for !
  72. **
  73. *************************************************************************/
  74.  
  75. typedef enum
  76. {
  77.     RESP_1        = 0x01,        /* turn on Response 1 light    */
  78.     RESP_2        = 0x02,        /* turn on Response 2 light    */
  79.     RESP_READY        = 0x04,        /* turn on Ready light        */
  80.     RESP_ANSWER        = 0x08,        /* turn on Answer light        */
  81.     RESP_INTV_1        = 0x10,        /* turn on Interval 1 light    */
  82.     RESP_INTV_2        = 0x20,        /* turn on Interval 2 light    */
  83.     RESP_FAILURE    = 0x40,        /* programming failure light    */
  84.     RESP_UNUSED        = 0x80,        /* ---future expansion---    */
  85.     RESP_ALL_ON        = 0x3F,        /* all lights turned on        */
  86.     RESP_ALL_OFF    = 0x00,        /* all lights turned off    */
  87.     RESP_CORRECT_1    = 0x11,        /* Interval 1, Response 1    */
  88.     RESP_CORRECT_2    = 0x22,        /* Interval 2, Response 2    */
  89.     RESP_WRONG_1    = 0x12,        /* Interval 1, Response 2    */
  90.     RESP_WRONG_2    = 0x21        /* Interval 2, Response 1    */
  91.  
  92. } ResponseFlag;
  93.  
  94. typedef enum
  95. {
  96.     FIRST_LIGHT        = 1,        /* ordinal version of above    */
  97.     RESPONSE_1        = 1,
  98.     RESPONSE_2        = 2,
  99.     READY_LIGHT        = 3,
  100.     ANSWER_LIGHT    = 4,
  101.     INTERVAL_1        = 5,
  102.     INTERVAL_2        = 6,
  103.     FAILURE_LIGHT    = 7,
  104.     LAST_LIGHT        = 8
  105.  
  106. } ResponseLightIndex;
  107.  
  108.  
  109. typedef struct
  110. {
  111.     int fillstyle;        // style of graphics background
  112.     ushort color;        // color of the response light
  113.     int x0, y0;            // pixel coordinate of upper left
  114.     int x1, y1;            // pixel coordinate of lower right
  115.     int status;            // 0=light off, 1=light on
  116.  
  117. } ResponseLight;
  118.  
  119.  
  120. typedef struct
  121. {
  122.     int font;            // font to use for the text
  123.     int direction;        // direction the lettering should go
  124.     int charsize;        // relative size of the character
  125.     int x0, y0;            // location of the start of the text
  126.     char *textstring;        // the string to draw
  127.     int status;            // 0=text off, 1=text on
  128.  
  129. } ResponseText;
  130.  
  131.  
  132. /************************************************************************
  133. ** ResponseBox
  134. **
  135. **    A specification for the screen background, and location and sizes
  136. ** of the square response lights.
  137. **
  138. *************************************************************************/
  139.  
  140. typedef struct
  141. {
  142.     ushort background_color;
  143.     int back_fillstyle;
  144.     ResponseLight response_1;
  145.     ResponseLight response_2;
  146.     ResponseLight response_3;
  147.     ResponseLight ready_light;
  148.     ResponseLight answer_light;
  149.     ResponseLight interval_1;
  150.     ResponseLight interval_2;
  151.     ResponseLight interval_3;
  152.     ResponseText failure_light;
  153.  
  154. } ResponseBox;
  155.  
  156.  
  157. /************************************************************************
  158. ** ResponseInterior
  159. **
  160. **    Since a ResponseBox is allocated in the constructor, we really
  161. ** need to add an assignment operator and copy constructor.  Later...
  162. ** (famous last word).
  163. **
  164. *************************************************************************/
  165.  
  166. class ResponseInterior : public TView
  167. {
  168.  
  169. public:
  170.  
  171.     ResponseInterior            // constructor
  172.     (
  173.     ResponseBox& virtualbox,    // light-coordinates in virtual units
  174.     const TRect& bounds
  175.     );
  176.  
  177.     ~ResponseInterior ();        // destructor
  178.  
  179.     virtual void draw ();        // override TView::draw()
  180.  
  181.     void boxAspectConvert        // convert all interior lights
  182.     (
  183.     TRect *wbox            // window box to hold it all
  184.     );
  185.     void lightAspectConvert        // converts a light to text units
  186.     (
  187.     TRect *wbox,            // window box into which light goes
  188.     ResponseLight& light,        // pixel-coordinates of light
  189.     ResponseLight& text        // text-coordinate-offsets of light
  190.     );
  191.     void textAspectConvert        // converts text to text units
  192.     (
  193.     TRect *wbox,            // window box into which light goes
  194.     ResponseText& light,        // pixel-coordinates of light
  195.     ResponseText& text        // text-coordinate-offsets of light
  196.     );
  197.     void lightDraw(ResponseLight *r);    // draws one light
  198.     void light                // sets drawing status of each light
  199.     (
  200.     unsigned char lightmask        // only a light with its bit on appears
  201.     );
  202.     void lightOn(ResponseLight *r);    // sets a light's status to RESP_ON
  203.     void lightOff(ResponseLight *r);    // sets a light's status to RESP_OFF
  204.  
  205. protected:
  206.  
  207.     int respRows;
  208.     int respColumns;
  209.     int respPixelX;
  210.     int respPixelY;
  211.  
  212.     //static ushort respBackground;    // a color
  213.  
  214.     ResponseBox *graphBox;        // light-layout in "virtual" units
  215.     ResponseBox *textBox;        // light-layout in text units
  216. };
  217.  
  218.  
  219. #endif                            // } RESPINTR_h
  220.