diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h index 5963e7138c..c9e531f773 100644 --- a/headers/os/interface/MenuField.h +++ b/headers/os/interface/MenuField.h @@ -27,6 +27,10 @@ public: BMenuField(const char* name, const char* label, BMenu* menu, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); + BMenuField(const char* name, + const char* label, BMenu* menu, + bool fixed_size, + uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BMenuField(const char* label, BMenu* menu, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BMenuField(BMessage* data); diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 6e6ca327e4..6db8a248e2 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -179,20 +179,22 @@ _BMCMenuBar_::AttachedToWindow() void _BMCMenuBar_::Draw(BRect updateRect) { - if (fFixedSize) { - // Set the width of the menu bar because the menu bar bounds may have - // been expanded by the selected menu item. - ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height()); - } else { - // For compatability with BeOS R5: - // - Set to the minimum of the menu bar width set by the menu frame - // and the selected menu item width. - // - Set the height to the preferred height ignoring the height of the - // menu field. - float height; - BMenuBar::GetPreferredSize(NULL, &height); - ResizeTo(std::min(Bounds().Width(), fMenuField->_MenuBarWidth()), - height); + if ((Flags() & B_SUPPORTS_LAYOUT) == 0) { + if (fFixedSize) { + // Set the width of the menu bar because the menu bar bounds may have + // been expanded by the selected menu item. + ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height()); + } else { + // For compatability with BeOS R5: + // - Set to the minimum of the menu bar width set by the menu frame + // and the selected menu item width. + // - Set the height to the preferred height ignoring the height of the + // menu field. + float height; + BMenuBar::GetPreferredSize(NULL, &height); + ResizeTo(std::min(Bounds().Width(), fMenuField->_MenuBarWidth()), + height); + } } BRect rect(Bounds()); diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 870e6b446f..5c7f4f30c7 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -247,6 +247,21 @@ BMenuField::BMenuField(const char* name, const char* label, BMenu* menu, } +BMenuField::BMenuField(const char* name, const char* label, BMenu* menu, + bool fixedSize, uint32 flags) + : + BView(name, flags | B_FRAME_EVENTS) +{ + InitObject(label); + + fFixedSizeMB = fixedSize; + + _InitMenuBar(menu, BRect(0, 0, 100, 15), fixedSize); + + InitObject2(); +} + + BMenuField::BMenuField(const char* label, BMenu* menu, uint32 flags) : BView(NULL, flags | B_FRAME_EVENTS)