Make UEFI boot-platform build again
[haiku.git] / headers / os / interface / MenuItem.h
blob055ccc3c0596e67101eedc9efb800b49bf7fc2ff
1 /*
2 * Copyright 2006-2007, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _MENU_ITEM_H
6 #define _MENU_ITEM_H
9 #include <Archivable.h>
10 #include <InterfaceDefs.h>
11 #include <Invoker.h>
12 #include <Menu.h>
15 class BMessage;
16 class BWindow;
18 namespace BPrivate {
19 class MenuItemPrivate;
22 class BMenuItem : public BArchivable, public BInvoker {
23 public:
24 BMenuItem(const char* label, BMessage* message,
25 char shortcut = 0, uint32 modifiers = 0);
26 BMenuItem(BMenu* menu,
27 BMessage* message = NULL);
28 BMenuItem(BMessage* data);
29 virtual ~BMenuItem();
31 static BArchivable* Instantiate(BMessage* archive);
32 virtual status_t Archive(BMessage* archive,
33 bool deep = true) const;
35 virtual void SetLabel(const char* name);
36 virtual void SetEnabled(bool enable);
37 virtual void SetMarked(bool mark);
38 virtual void SetTrigger(char trigger);
39 virtual void SetShortcut(char shortcut, uint32 modifiers);
41 const char* Label() const;
42 bool IsEnabled() const;
43 bool IsMarked() const;
44 char Trigger() const;
45 char Shortcut(uint32* _modifiers = NULL) const;
47 BMenu* Submenu() const;
48 BMenu* Menu() const;
49 BRect Frame() const;
51 protected:
52 virtual void GetContentSize(float* _width, float* _height);
53 virtual void TruncateLabel(float maxWidth, char* newLabel);
54 virtual void DrawContent();
55 virtual void Draw();
56 virtual void Highlight(bool highlight);
57 bool IsSelected() const;
58 BPoint ContentLocation() const;
60 private:
61 friend class BMenu;
62 friend class BPopUpMenu;
63 friend class BMenuBar;
64 friend class BPrivate::MenuItemPrivate;
66 virtual void _ReservedMenuItem1();
67 virtual void _ReservedMenuItem2();
68 virtual void _ReservedMenuItem3();
69 virtual void _ReservedMenuItem4();
71 void Install(BWindow* window);
72 void Uninstall();
73 void SetSuper(BMenu* superMenu);
74 void Select(bool select);
75 void SetAutomaticTrigger(int32 index,
76 uint32 trigger);
78 protected:
79 virtual status_t Invoke(BMessage* message = NULL);
81 private:
82 BMenuItem(const BMenuItem& other);
83 BMenuItem& operator=(const BMenuItem& other);
85 private:
86 void _InitData();
87 void _InitMenuData(BMenu* menu);
89 void _DrawMarkSymbol();
90 void _DrawShortcutSymbol();
91 void _DrawSubmenuSymbol();
92 void _DrawControlChar(char shortcut, BPoint where);
94 private:
95 char* fLabel;
96 BMenu* fSubmenu;
97 BWindow* fWindow;
98 BMenu* fSuper;
99 BRect fBounds;
100 uint32 fModifiers;
101 float fCachedWidth;
102 int16 fTriggerIndex;
103 char fUserTrigger;
104 char fShortcutChar;
105 bool fMark;
106 bool fEnabled;
107 bool fSelected;
108 uint32 fTrigger;
110 uint32 _reserved[3];
113 // BSeparatorItem now has its own declaration file, but for source
114 // compatibility we're exporting that class from here too.
115 #include <SeparatorItem.h>
117 #endif // _MENU_ITEM_H