From 55b35fb4d5df91adca8f54d520253696873c495d Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 31 Jan 2006 23:28:19 +0000 Subject: [PATCH] Empty menus now display an '' label git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16175 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/MenuWindow.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp index 19834a9d85..562c3e3f66 100644 --- a/src/kits/interface/MenuWindow.cpp +++ b/src/kits/interface/MenuWindow.cpp @@ -71,6 +71,11 @@ BMenuFrame::AttachedToWindow() { BView::AttachedToWindow(); ResizeTo(Window()->Bounds().Width(), Window()->Bounds().Height()); + if (fMenu != NULL) { + BFont font; + fMenu->GetFont(&font); + SetFont(&font); + } } @@ -78,13 +83,20 @@ void BMenuFrame::Draw(BRect updateRect) { if (fMenu->CountItems() == 0) { + // TODO: Review this as it's a bit hacky. + // Menu has a size of 0, 0, since there are no items in it. + // So the BMenuFrame class has to fake it and draw an empty item. + // Note that we can't add a real "empty" item because then we couldn't + // tell if the item was added by us or not. + // See also BMenu::UpdateWindowViewSize() SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR)); + SetLowColor(HighColor()); FillRect(updateRect); + font_height height; - fMenu->GetFontHeight(&height); - fMenu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT)); - // TODO: This doesn't get drawn for some reason - fMenu->DrawString("", BPoint(2, ceilf(height.ascent + 2))); + GetFontHeight(&height); + SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT)); + DrawString("", BPoint(2, ceilf(height.ascent + 2))); } SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));