/*
\\              Custom `select' class
*/

        #include <Includes/Main_Global.h>

	#define	 DIZSIZE	(44*12)
const char Default_DIZ[]=
 {
 "********************************************\n"
 "*     __________________________________   *\n"
 "*    / _  |  .  |  .  |  ___|  ___)  ___)  *\n"
 "*   / __  |  |--|  |--|  _)_|___  |___  |  *\n"
 "* _/  `|  |  '  |  '  |  `  |  `  |  `  |  *\n"
 "* `----`--`-----`-----`-----`-----`-----'  *\n"
 "*                                          *\n"
 "*              ..presents..                *\n"
 "*                                          *\n"
 "*                                          *\n"
 "*            DIZZER II by Cray             *\n"
 "********************************************\n"
 };

ULONG __stdargs DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
{
        return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
} 

// 45 CHARS *12 LINES

ULONG ASM SAVEDS DIZ_View_Dispatcher( REG(a0) struct IClass *cl,
					REG(a2) Object *o,
					REG(a1) Msg msg)
{

	switch(msg->MethodID)
	{
		case OM_SET:		return(_Set(cl,o,(APTR)msg));
		case MUIM_AskMinMax:	return(_AskMinMax(cl,o,(APTR)msg));
		case MUIM_Draw: 	return(_Draw(cl,o,(APTR)msg));
	}
	
     return(DoSuperMethodA(cl,o,(APTR) msg));
}

SAVEDS ULONG _Set(struct IClass *cl,Object *obj,struct opSet *msg)
{
	struct InstanceData *Data = INST_DATA(cl,obj);
	struct TagItem *tags,*tag;
	
	for(tags=((struct opSet *)msg)->ops_AttrList;tag=NextTagItem(&tags);)
	{
	  switch (tag->ti_Tag)
	  {
	   case	MUIA_DIZ_Contents:
	        if(strcmp(&Data->Main_Description,tag->ti_Data))
	   	strncpy(&Data->Main_Description,tag->ti_Data,DIZSIZE);
	   	MUI_Redraw(obj,MADF_DRAWOBJECT);
	   	break;
	  }
	 }
	 return(DoSuperMethodA(cl,obj,msg));
}

SAVEDS ULONG _Draw(struct IClass *cl,Object *obj,struct MUIP_Draw *msg)
{
 struct InstanceData *Data = INST_DATA(cl,obj);
 int GlobalIndex=0;
 int LocalIndex=0;
 char RasterBuffer[46];

 
 DoSuperMethodA(cl,obj,msg);
 SetAPen(_rp(obj),1);
 SetFont(_rp(obj),_font(obj));
 Move(_rp(obj),_mleft(obj)+(_font(obj)->tf_XSize),_mtop(obj)+(_font(obj)->tf_YSize));	
 
 while(GlobalIndex<DIZSIZE)	
       { 
	   while(Data->Main_Description[GlobalIndex]!=0x0A && LocalIndex<44 )
        	 {
	           RasterBuffer[LocalIndex]=Data->Main_Description[GlobalIndex];
	           LocalIndex++;
	           GlobalIndex++;
	         }
	   GlobalIndex++;
	   RasterBuffer[LocalIndex]=NULL; 
	   Text(_rp(obj),RasterBuffer,strlen(&RasterBuffer));
	   Move(_rp(obj),_mleft(obj)+(_font(obj)->tf_XSize),((_rp(obj)->cp_y)+_font(obj)->tf_YSize));
	   LocalIndex=0;
       }

}

ULONG _AskMinMax(struct IClass *cl,Object *obj,struct MUIP_AskMinMax *msg)
{	
	
        
        DoSuperMethodA(cl,obj,msg);
        
        msg->MinMaxInfo->MinWidth  += _font(obj)->tf_XSize * 45+1;
        msg->MinMaxInfo->DefWidth  += _font(obj)->tf_XSize * 45+1;
        msg->MinMaxInfo->MaxWidth  += _font(obj)->tf_XSize * 45+1;
        msg->MinMaxInfo->MinHeight += _font(obj)->tf_YSize * 12+1;
        msg->MinMaxInfo->DefHeight += _font(obj)->tf_YSize * 12+1;
        msg->MinMaxInfo->MaxHeight += _font(obj)->tf_YSize * 12+1;
       
        return(0);
}

















  