Now BSeparatorItem's Draw() checks the separator type. Implemented separator type "1". Please, someone with a better "artistic" skill than me, feel free to implement separator type "2" and check if the drawing of the others is correct :)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10554 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-12-31 09:04:14 +00:00
parent efa306a09d
commit 7ca9166efa
+47 -15
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2004, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -22,11 +22,13 @@
// File Name: SeparatorItem.cpp
// Author: Marc Flerackers ([email protected])
// Bill Hayden ([email protected])
// Stefano Ceccherini ([email protected])
// Description: Display separator item for BMenu class
//
//------------------------------------------------------------------------------
#include <MenuItem.h>
#include <Message.h>
#include <stdio.h>
BSeparatorItem::BSeparatorItem()
@@ -66,15 +68,16 @@ BSeparatorItem::Instantiate(BMessage *data)
void
BSeparatorItem::SetEnabled(bool state)
{
// Don't do anything
}
void
BSeparatorItem::GetContentSize(float *width, float *height)
{
if (width)
if (width != NULL)
*width = 2.0f;
if (height)
if (height != NULL)
*height = 8.0f;
}
@@ -82,18 +85,47 @@ BSeparatorItem::GetContentSize(float *width, float *height)
void
BSeparatorItem::Draw()
{
BMenu *menu = Menu();
if (menu == NULL)
return;
BRect bounds = Frame();
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_LIGHTEN_2_TINT));
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
Menu()->SetHighColor(0, 0, 0);
// TODO: Calling this on every Draw() doesn't seem nice.
menu_info menuInfo;
get_menu_info(&menuInfo);
switch (menuInfo.separator) {
case 0:
// TODO: Check if drawing is pixel perfect
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_LIGHTEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
menu->SetHighColor(0, 0, 0);
break;
case 1:
// TODO: Check if drawing is pixel perfect
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 4.0f),
BPoint(bounds.right - 9.0f, bounds.top + 4.0f));
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_LIGHTEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 5.0f),
BPoint(bounds.right - 9.0f, bounds.top + 5.0f));
menu->SetHighColor(0, 0, 0);
break;
case 2: // TODO: Implement "type 2" look
default:
printf("BSeparatorItem::Draw(): Separator item look not supported yet\n");
break;
}
}