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 12 class BMessageRunner; 13 14 15 class RadioView : public BView { 16 public: 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 protected: 30 virtual void AttachedToWindow(); 31 virtual void DetachedFromWindow(); 32 33 virtual void MessageReceived(BMessage* message); 34 virtual void Draw(BRect updateRect); 35 virtual void FrameResized(float width, float height); 36 37 private: 38 void _RestartPulsing(); 39 void _Compute(const BRect& bounds, BPoint& center, 40 int32& count, float& step) const; 41 void _DrawBow(int32 index, const BPoint& center, 42 int32 count, float step); 43 void _SetColor(int32 index, int32 count); 44 bool _IsDisabled(int32 index, int32 count) const; 45 46 private: 47 int32 fPercent; 48 BMessageRunner* fPulse; 49 int32 fPhase; 50 int32 fMax; 51 }; 52 53 54 #endif // RADIO_VIEW_H 55