xref: /haiku/headers/os/interface/PictureButton.h (revision bb83316a5811a550c4f850d07fa8e328e7ac0a94)
1  /*
2   * Copyright 2001-2015, 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 picture_button_behavior {
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 resizingMode = B_FOLLOW_LEFT_TOP,
26  									uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
27  								BPictureButton(BMessage* archive);
28  
29  	virtual						~BPictureButton();
30  
31  	static	BArchivable*		Instantiate(BMessage* archive);
32  	virtual	status_t			Archive(BMessage* archive,
33  									bool deep = true) const;
34  
35  	virtual	void				AttachedToWindow();
36  	virtual	void				DetachedFromWindow();
37  	virtual	void				AllAttached();
38  	virtual	void				AllDetached();
39  
40  	virtual	void				ResizeToPreferred();
41  	virtual	void				GetPreferredSize(float* _width,
42  									float* _height);
43  	virtual	void				FrameMoved(BPoint newPosition);
44  	virtual	void				FrameResized(float newWidth, float newHeight);
45  
46  	virtual	void				WindowActivated(bool active);
47  	virtual	void				MakeFocus(bool focus = true);
48  
49  	virtual	void				Draw(BRect updateRect);
50  
51  	virtual	void				MessageReceived(BMessage* message);
52  	virtual	void				KeyDown(const char* bytes, int32 numBytes);
53  	virtual	void				MouseDown(BPoint where);
54  	virtual	void				MouseUp(BPoint where);
55  	virtual	void				MouseMoved(BPoint where, uint32 code,
56  									const BMessage* dragMessage);
57  
58  	virtual	void				SetEnabledOn(BPicture* picture);
59  	virtual	void				SetEnabledOff(BPicture* picture);
60  	virtual	void				SetDisabledOn(BPicture* picture);
61  	virtual	void				SetDisabledOff(BPicture* picture);
62  
63  			BPicture*			EnabledOn() const;
64  			BPicture*			EnabledOff() const;
65  			BPicture*			DisabledOn() const;
66  			BPicture*			DisabledOff() const;
67  
68  	virtual	void				SetBehavior(uint32 behavior);
69  	uint32						Behavior() const;
70  
71  	virtual	void				SetValue(int32 value);
72  	virtual	status_t			Invoke(BMessage* message = NULL);
73  
74  	virtual	BHandler*			ResolveSpecifier(BMessage* message,
75  									int32 index, BMessage* specifier,
76  									int32 what, const char* property);
77  	virtual	status_t			GetSupportedSuites(BMessage* data);
78  
79  	virtual	status_t			Perform(perform_code code, void* data);
80  
81  	virtual	status_t			SetIcon(const BBitmap* icon, uint32 flags = 0);
82  
83  private:
84  	// FBC padding and forbidden methods
85  	virtual	void				_ReservedPictureButton1();
86  	virtual	void				_ReservedPictureButton2();
87  	virtual	void				_ReservedPictureButton3();
88  
89  			BPictureButton&		operator=(const BPictureButton& other);
90  
91  private:
92  			BPicture*			fEnabledOff;
93  			BPicture*			fEnabledOn;
94  			BPicture*			fDisabledOff;
95  			BPicture*			fDisabledOn;
96  
97  			bool				unused;
98  
99  			uint32				fBehavior;
100  
101  			uint32				_reserved[4];
102  };
103  
104  #endif // _PICTURE_BUTTON_H
105