home *** CD-ROM | disk | FTP | other *** search
- /*
- * FILE: color.c
- * Support routines for dealing with the color of an Intuition screen.
- *
- * Public Domain, but keep my name in it as the original author.
- * 31-Aug-88 Jan Sven Trabandt first release version
- */
-
-
- #define I_AM_COLOR
- #include <clib/macros.h>
- #include "gimmelib/gimmefuncs.h"
- #include "gimmelib/color.h"
-
-
- USHORT *getDefaultColors()
- {
- if( DFLT_MAX_COLORS > 0 ) {
- return( gimColorTable );
- } else {
- return( NULL );
- }
- } /* getDefaultColors */
-
-
- short setColors( screen, ctable, colors )
- struct Screen *screen;
- USHORT *ctable;
- SHORT colors;
- {
- #ifdef GIMME_WIMPY
- if( !screen || colors <= 0 ) {
- return( -1 );
- }
- #endif
- if( ctable ) {
- colors = MIN( colors, screen->ViewPort.ColorMap->Count );
- } else {
- if( colors > DFLT_MAX_COLORS ) {
- return( -1 );
- }
- ctable = gimColorTable;
- }
- LoadRGB4( &screen->ViewPort, ctable, (ULONG) colors );
- return( 0 );
- } /* setColors */
-
-
- #define TEST_TEXT "hi!"
- #define TEST_TEXT_LEN 3 /* strlen(TEST_TEXT) */
-
- short checkColors( screen, colors )
- struct Screen *screen;
- SHORT colors;
- {
- register struct RastPort *rp;
- SHORT i, j;
- SHORT x, y;
-
- #ifdef GIMME_WIMPY
- if( !screen ) {
- return( -1 );
- }
- #endif
- rp = &screen->RastPort;
- colors = MIN( colors, screen->ViewPort.ColorMap->Count );
- x = 0;
- y = screen->BarHeight + rp->TxHeight;
- j = 0;
- for( i = 0; i < colors; ++i ) {
- SetAPen( rp, (ULONG) i );
- if( !(i % 4) ) {
- y += rp->TxHeight;
- x = 0;
- } else {
- x += (TEST_TEXT_LEN+1) * rp->TxWidth;
- }
- Move( rp, (ULONG) x, (ULONG) y );
- Text( rp, TEST_TEXT, (ULONG) TEST_TEXT_LEN );
- }
- return( 0 );
- } /* checkColors */
-