-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathColorMenuItem.cpp
52 lines (45 loc) · 1.12 KB
/
ColorMenuItem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mattias Sundblad
* Andrew Bachmann
*/
#include "ColorMenuItem.h"
#include <Message.h>
#include <Rect.h>
ColorMenuItem::ColorMenuItem(const char* label, rgb_color color,
BMessage *message)
:
BMenuItem(label, message, 0, 0),
fItemColor(color)
{
message->AddData("color", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
}
void
ColorMenuItem::DrawContent()
{
BMenu* menu = Menu();
if (menu) {
rgb_color menuColor = menu->HighColor();
BRect colorSquare(Frame());
if (colorSquare.Width() > colorSquare.Height()) {
// large button
colorSquare.left += 8;
colorSquare.top += 2;
colorSquare.bottom -= 2;
}
colorSquare.right = colorSquare.left + colorSquare.Height();
if (IsMarked()) {
menu->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
menu->StrokeRect(colorSquare);
}
colorSquare.InsetBy(1, 1);
menu->SetHighColor(fItemColor);
menu->FillRect(colorSquare);
menu->SetHighColor(menuColor);
menu->MovePenBy(colorSquare.right + 5.0f, 4.0f);
BMenuItem::DrawContent();
}
}