2006-03-11 00:13:18 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* Mattias Sundblad
|
|
|
|
|
* Andrew Bachmann
|
|
|
|
|
*/
|
|
|
|
|
|
2002-09-23 23:01:55 +00:00
|
|
|
#include "ColorMenuItem.h"
|
|
|
|
|
|
2007-09-04 03:08:40 +00:00
|
|
|
#include <Message.h>
|
2015-06-30 13:26:48 -04:00
|
|
|
#include <Rect.h>
|
2006-03-11 00:13:18 +00:00
|
|
|
|
2015-06-30 13:26:48 -04:00
|
|
|
|
|
|
|
|
ColorMenuItem::ColorMenuItem(const char* label, rgb_color color,
|
2012-07-25 19:16:11 +02:00
|
|
|
BMessage *message)
|
2015-06-30 13:26:48 -04:00
|
|
|
:
|
|
|
|
|
BMenuItem(label, message, 0, 0),
|
2007-09-05 02:47:33 +00:00
|
|
|
fItemColor(color)
|
2006-03-11 00:13:18 +00:00
|
|
|
{
|
2015-06-30 13:26:48 -04:00
|
|
|
message->AddData("color", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
|
2002-09-23 23:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
2006-03-11 00:13:18 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ColorMenuItem::DrawContent()
|
|
|
|
|
{
|
2012-07-25 19:16:11 +02:00
|
|
|
BMenu* menu = Menu();
|
2007-09-04 03:08:40 +00:00
|
|
|
if (menu) {
|
|
|
|
|
rgb_color menuColor = menu->HighColor();
|
2015-06-30 13:26:48 -04:00
|
|
|
BRect colorSquare(Frame());
|
2006-03-11 00:13:18 +00:00
|
|
|
|
2015-06-30 13:26:48 -04:00
|
|
|
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);
|
2007-09-04 03:08:40 +00:00
|
|
|
menu->SetHighColor(fItemColor);
|
2015-06-30 13:26:48 -04:00
|
|
|
menu->FillRect(colorSquare);
|
2007-09-04 03:08:40 +00:00
|
|
|
menu->SetHighColor(menuColor);
|
2015-06-30 13:26:48 -04:00
|
|
|
menu->MovePenBy(colorSquare.right + 5.0f, 4.0f);
|
|
|
|
|
BMenuItem::DrawContent();
|
2007-09-04 03:08:40 +00:00
|
|
|
}
|
2002-09-23 23:01:55 +00:00
|
|
|
}
|