xref: /haiku/docs/user/interface/Menu.dox (revision 1978089f7cec856677e46204e992c7273d70b9af)
12f746eafSJohn Scipione/*
2*1978089fSPulkoMandy * Copyright 2013-2023 Haiku, Inc. All rights reserved.
32f746eafSJohn Scipione * Distributed under the terms of the MIT License.
42f746eafSJohn Scipione *
52f746eafSJohn Scipione * Authors:
62f746eafSJohn Scipione *		John Scipione, jscipione@gmail.com
72f746eafSJohn Scipione *
82f746eafSJohn Scipione * Corresponds to:
9*1978089fSPulkoMandy *		headers/os/interface/Menu.h	 hrev55562
10*1978089fSPulkoMandy *		src/kits/interface/Menu.cpp	 hrev55562
112f746eafSJohn Scipione */
122f746eafSJohn Scipione
132f746eafSJohn Scipione
142f746eafSJohn Scipione/*!
152f746eafSJohn Scipione	\file Menu.h
162f746eafSJohn Scipione	\ingroup interface
172f746eafSJohn Scipione	\ingroup libbe
18d7d2ff5bSJohn Scipione	\brief BMenu class definition and support structures.
192f746eafSJohn Scipione*/
202f746eafSJohn Scipione
212f746eafSJohn Scipione
222f746eafSJohn Scipione/*!
232f746eafSJohn Scipione	\enum menu_layout
242f746eafSJohn Scipione	\ingroup interface
252f746eafSJohn Scipione
262f746eafSJohn Scipione	Constants to define the layout of the menu items in a menu.
2747852bffSJohn Scipione
2847852bffSJohn Scipione	\since BeOS R3
292f746eafSJohn Scipione*/
302f746eafSJohn Scipione
312f746eafSJohn Scipione
322f746eafSJohn Scipione/*!
332f746eafSJohn Scipione	\var menu_layout B_ITEMS_IN_ROW
342f746eafSJohn Scipione
352f746eafSJohn Scipione	Items are arranged in a row, one next to the other.
3647852bffSJohn Scipione
3747852bffSJohn Scipione	\since BeOS R3
382f746eafSJohn Scipione*/
392f746eafSJohn Scipione
402f746eafSJohn Scipione
412f746eafSJohn Scipione/*!
422f746eafSJohn Scipione	\var menu_layout B_ITEMS_IN_COLUMN
432f746eafSJohn Scipione
442f746eafSJohn Scipione	Items are arranged in a column, one on top of the other.
4547852bffSJohn Scipione
4647852bffSJohn Scipione	\since BeOS R3
472f746eafSJohn Scipione*/
482f746eafSJohn Scipione
492f746eafSJohn Scipione
502f746eafSJohn Scipione/*!
512f746eafSJohn Scipione	\var menu_layout B_ITEMS_IN_MATRIX
522f746eafSJohn Scipione
532f746eafSJohn Scipione	Items are arranged in a matrix, a free-form arrangement that you create.
5447852bffSJohn Scipione
5547852bffSJohn Scipione	\since BeOS R3
562f746eafSJohn Scipione*/
572f746eafSJohn Scipione
582f746eafSJohn Scipione
592f746eafSJohn Scipione/*!
602f746eafSJohn Scipione	\struct menu_info
612f746eafSJohn Scipione	\ingroup interface
622f746eafSJohn Scipione	\ingroup libbe
632f746eafSJohn Scipione	\brief Information about a menu such as font size and family, background
642f746eafSJohn Scipione	       color, and flags.
6547852bffSJohn Scipione
6647852bffSJohn Scipione	\since BeOS R3
672f746eafSJohn Scipione*/
682f746eafSJohn Scipione
692f746eafSJohn Scipione
702f746eafSJohn Scipione/*!
712f746eafSJohn Scipione	\var menu_info::font_size
722f746eafSJohn Scipione
732f746eafSJohn Scipione	The font size to draw menu items with.
7447852bffSJohn Scipione
7547852bffSJohn Scipione	\since BeOS R3
762f746eafSJohn Scipione*/
772f746eafSJohn Scipione
782f746eafSJohn Scipione
792f746eafSJohn Scipione/*!
802f746eafSJohn Scipione	\var menu_info::f_family
812f746eafSJohn Scipione
822f746eafSJohn Scipione	The font family used to draw menu items.
8347852bffSJohn Scipione
8447852bffSJohn Scipione	\since BeOS R3
852f746eafSJohn Scipione*/
862f746eafSJohn Scipione
872f746eafSJohn Scipione
882f746eafSJohn Scipione/*!
892f746eafSJohn Scipione	\var menu_info::f_style
902f746eafSJohn Scipione
912f746eafSJohn Scipione	The font style used to draw menu items.
9247852bffSJohn Scipione
9347852bffSJohn Scipione	\since BeOS R3
942f746eafSJohn Scipione*/
952f746eafSJohn Scipione
962f746eafSJohn Scipione
972f746eafSJohn Scipione/*!
982f746eafSJohn Scipione	\var menu_info::background_color
992f746eafSJohn Scipione
1002f746eafSJohn Scipione	The menu's background color.
10147852bffSJohn Scipione
10247852bffSJohn Scipione	\since BeOS R3
1032f746eafSJohn Scipione*/
1042f746eafSJohn Scipione
1052f746eafSJohn Scipione
1062f746eafSJohn Scipione/*!
1072f746eafSJohn Scipione	\var menu_info::separator
1082f746eafSJohn Scipione
1092f746eafSJohn Scipione	The style of horizontal line to use to separates groups of items in a menu.
11047852bffSJohn Scipione
11147852bffSJohn Scipione	\since BeOS R3
1122f746eafSJohn Scipione*/
1132f746eafSJohn Scipione
1142f746eafSJohn Scipione
1152f746eafSJohn Scipione/*!
1162f746eafSJohn Scipione	\var menu_info::click_to_open
1172f746eafSJohn Scipione
1182f746eafSJohn Scipione	Whether or not the menu opens on click. The default value is \c true.
11947852bffSJohn Scipione
12047852bffSJohn Scipione	\since BeOS R3
1212f746eafSJohn Scipione*/
1222f746eafSJohn Scipione
1232f746eafSJohn Scipione
1242f746eafSJohn Scipione/*!
1252f746eafSJohn Scipione	\var menu_info::triggers_always_shown
1262f746eafSJohn Scipione
1272f746eafSJohn Scipione	Whether or not trigger underlines should always be shown. The default value
1282f746eafSJohn Scipione	is \c false.
12947852bffSJohn Scipione
13047852bffSJohn Scipione	\since BeOS R3
1312f746eafSJohn Scipione*/
1322f746eafSJohn Scipione
1332f746eafSJohn Scipione
1342f746eafSJohn Scipione/*!
1352f746eafSJohn Scipione	\fn status_t get_menu_info(menu_info* info)
1362f746eafSJohn Scipione	\brief Fill out the menu_info struct into \a info.
13747852bffSJohn Scipione
13847852bffSJohn Scipione	\since BeOS R3
1392f746eafSJohn Scipione*/
1402f746eafSJohn Scipione
1412f746eafSJohn Scipione
1422f746eafSJohn Scipione/*!
1432f746eafSJohn Scipione	\fn status_t set_menu_info(menu_info* info)
1442f746eafSJohn Scipione	\brief Set the menu's menu_info struct to \a info adjusting how the menu
1452f746eafSJohn Scipione	       will look and work.
14647852bffSJohn Scipione
14747852bffSJohn Scipione	\since BeOS R3
1482f746eafSJohn Scipione*/
1492f746eafSJohn Scipione
1502f746eafSJohn Scipione
1512f746eafSJohn Scipione/*!
1522f746eafSJohn Scipione	\typedef bool (*menu_tracking_hook)(BMenu* menu, void* state)
1532f746eafSJohn Scipione	\brief Defines the function passed into BMenu::SetTrackingHook().
15447852bffSJohn Scipione
15547852bffSJohn Scipione	\since BeOS R3
1562f746eafSJohn Scipione*/
1572f746eafSJohn Scipione
1582f746eafSJohn Scipione
1592f746eafSJohn Scipione/*!
1602f746eafSJohn Scipione	\class BMenu
1612f746eafSJohn Scipione	\ingroup interface
1622f746eafSJohn Scipione	\ingroup libbe
1632f746eafSJohn Scipione	\brief Displays a list of menu items including additional menus
1642f746eafSJohn Scipione	       arranged hierarchically.
1652f746eafSJohn Scipione
1662f746eafSJohn Scipione	A newly created BMenu object doesn't contain any menu items, you need to call
1670d635255SJohn Scipione	AddItem() or AddList() to add some.
1682f746eafSJohn Scipione
1692f746eafSJohn Scipione	In addition to BMenuItem objects you can also add additional BMenu objects in
1702f746eafSJohn Scipione	order to create a menu hierarchy. Unlike menus in other operating systems you
1712f746eafSJohn Scipione	can always select both the submenu and menu items, although selecting the
1722f746eafSJohn Scipione	submenu might not actually produce any action other than to close the menu.
1732f746eafSJohn Scipione	The name of a submenu is used to draw its label.
1742f746eafSJohn Scipione
1752f746eafSJohn Scipione	\image html BMenu_example.png
1762f746eafSJohn Scipione
1772f746eafSJohn Scipione	BMenu is the basis of several other Interface Kit classes including BMenuBar
1782f746eafSJohn Scipione	and BPopUpMenu. See BMenu::SetRadioMode() and BMenu::SetLabelFromMarked()
1792f746eafSJohn Scipione	for additional details on how BMenu and BPopUpMenu are related.
1802f746eafSJohn Scipione
1812f746eafSJohn Scipione	Menus arrange their items in one of three possible layouts:
1822f746eafSJohn Scipione	<table>
1832f746eafSJohn Scipione		<tr>
1842f746eafSJohn Scipione			<td>\c B_ITEMS_IN_COLUMN</td>
1852f746eafSJohn Scipione			<td>
1862f746eafSJohn Scipione				The menu items are stacked vertically in a column, one on top
1872f746eafSJohn Scipione				of another, as in a typical pop-up menu.
1882f746eafSJohn Scipione			</td>
1892f746eafSJohn Scipione		</tr>
1902f746eafSJohn Scipione		<tr>
1912f746eafSJohn Scipione			<td>\c B_ITEMS_IN_ROW</td>
1922f746eafSJohn Scipione			<td>
1932f746eafSJohn Scipione				The menu items are laid out horizontally in a row, from end to
1942f746eafSJohn Scipione				end, as in a typical menu bar.
1952f746eafSJohn Scipione			</td>
1962f746eafSJohn Scipione		</tr>
1972f746eafSJohn Scipione		<tr>
1982f746eafSJohn Scipione			<td>\c B_ITEMS_IN_MATRIX</td>
1992f746eafSJohn Scipione			<td>
2002f746eafSJohn Scipione				The menu items are arranged in a free-form arrangement that you
2012f746eafSJohn Scipione				create, such as a matrix.
2022f746eafSJohn Scipione			</td>
2032f746eafSJohn Scipione		</tr>
2042f746eafSJohn Scipione	</table>
2052f746eafSJohn Scipione
2062f746eafSJohn Scipione	Either \c B_ITEMS_IN_COLUMN or \c B_ITEMS_IN_ROW can be passed into the
2072f746eafSJohn Scipione	default constructor, but, you should use the constructor that allows you to
2082f746eafSJohn Scipione	set the height and width of the menu in order to utilize the
2092f746eafSJohn Scipione	\c B_ITEMS_IN_MATRIX layout.
2102f746eafSJohn Scipione
2112f746eafSJohn Scipione	Several methods will only work in some layouts as noted in the method
2122f746eafSJohn Scipione	description below.
21347852bffSJohn Scipione
21447852bffSJohn Scipione	\since BeOS R3
2152f746eafSJohn Scipione*/
2162f746eafSJohn Scipione
2172f746eafSJohn Scipione
2182f746eafSJohn Scipione/*!
2192f746eafSJohn Scipione	\fn BMenu::BMenu(const char* name, menu_layout layout)
2202f746eafSJohn Scipione	\brief Creates a new menu object with the specified \a name and \a layout.
2212f746eafSJohn Scipione
2222f746eafSJohn Scipione	Don't pass \c B_ITEMS_IN_MATRIX into \a layout with this method, use
2232f746eafSJohn Scipione	BMenu::BMenu(const char* name, float width, float height) instead.
2242f746eafSJohn Scipione
2252f746eafSJohn Scipione	\param name The menu's \a name, serves as a label for submenus.
2262f746eafSJohn Scipione	\param layout The menu layout, possibilities include:
2272f746eafSJohn Scipione	       - \c B_ITEMS_IN_ROW items are displayed in a single row,
2282f746eafSJohn Scipione	       - \c B_ITEMS_IN_COLUMN items are displayed in a single column.
22947852bffSJohn Scipione
23047852bffSJohn Scipione	\since BeOS R3
2312f746eafSJohn Scipione*/
2322f746eafSJohn Scipione
2332f746eafSJohn Scipione
2342f746eafSJohn Scipione/*!
2352f746eafSJohn Scipione	\fn BMenu::BMenu(const char* name, float width, float height)
2362f746eafSJohn Scipione	\brief Creates a new menu object with a \c B_ITEMS_IN_MATRIX layout and the
2372f746eafSJohn Scipione	       specified \a name, \a width, and \a height.
2382f746eafSJohn Scipione
2392f746eafSJohn Scipione	\param name The menu's \a name, serves as a label for submenus.
2402f746eafSJohn Scipione	\param width The menu \a width.
2412f746eafSJohn Scipione	\param height The menu \a height.
24247852bffSJohn Scipione
24347852bffSJohn Scipione	\since BeOS R3
2442f746eafSJohn Scipione*/
2452f746eafSJohn Scipione
2462f746eafSJohn Scipione
2472f746eafSJohn Scipione/*!
2482f746eafSJohn Scipione	\fn BMenu::BMenu(BMessage* archive)
2492f746eafSJohn Scipione	\brief Archive constructor.
2502f746eafSJohn Scipione
2512f746eafSJohn Scipione	\param archive The message data to construct the menu from.
25247852bffSJohn Scipione
25347852bffSJohn Scipione	\since BeOS R3
2542f746eafSJohn Scipione*/
2552f746eafSJohn Scipione
2562f746eafSJohn Scipione
2572f746eafSJohn Scipione/*!
2582f746eafSJohn Scipione	\fn BMenu::~BMenu()
2592f746eafSJohn Scipione	\brief Destructor.
2602f746eafSJohn Scipione
2610d635255SJohn Scipione	Also frees the memory used by any attached menu items and submenus.
26247852bffSJohn Scipione
26347852bffSJohn Scipione	\since BeOS R3
2642f746eafSJohn Scipione*/
2652f746eafSJohn Scipione
2662f746eafSJohn Scipione
2672f746eafSJohn Scipione/*!
26847852bffSJohn Scipione	\name Archiving
26947852bffSJohn Scipione*/
27047852bffSJohn Scipione
27147852bffSJohn Scipione
27247852bffSJohn Scipione//! @{
27347852bffSJohn Scipione
27447852bffSJohn Scipione
27547852bffSJohn Scipione/*!
2762f746eafSJohn Scipione	\fn BArchivable* BMenu::Instantiate(BMessage* archive)
2772f746eafSJohn Scipione	\brief Creates a new BMenu object from an \a archive message.
2782f746eafSJohn Scipione
2792f746eafSJohn Scipione	\returns A newly created BMenu object or \c NULL if the message doesn't
2802f746eafSJohn Scipione	         contain an archived BMenu.
28147852bffSJohn Scipione
28247852bffSJohn Scipione	\since BeOS R3
2832f746eafSJohn Scipione*/
2842f746eafSJohn Scipione
2852f746eafSJohn Scipione
2862f746eafSJohn Scipione/*!
2870d635255SJohn Scipione	\fn status_t BMenu::Archive(BMessage* data, bool deep) const
2880d635255SJohn Scipione	\brief Archives the the BMenu object into the \a data message.
2890d635255SJohn Scipione
2900d635255SJohn Scipione	\param data A pointer to the BMessage to archive the object into.
2910d635255SJohn Scipione	\param deep Whether or not to archive attached menu items as well.
2920d635255SJohn Scipione
2930d635255SJohn Scipione	\return A status code, \c B_OK if everything went well or an error code
2940d635255SJohn Scipione	        otherwise.
2950d635255SJohn Scipione	\retval B_OK The object was archived successfully.
2960d635255SJohn Scipione	\retval B_NO_MEMORY Ran out of memory while archiving the object.
29747852bffSJohn Scipione
29847852bffSJohn Scipione	\since BeOS R3
2990d635255SJohn Scipione*/
3000d635255SJohn Scipione
3010d635255SJohn Scipione
30247852bffSJohn Scipione//! @}
30347852bffSJohn Scipione
30447852bffSJohn Scipione
30547852bffSJohn Scipione/*!
30647852bffSJohn Scipione	\name Hook Methods
30747852bffSJohn Scipione*/
30847852bffSJohn Scipione
30947852bffSJohn Scipione
31047852bffSJohn Scipione//! @{
31147852bffSJohn Scipione
31247852bffSJohn Scipione
3130d635255SJohn Scipione/*!
3142f746eafSJohn Scipione	\fn void BMenu::AttachedToWindow()
3152f746eafSJohn Scipione	\brief Lays out the menu items and resizes the menu to fit.
31647852bffSJohn Scipione
31747852bffSJohn Scipione	\since BeOS R3
3182f746eafSJohn Scipione*/
3192f746eafSJohn Scipione
3202f746eafSJohn Scipione
3212f746eafSJohn Scipione/*!
3222f746eafSJohn Scipione	\fn void BMenu::Draw(BRect updateRect)
3232f746eafSJohn Scipione	\brief Draws the menu.
3242f746eafSJohn Scipione
3252f746eafSJohn Scipione	\param updateRect The area to draw in.
32647852bffSJohn Scipione
32747852bffSJohn Scipione	\since BeOS R3
3282f746eafSJohn Scipione*/
3292f746eafSJohn Scipione
3302f746eafSJohn Scipione
3312f746eafSJohn Scipione/*!
3322f746eafSJohn Scipione	\fn void BMenu::MessageReceived(BMessage* message)
3332f746eafSJohn Scipione	\brief Handles a \a message received by the associated looper.
3342f746eafSJohn Scipione
3352f746eafSJohn Scipione	Responds to mouse wheel events scrolling the menu if it is too
3362f746eafSJohn Scipione	long to fit in the window. Hold \c B_SHIFT_KEY to cause the menu
3372f746eafSJohn Scipione	to scroll faster.
3382f746eafSJohn Scipione
3392f746eafSJohn Scipione	\param message The \a message received by the associated looper.
34047852bffSJohn Scipione
34147852bffSJohn Scipione	\since BeOS R3
3422f746eafSJohn Scipione*/
3432f746eafSJohn Scipione
3442f746eafSJohn Scipione
3452f746eafSJohn Scipione/*!
3462f746eafSJohn Scipione	\fn void BMenu::KeyDown(const char* bytes, int32 numBytes)
3472f746eafSJohn Scipione	\brief Hook method that is called when a keyboard key is pressed.
3482f746eafSJohn Scipione
3492f746eafSJohn Scipione	Handles keyboard navigation and triggers.
3502f746eafSJohn Scipione
3512f746eafSJohn Scipione	\param bytes The bytes of the key combination pressed.
3522f746eafSJohn Scipione	\param numBytes The number of bytes in \a bytes.
35347852bffSJohn Scipione
35447852bffSJohn Scipione	\since BeOS R3
3552f746eafSJohn Scipione*/
3562f746eafSJohn Scipione
3572f746eafSJohn Scipione
35847852bffSJohn Scipione//! @}
35947852bffSJohn Scipione
36047852bffSJohn Scipione
3612f746eafSJohn Scipione/*!
3622f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenuItem* item)
3632f746eafSJohn Scipione	\brief Adds a menu \a item to the end of the list.
3642f746eafSJohn Scipione
3652f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
3662f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
3672f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
3682f746eafSJohn Scipione
3692f746eafSJohn Scipione	\param item The menu \a item to add.
3702f746eafSJohn Scipione
3712f746eafSJohn Scipione	\return Whether or not the \a item was added to the menu.
37247852bffSJohn Scipione
37347852bffSJohn Scipione	\since BeOS R3
3742f746eafSJohn Scipione*/
3752f746eafSJohn Scipione
3762f746eafSJohn Scipione
3772f746eafSJohn Scipione/*!
3782f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenuItem* item, int32 index)
3792f746eafSJohn Scipione	\brief Adds a menu \a item at the specified \a index.
3802f746eafSJohn Scipione
3812f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
3822f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
3832f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
3842f746eafSJohn Scipione
3852f746eafSJohn Scipione	\param item The menu \a item to add.
3862f746eafSJohn Scipione	\param index The \a index where to add the \a item to the menu.
3872f746eafSJohn Scipione
3882f746eafSJohn Scipione	\return Whether or not the \a item was added to the menu.
38947852bffSJohn Scipione
39047852bffSJohn Scipione	\since BeOS R3
3912f746eafSJohn Scipione*/
3922f746eafSJohn Scipione
3932f746eafSJohn Scipione
3942f746eafSJohn Scipione/*!
3952f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenuItem* item, BRect frame)
3962f746eafSJohn Scipione	\brief Adds a menu \a item in the specified \a frame rectangle within the menu.
3972f746eafSJohn Scipione
3982f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_MATRIX
3992f746eafSJohn Scipione	         layout, it is an error to use this method for a menu in
4002f746eafSJohn Scipione	         \c B_ITEMS_IN_COLUMN or \c B_ITEMS_IN_ROW layout.
4012f746eafSJohn Scipione
4022f746eafSJohn Scipione	\param item The menu \a item to add.
4032f746eafSJohn Scipione	\param frame The \a frame rectangle where to add the \a item to the menu.
4042f746eafSJohn Scipione
4052f746eafSJohn Scipione	\return Whether or not the \a item was added to the menu.
40647852bffSJohn Scipione
40747852bffSJohn Scipione	\since BeOS R3
4082f746eafSJohn Scipione*/
4092f746eafSJohn Scipione
4102f746eafSJohn Scipione
4112f746eafSJohn Scipione/*!
4122f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenu* submenu)
4132f746eafSJohn Scipione	\brief Add a \a submenu to the end of the list.
4142f746eafSJohn Scipione
4152f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
4162f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
4172f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
4182f746eafSJohn Scipione
4192f746eafSJohn Scipione	\param submenu The submenu to add.
4202f746eafSJohn Scipione
4212f746eafSJohn Scipione	\return Whether or not the \a submenu was added to the menu.
42247852bffSJohn Scipione
42347852bffSJohn Scipione	\since BeOS R3
4242f746eafSJohn Scipione*/
4252f746eafSJohn Scipione
4262f746eafSJohn Scipione
4272f746eafSJohn Scipione/*!
4282f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenu* submenu, int32 index)
4292f746eafSJohn Scipione	\brief Add a \a submenu at the specified \a index.
4302f746eafSJohn Scipione
4312f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
4322f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
4332f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
4342f746eafSJohn Scipione
4352f746eafSJohn Scipione	\param submenu The \a submenu to add.
4362f746eafSJohn Scipione	\param index The \a index where to add the \a submenu to the menu.
4372f746eafSJohn Scipione
4382f746eafSJohn Scipione	\return Whether or not the \a submenu was added to the menu.
43947852bffSJohn Scipione
44047852bffSJohn Scipione	\since BeOS R3
4412f746eafSJohn Scipione*/
4422f746eafSJohn Scipione
4432f746eafSJohn Scipione
4442f746eafSJohn Scipione/*!
4452f746eafSJohn Scipione	\fn bool BMenu::AddItem(BMenu* submenu, BRect frame)
4462f746eafSJohn Scipione	\brief Adds a \a submenu in the specified \a frame rectangle within the
4472f746eafSJohn Scipione	       menu.
4482f746eafSJohn Scipione
4492f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_MATRIX
4502f746eafSJohn Scipione	         layout, it is an error to use this method for a menu in
4512f746eafSJohn Scipione	         \c B_ITEMS_IN_COLUMN or \c B_ITEMS_IN_ROW layout.
4522f746eafSJohn Scipione
4532f746eafSJohn Scipione	\param submenu The submenu to add.
4542f746eafSJohn Scipione	\param frame The \a frame rectangle where to add the submenu to the menu.
4552f746eafSJohn Scipione
4562f746eafSJohn Scipione	\return Whether or not the \a submenu was added to the menu.
45747852bffSJohn Scipione
45847852bffSJohn Scipione	\since BeOS R3
4592f746eafSJohn Scipione*/
4602f746eafSJohn Scipione
4612f746eafSJohn Scipione
4622f746eafSJohn Scipione/*!
4632f746eafSJohn Scipione	\fn bool BMenu::AddList(BList* list, int32 index)
4642f746eafSJohn Scipione	\brief Add a \a list of menu items at the specified \a index.
4652f746eafSJohn Scipione
4662f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
4672f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
4682f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
4692f746eafSJohn Scipione
4702f746eafSJohn Scipione	\param list The \a list of menu items to add.
4712f746eafSJohn Scipione	\param index The \a index where to add the \a list to the menu.
4722f746eafSJohn Scipione
4732f746eafSJohn Scipione	\return Whether or not the \a list of menu items was added to the menu.
47447852bffSJohn Scipione
47547852bffSJohn Scipione	\since BeOS R3
4762f746eafSJohn Scipione*/
4772f746eafSJohn Scipione
4782f746eafSJohn Scipione
4792f746eafSJohn Scipione/*!
4802f746eafSJohn Scipione	\fn bool BMenu::AddSeparatorItem()
4812f746eafSJohn Scipione	\brief Adds a separator item to the end of the menu.
4822f746eafSJohn Scipione
4832f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
4842f746eafSJohn Scipione	         layout, it is an error to use this method for a menu in
4852f746eafSJohn Scipione	         \c B_ITEMS_IN_ROW or \c B_ITEMS_IN_MATRIX layout.
4862f746eafSJohn Scipione
4872f746eafSJohn Scipione	\return Whether or not the separator item was added to the menu.
48847852bffSJohn Scipione
48947852bffSJohn Scipione	\since BeOS R3
4902f746eafSJohn Scipione*/
4912f746eafSJohn Scipione
4922f746eafSJohn Scipione
4932f746eafSJohn Scipione/*!
4942f746eafSJohn Scipione	\fn bool BMenu::RemoveItem(BMenuItem* item)
4952f746eafSJohn Scipione	\brief Remove and delete the specified \a item from the menu.
4962f746eafSJohn Scipione
4972f746eafSJohn Scipione	\return Whether or not the \a item was removed from the menu.
49847852bffSJohn Scipione
49947852bffSJohn Scipione	\since BeOS R3
5002f746eafSJohn Scipione*/
5012f746eafSJohn Scipione
5022f746eafSJohn Scipione
5032f746eafSJohn Scipione/*!
5042f746eafSJohn Scipione	\fn BMenuItem* BMenu::RemoveItem(int32 index)
5052f746eafSJohn Scipione	\brief Remove the item at the specified \a index from the menu.
5062f746eafSJohn Scipione
5072f746eafSJohn Scipione	The menu item object is not deleted.
5082f746eafSJohn Scipione
5092f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
5102f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
5112f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
5122f746eafSJohn Scipione
5132f746eafSJohn Scipione	\param index The \a index of where to remove the menu item.
5142f746eafSJohn Scipione
5152f746eafSJohn Scipione	\return The menu item object or \c NULL if not found.
51647852bffSJohn Scipione
51747852bffSJohn Scipione	\since BeOS R3
5182f746eafSJohn Scipione*/
5192f746eafSJohn Scipione
5202f746eafSJohn Scipione
5212f746eafSJohn Scipione/*!
5222f746eafSJohn Scipione	\fn bool BMenu::RemoveItems(int32 index, int32 count, bool deleteItems)
5232f746eafSJohn Scipione	\brief Remove \a count number of items from the menu starting at the specified
5242f746eafSJohn Scipione	       \a index and delete them if \a deleteItems is \c true.
5252f746eafSJohn Scipione
5262f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
5272f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
5282f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
5292f746eafSJohn Scipione
5302f746eafSJohn Scipione	\param index The \a index of where to start removing menu items.
5312f746eafSJohn Scipione	\param count The number of items to remove.
5322f746eafSJohn Scipione	\param deleteItems Whether or not to delete the items after removing them.
5332f746eafSJohn Scipione
5342f746eafSJohn Scipione	\return Whether or not the items were removed from the menu.
53547852bffSJohn Scipione
53647852bffSJohn Scipione	\since BeOS R3
5372f746eafSJohn Scipione*/
5382f746eafSJohn Scipione
5392f746eafSJohn Scipione
5402f746eafSJohn Scipione/*!
5412f746eafSJohn Scipione	\fn bool BMenu::RemoveItem(BMenu* submenu)
5422f746eafSJohn Scipione	\brief Remove and delete a \a submenu from the menu.
5432f746eafSJohn Scipione
5442f746eafSJohn Scipione	\param submenu The submenu to remove.
5452f746eafSJohn Scipione
5462f746eafSJohn Scipione	\return Whether or not the \a submenu was removed from the menu.
54747852bffSJohn Scipione
54847852bffSJohn Scipione	\since BeOS R3
5492f746eafSJohn Scipione*/
5502f746eafSJohn Scipione
5512f746eafSJohn Scipione
5522f746eafSJohn Scipione/*!
5532f746eafSJohn Scipione	\fn int32 BMenu::CountItems() const
5542f746eafSJohn Scipione	\brief Returns the number of items added to the menu.
5552f746eafSJohn Scipione
5562f746eafSJohn Scipione	\return The number of items added to the menu.
55747852bffSJohn Scipione
55847852bffSJohn Scipione	\since BeOS R3
5592f746eafSJohn Scipione*/
5602f746eafSJohn Scipione
5612f746eafSJohn Scipione
5622f746eafSJohn Scipione/*!
5632f746eafSJohn Scipione	\fn BMenuItem* BMenu::ItemAt(int32 index) const
5642f746eafSJohn Scipione	\brief Returns a pointer to the menu item at the specified \a index.
5652f746eafSJohn Scipione
5662f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
5672f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
5682f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
5692f746eafSJohn Scipione
5702f746eafSJohn Scipione	\return A pointer to a menu item or \c NULL if not found.
57147852bffSJohn Scipione
57247852bffSJohn Scipione	\since BeOS R3
5732f746eafSJohn Scipione*/
5742f746eafSJohn Scipione
5752f746eafSJohn Scipione
5762f746eafSJohn Scipione/*!
5772f746eafSJohn Scipione	\fn BMenu* BMenu::SubmenuAt(int32 index) const
5782f746eafSJohn Scipione	\brief Returns a pointer to a submenu at the specified \a index.
5792f746eafSJohn Scipione
5802f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
5812f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for a
5822f746eafSJohn Scipione	         menu in \c B_ITEMS_IN_MATRIX layout.
5832f746eafSJohn Scipione
5842f746eafSJohn Scipione	\return A pointer to a submenu or \c NULL if not found.
58547852bffSJohn Scipione
58647852bffSJohn Scipione	\since BeOS R3
5872f746eafSJohn Scipione*/
5882f746eafSJohn Scipione
5892f746eafSJohn Scipione
5902f746eafSJohn Scipione/*!
5912f746eafSJohn Scipione	\fn int32 BMenu::IndexOf(BMenuItem* item) const
5922f746eafSJohn Scipione	\brief Returns the index of the specified menu \a item.
5932f746eafSJohn Scipione
5942f746eafSJohn Scipione	The index starts at the left for a menu in \c B_ITEMS_IN_COLUMN layout going
5952f746eafSJohn Scipione	right or start at the top for a menu in \c B_ITEMS_IN_ROW layout going down.
5962f746eafSJohn Scipione
5972f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
5982f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
5992f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
6002f746eafSJohn Scipione
6012f746eafSJohn Scipione	\return The index of the menu \a item or \c B_ERROR of not found.
60247852bffSJohn Scipione
60347852bffSJohn Scipione	\since BeOS R3
6042f746eafSJohn Scipione*/
6052f746eafSJohn Scipione
6062f746eafSJohn Scipione
6072f746eafSJohn Scipione/*!
6082f746eafSJohn Scipione	\fn int32 BMenu::IndexOf(BMenu* submenu) const
6092f746eafSJohn Scipione	\brief Returns the index of the specified \a submenu.
6102f746eafSJohn Scipione
6112f746eafSJohn Scipione	The index starts at the left for a menu in \c B_ITEMS_IN_COLUMN layout going
6122f746eafSJohn Scipione	right or at the top for a menu in \c B_ITEMS_IN_ROW layout going down.
6132f746eafSJohn Scipione
6142f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
6152f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
6162f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
6172f746eafSJohn Scipione
6182f746eafSJohn Scipione	\return The index of the \a submenu or \c B_ERROR of not found.
61947852bffSJohn Scipione
62047852bffSJohn Scipione	\since BeOS R3
6212f746eafSJohn Scipione*/
6222f746eafSJohn Scipione
6232f746eafSJohn Scipione
6242f746eafSJohn Scipione/*!
6252f746eafSJohn Scipione	\fn BMenuItem* BMenu::FindItem(const char* label) const
6262f746eafSJohn Scipione	\brief Returns a pointer to the menu item with the specified \a label.
6272f746eafSJohn Scipione
6282f746eafSJohn Scipione	\param label The \a label of the menu item to find.
6292f746eafSJohn Scipione
6302f746eafSJohn Scipione	\return A pointer to a menu item or \c NULL if not found.
63147852bffSJohn Scipione
63247852bffSJohn Scipione	\since BeOS R3
6332f746eafSJohn Scipione*/
6342f746eafSJohn Scipione
6352f746eafSJohn Scipione
6362f746eafSJohn Scipione/*!
6372f746eafSJohn Scipione	\fn BMenuItem* BMenu::FindItem(uint32 command) const
6382f746eafSJohn Scipione	\brief Returns a pointer to the menu item with the specified \a command for
6392f746eafSJohn Scipione	       its associated message.
6402f746eafSJohn Scipione
6412f746eafSJohn Scipione	\param command The \a command of the associated message of the menu item to
6422f746eafSJohn Scipione	       find.
6432f746eafSJohn Scipione
6442f746eafSJohn Scipione	\return A pointer to a menu item or \c NULL if not found.
64547852bffSJohn Scipione
64647852bffSJohn Scipione	\since BeOS R3
6472f746eafSJohn Scipione*/
6482f746eafSJohn Scipione
6492f746eafSJohn Scipione
6502f746eafSJohn Scipione/*!
6512f746eafSJohn Scipione	\fn status_t BMenu::SetTargetForItems(BHandler* handler)
6522f746eafSJohn Scipione	\brief Set the target to \a handler for each item in the menu.
6532f746eafSJohn Scipione
6542f746eafSJohn Scipione	This is a convenient way to set the target for all the items in a menu.
6552f746eafSJohn Scipione
6562f746eafSJohn Scipione	\param handler The BHandler object to set the target of the menu item to.
6572f746eafSJohn Scipione
6582f746eafSJohn Scipione	This method doesn't descend into submenus recursively and only acts on items
6592f746eafSJohn Scipione	that have already been added to the menu.
6602f746eafSJohn Scipione
6612f746eafSJohn Scipione	\return \c B_OK on success or an error code on error.
66247852bffSJohn Scipione
66347852bffSJohn Scipione	\since BeOS R3
6642f746eafSJohn Scipione*/
6652f746eafSJohn Scipione
6662f746eafSJohn Scipione
6672f746eafSJohn Scipione/*!
6682f746eafSJohn Scipione	\fn status_t BMenu::SetTargetForItems(BMessenger messenger)
6692f746eafSJohn Scipione	\brief Set the target to \a messenger for each item in the menu.
6702f746eafSJohn Scipione
6712f746eafSJohn Scipione	This is a convenient way to set the target for all the items in a menu.
6722f746eafSJohn Scipione
6732f746eafSJohn Scipione	This method doesn't descend into submenus recursively and only acts on items
6742f746eafSJohn Scipione	that have already been added to the menu.
6752f746eafSJohn Scipione
6762f746eafSJohn Scipione	\param messenger The BMessenger object to set the target of the menu item
6772f746eafSJohn Scipione	                 to.
6782f746eafSJohn Scipione
6792f746eafSJohn Scipione	\return \c B_OK on success or an error code on error.
68047852bffSJohn Scipione
68147852bffSJohn Scipione	\since BeOS R3
6822f746eafSJohn Scipione*/
6832f746eafSJohn Scipione
6842f746eafSJohn Scipione
6852f746eafSJohn Scipione/*!
6862f746eafSJohn Scipione	\fn void BMenu::SetEnabled(bool enable)
6872f746eafSJohn Scipione	\brief Enables or disables the menu.
6882f746eafSJohn Scipione
6892f746eafSJohn Scipione	\param enable \c true to enable, \c false to disable.
69047852bffSJohn Scipione
69147852bffSJohn Scipione	\since BeOS R3
6922f746eafSJohn Scipione*/
6932f746eafSJohn Scipione
6942f746eafSJohn Scipione
6952f746eafSJohn Scipione/*!
6962f746eafSJohn Scipione	\fn void BMenu::SetRadioMode(bool on)
6972f746eafSJohn Scipione	\brief Turns radio mode on or off.
6982f746eafSJohn Scipione
69924be9ac7SJohn Scipione	Turning radio mode off also turns off label-from-marked mode.
70024be9ac7SJohn Scipione
70124be9ac7SJohn Scipione	Radio mode means that only one menu item can be set as marked at a time.
70224be9ac7SJohn Scipione	Marking a menu item automatically unmarks all other menu items and draws
70324be9ac7SJohn Scipione	a check mark on the left side of the marked menu item. You don't have to
70424be9ac7SJohn Scipione	call BMenuItem::SetMarked() yourself for a menu in radio mode, this is done
70524be9ac7SJohn Scipione	for you automatically.
70624be9ac7SJohn Scipione
70724be9ac7SJohn Scipione	Radio mode does not work recursively, only the current menu is considered.
70824be9ac7SJohn Scipione	If you want to make a menu work in radio mode recursively you'll have to
70924be9ac7SJohn Scipione	turn radio mode off and iterate through each menu marking and unmarking
71024be9ac7SJohn Scipione	the items yourself.
7112f746eafSJohn Scipione
7122f746eafSJohn Scipione	\param on \c true to turn radio mode on, \c false to turn it off.
71347852bffSJohn Scipione
71447852bffSJohn Scipione	\since BeOS R3
7152f746eafSJohn Scipione*/
7162f746eafSJohn Scipione
7172f746eafSJohn Scipione
7182f746eafSJohn Scipione/*!
7192f746eafSJohn Scipione	\fn void BMenu::SetTriggersEnabled(bool enable)
7202f746eafSJohn Scipione	\brief Enables or disables triggers.
7212f746eafSJohn Scipione
7222f746eafSJohn Scipione	\param enable \c true to enable triggers, \c false to disable triggers.
72347852bffSJohn Scipione
72447852bffSJohn Scipione	\since BeOS R3
7252f746eafSJohn Scipione*/
7262f746eafSJohn Scipione
7272f746eafSJohn Scipione
7282f746eafSJohn Scipione/*!
7292f746eafSJohn Scipione	\fn void BMenu::SetMaxContentWidth(float width)
7302f746eafSJohn Scipione	\brief Sets the maximum width of the menu items' content area.
7312f746eafSJohn Scipione
7322f746eafSJohn Scipione	This is the maximum width that a menu item can draw in. Note that menu
7332f746eafSJohn Scipione	items have built-in margins on the left and right sides that are not
7342f746eafSJohn Scipione	included as part of the maximum content width.
7352f746eafSJohn Scipione
7362f746eafSJohn Scipione	\param width The maximum width for the menu item contents to draw in.
73747852bffSJohn Scipione
73847852bffSJohn Scipione	\since BeOS R3
7392f746eafSJohn Scipione*/
7402f746eafSJohn Scipione
7412f746eafSJohn Scipione
7422f746eafSJohn Scipione/*!
7432f746eafSJohn Scipione	\fn void BMenu::SetLabelFromMarked(bool on)
7442f746eafSJohn Scipione	\brief Sets whether or not the label of the menu is set according to the
7452f746eafSJohn Scipione	       marked item.
7462f746eafSJohn Scipione
7472f746eafSJohn Scipione	Turning label-from-marked mode on also turns radio mode on.
7482f746eafSJohn Scipione
7492f746eafSJohn Scipione	\param on \c true to turn label-from-marked mode on, \c false to turn it
7502f746eafSJohn Scipione	          off.
75147852bffSJohn Scipione
75247852bffSJohn Scipione	\since BeOS R3
7532f746eafSJohn Scipione*/
7542f746eafSJohn Scipione
7552f746eafSJohn Scipione
7562f746eafSJohn Scipione/*!
7572f746eafSJohn Scipione	\fn bool BMenu::IsLabelFromMarked()
7582f746eafSJohn Scipione	\brief Returns whether or not the menu is in label-from-marked mode.
7592f746eafSJohn Scipione
7602f746eafSJohn Scipione	\return \c true if menu is in label-from-marked mode, \c false if not.
76147852bffSJohn Scipione
76247852bffSJohn Scipione	\since BeOS R3
7632f746eafSJohn Scipione*/
7642f746eafSJohn Scipione
7652f746eafSJohn Scipione
7662f746eafSJohn Scipione/*!
7672f746eafSJohn Scipione	\fn bool BMenu::IsEnabled() const
7682f746eafSJohn Scipione	\brief Returns whether or not the menu is enabled.
7692f746eafSJohn Scipione
7702f746eafSJohn Scipione	\return \c true if menu is enabled, \c false if it is disabled.
77147852bffSJohn Scipione
77247852bffSJohn Scipione	\since BeOS R3
7732f746eafSJohn Scipione*/
7742f746eafSJohn Scipione
7752f746eafSJohn Scipione
7762f746eafSJohn Scipione/*!
7772f746eafSJohn Scipione	\fn bool BMenu::IsRadioMode() const
7782f746eafSJohn Scipione	\brief Returns whether or not the menu is in radio mode.
7792f746eafSJohn Scipione
7802f746eafSJohn Scipione	\return \c true if menu is in radio mode, \c false if not.
78147852bffSJohn Scipione
78247852bffSJohn Scipione	\since BeOS R3
7832f746eafSJohn Scipione*/
7842f746eafSJohn Scipione
7852f746eafSJohn Scipione
7862f746eafSJohn Scipione/*!
7872f746eafSJohn Scipione	\fn bool BMenu::AreTriggersEnabled() const
7882f746eafSJohn Scipione	\brief Returns whether or not triggers are enabled.
7892f746eafSJohn Scipione
7902f746eafSJohn Scipione	\return \c true if triggers are enabled, \c false if triggers are disabled.
79147852bffSJohn Scipione
79247852bffSJohn Scipione	\since BeOS R3
7932f746eafSJohn Scipione*/
7942f746eafSJohn Scipione
7952f746eafSJohn Scipione
7962f746eafSJohn Scipione/*!
7972f746eafSJohn Scipione	\fn bool BMenu::IsRedrawAfterSticky() const
7982f746eafSJohn Scipione	\brief Returns whether or not the menu is in redraw-after-sticky mode.
7992f746eafSJohn Scipione
8002f746eafSJohn Scipione	\return \c true if menu is in redraw-after-sticky mode, \c false if not.
80147852bffSJohn Scipione
80247852bffSJohn Scipione	\since Haiku R1
8032f746eafSJohn Scipione*/
8042f746eafSJohn Scipione
8052f746eafSJohn Scipione
8062f746eafSJohn Scipione/*!
8072f746eafSJohn Scipione	\fn float BMenu::MaxContentWidth() const
8082f746eafSJohn Scipione	\brief Return the maximum width of the menu items' content area.
8092f746eafSJohn Scipione
8102f746eafSJohn Scipione	\return The maximum width of the menu items' content area as a float.
81147852bffSJohn Scipione
81247852bffSJohn Scipione	\sa SetMaxContentWidth()
81347852bffSJohn Scipione
81447852bffSJohn Scipione	\since BeOS R3
8152f746eafSJohn Scipione*/
8162f746eafSJohn Scipione
8172f746eafSJohn Scipione
8182f746eafSJohn Scipione/*!
8192f746eafSJohn Scipione	\fn BMenuItem* BMenu::FindMarked()
8202f746eafSJohn Scipione	\brief Return a pointer to the first marked menu item.
8212f746eafSJohn Scipione
8222f746eafSJohn Scipione	The index starts at the left for a menu in \c B_ITEMS_IN_COLUMN layout going
8232f746eafSJohn Scipione	right or at the top for a menu in \c B_ITEMS_IN_ROW layout going down.
8242f746eafSJohn Scipione
8252f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
8262f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
8272f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
8282f746eafSJohn Scipione
8292f746eafSJohn Scipione	\return A pointer to the first marked menu item or \c NULL if not found.
83047852bffSJohn Scipione
83147852bffSJohn Scipione	\since BeOS R3
8322f746eafSJohn Scipione*/
8332f746eafSJohn Scipione
8342f746eafSJohn Scipione
8352f746eafSJohn Scipione/*!
8362f746eafSJohn Scipione	\fn int32 BMenu::FindMarkedIndex()
8372f746eafSJohn Scipione	\brief Return the index of the first marked menu item.
8382f746eafSJohn Scipione
8392f746eafSJohn Scipione	The index starts at the left for a menu in \c B_ITEMS_IN_COLUMN layout going
8402f746eafSJohn Scipione	right or at the top for a menu in \c B_ITEMS_IN_ROW layout going down.
8412f746eafSJohn Scipione
8422f746eafSJohn Scipione	\warning This method should only be used for a menu in \c B_ITEMS_IN_COLUMN
8432f746eafSJohn Scipione	         or \c B_ITEMS_IN_ROW layout, it is an error to use this method for
8442f746eafSJohn Scipione	         a menu in \c B_ITEMS_IN_MATRIX layout.
8452f746eafSJohn Scipione
8462f746eafSJohn Scipione	\return The index of the first marked menu item or -1 if not found.
84747852bffSJohn Scipione
84847852bffSJohn Scipione	\since Haiku R1
8492f746eafSJohn Scipione*/
8502f746eafSJohn Scipione
8512f746eafSJohn Scipione
8522f746eafSJohn Scipione/*!
8532f746eafSJohn Scipione	\fn BMenu* BMenu::Supermenu() const
8542f746eafSJohn Scipione	\brief Returns the pointer to the menu that this menu it attached to.
8552f746eafSJohn Scipione
8562f746eafSJohn Scipione	\return A pointer to a BMenu object or \c NULL if not found.
85747852bffSJohn Scipione
85847852bffSJohn Scipione	\since BeOS R3
8592f746eafSJohn Scipione*/
8602f746eafSJohn Scipione
8612f746eafSJohn Scipione
8622f746eafSJohn Scipione/*!
8632f746eafSJohn Scipione	\fn BMenuItem* BMenu::Superitem() const
8642f746eafSJohn Scipione	\brief Returns the pointer to the menu item that this menu it attached to.
8652f746eafSJohn Scipione
8662f746eafSJohn Scipione	\return A pointer to a BMenuItem object or \c NULL if not found.
86747852bffSJohn Scipione
86847852bffSJohn Scipione	\since BeOS R3
8692f746eafSJohn Scipione*/
8702f746eafSJohn Scipione
8712f746eafSJohn Scipione
8722f746eafSJohn Scipione/*!
8732f746eafSJohn Scipione	\fn BMenu::BMenu(BRect frame, const char* name, uint32 resizingMode,
8742f746eafSJohn Scipione		uint32 flags, menu_layout layout, bool resizeToFit)
8752f746eafSJohn Scipione	\brief Implemented by derived classes to create a new menu object.
8762f746eafSJohn Scipione
8772f746eafSJohn Scipione	This method is intended to be used by derived classes that don't simply wish
8782f746eafSJohn Scipione	to utilize different sorts of menu items or arrange them in a different way,
8790d635255SJohn Scipione	but wish to invent a different kind of menu altogether.
8802f746eafSJohn Scipione
8810d635255SJohn Scipione	If the \a layout is set to \c B_ITEMS_IN_MATRIX the \a resizeToFit flag should
8820d635255SJohn Scipione	be set to \c false.
8830d635255SJohn Scipione
8840d635255SJohn Scipione	\param frame The \a frame rectangle to create the menu in.
8852f746eafSJohn Scipione	\param name The menu's \a name, serves as a label for submenus.
8862f746eafSJohn Scipione	\param resizingMode The resizing mode flags, see BView for more details.
8872f746eafSJohn Scipione	\param flags The view \a flags, see BView for more details.
8882f746eafSJohn Scipione	\param layout The menu layout, possibilities include:
8892f746eafSJohn Scipione	       - \c B_ITEMS_IN_ROW items are displayed in a single row,
8902f746eafSJohn Scipione	       - \c B_ITEMS_IN_COLUMN items are displayed in a single column,
8912f746eafSJohn Scipione	       - \c B_ITEMS_IN_MATRIX items are displayed in a custom matrix.
8922f746eafSJohn Scipione	\param resizeToFit Whether or not the menu should automatically resize
8932f746eafSJohn Scipione	       itself to fit its contents, this will not work in
8942f746eafSJohn Scipione	       \c B_ITEMS_IN_MATRIX layout.
89547852bffSJohn Scipione
89647852bffSJohn Scipione	\since BeOS R3
8972f746eafSJohn Scipione*/
8982f746eafSJohn Scipione
8992f746eafSJohn Scipione
9002f746eafSJohn Scipione/*!
9012f746eafSJohn Scipione	\fn void BMenu::SetItemMargins(float left, float top, float right,
9022f746eafSJohn Scipione		float bottom)
9032f746eafSJohn Scipione	\brief Set the menu item margins.
9042f746eafSJohn Scipione
9052f746eafSJohn Scipione	\param left The left margin to set.
9062f746eafSJohn Scipione	\param top The top margin to set.
9072f746eafSJohn Scipione	\param right The right margin to set.
9082f746eafSJohn Scipione	\param bottom The bottom margin to set.
90947852bffSJohn Scipione
91047852bffSJohn Scipione	\since BeOS R3
9112f746eafSJohn Scipione*/
9122f746eafSJohn Scipione
9132f746eafSJohn Scipione
9142f746eafSJohn Scipione/*!
9152f746eafSJohn Scipione	\fn void BMenu::GetItemMargins(float* _left, float* _top, float* _right,
9162f746eafSJohn Scipione		float* _bottom) const
9172f746eafSJohn Scipione	\brief Fill out the margins into the passed in float pointers.
9182f746eafSJohn Scipione
9192f746eafSJohn Scipione	\param _left The left margin to fill out, can be \c NULL.
9202f746eafSJohn Scipione	\param _top The top margin to fill out, can be \c NULL.
9212f746eafSJohn Scipione	\param _right The right margin to fill out, can be \c NULL.
9222f746eafSJohn Scipione	\param _bottom The bottom margin to fill out, can be \c NULL.
92347852bffSJohn Scipione
92447852bffSJohn Scipione	\since BeOS R3
9252f746eafSJohn Scipione*/
9262f746eafSJohn Scipione
9272f746eafSJohn Scipione
9282f746eafSJohn Scipione/*!
9292f746eafSJohn Scipione	\fn menu_layout BMenu::Layout() const
9302f746eafSJohn Scipione	\brief Returns the current menu_layout constant.
93147852bffSJohn Scipione
93247852bffSJohn Scipione	\since BeOS R3
9332f746eafSJohn Scipione*/
9342f746eafSJohn Scipione
9352f746eafSJohn Scipione
9362f746eafSJohn Scipione/*!
9372f746eafSJohn Scipione	\fn BMenuItem* BMenu::Track(bool sticky, BRect* clickToOpenRect)
9382f746eafSJohn Scipione	\brief Initiates tracking the cursor within the menu.
9392f746eafSJohn Scipione
9402f746eafSJohn Scipione	This method passes tracking control to submenus hierarchically depending on
9412f746eafSJohn Scipione	where the user moves their mouse.
9422f746eafSJohn Scipione
9432f746eafSJohn Scipione	You only need to call this method yourself if you are implementing a menu
9442f746eafSJohn Scipione	that needs to track the cursor under nonstandard circumstances.
9452f746eafSJohn Scipione
9462f746eafSJohn Scipione	\param sticky If \c true Track() leaves the menu open even after the mouse
9472f746eafSJohn Scipione	       button is no longer held down.
9482f746eafSJohn Scipione	\param clickToOpenRect If \a sticky is \c true, leave the menu open even if
9492f746eafSJohn Scipione	       the user releases the mouse button while the cursor is inside
9502f746eafSJohn Scipione		   \a clickToOpenRect.
9512f746eafSJohn Scipione
9522f746eafSJohn Scipione	\return A BMenuItem object if the user ends tracking by invoking an item or
9532f746eafSJohn Scipione	        \c NULL if the user didn't invoke an item.
95447852bffSJohn Scipione
95547852bffSJohn Scipione	\since BeOS R3
9562f746eafSJohn Scipione*/
9572f746eafSJohn Scipione
9582f746eafSJohn Scipione
9592f746eafSJohn Scipione/*!
9602f746eafSJohn Scipione	\fn bool BMenu::AddDynamicItem(add_state state)
961c9afad22SZardshard	\brief Implemented by subclasses to add their own items to the menu.
962c9afad22SZardshard
963c9afad22SZardshard	This function is called when the menu is shown and will be continuously
964c9afad22SZardshard	called until it returns \c false. On the first call, \a state is
965c9afad22SZardshard	\c B_INITIAL_ADD. On subsequent calls \a state is \c B_PROCESSING. If the
966c9afad22SZardshard	function should stop adding items, such as if the user clicks off of it,
967c9afad22SZardshard	the function will be called with \a state set to \c B_ABORT.
9682f746eafSJohn Scipione
9692f746eafSJohn Scipione	\param state Possibilities include:
9702f746eafSJohn Scipione	       - \c B_INITIAL_ADD,
9712f746eafSJohn Scipione	       - \c B_PROCESSING,
9722f746eafSJohn Scipione	       - \c B_ABORT
9732f746eafSJohn Scipione
974c9afad22SZardshard	\return \c true if there is more to do, \c false otherwise.
97547852bffSJohn Scipione
97647852bffSJohn Scipione	\since Haiku R1
9772f746eafSJohn Scipione*/
9782f746eafSJohn Scipione
9792f746eafSJohn Scipione
9802f746eafSJohn Scipione/*!
9812f746eafSJohn Scipione	\fn void BMenu::DrawBackground(BRect updateRect)
9822f746eafSJohn Scipione	\brief Draw the menu background within the bounds of \a updateRect.
9832f746eafSJohn Scipione
9842f746eafSJohn Scipione	\param updateRect The area to draw the background in.
98547852bffSJohn Scipione
98647852bffSJohn Scipione	\since Haiku R1
9872f746eafSJohn Scipione*/
9882f746eafSJohn Scipione
9892f746eafSJohn Scipione
9902f746eafSJohn Scipione/*!
9912f746eafSJohn Scipione	\fn void BMenu::SetTrackingHook(menu_tracking_hook func, void* state)
9922f746eafSJohn Scipione	\brief Sets a hook function that is called when tracking begins.
9932f746eafSJohn Scipione
9942f746eafSJohn Scipione	\param func The hook function to call.
9952f746eafSJohn Scipione	\param state A variable passed to the hook function.
9962f746eafSJohn Scipione
99747852bffSJohn Scipione	\since Haiku R1
9982f746eafSJohn Scipione*/
999*1978089fSPulkoMandy
1000*1978089fSPulkoMandy
1001*1978089fSPulkoMandy/*!
1002*1978089fSPulkoMandy	\name Item reordering
1003*1978089fSPulkoMandy*/
1004*1978089fSPulkoMandy
1005*1978089fSPulkoMandy
1006*1978089fSPulkoMandy//! @{
1007*1978089fSPulkoMandy
1008*1978089fSPulkoMandy
1009*1978089fSPulkoMandy/*!
1010*1978089fSPulkoMandy	\fn void BMenu::SortItems(int (*compare)(const BMenuItem*, const BMenuItem*))
1011*1978089fSPulkoMandy	\brief Sort items in the menu.
1012*1978089fSPulkoMandy
1013*1978089fSPulkoMandy	\param compare Function used to compare items
1014*1978089fSPulkoMandy
1015*1978089fSPulkoMandy	Sort the items in the menu according to the order defined by the compare function.
1016*1978089fSPulkoMandy	The function should return -1 if the first item should be sorted before the second,
1017*1978089fSPulkoMandy	1 if it should be sorted after, and 0 if the items are equal.
1018*1978089fSPulkoMandy
1019*1978089fSPulkoMandy	The relative order between equal items is preserved, that is, if an item was before an equal
1020*1978089fSPulkoMandy	item in the list, it will still be before it when the sorting is completed.
1021*1978089fSPulkoMandy
1022*1978089fSPulkoMandy	\since Haiku R1
1023*1978089fSPulkoMandy*/
1024*1978089fSPulkoMandy
1025*1978089fSPulkoMandy
1026*1978089fSPulkoMandy/*!
1027*1978089fSPulkoMandy	\fn bool BMenu::SwapItems(int32 indexA, int32 indexB)
1028*1978089fSPulkoMandy	\brief Swap the positions of two items in the menu.
1029*1978089fSPulkoMandy
1030*1978089fSPulkoMandy	\return false in case one of the indexes is out of range
1031*1978089fSPulkoMandy
1032*1978089fSPulkoMandy	\since Haiku R1
1033*1978089fSPulkoMandy*/
1034*1978089fSPulkoMandy
1035*1978089fSPulkoMandy
1036*1978089fSPulkoMandy/*!
1037*1978089fSPulkoMandy	\fn bool BMenu::MoveItem(int32 indexFrom, int32 indexTo)
1038*1978089fSPulkoMandy	\brief Move a menu item to a new position in the menu
1039*1978089fSPulkoMandy
1040*1978089fSPulkoMandy	This is equivalent to removing the item at the old index then inserting it at the new one.
1041*1978089fSPulkoMandy
1042*1978089fSPulkoMandy	\return false in case one of the indexes is out of range
1043*1978089fSPulkoMandy
1044*1978089fSPulkoMandy	\since Haiku R1
1045*1978089fSPulkoMandy*/
1046*1978089fSPulkoMandy
1047*1978089fSPulkoMandy
1048*1978089fSPulkoMandy//! @}
1049