[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.