home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / SCAPI 0.85 / Cross-platform code / MySCAPIDrawingArea.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-16  |  2.2 KB  |  128 lines  |  [TEXT/CWIE]

  1. #include "MySCAPIDrawingArea.h"
  2.  
  3. // Contructor - Destructor
  4.  
  5. MySCAPIDrawingArea::MySCAPIDrawingArea(    SCAPIWindow*    inWindowP,
  6.                                         int                inOriginx,
  7.                                         int             inOriginy,
  8.                                         int                inWidth,
  9.                                         int                inHeight    )
  10.                                 
  11.                     : SCAPIDrawingArea(                    inWindowP,
  12.                                                         inOriginx,
  13.                                                         inOriginy,
  14.                                                         inWidth,
  15.                                                         inHeight    ),
  16.                       SCAPITimer(5.0)
  17. {
  18.     mMousePressed = FALSE;
  19. }
  20.  
  21. MySCAPIDrawingArea::~MySCAPIDrawingArea()
  22. {
  23.     
  24. }
  25.  
  26. void    MySCAPIDrawingArea::Tick()
  27. {
  28.     //Beep(0, 0);
  29.     //SysBeep(0);
  30. }
  31.  
  32. // Member functions
  33.  
  34. void    MySCAPIDrawingArea::LeftMouseButtonDownEvent(int    x, int    y)
  35. {
  36.     /*SetDrawingColor(1.0, 0.0, 0.0);
  37.     
  38.     DrawFilledRectangle(    x - 5,
  39.                             y - 5,
  40.                             10,
  41.                             10        );*/
  42.                             
  43.     Clear();
  44.     
  45.     /*SetDrawingColor(1.0, 0.0, 0.0);
  46.     DrawPoint(x, y);*/
  47.     
  48.     /*SetDrawingColor(1.0, 0.0, 0.0);
  49.     
  50.     DrawFilledOval(    x ,
  51.                     y,
  52.                     10,
  53.                     20        );*/
  54. }
  55.  
  56. void    MySCAPIDrawingArea::MiddleMouseButtonDownEvent(int    x, int    y)
  57. {
  58.     /*SetDrawingColor(1.0, 1.0, 0.0);
  59.     
  60.     DrawRectangle(    x - 5,
  61.                     y - 5,
  62.                     10,
  63.                     10        );*/
  64.                     
  65.     mMousePressed = TRUE;
  66.     ClearArea(    x - 5,
  67.                 y - 5,
  68.                 20,
  69.                 10        );
  70.                 
  71.     /*SetDrawingColor(0.0, 1.0, 0.0);
  72.     DrawLine(x, y, x + 20, y + 10);*/
  73.     
  74.     /*SetDrawingColor(1.0, 1.0, 0.0);
  75.     
  76.     DrawOval(    x,
  77.                 y,
  78.                 20,
  79.                 10        );*/
  80. }
  81.  
  82. void    MySCAPIDrawingArea::RightMouseButtonDownEvent(int    x, int    y)
  83. {
  84.     int            i, j;
  85.     float        theRedIntensity;
  86.     float        theGreenIntensity;
  87.     float        theBlueIntensity;
  88.  
  89.     for (j = 0; j < 100; j += 5)
  90.         for (i = 0; i < 200; i += 5)
  91.         {
  92.             theRedIntensity = (0.894427191 * i + 0.4472135955 * j) / 223.60679775;
  93.             theGreenIntensity = (100 - j) / 100.0;
  94.             theBlueIntensity = (200 - i) / 200.0;
  95.             
  96.             SetDrawingColor(theRedIntensity, theGreenIntensity, theBlueIntensity);
  97.             DrawFilledRectangle(    i,
  98.                                     j,
  99.                                     4,
  100.                                     4    );
  101.         }
  102. }
  103.  
  104. void    MySCAPIDrawingArea::LeftMouseButtonUpEvent(int    x, int    y)
  105. {
  106.     
  107. }
  108.  
  109. void    MySCAPIDrawingArea::MiddleMouseButtonUpEvent(int    x, int    y)
  110. {
  111.     mMousePressed = FALSE;
  112. }
  113.  
  114. void    MySCAPIDrawingArea::RightMouseButtonUpEvent(int    x, int    y)
  115. {
  116.     
  117. }
  118.  
  119. void    MySCAPIDrawingArea::MouseMove(int    x, int    y)
  120. {
  121.     if (mMousePressed)
  122.     {
  123.         ClearArea(    x - 5,
  124.                 y - 5,
  125.                 20,
  126.                 10        );
  127.     }
  128. }