History log of /haiku/src/kits/interface/BMCPrivate.cpp
Revision Date Author Comments
# 5f887442 18-Feb-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

BMenuField: allow to use non-fixed size in combination with layout mode

In fixed size mode, the menu field always uses all the available width.
In non-fixed size mode, the menu field will resize itself to be as small
as possible.

With layout, usually the difference isn't noticeable, since the layout
will already try to resize the control to the smallest possible size.
But there are a few cases where it makes a difference, when the layout
is over-constrained and the menu field can't be made as small as
possible. In that case, the menu field would be forced to fill its
allocated space, where we can instead make it a little smaller.

Change-Id: I911d497218a09aab3824865968558df5d4b3cf98
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6076
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: John Scipione <jscipione@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 582afd9a 21-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

interface & app_server: Fix missing parentheses near ternary operators.

+ has greater operator precendence than ?, so we need parentheses when
using both in expressions. Both of these look like actual bugs.

Spotted by Clang.


# bfbb9655 10-Sep-2017 Augustin Cavalier <waddlesplash@gmail.com>

Interface Kit: Remove more non-BControlLook code.


# dcecaf60 19-Apr-2016 John Scipione <jscipione@gmail.com>

BMenu: Remove _ from protected method _DrawItems


# 61dfdec4 19-Apr-2016 John Scipione <jscipione@gmail.com>

BMenu and friends: style fixes

BMenuBar: style fix: msg => message

MenuPrivate: style fixes

MenuItem: 80 char limit style fix

MenuBar: tiny style fix

Menu: tiny style fix, indentation

Menu: Small refactor

Implement _SetIgnoreHidden() in header
Change on to ignoreHidden
Change on in _SetStickyMode to sticky

_BMCItem_: tiny whitespace style fix

Menu: style fixes, rename msgr => messenger

BMenu: style fix, pointer != NULL

BMenu::Archive rename ret to status

Also check pointer against NULL explicitly

BMenuItem style fixes: rename abbreviation, pointer style


# 7a96554c 09-Dec-2015 looncraz <looncraz@looncraz.net>

kits/interface: Convert to using Set*UIColor.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Patches 0003-0017 from looncraz, unmodified.


# e0f81db6 08-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

re-add the _BMCItem_ class for binary compatibility.

This was removed in hrev17147, because our implementation of BMenuItem
does not uses it anymore. However, we must keep it in order to properly
unarchive BMenuFields that were archived in BeOS.

One application that was crashing because of this is VNCViewer.


# 58a3b207 22-Apr-2014 John Scipione <jscipione@gmail.com>

BMenuField: style fixes


# bb322d35 18-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

BMenuField: Draw everything on resize

* The label might be truncated, in which case the entire width needs to be
redrawn when the menu field shrinks or grows.
* Invalidating the border in the parent looked a bit weird. Simplified.


# 3dd9ff2b 24-Aug-2013 John Scipione <jscipione@gmail.com>

BMCMenuBar: Refactor MakeFocus()

Get rid of unused fRunner variable.

It is very basic now, it just works.

Also, renamed msg to message in MessageReceived() and
declared MakeFocus() above it (alphabetically).


# cccc4076 24-Aug-2013 John Scipione <jscipione@gmail.com>

Menu and friends: Style fixes, no functional

... changes intended.

* 80 char limit fixes
* Indentation fixes
* Braces style fixes
* Use ternary operator where appropriate
* Rename menuItem to just item and declare it once outside
the loop
* Omit 3rd param of GetMouse() because it is default
* Rename variables eg state => focused and menu => submenu
* Indent comments below line they apply to
* Reword some comments
* Add some #pragmas


# 408c0ee4 20-Aug-2013 John Scipione <jscipione@gmail.com>

MenuField: enable/disable the menu field when...

the child menu bar or the child menu bar's menu is enabled/disabled.

This means that there is just one status we have to check, the menu
fields, and the child menus agree. This change takes practical form
in the Backgrounds preflet which disables the placement menu when
the image is set to "None", but, only the menu got disabled and not the
parent menu field so the label was erroneously still drawn as enabled.


# 1c95f722 07-Jun-2013 John Scipione <jscipione@gmail.com>

Don't set MaxContentWidth on the menu bar of a BMenuField

Fixes #9816

