#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 "Window.h"

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

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

	Object->STR_Info = NULL;
	Object->STR_ExactText = "\033c Exact";
	Object->STR_OneText = "\033c One Out";
	Object->STR_TwoText = "\033c Two Out";
	Object->STR_ExactList = NULL;
	Object->STR_OneOutList = NULL;
	Object->STR_TwoOutList = NULL;
	Object->STR_Chord_Name_Box = NULL;
	Object->STR_Chord_Notes_Box = NULL;
	Object->STR_Chord_Intervals_Box = NULL;

	Object->App = ApplicationObject,
		MUIA_Application_Author, "Reggie",
		MUIA_Application_Base, "CHORDMASTER",
		MUIA_Application_Title, "Chord Master",
		MUIA_Application_Version, "$VER: ChordMaster 1.2b",
		MUIA_Application_Copyright, "Chris Carr 1995",
		MUIA_Application_Description, "Chord Master Program",
		SubWindow, Object->Chord_Pro_Window = WindowObject,
			MUIA_Window_Title, "Chord_Master 1.1b",
			MUIA_Window_ID, MAKE_ID( '0','W','I','N' ),
			WindowContents, GroupObject,
				Child, GroupObject,
					GroupFrameT( "Notes" ),
					MUIA_Group_Rows, 1,
					Child, ColGroup( 2 ),
						Child, Label2( "A" ),
						Child, Object->Note0 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "A#" ),
						Child, Object->Note1 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "B" ),
						Child, Object->Note2 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "C" ),
						Child, Object->Note3 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "C#" ),
						Child, Object->Note4 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "D" ),
						Child, Object->Note5 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "D#" ),
						Child, Object->Note6 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "E" ),
						Child, Object->Note7 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "F" ),
						Child, Object->Note8 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "F#" ),
						Child, Object->Note9 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "G" ),
						Child, Object->Note10 = CheckMark( FALSE ),
					End,
					Child, ColGroup( 2 ),
						Child, Label2( "G#" ),
						Child, Object->Note11 = CheckMark( FALSE ),
					End,
				End,
				Child, GroupObject,
					Child, Object->StartButton = KeyButton( "Start",'s' ),
				End,
				Child, GroupObject,
					Child, Object->Info = TextObject,
						MUIA_Background, 131,
						MUIA_Text_Contents, Object->STR_Info,
						MUIA_Text_SetMax, 0,
						MUIA_Text_SetMin, 0,
						MUIA_Frame, 3,
					End,
				End,
				Child, GroupObject,
					GroupFrameT( "Matches" ),
					MUIA_Group_Columns, 3,
					Child, Object->ExactText = TextObject,
						MUIA_Background, 128,
						MUIA_Text_Contents, Object->STR_ExactText,
						MUIA_Text_SetMax, 0,
						MUIA_Text_SetMin, 0,
						MUIA_Frame, 0,
					End,
					Child, Object->OneText = TextObject,
						MUIA_Background, 128,
						MUIA_Text_Contents, Object->STR_OneText,
						MUIA_Text_SetMax, 0,
						MUIA_Text_SetMin, 0,
						MUIA_Frame, 0,
					End,
					Child, Object->TwoText = TextObject,
						MUIA_Background, 128,
						MUIA_Text_Contents, Object->STR_TwoText,
						MUIA_Text_SetMax, 0,
						MUIA_Text_SetMin, 0,
						MUIA_Frame, 0,
					End,
					Child, Object->ExactList = ListviewObject,
						MUIA_Listview_List, FloattextObject,
							MUIA_Floattext_Text, Object->STR_ExactList,
							ReadListFrame,
						End,
					End,
					Child, Object->OneOutList = ListviewObject,
						MUIA_Listview_List, FloattextObject,
							MUIA_Floattext_Text, Object->STR_OneOutList,
							ReadListFrame,
						End,
					End,
					Child, Object->TwoOutList = ListviewObject,
						MUIA_Listview_List, FloattextObject,
							MUIA_Floattext_Text, Object->STR_TwoOutList,
							ReadListFrame,
						End,
					End,
				End,
				Child, GroupObject,
					MUIA_Group_Columns, 2,
					Child, Object->AboutButton = KeyButton( "About",'b' ),
					Child, Object->QuitButton = KeyButton( "Quit",'q' ),
				End,
			End,
		End,
		SubWindow, Object->Chord_Info_Window = WindowObject,
			MUIA_Window_Title, "Chord Information",
			MUIA_Window_ID, MAKE_ID( '1','W','I','N' ),
			WindowContents, GroupObject,
				MUIA_Group_Columns, 2,
				Child, Label( "Chord Name " ),
				Child, Object->Chord_Name_Box = TextObject,
					MUIA_Background, 131,
					MUIA_Text_Contents, Object->STR_Chord_Name_Box,
					MUIA_Text_SetMax, 0,
					MUIA_Text_SetMin, 1,
					MUIA_Frame, 5,
				End,
				Child, Label( "Chord Notes " ),
				Child, Object->Chord_Notes_Box = TextObject,
					MUIA_Background, 131,
					MUIA_Text_Contents, Object->STR_Chord_Notes_Box,
					MUIA_Text_SetMax, 0,
					MUIA_Text_SetMin, 1,
					MUIA_Frame, 5,
				End,
				Child, Label( "Chord Intervals " ),
				Child, Object->Chord_Intervals_Box = TextObject,
					MUIA_Background, 131,
					MUIA_Text_Contents, Object->STR_Chord_Intervals_Box,
					MUIA_Text_SetMax, 0,
					MUIA_Text_SetMin, 1,
					MUIA_Frame, 5,
				End,
			End,
		End,
	End;

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

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