527 lines
69 KiB
HTML
527 lines
69 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Interface Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInterfaceKit.html" title="The Interface Kit" /><link rel="prev" href="BListView.html" title="BListView" /><link rel="next" href="BMenuBar.html" title="BMenuBar" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BListView.html" title="BListView"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInterfaceKit.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BMenuBar.html" title="BMenuBar"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Interface Kit</div></div><div id="headerB">Prev: <a href="BListView.html">BListView</a> Up: <a href="TheInterfaceKit.html">The Interface Kit</a> Next: <a href="BMenuBar.html">BMenuBar</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu"></a>BMenu</h2></div></div></div><a id="id994280" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td><a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a></td></tr><tr><td>Mix-in Classes:</td><td>–</td></tr><tr><td>Declared In:</td><td><code class="filename">interface/Menu.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libbe.so</code></td></tr><tr><td>Allocation:</td><td>–</td></tr></tbody></table></td><td>
|
||
<a class="link overview" href="BMenu_Overview.html" title="BMenu">Class Overview</a>
|
||
<div class="toc"><ul><li><span class="section"><a href="BMenu.html#BMenu_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BMenu.html#BMenu_HookFunctions">Hook Functions</a></span></li><li><span class="section"><a href="BMenu.html#BMenu_MemberFunctions">Member Functions</a></span></li><li><span class="section"><a href="BMenu.html#BMenu_StaticFunctions">Static Functions</a></span></li><li><span class="section"><a href="BMenu.html#BMenu_Scripting">Scripting Support</a></span></li><li><span class="section"><a href="BMenu.html#BMenu_ArchivedFields">Archived Fields</a></span></li></ul></div>
|
||
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Constructor"></a>BMenu()</h4></div></div></div><a id="id994469" class="indexterm"></a><a id="id994478" class="indexterm"></a><a id="id994487" class="indexterm"></a><div class="synopsisgroup">
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BMenu</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span></span>,<br /> <span class="methodparam"><span class="type">menu_layout </span><span class="parameter">layout</span><span class="initializer"> = <span class="constant">B_ITEMS_IN_COLUMN</span></span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BMenu</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span></span>,<br /> <span class="methodparam"><span class="type">float </span><span class="parameter">width</span></span>,<br /> <span class="methodparam"><span class="type">float </span><span class="parameter">height</span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BMenu</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="modifier">protected </span><span class="methodname">BMenu</span>(<span class="methodparam"><span class="type"><a class="link" href="BRect.html" title="BRect"><code class="classname">BRect</code></a> </span><span class="parameter">frame</span></span>,<br /> <span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">name</span></span>,<br /> <span class="methodparam"><span class="type">uint32 </span><span class="parameter">resizingMode</span></span>,<br /> <span class="methodparam"><span class="type">uint32 </span><span class="parameter">flags</span></span>,<br /> <span class="methodparam"><span class="type">menu_layout </span><span class="parameter">layout</span></span>,<br /> <span class="methodparam"><span class="type">bool </span><span class="parameter">resizeToFit</span></span>);</code>
|
||
</div><p>
|
||
Initializes the <code class="classname">BMenu</code> object. The name of the object becomes the initial
|
||
label of the supermenu item that controls the menu and brings it to the
|
||
screen. (It's also the name that can be passed to
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>'s
|
||
<a class="link" href="BView.html#BView_FindView" title="FindView()"><code class="methodname">FindView()</code></a>
|
||
function.)
|
||
</p><p>
|
||
A new <code class="classname">BMenu</code> object doesn't contain any items; you need to call
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
to set up its contents.
|
||
</p><p>
|
||
A menu can arrange its items in any of three ways:
|
||
</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_ITEMS_IN_COLUMN</code></span></p></td><td><p>The items are stacked vertically in a column, one on top of the other,
|
||
as in a typical menu.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_ITEMS_IN_ROW</code></span></p></td><td><p>The items are laid out horizontally in a row, from end to end, as in a
|
||
typical menu bar.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_ITEMS_IN_MATRIX</code></span></p></td><td><p>The items are arranged in a custom fashion, such as a matrix.</p></td></tr></tbody></table><p>
|
||
Either <code class="constant">B_ITEMS_IN_ROW</code> or the default <code class="constant">B_ITEMS_IN_COLUMN</code> can be passed as
|
||
the layout argument to the public constructor. (A column is the default
|
||
for ordinary menus; a row is the default for
|
||
<a class="link" href="BMenuBar.html" title="BMenuBar"><code class="classname">BMenuBar</code></a>s.) This version of
|
||
the constructor isn't designed for <code class="constant">B_ITEMS_IN_MATRIX</code> layouts.
|
||
</p><p>
|
||
A <code class="classname">BMenu</code> object can arrange items that are laid out in a column or a row
|
||
entirely on its own. The menu will be resized to exactly fit the items
|
||
that are added to it.
|
||
</p><p>
|
||
However, when items are laid out in a custom matrix, the menu needs more
|
||
help. First, the constructor must be informed of the exact width and
|
||
height of the menu rectangle. The version of the constructor that takes
|
||
these two parameters is designed just for matrix menus—it sets the
|
||
layout to <code class="constant">B_ITEMS_IN_MATRIX</code>. Then, when items are added to the menu, the
|
||
<code class="classname">BMenu</code> object expects to be informed of their precise positions within the
|
||
specified area. The menu is not resized to fit the items that are added.
|
||
Finally, when items in the matrix change, you must take care of any
|
||
required adjustments in the layout yourself.
|
||
</p><p>
|
||
The protected version of the constructor is supplied for derived classes
|
||
that don't simply devise different sorts of menu items or arrange them in
|
||
a different way, but invent a different kind of menu. If the
|
||
<code class="parameter">resizeToFit</code> flag is
|
||
<code class="constant">true</code>, it's expected that the layout will be
|
||
<code class="constant">B_ITEMS_IN_COLUMN</code> or
|
||
<code class="constant">B_ITEMS_IN_ROW</code>. The menu will resize itself to fit
|
||
the items that are added to it. If the layout is
|
||
<code class="constant">B_ITEMS_IN_MATRIX</code>, the
|
||
<code class="parameter">resizeToFit</code> flag should be
|
||
<code class="constant">false</code>. </p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Destructor"></a>~BMenu()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BMenu</span>();</code><p>
|
||
Deletes all the items that were added to the menu and frees all memory
|
||
allocated by the <code class="classname">BMenu</code> object. Deleting the items serves also to delete
|
||
any submenus those items control and, thus, the whole branch of the menu
|
||
hierarchy.
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_HookFunctions"></a>Hook Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_AttachedToWindow"></a>AttachedToWindow()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">AttachedToWindow</span>();</code><p>
|
||
Finishes initializing the <code class="classname">BMenu</code> object by laying out its items and
|
||
resizing the <code class="classname">BMenu</code> view to fit. This function is called for you each time
|
||
the <code class="classname">BMenu</code> is assigned to a window. For a submenu, that means each time
|
||
the menu is shown on-screen.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BView.html#BView_AttachedToWindow" title="AttachedToWindow(), AllAttached()"><code class="methodname">BView::AttachedToWindow()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Draw"></a>Draw()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">Draw</span>(<span class="methodparam"><span class="type"><a class="link" href="BRect.html" title="BRect"><code class="classname">BRect</code></a> </span><span class="parameter">updateRect</span></span>);</code><p>
|
||
Draws the menu. This function is called for you whenever the menu is
|
||
placed on-screen or is updated while on-screen. It's not a function you
|
||
need to call yourself.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BView.html#BView_Draw" title="Draw()"><code class="methodname">BView::Draw()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_KeyDown"></a>KeyDown()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">KeyDown</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">bytes</span></span>,<br /> <span class="methodparam"><span class="type">int32 </span><span class="parameter">numBytes</span></span>);</code><p>
|
||
Handles keyboard navigation through the menu. This function is called to
|
||
respond to messages reporting key-down events. It should not be called
|
||
from application code.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BView.html#BView_KeyDown" title="KeyDown()"><code class="methodname">BView::KeyDown()</code></a>
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_AddItem"></a>AddItem()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="parameter">item</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="parameter">item</span></span>,<br /> <span class="methodparam"><span class="type">int32 </span><span class="parameter">index</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="parameter">item</span></span>,<br /> <span class="methodparam"><span class="type"><a class="link" href="BRect.html" title="BRect"><code class="classname">BRect</code></a> </span><span class="parameter">frame</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenu.html" title="BMenu"><code class="classname">BMenu</code></a>* </span><span class="parameter">submenu</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenu.html" title="BMenu"><code class="classname">BMenu</code></a>* </span><span class="parameter">submenu</span></span>,<br /> <span class="methodparam"><span class="type">int32 </span><span class="parameter">index</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenu.html" title="BMenu"><code class="classname">BMenu</code></a>* </span><span class="parameter">submenu</span></span>,<br /> <span class="methodparam"><span class="type"><a class="link" href="BRect.html" title="BRect"><code class="classname">BRect</code></a> </span><span class="parameter">frame</span></span>);</code>
|
||
</div><p>
|
||
Adds an item to the menu list at <code class="parameter">index</code>—or, if no index is
|
||
mentioned, to the end of the list. If items are arranged in a matrix
|
||
rather than a list, it's necessary to specify the item's <code class="parameter">frame</code>
|
||
rectangle—the exact position where it should be located in the menu
|
||
view. Assume a coordinate system for the menu that has the origin, (0.0,
|
||
0.0), at the left top corner of the view rectangle. The rectangle will
|
||
have the width and height that were specified when the menu was
|
||
constructed.
|
||
</p><p>
|
||
The versions of this function that take an <code class="parameter">index</code> (even an implicit one)
|
||
can be used only if the menu arranges items in a column or row
|
||
(<code class="constant">B_ITEMS_IN_COLUMN</code> or <code class="constant">B_ITEMS_IN_ROW</code>); it's an error to use them for
|
||
items arranged in a matrix. Conversely, the versions of this function
|
||
that take a frame rectangle can be used only if the menu arranges items
|
||
in a matrix (<code class="constant">B_ITEMS_IN_MATRIX</code>); it's an error to use them for items
|
||
arranged in a list.
|
||
</p><p>
|
||
If a <code class="parameter">submenu</code> is specified rather than an <code class="parameter">item</code>,
|
||
<code class="methodname">AddItem()</code> constructs a
|
||
controlling <a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a> for the
|
||
submenu and adds the item to the menu.
|
||
</p><p>
|
||
If it's unable to add the item to the menu—for example, if the
|
||
index is out-of-range or the wrong version of the function has been
|
||
called—<code class="methodname">AddItem()</code> returns <code class="constant">false</code>. If successful, it returns <code class="constant">true</code>.
|
||
</p><p>
|
||
See also:
|
||
the <code class="classname">BMenu</code> constructor,
|
||
the <a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a> class,
|
||
<a class="link" href="BMenu.html#BMenu_RemoveItem" title="RemoveItem()"><code class="methodname">RemoveItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_AddSeparatorItem"></a>AddSeparatorItem()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AddSeparatorItem</span>();</code><p>
|
||
Creates an instance of the
|
||
<a class="link" href="BSeparatorItem.html" title="BSeparatorItem"><code class="classname">BSeparatorItem</code></a>
|
||
class and adds it to the end of the menu list, returning
|
||
<code class="constant">true</code> if successful and <code class="constant">false</code> if not (a very
|
||
unlikely possibility). This function is a shorthand for:
|
||
</p><pre class="programlisting example cpp"><span class="type"><a class="link" href="BSeparatorItem.html" title="BSeparatorItem"><code class="classname">BSeparatorItem</code></a>*</span> <code class="varname">separator</code> = new <a class="link" href="BSeparatorItem.html" title="BSeparatorItem"><code class="classname">BSeparatorItem</code></a>;
|
||
<code class="methodname">AddItem</code>(<code class="varname">separator</code>);</pre><p>
|
||
A separator serves only to separate other items in the list. It counts as
|
||
an item and has an indexed position in the list, but it doesn't do
|
||
anything. It's drawn as a horizontal line across the menu. Therefore,
|
||
it's appropriately added only to menus where the items are laid out in a
|
||
column.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Archive"></a>Archive()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">Archive</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>,<br /> <span class="methodparam"><span class="type">bool </span><span class="parameter">deep</span><span class="initializer"> = <span class="constant">true</span></span></span>) <span class="modifier">const</span>;</code><p>
|
||
Calls the inherited version of <a class="link" href="BView.html#BView_Archive" title="Archive()"><code class="methodname">Archive()</code></a>,
|
||
then archives the <code class="classname">BMenu</code> by
|
||
recording its layout and all current settings in the
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> <code class="parameter">archive</code>. If
|
||
the <code class="parameter">deep</code> flag is <code class="constant">true</code>, all of the menu items are also archived.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BArchivable.html#BArchivable_Archive" title="Archive()"><code class="methodname">BArchivable::Archive()</code></a>,
|
||
<a class="link" href="BMenu.html#BMenu_Instantiate" title="Instantiate()"><code class="methodname">Instantiate()</code></a> static function
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_CountItems"></a>CountItems()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">int32 </span><span class="methodname">CountItems</span>() <span class="modifier">const</span>;</code><p>
|
||
Returns the total number of items in the menu, including separator items.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_FindItem"></a>FindItem()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">FindItem</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char* </span><span class="parameter">label</span></span>) <span class="modifier">const</span>;</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">FindItem</span>(<span class="methodparam"><span class="type">uint32 </span><span class="parameter">command</span></span>) <span class="modifier">const</span>;</code>
|
||
</div><p>
|
||
Returns the item with the specified <code class="parameter">label</code>—or the one that sends a
|
||
message with the specified <code class="parameter">command</code>. If there's more than one item in the
|
||
menu hierarchy with that particular <code class="parameter">label</code> or associated with that
|
||
particular <code class="parameter">command</code>, this function returns the first one it finds. It
|
||
recursively searches the menu by working down the list of items in order.
|
||
If an item controls a submenu, it searches the submenu before returning
|
||
to check any remaining items in the menu.
|
||
</p><p>
|
||
If none of the items in the menu hierarchy meet the stated criterion,
|
||
<code class="methodname">FindItem()</code> returns <code class="constant">NULL</code>.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_FindMarked"></a>FindMarked()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">FindMarked</span>();</code><p>
|
||
Returns the first marked item in the menu list (the one with the lowest
|
||
index), or <code class="constant">NULL</code> if no item is marked.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_SetRadioMode" title="SetRadioMode(), IsRadioMode()"><code class="methodname">SetRadioMode()</code></a>,
|
||
<a class="link" href="BMenuItem.html#BMenuItem_SetMarked" title="SetMarked(), IsMarked()"><code class="methodname">BMenuItem::SetMarked()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Hide"></a><a id="BMenu_Show"></a>
|
||
Hide(), Show()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">Hide</span>();</code><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">Show</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">selectFirst</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">Show</span>();</code>
|
||
</div><p>
|
||
These functions hide the menu (remove the <code class="classname">BMenu</code> view from the window it's
|
||
in and remove the window from the screen) and show it (attach the <code class="classname">BMenu</code>
|
||
to a window and place the window on-screen). If the <code class="parameter">selectFirst</code> flag
|
||
passed to <code class="methodname">Show()</code> is <code class="constant">true</code>, the first item in the menu will be selected
|
||
when it's shown. If <code class="parameter">selectFirst</code> is <code class="constant">false</code>, the menu is shown without a
|
||
selected item.
|
||
</p><p>
|
||
The version of <code class="methodname">Show()</code> that doesn't take an argument simply calls the
|
||
version that does and passes it a <code class="parameter">selectFirst</code> value of <code class="constant">false</code>.
|
||
</p><p>
|
||
These functions are not ones that you'd ordinarily call, even when
|
||
implementing a derived class. You'd need them only if you're implementing
|
||
a nonstandard menu of some kind and want to control when the menu appears
|
||
on-screen.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BView.html#BView_Show"><code class="methodname">BView::Show()</code></a>,
|
||
<a class="link" href="BMenu.html#BMenu_Track" title="Track()"><code class="methodname">Track()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_IndexOf"></a>IndexOf()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type">int32 </span><span class="methodname">IndexOf</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="parameter">item</span></span>) <span class="modifier">const</span>;</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">int32 </span><span class="methodname">IndexOf</span>(<span class="methodparam"><span class="type">BMenu* </span><span class="parameter">submenu</span></span>) <span class="modifier">const</span>;</code>
|
||
</div><p>
|
||
Returns the index of the specified menu <code class="parameter">item</code>—or the item that
|
||
controls the specified <code class="parameter">submenu</code>. Indices record the position of the item
|
||
in the menu list. They begin at 0 for the item at the top of a column or
|
||
at the left of a row and include separator items.
|
||
</p><p>
|
||
If the menu doesn't contain the specified <code class="parameter">item</code>, or the item that controls
|
||
<code class="parameter">submenu</code>, the return value will be <code class="constant">B_ERROR</code>.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_InvalidateLayout"></a>InvalidateLayout()</h4></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">InvalidateLayout</span>();</code><p>
|
||
Forces the <code class="classname">BMenu</code> to recalculate the layout of all menu items and,
|
||
consequently, its own size. It can do this only if the items are arranged
|
||
in a row or a column. If the items are arranged in a matrix, it's up to
|
||
you to keep their layout up-to-date.
|
||
</p><p>
|
||
All <code class="classname">BMenu</code> and
|
||
<a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>
|
||
functions that change an item in a way that might
|
||
affect the overall menu automatically invalidate the menu's layout so it
|
||
will be recalculated. For example, changing the label of an item might
|
||
cause the menu to become wider (if it needs more room to accommodate the
|
||
longer label) or narrower (if it no longer needs as much room as before).
|
||
</p><p>
|
||
Therefore, you don't need to call <code class="methodname">InvalidateLayout()</code> after using a kit
|
||
function to change a menu or menu item; it's called for you. You'd call
|
||
it only when making some other change to a menu.
|
||
</p><p>
|
||
See also: the <code class="classname">BMenu</code>
|
||
<a class="link" href="BMenu.html#BMenu_Constructor" title="BMenu()">constructor</a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_ItemAt"></a><a id="BMenu_SubmenuAt"></a>
|
||
ItemAt(), SubmenuAt()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">ItemAt</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">index</span></span>) <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">BMenu* </span><span class="methodname">SubmenuAt</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">index</span></span>) <span class="modifier">const</span>;</code><p>
|
||
These functions return the item at <code class="parameter">index</code>—or the submenu controlled
|
||
by the item at <code class="parameter">index</code>. If there's no item at the index,
|
||
they return <code class="constant">NULL</code>.
|
||
<code class="methodname">SubmenuAt()</code> is a shorthand for:
|
||
</p><pre class="programlisting example cpp"><code class="methodname">ItemAt</code>(<code class="varname">index</code>)-><code class="methodname">Submenu</code>()</pre><p>
|
||
It returns <code class="constant">NULL</code> if the item at <code class="parameter">index</code>
|
||
doesn't control a submenu.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Layout"></a>Layout()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="type">menu_layout </span><span class="methodname">Layout</span>() <span class="modifier">const</span>;</code><p>
|
||
Returns <code class="constant">B_ITEMS_IN_COLUMN</code> if the items in the menu are stacked in a
|
||
column from top to bottom, <code class="constant">B_ITEMS_IN_ROW</code> if they're stretched out in a
|
||
row from left to right, or <code class="constant">B_ITEMS_IN_MATRIX</code> if they're arranged in some
|
||
custom fashion. By default <code class="classname">BMenu</code> items are arranged in a column and
|
||
<a class="link" href="BMenuBar.html" title="BMenuBar"><code class="classname">BMenuBar</code></a> items in a row.
|
||
</p><p>
|
||
The layout is established by the constructor.
|
||
</p><p>
|
||
See also:
|
||
The <code class="classname">BMenu</code> <a class="link" href="BMenu.html#BMenu_Constructor" title="BMenu()">constructor</a> and
|
||
<a class="link" href="BMenuBar.html" title="BMenuBar"><code class="classname">BMenuBar</code></a> <a class="link" href="BMenuBar.html#BMenuBar_Constructor" title="BMenuBar()">constructor</a>.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_RemoveItem"></a>RemoveItem()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">RemoveItem</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">index</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">RemoveItem</span>(<span class="methodparam"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="parameter">item</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">RemoveItem</span>(<span class="methodparam"><span class="type">BMenu* </span><span class="parameter">submenu</span></span>);</code>
|
||
</div><p>
|
||
Removes the item at <code class="parameter">index</code>, or the specified <code class="parameter">item</code>, or the item that
|
||
controls the specified <code class="parameter">submenu</code>. Removing the item doesn't free it.
|
||
</p><ul class="itemizedlist"><li><p>
|
||
If passed an <code class="parameter">index</code>, this function returns a pointer to the item so
|
||
you can free it. It returns a <code class="constant">NULL</code> pointer if the item couldn't be
|
||
removed (for example, if the <code class="parameter">index</code> is out-of-range).
|
||
</p></li><li><p>
|
||
If passed an <code class="parameter">item</code>, it returns <code class="constant">true</code> if the item was in the list and
|
||
could be removed, and <code class="constant">false</code> if not.
|
||
</p></li><li><p>
|
||
If passed a <code class="parameter">submenu</code>, it returns <code class="constant">true</code> if the submenu is controlled by
|
||
an item in the menu and that item could be removed, and <code class="constant">false</code> otherwise.
|
||
</p></li></ul><p>
|
||
When an item is removed from a menu, it loses its target; the cached
|
||
value is set to <code class="constant">NULL</code>. If the item controls a submenu, it remains attached
|
||
to the submenu even after being removed.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_ScreenLocation"></a>ScreenLocation()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type"><a class="link" href="BPoint.html" title="BPoint"><code class="classname">BPoint</code></a> </span><span class="methodname">ScreenLocation</span>();</code><p>
|
||
Returns the point where the left top corner of the menu should appear
|
||
when the menu is shown on-screen. The point is specified in the screen
|
||
coordinate system.
|
||
</p><p>
|
||
This function is called each time a hidden menu (a submenu of another
|
||
menu) is brought to the screen. It can be overridden in a derived class
|
||
to change where the menu appears. For example, the
|
||
<a class="link" href="BPopUpMenu.html" title="BPopUpMenu"><code class="classname">BPopUpMenu</code></a> class
|
||
overrides it so that a pop-up menu pops up over the controlling item.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetEnabled"></a><a id="BMenu_IsEnabled"></a>
|
||
SetEnabled(), IsEnabled()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">SetEnabled</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">enabled</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsEnabled</span>() <span class="modifier">const</span>;</code><p>
|
||
<code class="methodname">SetEnabled()</code> enables the <code class="classname">BMenu</code>
|
||
if the <code class="parameter">enabled</code> flag is <code class="constant">true</code>, and disables
|
||
it if <code class="parameter">enabled</code> is <code class="constant">false</code>. If the menu is a submenu, this enables or
|
||
disables its controlling item, just as if <code class="methodname">SetEnabled()</code> were called for
|
||
that item. The controlling item is updated so that it displays its new
|
||
state, if it happens to be visible on-screen.
|
||
</p><p>
|
||
Disabling a menu disables its entire branch of the menu hierarchy. All
|
||
items in the menu, including those that control other menus, are disabled.
|
||
</p><p>
|
||
<code class="methodname">IsEnabled()</code> returns <code class="constant">true</code> if
|
||
the <code class="classname">BMenu</code>, and every <code class="classname">BMenu</code> above it in the
|
||
menu hierarchy, is enabled. It returns <code class="constant">false</code> if the
|
||
<code class="classname">BMenu</code>, or any <code class="classname">BMenu</code>
|
||
above it in the menu hierarchy, is disabled.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenuItem.html#BMenuItem_SetEnabled" title="SetEnabled(), IsEnabled()"><code class="methodname">BMenuItem::SetEnabled()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetItemMargins"></a><a id="BMenu_GetItemMargins"></a>
|
||
SetItemMargins(), GetItemMargins()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetItemMargins</span>(<span class="methodparam"><span class="type">float </span><span class="parameter">left</span></span>,<br /> <span class="methodparam"><span class="type">float </span><span class="parameter">top</span></span>,<br /> <span class="methodparam"><span class="type">float </span><span class="parameter">right</span></span>,<br /> <span class="methodparam"><span class="type">float </span><span class="parameter">bottom</span></span>);</code><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">GetItemMargins</span>(<span class="methodparam"><span class="type">float* </span><span class="parameter">left</span></span>,<br /> <span class="methodparam"><span class="type">float* </span><span class="parameter">top</span></span>,<br /> <span class="methodparam"><span class="type">float* </span><span class="parameter">right</span></span>,<br /> <span class="methodparam"><span class="type">float* </span><span class="parameter">bottom</span></span>);</code><p>
|
||
These functions set and get the margins around each item in the <code class="classname">BMenu</code>.
|
||
For the purposes of this function, you should assume that all items are
|
||
enclosed in a rectangle of the same size, one big enough for the largest
|
||
item. Keyboard shortcuts are displayed in the right margin and check
|
||
marks in the left.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_SetMaxContentWidth" title="SetMaxContentWidth(), MaxContentWidth()"><code class="methodname">SetMaxContentWidth()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetLabelFromMarked"></a><a id="BMenu_IsLabelFromMarked"></a>
|
||
SetLabelFromMarked() , IsLabelFromMarked()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="void">void </span><span class="methodname">SetLabelFromMarked</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">flag</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsLabelFromMarked</span>();</code><p>
|
||
<code class="methodname">SetLabelFromMarked()</code> determines whether the label of the item that
|
||
controls the menu (the label of the superitem) should be taken from the
|
||
currently marked item within the menu. If <code class="parameter">flag</code> is <code class="constant">true</code>, the menu is
|
||
placed in radio mode and the superitem's label is reset each time the
|
||
user selects a different item. If <code class="parameter">flag</code> is <code class="constant">false</code>, the setting for radio
|
||
mode doesn't change and the label of the superitem isn't automatically
|
||
reset.
|
||
</p><p>
|
||
<code class="methodname">IsLabelFromMarked()</code> returns whether the superitem's label is taken from
|
||
the marked item (but not necessarily whether the <code class="classname">BMenu</code> is in radio mode).
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_SetRadioMode" title="SetRadioMode(), IsRadioMode()"><code class="methodname">SetRadioMode()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetMaxContentWidth"></a><a id="BMenu_MaxContentWidth"></a>
|
||
SetMaxContentWidth(), MaxContentWidth()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">SetMaxContentWidth</span>(<span class="methodparam"><span class="type">float </span><span class="parameter">width</span></span>);</code><code class="methodsynopsis cpp"><span class="type">float </span><span class="methodname">MaxContentWidth</span>() <span class="modifier">const</span>;</code><p>
|
||
These functions set and return the maximum width of an item's content
|
||
area. The content area is where the item label is drawn; it excludes the
|
||
margin on the left where a check mark might be placed and the margin on
|
||
the right where a shortcut character or a submenu symbol might appear.
|
||
The content area is the same size for all items in the menu.
|
||
</p><p>
|
||
Normally, a menu will be wide enough to accommodate its longest item.
|
||
However, items wider than the maximum set by <code class="methodname">SetMaxContentWidth()</code> are
|
||
truncated to fit.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_SetItemMargins" title="SetItemMargins(), GetItemMargins()"><code class="methodname">SetItemMargins()</code></a>,
|
||
<a class="link" href="BMenuItem.html#BMenuItem_TruncateLabel" title="TruncateLabel()"><code class="methodname">BMenuItem::TruncateLabel()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetRadioMode"></a><a id="BMenu_IsRadioMode"></a>
|
||
SetRadioMode(), IsRadioMode()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">SetRadioMode</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">flag</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsRadioMode</span>();</code><p>
|
||
<code class="methodname">SetRadioMode()</code> puts the <code class="classname">BMenu</code>
|
||
in radio mode if <code class="parameter">flag</code> is <code class="constant">true</code> and takes it
|
||
out of radio mode if <code class="parameter">flag</code> is <code class="constant">false</code>.
|
||
In radio mode, only one item in the
|
||
menu can be marked at a time. If the user selects an item, a check mark
|
||
is placed in front of it automatically (you don't need to call
|
||
<a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>'s
|
||
<a class="link" href="BMenuItem.html#BMenuItem_SetMarked" title="SetMarked(), IsMarked()"><code class="methodname">SetMarked()</code></a>
|
||
function; it's called for you). If another item
|
||
was marked at the time, its mark is removed. Selecting a currently marked
|
||
item retains the mark.
|
||
</p><p>
|
||
<code class="methodname">IsRadioMode()</code> returns whether the
|
||
<code class="classname">BMenu</code> is currently in radio mode. The
|
||
default radio mode is <code class="constant">false</code> for ordinary
|
||
<code class="classname">BMenu</code>s, but <code class="constant">true</code> for
|
||
<a class="link" href="BPopUpMenu.html" title="BPopUpMenu"><code class="classname">BPopUpMenu</code></a>s.
|
||
</p><p>
|
||
<code class="methodname">SetRadioMode()</code> doesn't change any of the items in the menu. If you want
|
||
an initial item to be marked when the menu is put into radio mode, you
|
||
must mark it yourself.
|
||
</p><p>
|
||
When <code class="methodname">SetRadioMode()</code> turns radio mode off, it calls SetLabelFromMarked()
|
||
and passes it an argument of <code class="constant">false</code>—turning off the feature that
|
||
changes the label of the menu's superitem each time the marked item
|
||
changes. Similarly, when
|
||
<a class="link" href="BMenu.html#BMenu_SetLabelFromMarked" title="SetLabelFromMarked() , IsLabelFromMarked()"><code class="methodname">SetLabelFromMarked()</code></a>
|
||
turns on this feature, it calls <code class="methodname">SetRadioMode()</code> and
|
||
passes it an argument of <code class="constant">true</code>—turning
|
||
radio mode on.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetTargetForItems"></a>SetTargetForItems()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetTargetForItems</span>(<span class="methodparam"><span class="type"><a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a>* </span><span class="parameter">handler</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetTargetForItems</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessenger.html" title="BMessenger"><code class="classname">BMessenger</code></a> </span><span class="parameter">messenger</span></span>);</code>
|
||
</div><p>
|
||
Assigns <code class="parameter">handler</code> or <code class="parameter">messenger</code>
|
||
as the target for all the items in the menu.
|
||
The proposed target is subject to the restrictions imposed by the
|
||
<code class="methodname">SetTarget()</code> function that
|
||
<a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a> inherits from
|
||
<a class="link" href="BInvoker.html" title="BInvoker"><code class="classname">BInvoker</code></a> in the
|
||
Application Kit. See that function for further information.
|
||
</p><p>
|
||
If it's unable to set the target of any item, <code class="methodname">SetTargetForItems()</code> aborts
|
||
and returns the error it encountered. If successful in setting the target
|
||
of all items, it returns <code class="constant">B_OK</code>.
|
||
</p><p>
|
||
This function doesn't work recursively (it doesn't descend into
|
||
submenus), and it only acts on items that are currently in the <code class="classname">BMenu</code> (it
|
||
doesn't affect items that are added later).
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_SetTriggersEnabled"></a><a id="BMenu_AreTriggersEnabled"></a>
|
||
SetTriggersEnabled(), AreTriggersEnabled()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">SetTriggersEnabled</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">flag</span></span>);</code><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">AreTriggersEnabled</span>() <span class="modifier">const</span>;</code><p>
|
||
<code class="methodname">SetTriggersEnabled()</code> enables the triggers for all items in the menu if
|
||
<code class="parameter">flag</code> is <code class="constant">true</code> and disables them if
|
||
<code class="parameter">flag</code> is <code class="constant">false</code>.
|
||
<code class="methodname">AreTriggersEnabled()</code>
|
||
returns whether the triggers are currently enabled or disabled. They're
|
||
enabled by default.
|
||
</p><p>
|
||
Triggers are displayed to the user only if they're enabled, and only when
|
||
keyboard actions can operate the menu.
|
||
</p><p>
|
||
Triggers are appropriate for some menus, but not for others.
|
||
<code class="methodname">SetTriggersEnabled()</code> is typically called to
|
||
initialize the <code class="classname">BMenu</code> when
|
||
it's constructed, not to enable and disable triggers as the application
|
||
is running. If triggers are ever enabled for a menu, they should always
|
||
be enabled; if they're ever disabled, they should always be disabled.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenuItem.html#BMenuItem_SetTrigger" title="SetTrigger(), Trigger()"><code class="methodname">BMenuItem::SetTrigger()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Superitem"></a><a id="BMenu_Supermenu"></a>
|
||
Superitem(), Supermenu()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">BMenuItem* </span><span class="methodname">Superitem</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type"><span class="classname">BMenu</span> * </span><span class="methodname">Supermenu</span>() <span class="modifier">const</span>;</code><p>
|
||
These functions return the supermenu item that controls the <code class="classname">BMenu</code> and the
|
||
supermenu where that item is located. The supermenu could be a
|
||
<a class="link" href="BMenuBar.html" title="BMenuBar"><code class="classname">BMenuBar</code></a>
|
||
object. If the <code class="classname">BMenu</code> hasn't been made the submenu of another menu, both
|
||
functions return <code class="constant">NULL</code>.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">AddItem()</code></a>
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Track"></a>Track()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="type"><a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>* </span><span class="methodname">Track</span>(<span class="methodparam"><span class="type">bool </span><span class="parameter">openAnyway</span><span class="initializer"> = <span class="constant">false</span></span></span>,<br /> <span class="methodparam"><span class="type"><a class="link" href="BRect.html" title="BRect"><code class="classname">BRect</code></a>* </span><span class="parameter">clickToOpenRect</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><p>
|
||
Initiates tracking of the cursor within the menu. This function passes
|
||
tracking control to submenus (and submenus of submenus) depending on
|
||
where the user moves the mouse. If the user ends tracking by invoking an
|
||
item, <code class="methodname">Track()</code> returns the item. If the user didn't invoke any item, it
|
||
returns <code class="constant">NULL</code>. The item doesn't have to be located in
|
||
the <code class="classname">BMenu</code>; it could,
|
||
for example, belong to a submenu of the <code class="classname">BMenu</code>.
|
||
</p><p>
|
||
If the <code class="parameter">openAnyway</code> flag is <code class="constant">true</code>,
|
||
<code class="methodname">Track()</code> opens the menu and leaves it open
|
||
even though a mouse button isn't held down. This enables menu navigation
|
||
from the keyboard. If a <code class="parameter">clickToOpenRect</code> is specified and the user has set
|
||
the click-to-open preference, <code class="methodname">Track()</code> will leave the menu open if the
|
||
user releases the mouse button while the cursor is inside the rectangle.
|
||
The rectangle should be stated in the screen coordinate system.
|
||
</p><p>
|
||
<code class="methodname">Track()</code> is called by the <code class="classname">BMenu</code> to initiate tracking in the menu
|
||
hierarchy. You would need to call it yourself only if you're implementing
|
||
a different kind of menu that starts to track the cursor under
|
||
nonstandard circumstances.
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_StaticFunctions"></a>Static Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Instantiate"></a>Instantiate()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">static </span><span class="type"><a class="link" href="BArchivable.html" title="BArchivable"><code class="classname">BArchivable</code></a>* </span><span class="methodname">Instantiate</span>(<span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">archive</span></span>);</code><p>
|
||
Returns a new <code class="classname">BMenu</code> object, allocated by new and created with the version
|
||
of the constructor that takes a <a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>
|
||
archive. However, if the <code class="parameter">archive</code>
|
||
message doesn't contain data for a <code class="classname">BMenu</code> object,
|
||
<code class="methodname">Instantiate()</code> returns <code class="constant">NULL</code>.
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="BArchivable.html#BArchivable_Instantiate" title="Instantiate()"><code class="methodname">BArchivable::Instantiate()</code></a>,
|
||
<a class="link" href="TheSupportKit_Functions.html#instantiate_object" title="instantiate_object()"><code class="function">instantiate_object()</code></a>,
|
||
<a class="link" href="BMenu.html#BMenu_Archive" title="Archive()"><code class="methodname">Archive()</code></a>
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting"></a>Scripting Support</h3></div></div></div><p>
|
||
The <code class="classname">BMenu</code> class implements the suite called "suite/vnd.Be-menu"
|
||
consisting of the following messages:
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting_Enabled"></a>The Enabled Property</h4></div></div></div><p>
|
||
The "Enabled" property reflects whether the menu or menu item is enabled
|
||
or disabled.
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Message</th><th>Specifiers</th><th>Description</th></tr></thead><tbody><tr><td><code class="constant">B_GET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Returns <code class="constant">true</code> if menu or menu item is
|
||
enabled; <code class="constant">false</code> otherwise.</td></tr><tr><td><code class="constant">B_SET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Enables or disables menu or menu item.</td></tr></tbody></table></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting_Label"></a>The Label Property</h4></div></div></div><p>
|
||
The "Label" property refers to the text label of a menu or menu item.
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Message</th><th>Specifiers</th><th>Description</th></tr></thead><tbody><tr><td><code class="constant">B_GET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Returns the string label of the menu or menu item.</td></tr><tr><td><code class="constant">B_SET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Sets the string label of the menu or menu item.</td></tr></tbody></table></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting_Mark"></a>The Mark Property</h4></div></div></div><p>
|
||
The "Mark" property refers to whether or not a given menu item or a given
|
||
menu's superitem is marked.
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Message</th><th>Specifiers</th><th>Description</th></tr></thead><tbody><tr><td><code class="constant">B_GET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Returns <code class="constant">true</code> if the menu item or the
|
||
menu's superitem is marked; <code class="constant">false</code> otherwise.</td></tr><tr><td><code class="constant">B_SET_PROPERTY</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Marks or unmarks the menu item or the menu's superitem.</td></tr></tbody></table></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting_Menu"></a>The Menu Property</h4></div></div></div><p>
|
||
The "Menu" property refers to individual <code class="classname">BMenu</code>s in the menu.
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Message</th><th>Specifiers</th><th>Description</th></tr></thead><tbody><tr><td><code class="constant">B_CREATE_PROPERTY</code></td><td><code class="constant">B_NAME_SPECIFIER</code>,<br />
|
||
<code class="constant">B_INDEX_SPECIFIER</code>,<br />
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Adds a new menu item at the specified index
|
||
with the text label found in "data" and the <span class="type">int32</span> command found in "what"
|
||
(used as the <code class="varname">what</code> field in the
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> sent by the item).</td></tr><tr><td><code class="constant">B_DELETE_PROPERTY</code></td><td><code class="constant">B_NAME_SPECIFIER</code>,<br />
|
||
<code class="constant">B_INDEX_SPECIFIER</code>,<br />
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Removes the selected menu or menus.</td></tr><tr><td>any other</td><td><code class="constant">B_NAME_SPECIFIER</code>, <code class="constant">B_INDEX_SPECIFIER</code>,
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Directs scripting message to the specified
|
||
menu, first popping the current specifier off the stack.</td></tr></tbody></table></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_Scripting_MenuItem"></a>The MenuItem Property</h4></div></div></div><p>
|
||
The "MenuItem" property refers to individual <code class="classname">BMenu</code>Items in the menu.
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Message</th><th>Specifiers</th><th>Description</th></tr></thead><tbody><tr><td><code class="constant">B_COUNT_PROPERTIES</code></td><td><code class="constant">B_DIRECT_SPECIFIER</code></td><td>Counts the number of menu items in the specified menu.</td></tr><tr><td><code class="constant">B_CREATE_PROPERTY</code></td><td><code class="constant">B_NAME_SPECIFIER</code>,<br />
|
||
<code class="constant">B_INDEX_SPECIFIER</code>,<br />
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Adds a new menu item at the specified index
|
||
with the text label found in "data" and the <span class="type">int32</span> command found in "what"
|
||
(used as the <code class="varname">what</code> field in the
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>
|
||
sent by the item).</td></tr><tr><td><code class="constant">B_DELETE_PROPERTY</code></td><td><code class="constant">B_NAME_SPECIFIER</code>,<br />
|
||
<code class="constant">B_INDEX_SPECIFIER</code>,<br />
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Removes the specified menu item from its parent menu.</td></tr><tr><td><code class="constant">B_EXECUTE_PROPERTY</code></td><td><code class="constant">B_NAME_SPECIFIER</code>,<br />
|
||
<code class="constant">B_INDEX_SPECIFIER</code>,<br />
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Invokes the specified menu item.</td></tr><tr><td>any other</td><td><code class="constant">B_NAME_SPECIFIER</code>, <code class="constant">B_INDEX_SPECIFIER</code>,
|
||
<code class="constant">B_REVERSE_INDEX_SPECIFIER</code></td><td>Directs scripting message to the specified
|
||
menu, first popping the current specifier off the stack.</td></tr></tbody></table></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenu_ArchivedFields"></a>Archived Fields</h3></div></div></div><p>
|
||
The <a class="link" href="BMenu.html#BMenu_Archive" title="Archive()"><code class="methodname">Archive()</code></a>
|
||
function adds the following fields to its
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a> argument:
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Field</th><th>Type code</th><th>Description</th></tr></thead><tbody><tr><td><code class="varname">_layout</code></td><td><code class="constant">B_INT32_TYPE</code></td><td>Menu layout (Exists only if layout not <code class="constant">B_ITEMS_IN_ROW</code>).</td></tr><tr><td><code class="varname">_rsize_to_fit</code></td><td><code class="constant">B_BOOL_TYPE</code></td><td><code class="constant">true</code> if menu resizes to fit items.</td></tr><tr><td><code class="varname">_disable</code></td><td><code class="constant">B_BOOL_TYPE</code></td><td><code class="constant">true</code> if menu is disabled.</td></tr><tr><td><code class="varname">_radio</code></td><td><code class="constant">B_BOOL_TYPE</code></td><td><code class="constant">true</code> if menu is in radio mode.</td></tr><tr><td><code class="varname">_trig_disabled</code></td><td><code class="constant">B_BOOL_TYPE</code></td><td><code class="constant">true</code> if menu triggers are disabled.</td></tr><tr><td><code class="varname">_dyn_label</code></td><td><code class="constant">B_BOOL_TYPE</code></td><td><code class="constant">true</code> if menu label mirrors the currently
|
||
selected item.</td></tr><tr><td><code class="varname">_maxwidth</code></td><td><code class="constant">B_FLOAT_TYPE</code></td><td>Maximum content width of the menu.</td></tr><tr><td><code class="varname">_items</code> (array)</td><td><code class="constant">B_MESSAGE_TYPE</code></td><td>Menu items (only in deep copy).</td></tr><tr><td><code class="varname">_i_frames</code> (array)</td><td><code class="constant">B_MESSAGE_TYPE</code></td><td>Location of items (only in deep copy
|
||
of layout <code class="constant">B_ITEMS_IN_MATRIX</code>)</td></tr></tbody></table></div><p>
|
||
Some of these fields may not be present if the setting they represent
|
||
isn't used, or is the default value. For example, if the menu is
|
||
disabled, the <code class="varname">_disable</code> field won't be found in the archive.
|
||
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BListView.html">BListView</a> Up: <a href="TheInterfaceKit.html">The Interface Kit</a> Next: <a href="BMenuBar.html">BMenuBar</a> </div><div id="footerB"><div id="footerBL"><a href="BListView.html" title="BListView"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInterfaceKit.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BMenuBar.html" title="BMenuBar"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|