It is no longer necessary, or even desirable for us to set the max
content width of the menu bar of a BMenuField now that BMenuItem
truncation and BMenuField sizing are working.

The user may, however, wish to set the max content width of the menu
bar of a BMenuField themselves like so:

menuField->MenuBar()->SetMaxContentWidth(width);

and the Interface Kit will automatically deduct the left and right
margins from the width including the space used by the drop down arrow.


# ca3a1c04 29-May-2013 John Scipione <jscipione@gmail.com>

BMenuField: If fixed size always set max content width

When you resize, also set max content width.

Create a SetMaxContentWidth() method that includes the margins.


# a1cf3ead 25-May-2013 John Scipione <jscipione@gmail.com>

Resize menu field if below minimum width in auto-size mode

... cancelling the normal item truncation behavior.
This funcationality comes from BeOS R5, we need to reproduce it for
backwards compat. KeymapSwitcher depends on it at least.

Minimum width is 20px, was set in last commit, comes from BeOS R5.


# 6031e624 25-May-2013 John Scipione <jscipione@gmail.com>

Move constants to BMCPrivate.h and refactor

We use these constants in both MenuField.cpp and BMCPrivate.cpp

Incorporate kMarginWidth into kPopUpIndicatorWidth.

A small code simplication in FrameResized() along with replacing bare numbers
with magic constants.


# f7c092f5 25-May-2013 John Scipione <jscipione@gmail.com>

Refactor _BMCMenuBar_::Draw a bit

Move the comments around, expand on them and an 80 char fix.


# 01636e8f 15-May-2013 John Scipione <jscipione@gmail.com>

Adjust menu field's menu bar height in auto mode

On IRC diver pointed out to me that KeymapSwitcher had a menu field that
was drawing as just a line since my recent change to BMenuField. I did a
little research and discovered that this was because the menu field in
KeymapSwitch was not using the layout APIs and it's frame rect was set to
0 height.

I did a little more research and experimented with menu fields in
BeOS R5. I discovered that in R5 if the menu field is set to auto-size
mode then the menu bar inside ignores the height of the menu field frame
and uses the BMenuBar's preferred height instead.

So, I adjusted the BMenuField code in Haiku accordingly. This should make
Haiku match the behavior of BeOS R5 in auto-size mode. For fixed-size mode
it should also work the same, although some more testing is needed to
see if there are any regressions there.


# 298cd4c2 09-May-2013 John Scipione <jscipione@gmail.com>

BMenuField: Fix menu bar resizing in auto-size mode.

Fixes #9753 (for real this time)

Don't resize the menu field when the menu bar resizes, the menu
field stays the same size because we'll need to use it's width to
check when the menu bar width has expanded beyond its width.
Then, if the selected menu item expands the menu bar to a width
greater than the width of the menu field resize it to the menu field
width.


# ec1f08fb 08-May-2013 John Scipione <jscipione@gmail.com>

Resize menu field menu bar iff fFixedSize is true

If the menu field is not fixed size than the width of the menu bar
should depend on the menu item contents so just do the default and
get the Bounds() without any extra resizing.


# e28ba280 06-May-2013 John Scipione <jscipione@gmail.com>

BMCPrivate: Cleanup

Remove no longer needed header includes, most that I recently added
a few that were already there but just aren't needed anymore. Don't
use BPrivate::MenuPrivate namespace.


# c1a7e89f 06-May-2013 John Scipione <jscipione@gmail.com>

Put the label truncation code back in BMenuItem.

Just a few commits ago I moved the label truncation code out of
BMenuItem and into BMCMenuBar because the truncation had to happen
outside of BMenuItem. Turns out, that wasn't true so I'm moving the
label truncation back into BMenuItem and removing the _DrawItems()
method from BMCMenuBar.

Note that the code is not a copy of what was there before, but, the
updated version I created for BMCMenuBar. The main difference is that
I use menuPrivate.Padding() instead of GetItemMargins() and I always
use the width of the parent menu frame instead of using fBounds even
if the state is not MENU_STATE_CLOSED. These are changes needed for
BMCMenuBar but should work just as well for a regular BMenu.


# c3339662 06-May-2013 John Scipione <jscipione@gmail.com>

Draw truncated menu label in BMCPrivate, fixes #9735

...instead of in BMenuItem and remove the truncation code from BMenuItem.

