From 557dfeeb1292aa8930a1c893316eb37bca79a986 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 23 Jun 2005 08:41:55 +0000 Subject: [PATCH] Implemented CalcFrame() and used it to limit the menu frame's size (actually, only the width for now). This shows that TruncateLabel() works. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13229 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 9997ed5cbe..d13eae1503 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1359,7 +1359,10 @@ BMenu::ItemLocInRect(BRect frame) const BRect BMenu::CalcFrame(BPoint where, bool *scrollOn) { - return BRect(); + // TODO: Improve me + BRect frame = BScreen(MenuWindow()).Frame(); + frame.left += where.x + 2; + return frame; } @@ -1664,6 +1667,13 @@ void BMenu::UpdateWindowViewSize(bool upWind) { ASSERT(fCachedMenuWindow != NULL); + + // TODO: Improve this, we already resize the menu + // in "LayoutItems()" + bool scroll; + BRect maxFrame = CalcFrame(ScreenLocation(), &scroll); + float width = min_c(Frame().Width(), maxFrame.Width()); + ResizeTo(width, Frame().Height()); if (fCachedMenuWindow != NULL) { fCachedMenuWindow->ResizeTo(Bounds().Width() + 2, Bounds().Height() + 2); fCachedMenuWindow->MoveTo(ScreenLocation());