2006-04-04 17:02:52 +04:00
|
|
|
/*
|
2009-08-27 15:12:41 +04:00
|
|
|
* Copyright 2006-2007, Haiku, Inc. All rights reserved.
|
2006-04-04 17:02:52 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-10-23 17:54:44 +04:00
|
|
|
#ifndef _MENU_ITEM_H
|
|
|
|
#define _MENU_ITEM_H
|
2016-04-19 23:48:25 +03:00
|
|
|
|
2006-04-04 17:02:52 +04:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
#include <Archivable.h>
|
2006-04-04 17:02:52 +04:00
|
|
|
#include <InterfaceDefs.h>
|
2002-10-23 17:54:44 +04:00
|
|
|
#include <Invoker.h>
|
2006-04-04 17:02:52 +04:00
|
|
|
#include <Menu.h>
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2016-04-19 23:48:25 +03:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
class BMessage;
|
|
|
|
class BWindow;
|
|
|
|
|
2016-04-19 00:44:00 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
class MenuItemPrivate;
|
|
|
|
}
|
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
class BMenuItem : public BArchivable, public BInvoker {
|
2009-08-27 15:12:41 +04:00
|
|
|
public:
|
|
|
|
BMenuItem(const char* label, BMessage* message,
|
|
|
|
char shortcut = 0, uint32 modifiers = 0);
|
|
|
|
BMenuItem(BMenu* menu,
|
|
|
|
BMessage* message = NULL);
|
|
|
|
BMenuItem(BMessage* data);
|
|
|
|
virtual ~BMenuItem();
|
|
|
|
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
virtual status_t Archive(BMessage* archive,
|
|
|
|
bool deep = true) const;
|
|
|
|
|
|
|
|
virtual void SetLabel(const char* name);
|
2014-03-01 04:04:49 +04:00
|
|
|
virtual void SetEnabled(bool enable);
|
|
|
|
virtual void SetMarked(bool mark);
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual void SetTrigger(char trigger);
|
|
|
|
virtual void SetShortcut(char shortcut, uint32 modifiers);
|
|
|
|
|
|
|
|
const char* Label() const;
|
|
|
|
bool IsEnabled() const;
|
|
|
|
bool IsMarked() const;
|
|
|
|
char Trigger() const;
|
|
|
|
char Shortcut(uint32* _modifiers = NULL) const;
|
|
|
|
|
|
|
|
BMenu* Submenu() const;
|
|
|
|
BMenu* Menu() const;
|
|
|
|
BRect Frame() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void GetContentSize(float* _width, float* _height);
|
|
|
|
virtual void TruncateLabel(float maxWidth, char* newLabel);
|
|
|
|
virtual void DrawContent();
|
|
|
|
virtual void Draw();
|
2014-03-01 04:04:49 +04:00
|
|
|
virtual void Highlight(bool highlight);
|
2009-08-27 15:12:41 +04:00
|
|
|
bool IsSelected() const;
|
|
|
|
BPoint ContentLocation() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BMenu;
|
|
|
|
friend class BPopUpMenu;
|
|
|
|
friend class BMenuBar;
|
2016-04-19 00:44:00 +03:00
|
|
|
friend class BPrivate::MenuItemPrivate;
|
2009-08-27 15:12:41 +04:00
|
|
|
|
|
|
|
virtual void _ReservedMenuItem1();
|
|
|
|
virtual void _ReservedMenuItem2();
|
|
|
|
virtual void _ReservedMenuItem3();
|
|
|
|
virtual void _ReservedMenuItem4();
|
|
|
|
|
|
|
|
void Install(BWindow* window);
|
|
|
|
void Uninstall();
|
|
|
|
void SetSuper(BMenu* superMenu);
|
|
|
|
void Select(bool select);
|
|
|
|
void SetAutomaticTrigger(int32 index,
|
|
|
|
uint32 trigger);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual status_t Invoke(BMessage* message = NULL);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BMenuItem(const BMenuItem& other);
|
|
|
|
BMenuItem& operator=(const BMenuItem& other);
|
|
|
|
|
2016-04-19 00:44:00 +03:00
|
|
|
private:
|
2009-08-27 15:12:41 +04:00
|
|
|
void _InitData();
|
|
|
|
void _InitMenuData(BMenu* menu);
|
|
|
|
|
2018-07-17 22:03:11 +03:00
|
|
|
bool _IsActivated();
|
|
|
|
rgb_color _LowColor();
|
|
|
|
rgb_color _HighColor();
|
|
|
|
|
2012-07-29 07:00:56 +04:00
|
|
|
void _DrawMarkSymbol();
|
2009-08-27 15:12:41 +04:00
|
|
|
void _DrawShortcutSymbol();
|
2012-07-29 07:00:56 +04:00
|
|
|
void _DrawSubmenuSymbol();
|
2009-08-27 15:12:41 +04:00
|
|
|
void _DrawControlChar(char shortcut, BPoint where);
|
|
|
|
|
|
|
|
private:
|
|
|
|
char* fLabel;
|
|
|
|
BMenu* fSubmenu;
|
|
|
|
BWindow* fWindow;
|
|
|
|
BMenu* fSuper;
|
|
|
|
BRect fBounds;
|
|
|
|
uint32 fModifiers;
|
|
|
|
float fCachedWidth;
|
|
|
|
int16 fTriggerIndex;
|
|
|
|
char fUserTrigger;
|
|
|
|
char fShortcutChar;
|
|
|
|
bool fMark;
|
|
|
|
bool fEnabled;
|
|
|
|
bool fSelected;
|
|
|
|
uint32 fTrigger;
|
|
|
|
|
|
|
|
uint32 _reserved[3];
|
2002-10-23 17:54:44 +04:00
|
|
|
};
|
|
|
|
|
2006-04-04 17:02:52 +04:00
|
|
|
// BSeparatorItem now has its own declaration file, but for source
|
|
|
|
// compatibility we're exporting that class from here too.
|
2004-12-30 13:11:38 +03:00
|
|
|
#include <SeparatorItem.h>
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
#endif // _MENU_ITEM_H
|