The label truncation code cannot work in BMenuItem because the super
menu helpfully resizes itself to fit the menu item. So, instead we do the label
truncation in BMCPrivate making sure that BMenuItem there can't expand the
BMCMenuBar because we set the width to fMenuField->_MenuBarWidth()
explicity.

Note that this only truncates the label in BMCMenuField, i.e. the label inside
the menufield, it does nothing to the labels of the menu items in the attached
BMenu or BPopUpMenu which is exactly what we want.


# 1afff671 06-May-2013 John Scipione <jscipione@gmail.com>

Set some static variables for magic number constants


# 2bf1592a 06-May-2013 John Scipione <jscipione@gmail.com>

Rework layout-enabled contructor for BMCMenuBar

Was passing !fixedSize into the view flags of BMenuBar, which made no sense.
Stop doing that, set fixedSize to true instead.

Remove the fixedSize parameter from this contructor, it's too late for that.


# 6c145207 06-May-2013 John Scipione <jscipione@gmail.com>

Remove pre-ControlLook drawing code in menu classes


# d218f0f8 06-May-2013 John Scipione <jscipione@gmail.com>

Put the BMenuBar initilization on it's own line


# d5c51ba6 06-May-2013 John Scipione <jscipione@gmail.com>

Update header comments


# d97b4340 06-May-2013 John Scipione <jscipione@gmail.com>

Style fixes to BMenu and related classes.


# 57c5b09e 05-Aug-2012 Ryan Leavengood <leavengood@gmail.com>

Use be_control_look != NULL everywhere in the Interface Kit.

Should not be a functional change. It is not in the Haiku Coding Guidelines but
I feel like 'if (object != NULL)' is generally preferred to 'if (object)', plus
in this case of be_control_look that is the more common style.


# 6a03786c 28-Jul-2012 Ryan Leavengood <leavengood@gmail.com>

Draw menus using the user chosen colors.


# 50f8cd14 07-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.
* Remove superfluous operator=() implementations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32174 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d82ea8ab 07-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Only take the popup marker into account if fShowPopUpMarker is true.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32173 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01592a40 06-Aug-2009 Rene Gollent <anevilyak@gmail.com>

Fix small style violation.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 102a66c3 06-Aug-2009 Rene Gollent <anevilyak@gmail.com>

BMenuField's private menu bar did not take into account the width of the popup indicator when computing its minimum size. Fixes ticket #3635.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32171 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 681c2e44 25-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

The button and menu field draw routines take a background color into account,
which makes the resessed frame blend better with the surroundings. This can
be seen best in Keymap, where a different color is set on some buttons, but
the resessed frame should still be the same across all those buttons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29716 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94e66d17 25-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed recently introduced regressions with layouted BMenuFields. When passing
fixedSize=true to the private BMenuBar class, it would set the follow mode
in AttachedToWindow() such that BMenu would calculate the minimum width
differently. Also fixes ticket #3606.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29691 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31852cb1 22-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Various fixes to BMenuField behavior:
* In layout mode, using a BMenuField directly will make it behave like using
a fixed size BMenuField in non-layout mode. This is open for debate, but
not a change to the previous behavior. When using the Label and MenuBar-
LayoutItems though, the behavior is now changed to be more what one would
expect, ie the BMenuBar part is layouted across the full available width
just like it happens with BTextControls.
* Fixed invalidation of the BMenuBar when it auto-resizes according to picking
another item, and when it is resized due to layout changes.
* Fixed the problem with growing BMenuFields in file panels after changing
folders the first time. The fix is not so nice, but the purpose of setting
the menu item margins is to make sure it renders at the same vertical
offset as the BMenuField label. The better fix would be to change the
calculation of the content location or required margins in the BMenuItem
code... however the BMCPrivate code needs to account for the popup indicator
in the margins so I just kept the fix for the offset there as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29650 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f86ba45 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented a new look for the Haiku interface controls. It was
overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0095fe72 14-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Added a comment about the purpose of the code in AttachedToWindow().
* Improved FrameResized(). The "diff" is actually between the new location
of the right side (Frame().right) and the location where it probably was
in the parent before it is resized (fMenuField->Bounds().right - 2).
Could be that this change is wrong, or at least, not yet correct. Will
test on a different machine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27507 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15b9bc4f 19-Nov-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

