diff --git a/headers/private/interface/MenuPrivate.h b/headers/private/interface/MenuPrivate.h index e0579a3e15..d86ecfef63 100644 --- a/headers/private/interface/MenuPrivate.h +++ b/headers/private/interface/MenuPrivate.h @@ -17,11 +17,14 @@ enum menu_states { MENU_STATE_CLOSED = 5 }; + class BBitmap; class BMenu; class BWindow; namespace BPrivate { + +extern const char *kEmptyMenuLabel; class MenuPrivate { public: @@ -37,7 +40,8 @@ public: BRect Padding() const; void GetItemMargins(float *, float *, float *, float *) const; - bool IsAltCommandKey() const; + static bool IsAltCommandKey(); + int State(BMenuItem **item = NULL) const; void Install(BWindow *window); @@ -56,16 +60,16 @@ public: static const BBitmap *MenuItemShift(); private: BMenu *fMenu; -}; -extern BBitmap *gMenuItemAlt; -extern BBitmap *gMenuItemControl; -extern BBitmap *gMenuItemOption; -extern BBitmap *gMenuItemShift; + static BBitmap *sMenuItemAlt; + static BBitmap *sMenuItemControl; + static BBitmap *sMenuItemOption; + static BBitmap *sMenuItemShift; }; -extern const char *kEmptyMenuLabel; + +}; // Note: since sqrt is slow, we don't use it and return the square of the distance diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index f6788dbafd..d9db19a5a7 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -173,7 +173,7 @@ static property_info sPropList[] = { }; -const char *kEmptyMenuLabel = ""; +const char *BPrivate::kEmptyMenuLabel = ""; struct BMenu::LayoutData { @@ -2667,7 +2667,8 @@ BMenu::_UpdateWindowViewSize(bool updatePosition) } } else { _CacheFontInfo(); - window->ResizeTo(StringWidth(kEmptyMenuLabel) + fPad.left + fPad.right, + window->ResizeTo(StringWidth(BPrivate::kEmptyMenuLabel) + + fPad.left + fPad.right, fFontHeight + fPad.top + fPad.bottom); } diff --git a/src/kits/interface/MenuPrivate.cpp b/src/kits/interface/MenuPrivate.cpp index 81ec8b6fbf..d9297bea84 100644 --- a/src/kits/interface/MenuPrivate.cpp +++ b/src/kits/interface/MenuPrivate.cpp @@ -72,10 +72,12 @@ const unsigned char kShiftBits[] = { namespace BPrivate { -BBitmap *gMenuItemAlt; -BBitmap *gMenuItemControl; -BBitmap *gMenuItemOption; -BBitmap *gMenuItemShift; + +BBitmap* MenuPrivate::sMenuItemAlt; +BBitmap* MenuPrivate::sMenuItemControl; +BBitmap* MenuPrivate::sMenuItemOption; +BBitmap* MenuPrivate::sMenuItemShift; + MenuPrivate::MenuPrivate(BMenu *menu) : @@ -134,10 +136,11 @@ MenuPrivate::GetItemMargins(float *left, float *top, } +/* static */ bool -MenuPrivate::IsAltCommandKey() const +MenuPrivate::IsAltCommandKey() { - return fMenu->sAltAsCommandKey; + return BMenu::sAltAsCommandKey; } @@ -197,21 +200,21 @@ MenuPrivate::CreateBitmaps() BRect smallRect(0, 0, 16, 10); BRect largeRect(0, 0, 21, 10); try { - gMenuItemAlt = new BBitmap(smallRect, B_CMAP8); - gMenuItemControl = new BBitmap(smallRect, B_CMAP8); - gMenuItemOption = new BBitmap(smallRect, B_CMAP8); - gMenuItemShift = new BBitmap(largeRect, B_CMAP8); + sMenuItemAlt = new BBitmap(smallRect, B_CMAP8); + sMenuItemControl = new BBitmap(smallRect, B_CMAP8); + sMenuItemOption = new BBitmap(smallRect, B_CMAP8); + sMenuItemShift = new BBitmap(largeRect, B_CMAP8); } catch (...) { return B_NO_MEMORY; } - gMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits), + sMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits), 17, 0, B_CMAP8); - gMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits), + sMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits), 17, 0, B_CMAP8); - gMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits), + sMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits), 17, 0, B_CMAP8); - gMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits), + sMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits), 22, 0, B_CMAP8); return B_OK; @@ -222,10 +225,10 @@ MenuPrivate::CreateBitmaps() void MenuPrivate::DeleteBitmaps() { - delete gMenuItemAlt; - delete gMenuItemControl; - delete gMenuItemOption; - delete gMenuItemShift; + delete sMenuItemAlt; + delete sMenuItemControl; + delete sMenuItemOption; + delete sMenuItemShift; } @@ -234,9 +237,9 @@ const BBitmap * MenuPrivate::MenuItemCommand() { if (BMenu::sAltAsCommandKey) - return gMenuItemAlt; + return sMenuItemAlt; - return gMenuItemControl; + return sMenuItemControl; } @@ -245,9 +248,9 @@ const BBitmap * MenuPrivate::MenuItemControl() { if (BMenu::sAltAsCommandKey) - return gMenuItemControl; + return sMenuItemControl; - return gMenuItemAlt; + return sMenuItemAlt; } @@ -255,7 +258,7 @@ MenuPrivate::MenuItemControl() const BBitmap * MenuPrivate::MenuItemOption() { - return gMenuItemOption; + return sMenuItemOption; } @@ -263,7 +266,7 @@ MenuPrivate::MenuItemOption() const BBitmap * MenuPrivate::MenuItemShift() { - return gMenuItemShift; + return sMenuItemShift; }