[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

The menu and menuitem structures returned by createmenus() contain no size
or positional information.  This information is added in a separate layout
step, using layoutmenus().  as with the other tag-based functions, the
program may call either LayoutMenus() or layoutmenusa().

    BOOL LayoutMenusA( struct Menu *firstmenu, APTR vi,
                       struct TagItem *taglist );
    BOOL LayoutMenus( struct Menu *firstmenu, APTR vi, Tag tag1, ... );

Set firstmenu to a pointer to a menu structure returned by a previous call
to createmenus().  the vi argument is a a visualinfo handle obtained from
getvisualinfo().  see the documentation of gadtools gadgets below for more
about this call.  For the tag arguments, tag1 or taglist, layoutmenus()
recognizes a single tag:

GTMN_TextAttr
    A pointer to an openable font (textattr structure) to be used for the
    menu item and sub-item text.  The default is to use the screen's font.

layoutmenus() fills in all the size, font and position information for the
menu strip.  LayoutMenus() returns TRUE if successful and FALSE if it
fails.  The usual reason for failure is that the font supplied cannot be
opened.

layoutmenus() takes care of calculating the width, height and position of
each individual menu item and sub-item, as well as the positioning of all
menus and sub-menus.  In the event that a menu would be too tall for the
screen, it is broken up into multiple columns.  Additionally, whole menus
may be shifted left from their normal position to ensure that they fit on
screen.  If a large menu is combined with a large font, it is possible,
even with columnization and shifting, to create a menu too big for the
screen.  GadTools does not currently trim off excess menus, items or
sub-items, but relies on Intuition to clip menus at the edges of the
screen.

It is perfectly acceptable to change the menu layout by calling
clearmenustrip() to remove the menus, then layoutmenus() to make the
change and then setmenustrip() to display the new layout.  do this when
changing the menu's font (this can be handled by a tag to LayoutMenus()),
or when updating the menu's text (to a different language, for instance).
Run-time language switching in menus will be discussed later.