[haiku-commits] haiku: hrev45636 - src/kits/interface headers

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 6 May 2013 23:23:18 +0200 (CEST)

hrev45636 adds 8 changesets to branch 'master'
old head: 3f5d1e78252bb593cf5b430f37c3d18d779afab1
new head: c33396629144d09d2efb678e0d7f97290e69b1ac
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=c333966+%5E3f5d1e7

----------------------------------------------------------------------------

d97b434: Style fixes to BMenu and related classes.

d5c51ba: Update header comments

d218f0f: Put the BMenuBar initilization on it's own line

6c14520: Remove pre-ControlLook drawing code in menu classes

2bf1592: 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.

4e1b192: Refactor BMenuField::DrawLabel()
  
  also use std::max() instead of max_c()

1afff67: Set some static variables for magic number constants

c333966: 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.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

9 files changed, 226 insertions(+), 303 deletions(-)
headers/os/interface/Menu.h            |   5 +-
headers/os/interface/MenuField.h       |   4 +-
headers/private/interface/BMCPrivate.h |  12 +-
src/kits/interface/BMCPrivate.cpp      | 218 +++++++++++++----------------
src/kits/interface/Menu.cpp            |  23 +--
src/kits/interface/MenuBar.cpp         |  42 +-----
src/kits/interface/MenuField.cpp       |  77 +++++-----
src/kits/interface/MenuItem.cpp        | 132 +++++++----------
src/kits/interface/MenuPrivate.cpp     |  16 +--

############################################################################

Commit:      d97b43406038a6398e097939b71908ff490c64ff
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d97b434
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 20:50:23 2013 UTC

Style fixes to BMenu and related classes.

----------------------------------------------------------------------------

diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h
index 4ef27a7..41a17fe 100644
--- a/headers/os/interface/Menu.h
+++ b/headers/os/interface/Menu.h
@@ -10,6 +10,7 @@
 #include <List.h>
 #include <View.h>
 
+
 class BMenu;
 class BMenuBar;
 class BMenuItem;
@@ -216,7 +217,7 @@ private:
                        void                            
_ComputeColumnLayout(int32 index, bool bestFit,
                                                                        bool 
moveItems, BRect* override, BRect& outRect);
                        void                            _ComputeRowLayout(int32 
index, bool bestFit,
-                                                                       bool 
moveItems, BRect& outRect);                
+                                                                       bool 
moveItems, BRect& outRect);
                        void                            
_ComputeMatrixLayout(BRect& outRect);
 
                        BRect                           _CalcFrame(BPoint 
where, bool* scrollOn);
diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h
index 2fba759..d58cd7a 100644
--- a/headers/os/interface/MenuField.h
+++ b/headers/os/interface/MenuField.h
@@ -35,7 +35,7 @@ public:
        virtual status_t                        Archive(BMessage* archive,
                                                                        bool 
deep = true) const;
 
-       virtual void                            Draw(BRect update);
+       virtual void                            Draw(BRect updateRect);
        virtual void                            AttachedToWindow();
        virtual void                            AllAttached();
        virtual void                            MouseDown(BPoint where);
@@ -121,7 +121,7 @@ private:
 
                        void                            InitObject(const char* 
label);
                        void                            InitObject2();
-                       void                            DrawLabel(BRect bounds, 
BRect update);
+                       void                            DrawLabel(BRect bounds, 
BRect updateRect);
        static  void                            InitMenu(BMenu* menu);
 
                        int32                           _MenuTask();
diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 56c4efa..25bfe20 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -271,7 +271,6 @@ _BMCMenuBar_::FrameResized(float width, float height)
                        dirty = Bounds();
                        dirty.left = dirty.right - diff - 12;
                        Invalidate(dirty);
-
                } else if (diff < 0) {
                        // clean up the dirty right line of
                        // the menu field when shrinking
@@ -295,6 +294,7 @@ _BMCMenuBar_::FrameResized(float width, float height)
                diff = Frame().right + 2 - fMenuField->Bounds().right;
                fMenuField->ResizeBy(diff, 0.0);
        }
+
        BMenuBar::FrameResized(width, height);
 }
 
diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp
index e7049cf..76e1eb3 100644
--- a/src/kits/interface/Menu.cpp
+++ b/src/kits/interface/Menu.cpp
@@ -733,7 +733,7 @@ BMenu::AddItem(BMenuItem* item, BRect frame)
                        "be called if the menu layout is B_ITEMS_IN_MATRIX");
        }
 
-       if (!item)
+       if (item == NULL)
                return false;
 
        item->fBounds = frame;
