SetEnabled() enables or disables the parent menu too, SetRadioMode() and SetLabelFromMarked() call each other if needed, BMenuBar::Draw() doesn't make a difference if the menubar is disabled or not, should even fix bug #87 as it was calling LayoutItems() every cycle. Work done by John Drinkwater and me

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15988 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-01-16 21:42:57 +00:00
parent 487f65913b
commit dd180e6378
2 changed files with 30 additions and 24 deletions

View File

@ -530,6 +530,14 @@ BMenu::SetEnabled(bool enabled)
{
fEnabled = enabled;
if (fSuper) {
// Can't use fSuper->SetEnabled() here, as
// it would call SetEnabled() on us again, thus
// entering an infinite loop
fSuper->fEnabled = enabled;
}
for (int32 i = 0; i < CountItems(); i++)
ItemAt(i)->SetEnabled(enabled);
}
@ -539,6 +547,8 @@ void
BMenu::SetRadioMode(bool flag)
{
fRadioMode = flag;
if (!flag)
SetLabelFromMarked(false);
}
@ -560,6 +570,8 @@ void
BMenu::SetLabelFromMarked(bool flag)
{
fDynamicName = flag;
if (flag)
SetRadioMode(true);
}
@ -935,7 +947,7 @@ BMenu::Hide()
BMenuItem *
BMenu::Track(bool openAnyway, BRect *clickToOpenRect)
{
if (IsStickyPrefOn())
if (!IsStickyPrefOn())
openAnyway = false;
SetStickyMode(openAnyway);

View File

@ -136,34 +136,28 @@ void
BMenuBar::Draw(BRect updateRect)
{
// TODO: implement additional border styles
if (IsEnabled()) {
rgb_color color = HighColor();
rgb_color color = HighColor();
BRect bounds(Bounds());
// Restore the background of the previously selected menuitem
DrawBackground(bounds & updateRect);
BRect bounds(Bounds());
// Restore the background of the previously selected menuitem
DrawBackground(bounds & updateRect);
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
StrokeLine(BPoint(bounds.right, 0.0f));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
StrokeLine(BPoint(bounds.right, 0.0f));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
BPoint(bounds.right, bounds.bottom - 1.0f));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
BPoint(bounds.right, bounds.bottom - 1.0f));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
SetHighColor(color);
// revert to previous used color (cheap PushState()/PopState())
SetHighColor(color);
// revert to previous used color (cheap PushState()/PopState())
DrawItems(updateRect);
} else {
LayoutItems(0);
Sync();
Invalidate();
}
DrawItems(updateRect);
}