c3d7cee2d9
for every BMenuItem, have them created in _init_interface_kit(), and keep them cached. This required some reorganisation of the code in Menu and MenuItem. Also has the side effect that BMenuItem doesn't have to know about the alt/ctrl/command keys stuff. Added a comment in BMenu::AttachedToWindow(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31962 a95241bf-73f2-0310-859d-f6bbb57e9c96
82 lines
1.7 KiB
C++
82 lines
1.7 KiB
C++
/*
|
|
* Copyright 2006-2008, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
|
|
*/
|
|
|
|
#ifndef __MENU_PRIVATE_H
|
|
#define __MENU_PRIVATE_H
|
|
|
|
|
|
enum menu_states {
|
|
MENU_STATE_TRACKING = 0,
|
|
MENU_STATE_TRACKING_SUBMENU = 1,
|
|
MENU_STATE_CLOSED = 5
|
|
};
|
|
|
|
class BBitmap;
|
|
class BMenu;
|
|
class BWindow;
|
|
|
|
namespace BPrivate {
|
|
|
|
class MenuPrivate {
|
|
public:
|
|
MenuPrivate(BMenu *menu);
|
|
|
|
menu_layout Layout() const;
|
|
|
|
void ItemMarked(BMenuItem *item);
|
|
void CacheFontInfo();
|
|
|
|
float FontHeight() const;
|
|
float Ascent() const;
|
|
BRect Padding() const;
|
|
void GetItemMargins(float *, float *, float *, float *) const;
|
|
|
|
bool IsAltCommandKey() const;
|
|
int State(BMenuItem **item = NULL) const;
|
|
|
|
void Install(BWindow *window);
|
|
void Uninstall();
|
|
void SetSuper(BMenu *menu);
|
|
void SetSuperItem(BMenuItem *item);
|
|
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;
|
|
|
|
|
|
// Note: since sqrt is slow, we don't use it and return the square of the distance
|
|
#define square(x) ((x) * (x))
|
|
static inline float
|
|
point_distance(const BPoint &pointA, const BPoint &pointB)
|
|
{
|
|
return square(pointA.x - pointB.x) + square(pointA.y - pointB.y);
|
|
}
|
|
|
|
#undef square
|
|
|
|
|
|
#endif // __MENU_PRIVATE_H
|