home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 199.lha / GimmeLib / color.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-28  |  1.7 KB  |  83 lines

  1. /*
  2.  *  FILE: color.c
  3.  *  Support routines for dealing with the color of an Intuition screen.
  4.  *
  5.  *  Public Domain, but keep my name in it as the original author.
  6.  *  31-Aug-88    Jan Sven Trabandt   first release version
  7.  */
  8.  
  9.  
  10. #define I_AM_COLOR
  11. #include <clib/macros.h>
  12. #include "gimmelib/gimmefuncs.h"
  13. #include "gimmelib/color.h"
  14.  
  15.  
  16. USHORT *getDefaultColors()
  17. {
  18.     if( DFLT_MAX_COLORS > 0 ) {
  19.     return( gimColorTable );
  20.     } else {
  21.     return( NULL );
  22.     }
  23. } /* getDefaultColors */
  24.  
  25.  
  26. short setColors( screen, ctable, colors )
  27.     struct Screen   *screen;
  28.     USHORT        *ctable;
  29.     SHORT        colors;
  30. {
  31. #ifdef GIMME_WIMPY
  32.     if( !screen || colors <= 0 ) {
  33.     return( -1 );
  34.     }
  35. #endif
  36.     if( ctable ) {
  37.     colors = MIN( colors, screen->ViewPort.ColorMap->Count );
  38.     } else {
  39.     if( colors > DFLT_MAX_COLORS ) {
  40.         return( -1 );
  41.     }
  42.     ctable = gimColorTable;
  43.     }
  44.     LoadRGB4( &screen->ViewPort, ctable, (ULONG) colors );
  45.     return( 0 );
  46. } /* setColors */
  47.  
  48.  
  49. #define TEST_TEXT    "hi!"
  50. #define TEST_TEXT_LEN    3    /* strlen(TEST_TEXT) */
  51.  
  52. short checkColors( screen, colors )
  53.     struct Screen   *screen;
  54.     SHORT        colors;
  55. {
  56.     register struct RastPort    *rp;
  57.     SHORT   i, j;
  58.     SHORT   x, y;
  59.  
  60. #ifdef GIMME_WIMPY
  61.     if( !screen ) {
  62.     return( -1 );
  63.     }
  64. #endif
  65.     rp = &screen->RastPort;
  66.     colors = MIN( colors, screen->ViewPort.ColorMap->Count );
  67.     x = 0;
  68.     y = screen->BarHeight + rp->TxHeight;
  69.     j = 0;
  70.     for( i = 0; i < colors; ++i ) {
  71.     SetAPen( rp, (ULONG) i );
  72.     if( !(i % 4) ) {
  73.         y += rp->TxHeight;
  74.         x = 0;
  75.     } else {
  76.         x += (TEST_TEXT_LEN+1) * rp->TxWidth;
  77.     }
  78.     Move( rp, (ULONG) x, (ULONG) y );
  79.     Text( rp, TEST_TEXT, (ULONG) TEST_TEXT_LEN );
  80.     }
  81.     return( 0 );
  82. } /* checkColors */
  83.