xref: /haiku/headers/os/interface/CheckBox.h (revision 9522c1e4f21b0292084467c927e4169770db1329)
1 /*
2  * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _CHECK_BOX_H
6 #define _CHECK_BOX_H
7 
8 
9 #include <Control.h>
10 
11 
12 class BCheckBox : public BControl {
13 public:
14 								BCheckBox(BRect frame, const char* name,
15 									const char* label, BMessage* message,
16 									uint32 resizingMode
17 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
18 									uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
19 								BCheckBox(const char* name, const char* label,
20 									BMessage* message, uint32 flags
21 										= B_WILL_DRAW | B_NAVIGABLE);
22 								BCheckBox(const char* label,
23 									BMessage* message = NULL);
24 								BCheckBox(BMessage* data);
25 
26 	virtual						~BCheckBox();
27 
28 	static	BArchivable*		Instantiate(BMessage* data);
29 	virtual	status_t			Archive(BMessage* data, bool deep = true) const;
30 
31 	virtual	void				Draw(BRect updateRect);
32 
33 	virtual	void				AttachedToWindow();
34 	virtual	void				DetachedFromWindow();
35 	virtual	void				AllAttached();
36 	virtual	void				AllDetached();
37 
38 	virtual	void				FrameMoved(BPoint newPosition);
39 	virtual	void				FrameResized(float newWidth, float newHeight);
40 	virtual	void				WindowActivated(bool active);
41 
42 	virtual	void				MessageReceived(BMessage* message);
43 
44 	virtual	void				KeyDown(const char* bytes, int32 numBytes);
45 
46 	virtual	void				MouseDown(BPoint where);
47 	virtual	void				MouseUp(BPoint where);
48 	virtual	void				MouseMoved(BPoint where, uint32 code,
49 									const BMessage* dragMessage);
50 
51 	virtual	void				GetPreferredSize(float* _width,
52 									float* _height);
53 	virtual	void				ResizeToPreferred();
54 
55 	virtual	BSize				MinSize();
56 	virtual	BSize				MaxSize();
57 	virtual	BSize				PreferredSize();
58 	virtual	BAlignment			LayoutAlignment();
59 
60 	virtual	void				MakeFocus(bool focused = true);
61 
62 	virtual	void				SetValue(int32 value);
63 	virtual	status_t			Invoke(BMessage* message = NULL);
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 
70 	virtual	status_t			Perform(perform_code code, void* data);
71 
72 	virtual	status_t			SetIcon(const BBitmap* icon, uint32 flags = 0);
73 
74 			bool				IsPartialStateToOff() const;
75 			void				SetPartialStateToOff(bool partialToOff);
76 
77 protected:
78 	virtual	void				LayoutInvalidated(bool descendants = false);
79 
80 private:
81 	// FBC padding
82 	virtual	void				_ReservedCheckBox1();
83 	virtual	void				_ReservedCheckBox2();
84 	virtual	void				_ReservedCheckBox3();
85 
86 private:
87 	inline	BRect				_CheckBoxFrame(const font_height& fontHeight)
88 									const;
89 			BRect				_CheckBoxFrame() const;
90 			BSize				_ValidatePreferredSize();
91 			int32				_NextState() const;
92 
93 private:
94 	// Forbidden
95 			BCheckBox&			operator=(const BCheckBox&);
96 
97 private:
98 			BSize				fPreferredSize;
99 			bool				fOutlined;
100 			bool				fPartialToOff;
101 };
102 
103 
104 #endif // _CHECK_BOX_H
105