/*
#define MWDEBUG 1
#include "memwatch.h"
*/

/* the config file */
#define CONFIG "PROGDIR:WinPlot.cfg"

/* types */

struct RangeObject
{
 APTR Min, Max, Auto;
};

struct LogScaleObject
{
 APTR Base, LogScale;
};

struct LabelObject
{
 APTR Label, XOff, YOff;
};

struct PlotWindow
{
 APTR WI_Plot, BT_Plot, BT_Load, BT_Save, BT_CD, BT_Set, BT_New, BO_Plot;
 char Title[10];
};

/* PlotImageClass */
#define PIG_LastX 0x12340001
#define PIG_LastY 0x12340002

#define NUMCOLORS 10

extern Class *PlotImgClass;

extern struct MUI_Palette_Entry  ColorEntries[];
extern char                     *ColorNames[];
extern struct PlotCommand       *commands;
extern int                       ncommands;

/* Commands */
void SendRexxMsg(char *);
void ReplyRexxMsg(void);
void LoadFunc(void);
void SaveFunc(void);
void CDFunc(void);
void LoadConf(void);
void SaveConf(void);

extern struct MsgPort *RexxReplyPort;

/* Window */
APTR GetGUI(void);
void WaitRequest(char *);
void Refresh(void);
void Settings(struct SetVar *);
BOOL HandleMUI(LONG);

#define MAXWINDOW 5

extern APTR              AP_WinPlot, LV_Font, RG_Set;
extern struct PlotWindow Windows[MAXWINDOW];
extern LONG              ActiveWindow;
  
/* WinPlot */
extern struct FileRequester *FileReq;
extern        Class         *PlotImgClass;
extern        BOOL           IsReady;

/* Hooks */
extern        char *StyleEntries[];
extern struct Hook  RangeHook, CheckHook, LogScaleHook, ConFontHook, DesFontHook,
                    RexxCommandHook, StringCommandHook, StyleHook, LabelHook, ViewHook,
                    ConVarHook, DesVarHook;

/* some a little bit changed private GnuPlot definitions from "plot.h" */
#define MAX_ID_LEN     50	/* max length of an identifier */
#define MAX_NUM_VAR	5	/* Ploting projection of func. of max. five vars. */

enum DATA_TYPES
{
 INTGR, CMPLX
};

struct cmplx
{
 double real, imag;
};

struct value
{
 enum DATA_TYPES type;
 union
  {
   int int_val;
   struct cmplx cmplx_val;
  } v;
};

typedef struct udft_entry
{				                /* user-defined function table entry */
	struct udft_entry *next_udf; 		/* pointer to next udf in linked list */
	char udf_name[MAX_ID_LEN+1]; 		/* name of this function entry */
	struct at_type *at;			/* pointer to action table to execute */
	char *definition; 			/* definition of function as typed */
	struct value dummy_values[MAX_NUM_VAR];	/* current value of dummy variables */
} udft_entry;


typedef struct udvt_entry
{			                /* user-defined value table entry */
	struct udvt_entry *next_udv;    /* pointer to next value in linked list */
	char udv_name[MAX_ID_LEN+1];    /* name of this value entry */
	ULONG udv_undef;		/* true if not defined yet */
	struct value udv_value;	        /* value it has */
} udvt_entry;