small cleanups


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22964 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bbe85585 13-Sep-2007 Stephan Aßmus <superstippi@gmx.de>

* make absolutely sure there is no cyclic resizing


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22229 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a38a485 30-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* fixed size layout of BMenuBar on BMenuField in fixed size mode
(needs to account for the parts that the BMenuField draws, ie the shadow
on the right)
* fixed follow mode of BMenuBar in fixed size mode (B_FOLLOW_LEFT_RIGHT)
* don't resize the BMenuField in fixed size mode (endless loop), this should
be more robust anyways, since this endless loop would be triggered if an
application tried to manually resize menuField->MenuBar() in auto resizing
mode
* fixed calculation of the parts that need to be redrawn on resize


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bd57c145 15-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* setting a different menu color with the menu preflet gives now visually
agreeable results (I hope)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec592aa9 19-Jun-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Implement _BMCMenuBar_::MaxSize() to override BMenuBar::MaxSize() and limit
the maximum width. The latter supports unlimited maximum width. The
_BMCMenuBar_ draws fine when resized wider than its min/preferred width, but
not the complete "button" area will cause the menu to open when being pressed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21465 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd39decc 28-May-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added a filter to MenuField, so that mousedown messages caught by the inner menubar are redirected to the BMenuField's MouseDown() like happens on beos. That way we can track and invalidate correctly. Implemented Show/HidePopUpMarker

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8773f97 10-May-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Invalidate less in BMenuBar::FrameResized() and a bit more in _BMCMenuBar_::FrameResized(), removed unused _BMCItem_

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e3d07155 14-Mar-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Enlarged a bit the BMCMenuBar's frame, so that it's drawn more nicely

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16795 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f282009d 16-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

