diff --git a/headers/private/interface/MenuPrivate.h b/headers/private/interface/MenuPrivate.h index eb78dd44c1..7b329f766c 100644 --- a/headers/private/interface/MenuPrivate.h +++ b/headers/private/interface/MenuPrivate.h @@ -16,6 +16,7 @@ enum menu_states { MENU_STATE_CLOSED = 5 }; +class BBitmap; class BMenu; class BWindow; @@ -45,10 +46,22 @@ public: void InvokeItem(BMenuItem *item, bool now = false); void QuitTracking(bool thisMenuOnly = true); + static status_t CreateBitmaps(); + static void DeleteBitmaps(); + + static const BBitmap *MenuItemCommand(); + static const BBitmap *MenuItemControl(); + static const BBitmap *MenuItemOption(); + static const BBitmap *MenuItemShift(); private: BMenu *fMenu; }; +extern BBitmap *gMenuItemAlt; +extern BBitmap *gMenuItemControl; +extern BBitmap *gMenuItemOption; +extern BBitmap *gMenuItemShift; + }; extern const char *kEmptyMenuLabel; diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 32a6410279..a42e8582b5 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -951,8 +952,9 @@ _init_interface_kit_() be_control_look = new BControlLook(); _init_global_fonts_(); - + BPrivate::gWidthBuffer = new BPrivate::WidthBuffer; + BPrivate::MenuPrivate::CreateBitmaps(); _menu_info_ptr_ = &BMenu::sMenuInfo; @@ -973,6 +975,8 @@ _init_interface_kit_() extern "C" status_t _fini_interface_kit_() { + BPrivate::MenuPrivate::DeleteBitmaps(); + delete BPrivate::gWidthBuffer; BPrivate::gWidthBuffer = NULL; diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index b84c649304..3bd1e707bc 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -76,6 +77,11 @@ public: }; +BBitmap *gMenuItemAlt; +BBitmap *gMenuItemControl; +BBitmap *gMenuItemOption; +BBitmap *gMenuItemShift; + } // namespace BPrivate @@ -83,6 +89,66 @@ menu_info BMenu::sMenuInfo; bool BMenu::sAltAsCommandKey; +const unsigned char kCtrlBits[] = { + 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 +}; + + +const unsigned char kAltBits[] = { + 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 +}; + + +const unsigned char kOptBits[] = { + 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 +}; + + +const unsigned char kShiftBits[] = { + 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, + 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, + 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 +}; + + static property_info sPropList[] = { { "Enabled", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 }, "Returns true if menu or menu item is enabled; false " @@ -348,16 +414,20 @@ BMenu::AttachedToWindow() { BView::AttachedToWindow(); - sAltAsCommandKey = true; + // TODO: Move into init_interface_kit(). + // Currently we can't do that, as get_key_map() blocks forever + // when called there. Probably because the BApplication isn't yet + // initialized, or running. + BMenu::sAltAsCommandKey = true; key_map *keys = NULL; char *chars = NULL; get_key_map(&keys, &chars); if (keys == NULL || keys->left_command_key != 0x5d || keys->left_control_key != 0x5c) - sAltAsCommandKey = false; + BMenu::sAltAsCommandKey = false; free(chars); free(keys); - + BMenuItem *superItem = Superitem(); BMenu *superMenu = Supermenu(); if (AddDynamicItem(B_INITIAL_ADD)) { @@ -2256,12 +2326,14 @@ BMenu::_CalcFrame(BPoint where, bool *scrollOn) void BMenu::_DrawItems(BRect updateRect) { + bigtime_t start = system_time(); int32 itemCount = fItems.CountItems(); for (int32 i = 0; i < itemCount; i++) { BMenuItem *item = ItemAt(i); if (item->Frame().Intersects(updateRect)) item->Draw(); } + printf("BMenu::_DrawItems() took %lld usecs\n", system_time() - start); } @@ -2879,4 +2951,79 @@ MenuPrivate::QuitTracking(bool thisMenuOnly) fMenu->_QuitTracking(thisMenuOnly); } + +/* static */ +status_t +MenuPrivate::CreateBitmaps() +{ + BRect smallRect(0, 0, 16, 10); + BRect largeRect(0, 0, 21, 10); + + gMenuItemAlt = new BBitmap(smallRect, B_CMAP8); + gMenuItemControl = new BBitmap(smallRect, B_CMAP8); + gMenuItemOption = new BBitmap(smallRect, B_CMAP8); + gMenuItemShift = new BBitmap(largeRect, B_CMAP8); + + gMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits), + 17, 0, B_CMAP8); + gMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits), + 17, 0, B_CMAP8); + gMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits), + 17, 0, B_CMAP8); + gMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits), + 22, 0, B_CMAP8); + + return B_OK; +} + + +/* static */ +void +MenuPrivate::DeleteBitmaps() +{ + delete gMenuItemAlt; + delete gMenuItemControl; + delete gMenuItemOption; + delete gMenuItemShift; +} + + +/* static */ +const BBitmap * +MenuPrivate::MenuItemCommand() +{ + if (BMenu::sAltAsCommandKey) + return gMenuItemAlt; + + return gMenuItemControl; +} + + +/* static */ +const BBitmap * +MenuPrivate::MenuItemControl() +{ + if (BMenu::sAltAsCommandKey) + return gMenuItemControl; + + return gMenuItemAlt; +} + + +/* static */ +const BBitmap * +MenuPrivate::MenuItemOption() +{ + return gMenuItemOption; +} + + +/* static */ +const BBitmap * +MenuPrivate::MenuItemShift() +{ + return gMenuItemShift; +} + + } // namespace BPrivate diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 3b5a36a39a..de17e05109 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -26,64 +26,6 @@ #include "utf8_functions.h" -const unsigned char kCtrlBits[] = { - 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, - 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 -}; - - -const unsigned char kAltBits[] = { - 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, - 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 -}; - - -const unsigned char kOptBits[] = { - 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, - 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 -}; - - -const unsigned char kShiftBits[] = { - 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14, - 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14, - 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14, - 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 -}; const float kLightBGTint = (B_LIGHTEN_1_TINT + B_LIGHTEN_1_TINT + B_NO_TINT) / 3.0; @@ -790,46 +732,32 @@ BMenuItem::_DrawShortcutSymbol() where.y += (fBounds.Height() - 11) / 2 - 1; where.x -= 4; - const bool altCommandKey = MenuPrivate(fSuper).IsAltCommandKey(); if (fModifiers & B_COMMAND_KEY) { - BRect rect(0,0,16,10); - BBitmap control(rect, B_CMAP8); - - if (altCommandKey) - control.ImportBits(kAltBits, sizeof(kAltBits), 17, 0, B_CMAP8); - else - control.ImportBits(kCtrlBits, sizeof(kCtrlBits), 17, 0, B_CMAP8); - + const BBitmap *command = MenuPrivate::MenuItemCommand(); + const BRect &rect = command->Bounds(); where.x -= rect.Width() + 1; - fSuper->DrawBitmap(&control, where); + fSuper->DrawBitmap(command, where); } if (fModifiers & B_CONTROL_KEY) { - BRect rect(0,0,16,10); - BBitmap control(rect, B_CMAP8); - - if (altCommandKey) - control.ImportBits(kCtrlBits, sizeof(kCtrlBits), 17, 0, B_CMAP8); - else - control.ImportBits(kAltBits, sizeof(kAltBits), 17, 0, B_CMAP8); + const BBitmap *control = MenuPrivate::MenuItemControl(); + const BRect &rect = control->Bounds(); where.x -= rect.Width() + 1; - fSuper->DrawBitmap(&control, where); + fSuper->DrawBitmap(control, where); } if (fModifiers & B_OPTION_KEY) { - BRect rect(0,0,16,10); - BBitmap option(rect, B_CMAP8); - option.ImportBits(kOptBits, sizeof(kOptBits), 17, 0, B_CMAP8); + const BBitmap *option = MenuPrivate::MenuItemOption(); + const BRect &rect = option->Bounds(); where.x -= rect.Width() + 1; - fSuper->DrawBitmap(&option, where); + fSuper->DrawBitmap(option, where); } if (fModifiers & B_SHIFT_KEY) { - BRect rect(0,0,21,10); - BBitmap shift(rect, B_CMAP8); - shift.ImportBits(kShiftBits, sizeof(kShiftBits), 22, 0, B_CMAP8); + const BBitmap *shift = MenuPrivate::MenuItemOption(); + const BRect &rect = shift->Bounds(); where.x -= rect.Width() + 1; - fSuper->DrawBitmap(&shift, where); + fSuper->DrawBitmap(shift, where); } }