/*********************************************************************** * palette.c * This program is useful for designing color palettes. * It may be used stand-alone (I would be setting the 'default map', * if preferences had a complete color map...), or you can use it * as a subroutine with minor modifications. * One of the unique features of this program is that it prints * the hex value of the selected color, so you use it to generate * numeric values for use in programs. * (c) 1985 by Charlie Heath of Microsmiths, this program is in * the public domain. Not to be used commercially without permission * from MicroSmiths. ***********************************************************************/ #define I_REV 29 #define G_REV 29 #define FAST register /* Register type variable */ #define DPTH 2 /* Raster dimensions */ #define WDTH 640 #define HGHT 200 #define BCOL 1 /* Background color for menus, etc */ #define CTSIZ 4 /* In spite of myself, color table size */ /**** Variables Initialized by init_colors() **********/ struct ColorMap *p_Co; USHORT *p_ct; /* Color table as words */ extern struct ViewPort *vp; USHORT default_color[CTSIZ]; /* Save a copy of the defaults */ init_colors() { FAST int i; p_Co = (struct ColorMap *)GetColorMap(CTSIZ); p_ct = (USHORT *)p_Co->ColorTable; for ( i=0; i= 0; cursel--) backup[cursel] = p_ct[cursel]; r_prop.Flags = g_prop.Flags = b_prop.Flags = FREEHORIZ | AUTOKNOB; r_prop.HorizBody = g_prop.HorizBody = b_prop.HorizBody = 0x1000; /* Get screen from calling window */ NewCmod.Screen = calling_window->WScreen; /* NEED TO SET SCREEN!!! */ if ( ! (cW = (struct Window *)OpenWindow(&NewCmod)) ) { return(FALSE); /* Oops... */ } PrintIText(cW->RPort,&mstxt,7,71); cW->UserPort = calling_window->UserPort; ModifyIDCMP(cW, GADGETUP | GADGETDOWN | MENUVERIFY ); for ( munge = keepon = TRUE; keepon; ) { if ( munge ) { SetAPen(cW->RPort,cursel); RectFill(cW->RPort,133,3,PLX-5,66); /* RJ will proably cringe if he see's this, but it is proably */ /* safe to modify the HorizPot values this way, UNLESS the */ /* gadgets were being fiddled with when you do it. Here that */ /* is quite unlikely, since another gadget was just activated */ /* to cause the munge flag to be set... */ r_prop.HorizPot = (p_ct[cursel] & 0xf00) << 4; g_prop.HorizPot = (p_ct[cursel] & 0x0f0) << 8; b_prop.HorizPot = p_ct[cursel] << 12; RefreshGadgets(&red_gad,cW,NL); munge = FALSE; hxtxt.FrontPen = cursel ^ 15; hxtxt.BackPen = cursel; } while ( ! (imsg=(struct IntuiMessage *)GetMsg(cW->UserPort)) ) { class = p_ct[cursel] = ((r_prop.HorizPot >> 4) & 0xf00) + ((g_prop.HorizPot >> 8) & 0xf0) + (b_prop.HorizPot >>12); set_cmap(); frog[0] = hxtab[class >> 8]; frog[1] = hxtab[ (class >> 4) & 0x0f]; frog[2] = hxtab[class & 0x0f]; PrintIText(cW->RPort,&hxtxt,0,0); /* Proably, should do a WaitPort(cW->UserPort); */ /* I didn't, so the color updates faster. */ /* In a multitasking environment, the system is */ /* being gronked... */ } igad =(struct Gadget *) imsg->IAddress; if ( (class = imsg->Class) == MENUVERIFY ) { imsg->Code = MENUCANCEL; /* Don't Let Em Out! */ DisplayBeep(NL); } ReplyMsg(imsg); switch ( class ) { case GADGETUP: case GADGETDOWN: if ((igad->GadgetID >= PGAD)&&(igad->GadgetID < PGAD+CTSIZ)) { cursel = igad->GadgetID - PGAD; munge = TRUE; } else switch ( igad->GadgetID ) { case PGHI+1: /* Cancel */ for ( class =0 ; classUserPort = NL; CloseWindow(cW); return(TRUE); } /*************************************************************/