xref: /haiku/headers/os/interface/PictureButton.h (revision 04a0e9c7b68cbe3a43d38e2bca8e860fd80936fb)
1 /*
2  * Copyright 2001-2008, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PICTURE_BUTTON_H
6 #define _PICTURE_BUTTON_H
7 
8 
9 #include <Control.h>
10 #include <Picture.h>
11 
12 
13 enum {
14 	B_ONE_STATE_BUTTON,
15 	B_TWO_STATE_BUTTON
16 };
17 
18 
19 class BPictureButton : public BControl {
20 public:
21 								BPictureButton(BRect frame, const char* name,
22 									BPicture* off, BPicture* on,
23 									BMessage* message,
24 									uint32 behavior = B_ONE_STATE_BUTTON,
25 									uint32 resizeMask = B_FOLLOW_LEFT
26 										| B_FOLLOW_TOP,
27 									uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
28 								BPictureButton(BMessage* archive);
29 
30 	virtual						~BPictureButton();
31 
32 	static	BArchivable*		Instantiate(BMessage* archive);
33 	virtual	status_t			Archive(BMessage* archive,
34 									bool deep = true) const;
35 
36 	virtual	void				AttachedToWindow();
37 	virtual	void				DetachedFromWindow();
38 	virtual	void				AllAttached();
39 	virtual	void				AllDetached();
40 
41 	virtual	void				ResizeToPreferred();
42 	virtual	void				GetPreferredSize(float* _width,
43 									float* _height);
44 	virtual	void				FrameMoved(BPoint position);
45 	virtual	void				FrameResized(float width, float height);
46 
47 	virtual	void				WindowActivated(bool state);
48 	virtual	void				MakeFocus(bool state = true);
49 
50 	virtual	void				Draw(BRect updateRect);
51 
52 	virtual	void				MessageReceived(BMessage* message);
53 	virtual	void				KeyDown(const char* bytes, int32 numBytes);
54 	virtual	void				MouseDown(BPoint where);
55 	virtual	void				MouseUp(BPoint where);
56 	virtual	void				MouseMoved(BPoint where, uint32 transit,
57 									const BMessage* message);
58 
59 	virtual	void				SetEnabledOn(BPicture* on);
60 	virtual	void				SetEnabledOff(BPicture* off);
61 	virtual	void				SetDisabledOn(BPicture* on);
62 	virtual	void				SetDisabledOff(BPicture* off);
63 
64 			BPicture*			EnabledOn() const;
65 			BPicture*			EnabledOff() const;
66 			BPicture*			DisabledOn() const;
67 			BPicture*			DisabledOff() const;
68 
69 	virtual	void				SetBehavior(uint32 behavior);
70 	uint32						Behavior() const;
71 
72 	virtual	void				SetValue(int32 value);
73 	virtual	status_t			Invoke(BMessage* message = NULL);
74 
75 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
76 									int32 index, BMessage* specifier,
77 									int32 form, const char* property);
78 	virtual	status_t			GetSupportedSuites(BMessage* data);
79 
80 	virtual	status_t			Perform(perform_code code, void* data);
81 
82 	virtual	status_t			SetIcon(const BBitmap* icon, uint32 flags = 0);
83 
84 private:
85 	// FBC padding and forbidden methods
86 	virtual	void				_ReservedPictureButton1();
87 	virtual	void				_ReservedPictureButton2();
88 	virtual	void				_ReservedPictureButton3();
89 
90 			BPictureButton&		operator=(const BPictureButton& other);
91 
92 private:
93 			BPicture*			fEnabledOff;
94 			BPicture*			fEnabledOn;
95 			BPicture*			fDisabledOff;
96 			BPicture*			fDisabledOn;
97 
98 			bool				unused;
99 
100 			uint32				fBehavior;
101 
102 			uint32				_reserved[4];
103 };
104 
105 #endif // _PICTURE_BUTTON_H
106