Fix more class/struct mixups.
[haiku.git] / headers / os / interface / MenuField.h
blobfac2aec1279c5bb5f2f43f1313a656db85b937aa
1 /*
2 * Copyright 2006-2016 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _MENU_FIELD_H
6 #define _MENU_FIELD_H
9 #include <Menu.h>
12 class BMenuBar;
13 class BMessageFilter;
16 class BMenuField : public BView {
17 public:
18 BMenuField(BRect frame, const char* name,
19 const char* label, BMenu* menu,
20 uint32 resizingMode = B_FOLLOW_LEFT_TOP,
21 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
22 BMenuField(BRect frame, const char* name,
23 const char* label, BMenu* menu,
24 bool fixed_size,
25 uint32 resizingMode = B_FOLLOW_LEFT_TOP,
26 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
27 BMenuField(const char* name,
28 const char* label, BMenu* menu,
29 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
30 BMenuField(const char* label, BMenu* menu,
31 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
32 BMenuField(BMessage* data);
33 virtual ~BMenuField();
35 static BArchivable* Instantiate(BMessage* archive);
36 virtual status_t Archive(BMessage* archive,
37 bool deep = true) const;
39 virtual void Draw(BRect updateRect);
40 virtual void AttachedToWindow();
41 virtual void AllAttached();
42 virtual void MouseDown(BPoint where);
43 virtual void KeyDown(const char* bytes, int32 numBytes);
44 virtual void MakeFocus(bool focused);
45 virtual void MessageReceived(BMessage* message);
46 virtual void WindowActivated(bool active);
47 virtual void MouseUp(BPoint where);
48 virtual void MouseMoved(BPoint where, uint32 transit,
49 const BMessage* dragMessage);
50 virtual void DetachedFromWindow();
51 virtual void AllDetached();
52 virtual void FrameMoved(BPoint where);
53 virtual void FrameResized(float width, float height);
55 BMenu* Menu() const;
56 BMenuBar* MenuBar() const;
57 BMenuItem* MenuItem() const;
59 virtual void SetLabel(const char* label);
60 const char* Label() const;
62 virtual void SetEnabled(bool on);
63 bool IsEnabled() const;
65 virtual void SetAlignment(alignment label);
66 alignment Alignment() const;
67 virtual void SetDivider(float position);
68 float Divider() const;
70 void ShowPopUpMarker();
71 void HidePopUpMarker();
73 virtual BHandler* ResolveSpecifier(BMessage* message,
74 int32 index, BMessage* specifier,
75 int32 form, const char* property);
76 virtual status_t GetSupportedSuites(BMessage* data);
78 virtual void ResizeToPreferred();
79 virtual void GetPreferredSize(float* width, float* height);
81 virtual BSize MinSize();
82 virtual BSize MaxSize();
83 virtual BSize PreferredSize();
85 BLayoutItem* CreateLabelLayoutItem();
86 BLayoutItem* CreateMenuBarLayoutItem();
88 virtual status_t Perform(perform_code d, void* arg);
90 protected:
91 virtual status_t AllArchived(BMessage* into) const;
92 virtual status_t AllUnarchived(const BMessage* from);
94 virtual void LayoutInvalidated(bool descendants);
95 virtual void DoLayout();
97 private:
98 // FBC padding
99 virtual void _ReservedMenuField1();
100 virtual void _ReservedMenuField2();
101 virtual void _ReservedMenuField3();
103 // Forbidden
104 BMenuField& operator=(const BMenuField& other);
106 private:
107 class LabelLayoutItem;
108 class MenuBarLayoutItem;
109 struct LayoutData;
111 friend class _BMCMenuBar_;
112 friend class LabelLayoutItem;
113 friend class MenuBarLayoutItem;
114 friend struct LayoutData;
116 BMenuField(const char* name,
117 const char* label, BMenu* menu,
118 BMessage* message,
119 uint32 flags);
120 BMenuField(const char* label,
121 BMenu* menu, BMessage* message);
123 void _DrawLabel(BRect updateRect);
124 void _DrawMenuBar(BRect updateRect);
126 void InitObject(const char* label);
127 void InitObject2();
129 static void InitMenu(BMenu* menu);
131 int32 _MenuTask();
132 static int32 _thread_entry(void *arg);
134 void _UpdateFrame();
135 void _InitMenuBar(BMenu* menu,
136 BRect frame, bool fixedSize);
137 void _InitMenuBar(const BMessage* archive);
138 void _AddMenu(BMenu* menu);
140 void _ValidateLayoutData();
141 float _MenuBarOffset() const;
142 float _MenuBarWidth() const;
144 void _DoneTracking(BPoint point);
145 void _Track(BPoint point, uint32);
147 private:
148 char* fLabel;
149 BMenu* fMenu;
150 BMenuBar* fMenuBar;
151 alignment fAlign;
152 float fDivider;
153 bool fEnabled;
154 bool fFixedSizeMB;
155 thread_id fMenuTaskID;
157 LayoutData* fLayoutData;
158 BMessageFilter* fMouseDownFilter;
160 uint32 _reserved[2];
164 #endif // _MENU_FIELD_H