/*  GadTools layout toolkit
**
**  Copyright © 1993-1995 by Olaf `Olsen' Barthel
**  Freely distributable.
**
**  :ts=4
*/

#include "gtlayout_global.h"

#ifdef DO_MENUS

	/* LT_NewMenuTemplate():
	 *
	 *	Create a new menu, based on the Screen, Font and template given.
	 */

struct Menu * LIBENT
LT_NewMenuTemplate(REG(a0) struct Screen *Screen,REG(a1) struct TextAttr *TextAttr,REG(a2) struct Image *AmigaGlyph,REG(a3) struct Image *CheckGlyph,REG(d0) LONG *Error,REG(d1) struct NewMenu *MenuTemplate)
{
	if(MenuTemplate)
	{
		RootMenu	*Root;
		LONG		 ErrorValue;

		if(!Error)
			Error = &ErrorValue;

		if(Root = LTP_NewMenu(Screen,TextAttr,AmigaGlyph,CheckGlyph,Error))
		{
				// Create the menu

			if(LTP_CreateMenuTemplate(Root,Error,MenuTemplate))
			{
					// Do the layout

				if(LTP_LayoutMenu(Root,2,2))
					return(&Root -> Menu);
				else
					*Error = ERROR_DISK_FULL;
			}

			LT_DisposeMenu(&Root -> Menu);
		}
	}

	return(NULL);
}

#endif	/* DO_MENUS */
