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