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 #include <layout.h> 15 16 enum { 17 MSG_COLOR_DROP = 'PSTE', 18 }; 19 20 class SwatchView : public MView, public BView { 21 public: 22 SwatchView(const char* name, 23 BMessage* message, 24 BHandler* target, 25 rgb_color color, 26 float width = 24.0, 27 float height = 24.0); 28 virtual ~SwatchView(); 29 30 // MView 31 virtual minimax layoutprefs(); 32 virtual BRect layout(BRect frame); 33 34 // BView 35 virtual void Draw(BRect updateRect); 36 virtual void MessageReceived(BMessage* message); 37 38 virtual void MouseDown(BPoint where); 39 virtual void MouseUp(BPoint where); 40 virtual void MouseMoved(BPoint where, uint32 transit, 41 const BMessage* dragMessage); 42 43 // SwatchView 44 void SetColor(rgb_color color); 45 rgb_color Color() const 46 { return fColor; } 47 48 void SetClickedMessage(BMessage* message); 49 void SetDroppedMessage(BMessage* message); 50 51 private: 52 void _Invoke(const BMessage* message); 53 void _StrokeRect(BRect frame, rgb_color leftTop, 54 rgb_color rightBottom); 55 void _DragColor(); 56 57 rgb_color fColor; 58 BPoint fTrackingStart; 59 bool fActive; 60 bool fDropInvokes; 61 62 BMessage* fClickMessage; 63 BMessage* fDroppedMessage; 64 BHandler* fTarget; 65 66 float fWidth; 67 float fHeight; 68 }; 69 70 #endif // SWATCH_VIEW_H 71