/*
 *  prefs.h - include file for the preferences program
 *  Copyright (C) 1997 Aki Laukkanen

 *
 */

#ifndef PREFS_H
#define PREFS_H

/*
 * global includes
 */

#include <exec/types.h>
#include <exec/memory.h>

#include <libraries/mui.h>
#include <libraries/asl.h>
#include <libraries/gadtools.h>

#include <utility/utility.h>
#include <utility/tagitem.h>

#include <dos/dos.h>

#ifdef __SASC
#define __USE_SYSBASE
#endif

#ifdef __GNUC__
#define __NOLIBBASE__
#endif

#include <proto/muimaster.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>

#include "macros.h"
#include "evd_prefs.h"

/*
 * defines
 */

#ifndef TAGBASE_AMLAUKKA
#define TAGBASE_AMLAUKKA (TAG_USER | 0x0dad0000)    /* from mccreg@sasg.com */
#endif /* TAGBASE_AMLAUKKA */

#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((((ULONG) (a)) << 24) | (((ULONG) (b)) << 16) | (((ULONG) (c)) << 8) | ((ULONG) (d)))
#endif /* MAKE_ID */

#define DEFAULT_PALCACHE "PROGDIR:palette.cached"

/*
 * external symbols
 */

extern struct MUI_CustomClass* CL_prefsWindow;
extern struct MUI_CustomClass* CL_evdPanel;
extern struct MUI_CustomClass* CL_paletteWindow;

/*
 * function prototypes
 */

extern ULONG REGARGS prefsWindow_Dispatcher(REG(a0, struct IClass*),REG(a2, Object*),REG(a1, Msg));
extern ULONG REGARGS evdPanel_Dispatcher(REG(a0, struct IClass*),REG(a2, Object*),REG(a1, Msg));
extern ULONG REGARGS paletteWindow_Dispatcher(REG(a0, struct IClass*),REG(a2, Object*),REG(a1, Msg));

/*
 * some helper functions 'nicked' from PSI sources
 */

extern ULONG STDARGS DoSuperNew(struct IClass*, Object*, ULONG, ...);
extern LONG xget(Object*,ULONG);
extern char* getfilename(Object*, char*, char*, char*, BOOL);
extern BOOL getbool(Object*);
extern Object* MakeButton(char*);
extern Object* MakeCheck(char*);
extern Object* MakeLLabel1(char*);
extern Object* MakeSlider(int,int, char*);
extern Object* MakeString(int, char*);

/*
 * public methods
 */

#define MUIM_evdPanel_Save (TAGBASE_AMLAUKKA+0x1001)
#define MUIM_evdPanel_Load (TAGBASE_AMLAUKKA+0x1002)
#define MUIM_evdPanel_Finish (TAGBASE_AMLAUKKA+0x1003)
#define MUIM_evdPanel_CloseWindows (TAGBASE_AMLAUKKA+0x1004)

/*
 * public attributes
 */

#define MUIA_paletteWindow_Palette (TAGBASE_AMLAUKKA+0x8001)
#define MUIA_paletteWindow_Orig (TAGBASE_AMLAUKKA+0x8002)

/*
 * instance data structures
 */

struct MUIP_evdPanel_Finish
{
	ULONG   method_id;
	Object* win;
};

struct prefsWindowData
{
	Object* PA_evd;
};

struct paletteEntry
{
	Object* palWindow;          /* pointer to an open palette edit window */
	char*   name;               /* for the listview */
	char*   filename;           /* cached name */
	ULONG   epsilon;            /* magic epsilon value */
	ULONG   rgb[64];            /* palette data */
};

struct paletteWindowData
{
	Object* PA_Orig;
	Object* ST_Name;
	Object* ST_CachedName;
	Object* ST_Epsilon;
	struct paletteEntry* pal;
	BOOL    changed;
	ULONG   rgb[64];
};

struct evdPanelData
{
	Object* BT_New;
	Object* BT_Delete;
	Object* BT_Edit;
	Object* LV_Palettes;
	Object* ST_PaletteName;
	Object* CM_BBlank;
	Object* CM_FCached;
	Object* CM_CImpres;
	Object* CM_OwnRefr;
	Object* SL_RRate;

	ULONG   refreshrate;
	ULONG   numpals;
	ULONG   usedpal;
	BOOL    bblank;
	BOOL    own_refresh;
	BOOL    copyback_buffer;
	BOOL    imprecise_bitplanes;
};

#endif /* PREFS_H */
