#ifndef LIBRARIES_XCOLOR_H
#define LIBRARIES_XCOLOR_H

/*
    XColor.library
    main include file

    © by Roger Fischlin
    created 24.1.90 by Ølli
    revised 26.1.90: changed request structure to correctly
		     reflect assembler code

*/

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif

#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif

#ifndef LIBRARIES_DOS_H
#include <libraries/dos.h>
#endif


#define XCOLORNAME "xcolor.library"
#define XC_VERSION 34

/* Library Base */
struct XColorBase {
    struct Library Libnode;
    BPTR XCb_Seglist;
    struct IntuitionBase *XCb_IntuitionBase;
    struct GfxBase *XCb_GfxBase;
    struct MathBase *XCb_MathBase;
    struct List *XCb_List;
};

/* color/colour-compatibility definitions */
#define CheckColour() CheckColor()
#define ColourMapAddress ColorMapAdress()
#define ExchangeColours() ExchangeColors()
#define CopyColours() CopyColors()
#define ColourNumber() ColorNumber()
#define ColourRequester() ColorRequester()

/* ColorRequester structur */
#define ColourRequest ColorRequest
struct ColorRequest {
    struct Screen *Screen; /* screen to open into */
    UBYTE TextColor,BackColor,GBorderColor,GTextColor; /* rendering colo(u)rs */
    ULONG Flags; /* see definitions below */
    SHORT LeftEdge,TopEdge; /* position for req window */
    struct TextAttr *Font; /* which font to use */
    ULONG DefaultEntries;  /* default color settings */
    USHORT *DefaultColorMap;
    VOID (*JMPWindow)();  /* special functions to call */
    VOID (*JMPMessage)();
    VOID (*JMPMode)();
    VOID (*JMPDraw)();
    UBYTE *ScreenTitle,*DefaultWTitle;
    ULONG im_Class; /* IntuiMsg reply */
    USHORT im_Code,im_Qualifier;
    APTR im_IAddress;
    USHORT im_MouseX,im_MouseY;
    struct Window *WindowPointer; /* We present: The Window */
    ULONG UndoSize; /* Let the user think about his sins */
    USHORT *UndoBuffer;
    USHORT Undo;
    ULONG Color; /* the current colo(u)r */
    ULONG MemorySize,*Memory; /* keep track of the mem */
    struct NewWindow *NewWindow;
    ULONG Mode;     /* the current mode */
    UBYTE *WindowTitle; /* the current windowtitle */
    ULONG Reserved[10]; /* set to ZERO */
};

#define TextColour TextColor
#define BackColour BackColor
#define GBorderColour GBorderColor
#define GTextColour GTextColor
#define DefaultColourMap DefaultColorMap
#define Colour Color


/* Flag definitions for ColorReq-structure */
#define FLAG_HSV 1
#define FLAG_RGB 0
#define FLAG_HEX 2
#define FLAG_NORMAL 0
#define FLAG_NOWINDOWDEPTH 4
#define FLAG_NOWINDOWDRAG 8
#define FLAG_RMBTRAP 16

/* return codes */
#define CR_NOTHING 0
#define CR_REMAKE 1
#define CR_NEWMODE 2
#define CR_EXIT 3
#define CR_NEWCOLOR 4
#define CR_UPDATECOLOR 5
#define CR_NEWCOLOUR 4
#define CR_UPDATECOLOUR 5

/* modes */
#define MODE_COLOUR 0
#define MODE_COLOR 0
#define MODE_COPY 1
#define MODE_EXCHG 2
#define MODE_SPREAD 3

/* returns from ColorRequester() */
#define CR_OK 0
#define CR_NoMemory -1
#define CR_ViewPortused -2
#define CR_NoWindow -3

/* for RGBtoHSV */
struct HSV {
    ULONG HSV_H,HSV_S,HSV_V;
};

#endif
