1/*
2 * Copyright 2010, Axel D��rfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef RADIO_VIEW_H
6#define RADIO_VIEW_H
7
8
9#include <View.h>
10
11
12class BMessageRunner;
13
14
15class RadioView : public BView {
16public:
17								RadioView(BRect frame, const char* name,
18									int32 resizingMode);
19	virtual						~RadioView();
20
21			void				SetPercent(int32 percent);
22			void				SetMax(int32 max);
23
24			void				StartPulsing();
25			void				StopPulsing();
26			bool				IsPulsing() const
27									{ return fPulse != NULL; }
28
29	static	void				Draw(BView* view, BRect rect, int32 percent,
30									int32 count);
31	static	int32				DefaultMax();
32
33protected:
34	virtual	void				AttachedToWindow();
35	virtual	void				DetachedFromWindow();
36
37	virtual	void				MessageReceived(BMessage* message);
38	virtual	void				Draw(BRect updateRect);
39	virtual void				FrameResized(float width, float height);
40
41private:
42			void				_RestartPulsing();
43
44	static	void				_Compute(const BRect& bounds, BPoint& center,
45									int32& count, int32 max, float& step);
46	static	void				_DrawBow(BView* view, int32 index,
47									const BPoint& center, int32 count,
48									float step);
49	static	void				_SetColor(BView* view, int32 percent,
50									int32 phase, int32 index, int32 count);
51	static	bool				_IsDisabled(int32 percent, int32 index,
52									int32 count);
53
54private:
55			int32				fPercent;
56			BMessageRunner*		fPulse;
57			int32				fPhase;
58			int32				fMax;
59};
60
61
62#endif	// RADIO_VIEW_H
63