hrev46323 adds 3 changesets to branch 'master' old head: 45e17d3d420323d76203ea234106f4d9d2bdd451 new head: ed7c19b5ef6a97238f6a54514e6489f273e6e147 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=ed7c19b+%5E45e17d3 ---------------------------------------------------------------------------- 0d63525: Minor updates to BMenu docs. Added an Archive() method description. ef92b3d: BMenuBar: Update param names related to docs. No functional change intended. Renamed title => name in regular constructors, No right or wrong here but consistant now. Renamed data => archive in Achive constructor, Ditto. ed7c19b: Added BMenuBar docs. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 4 files changed, 282 insertions(+), 20 deletions(-) docs/user/interface/Menu.dox | 33 +++-- docs/user/interface/MenuBar.dox | 247 ++++++++++++++++++++++++++++++++++++ headers/os/interface/MenuBar.h | 6 +- src/kits/interface/MenuBar.cpp | 16 +-- ############################################################################ Commit: 0d635255f5b010df62c0c015d492a460f13eddce URL: http://cgit.haiku-os.org/haiku/commit/?id=0d63525 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Nov 7 00:23:48 2013 UTC Minor updates to BMenu docs. Added an Archive() method description. ---------------------------------------------------------------------------- diff --git a/docs/user/interface/Menu.dox b/docs/user/interface/Menu.dox index 3f3848d..78b3e8c 100644 --- a/docs/user/interface/Menu.dox +++ b/docs/user/interface/Menu.dox @@ -6,8 +6,8 @@ * John Scipione, jscipione@xxxxxxxxx * * Corresponds to: - * headers/os/interface/Menu.h hrev46318 - * src/kits/interface/Menu.cpp hrev46318 + * headers/os/interface/Menu.h hrev46321 + * src/kits/interface/Menu.cpp hrev46321 */ @@ -134,7 +134,7 @@ arranged hierarchically. A newly created BMenu object doesn't contain any menu items, you need to call - BMenu::AddItem() or BMenu::AddList() to add some. + AddItem() or AddList() to add some. In addition to BMenuItem objects you can also add additional BMenu objects in order to create a menu hierarchy. Unlike menus in other operating systems you @@ -220,7 +220,7 @@ \fn BMenu::~BMenu() \brief Destructor. - Also destroys any attached menu items and submenus. + Also frees the memory used by any attached menu items and submenus. */ @@ -234,7 +234,21 @@ /*! - \name Reimplemented Hook Methods + \fn status_t BMenu::Archive(BMessage* data, bool deep) const + \brief Archives the the BMenu object into the \a data message. + + \param data A pointer to the BMessage to archive the object into. + \param deep Whether or not to archive attached menu items as well. + + \return A status code, \c B_OK if everything went well or an error code + otherwise. + \retval B_OK The object was archived successfully. + \retval B_NO_MEMORY Ran out of memory while archiving the object. +*/ + + +/*! + \name Hook Methods Reimplemented from BView */ @@ -714,11 +728,12 @@ This method is intended to be used by derived classes that don't simply wish to utilize different sorts of menu items or arrange them in a different way, - but wish to invent a different kind of menu altogether. If the \a layout is - set to \c B_ITEMS_IN_MATRIX then the \a resizeToFit flag should be set to - \c false. + but wish to invent a different kind of menu altogether. + + If the \a layout is set to \c B_ITEMS_IN_MATRIX the \a resizeToFit flag should + be set to \c false. - \param frame The \a frame rectangle to create the menu from. + \param frame The \a frame rectangle to create the menu in. \param name The menu's \a name, serves as a label for submenus. \param resizingMode The resizing mode flags, see BView for more details. \param flags The view \a flags, see BView for more details. ############################################################################ Commit: ef92b3dd4cef462499c13de98df2ab2ab8320e93 URL: http://cgit.haiku-os.org/haiku/commit/?id=ef92b3d Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Nov 7 00:26:19 2013 UTC BMenuBar: Update param names related to docs. No functional change intended. Renamed title => name in regular constructors, No right or wrong here but consistant now. Renamed data => archive in Achive constructor, Ditto. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/MenuBar.h b/headers/os/interface/MenuBar.h index a825571..3a4a563 100644 --- a/headers/os/interface/MenuBar.h +++ b/headers/os/interface/MenuBar.h @@ -25,12 +25,12 @@ class BMenuField; class BMenuBar : public BMenu { public: - BMenuBar(BRect frame, const char* title, - uint32 resizeMask = B_FOLLOW_LEFT_RIGHT + BMenuBar(BRect frame, const char* name, + uint32 resizingMode = B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, menu_layout layout = B_ITEMS_IN_ROW, bool resizeToFit = true); - BMenuBar(const char* title, + BMenuBar(const char* name, menu_layout layout = B_ITEMS_IN_ROW, uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS); diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 139123e..36840a0 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -44,10 +44,10 @@ struct menubar_data { }; -BMenuBar::BMenuBar(BRect frame, const char* title, uint32 resizeMask, +BMenuBar::BMenuBar(BRect frame, const char* name, uint32 resizingMode, menu_layout layout, bool resizeToFit) : - BMenu(frame, title, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS + BMenu(frame, name, resizingMode, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE, layout, resizeToFit), fBorder(B_BORDER_FRAME), fTrackingPID(-1), @@ -60,9 +60,9 @@ BMenuBar::BMenuBar(BRect frame, const char* title, uint32 resizeMask, } -BMenuBar::BMenuBar(const char* title, menu_layout layout, uint32 flags) +BMenuBar::BMenuBar(const char* name, menu_layout layout, uint32 flags) : - BMenu(BRect(), title, B_FOLLOW_NONE, + BMenu(BRect(), name, B_FOLLOW_NONE, flags | B_WILL_DRAW | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT, layout, false), fBorder(B_BORDER_FRAME), @@ -76,9 +76,9 @@ BMenuBar::BMenuBar(const char* title, menu_layout layout, uint32 flags) } -BMenuBar::BMenuBar(BMessage* data) +BMenuBar::BMenuBar(BMessage* archive) : - BMenu(data), + BMenu(archive), fBorder(B_BORDER_FRAME), fTrackingPID(-1), fPrevFocusToken(-1), @@ -88,11 +88,11 @@ BMenuBar::BMenuBar(BMessage* data) { int32 border; - if (data->FindInt32("_border", &border) == B_OK) + if (archive->FindInt32("_border", &border) == B_OK) SetBorder((menu_bar_border)border); menu_layout layout = B_ITEMS_IN_COLUMN; - data->FindInt32("_layout", (int32*)&layout); + archive->FindInt32("_layout", (int32*)&layout); _InitData(layout); } ############################################################################ Revision: hrev46323 Commit: ed7c19b5ef6a97238f6a54514e6489f273e6e147 URL: http://cgit.haiku-os.org/haiku/commit/?id=ed7c19b Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Nov 7 00:26:34 2013 UTC Added BMenuBar docs. ---------------------------------------------------------------------------- diff --git a/docs/user/interface/MenuBar.dox b/docs/user/interface/MenuBar.dox new file mode 100644 index 0000000..b5c8d08 --- /dev/null +++ b/docs/user/interface/MenuBar.dox @@ -0,0 +1,247 @@ +/* + * Copyright 2013 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * John Scipione, jscipione@xxxxxxxxx + * + * Corresponds to: + * headers/os/interface/MenuBar.h hrev46323 + * src/kits/interface/MenuBar.cpp hrev46323 + */ + + +/*! + \file MenuBar.h + \ingroup interface + \ingroup libbe + \brief MenuBar class definition and support structures. +*/ + + +/*! + \enum menu_bar_border + \ingroup interface + + Menu bar border style constants. + + \see BMenuBar::SetBorder() +*/ + + +/*! + \var menu_bar_border B_BORDER_FRAME + + The border is drawn around the entire menu bar. +*/ + + +/*! + \var menu_bar_border B_BORDER_CONTENTS + + The border is drawn around the list of items. +*/ + + + +/*! + \var menu_bar_border B_BORDER_EACH_ITEM + + The border is drawn around each individual item. +*/ + + +/*! + \class BMenuBar + \ingroup interface + \ingroup libbe + \brief A window's root menu. + + A menu bar, if a window has one, is typically drawn across the top of the + window just below the tab and a window typically has just a single menu bar, + although this is up to you. + + One menu bar attached to a window is considered to be the "key" menu bar + that can be navigated by the user using the keyboard. The last menu bar + attached to a window is automatically set as the key menu bar for the + window. To override this behavior and set a different key menu bar use the + BWindow::SetKeyMenuBar() method. + + When either the \key{Menu} key or \key{Command}+\key{Esc} keys are pressed + the key menu bar opens and focuses it's first menu item, typically a BMenu. + Once the menu bar is open the user can navigate around the attached menus + and menu items using the arrow keys. + + Like a BMenu, a BMenuBar object starts without any items attached to it, + you'll need to call AddItem() or AddList() to add some. The top-level items + in a menu bar are typically menus which have menu items and menus added to + them in turn. +*/ + + +/*! + \fn BMenuBar::BMenuBar(BRect frame, const char* name, uint32 resizingMode, + menu_layout layout, bool resizeToFit) + \brief Create a new BMenuBar object. + + The default resizing mode, \c B_FOLLOW_LEFT_RIGHT | \c B_FOLLOW_TOP is + meant to be used by a typical menu bar that is positioned along the top + edge of a window. This resizing mode allows the menu bar to resize itself + based on changes to the window's width while keeping it attached to the + top of the window frame. + + For menu bars in \c B_ITEMS_IN_ROW layout the height is automatically + set to be the height of a single item, while menus bars in + \c B_ITEMS_IN_COLUMN layout the width is automatically set to be the width + of the widest item. + + The width of a menu bar is set equal to the width of its parent for menu + bars in \c B_ITEMS_IN_ROW layout and a \a resizingMode mask that includes + \c B_FOLLOW_LEFT_RIGHT so that the menu bar will always be as wide as its + attached window. + + Likewise, the height of a menu bar is set equal to the height of its parent + for menu bars in \c B_ITEMS_IN_COLUMN layout and a \a resizingMode mask that + includes \c B_FOLLOW_TOP_BOTTOM so that the menu bar will always be as high + as its attached window. + + When \a resizeToFit is set to \c true, as is the default, the \a frame + rectangle determines only where the menu bar is located, not its size. + If the \a layout is set to \c B_ITEMS_IN_MATRIX the \a resizeToFit flag + should be set to \c false. + + \param frame The \a frame rectangle to create the menu bar in. + \param name The \a name of the menu bar, used internally only. + \param resizingMode The resizing mode flags, see BView for more details. + \param layout The menu layout, possibilities include: + - \c B_ITEMS_IN_ROW items are displayed in a single row, + - \c B_ITEMS_IN_COLUMN items are displayed in a single column, + - \c B_ITEMS_IN_MATRIX items are displayed in a custom matrix. + \param resizeToFit Whether or not the menu bar should automatically resize + itself to fit its contents, this will not work in + \c B_ITEMS_IN_MATRIX layout. +*/ + + +/*! + \fn BMenuBar::BMenuBar(const char* name, menu_layout layout, uint32 flags) + \brief Create a new BMenuBar object suitable to use with the layout APIs. + + \param name The \a name of the menu bar, used internally only. + \param flags The view \a flags, see BView for more details. + \param layout The menu layout, possibilities include: + - \c B_ITEMS_IN_ROW items are displayed in a single row, + - \c B_ITEMS_IN_COLUMN items are displayed in a single column, + - \c B_ITEMS_IN_MATRIX items are displayed in a custom matrix. +*/ + + +/*! + \fn BMenuBar::BMenuBar(BMessage* archive) + \brief Archive constructor. + + \param archive The message data to construct the menu from. +*/ + + +/*! + \fn BMenuBar::~BMenuBar() + \brief Destructor. + + Also frees the memory used by any attached menus and menu items. +*/ + + +/*! + \fn BArchivable* BMenuBar::Instantiate(BMessage* data) + \brief Creates a new BMenuBar object from an \a archive message. + + \returns A newly created BMenuBar object or \c NULL if the message + doesn't contain an archived BMenuBar. +*/ + + +/*! + \fn status_t BMenuBar::Archive(BMessage* data, bool deep) const + \brief Archives the the BMenuBar object into the \a data message. + + \param data A pointer to the BMessage to archive the object into. + \param deep Whether or not to archive attached menu items as well. + + \return A status code, \c B_OK if everything went well or an error code + otherwise. + \retval B_OK The object was archived successfully. + \retval B_NO_MEMORY Ran out of memory while archiving the object. +*/ + + +/*! + \name Hook Methods Reimplemented from BMenu +*/ + + +//! @{ + + +/*! + \fn void BMenuBar::AttachedToWindow() + \brief Sets this as the key menubar for the window, lays out the menu items + and resizes the menu to fit. + + \see BWindow::SetKeyMenuBar() +*/ + + +/*! + \fn void BMenuBar::FrameResized(float newWidth, float newHeight) + \brief Hook method that gets called when the menu bar is resized. + + Redraws the affected borders. + + \param newWidth The new \a width of the menu bar. + \param newHeight The new \a height of the menu bar. +*/ + + +/*! + \fn void BMenuBar::Draw(BRect updateRect) + \brief Draws the menu bar. + + \param updateRect The area to draw in. +*/ + + +/*! + \fn void BMenuBar::MouseDown(BPoint where) + \brief Hook method that is called when a mouse button is pressed. + + Right clicking on a menu bar sends the window to back or brings it to front. + + \param where The point on the screen where to mouse pointer is when + the mouse button is pressed. +*/ + + +//! @} + + +/*! + \fn void BMenuBar::SetBorder(menu_bar_border border) + \brief Sets how the menu bar border is drawn. + + The default is \c B_BORDER_FRAME. + + \param border Options include: + - \c B_BORDER_FRAME The border is drawn around the entire menu bar. + - \c B_BORDER_CONTENTS The border is drawn around the list of items. + - \c B_BORDER_EACH_ITEM The border is drawn around each individual + item. +*/ + + +/*! + \fn menu_bar_border BMenuBar::Border() const + \brief Returns the currently set border style. + + /see BMenuBar::SetBorder() for details. +*/