2008-04-11 12:29:54 +04:00
|
|
|
/*
|
2015-02-20 22:35:36 +03:00
|
|
|
* Copyright 2006-2015 Haiku, Inc. All rights reserved.
|
2008-04-11 12:29:54 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
|
|
|
|
*/
|
|
|
|
|
2005-06-07 17:34:50 +04:00
|
|
|
#ifndef __MENU_PRIVATE_H
|
|
|
|
#define __MENU_PRIVATE_H
|
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
|
2009-07-30 14:41:33 +04:00
|
|
|
#include <Menu.h>
|
2005-06-07 17:34:50 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
|
2006-04-22 21:56:21 +04:00
|
|
|
enum menu_states {
|
|
|
|
MENU_STATE_TRACKING = 0,
|
|
|
|
MENU_STATE_TRACKING_SUBMENU = 1,
|
2011-06-07 16:46:00 +04:00
|
|
|
MENU_STATE_KEY_TO_SUBMENU = 2,
|
|
|
|
MENU_STATE_KEY_LEAVE_SUBMENU = 3,
|
2006-04-22 21:56:21 +04:00
|
|
|
MENU_STATE_CLOSED = 5
|
2005-06-07 17:34:50 +04:00
|
|
|
};
|
|
|
|
|
2009-08-01 12:14:18 +04:00
|
|
|
|
2009-07-30 14:33:46 +04:00
|
|
|
class BBitmap;
|
2008-04-11 12:22:09 +04:00
|
|
|
class BMenu;
|
|
|
|
class BWindow;
|
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
|
2008-04-11 12:22:09 +04:00
|
|
|
namespace BPrivate {
|
2009-08-01 12:14:18 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
extern const char* kEmptyMenuLabel;
|
|
|
|
|
2008-04-11 12:22:09 +04:00
|
|
|
class MenuPrivate {
|
|
|
|
public:
|
2015-02-20 22:24:46 +03:00
|
|
|
MenuPrivate(BMenu* menu);
|
2008-04-11 12:22:09 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
menu_layout Layout() const;
|
2015-02-20 22:35:36 +03:00
|
|
|
void SetLayout(menu_layout layout);
|
2009-07-30 14:33:46 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
void ItemMarked(BMenuItem* item);
|
|
|
|
void CacheFontInfo();
|
|
|
|
|
|
|
|
float FontHeight() const;
|
|
|
|
float Ascent() const;
|
|
|
|
BRect Padding() const;
|
|
|
|
void GetItemMargins(float*, float*, float*, float*)
|
|
|
|
const;
|
2016-04-19 23:59:48 +03:00
|
|
|
void SetItemMargins(float, float, float, float);
|
2015-02-20 22:24:46 +03:00
|
|
|
|
|
|
|
int State(BMenuItem** item = NULL) const;
|
2008-04-11 12:22:09 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
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* MenuItemShift();
|
|
|
|
static const BBitmap* MenuItemControl();
|
|
|
|
static const BBitmap* MenuItemOption();
|
|
|
|
static const BBitmap* MenuItemCommand();
|
|
|
|
static const BBitmap* MenuItemMenu();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BMenu* fMenu;
|
|
|
|
|
|
|
|
static BBitmap* sMenuItemShift;
|
|
|
|
static BBitmap* sMenuItemControl;
|
|
|
|
static BBitmap* sMenuItemOption;
|
|
|
|
static BBitmap* sMenuItemAlt;
|
|
|
|
static BBitmap* sMenuItemMenu;
|
2009-08-01 12:14:18 +04:00
|
|
|
|
|
|
|
};
|
2006-03-03 22:10:33 +03:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
}; // namespace BPrivate
|
|
|
|
|
2005-06-07 17:34:50 +04:00
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
// Note: since sqrt is slow, we don't use it and return the square of the
|
|
|
|
// distance
|
2008-01-03 10:30:05 +03:00
|
|
|
#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
|
|
|
|
|
|
|
|
|
2015-02-20 22:24:46 +03:00
|
|
|
#endif // __MENU_PRIVATE_H
|