/*
** Zapster Preferences
** -------------------
**
** © 2000 by David Gerber <zapek@vapor.com>
** All rights reserved
**
** $Id$
**
*/


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

// MUI

#include <libraries/mui.h>

// Protos

#include <proto/exec.h>
#include <proto/muimaster.h>

#include "zapster_mcc.h"
#include "v_plugin.h"

extern ULONG getv(APTR obj, ULONG attr);

extern struct Library *MUIMasterBase;

ULONG __stdargs DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
{
	return(DoSuperMethod(cl, obj, OM_NEW, &tag1, NULL));
}
 
static char *opts[] = {
	"Yes",
	"No",
	"Maybe",
	"Too bad",
	NULL
};


static ULONG handleOM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
{
	obj = (Object *)DoSuperNew(cl, obj,
						
						/*
						 * Preference object
						 */
						Child, VGroup,
							Child, VSpace(0),
							Child, HGroup,
								Child, HSpace(0),
								Child, VGroup, GroupFrameT("Prefs example"),
									Child, HGroup,
										Child, Label1("Options:"), Child, Cycle(opts),
									End,
								End,
								Child, HSpace(0),
							End,
							Child, VSpace(0),
						End,
	TAG_DONE);

	return((ULONG)obj);
}


static ULONG handleMM_Prefs_StorePrefs(struct IClass *cl, Object *obj, ULONG *msg)
{
	/*
	 * This method does nothing but we can for example store the prefs
	 * in some internal structures here.
	 */
	return(TRUE);
}


__saveds __asm ULONG prefs_dispatch(register __a0 struct IClass *cl, register __a2 Object *obj, register __a1 Msg msg)
{
	/*
	 * We need to restore the near data pointer.
	 * This *HAS* to be done in every dispatcher !
	 */
	putreg(REG_A4, cl->cl_UserData);
	
	switch (msg->MethodID)
	{
		case OM_NEW:				return(handleOM_NEW(cl, obj, (APTR)msg));
	}
	return(DoSuperMethodA(cl,obj,(Msg)msg));
}
