#include <exec/nodes.h>
#include <exec/lists.h>
#include <libraries/gadtools.h>
#include <utility/tagitem.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <proto/utility.h>
#include <dialog/dialog.h>

struct Screen *myScreen;
APTR myVisualInfo;

STRPTR labels[] = { "This", "That", "Neither", NULL };

VOID dialog( VOID )
{
	DialogElement root, hstack, hbumper, vstack, ok, *termination;
	DialogElement mx1, mx2;
	ULONG error = 0;

	initDialogElement( &root, NULL, dispatchRoot, &error,
		DA_Screen, myScreen,
		DA_Member, &hstack,
		WA_Activate, TRUE,
		WA_DragBar, TRUE,
		TAG_DONE );
	initDialogElement( &hstack, &root, dispatchHStack, &error,
		DA_Member, &ok,
		DA_Member, &hbumper,
		DA_Member, &vstack,
		DA_Alignment, 0,
		TAG_DONE );
	initDialogElement( &hbumper, &root, dispatchHBumper, &error, TAG_DONE );
	initDialogElement( &vstack, &root, dispatchVStack, &error,
		DA_Member, &mx1,
		DA_Member, &mx2,
		DA_Alignment, 0,
		TAG_DONE );
	initDialogElement( &ok, &root, dispatchButton, &error,
		NGDA_TextAttr, myScreen->Font,
		NGDA_VisualInfo, myVisualInfo,
		NGDA_GadgetText, "_Ok",
		GT_Underscore, '_',
		DA_EquivalentKey, 'O',
		DA_Termination, TRUE,
		TAG_DONE );
	initDialogElement( &mx1, &root, dispatchMX, &error,
		NGDA_TextAttr, myScreen->Font,
		NGDA_VisualInfo, myVisualInfo,
/*		NGDA_Flags, PLACETEXT_LEFT,	*** default *** */
		GTMX_Labels, labels,
		GTMX_Spacing, 10,
		TAG_DONE );
	initDialogElement( &mx2, &root, dispatchMX, &error,
		NGDA_TextAttr, myScreen->Font,
		NGDA_VisualInfo, myVisualInfo,
		NGDA_Flags, PLACETEXT_RIGHT,
		GTMX_Labels, labels,
		TAG_DONE );

	if( error )
		goto cleanup;

	termination = runSimpleDialog( &root,
		WA_Title, "Example : GadTools MX",
		TAG_DONE );

cleanup:
	cleanupDialogElement( &mx1 );
	cleanupDialogElement( &mx2 );
	cleanupDialogElement( &ok );
	cleanupDialogElement( &vstack );
	cleanupDialogElement( &hstack );
	cleanupDialogElement( &hbumper );
	cleanupDialogElement( &root );
}

main( int argc, char *argv[] )
{
	myScreen = LockPubScreen( NULL );
	if( !myScreen )
		goto cleanup;

	myVisualInfo = GetVisualInfo( myScreen, TAG_DONE );
	if( !myVisualInfo )
		goto cleanup;

	dialog();

cleanup:
	if( myVisualInfo )
		FreeVisualInfo( myVisualInfo );
	if( myScreen )
		UnlockPubScreen( NULL, myScreen );
}
