home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
util
/
cdity
/
colorsaver
/
src
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-12
|
31KB
|
1,034 lines
/****************************************************************************
* ColorSaver --- A popup color palette commodity
*
* 05 January 1993
* Compiled with DICE
*
* Copyright © 1993, 1994 By Dan Fish
* All rights reserved.
*
* Permission is granted to freely redistribute this program provided
* the source code and documentation are included in the distribution,
* changes are clearly documented, and this copyright notice remains
* unchanged.
*
****************************************************************************/
#include <exec/memory.h> /*N*/
#include <clib/macros.h> /*N*/
#include <libraries/commodities.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <workbench/startup.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <clib/exec_protos.h>
#include <clib/commodities_protos.h>
#include <clib/utility_protos.h>
#include <clib/intuition_protos.h>
#include <clib/alib_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include "gadgets.h" /* GadToolsBox file */
#include "protos.h" /* Routine prototypes */
#include "simplerexx.h" /* ARexx stuff */
#include "defs.h"
/*-------------------------------------------------------------------------
* The following strings represent the
* possible tooltypes of the ColorSaver icon.
*-------------------------------------------------------------------------*/
UBYTE *CX_PRIORITY = "CX_PRIORITY";
UBYTE *CX_POPUP = "CX_POPUP";
UBYTE *CX_POPKEY = "CX_POPKEY";
UBYTE *CX_QUIT = "CX_QUIT";
UBYTE *CX_HSV = "HSV";
UBYTE *CX_SEL = "SELECT";
UBYTE *CX_PATH = "PATH";
UBYTE *CX_POP_X = "POP_X";
UBYTE *CX_POP_Y = "POP_Y";
/*-------------------------------------------------------------------------
* Following are the default ColorSaver
* settings which can be changed with
* the command line or the icon tooltypes.
*-------------------------------------------------------------------------*/
#define CX_DEFPRI 0
#define CX_DEFSEL 0
#define CX_DEFPOP_X 175
#define CX_DEFPOP_Y 50
UBYTE *CX_DEFPOPKEY = "lalt ralt c";
UBYTE *CX_DEFPOPUP = "YES";
UBYTE *CX_DEFMODE = "RGB";
UBYTE *CX_DEFQUIT = "lalt ralt q";
UBYTE *CX_DEFPATH = "SYS:Prefs/Presets";
/*-------------------------------------------------------------------------
* Some Commodity definitions
*-------------------------------------------------------------------------*/
#define CX_SHOW 1L /* show window */
#define CX_SHUTUP 2L /* quit ColorSaver */
#define CxOn( b ) ActivateCxObj( b, TRUE )
#define CxOff( b ) ActivateCxObj( b, FALSE );
/*-------------------------------------------------------------------------
* I used this stuff for debugging
*-------------------------------------------------------------------------*/
#ifdef CS_DEBUG
UBYTE *conwinname = "CON:10/10/620/180/CS_Debug";
FILE *conwin = NULL;
#endif
/*-------------------------------------------------------------------------
* Miscellaneous program information.
*-------------------------------------------------------------------------*/
#define CSVersion "v1.19"
#define CSName "ColorSaver"
#define CSDescr "Color Palette Tool"
#define CSCopy "© 1994, Dan Fish"
#define CSDate "(10.12.1994)"
#define CSTitle CSName " " CSVersion ", " CSCopy
/*-------------------------------------------------------------------------
* Shell version string.
*-------------------------------------------------------------------------*/
#define CSVerString "$VER:" CSName " "CSVersion " "CSDate"\r\n"
static UBYTE CsVer[] = { CSVerString };
/*-------------------------------------------------------------------------
* The NewBroker structure defining
* some important information for
* the commodities.library and Exchange.
*-------------------------------------------------------------------------*/
struct NewBroker CSNBrok = {
NB_VERSION, CSName, CSTitle, CSDescr,
NBU_NOTIFY | NBU_UNIQUE, COF_SHOW_HIDE, NULL, 0
};
/*-------------------------------------------------------------------------
* DCBack required data. DCBack is a tiny link library
* written by Jan van den Baard to make it possible to write
* auto-detachable programs with DICE. DCBack also parses the
* argument line for you using ReadArgs().
*-------------------------------------------------------------------------*/
UBYTE *_procname = CSName "_" CSVersion;
UBYTE *_template = "PRIORITY/K/N,POPUP/K,POPKEY/K,QUIT/K,POP_X/K/N,POP_Y/K/N,PATH/K,SELECT/K/N,HSV/S";
UBYTE *_exthelp = NULL;
LONG _stack = 4096L;
LONG _priority = NULL;
LONG _BackGroundIO = NULL;
/*-------------------------------------------------------------------------
* ARexx declarations
*-------------------------------------------------------------------------*/
AREXXCONTEXT RexxStuff;
UBYTE RexxName[64];
/*-------------------------------------------------------------------------
* Required libraries that are not in DICE's
* auto-init library.
*-------------------------------------------------------------------------*/
struct Library *CxBase = NULL;
struct Library *IconBase = NULL;
struct Library *WorkbenchBase = NULL;
/*-------------------------------------------------------------------------
* The following libraries are all auto-init.
*-------------------------------------------------------------------------*/
extern struct IntuitionBase *IntuitionBase;
extern struct UtilityBase *UtilityBase;
extern struct GadToolsBase *GadToolsBase;
/*-------------------------------------------------------------------------
* Some other useful global variables
*-------------------------------------------------------------------------*/
struct MsgPort *CSComPort = NULL; /* commodity port */
struct MsgPort *CSIdPort = NULL; /* IDCMP port */
CxObj *CSBroker = NULL; /* the broker */
ULONG CSMask = NULL; /* the port bit-mask */
ULONG CSIdMask = NULL; /* IDCMP port bit-mask */
ULONG RexxMask = NULL; /* ARexx port bit-mask */
UBYTE *CSTTypes = NULL; /* the tooltype array */
ULONG *CSArgs; /* shell args array */
struct Screen *Scr = NULL; /* screen we open up on */
struct WBStartup *WbMsg = NULL; /* workbench message */
UBYTE *CSPopkey; /* popkey string ptr */
UBYTE *Palette_Dir; /* default palette path */
UBYTE CSIsOpen = FALSE; /* window open? */
UBYTE CSPop = TRUE; /* open on startup? */
UBYTE CSWTitle[80]; /* window title */
UWORD ColorSaverLeft; /* left edge of window */
UWORD ColorSaverTop; /* top edge of window */
UWORD RedVal; /* RGB red value */
UWORD GreenVal; /* RGB green value */
UWORD BlueVal; /* RGB blue value */
UWORD HueLevel; /* HSV hue */
UWORD SatLevel; /* HSV saturation */
UWORD ValLevel; /* HSV value */
ULONG NumColors; /* # of colors in palette */
SHORT CurrentColor=0; /* Currently selected color */
USHORT *ResetPal = NULL; /* Palette w/window first opens */
USHORT *SavePal = NULL; /* Snapshot of current palette*/
UBYTE ScanFileSpe