2 * Copyright 2001-2002 OpenBeOS
3 * Copyright 2003-2016 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
7 * DarkWyrm, darkwyrm@earthlink.net
8 * Rene Gollent, rene@gollent.com
9 * Ryan Leavengood, leavengood@gmail.com
10 * John Scipione, jscipione@gmail.com
14 #include "ColorWhichItem.h"
18 #include <ControlLook.h>
25 #define M_PHI 1.61803398874989484820
28 ColorWhichItem::ColorWhichItem(const char* text
, color_which which
,
31 BStringItem(text
, 0, false),
39 ColorWhichItem::DrawItem(BView
* owner
, BRect frame
, bool complete
)
41 rgb_color highColor
= owner
->HighColor();
42 rgb_color lowColor
= owner
->LowColor();
44 if (IsSelected() || complete
) {
46 owner
->SetHighUIColor(B_LIST_SELECTED_BACKGROUND_COLOR
);
47 owner
->SetLowColor(owner
->HighColor());
49 owner
->SetHighColor(lowColor
);
51 owner
->FillRect(frame
);
54 float spacer
= ceilf(be_control_look
->DefaultItemSpacing() / 2);
56 BRect
colorRect(frame
);
57 colorRect
.InsetBy(2.0f
, 2.0f
);
58 colorRect
.left
+= spacer
;
59 colorRect
.right
= colorRect
.left
+ floorf(colorRect
.Height() * M_PHI
);
60 owner
->SetHighColor(fColor
);
61 owner
->FillRect(colorRect
);
62 owner
->SetHighUIColor(B_CONTROL_BORDER_COLOR
);
63 owner
->StrokeRect(colorRect
);
65 owner
->MovePenTo(colorRect
.right
+ spacer
, frame
.top
+ BaselineOffset());
68 rgb_color textColor
= ui_color(B_LIST_ITEM_TEXT_COLOR
);
69 if (textColor
.red
+ textColor
.green
+ textColor
.blue
> 128 * 3)
70 owner
->SetHighColor(tint_color(textColor
, B_DARKEN_2_TINT
));
72 owner
->SetHighColor(tint_color(textColor
, B_LIGHTEN_2_TINT
));
75 owner
->SetHighUIColor(B_LIST_SELECTED_ITEM_TEXT_COLOR
);
77 owner
->SetHighUIColor(B_LIST_ITEM_TEXT_COLOR
);
80 owner
->DrawString(Text());
82 owner
->SetHighColor(highColor
);
83 owner
->SetLowColor(lowColor
);