1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6#include "ColorCheckBox.h"
7
8#include <SpaceLayoutItem.h>
9
10
11ColorCheckBox::ColorCheckBox(const char* label, const rgb_color& color,
12	BMessage* message)
13	:
14	BGroupView(B_HORIZONTAL),
15	fColor(color)
16{
17	SetFlags(Flags() | B_WILL_DRAW);
18
19	fCheckBox = new BCheckBox(label, message);
20	GroupLayout()->AddView(fCheckBox, 0);
21	AddChild(BSpaceLayoutItem::CreateHorizontalStrut(15));
22	AddChild(BSpaceLayoutItem::CreateGlue());
23}
24
25
26BCheckBox*
27ColorCheckBox::CheckBox() const
28{
29	return fCheckBox;
30}
31
32
33void
34ColorCheckBox::SetTarget(const BMessenger& target)
35{
36	fCheckBox->SetTarget(target);
37}
38
39
40void
41ColorCheckBox::Draw(BRect updateRect)
42{
43	BGroupView::Draw(updateRect);
44
45	BRect rect(Bounds());
46	rect.left += fCheckBox->Frame().right + 5;
47	rect.right = rect.left + 9;
48	rect.top = floorf((rect.top + rect.bottom) / 2);
49	rect.bottom = rect.top + 1;
50
51	SetHighColor(fColor);
52	FillRect(rect);
53}
54