xref: /haiku/src/apps/icon-o-matic/generic/property/view/specific_properties/SwatchValueView.cpp (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
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 #include "SwatchValueView.h"
10 
11 #include <stdio.h>
12 
13 // constructor
14 SwatchValueView::SwatchValueView(const char* name,
15 								 BMessage* message,
16 								 BHandler* target,
17 								 rgb_color color,
18 								 float width,
19 								 float height)
20 	: SwatchView(name, message, target, color, width, height)
21 {
22 	uint32 flags = Flags();
23 	flags |= B_NAVIGABLE;
24 	SetFlags(flags);
25 }
26 
27 // destructor
28 SwatchValueView::~SwatchValueView()
29 {
30 }
31 
32 // MakeFocus
33 void
34 SwatchValueView::MakeFocus(bool focused)
35 {
36 	BView::MakeFocus(focused);
37 	if (BView* parent = Parent())
38 		parent->Invalidate();
39 }
40 
41 // Draw
42 void
43 SwatchValueView::Draw(BRect updateRect)
44 {
45 	BRect b(Bounds());
46 	if (BView* parent = Parent()) {
47 		SetLowColor(tint_color(parent->LowColor(), B_DARKEN_1_TINT));
48 		StrokeRect(b, B_SOLID_LOW);
49 		b.InsetBy(1.0, 1.0);
50 	}
51 	FillRect(b);
52 }
53 
54 // MouseDown
55 void
56 SwatchValueView::MouseDown(BPoint where)
57 {
58 	// forward click
59 	if (BView* parent = Parent())
60 		parent->MouseDown(ConvertToParent(where));
61 
62 	SwatchView::MouseDown(where);
63 }
64