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

#include "gtlayout_global.h"

#ifdef DO_MENUS

	/* LTP_FixExtraLabel(RootMenu *Root,LONG *Error):
	 *
	 *	Fix up the submenu indicators and command labels.
	 */

VOID __regargs
LTP_FixExtraLabel(RootMenu *Root,LONG *Error)
{
	ItemNode *Item;

		// Now take care of items which have command sequences
		// or submenu items attached

	for(Item = (ItemNode *)Root -> ItemList . mlh_Head ; !(*Error) && Item -> Node . mln_Succ ; Item = (ItemNode *)Item -> Node . mln_Succ)
	{
			// Does this one need more label data?

		if(Item -> Flags & (ITEMF_HasSub | ITEMF_Command))
		{
			struct IntuiText *IntuiText;

			DB(kprintf("  attach to |%s|\n",((struct IntuiText *)Item -> Item . ItemFill) -> IText));

				// Make room for the extra label data

			if(IntuiText = AsmAllocPooled(Root -> Pool,sizeof(struct IntuiText),SysBase))
			{
					// Fill it in

				LTP_InitIText(Root,IntuiText);

					// Command sequence?

				if(Item -> ExtraLabel)
				{
					IntuiText -> IText		= Item -> ExtraLabel;
					IntuiText -> ITextFont	= (struct TextAttr *)&Root -> BoldAttr;
				}
				else
					IntuiText -> IText = (STRPTR)"»";

				IntuiText -> TopEdge = (Root -> ItemHeight - Root -> RPort . TxHeight) / 2;;

					// Link to previous entry

				((struct IntuiText *)Item -> Item . ItemFill) -> NextText = IntuiText;
			}
			else
				*Error = ERROR_NO_FREE_STORE;
		}
	}
}

#endif	/* DO_MENUS */
