home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Demo code ƒ / demo graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  2.5 KB  |  107 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        demo graphics.c
  4.  
  5. Purpose:    This module handles updating the main window (via the
  6.             offscreen bitmaps).
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "demo graphics.h"
  30. #include "program globals.h"
  31. #include "msg graphics.h"
  32.  
  33. PicHandle            gPic1ColorPict;
  34. PicHandle            gPic1BWPict;
  35. PicHandle            gPic2ColorPict;
  36. PicHandle            gPic2BWPict;
  37.  
  38. void InitProgramGraphics(void)
  39. {
  40.     gPic1ColorPict=gPic1BWPict=gPic2ColorPict=gPic2BWPict=0L;
  41. }
  42.  
  43. void DrawTheWindowColor(int index)
  44. {
  45.     RGBColor    oldForeColor, oldBackColor;
  46.     GrafPtr        curPort;
  47.     
  48.     GetForeColor(&oldForeColor);
  49.     GetBackColor(&oldBackColor);
  50.     
  51.     GetPort(&curPort);
  52.     
  53.     switch (index)
  54.     {
  55.         case kMainWindow:
  56.             if (!gWhichWipe)
  57.                 gWhichPict=!gWhichPict;
  58.             if (gWhichPict)
  59.                 DrawThePicture(&gPic1ColorPict, kPic1ColorID, 0, 0);
  60.             else
  61.                 DrawThePicture(&gPic2ColorPict, kPic2ColorID, 0, 0);
  62.             
  63.             if (!gWhichWipe)
  64.                 gWhichPict=!gWhichPict;
  65.             break;
  66.         default:
  67.             EraseRect(&(curPort->portRect));
  68.             break;
  69.     }
  70.     
  71.     RGBForeColor(&oldForeColor);
  72.     RGBBackColor(&oldBackColor);
  73. }
  74.  
  75. void DrawTheWindowBW(int index)
  76. {
  77.     GrafPtr    curPort;
  78.     
  79.     GetPort(&curPort);
  80.     
  81.     switch (index)
  82.     {
  83.         case kMainWindow:
  84.             if (!gWhichWipe)
  85.                 gWhichPict=!gWhichPict;
  86.             if (gWhichPict)
  87.                 DrawThePicture(&gPic1BWPict, kPic1BWID, 0, 0);
  88.             else
  89.                 DrawThePicture(&gPic2BWPict, kPic2BWID, 0, 0);
  90.             
  91.             if (!gWhichWipe)
  92.                 gWhichPict=!gWhichPict;
  93.             break;
  94.         default:
  95.             EraseRect(&(curPort->portRect));
  96.             break;
  97.     }
  98. }
  99.  
  100. void ShutDownProgramGraphics(void)
  101. {
  102.     ReleaseThePict(gPic1ColorPict);
  103.     ReleaseThePict(gPic1BWPict);
  104.     ReleaseThePict(gPic2ColorPict);
  105.     ReleaseThePict(gPic2BWPict);
  106. }
  107.