@@ -758,7 +758,7 @@ bool
 BMenu::AddItem(BMenu* submenu)
 {
        BMenuItem* item = new (nothrow) BMenuItem(submenu);
-       if (!item)
+       if (item == NULL)
                return false;
 
        if (!AddItem(item, CountItems())) {
@@ -780,7 +780,7 @@ BMenu::AddItem(BMenu* submenu, int32 index)
        }
 
        BMenuItem* item = new (nothrow) BMenuItem(submenu);
-       if (!item)
+       if (item == NULL)
                return false;
 
        if (!AddItem(item, index)) {
@@ -802,7 +802,7 @@ BMenu::AddItem(BMenu* submenu, BRect frame)
        }
 
        BMenuItem* item = new (nothrow) BMenuItem(submenu);
-       if (!item)
+       if (item == NULL)
                return false;
 
        if (!AddItem(item, frame)) {
@@ -2848,7 +2848,8 @@ BMenu::_UpdateWindowViewSize(const bool &move)
                return;
 
        bool scroll = false;
-       const BPoint screenLocation = move ? ScreenLocation() : 
window->Frame().LeftTop();
+       const BPoint screenLocation = move ? ScreenLocation()
+               : window->Frame().LeftTop();
        BRect frame = _CalcFrame(screenLocation, &scroll);
        ResizeTo(frame.Width(), frame.Height());
 
@@ -3024,4 +3025,3 @@ 
B_IF_GCC_2(InvalidateLayout__5BMenub,_ZN5BMenu16InvalidateLayoutEb)(
 {
        menu->InvalidateLayout();
 }
-
diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp
index 31aacbd..bda34a2 100644
--- a/src/kits/interface/MenuField.cpp
+++ b/src/kits/interface/MenuField.cpp
@@ -353,12 +353,12 @@ BMenuField::AllUnarchived(const BMessage* from)
 
 
 void
-BMenuField::Draw(BRect update)
+BMenuField::Draw(BRect updateRect)
 {
        BRect bounds(Bounds());
        bool active = IsFocus() && Window()->IsActive();
 
-       DrawLabel(bounds, update);
+       DrawLabel(bounds, updateRect);
 
        BRect frame(fMenuBar->Frame());
 
@@ -370,7 +370,7 @@ BMenuField::Draw(BRect update)
                flags |= BControlLook::B_DISABLED;
        if (active)
                flags |= BControlLook::B_FOCUSED;
-       be_control_look->DrawMenuFieldFrame(this, frame, update, base,
+       be_control_look->DrawMenuFieldFrame(this, frame, updateRect, base,
                background, flags);
 }
 
@@ -423,7 +423,7 @@ BMenuField::MouseDown(BPoint where)
        fMenuBar->StartMenuBar(-1, false, true, &bounds);
 
        fMenuTaskID = spawn_thread((thread_func)_thread_entry,
-                               "_m_task_", B_NORMAL_PRIORITY, this);
+               "_m_task_", B_NORMAL_PRIORITY, this);
        if (fMenuTaskID >= 0)
                resume_thread(fMenuTaskID);
 }
@@ -473,9 +473,9 @@ BMenuField::MakeFocus(bool state)
 
 
 void
-BMenuField::MessageReceived(BMessage* msg)
+BMenuField::MessageReceived(BMessage* message)
 {
-       BView::MessageReceived(msg);
+       BView::MessageReceived(message);
 }
 
 
@@ -980,7 +980,7 @@ BMenuField::InitObject2()
 
 
 void
-BMenuField::DrawLabel(BRect bounds, BRect update)
+BMenuField::DrawLabel(BRect bounds, BRect updateRect)
 {
        CALLED();
 
@@ -1107,8 +1107,8 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool 
fixedSize)
        fMenu = menu;
        InitMenu(menu);
 
-       if ((Flags() & B_SUPPORTS_LAYOUT)) {
-               fMenuBar = new _BMCMenuBar_(fixedSize, this);
+       if ((Flags() & B_SUPPORTS_LAYOUT) != 0) {
+               fMenuBar = new _BMCMenuBar_(this);
        } else {
                frame.left = _MenuBarOffset();
                frame.top = kVMargin;
@@ -1147,7 +1147,7 @@ BMenuField::_InitMenuBar(const BMessage* archive)
                fFixedSizeMB = fixed;
 
        fMenuBar = (BMenuBar*)FindView("_mc_mb_");
-       if (!fMenuBar) {
+       if (fMenuBar == NULL) {
                _InitMenuBar(new BMenu(""), BRect(0, 0, 100, 15), fFixedSizeMB);
                InitObject2();
        } else {
@@ -1194,8 +1194,8 @@ BMenuField::_ValidateLayoutData()
                divider = fLayoutData->label_width + 5;
 
        // If we shan't do real layout, we let the current divider take 
influence.
-       if (!(Flags() & B_SUPPORTS_LAYOUT))
-               divider = max_c(divider, fDivider);
+       if ((Flags() & B_SUPPORTS_LAYOUT) == 0)
+               divider = std::max(divider, fDivider);
 
        // get the minimal (== preferred) menu bar size
        // TODO: BMenu::MinSize() is using the ResizeMode() to decide the
diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index 0b5f211..94d2d66 100644
--- a/src/kits/interface/MenuItem.cpp
+++ b/src/kits/interface/MenuItem.cpp
@@ -55,8 +55,8 @@ const char *kUTF8ControlMap[] = {
 
 using BPrivate::MenuPrivate;
 
-BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut,
-                                        uint32 modifiers)
+BMenuItem::BMenuItem(const char* label, BMessage* message, char shortcut,
+       uint32 modifiers)
 {
        _InitData();
        if (label != NULL)
@@ -73,7 +73,7 @@ BMenuItem::BMenuItem(const char *label, BMessage *message, 
char shortcut,
 }
 
 
-BMenuItem::BMenuItem(BMenu *menu, BMessage *message)
+BMenuItem::BMenuItem(BMenu* menu, BMessage* message)
 {
        _InitData();
        SetMessage(message);
@@ -81,7 +81,7 @@ BMenuItem::BMenuItem(BMenu *menu, BMessage *message)
 }
 
 
-BMenuItem::BMenuItem(BMessage *data)
+BMenuItem::BMenuItem(BMessage* data)
 {
        _InitData();
 
@@ -121,9 +121,9 @@ BMenuItem::BMenuItem(BMessage *data)
 
        BMessage subMessage;
        if (data->FindMessage("_submenu", &subMessage) == B_OK) {
-               BArchivable *object = instantiate_object(&subMessage);
+               BArchivable* object = instantiate_object(&subMessage);
                if (object != NULL) {
-                       BMenu *menu = dynamic_cast<BMenu *>(object);
+                       BMenu* menu = dynamic_cast<BMenu *>(object);
                        if (menu != NULL)
                                _InitMenuData(menu);
                }
@@ -131,8 +131,8 @@ BMenuItem::BMenuItem(BMessage *data)
 }
 
 
-BArchivable *
-BMenuItem::Instantiate(BMessage *data)
+BArchivable*
+BMenuItem::Instantiate(BMessage* data)
 {
        if (validate_instantiation(data, "BMenuItem"))
                return new BMenuItem(data);
@@ -142,7 +142,7 @@ BMenuItem::Instantiate(BMessage *data)
 
 
 status_t
-BMenuItem::Archive(BMessage *data, bool deep) const
+BMenuItem::Archive(BMessage* data, bool deep) const
 {
        status_t ret = BArchivable::Archive(data, deep);
 
@@ -217,7 +217,7 @@ BMenuItem::SetEnabled(bool state)
        if (fSubmenu != NULL)
                fSubmenu->SetEnabled(state);
 
-       BMenu *menu = Menu();
+       BMenu* menu = fSuper;
        if (menu != NULL && menu->LockLooper()) {
                menu->Invalidate(fBounds);
                menu->UnlockLooper();
@@ -230,8 +230,8 @@ BMenuItem::SetMarked(bool state)
 {
        fMark = state;
 
-       if (state && Menu() != NULL) {
-               MenuPrivate priv(Menu());
+       if (state && fSuper != NULL) {
+               MenuPrivate priv(fSuper);
                priv.ItemMarked(this);
        }
 }
@@ -292,7 +292,7 @@ BMenuItem::SetShortcut(char ch, uint32 modifiers)
 }
 
 
-const char *
+const char*
 BMenuItem::Label() const
 {
        return fLabel;
@@ -308,7 +308,7 @@ BMenuItem::IsEnabled() const
        if (!fEnabled)
                return false;
 
-       return fSuper ? fSuper->IsEnabled() : true;
+       return fSuper != NULL ? fSuper->IsEnabled() : true;
 }
 
 
@@ -327,7 +327,7 @@ BMenuItem::Trigger() const
 
 
 char
-BMenuItem::Shortcut(uint32 *modifiers) const
+BMenuItem::Shortcut(uint32* modifiers) const
 {
        if (modifiers)
                *modifiers = fModifiers;
@@ -336,14 +336,14 @@ BMenuItem::Shortcut(uint32 *modifiers) const
 }
 
 
-BMenu *
+BMenu*
 BMenuItem::Submenu() const
 {
        return fSubmenu;
 }
 
 
-BMenu *
+BMenu*
 BMenuItem::Menu() const
 {
        return fSuper;
@@ -369,9 +369,8 @@ BMenuItem::GetContentSize(float* width, float* height)
 
        if (width)
                *width = (float)ceil(fCachedWidth);
-       if (height) {
+       if (height)
                *height = MenuPrivate(fSuper).FontHeight();
-       }
 }
 
 
@@ -452,8 +451,7 @@ BMenuItem::Draw()
        bool selected = IsSelected();
 
        // set low color and fill background if selected
-       bool activated = selected && (enabled || Submenu())
-               /*&& fSuper->fRedrawAfterSticky*/;
+       bool activated = selected && (enabled || Submenu());
        if (activated) {
                if (be_control_look != NULL) {
                        BRect rect = Frame();
@@ -500,7 +498,7 @@ BMenuItem::Draw()
 void
 BMenuItem::Highlight(bool flag)
 {
-       Menu()->Invalidate(Frame());
+       fSuper->Invalidate(Frame());
 }
 
 
@@ -514,10 +512,9 @@ BMenuItem::IsSelected() const
 BPoint
 BMenuItem::ContentLocation() const
 {
-       const BRect &padding = MenuPrivate(fSuper).Padding();
+       const BRect& padding = MenuPrivate(fSuper).Padding();
 
-       return BPoint(fBounds.left + padding.left,
-               fBounds.top + padding.top);
+       return BPoint(fBounds.left + padding.left, fBounds.top + padding.top);
 }
 
 
@@ -532,7 +529,7 @@ BMenuItem::BMenuItem(const BMenuItem &)
 }
 
 
-BMenuItem &
+BMenuItem&
 BMenuItem::operator=(const BMenuItem &)
 {
        return *this;
@@ -559,13 +556,13 @@ BMenuItem::_InitData()
 
 
 void
-BMenuItem::_InitMenuData(BMenu *menu)
+BMenuItem::_InitMenuData(BMenu* menu)
 {
        fSubmenu = menu;
 
        MenuPrivate(fSubmenu).SetSuperItem(this);
 
-       BMenuItem *item = menu->FindMarked();
+       BMenuItem* item = menu->FindMarked();
 
        if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL)
                SetLabel(item->Label());
@@ -575,11 +572,10 @@ BMenuItem::_InitMenuData(BMenu *menu)
 
 
 void
-BMenuItem::Install(BWindow *window)
+BMenuItem::Install(BWindow* window)
 {
-       if (fSubmenu) {
+       if (fSubmenu != NULL)
                MenuPrivate(fSubmenu).Install(window);
-       }
 
        fWindow = window;
 
@@ -592,7 +588,7 @@ BMenuItem::Install(BWindow *window)
 
 
 status_t
-BMenuItem::Invoke(BMessage *message)
+BMenuItem::Invoke(BMessage* message)
 {
        if (!IsEnabled())
                return B_ERROR;
@@ -606,21 +602,21 @@ BMenuItem::Invoke(BMessage *message)
        BMessage clone(kind);
        status_t err = B_BAD_VALUE;
 
-       if (!message && !notify)
+       if (message == NULL && !notify)
                message = Message();
 
-       if (!message) {
+       if (message == NULL) {
                if (!fSuper->IsWatched())
                        return err;
        } else
                clone = *message;
 
-       clone.AddInt32("index", Menu()->IndexOf(this));
+       clone.AddInt32("index", fSuper->IndexOf(this));
        clone.AddInt64("when", (int64)system_time());
        clone.AddPointer("source", this);
        clone.AddMessenger("be:sender", BMessenger(fSuper));
 
-       if (message)
+       if (message != NULL)
                err = BInvoker::Invoke(&clone);
 
 //     TODO: assynchronous messaging
@@ -633,30 +629,31 @@ BMenuItem::Invoke(BMessage *message)
 void
 BMenuItem::Uninstall()
 {
-       if (fSubmenu != NULL) {
+       if (fSubmenu != NULL)
                MenuPrivate(fSubmenu).Uninstall();
-       }
 
        if (Target() == fWindow)
                SetTarget(BMessenger());
 
        if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) != 0
-               && fWindow != NULL)
+               && fWindow != NULL) {
                fWindow->RemoveShortcut(fShortcutChar, fModifiers);
+       }
 
        fWindow = NULL;
 }
 
 
 void
-BMenuItem::SetSuper(BMenu *super)
+BMenuItem::SetSuper(BMenu* super)
 {
-       if (fSuper != NULL && super != NULL)
-               debugger("Error - can't add menu or menu item to more than 1 
container (either menu or menubar).");
+       if (fSuper != NULL && super != NULL) {
+               debugger("Error - can't add menu or menu item to more than 1 
container"
+                       " (either menu or menubar).");
+       }
 
-       if (fSubmenu != NULL) {
+       if (fSubmenu != NULL)
                MenuPrivate(fSubmenu).SetSuper(super);
-       }
 
        fSuper = super;
 }
@@ -668,7 +665,7 @@ BMenuItem::Select(bool selected)
        if (fSelected == selected)
                return;
 
-       if (Submenu() || IsEnabled()) {
+       if (Submenu() != NULL || IsEnabled()) {
                fSelected = selected;
                Highlight(selected);
        }
@@ -717,7 +714,7 @@ BMenuItem::_DrawMarkSymbol()
 void
 BMenuItem::_DrawShortcutSymbol()
 {
-       BMenu *menu = Menu();
+       BMenu* menu = fSuper;
        BFont font;
        menu->GetFont(&font);
        BPoint where = ContentLocation();
diff --git a/src/kits/interface/MenuPrivate.cpp 
b/src/kits/interface/MenuPrivate.cpp
index 41303e6..7e2d80f 100644
--- a/src/kits/interface/MenuPrivate.cpp
+++ b/src/kits/interface/MenuPrivate.cpp
@@ -97,7 +97,7 @@ BBitmap* MenuPrivate::sMenuItemAlt;
 BBitmap* MenuPrivate::sMenuItemMenu;
 
 
-MenuPrivate::MenuPrivate(BMenu *menu)
+MenuPrivate::MenuPrivate(BMenu* menu)
        :
        fMenu(menu)
 {
@@ -147,22 +147,22 @@ MenuPrivate::Padding() const
 
 
 void
-MenuPrivate::GetItemMargins(float *left, float *top,
-                                       float *right, float *bottom) const
+MenuPrivate::GetItemMargins(float* left, float* top, float* right,
+       float* bottom) const
 {
        fMenu->GetItemMargins(left, top, right, bottom);
 }
 
 
 int
-MenuPrivate::State(BMenuItem **item) const
+MenuPrivate::State(BMenuItem** item) const
 {
        return fMenu->_State(item);
 }
 
 
 void
-MenuPrivate::Install(BWindow *window)
+MenuPrivate::Install(BWindow* window)
 {
        fMenu->_Install(window);
 }
@@ -176,21 +176,21 @@ MenuPrivate::Uninstall()
 
 
 void
-MenuPrivate::SetSuper(BMenu *menu)
+MenuPrivate::SetSuper(BMenu* menu)
 {
        fMenu->fSuper = menu;
 }
 
 
 void
-MenuPrivate::SetSuperItem(BMenuItem *item)
+MenuPrivate::SetSuperItem(BMenuItem* item)
 {
        fMenu->fSuperitem = item;
 }
 
 
 void
-MenuPrivate::InvokeItem(BMenuItem *item, bool now)
+MenuPrivate::InvokeItem(BMenuItem* item, bool now)
 {
        fMenu->_InvokeItem(item, now);
 }

############################################################################

Commit:      d5c51ba6768d7ffd5bb983af9ab97b6372eae134
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d5c51ba
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 20:53:21 2013 UTC

Update header comments

----------------------------------------------------------------------------

diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h
index 41a17fe..bbca5c4 100644
--- a/headers/os/interface/Menu.h
+++ b/headers/os/interface/Menu.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2009, Haiku, Inc. All rights reserved.
+ * Copyright 2007-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
 #ifndef _MENU_H
diff --git a/headers/private/interface/BMCPrivate.h 
b/headers/private/interface/BMCPrivate.h
index f8ff703..dd59c70 100644
--- a/headers/private/interface/BMCPrivate.h
+++ b/headers/private/interface/BMCPrivate.h
@@ -1,10 +1,11 @@
 /*
- * Copyright 2001-2009 Haiku, Inc. All rights reserved.
+ * Copyright 2001-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Marc Flerackers (mflerackers@xxxxxxxxxx)
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Marc Flerackers, mflerackers@xxxxxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 #ifndef _BMC_PRIVATE_H
 #define _BMC_PRIVATE_H
diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 25bfe20..512f69b 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -1,10 +1,11 @@
 /*
- * Copyright 2001-2009 Haiku, Inc. All rights reserved.
+ * Copyright 2001-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Marc Flerackers (mflerackers@xxxxxxxxxx)
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Marc Flerackers, mflerackers@xxxxxxxxxx
+ *             John Scipione, jcipione@xxxxxxxxx
  */
 
 
diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp
index 76e1eb3..3b7bb02 100644
--- a/src/kits/interface/Menu.cpp
+++ b/src/kits/interface/Menu.cpp
@@ -1,12 +1,13 @@
 /*
- * Copyright 2001-2011, Haiku Inc. All rights reserved.
+ * Copyright 2001-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT license.
  *
  * Authors:
- *             Marc Flerackers (mflerackers@xxxxxxxxxx)
- *             Stefano Ceccherini (stefano.ceccherini@xxxxxxxxx)
- *             Rene Gollent (anevilyak@xxxxxxxxx)
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Stefano Ceccherini, stefano.ceccherini@xxxxxxxxx
+ *             Marc Flerackers, mflerackers@xxxxxxxxxx
+ *             Rene Gollent, anevilyak@xxxxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 
 
diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index 94d2d66..7d2565a 100644
--- a/src/kits/interface/MenuItem.cpp
+++ b/src/kits/interface/MenuItem.cpp
@@ -1,12 +1,13 @@
 /*
- * Copyright 2001-2008, Haiku, Inc.
+ * Copyright 2001-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Marc Flerackers (mflerackers@xxxxxxxxxx)
- *             Bill Hayden (haydentech@xxxxxxxxxxxxxxxxxxxxx)
- *             Stefano Ceccherini (stefano.ceccherini@xxxxxxxxx)
+ *             Stefano Ceccherini, stefano.ceccherini@xxxxxxxxx
+ *             Marc Flerackers, mflerackers@xxxxxxxxxx
+ *             Bill Hayden, haydentech@xxxxxxxxxxxxxxxxxxxxx
  *             Olivier Milla
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 
 //!    Display item for BMenu class

############################################################################

Commit:      d218f0f822babcbc2b1dd15880440638c8ffe5b7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d218f0f
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 20:54:30 2013 UTC

Put the BMenuBar initilization on it's own line

----------------------------------------------------------------------------

diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 512f69b..78f769c 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -82,7 +82,8 @@ _BMCMenuBar_::_BMCMenuBar_(bool fixedSize, BMenuField* 
menuField)
 
 
 _BMCMenuBar_::_BMCMenuBar_(BMessage* data)
-       :       BMenuBar(data),
+       :
+       BMenuBar(data),
        fMenuField(NULL),
        fFixedSize(true),
        fRunner(NULL),

############################################################################

Commit:      6c1452071c4b2220dcf554213c3cd1787f93f8e4
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6c14520
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 20:56:32 2013 UTC

Remove pre-ControlLook drawing code in menu classes

----------------------------------------------------------------------------

diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 78f769c..b6e6ef9 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -136,119 +136,24 @@ _BMCMenuBar_::AttachedToWindow()
 void
 _BMCMenuBar_::Draw(BRect updateRect)
 {
-       if (be_control_look != NULL) {
-               BRect rect(Bounds());
-               rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
-               uint32 flags = 0;
-               if (!IsEnabled())
-                       flags |= BControlLook::B_DISABLED;
-               if (IsFocus())
-                       flags |= BControlLook::B_FOCUSED;
-               be_control_look->DrawMenuFieldBackground(this, rect,
-                       updateRect, base, fShowPopUpMarker, flags);
-
-               _DrawItems(updateRect);
-
-               return;
-       }
-
-       if (!fShowPopUpMarker) {
-               BMenuBar::Draw(updateRect);
-               return;
-       }
-
-       // draw the right side with the popup marker
-
-       // prevent the original BMenuBar's Draw from
-       // drawing in those parts
-       BRect bounds(Bounds());
-       bounds.right -= 10.0;
-       bounds.bottom -= 1.0;
-
-       BRegion clipping(bounds);
-       ConstrainClippingRegion(&clipping);
-
-       BMenuBar::Draw(updateRect);
-
-       // restore clipping
-       ConstrainClippingRegion(NULL);
-       bounds.right += 10.0;
-       bounds.bottom += 1.0;
-
-       // prepare some colors
-       rgb_color normalNoTint = LowColor();
-       rgb_color noTint = tint_color(normalNoTint, 0.74);
-       rgb_color darken4;
-       rgb_color normalDarken4;
-       rgb_color darken1;
-       rgb_color lighten1;
-       rgb_color lighten2;
-
-       if (IsEnabled()) {
-               darken4 = tint_color(noTint, B_DARKEN_4_TINT);
-               normalDarken4 = tint_color(normalNoTint, B_DARKEN_4_TINT);
-               darken1 = tint_color(noTint, B_DARKEN_1_TINT);
-               lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT);
-               lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT);
-       } else {
-               darken4 = tint_color(noTint, B_DARKEN_2_TINT);
-               normalDarken4 = tint_color(normalNoTint, B_DARKEN_2_TINT);
-               darken1 = tint_color(noTint, (B_NO_TINT + B_DARKEN_1_TINT) / 
2.0);
-               lighten1 = tint_color(noTint, (B_NO_TINT + B_LIGHTEN_1_TINT) / 
2.0);
-               lighten2 = tint_color(noTint, B_LIGHTEN_1_TINT);
-       }
-
-       BRect r(bounds);
-       r.left = r.right - 10.0;
-
-       BeginLineArray(6);
-               // bottom below item text, darker then BMenuBar
-               // would normaly draw it
-               AddLine(BPoint(bounds.left, r.bottom),
-                               BPoint(r.left - 1.0, r.bottom), normalDarken4);
-
-               // bottom below popup marker
-               AddLine(BPoint(r.left, r.bottom),
-                               BPoint(r.right, r.bottom), darken4);
-               // right of popup marker
-               AddLine(BPoint(r.right, r.bottom - 1),
-                               BPoint(r.right, r.top), darken4);
-               // top above popup marker
-               AddLine(BPoint(r.left, r.top),
-                               BPoint(r.right - 2, r.top), lighten2);
-
-               r.top += 1;
-               r.bottom -= 1;
-               r.right -= 1;
-
-               // bottom below popup marker
-               AddLine(BPoint(r.left, r.bottom),
-                               BPoint(r.right, r.bottom), darken1);
-               // right of popup marker
-               AddLine(BPoint(r.right, r.bottom - 1),
-                               BPoint(r.right, r.top), darken1);
-       EndLineArray();
-
-       r.bottom -= 1;
-       r.right -= 1;
-       SetHighColor(noTint);
-       FillRect(r);
-
-       // popup marker
-       BPoint center(roundf((r.left + r.right) / 2.0),
-                                 roundf((r.top + r.bottom) / 2.0));
-       BPoint triangle[3];
-       triangle[0] = center + BPoint(-2.5, -0.5);
-       triangle[1] = center + BPoint(2.5, -0.5);
-       triangle[2] = center + BPoint(0.0, 2.0);
-
-       uint32 flags = Flags();
-       SetFlags(flags | B_SUBPIXEL_PRECISE);
-
-       SetHighColor(normalDarken4);
-       FillTriangle(triangle[0], triangle[1], triangle[2]);
-
-       SetFlags(flags);
+       float height;
+       GetPreferredSize(NULL, &height);
+       ResizeTo(fMenuField->_MenuBarWidth(), height);
+               // Set the width to the menu field width because the menubar
+               // bounds are expanded by the selected menu item.
+       BRect rect(Bounds());
+
+       rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
+       uint32 flags = 0;
+       if (!IsEnabled())
+               flags |= BControlLook::B_DISABLED;
+       if (IsFocus())
+               flags |= BControlLook::B_FOCUSED;
+
+       be_control_look->DrawMenuFieldBackground(this, rect,
+               updateRect, base, fShowPopUpMarker, flags);
+
+       _DrawItems(updateRect);
 }
 
 
diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp
index b582d87..987f355 100644
--- a/src/kits/interface/MenuBar.cpp
+++ b/src/kits/interface/MenuBar.cpp
@@ -279,44 +279,14 @@ BMenuBar::Draw(BRect updateRect)
                return;
        }
 
-       if (be_control_look != NULL) {
-               BRect rect(Bounds());
-               rgb_color base = LowColor();
-               uint32 flags = 0;
+       BRect rect(Bounds());
+       rgb_color base = LowColor();
+       uint32 flags = 0;
 
-               be_control_look->DrawBorder(this, rect, updateRect, base,
-                       B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
+       be_control_look->DrawBorder(this, rect, updateRect, base,
+               B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
 
-               be_control_look->DrawMenuBarBackground(this, rect, updateRect, 
base);
-
-               _DrawItems(updateRect);
-               return;
-       }
-
-       // TODO: implement additional border styles
-       rgb_color color = HighColor();
-
-       BRect bounds(Bounds());
-       // Restore the background of the previously selected menuitem
-       DrawBackground(bounds & updateRect);
-
-       rgb_color noTint = LowColor();
-
-       SetHighColor(tint_color(noTint, B_LIGHTEN_2_TINT));
-       StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
-       StrokeLine(BPoint(bounds.right, 0.0f));
-
-       SetHighColor(tint_color(noTint, B_DARKEN_1_TINT));
-       StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
-               BPoint(bounds.right, bounds.bottom - 1.0f));
-
-       SetHighColor(tint_color(noTint, B_DARKEN_2_TINT));
-       StrokeLine(BPoint(0.0f, bounds.bottom),
-               BPoint(bounds.right, bounds.bottom));
-       StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, 
bounds.bottom));
-
-       SetHighColor(color);
-               // revert to previous used color (cheap PushState()/PopState())
+       be_control_look->DrawMenuBarBackground(this, rect, updateRect, base);
 
        _DrawItems(updateRect);
 }
diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index 7d2565a..1ab2490 100644
--- a/src/kits/interface/MenuItem.cpp
+++ b/src/kits/interface/MenuItem.cpp
@@ -454,15 +454,10 @@ BMenuItem::Draw()
        // set low color and fill background if selected
        bool activated = selected && (enabled || Submenu());
        if (activated) {
-               if (be_control_look != NULL) {
-                       BRect rect = Frame();
-                       be_control_look->DrawMenuItemBackground(fSuper, rect, 
rect,
-                               ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
-                               BControlLook::B_ACTIVATED);
-               } else {
-                       
fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
-                       fSuper->FillRect(Frame(), B_SOLID_LOW);
-               }
+               BRect rect = Frame();
+               be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
+                       ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
+                       BControlLook::B_ACTIVATED);
        }
 
        // set high color

############################################################################

Commit:      2bf1592a70d3f413132a0357213aa6be64077c5e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2bf1592
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 21:00:42 2013 UTC

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.

----------------------------------------------------------------------------

diff --git a/headers/private/interface/BMCPrivate.h 
b/headers/private/interface/BMCPrivate.h
index dd59c70..3fe04cd 100644
--- a/headers/private/interface/BMCPrivate.h
+++ b/headers/private/interface/BMCPrivate.h
@@ -37,8 +37,7 @@ class _BMCMenuBar_ : public BMenuBar {
 public:
                                                                
_BMCMenuBar_(BRect frame, bool fixedSize,
                                                                        
BMenuField* menuField);
-                                                               
_BMCMenuBar_(bool fixedSize,
-                                                                       
BMenuField* menuField);
+                                                               
_BMCMenuBar_(BMenuField* menuField);
                                                                
_BMCMenuBar_(BMessage* data);
        virtual                                         ~_BMCMenuBar_();
 
diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index b6e6ef9..05e36fc 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -69,11 +69,11 @@ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, 
BMenuField* menuField)
 }
 
 
-_BMCMenuBar_::_BMCMenuBar_(bool fixedSize, BMenuField* menuField)
+_BMCMenuBar_::_BMCMenuBar_(BMenuField* menuField)
        :
-       BMenuBar("_mc_mb_", B_ITEMS_IN_ROW, !fixedSize),
+       BMenuBar("_mc_mb_", B_ITEMS_IN_ROW),
        fMenuField(menuField),
-       fFixedSize(fixedSize),
+       fFixedSize(true),
        fRunner(NULL),
        fShowPopUpMarker(true)
 {

############################################################################

Commit:      4e1b19207ad7f4ef511c0503aae9ac3e8c0e1340
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4e1b192
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 21:02:26 2013 UTC

Refactor BMenuField::DrawLabel()

also use std::max() instead of max_c()

----------------------------------------------------------------------------

diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp
index bda34a2..d82affe 100644
--- a/src/kits/interface/MenuField.cpp
+++ b/src/kits/interface/MenuField.cpp
@@ -11,6 +11,7 @@
 
 #include <MenuField.h>
 
+#include <algorithm>
 #include <stdlib.h>
 #include <string.h>
 
@@ -987,35 +988,37 @@ BMenuField::DrawLabel(BRect bounds, BRect updateRect)
        _ValidateLayoutData();
        font_height& fh = fLayoutData->font_info;
 
-       if (Label()) {
-               SetLowColor(ViewColor());
+       const char* label = Label();
+       if (label == NULL)
+               return;
 
-               // horizontal alignment
-               float x;
-               switch (fAlign) {
-                       case B_ALIGN_RIGHT:
-                               x = fDivider - fLayoutData->label_width - 3.0;
-                               break;
+       SetLowColor(ViewColor());
 
-                       case B_ALIGN_CENTER:
-                               x = fDivider - fLayoutData->label_width / 2.0;
-                               break;
+       // horizontal alignment
+       float x;
+       switch (fAlign) {
+               case B_ALIGN_RIGHT:
+                       x = fDivider - fLayoutData->label_width - 3.0;
+                       break;
 
-                       default:
-                               x = 0.0;
-                               break;
-               }
+               case B_ALIGN_CENTER:
+                       x = fDivider - fLayoutData->label_width / 2.0;
+                       break;
 
-               // vertical alignment
-               float y = Bounds().top
-                       + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2
-                       + fh.ascent;
-               y = floor(y + 0.5);
-
-               SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
-                       IsEnabled() ? B_DARKEN_MAX_TINT : 
B_DISABLED_LABEL_TINT));
-               DrawString(Label(), BPoint(x, y));
+               default:
+                       x = 0.0;
+                       break;
        }
+
+       // vertical alignment
+       float y = Bounds().top
+               + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2
+               + fh.ascent;
+       y = floor(y + 0.5);
+
+       SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
+               IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT));
+       DrawString(label, BPoint(x, y));
 }
 
 
@@ -1228,7 +1231,7 @@ BMenuField::_ValidateLayoutData()
 float
 BMenuField::_MenuBarOffset() const
 {
-       return max_c(kVMargin, fDivider + kVMargin);
+       return std::max(fDivider + kVMargin, kVMargin);
 }
 
 

############################################################################

Commit:      1afff67178d334197c16354e8a704d99d2fded51
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1afff67
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 21:04:27 2013 UTC

Set some static variables for magic number constants

----------------------------------------------------------------------------

diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 05e36fc..54240fe 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -23,6 +23,10 @@
 #include <Window.h>
 
 
+static const float kPopUpIndicatorWidth = 10.0f;
+static const float kMarginWidth = 3.0f;
+
+
 _BMCFilter_::_BMCFilter_(BMenuField* menuField, uint32 what)
        :
        BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, what),
@@ -271,7 +275,7 @@ _BMCMenuBar_::MinSize()
 
        if (fShowPopUpMarker) {
                // account for popup indicator + a few pixels margin
-               size.width += 13.0;
+               size.width += kPopUpIndicatorWidth + kMarginWidth;
        }
 
        return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
@@ -317,7 +321,9 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth)
        if (be_control_look != NULL)
                left = right = be_control_look->DefaultLabelSpacing();
 
-       SetItemMargins(left, top, right + fShowPopUpMarker ? 10 : 0, bottom);
+       SetItemMargins(left, top,
+               right + fShowPopUpMarker ? kPopUpIndicatorWidth + kMarginWidth 
: 0,
+               bottom);
 
        fPreviousWidth = Bounds().Width();
 

############################################################################

Revision:    hrev45636
Commit:      c33396629144d09d2efb678e0d7f97290e69b1ac
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c333966
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon May  6 21:13:40 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/9735

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.

----------------------------------------------------------------------------

diff --git a/headers/private/interface/BMCPrivate.h 
b/headers/private/interface/BMCPrivate.h
index 3fe04cd..f3fea82 100644
--- a/headers/private/interface/BMCPrivate.h
+++ b/headers/private/interface/BMCPrivate.h
@@ -62,6 +62,8 @@ private:
 
                        void                            _Init(bool 
setMaxContentWidth);
 
+                       void                            _DrawItems(BRect 
updateRect);
+
                        BMenuField*                     fMenuField;
                        bool                            fFixedSize;     
                        BMessageRunner*         fRunner;
diff --git a/src/kits/interface/BMCPrivate.cpp 
b/src/kits/interface/BMCPrivate.cpp
index 54240fe..09d99b5 100644
--- a/src/kits/interface/BMCPrivate.cpp
+++ b/src/kits/interface/BMCPrivate.cpp
@@ -12,16 +12,21 @@
 #include <BMCPrivate.h>
 
 #include <stdio.h>
+#include <string.h>
 
 #include <ControlLook.h>
+#include <Font.h>
 #include <LayoutUtils.h>
 #include <MenuField.h>
 #include <MenuItem.h>
 #include <Message.h>
 #include <MessageRunner.h>
 #include <Region.h>
+#include <String.h>
 #include <Window.h>
 
+#include <MenuPrivate.h>
+
 
 static const float kPopUpIndicatorWidth = 10.0f;
 static const float kMarginWidth = 3.0f;
@@ -59,6 +64,7 @@ _BMCFilter_::Filter(BMessage* message, BHandler** handler)
 
 // #pragma mark -
 
+using BPrivate::MenuPrivate;
 
 _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField)
        :
@@ -331,3 +337,56 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth)
                SetMaxContentWidth(fPreviousWidth - (left + right));
 }
 
+
+void
+_BMCMenuBar_::_DrawItems(BRect updateRect)
+{
+       MenuPrivate menuPrivate(this);
+       menuPrivate.CacheFontInfo();
+       const BRect& padding = menuPrivate.Padding();
+       float frameWidth = fMenuField->_MenuBarWidth()
+               - (padding.left + padding.right);
+       int32 itemCount = CountItems();
+
+       for (int32 i = 0; i < itemCount; i++) {
+               BMenuItem* item = ItemAt(i);
+               if (item == NULL)
+                       continue;
+
+               if (!item->Frame().Intersects(updateRect))
+                       continue;
+
+               const char* label = item->Label();
+               if (label == NULL)
+                       continue;
+
+               BPoint contentLocation(item->Frame().left + padding.left,
+                       item->Frame().top + padding.top);
+               MovePenTo(contentLocation);
+               MovePenBy(0, menuPrivate.Ascent());
+
+               if (item->IsEnabled())
+                       SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
+               else
+                       SetHighColor(tint_color(LowColor(), 
B_DISABLED_LABEL_TINT));
+
+               SetDrawingMode(B_OP_OVER);
+
+               if (frameWidth >= StringWidth(label))
+                       DrawString(label);
+               else {
+                       // truncate label to fit
+                       char* truncatedLabel = new char[strlen(label) + 4];
+                       BFont font;
+                       GetFont(&font);
+                       BString labelString(label);
+                       font.TruncateString(&labelString, B_TRUNCATE_MIDDLE, 
frameWidth);
+                       labelString.CopyInto(truncatedLabel, 0, 
labelString.Length());
+                       truncatedLabel[labelString.Length()] = '\0';
+                       DrawString(truncatedLabel);
+                       delete[] truncatedLabel;
+               }
+
+               SetDrawingMode(B_OP_COPY);
+       }
+}
diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index 1ab2490..fb79e1b 100644
--- a/src/kits/interface/MenuItem.cpp
+++ b/src/kits/interface/MenuItem.cpp
@@ -399,28 +399,9 @@ BMenuItem::DrawContent()
        fSuper->MovePenBy(0, menuPrivate.Ascent());
        BPoint lineStart = fSuper->PenLocation();
 
-       float labelWidth, labelHeight;
-       GetContentSize(&labelWidth, &labelHeight);
-
        fSuper->SetDrawingMode(B_OP_OVER);
 
-       float frameWidth = fBounds.Width();
-       if (menuPrivate.State() == MENU_STATE_CLOSED) {
-               float leftMargin;
-               float rightMargin;
-               menuPrivate.GetItemMargins(&leftMargin, NULL, &rightMargin, 
NULL);
-               frameWidth = fSuper->Frame().Width() - rightMargin + leftMargin;
-       }
-
-       if (frameWidth >= labelWidth)
-               fSuper->DrawString(fLabel);
-       else {
-               // truncate the label to fit
-               char* truncatedLabel = new char[strlen(fLabel) + 4];
-               TruncateLabel(frameWidth, truncatedLabel);
-               fSuper->DrawString(truncatedLabel);
-               delete[] truncatedLabel;
-       }
+       fSuper->DrawString(fLabel);
 
        if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) {
                float escapements[fTriggerIndex + 1];


Other related posts: