1/*
2 * Copyright 2006-2012, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan Aßmus <superstippi@gmx.de>
7 */
8#ifndef SWATCH_VIEW_H
9#define SWATCH_VIEW_H
10
11#include <View.h>
12
13
14class SwatchView : public BView {
15public:
16								SwatchView(const char* name, BMessage* message,
17									BHandler* target, rgb_color color,
18									float width = 24.0, float height = 24.0);
19	virtual						~SwatchView();
20
21	// BView
22	virtual	void				Draw(BRect updateRect);
23	virtual	void				MessageReceived(BMessage* message);
24
25	virtual	void				MouseDown(BPoint where);
26	virtual	void				MouseUp(BPoint where);
27	virtual	void				MouseMoved(BPoint where, uint32 transit,
28									const BMessage* dragMessage);
29
30	// SwatchView
31			void				SetColor(rgb_color color);
32	inline	rgb_color			Color() const
33									{ return fColor; }
34
35			void				SetClickedMessage(BMessage* message);
36			void				SetDroppedMessage(BMessage* message);
37
38private:
39			void				_Invoke(const BMessage* message);
40			void				_StrokeRect(BRect frame, rgb_color leftTop,
41									rgb_color rightBottom);
42			void				_DragColor();
43
44private:
45			rgb_color			fColor;
46			BPoint				fTrackingStart;
47			bool				fActive;
48			bool				fDropInvokes;
49
50			BMessage*			fClickMessage;
51			BMessage*			fDroppedMessage;
52			BHandler*			fTarget;
53
54			float				fWidth;
55			float				fHeight;
56};
57
58#endif // SWATCH_VIEW_H
59