From 7ca9166efa317426096426a03a05832eee0a1beb Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 31 Dec 2004 09:04:14 +0000 Subject: [PATCH] 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 --- src/kits/interface/SeparatorItem.cpp | 62 +++++++++++++++++++++------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/src/kits/interface/SeparatorItem.cpp b/src/kits/interface/SeparatorItem.cpp index cec8189e5f..9ee65bc875 100644 --- a/src/kits/interface/SeparatorItem.cpp +++ b/src/kits/interface/SeparatorItem.cpp @@ -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 (mflerackers@androme.be) // Bill Hayden (haydentech@users.sourceforge.net) +// Stefano Ceccherini (burton666@libero.it) // Description: Display separator item for BMenu class // //------------------------------------------------------------------------------ #include -#include + +#include 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; + } }