#include <libraries/mui.h>
#include <proto/muimaster.h>
#include <clib/exec_protos.h>
#include <exec/memory.h>

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

#ifdef _DCC
#define __inline
#endif

/*	ExTended KeyButton ( or Eric Totel KeyButton :-) )	*/
/*	to use with localization features 			*/

static APTR __inline ETKeyButton(char *text)
{
        return (KeyButton(&text[3], text[1]));
}

#include "Click.h"

struct ObjApp * CreateApp( void )
{
	struct ObjApp * Object;

	if (!(Object = AllocVec( sizeof( struct ObjApp ), MEMF_PUBLIC|MEMF_CLEAR )))
		return( NULL );

	Object->STR_TX_label_0 = "\0338\033cClick on buttons";

	Object->App = ApplicationObject,
		MUIA_Application_Author, "Eric Totel",
		MUIA_Application_Base, "CLICK",
		MUIA_Application_Title, "Click",
		MUIA_Application_Version, "$VER : Click 1.0",
		MUIA_Application_Copyright, "Eric Totel 1994",
		MUIA_Application_Description, "just a demo !!!",
		SubWindow, Object->WI_try = WindowObject,
			MUIA_Window_Title, "Click !!!",
			MUIA_Window_ID, MAKE_ID( '0','W','I','N' ),
			WindowContents, GroupObject,
				Child, Object->TX_label_0 = TextObject,
					MUIA_Background, 131,
					MUIA_Text_Contents, Object->STR_TX_label_0,
					MUIA_Text_SetMax, 0,
					MUIA_Text_SetMin, 1,
					MUIA_Frame, 9,
				End,
				Child, GroupObject,
					MUIA_Group_Horiz, TRUE,
					MUIA_Group_SameWidth, TRUE,
					Child, Object->BT_1stbutton = KeyButton( "Button 1",'1' ),
					Child, Object->BT_2ndbutton = KeyButton( "Button 2",'2' ),
					Child, Object->BT_3rdbutton = KeyButton( "Button 3",'3' ),
				End,
			End,
		End,
	End;

	if (!(Object->App))
	{
		FreeVec(Object);
		Object = NULL;
	}
	return( Object );
}

void DisposeApp( struct ObjApp * Object )
{
	MUI_DisposeObject(Object->App);
	FreeVec( Object );
}