xref: /haiku/headers/os/interface/PictureButton.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
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:		PictureButton.h
23 //	Author:			Graham MacDonald (macdonag@btopenworld.com)
24 //	Description:	BPictureButton displays and controls a picture button in a
25 //					window.
26 //------------------------------------------------------------------------------
27 
28 #ifndef _PICTURE_BUTTON_H
29 #define _PICTURE_BUTTON_H
30 
31 // Standard Includes -----------------------------------------------------------
32 
33 // System Includes -------------------------------------------------------------
34 #include <BeBuild.h>
35 #include <Control.h>
36 #include <Picture.h>	/* For convenience */
37 
38 // Project Includes ------------------------------------------------------------
39 
40 // Local Includes --------------------------------------------------------------
41 
42 // Local Defines ---------------------------------------------------------------
43 
44 // Globals ---------------------------------------------------------------------
45 enum {
46 	B_ONE_STATE_BUTTON,
47 	B_TWO_STATE_BUTTON
48 };
49 
50 
51 // BPictureButton class --------------------------------------------------------
52 class BPictureButton : public BControl
53 {
54 public:
55 	BPictureButton (BRect frame,
56 					const char* name,
57 					BPicture *off,
58 					BPicture *on,
59 					BMessage *message,
60 					uint32 behavior = B_ONE_STATE_BUTTON,
61 					uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
62 					uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
63 	BPictureButton (BMessage *data);
64 
65 	virtual ~BPictureButton ();
66 
67 
68 	static	BArchivable	*Instantiate (BMessage *data);
69 
70 	virtual status_t Archive (BMessage *data, bool deep = true) const;
71 
72 	virtual void Draw (BRect updateRect);
73 
74 	virtual void MouseDown (BPoint point);
75 	virtual void KeyDown (const char *bytes, int32 numBytes);
76 
77 	virtual void SetEnabledOn (BPicture *on);
78 	virtual void SetEnabledOff (BPicture *off);
79 	virtual void SetDisabledOn (BPicture *on);
80 	virtual void SetDisabledOff (BPicture *off);
81 
82 	BPicture *EnabledOn () const;
83 	BPicture *EnabledOff () const;
84 	BPicture *DisabledOn () const;
85 	BPicture *DisabledOff () const;
86 
87 	virtual void SetBehavior (uint32 behavior);
88 	uint32 Behavior () const;
89 
90 	virtual void MessageReceived (BMessage *msg);
91 	virtual void MouseUp (BPoint point);
92 	virtual void WindowActivated (bool state);
93 	virtual void MouseMoved (BPoint pt, uint32 code, const BMessage *msg);
94 	virtual void AttachedToWindow ();
95 	virtual void DetachedFromWindow ();
96 	virtual void SetValue (int32 value);
97 	virtual status_t Invoke (BMessage *msg = NULL);
98 	virtual void FrameMoved (BPoint new_position);
99 	virtual void FrameResized (float new_width, float new_height);
100 
101 	virtual BHandler *ResolveSpecifier (BMessage *msg,
102 										 int32 index,
103 										 BMessage *specifier,
104 										 int32 form,
105 										 const char *property);
106 	virtual status_t GetSupportedSuites (BMessage *data);
107 
108 	virtual void ResizeToPreferred ();
109 	virtual void GetPreferredSize (float *width, float *height);
110 	virtual void MakeFocus (bool state = true);
111 	virtual void AllAttached ();
112 	virtual void AllDetached ();
113 
114 
115 	// Private or reserved -----------------------------------------------------
116 	virtual status_t Perform (perform_code d, void *arg);
117 
118 
119 private:
120 
121 	virtual void _ReservedPictureButton1 ();
122 	virtual void _ReservedPictureButton2 ();
123 	virtual void _ReservedPictureButton3 ();
124 
125 	BPictureButton &operator= (const BPictureButton &);
126 
127 	void Redraw ();
128 	void InitData ();
129 
130 	BPicture *fEnabledOff;
131 	BPicture *fEnabledOn;
132 	BPicture *fDisabledOff;
133 	BPicture *fDisabledOn;
134 
135 	bool fOutlined;
136 
137 	uint32 fBehavior;
138 	uint32 _reserved[4];
139 };
140 
141 //------------------------------------------------------------------------------
142 
143 #endif /* _PICTURE_BUTTON_H */
144 
145 /*
146  * $Log $
147  *
148  * $Id  $
149  *
150  */
151 
152