From fc3a8a1c73d9d02de79d39acbba37aa3f3220d7a Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 13 Jan 2006 20:48:48 +0000 Subject: [PATCH] Fixed popup menus opened at the wrong position (mostly noticed in Installer) with a horrible hack which I can't see how to avoid git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15941 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 2708393ea6..8bd7c5b2c9 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -288,7 +289,7 @@ bool BMenu::AddItem(BMenuItem *item, int32 index) { if (fLayout == B_ITEMS_IN_MATRIX) - debugger("BMenu::AddItem(BMenuItem *, int32) this method can only" + debugger("BMenu::AddItem(BMenuItem *, int32) this method can only " "be called if the menu layout is not B_ITEMS_IN_MATRIX"); return _AddItem(item, index); @@ -299,8 +300,8 @@ bool BMenu::AddItem(BMenuItem *item, BRect frame) { if (fLayout != B_ITEMS_IN_MATRIX) - debugger("BMenu::AddItem(BMenuItem *, BRect) this method can only" - " be called if the menu layout is B_ITEMS_IN_MATRIX"); + debugger("BMenu::AddItem(BMenuItem *, BRect) this method can only " + "be called if the menu layout is B_ITEMS_IN_MATRIX"); if (!item) return false; @@ -326,7 +327,7 @@ bool BMenu::AddItem(BMenu *submenu, int32 index) { if (fLayout == B_ITEMS_IN_MATRIX) - debugger("BMenu::AddItem(BMenuItem *, int32) this method can only" + debugger("BMenu::AddItem(BMenuItem *, int32) this method can only " "be called if the menu layout is not B_ITEMS_IN_MATRIX"); BMenuItem *item = new BMenuItem(submenu); @@ -341,8 +342,8 @@ bool BMenu::AddItem(BMenu *submenu, BRect frame) { if (fLayout != B_ITEMS_IN_MATRIX) - debugger("BMenu::AddItem(BMenu *, BRect) this method can only" - " be called if the menu layout is B_ITEMS_IN_MATRIX"); + debugger("BMenu::AddItem(BMenu *, BRect) this method can only " + "be called if the menu layout is B_ITEMS_IN_MATRIX"); BMenuItem *item = new BMenuItem(submenu); item->fBounds = frame; @@ -1429,7 +1430,11 @@ BMenu::CalcFrame(BPoint where, bool *scrollOn) BMenu *superMenu = Supermenu(); BMenuItem *superItem = Superitem(); - if (superMenu == NULL || superItem == NULL) { + // TODO: Horrible hack: + // When added to a BMenuField, a BPopUpMenu is the child of + // a _BMCItem_ inside a _BMCMenuBar_ to "fake" the menu hierarchy + if (superMenu == NULL || superItem == NULL + || dynamic_cast<_BMCItem_ *>(superItem) != NULL) { // just move the window on screen if (frame.bottom > screenFrame.bottom)