diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index f3fea82fc2..3fe04cdaf3 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -62,8 +62,6 @@ 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 09d99b5139..d3743b12ca 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -336,57 +336,3 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth) if (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 fb79e1bc8f..c27645e336 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -401,7 +401,22 @@ BMenuItem::DrawContent() fSuper->SetDrawingMode(B_OP_OVER); - fSuper->DrawString(fLabel); + float labelWidth; + float labelHeight; + GetContentSize(&labelWidth, &labelHeight); + + const BRect& padding = menuPrivate.Padding(); + float frameWidth = fSuper->Frame().Width() - padding.left - padding.right; + + if (frameWidth >= labelWidth) + fSuper->DrawString(fLabel); + else { + // truncate label to fit + char* truncatedLabel = new char[strlen(fLabel) + 4]; + TruncateLabel(frameWidth, truncatedLabel); + fSuper->DrawString(truncatedLabel); + delete[] truncatedLabel; + } if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) { float escapements[fTriggerIndex + 1];