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:
@@ -17,12 +17,15 @@ enum menu_states {
|
|||||||
MENU_STATE_CLOSED = 5
|
MENU_STATE_CLOSED = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
class BWindow;
|
class BWindow;
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
extern const char *kEmptyMenuLabel;
|
||||||
|
|
||||||
class MenuPrivate {
|
class MenuPrivate {
|
||||||
public:
|
public:
|
||||||
MenuPrivate(BMenu *menu);
|
MenuPrivate(BMenu *menu);
|
||||||
@@ -37,7 +40,8 @@ public:
|
|||||||
BRect Padding() const;
|
BRect Padding() const;
|
||||||
void GetItemMargins(float *, float *, float *, float *) const;
|
void GetItemMargins(float *, float *, float *, float *) const;
|
||||||
|
|
||||||
bool IsAltCommandKey() const;
|
static bool IsAltCommandKey();
|
||||||
|
|
||||||
int State(BMenuItem **item = NULL) const;
|
int State(BMenuItem **item = NULL) const;
|
||||||
|
|
||||||
void Install(BWindow *window);
|
void Install(BWindow *window);
|
||||||
@@ -56,16 +60,16 @@ public:
|
|||||||
static const BBitmap *MenuItemShift();
|
static const BBitmap *MenuItemShift();
|
||||||
private:
|
private:
|
||||||
BMenu *fMenu;
|
BMenu *fMenu;
|
||||||
};
|
|
||||||
|
|
||||||
extern BBitmap *gMenuItemAlt;
|
static BBitmap *sMenuItemAlt;
|
||||||
extern BBitmap *gMenuItemControl;
|
static BBitmap *sMenuItemControl;
|
||||||
extern BBitmap *gMenuItemOption;
|
static BBitmap *sMenuItemOption;
|
||||||
extern BBitmap *gMenuItemShift;
|
static BBitmap *sMenuItemShift;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char *kEmptyMenuLabel;
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Note: since sqrt is slow, we don't use it and return the square of the distance
|
// 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 {
|
struct BMenu::LayoutData {
|
||||||
@@ -2667,7 +2667,8 @@ BMenu::_UpdateWindowViewSize(bool updatePosition)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_CacheFontInfo();
|
_CacheFontInfo();
|
||||||
window->ResizeTo(StringWidth(kEmptyMenuLabel) + fPad.left + fPad.right,
|
window->ResizeTo(StringWidth(BPrivate::kEmptyMenuLabel)
|
||||||
|
+ fPad.left + fPad.right,
|
||||||
fFontHeight + fPad.top + fPad.bottom);
|
fFontHeight + fPad.top + fPad.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,10 +72,12 @@ const unsigned char kShiftBits[] = {
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
BBitmap *gMenuItemAlt;
|
|
||||||
BBitmap *gMenuItemControl;
|
BBitmap* MenuPrivate::sMenuItemAlt;
|
||||||
BBitmap *gMenuItemOption;
|
BBitmap* MenuPrivate::sMenuItemControl;
|
||||||
BBitmap *gMenuItemShift;
|
BBitmap* MenuPrivate::sMenuItemOption;
|
||||||
|
BBitmap* MenuPrivate::sMenuItemShift;
|
||||||
|
|
||||||
|
|
||||||
MenuPrivate::MenuPrivate(BMenu *menu)
|
MenuPrivate::MenuPrivate(BMenu *menu)
|
||||||
:
|
:
|
||||||
@@ -134,10 +136,11 @@ MenuPrivate::GetItemMargins(float *left, float *top,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
bool
|
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 smallRect(0, 0, 16, 10);
|
||||||
BRect largeRect(0, 0, 21, 10);
|
BRect largeRect(0, 0, 21, 10);
|
||||||
try {
|
try {
|
||||||
gMenuItemAlt = new BBitmap(smallRect, B_CMAP8);
|
sMenuItemAlt = new BBitmap(smallRect, B_CMAP8);
|
||||||
gMenuItemControl = new BBitmap(smallRect, B_CMAP8);
|
sMenuItemControl = new BBitmap(smallRect, B_CMAP8);
|
||||||
gMenuItemOption = new BBitmap(smallRect, B_CMAP8);
|
sMenuItemOption = new BBitmap(smallRect, B_CMAP8);
|
||||||
gMenuItemShift = new BBitmap(largeRect, B_CMAP8);
|
sMenuItemShift = new BBitmap(largeRect, B_CMAP8);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
gMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits),
|
sMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits),
|
||||||
17, 0, B_CMAP8);
|
17, 0, B_CMAP8);
|
||||||
gMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits),
|
sMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits),
|
||||||
17, 0, B_CMAP8);
|
17, 0, B_CMAP8);
|
||||||
gMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits),
|
sMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits),
|
||||||
17, 0, B_CMAP8);
|
17, 0, B_CMAP8);
|
||||||
gMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits),
|
sMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits),
|
||||||
22, 0, B_CMAP8);
|
22, 0, B_CMAP8);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -222,10 +225,10 @@ MenuPrivate::CreateBitmaps()
|
|||||||
void
|
void
|
||||||
MenuPrivate::DeleteBitmaps()
|
MenuPrivate::DeleteBitmaps()
|
||||||
{
|
{
|
||||||
delete gMenuItemAlt;
|
delete sMenuItemAlt;
|
||||||
delete gMenuItemControl;
|
delete sMenuItemControl;
|
||||||
delete gMenuItemOption;
|
delete sMenuItemOption;
|
||||||
delete gMenuItemShift;
|
delete sMenuItemShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,9 +237,9 @@ const BBitmap *
|
|||||||
MenuPrivate::MenuItemCommand()
|
MenuPrivate::MenuItemCommand()
|
||||||
{
|
{
|
||||||
if (BMenu::sAltAsCommandKey)
|
if (BMenu::sAltAsCommandKey)
|
||||||
return gMenuItemAlt;
|
return sMenuItemAlt;
|
||||||
|
|
||||||
return gMenuItemControl;
|
return sMenuItemControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,9 +248,9 @@ const BBitmap *
|
|||||||
MenuPrivate::MenuItemControl()
|
MenuPrivate::MenuItemControl()
|
||||||
{
|
{
|
||||||
if (BMenu::sAltAsCommandKey)
|
if (BMenu::sAltAsCommandKey)
|
||||||
return gMenuItemControl;
|
return sMenuItemControl;
|
||||||
|
|
||||||
return gMenuItemAlt;
|
return sMenuItemAlt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -255,7 +258,7 @@ MenuPrivate::MenuItemControl()
|
|||||||
const BBitmap *
|
const BBitmap *
|
||||||
MenuPrivate::MenuItemOption()
|
MenuPrivate::MenuItemOption()
|
||||||
{
|
{
|
||||||
return gMenuItemOption;
|
return sMenuItemOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,7 +266,7 @@ MenuPrivate::MenuItemOption()
|
|||||||
const BBitmap *
|
const BBitmap *
|
||||||
MenuPrivate::MenuItemShift()
|
MenuPrivate::MenuItemShift()
|
||||||
{
|
{
|
||||||
return gMenuItemShift;
|
return sMenuItemShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user