From 7a8567e61d42a4c1aa3ecae991ad8dd3b098db44 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 30 Jul 2009 10:41:33 +0000 Subject: [PATCH] Moved MenuPrivate implementation to its own file. Made MenuPrivate.h self-contained. Adjusted other files accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31963 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/interface/MenuPrivate.h | 1 + src/kits/interface/Jamfile | 1 + src/kits/interface/Menu.cpp | 259 ----------------------- src/kits/interface/MenuItem.cpp | 2 +- src/kits/interface/MenuPrivate.cpp | 267 ++++++++++++++++++++++++ 5 files changed, 270 insertions(+), 260 deletions(-) create mode 100644 src/kits/interface/MenuPrivate.cpp diff --git a/headers/private/interface/MenuPrivate.h b/headers/private/interface/MenuPrivate.h index 7b329f766c..e0579a3e15 100644 --- a/headers/private/interface/MenuPrivate.h +++ b/headers/private/interface/MenuPrivate.h @@ -9,6 +9,7 @@ #ifndef __MENU_PRIVATE_H #define __MENU_PRIVATE_H +#include enum menu_states { MENU_STATE_TRACKING = 0, diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index b606d9d3f3..c62f3ff579 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -84,6 +84,7 @@ MergeObject interface_kit.o : MenuBar.cpp MenuField.cpp MenuItem.cpp + MenuPrivate.cpp MenuWindow.cpp OptionControl.cpp OptionPopUp.cpp diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 3bd1e707bc..2439e05f17 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -77,11 +76,6 @@ public: }; -BBitmap *gMenuItemAlt; -BBitmap *gMenuItemControl; -BBitmap *gMenuItemOption; -BBitmap *gMenuItemShift; - } // namespace BPrivate @@ -89,66 +83,6 @@ 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 " @@ -2834,196 +2768,3 @@ get_menu_info(menu_info *info) return status; } - - -// MenuPrivate -namespace BPrivate { - -MenuPrivate::MenuPrivate(BMenu *menu) - : - fMenu(menu) -{ -} - - -menu_layout -MenuPrivate::Layout() const -{ - return fMenu->Layout(); -} - - -void -MenuPrivate::ItemMarked(BMenuItem *item) -{ - fMenu->_ItemMarked(item); -} - - -void -MenuPrivate::CacheFontInfo() -{ - fMenu->_CacheFontInfo(); -} - - -float -MenuPrivate::FontHeight() const -{ - return fMenu->fFontHeight; -} - - -float -MenuPrivate::Ascent() const -{ - return fMenu->fAscent; -} - - -BRect -MenuPrivate::Padding() const -{ - return fMenu->fPad; -} - - -void -MenuPrivate::GetItemMargins(float *left, float *top, - float *right, float *bottom) const -{ - fMenu->GetItemMargins(left, top, right, bottom); -} - - -bool -MenuPrivate::IsAltCommandKey() const -{ - return fMenu->sAltAsCommandKey; -} - - -int -MenuPrivate::State(BMenuItem **item) const -{ - return fMenu->_State(item); -} - - -void -MenuPrivate::Install(BWindow *window) -{ - fMenu->_Install(window); -} - - -void -MenuPrivate::Uninstall() -{ - fMenu->_Uninstall(); -} - - -void -MenuPrivate::SetSuper(BMenu *menu) -{ - fMenu->fSuper = menu; -} - - -void -MenuPrivate::SetSuperItem(BMenuItem *item) -{ - fMenu->fSuperitem = item; -} - - -void -MenuPrivate::InvokeItem(BMenuItem *item, bool now) -{ - fMenu->_InvokeItem(item, now); -} - - -void -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 de17e05109..11880c5ccc 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/src/kits/interface/MenuPrivate.cpp b/src/kits/interface/MenuPrivate.cpp new file mode 100644 index 0000000000..81b6927f3b --- /dev/null +++ b/src/kits/interface/MenuPrivate.cpp @@ -0,0 +1,267 @@ +/* + * Copyright 2001-2009, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini (stefano.ceccherini@gmail.com) + */ + +#include + +#include +#include + +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 +}; + +namespace BPrivate { + +BBitmap *gMenuItemAlt; +BBitmap *gMenuItemControl; +BBitmap *gMenuItemOption; +BBitmap *gMenuItemShift; + +MenuPrivate::MenuPrivate(BMenu *menu) + : + fMenu(menu) +{ +} + + +menu_layout +MenuPrivate::Layout() const +{ + return fMenu->Layout(); +} + + +void +MenuPrivate::ItemMarked(BMenuItem *item) +{ + fMenu->_ItemMarked(item); +} + + +void +MenuPrivate::CacheFontInfo() +{ + fMenu->_CacheFontInfo(); +} + + +float +MenuPrivate::FontHeight() const +{ + return fMenu->fFontHeight; +} + + +float +MenuPrivate::Ascent() const +{ + return fMenu->fAscent; +} + + +BRect +MenuPrivate::Padding() const +{ + return fMenu->fPad; +} + + +void +MenuPrivate::GetItemMargins(float *left, float *top, + float *right, float *bottom) const +{ + fMenu->GetItemMargins(left, top, right, bottom); +} + + +bool +MenuPrivate::IsAltCommandKey() const +{ + return fMenu->sAltAsCommandKey; +} + + +int +MenuPrivate::State(BMenuItem **item) const +{ + return fMenu->_State(item); +} + + +void +MenuPrivate::Install(BWindow *window) +{ + fMenu->_Install(window); +} + + +void +MenuPrivate::Uninstall() +{ + fMenu->_Uninstall(); +} + + +void +MenuPrivate::SetSuper(BMenu *menu) +{ + fMenu->fSuper = menu; +} + + +void +MenuPrivate::SetSuperItem(BMenuItem *item) +{ + fMenu->fSuperitem = item; +} + + +void +MenuPrivate::InvokeItem(BMenuItem *item, bool now) +{ + fMenu->_InvokeItem(item, now); +} + + +void +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