This section describes the declarative syntax used by rules that define menus / toolbars.<h2>Syntax</h2>
<pre>
<i>menu-rule:</i>
<i>menu-decl</i>
<i>menu-decl</i> <i>menu-rule</i>
<i>menu-decl:</i>
<i>menu-tag</i>
<i>menu-clause</i>
<i>menu-clause:</i>
<i>append-tag</i>
<i>insert-tag</i>
<i>remove-tag</i>
<i>clear-tag</i>
</pre>
<h2><menu> tag</h2>
Defines a new menu. All standard menu attributes are supported (see
<q ref="core.env:KitMenubars!MENU_BAR">MENU_BAR</q> for details).
<pre>
<i>menu-tag</i>:
<menu <i>menu-attributes</i>>
<i>menu-clause</i><sub>many</sub>
</menu>
</pre>
<h2><item> tag</h2>
Defines a menu item. This is an inner tag that can only be used inside menu <append> or <insert> clauses.
<pre>
<i>item-tag</i>:
<item <i>item-attributes...</i>/>
</pre>
<div class="INSET">
<p>
All standard menu item attributes are supported (see <q ref="core.env:KitMenubars!MENU_ITEM">MENU_ITEM</q> for details).
A special 'class' attribute is also provided as a shortcut for creating menu items based on class metadata.
An empty item tag (i.e., without attributes) represents a menu separator.
</p><p>
Menus items can be nested to create sub-menus. This nesting can continue to any number of levels.
Sub-menus that are defined by nested menu items are local to the containing menu and cannot be extended.
</p><p>
Alternatively, a sub-menu can be defined by using the 'menu' attribute on the item to reference
a global menu definition. Sub-menus defined in this way are extensible, since the global menus
on which they are based can be extended.
</p>
</div>
<h2><append> tag</h2>
Appends one or more items to the end of a menu, where the menu is either the enclosing <i>menu-tag</i> or
the specified <i>menuId</i> attribute.
<pre>
<i>append-tag</i>:
<append <i>menu="menuId"</i>>
<i>item-tag</i><sub>many</sub>
</append>
</pre>
<h2><insert> tag</h2>
Inserts one or more items before / after a specified menu item, where the menu is either the enclosing <i>menu-tag</i> or
the specified <i>menuId</i> attribute.
<pre>
<i>insert-tag</i>:<sub>one of</sub>
<insert before="itemId" <i>menu="menuId"</i>>
<i>item-tag</i><sub>many</sub>
</insert>
<insert after="itemId" <i>menu="menuId"</i>>
<i>item-tag</i><sub>many</sub>
</insert>
</pre>
<h2><remove> tag</h2>
Removes a specified menu item, where the menu is either the enclosing <i>menu-tag</i> or
the specified <i>menuId</i> attribute.
<pre>
<i>remove-tag</i>:
<remove item="itemId" <i>menu="menuId"</i>/>
</pre>
<h2><clear> tag</h2>
Clears an entire menu, where the menu is either the enclosing <i>menu-tag</i> or
the specified <i>menuId</i> attribute.
<pre>
<i>clear-tag</i>:
<clear <i>menu="menuId"</i> />
</pre>
<h2>Example (popup menu)</h2>
<pre>
<extend rule="defineContextMenu">
<constraint>(board isa svg:ZDrawing) and (element isa gml2:Unit)</constraint>
<comments> Annotate | Actual Size, Fit Window, Print...</comments>
<append>
<item command="EDIT_ANNOTATE" signal="BOARD->annotate(@pos)"/>
<item />
<item command="VIEW_ACTUAL_SIZE"/>
<item command="VIEW_FIT_WINDOW"/>
<item command="FILE_PRINT"/>
</append>
</extend>
</pre>
<h2>Example (toolbar)</h2>
<pre>
<extend rule="defineToolbars">
<constraint>model isa gml2:Model</constraint>
<comments>Standard drawing toolbars</comments>
<menu id="DSG_TOOLBAR" category="DRAWING" description="Drawing" editable="true">
<append>
<item command="VIEW_ZOOM_IN"/>
<item command="VIEW_ZOOM_OUT"/>
<item />
<item command="DRAW_FLIP_X"/>
<item command="DRAW_FLIP_Y"/>
<item command="DRAW_ROTATE_RIGHT"/>
<item command="DRAW_ROTATE_LEFT"/>
<item />
<item command="TOOLS_OPTIONS"/>
</append>
</menu>
<insert before="SEARCH_HOME" menu="MAIN_TOOLBAR">
<item command="VIEW_ZOOM_IN"/>
<item command="VIEW_ZOOM_OUT"/>
<item />
</insert>
</extend>
</pre>
<h2>Example (sub-menu)</h2>
<pre>
<extend rule="defineMainmenu">
<constraint>model isa gml2:Model</constraint>
<comments> Standard tools menu</comments>
<append>
<item command="TOOLS_KITCONFIG"/>
<item command="TOOLS_DOCUMENTATION"/>
<item text="SDK Tools">
<item command="SDK_RELOAD_KITS"/>
<item command="SDK_RELOAD_RULES"/>
<item command="SDK_RELOAD_BOARD"/>
</item>
<item />
<item command="TOOLS_CUSTOMIZE"/>
<item command="TOOLS_OPTIONS"/>
</append>
</extend>
</pre>(c) SAP AG 2003-2006. All rights reserved.