hrev46969 adds 3 changesets to branch 'master' old head: 217f090f9e247d1d4c5644e626642c430fafe4e5 new head: 379ede58af15012f17e87673b0266235762a1230 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=379ede5+%5E217f090 ---------------------------------------------------------------------------- 4479c8f: Style fixes to BSeparatorItem class. Mostly meant for documentation with a few other style corrections as well. Update copyright header. 9b39e22: Add BSeparatorItem class documentation 379ede5: Style fixes to BMenuItem::GetContentSize and update docs Rename width and height to _width and _height matching the header. Update the documentation for this method as well. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 5 files changed, 148 insertions(+), 31 deletions(-) docs/user/interface/MenuItem.dox | 14 ++-- docs/user/interface/SeparatorItem.dox | 115 ++++++++++++++++++++++++++++++ headers/os/interface/SeparatorItem.h | 10 +-- src/kits/interface/MenuItem.cpp | 10 +-- src/kits/interface/SeparatorItem.cpp | 30 ++++---- ############################################################################ Commit: 4479c8fda7c6704266eaf4ca3284b3b4325170aa URL: http://cgit.haiku-os.org/haiku/commit/?id=4479c8f Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Mar 4 19:15:20 2014 UTC Style fixes to BSeparatorItem class. Mostly meant for documentation with a few other style corrections as well. Update copyright header. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/SeparatorItem.h b/headers/os/interface/SeparatorItem.h index 4405f28..ac102d8 100644 --- a/headers/os/interface/SeparatorItem.h +++ b/headers/os/interface/SeparatorItem.h @@ -1,10 +1,10 @@ /* - * Copyright 2001-2009, Haiku, Inc. All rights reserved. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _SEPARATOR_ITEM_H #define _SEPARATOR_ITEM_H - + #include <MenuItem.h> @@ -17,11 +17,11 @@ public: BSeparatorItem(BMessage* archive); virtual ~BSeparatorItem(); - static BArchivable* Instantiate(BMessage* archive); - virtual status_t Archive(BMessage* archive, + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; - virtual void SetEnabled(bool state); + virtual void SetEnabled(bool enable); protected: virtual void GetContentSize(float* _width, float* _height); diff --git a/src/kits/interface/SeparatorItem.cpp b/src/kits/interface/SeparatorItem.cpp index ba2bd38..ac9b8a6 100644 --- a/src/kits/interface/SeparatorItem.cpp +++ b/src/kits/interface/SeparatorItem.cpp @@ -1,29 +1,30 @@ /* - * Copyright (c) 2001-2010, Haiku, Inc. + * Copyright (c) 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: - * Marc Flerackers (mflerackers@xxxxxxxxxx) - * Bill Hayden (haydentech@xxxxxxxxxxxxxxxxxxxxx) - * Stefano Ceccherini (burton666@xxxxxxxxx) + * Stefano Ceccherini, burton666@xxxxxxxxx + * Marc Flerackers, mflerackers@xxxxxxxxxx + * Bill Hayden, haydentech@xxxxxxxxxxxxxxxxxxxxx */ -/*! Display separator item for BMenu class */ - #include <SeparatorItem.h> + #include <Font.h> BSeparatorItem::BSeparatorItem() - : BMenuItem("", NULL) + : + BMenuItem("", NULL) { BMenuItem::SetEnabled(false); } -BSeparatorItem::BSeparatorItem(BMessage* archive) - : BMenuItem(archive) +BSeparatorItem::BSeparatorItem(BMessage* data) + : + BMenuItem(data) { BMenuItem::SetEnabled(false); } @@ -35,13 +36,13 @@ BSeparatorItem::~BSeparatorItem() status_t -BSeparatorItem::Archive(BMessage* archive, bool deep) const +BSeparatorItem::Archive(BMessage* data, bool deep) const { - return BMenuItem::Archive(archive, deep); + return BMenuItem::Archive(data, deep); } -BArchivable * +BArchivable* BSeparatorItem::Instantiate(BMessage* archive) { if (validate_instantiation(archive, "BSeparatorItem")) @@ -52,7 +53,7 @@ BSeparatorItem::Instantiate(BMessage* archive) void -BSeparatorItem::SetEnabled(bool state) +BSeparatorItem::SetEnabled(bool enable) { // Don't do anything - we don't want to get enabled ever } @@ -66,8 +67,9 @@ BSeparatorItem::GetContentSize(float* _width, float* _height) if (_height != NULL) { BFont font(be_plain_font); - if (Menu()) + if (Menu() != NULL) Menu()->GetFont(&font); + const float height = floorf((font.Size() * 0.8) / 2) * 2; *_height = max_c(4, height); } ############################################################################ Commit: 9b39e22db276fe4aa8434fb4e16fcdc29888f84d URL: http://cgit.haiku-os.org/haiku/commit/?id=9b39e22 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Mar 4 19:15:45 2014 UTC Add BSeparatorItem class documentation ---------------------------------------------------------------------------- diff --git a/docs/user/interface/SeparatorItem.dox b/docs/user/interface/SeparatorItem.dox new file mode 100644 index 0000000..d78bfac --- /dev/null +++ b/docs/user/interface/SeparatorItem.dox @@ -0,0 +1,115 @@ +/* + * Copyright 2014 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * John Scipione, jscipione@xxxxxxxxx + * + * Corresponds to: + * headers/os/interface/SeparatorItem.h hrev46969 + * src/kits/interface/SeparatorItem.cpp hrev46969 + */ + + +/*! + \file SeparatorItem.h + \ingroup interface + \ingroup libbe + \brief BSeparatorItem class definition. +*/ + + +/*! + \class BSeparatorItem + \ingroup interface + \ingroup libbe + \brief Display separator item for BMenu class. + + A BSeparatorItem is used to separate groups of menu items in a BMenu. + It is drawn as a horizontal line and cannot be selected or highlighted. + + \warning BSeparatorItems are only meant to be used with menus whose + items are arranged in a \c B_ITEMS_IN_COLUMN layout. +*/ + + +/*! + \fn BSeparatorItem::BSeparatorItem() + \brief Creates a new BSeparatorItem object. + + The creates a new BSeparatorItem from BMenuItem with a blank label and + \c NULL message, then disables it. +*/ + + +/*! + \fn BSeparatorItem::BSeparatorItem(BMessage* data) + \brief Archive constructor. + + \param data The message \a data to construct the separator item from. +*/ + + +/*! + \fn BSeparatorItem::~BSeparatorItem() + \brief Destructor, does nothing. +*/ + + +/*! + \fn status_t BSeparatorItem::Archive(BMessage* data, bool deep) const + \brief Archives the the BSeparatorItem object into the \a data message. + + \param data A pointer to the BMessage to archive the object into. + \param deep This parameter has no effect for this class. + + \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. +*/ + + +/*! + \fn BArchivable* BSeparatorItem::Instantiate(BMessage* data) + \brief Creates a new BSeparatorItem object from an \a data message. + + \return A newly created BSeparatorItem object or \c NULL if the message + doesn't contain an archived BSeparatorItem. +*/ + + +/*! + \fn void BSeparatorItem::SetEnabled(bool enable) + \brief Does nothing, this method is defined to override the default + BMenuItem behavior. +*/ + + +/*! + \fn void BSeparatorItem::GetContentSize(float* _width, float* _height) + \brief Fills out \a _width and \a _height with the content rectangle + dimensions. + + You only need to call this method if you're implementing your own + DrawContent() method to override how the contents of the separator + are drawn. + + \param _width Filled out with the width of the content rectangle. + \param _height Filled out with the height of the content rectangle. + + \sa ContentLocation() + \sa DrawContent() +*/ + + +/*! + \fn void BSeparatorItem::Draw() + \brief Hook method used to draw the menu items. + + This method is called by automatically by BMenu::Draw(). You should not need to + call this method yourself but you may want to override it in a derived class + to do something other than the default. + + The default draws a light grey vertical line through the middle of the item. +*/ ############################################################################ Revision: hrev46969 Commit: 379ede58af15012f17e87673b0266235762a1230 URL: http://cgit.haiku-os.org/haiku/commit/?id=379ede5 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Mar 4 19:17:46 2014 UTC Style fixes to BMenuItem::GetContentSize and update docs Rename width and height to _width and _height matching the header. Update the documentation for this method as well. ---------------------------------------------------------------------------- diff --git a/docs/user/interface/MenuItem.dox b/docs/user/interface/MenuItem.dox index b858efc..f852885 100644 --- a/docs/user/interface/MenuItem.dox +++ b/docs/user/interface/MenuItem.dox @@ -1,13 +1,13 @@ /* - * Copyright 2014 Haiku Inc. All rights reserved. + * Copyright 2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * John Scipione, jscipione@xxxxxxxxx * * Corresponds to: - * headers/os/interface/MenuItem.h hrev46953 - * src/kits/interface/MenuItem.cpp hrev46953 + * headers/os/interface/MenuItem.h hrev46969 + * src/kits/interface/MenuItem.cpp hrev46969 */ @@ -266,8 +266,8 @@ /*! - \fn void BMenuItem::GetContentSize(float* width, float* height) - \brief Fills out \a width and \a height with the content rectangle + \fn void BMenuItem::GetContentSize(float* _width, float* _height) + \brief Fills out \a _width and \a _height with the content rectangle dimensions. You only need to call this method if you're implementing your own @@ -280,8 +280,8 @@ The content rectangle can be calculated using this method as well as ContentLocation() to get location of the top left corner. - \param width Filled out with the \a width of the content rectangle. - \param height Filled out with the \a height of the content rectangle. + \param _width Filled out with the width of the content rectangle. + \param _height Filled out with the height of the content rectangle. \sa ContentLocation() \sa DrawContent() diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 0cf8b99..e1a20a8 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -360,7 +360,7 @@ BMenuItem::Frame() const void -BMenuItem::GetContentSize(float* width, float* height) +BMenuItem::GetContentSize(float* _width, float* _height) { // TODO: Get rid of this. BMenu should handle this // automatically. Maybe it's not even needed, since our @@ -369,10 +369,10 @@ BMenuItem::GetContentSize(float* width, float* height) fCachedWidth = fSuper->StringWidth(fLabel); - if (width) - *width = (float)ceil(fCachedWidth); - if (height) - *height = MenuPrivate(fSuper).FontHeight(); + if (_width) + *_width = (float)ceil(fCachedWidth); + if (_height) + *_height = MenuPrivate(fSuper).FontHeight(); }