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