revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / gadtools / layoutmenusa.c
blobab6e2377e199f5ef528746177139602e2bef8223
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 #include "gadtools_intern.h"
7 /*********************************************************************
9 NAME */
11 #include <string.h>
13 #include <exec/types.h>
14 #include <proto/gadtools.h>
15 #include <intuition/intuition.h>
16 #include <graphics/text.h>
18 AROS_LH3(BOOL, LayoutMenusA,
20 /* SYNOPSIS */
21 AROS_LHA(struct Menu *, menu, A0),
22 AROS_LHA(APTR, vi, A1),
23 AROS_LHA(struct TagItem *, tagList, A2),
25 /* LOCATION */
26 struct Library *, GadToolsBase, 11, GadTools)
28 /* FUNCTION
30 INPUTS
31 menu - Menu to be layouted.
32 vi - Visual info to layout the menu for.
33 tagList - Additional tags.
35 RESULT
36 FALSE, if an error occured.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 CreateMenusA(), LayoutMenuItemsA(), GetVisualInfoA()
47 INTERNALS
49 HISTORY
51 ***************************************************************************/
53 AROS_LIBFUNC_INIT
55 ULONG curX = 0;
56 ULONG curY = 0;
57 struct VisualInfo * vinfo = (struct VisualInfo *)vi;
59 struct TextFont * textfont = vinfo->vi_dri->dri_Font;
61 /* Set GTMN_Menu to menu, as GTMN_Menu is really just a
62 LayoutMenuItemsA() tag, and should not appear in the
63 taglist passed to LayoutMenusA(). stegerg. */
65 struct TagItem stdlayouttags[] =
67 {GTMN_Menu , (IPTR)menu},
68 {GTMN_TextAttr , (IPTR) NULL },
69 {GTMN_NewLookMenus , TRUE },
70 {GTMN_Checkmark , (IPTR) NULL },
71 {GTMN_AmigaKey , (IPTR) NULL },
72 {GTMN_FrontPen , 0L },
73 {TAG_DONE }
76 if (NULL == textfont)
77 return FALSE;
79 stdlayouttags[TAG_TextAttr].ti_Data = GetTagData(GTMN_TextAttr,
80 (IPTR) NULL,
81 tagList);
83 stdlayouttags[TAG_NewLookMenus].ti_Data = GetTagData(GTMN_NewLookMenus,
84 FALSE,
85 tagList);
87 stdlayouttags[TAG_CheckMark].ti_Data = GetTagData(GTMN_Checkmark,
88 (IPTR) NULL,
89 tagList);
91 stdlayouttags[TAG_AmigaKey].ti_Data = GetTagData(GTMN_AmigaKey,
92 (IPTR) NULL,
93 tagList);
96 ** Only if the FrontPen is provided I will make it a valid
97 ** entry in the tag list.
98 */
100 if (NULL != tagList && NULL != FindTagItem(GTMN_FrontPen, tagList))
102 stdlayouttags[TAG_FrontPen].ti_Data = GetTagData(GTMN_FrontPen,
104 tagList);
106 else
108 stdlayouttags[TAG_FrontPen].ti_Tag = TAG_DONE;
112 while (NULL != menu)
114 if (NULL != menu->FirstItem)
116 stdlayouttags[TAG_Menu].ti_Data = (IPTR)menu;
118 if (FALSE == LayoutMenuItemsA(menu->FirstItem,
120 stdlayouttags))
121 return FALSE;
125 ** Set the coordinates of this menu title
126 ** !!! This might still look ugly...
128 menu->LeftEdge = curX;
129 menu->TopEdge = curY;
131 menu->Width = TextLength(&vinfo->vi_screen->RastPort,
132 menu->MenuName,
133 strlen(menu->MenuName)) +
134 vinfo->vi_screen->MenuHBorder * 2;
136 #if 0
137 /* stegerg: the Amiga just clips them away, and BTW:
138 dri->dri_Resolution.X is not screen width!! It's
139 aspect information */
140 if (menu->Width + curX > vinfo->vi_dri->dri_Resolution.X)
142 //#warning Proper layout of menu titles???
143 curX = 0;
144 curY += ((textfont->tf_YSize * 5) / 4);
146 menu->LeftEdge = curX;
147 menu->TopEdge = curY;
149 #endif
151 menu->Height = textfont->tf_YSize;
153 /* Proper layout??? */
154 curX += menu->Width + vinfo->vi_screen->BarHBorder * 2;
157 menu = menu->NextMenu;
158 } /* while (NULL != menu) */
160 return TRUE;
162 AROS_LIBFUNC_EXIT
163 } /* LayoutMenusA */