xref: /haiku/headers/os/interface/MenuField.h (revision 24159a0c7d6d6dcba9f2a0c1a7c08d2c8167f21b)
1 /*******************************************************************************
2 /
3 /	File:			MenuField.h
4 /
5 /   Description:    BMenuField displays a labeled pop-up menu.
6 /
7 /	Copyright 1994-98, Be Incorporated, All Rights Reserved
8 /
9 *******************************************************************************/
10 
11 
12 #ifndef _MENU_FIELD_H
13 #define _MENU_FIELD_H
14 
15 #include <BeBuild.h>
16 #include <Menu.h>		/* For convenience */
17 #include <View.h>
18 
19 class BMenuBar;
20 
21 /*----------------------------------------------------------------*/
22 /*----- BMenuField class -----------------------------------------*/
23 
24 class BMenuField : public BView
25 {
26 public:
27 						BMenuField(	BRect frame,
28 									const char *name,
29 									const char *label,
30 									BMenu *menu,
31 									uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
32 									uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
33 						BMenuField(	BRect frame,
34 									const char *name,
35 									const char *label,
36 									BMenu *menu,
37 									bool fixed_size,
38 									uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
39 									uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
40 						BMenuField(BMessage *data);
41 virtual					~BMenuField();
42 static	BArchivable		*Instantiate(BMessage *data);
43 virtual	status_t		Archive(BMessage *data, bool deep = true) const;
44 
45 virtual	void			Draw(BRect update);
46 virtual	void			AttachedToWindow();
47 virtual	void			AllAttached();
48 virtual	void			MouseDown(BPoint where);
49 virtual	void			KeyDown(const char *bytes, int32 numBytes);
50 virtual	void			MakeFocus(bool state);
51 virtual void			MessageReceived(BMessage *msg);
52 virtual void			WindowActivated(bool state);
53 virtual	void			MouseUp(BPoint pt);
54 virtual	void			MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
55 virtual	void			DetachedFromWindow();
56 virtual	void			AllDetached();
57 virtual	void			FrameMoved(BPoint new_position);
58 virtual	void			FrameResized(float new_width, float new_height);
59 
60 		BMenu			*Menu() const;
61 		BMenuBar		*MenuBar() const;
62 		BMenuItem		*MenuItem() const;
63 
64 virtual	void			SetLabel(const char *label);
65 		const char		*Label() const;
66 
67 virtual void			SetEnabled(bool on);
68 		bool			IsEnabled() const;
69 
70 virtual	void			SetAlignment(alignment label);
71 		alignment		Alignment() const;
72 virtual	void			SetDivider(float dividing_line);
73 		float			Divider() const;
74 
75 		void			ShowPopUpMarker();
76 		void			HidePopUpMarker();
77 
78 virtual BHandler		*ResolveSpecifier(BMessage *msg,
79 										int32 index,
80 										BMessage *specifier,
81 										int32 form,
82 										const char *property);
83 virtual status_t		GetSupportedSuites(BMessage *data);
84 
85 virtual void			ResizeToPreferred();
86 virtual void			GetPreferredSize(float *width, float *height);
87 
88 
89 /*----- Private or reserved -----------------------------------------*/
90 virtual status_t		Perform(perform_code d, void *arg);
91 
92 private:
93 friend class _BMCMenuBar_;
94 
95 virtual	void			_ReservedMenuField1();
96 virtual	void			_ReservedMenuField2();
97 virtual	void			_ReservedMenuField3();
98 
99 		BMenuField		&operator=(const BMenuField &);
100 
101 
102 		void			InitObject(const char *label);
103 		void			InitObject2();
104 		void			DrawLabel(BRect bounds, BRect update);
105 static	void			InitMenu(BMenu *menu);
106 static	long			MenuTask(void *arg);
107 
108 		char			*fLabel;
109 		BMenu			*fMenu;
110 		BMenuBar		*fMenuBar;
111 		alignment		fAlign;
112 		float			fDivider;
113 		float			fStringWidth;
114 		bool			fEnabled;
115 		bool			fSelected;
116 		bool			fTransition;
117 		bool			fFixedSizeMB;
118 		thread_id		fMenuTaskID;
119 		uint32			_reserved[3];
120 };
121 
122 /*-------------------------------------------------------------*/
123 /*-------------------------------------------------------------*/
124 
125 #endif /* _MENU_FIELD_H */
126