Button.h revision b181fabe
1/*
2 * Copyright 2001-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _BUTTON_H
6#define _BUTTON_H
7
8#include <Control.h>
9
10
11class BButton : public BControl {
12public:
13								BButton(BRect frame, const char* name,
14									const char* label, BMessage* message,
15									uint32 resizingMode
16										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
17									uint32 flags = B_WILL_DRAW | B_NAVIGABLE
18										| B_FULL_UPDATE_ON_RESIZE);
19								BButton(const char* name, const char* label,
20									BMessage *message,
21									uint32 flags = B_WILL_DRAW | B_NAVIGABLE
22										| B_FULL_UPDATE_ON_RESIZE);
23								BButton(const char* label,
24									BMessage* message = NULL);
25
26								BButton(BMessage *archive);
27
28	virtual						~BButton();
29
30	static	BArchivable*		Instantiate(BMessage* archive);
31	virtual	status_t			Archive(BMessage* archive,
32									bool deep = true) const;
33
34	virtual	void				Draw(BRect updateRect);
35	virtual	void				MouseDown(BPoint point);
36	virtual	void				AttachedToWindow();
37	virtual	void				KeyDown(const char* bytes, int32 numBytes);
38	virtual	void				MakeDefault(bool flag);
39	virtual	void				SetLabel(const char* string);
40			bool				IsDefault() const;
41
42			bool				IsFlat() const;
43			void				SetFlat(bool flat);
44
45	virtual	void				MessageReceived(BMessage* message);
46	virtual	void				WindowActivated(bool active);
47	virtual	void				MouseMoved(BPoint point, uint32 transit,
48									const BMessage* message);
49	virtual	void				MouseUp(BPoint point);
50	virtual	void				DetachedFromWindow();
51	virtual	void				SetValue(int32 value);
52	virtual	void				GetPreferredSize (float* _width,
53									float* _height);
54	virtual	void				ResizeToPreferred();
55	virtual	status_t			Invoke(BMessage* message = NULL);
56	virtual	void				FrameMoved(BPoint newLocation);
57	virtual	void				FrameResized(float width, float height);
58
59	virtual	void				MakeFocus(bool focused = true);
60	virtual	void				AllAttached();
61	virtual	void				AllDetached();
62
63	virtual	BHandler*			ResolveSpecifier(BMessage* message,
64									int32 index, BMessage* specifier,
65									int32 what, const char* property);
66	virtual	status_t			GetSupportedSuites(BMessage* message);
67	virtual	status_t			Perform(perform_code d, void* arg);
68
69
70	virtual	BSize				MinSize();
71	virtual	BSize				MaxSize();
72	virtual	BSize				PreferredSize();
73
74	virtual	status_t			SetIcon(const BBitmap* icon, uint32 flags = 0);
75
76
77protected:
78	virtual	void				LayoutInvalidated(bool descendants = false);
79
80private:
81	virtual	void				_ReservedButton1();
82	virtual	void				_ReservedButton2();
83	virtual	void				_ReservedButton3();
84
85			BButton&			operator=(const BButton &);
86
87			BSize				_ValidatePreferredSize();
88
89			BRect				_DrawDefault(BRect bounds, bool enabled);
90			void 				_DrawFocusLine(float x, float y, float width,
91									bool bVisible);
92
93	inline	bool				_Flag(uint32 flag) const;
94	inline	bool				_SetFlag(uint32 flag, bool set);
95
96private:
97			BSize				fPreferredSize;
98			uint32				fFlags;
99
100			uint32				_reserved[2];
101};
102
103#endif // _BUTTON_H
104