* _BMCItem_ is no longer used, but I didn't remove it
yet, just commented it out in BMenuField. As was expected,
nothing changed in any obvious way
* made the _BMCMenuBar_ draw the popup marked. I changed it
a bit, inspired from some mockup I saw, sorry I don't
remember where. I hope you like it (it is easily changed
back if you don't).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5364573e 14-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Partially reverted to 15464 to have less code duplication, now that the special case is handled in BMenu::CalcFrame()

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15944 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5cd88a5 13-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Small changes, nothing important

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15942 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9f970d9 11-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Yesterday's commit triggered some other visual bugs: hopefully fixed them all. A disabled menufield now doesn't open its associated menu anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 797d1a66 10-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

menufields should default to B_ITEMS_IN_COLUMN. This fixes the workspaces menu (in Screen) opened at the wrong position. As a consequence of this, I had to change the drawing code a bit

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15892 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b98735f 10-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

forgot about the right side extra room for the focus indication

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15464 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3f0aa142 07-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

take care of resizing and cleaning up parent BMenuField in FrameResized(), fixes missing areas in Fonts and most likely other BMenuFields

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15413 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0a95bea6 06-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

fixed wrong usage of ConstrainClippingRegion() introduced by myself a couple months ago

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15374 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e6a5805 05-Jul-2005 Stephan Aßmus <superstippi@gmx.de>

MenuField layouts the menu bar better with respect to fDivider, it aligns better with other controls. fDivider in TextControl is an integer number now, small fix and small cleanup in Menu, Window::InitData takes an optional BBitmap token to construct an offscreen window, fixed PrivateScreen IndexForColor, View prevents being located at fractional coordinates as in R5, BBitmap unlocks its offscreen window since it is never Show()n and needs manual unlocking, fixed Slider offscreen window mode and improved triange thumb drawing, ScrollView would not crash when passing a NULL target just for kicks, the private MenuBar class now implements Draw to draw itself a little differently inside the BMenuField (dark right and bottom side) - though how it currently sets the clipping region prevents the text controls to draw in Playground, needs fixing

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13450 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ea7a892 16-Jun-2003 Marc Flerackers <mflerackers@nowhere.fake>

BMenuField


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3542 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0f81db6578881e671dd5539cf7b4cb7ca5f526d 08-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

re-add the _BMCItem_ class for binary compatibility.

This was removed in hrev17147, because our implementation of BMenuItem
does not uses it anymore. However, we must keep it in order to properly
unarchive BMenuFields that were archived in BeOS.

One application that was crashing because of this is VNCViewer.


# 58a3b20760f388db630dbda0986c67e9e87ca38c 22-Apr-2014 John Scipione <jscipione@gmail.com>

BMenuField: style fixes


# bb322d35003f8cb1b51fa772c83f8461d1295771 18-Feb-2014 Stephan Aßmus <superstippi@gmx.de>

BMenuField: Draw everything on resize

* The label might be truncated, in which case the entire width needs to be
redrawn when the menu field shrinks or grows.
* Invalidating the border in the parent looked a bit weird. Simplified.


# 3dd9ff2b5d3a9c13e0fa87760efc29e6c929ac21 24-Aug-2013 John Scipione <jscipione@gmail.com>

BMCMenuBar: Refactor MakeFocus()

Get rid of unused fRunner variable.

It is very basic now, it just works.

Also, renamed msg to message in MessageReceived() and
declared MakeFocus() above it (alphabetically).


# cccc4076dbd857be016741e5dd75c61858aabe2a 24-Aug-2013 John Scipione <jscipione@gmail.com>

Menu and friends: Style fixes, no functional

... changes intended.

* 80 char limit fixes
* Indentation fixes
* Braces style fixes
* Use ternary operator where appropriate
* Rename menuItem to just item and declare it once outside
the loop
* Omit 3rd param of GetMouse() because it is default
* Rename variables eg state => focused and menu => submenu
* Indent comments below line they apply to
* Reword some comments
* Add some #pragmas


# 408c0ee4cdd7cbe9935aae9af2c5e3ca110a89a6 20-Aug-2013 John Scipione <jscipione@gmail.com>

MenuField: enable/disable the menu field when...

the child menu bar or the child menu bar's menu is enabled/disabled.

This means that there is just one status we have to check, the menu
fields, and the child menus agree. This change takes practical form
in the Backgrounds preflet which disables the placement menu when
the image is set to "None", but, only the menu got disabled and not the
parent menu field so the label was erroneously still drawn as enabled.


# 1c95f72222f766079af3183ab490e42506f5feca 07-Jun-2013 John Scipione <jscipione@gmail.com>

Don't set MaxContentWidth on the menu bar of a BMenuField

Fixes #9816

It is no longer necessary, or even desirable for us to set the max
content width of the menu bar of a BMenuField now that BMenuItem
truncation and BMenuField sizing are working.

The user may, however, wish to set the max content width of the menu
bar of a BMenuField themselves like so:

menuField->MenuBar()->SetMaxContentWidth(width);

and the Interface Kit will automatically deduct the left and right
margins from the width including the space used by the drop down arrow.


# ca3a1c04518ebab574847a83e518c5fa407830a8 29-May-2013 John Scipione <jscipione@gmail.com>

BMenuField: If fixed size always set max content width

When you resize, also set max content width.

Create a SetMaxContentWidth() method that includes the margins.


# a1cf3ead5f5e9b2857b9622bef5bc1742fd21151 25-May-2013 John Scipione <jscipione@gmail.com>

Resize menu field if below minimum width in auto-size mode

... cancelling the normal item truncation behavior.
This funcationality comes from BeOS R5, we need to reproduce it for
backwards compat. KeymapSwitcher depends on it at least.

Minimum width is 20px, was set in last commit, comes from BeOS R5.


# 6031e62420fec7cc6c360bb210ca860a4a60e0f0 25-May-2013 John Scipione <jscipione@gmail.com>

Move constants to BMCPrivate.h and refactor

We use these constants in both MenuField.cpp and BMCPrivate.cpp

Incorporate kMarginWidth into kPopUpIndicatorWidth.

A small code simplication in FrameResized() along with replacing bare numbers
with magic constants.


# f7c092f5dbe074036566d6b37da0870e5bbded58 25-May-2013 John Scipione <jscipione@gmail.com>

Refactor _BMCMenuBar_::Draw a bit

Move the comments around, expand on them and an 80 char fix.


# 01636e8f2af4878e9181ff1a18721494e5222e75 15-May-2013 John Scipione <jscipione@gmail.com>

Adjust menu field's menu bar height in auto mode

On IRC diver pointed out to me that KeymapSwitcher had a menu field that
was drawing as just a line since my recent change to BMenuField. I did a
little research and discovered that this was because the menu field in
KeymapSwitch was not using the layout APIs and it's frame rect was set to
0 height.

I did a little more research and experimented with menu fields in
BeOS R5. I discovered that in R5 if the menu field is set to auto-size
mode then the menu bar inside ignores the height of the menu field frame
and uses the BMenuBar's preferred height instead.

So, I adjusted the BMenuField code in Haiku accordingly. This should make
Haiku match the behavior of BeOS R5 in auto-size mode. For fixed-size mode
it should also work the same, although some more testing is needed to
see if there are any regressions there.


# 298cd4c2bffa793e9d17f22f5d2d6f49c3d07a73 09-May-2013 John Scipione <jscipione@gmail.com>

BMenuField: Fix menu bar resizing in auto-size mode.

Fixes #9753 (for real this time)

Don't resize the menu field when the menu bar resizes, the menu
field stays the same size because we'll need to use it's width to
check when the menu bar width has expanded beyond its width.
Then, if the selected menu item expands the menu bar to a width
greater than the width of the menu field resize it to the menu field
width.


# ec1f08fb05e916c96194f62ff15f129b2ad66124 08-May-2013 John Scipione <jscipione@gmail.com>

Resize menu field menu bar iff fFixedSize is true

If the menu field is not fixed size than the width of the menu bar
should depend on the menu item contents so just do the default and
get the Bounds() without any extra resizing.


# e28ba280de24a60949104e5c468a4c8c8687ce8b 06-May-2013 John Scipione <jscipione@gmail.com>

BMCPrivate: Cleanup

Remove no longer needed header includes, most that I recently added
a few that were already there but just aren't needed anymore. Don't
use BPrivate::MenuPrivate namespace.


# c1a7e89fc235363e91d79eb547e92e9e16efd5e5 06-May-2013 John Scipione <jscipione@gmail.com>

Put the label truncation code back in BMenuItem.

Just a few commits ago I moved the label truncation code out of
BMenuItem and into BMCMenuBar because the truncation had to happen
outside of BMenuItem. Turns out, that wasn't true so I'm moving the
label truncation back into BMenuItem and removing the _DrawItems()
method from BMCMenuBar.

Note that the code is not a copy of what was there before, but, the
updated version I created for BMCMenuBar. The main difference is that
I use menuPrivate.Padding() instead of GetItemMargins() and I always
use the width of the parent menu frame instead of using fBounds even
if the state is not MENU_STATE_CLOSED. These are changes needed for
BMCMenuBar but should work just as well for a regular BMenu.


# c33396629144d09d2efb678e0d7f97290e69b1ac 06-May-2013 John Scipione <jscipione@gmail.com>

Draw truncated menu label in BMCPrivate, fixes #9735

...instead of in BMenuItem and remove the truncation code from BMenuItem.

The label truncation code cannot work in BMenuItem because the super
menu helpfully resizes itself to fit the menu item. So, instead we do the label
truncation in BMCPrivate making sure that BMenuItem there can't expand the
BMCMenuBar because we set the width to fMenuField->_MenuBarWidth()
explicity.

Note that this only truncates the label in BMCMenuField, i.e. the label inside
the menufield, it does nothing to the labels of the menu items in the attached
BMenu or BPopUpMenu which is exactly what we want.


# 1afff67178d334197c16354e8a704d99d2fded51 06-May-2013 John Scipione <jscipione@gmail.com>

Set some static variables for magic number constants


# 2bf1592a70d3f413132a0357213aa6be64077c5e 06-May-2013 John Scipione <jscipione@gmail.com>

Rework layout-enabled contructor for BMCMenuBar

Was passing !fixedSize into the view flags of BMenuBar, which made no sense.
Stop doing that, set fixedSize to true instead.

Remove the fixedSize parameter from this contructor, it's too late for that.


# 6c1452071c4b2220dcf554213c3cd1787f93f8e4 06-May-2013 John Scipione <jscipione@gmail.com>

Remove pre-ControlLook drawing code in menu classes


# d218f0f822babcbc2b1dd15880440638c8ffe5b7 06-May-2013 John Scipione <jscipione@gmail.com>

Put the BMenuBar initilization on it's own line


# d5c51ba6768d7ffd5bb983af9ab97b6372eae134 06-May-2013 John Scipione <jscipione@gmail.com>

Update header comments


# d97b43406038a6398e097939b71908ff490c64ff 06-May-2013 John Scipione <jscipione@gmail.com>

Style fixes to BMenu and related classes.


# 57c5b09e1a3d0f36f94cbab11c96842d782b8eaf 05-Aug-2012 Ryan Leavengood <leavengood@gmail.com>

Use be_control_look != NULL everywhere in the Interface Kit.

Should not be a functional change. It is not in the Haiku Coding Guidelines but
I feel like 'if (object != NULL)' is generally preferred to 'if (object)', plus
in this case of be_control_look that is the more common style.


# 6a03786cc9918b43c7695cc2349e77eb3193e922 28-Jul-2012 Ryan Leavengood <leavengood@gmail.com>

Draw menus using the user chosen colors.


# 50f8cd14bb40895f9167f44752525386af219513 07-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.
* Remove superfluous operator=() implementations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32174 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d82ea8abda884c8de54ca487c9993a7080310340 07-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Only take the popup marker into account if fShowPopUpMarker is true.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32173 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01592a405784dc77542a58a9f312d56030a734c5 06-Aug-2009 Rene Gollent <anevilyak@gmail.com>

Fix small style violation.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 102a66c3f6101acacf6e3fcbdd6ac928e9e3a604 06-Aug-2009 Rene Gollent <anevilyak@gmail.com>

BMenuField's private menu bar did not take into account the width of the popup indicator when computing its minimum size. Fixes ticket #3635.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32171 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 681c2e4425073000c01c9c97237d2615d226f401 25-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

The button and menu field draw routines take a background color into account,
which makes the resessed frame blend better with the surroundings. This can
be seen best in Keymap, where a different color is set on some buttons, but
the resessed frame should still be the same across all those buttons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29716 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94e66d170f3c9e07a94dc1cd3f07e4038240c3bb 25-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed recently introduced regressions with layouted BMenuFields. When passing
fixedSize=true to the private BMenuBar class, it would set the follow mode
in AttachedToWindow() such that BMenu would calculate the minimum width
differently. Also fixes ticket #3606.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29691 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31852cb13e991ab5e9537fd5b6dad29647f16d4e 22-Mar-2009 Stephan Aßmus <superstippi@gmx.de>

Various fixes to BMenuField behavior:
* In layout mode, using a BMenuField directly will make it behave like using
a fixed size BMenuField in non-layout mode. This is open for debate, but
not a change to the previous behavior. When using the Label and MenuBar-
LayoutItems though, the behavior is now changed to be more what one would
expect, ie the BMenuBar part is layouted across the full available width
just like it happens with BTextControls.
* Fixed invalidation of the BMenuBar when it auto-resizes according to picking
another item, and when it is resized due to layout changes.
* Fixed the problem with growing BMenuFields in file panels after changing
folders the first time. The fix is not so nice, but the purpose of setting
the menu item margins is to make sure it renders at the same vertical
offset as the BMenuField label. The better fix would be to change the
calculation of the content location or required margins in the BMenuItem
code... however the BMCPrivate code needs to account for the popup indicator
in the margins so I just kept the fix for the offset there as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29650 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f86ba45579bdc9648b232175f87edc62ab71b54 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented a new look for the Haiku interface controls. It was
overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0095fe722a4c08b59aff3d863a740f37b5f00562 14-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Added a comment about the purpose of the code in AttachedToWindow().
* Improved FrameResized(). The "diff" is actually between the new location
of the right side (Frame().right) and the location where it probably was
in the parent before it is resized (fMenuField->Bounds().right - 2).
Could be that this change is wrong, or at least, not yet correct. Will
test on a different machine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27507 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15b9bc4f1b4ad72c6b96d02d39c00fcbd89e2100 19-Nov-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

small cleanups


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22964 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bbe8558522a9b6b83ffa9c585d83d38acf9f86de 13-Sep-2007 Stephan Aßmus <superstippi@gmx.de>

* make absolutely sure there is no cyclic resizing


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22229 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a38a48561809f630ed89ee09acf16b79c307073 30-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* fixed size layout of BMenuBar on BMenuField in fixed size mode
(needs to account for the parts that the BMenuField draws, ie the shadow
on the right)
* fixed follow mode of BMenuBar in fixed size mode (B_FOLLOW_LEFT_RIGHT)
* don't resize the BMenuField in fixed size mode (endless loop), this should
be more robust anyways, since this endless loop would be triggered if an
application tried to manually resize menuField->MenuBar() in auto resizing
mode
* fixed calculation of the parts that need to be redrawn on resize


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bd57c145be88c15d40eb869978523956a01895a6 15-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* setting a different menu color with the menu preflet gives now visually
agreeable results (I hope)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec592aa9e56e04a312235b34ba89d707cc26aff8 19-Jun-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Implement _BMCMenuBar_::MaxSize() to override BMenuBar::MaxSize() and limit
the maximum width. The latter supports unlimited maximum width. The
_BMCMenuBar_ draws fine when resized wider than its min/preferred width, but
not the complete "button" area will cause the menu to open when being pressed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21465 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd39decc4481f8bee34c1514366c6468919369e8 28-May-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added a filter to MenuField, so that mousedown messages caught by the inner menubar are redirected to the BMenuField's MouseDown() like happens on beos. That way we can track and invalidate correctly. Implemented Show/HidePopUpMarker

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8773f97a0894317f219e347abda1379d8b54b86 10-May-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Invalidate less in BMenuBar::FrameResized() and a bit more in _BMCMenuBar_::FrameResized(), removed unused _BMCItem_

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e3d0715523c6d2b7a93dfd158339fad13162d3ea 14-Mar-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Enlarged a bit the BMCMenuBar's frame, so that it's drawn more nicely

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16795 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f282009d152d44be5245b51b95922b627b7ec828 16-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

* _BMCItem_ is no longer used, but I didn't remove it
yet, just commented it out in BMenuField. As was expected,
nothing changed in any obvious way
* made the _BMCMenuBar_ draw the popup marked. I changed it
a bit, inspired from some mockup I saw, sorry I don't
remember where. I hope you like it (it is easily changed
back if you don't).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5364573ebd8e7d385cd688ada041a5adbc90d309 14-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Partially reverted to 15464 to have less code duplication, now that the special case is handled in BMenu::CalcFrame()

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15944 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5cd88a5c7aefd98694982f25b4381b7d2417db1 13-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Small changes, nothing important

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15942 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9f970d98c9d5c3dfb544bdedf0561f83f76f1e8 11-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Yesterday's commit triggered some other visual bugs: hopefully fixed them all. A disabled menufield now doesn't open its associated menu anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 797d1a66fa05bd68a2bb475b4786af13038e9b16 10-Jan-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

menufields should default to B_ITEMS_IN_COLUMN. This fixes the workspaces menu (in Screen) opened at the wrong position. As a consequence of this, I had to change the drawing code a bit

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15892 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b98735f6d3cc32bd2a2f6c111279ea7092467c6 10-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

forgot about the right side extra room for the focus indication

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15464 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3f0aa1427cdcfdd94ca27693c163230da55ccea9 07-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

take care of resizing and cleaning up parent BMenuField in FrameResized(), fixes missing areas in Fonts and most likely other BMenuFields

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15413 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0a95bea66d370459d9a0d7712f2dcbcdaa8eb00c 06-Dec-2005 Stephan Aßmus <superstippi@gmx.de>

fixed wrong usage of ConstrainClippingRegion() introduced by myself a couple months ago

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15374 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e6a5805ba8db3b072d81257cc44f966def5fd37 05-Jul-2005 Stephan Aßmus <superstippi@gmx.de>

MenuField layouts the menu bar better with respect to fDivider, it aligns better with other controls. fDivider in TextControl is an integer number now, small fix and small cleanup in Menu, Window::InitData takes an optional BBitmap token to construct an offscreen window, fixed PrivateScreen IndexForColor, View prevents being located at fractional coordinates as in R5, BBitmap unlocks its offscreen window since it is never Show()n and needs manual unlocking, fixed Slider offscreen window mode and improved triange thumb drawing, ScrollView would not crash when passing a NULL target just for kicks, the private MenuBar class now implements Draw to draw itself a little differently inside the BMenuField (dark right and bottom side) - though how it currently sets the clipping region prevents the text controls to draw in Playground, needs fixing

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13450 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ea7a8928a55a7ed67c4f9252a03c749ea31fe3a 16-Jun-2003 Marc Flerackers <mflerackers@nowhere.fake>

BMenuField


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3542 a95241bf-73f2-0310-859d-f6bbb57e9c96