Some cleanups: made the bitmaps static, moved variables around. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32056 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
90d0584d89
commit
dcc8ae9118
@ -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
|
||||
|
@ -173,7 +173,7 @@ static property_info sPropList[] = {
|
||||
};
|
||||
|
||||
|
||||
const char *kEmptyMenuLabel = "<empty>";
|
||||
const char *BPrivate::kEmptyMenuLabel = "<empty>";
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user