xref: /haiku/headers/os/interface/Button.h (revision f23596149e0d173463f70629581aa10cc305d32e)
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:		Button.h
23 //	Author:			Marc Flerackers (mflerackers@androme.be)
24 //	Description:	BButton displays and controls a button in a window.
25 //------------------------------------------------------------------------------
26 
27 #ifndef _BUTTON_H
28 #define _BUTTON_H
29 
30 // Standard Includes -----------------------------------------------------------
31 
32 // System Includes -------------------------------------------------------------
33 #include <BeBuild.h>
34 #include <Control.h>
35 
36 // Project Includes ------------------------------------------------------------
37 
38 // Local Includes --------------------------------------------------------------
39 
40 // Local Defines ---------------------------------------------------------------
41 
42 // Globals ---------------------------------------------------------------------
43 
44 
45 // BButton class ---------------------------------------------------------------
46 class BButton : public BControl {
47 
48 public:
49 					BButton(BRect frame,
50 							const char *name,
51 							const char *label,
52 							BMessage *message,
53 							uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
54 							uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
55 					BButton(const char* name, const char* label,
56 							BMessage *message,
57 							uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
58 					BButton(const char* label, BMessage *message);
59 
60 virtual				~BButton();
61 
62 					BButton(BMessage *archive);
63 
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		MouseDown(BPoint point);
69 virtual void		AttachedToWindow();
70 virtual void		KeyDown(const char *bytes, int32 numBytes);
71 virtual void		MakeDefault(bool flag);
72 virtual void		SetLabel(const char *string);
73 		bool		IsDefault() const;
74 
75 virtual void		MessageReceived(BMessage *message);
76 virtual void		WindowActivated(bool active);
77 virtual void		MouseMoved(BPoint point, uint32 transit, const BMessage *message);
78 virtual void		MouseUp(BPoint point);
79 virtual	void		DetachedFromWindow();
80 virtual	void		SetValue(int32 value);
81 virtual void		GetPreferredSize (float *width, float *height);
82 virtual void		ResizeToPreferred();
83 virtual	status_t	Invoke(BMessage *message = NULL);
84 virtual	void		FrameMoved(BPoint newLocation);
85 virtual	void		FrameResized(float width, float height);
86 
87 virtual void		MakeFocus(bool focused = true);
88 virtual void		AllAttached();
89 virtual void		AllDetached();
90 
91 virtual BHandler	*ResolveSpecifier(BMessage *message,
92 									int32 index,
93 									BMessage *specifier,
94 									int32 what,
95 									const char *property);
96 virtual	status_t	GetSupportedSuites(BMessage *message);
97 virtual status_t	Perform(perform_code d, void *arg);
98 
99 virtual	BSize		MaxSize();
100 
101 
102 private:
103 
104 virtual	void		_ReservedButton1();
105 virtual	void		_ReservedButton2();
106 virtual	void		_ReservedButton3();
107 
108 		BButton		&operator=(const BButton &);
109 
110 		BRect		DrawDefault(BRect bounds, bool enabled);
111 		void 		DrawFocusLine(float x, float y, float width,
112 			bool bVisible);
113 
114 		status_t	Execute ();
115 
116 		float		fCachedWidth;
117 		bool		fDrawAsDefault;
118 		uint32		_reserved[3];
119 };
120 //------------------------------------------------------------------------------
121 
122 #endif // _BUTTON_H
123 
124 /*
125  * $Log $
126  *
127  * $Id  $
128  *
129  */
130