2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 #include "gadtools_intern.h"
7 /*********************************************************************
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
,
21 AROS_LHA(struct Menu
*, menu
, A0
),
22 AROS_LHA(APTR
, vi
, A1
),
23 AROS_LHA(struct TagItem
*, tagList
, A2
),
26 struct Library
*, GadToolsBase
, 11, GadTools
)
31 menu - Menu to be layouted.
32 vi - Visual info to layout the menu for.
33 tagList - Additional tags.
36 FALSE, if an error occured.
45 CreateMenusA(), LayoutMenuItemsA(), GetVisualInfoA()
51 ***************************************************************************/
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 },
79 stdlayouttags
[TAG_TextAttr
].ti_Data
= GetTagData(GTMN_TextAttr
,
83 stdlayouttags
[TAG_NewLookMenus
].ti_Data
= GetTagData(GTMN_NewLookMenus
,
87 stdlayouttags
[TAG_CheckMark
].ti_Data
= GetTagData(GTMN_Checkmark
,
91 stdlayouttags
[TAG_AmigaKey
].ti_Data
= GetTagData(GTMN_AmigaKey
,
96 ** Only if the FrontPen is provided I will make it a valid
97 ** entry in the tag list.
100 if (NULL
!= tagList
&& NULL
!= FindTagItem(GTMN_FrontPen
, tagList
))
102 stdlayouttags
[TAG_FrontPen
].ti_Data
= GetTagData(GTMN_FrontPen
,
108 stdlayouttags
[TAG_FrontPen
].ti_Tag
= TAG_DONE
;
114 if (NULL
!= menu
->FirstItem
)
116 stdlayouttags
[TAG_Menu
].ti_Data
= (IPTR
)menu
;
118 if (FALSE
== LayoutMenuItemsA(menu
->FirstItem
,
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
,
133 strlen(menu
->MenuName
)) +
134 vinfo
->vi_screen
->MenuHBorder
* 2;
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???
144 curY
+= ((textfont
->tf_YSize
* 5) / 4);
146 menu
->LeftEdge
= curX
;
147 menu
->TopEdge
= curY
;
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) */