diff --git a/headers/private/interface/MenuPrivate.h b/headers/private/interface/MenuPrivate.h index 8ac961e375..582f87f95a 100644 --- a/headers/private/interface/MenuPrivate.h +++ b/headers/private/interface/MenuPrivate.h @@ -8,7 +8,7 @@ enum menu_actions { }; -const static char *kEmptyMenuLabel = ""; +#define kEmptyMenuLabel "" #endif // __MENU_PRIVATE_H diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index e5642910a4..7d1a95b590 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -4090,15 +4090,13 @@ BTextView::UpdateScrollbars() void BTextView::AutoResize(bool doredraw) { - // TODO: What about fContainerView ? Should we resize it as well ? if (fResizable) { float width = 0; for (int32 i = 0; i < CountLines(); i++) width = max_c(width, LineWidth(i)); - ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines()))); - if (fContainerView) - fContainerView->ResizeTo(Bounds().Width(), Bounds().Height()); + BView *viewToResize = fContainerView != NULL ? fContainerView : this; + viewToResize->ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines()))); } } diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 6f258ef82c..df14c5b00f 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1816,7 +1816,7 @@ BMenu::UpdateWindowViewSize(bool upWind) window->ResizeTo(Bounds().Width() + 2, Bounds().Height() + 2); else { CacheFontInfo(); - window->ResizeTo(StringWidth("") + 4, fFontHeight + 6); + window->ResizeTo(StringWidth(kEmptyMenuLabel) + 5, fFontHeight + 6); } window->MoveTo(frame.LeftTop()); } diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index b62ffb3a9d..00886e9d4f 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -647,14 +647,17 @@ BMenuItem::SetSuper(BMenu *super) void -BMenuItem::Select(bool on) +BMenuItem::Select(bool selected) { + if (fSelected == selected) + return; + if (Submenu()) { - fSelected = on; - Highlight(on); + fSelected = selected; + Highlight(selected); } else if (IsEnabled()) { - fSelected = on; - Highlight(on); + fSelected = selected; + Highlight(selected); } } @@ -704,26 +707,42 @@ BMenuItem::DrawShortcutSymbol() where -= BPoint(20, 10); + // TODO: Do this in a better way + bool altAsCommandKey = true; + key_map *keys = NULL; + char *chars; + get_key_map(&keys, &chars); + if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f) + altAsCommandKey = false; + free(chars); + free(keys); + if (fModifiers & B_COMMAND_KEY) { - key_map *keys; - char *chars; - get_key_map(&keys, &chars); BRect rect(0,0,16,10); BBitmap control(rect, B_COLOR_8_BIT); - // TODO: isn't there a better way to do this? - if (keys != NULL - && keys->left_command_key == 0x5d && keys->right_command_key == 0x5f) + if (altAsCommandKey) control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT); else control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT); fSuper->DrawBitmap(&control, where); - where.x -= rect.Width(); - - free(chars); - free(keys); + where.x -= rect.Width() + 1; } + + if (fModifiers & B_CONTROL_KEY) { + BRect rect(0,0,16,10); + BBitmap control(rect, B_COLOR_8_BIT); + + if (altAsCommandKey) + control.SetBits(kCtrlBits, kCtrlLength, 0, B_COLOR_8_BIT); + else + control.SetBits(kAltBits, kAltLength, 0, B_COLOR_8_BIT); + fSuper->DrawBitmap(&control, where); + + where.x -= rect.Width() + 1; + } + if (fModifiers & B_SHIFT_KEY) { BRect rect(0,0,21,10); BBitmap shift(rect, B_COLOR_8_BIT); diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp index 562c3e3f66..ba2c910e5f 100644 --- a/src/kits/interface/MenuWindow.cpp +++ b/src/kits/interface/MenuWindow.cpp @@ -12,8 +12,9 @@ // TODO: Add scrollers #include -#include +#include +#include #include @@ -96,7 +97,7 @@ BMenuFrame::Draw(BRect updateRect) font_height height; GetFontHeight(&height); SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT)); - DrawString("", BPoint(2, ceilf(height.ascent + 2))); + DrawString(kEmptyMenuLabel, BPoint(3, ceilf(height.ascent + 2))); } SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));