Files
haiku-beta6/src/apps/stylededit/ColorMenuItem.cpp
T
Philippe Saint-Pierre e62d9cf8c5 StyledEdit: Rework of the font color system
1) The default font color is now B_DOCUMENT_TEXT_COLOR
2) The font color menu now shows a palette
3) The font color menu now includes a "default" item, set
to B_DOCUMENT_TEXT_COLOR
4) Added a Todo mentionning it would be ideal to not save the default color
itself, but instead saving the fact the default color was used. Maybe allow the
StyleBuffer to use a Null color or something similar.
2015-06-30 13:32:45 -04:00

53 lines
1.1 KiB
C++

/*
* 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();
}
}