xref: /haiku/headers/os/interface/CheckBox.h (revision b30304acc8c37e678a1bf66976d15bdab103f931)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		CheckBox.h
23 //	Author:			Marc Flerackers (mflerackers@androme.be)
24 //	Description:	BCheckBox displays an on/off control.
25 //------------------------------------------------------------------------------
26 
27 #ifndef _CHECK_BOX_H
28 #define _CHECK_BOX_H
29 
30 // Standard Includes -----------------------------------------------------------
31 
32 // System Includes -------------------------------------------------------------
33 #include <BeBuild.h>
34 #include <Control.h>
35 // Project Includes ------------------------------------------------------------
36 
37 // Local Includes --------------------------------------------------------------
38 
39 // Local Defines ---------------------------------------------------------------
40 
41 // Globals ---------------------------------------------------------------------
42 
43 
44 // BCheckBox class -------------------------------------------------------------
45 class BCheckBox : public BControl {
46 
47 public:
48 					BCheckBox(BRect frame,
49 							const char *name,
50 							const char *label,
51 							BMessage *message,
52 							uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
53 							uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
54 					BCheckBox(const char *name,
55 							const char *label,
56 							BMessage *message,
57 							uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
58 					BCheckBox(const char *label,
59 							BMessage *message = NULL);
60 virtual				~BCheckBox();
61 
62 /* Archiving */
63 					BCheckBox(BMessage *archive);
64 static	BArchivable	*Instantiate(BMessage *archive);
65 virtual	status_t	Archive(BMessage *archive, bool deep = true) const;
66 
67 virtual	void		Draw(BRect updateRect);
68 virtual	void		AttachedToWindow();
69 virtual	void		MouseDown(BPoint point);
70 
71 virtual void		MessageReceived(BMessage *message);
72 virtual void		WindowActivated(bool active);
73 virtual	void		KeyDown(const char *bytes, int32 numBytes);
74 virtual	void		MouseUp(BPoint point);
75 virtual	void		MouseMoved(BPoint point, uint32 transit, const BMessage *message);
76 virtual	void		DetachedFromWindow();
77 virtual	void		SetValue(int32 value);
78 virtual void		GetPreferredSize(float *width, float *height);
79 virtual void		ResizeToPreferred();
80 virtual	status_t	Invoke(BMessage *message = NULL);
81 virtual	void		FrameMoved(BPoint newLocation);
82 virtual	void		FrameResized(float width, float height);
83 
84 virtual BHandler	*ResolveSpecifier(BMessage *message,
85 									int32 index,
86 									BMessage *specifier,
87 									int32 what,
88 									const char *property);
89 virtual status_t	GetSupportedSuites(BMessage *message);
90 
91 virtual void		MakeFocus(bool focused = true);
92 virtual void		AllAttached();
93 virtual void		AllDetached();
94 
95 virtual status_t	Perform(perform_code d, void *arg);
96 
97 virtual	void		InvalidateLayout(bool descendants = false);
98 
99 virtual	BSize		MinSize();
100 virtual	BSize		MaxSize();
101 virtual	BSize		PreferredSize();
102 
103 private:
104 
105 virtual	void		_ReservedCheckBox1();
106 virtual	void		_ReservedCheckBox2();
107 virtual	void		_ReservedCheckBox3();
108 
109 		BRect		_CheckBoxFrame() const;
110 		BSize		_ValidatePreferredSize();
111 
112 		BCheckBox	&operator=(const BCheckBox &);
113 
114 		BSize		fPreferredSize;
115 		bool		fOutlined;
116 };
117 //------------------------------------------------------------------------------
118 
119 #endif // _CHECK_BOX_H
120 
121 /*
122  * $Log $
123  *
124  * $Id  $
125  *
126  */
127