BMenuItem now also draws the trigger at the right position. There was a small visual glitch because the menu's lowcolor was not resetted: fixed. BMenuItem::Draw() needs a cleanup.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-01-18 13:44:36 +00:00
parent 727e24f793
commit 6c857bb9fe

View File

@ -347,21 +347,40 @@ void
BMenuItem::DrawContent()
{
fSuper->MovePenBy(0, fSuper->fAscent);
BPoint lineStart = fSuper->PenLocation();
fSuper->DrawString(fLabel);
// ToDo: label truncation is missing
// ToDo: draw trigger is missing!
if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) {
float escapements[128]; // TODO: this doesn't look nice
BFont font;
fSuper->GetFont(&font);
font.GetEscapements(fLabel, fTriggerIndex + 1, escapements);
for (int32 i = 0; i < fTriggerIndex; i++)
lineStart.x += escapements[i] * font.Size();
lineStart.x--;
lineStart.y++;
BPoint lineEnd(lineStart);
lineEnd.x += escapements[fTriggerIndex] * font.Size();
fSuper->StrokeLine(lineStart, lineEnd);
}
}
void
BMenuItem::Draw()
{
// TODO: Cleanup
bool enabled = IsEnabled();
fSuper->CacheFontInfo();
if (IsSelected() && (enabled || Submenu())/* && fSuper->fRedrawAfterSticky*/) {
if (IsSelected() && (enabled || Submenu()) /*&& fSuper->fRedrawAfterSticky*/) {
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
fSuper->SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
@ -379,8 +398,11 @@ BMenuItem::Draw()
B_DISABLED_LABEL_TINT));
fSuper->MovePenTo(ContentLocation());
DrawContent();
fSuper->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
if (fSuper->Layout() == B_ITEMS_IN_COLUMN) {
if (IsMarked())
DrawMarkSymbol();
@ -459,10 +481,9 @@ BMenuItem::InitMenuData(BMenu *menu)
fSubmenu = menu;
fSubmenu->fSuperitem = this;
BMenuItem *item;
BMenuItem *item = menu->FindMarked();
if (menu->IsRadioMode() && menu->IsLabelFromMarked() &&
(item = menu->FindMarked()) != NULL)
if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL)
SetLabel(item->Label());
else
SetLabel(menu->Name());