#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 "Small_Example.h"
#include "Small_Example_cat.h"


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

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


	Object->App = ApplicationObject,
		MUIA_Application_Author, "Eric Totel",
		MUIA_Application_Base, "SMALL",
		MUIA_Application_Title, "Small_Example",
		MUIA_Application_Version, "$VER : Small 1.0",
		MUIA_Application_Copyright, "(c) 1993 Eric Totel",
		MUIA_Application_Description, GetSmall_ExampleString( MSG_AppDescription ),
		MUIA_HelpFile, "small.guide",
		SubWindow, Object->WI_smallexample = WindowObject,
			MUIA_Window_Title, GetSmall_ExampleString( MSG_WI_smallExample ),
			MUIA_HelpNode, "WI_smallexample",
			MUIA_Window_ID, MAKE_ID( '0','W','I','N' ),
			WindowContents, Object->GROUP_ROOT_0 = GroupObject,
				Child, Object->GR_lists = GroupObject,
					GroupFrameT( GetSmall_ExampleString( MSG_GR_lists ) ),
					MUIA_HelpNode, "GR_lists",
					MUIA_Group_Horiz, TRUE,
					Child, Object->LV_label_0 = ListviewObject,
						MUIA_HelpNode, "LV_label_0",
						MUIA_Listview_List, DirlistObject,
							InputListFrame,
							MUIA_Dirlist_Directory, "progdir:",
							MUIA_Dirlist_DrawersOnly, FALSE,
							MUIA_Dirlist_FilesOnly, FALSE,
							MUIA_Dirlist_FilterDrawers, FALSE,
							MUIA_Dirlist_MultiSelDirs, FALSE,
							MUIA_Dirlist_RejectIcons, FALSE,
							MUIA_Dirlist_SortDirs, MUIV_Dirlist_SortDirs_First,
							MUIA_Dirlist_SortHighLow, FALSE,
							MUIA_Dirlist_SortType, 0,
						End,
					End,
					Child, Object->LV_label_1 = ListviewObject,
						MUIA_HelpNode, "LV_label_1",
						MUIA_Listview_MultiSelect, MUIV_Listview_MultiSelect_Default,
						MUIA_Listview_List, VolumelistObject,
							InputListFrame,
						End,
					End,
				End,
				Child, Object->GR_grp_1 = GroupObject,
					MUIA_HelpNode, "GR_grp_1",
					MUIA_Group_Horiz, TRUE,
					MUIA_Group_SameWidth, TRUE,
					Child, Object->BT_ok = ETKeyButton( GetSmall_ExampleString( MSG_BT_ok ) ),
					Child, Object->BT_cancel = ETKeyButton( GetSmall_ExampleString( MSG_BT_cancel ) ),
				End,
			End,
		End,
	End;

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

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