xref: /haiku/src/kits/interface/SeparatorItem.cpp (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
1 /*
2  * Copyright (c) 2001-2006, Haiku, Inc.
3  * Distributed under the terms of the MIT license.
4  *
5  * Authors:
6  *		Marc Flerackers (mflerackers@androme.be)
7  *		Bill Hayden (haydentech@users.sourceforge.net)
8  *		Stefano Ceccherini (burton666@libero.it)
9  */
10 
11 /*!	Display separator item for BMenu class */
12 
13 
14 #include <SeparatorItem.h>
15 
16 
17 BSeparatorItem::BSeparatorItem()
18 	: BMenuItem("", NULL)
19 {
20 	BMenuItem::SetEnabled(false);
21 }
22 
23 
24 BSeparatorItem::BSeparatorItem(BMessage* archive)
25 	: BMenuItem(archive)
26 {
27 	BMenuItem::SetEnabled(false);
28 }
29 
30 
31 BSeparatorItem::~BSeparatorItem()
32 {
33 }
34 
35 
36 status_t
37 BSeparatorItem::Archive(BMessage* archive, bool deep) const
38 {
39 	return BMenuItem::Archive(archive, deep);
40 }
41 
42 
43 BArchivable *
44 BSeparatorItem::Instantiate(BMessage* archive)
45 {
46 	if (validate_instantiation(archive, "BSeparatorItem"))
47 		return new BSeparatorItem(archive);
48 
49 	return NULL;
50 }
51 
52 
53 void
54 BSeparatorItem::SetEnabled(bool state)
55 {
56 	// Don't do anything - we don't want to get enabled ever
57 }
58 
59 
60 void
61 BSeparatorItem::GetContentSize(float* _width, float* _height)
62 {
63 	if (_width != NULL)
64 		*_width = 2.0f;
65 
66 	if (_height != NULL)
67 		*_height = 8.0f;
68 }
69 
70 
71 void
72 BSeparatorItem::Draw()
73 {
74 	BMenu *menu = Menu();
75 	if (menu == NULL)
76 		return;
77 
78 	BRect bounds = Frame();
79 	rgb_color oldColor = menu->HighColor();
80 
81 	menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
82 	menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f), BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
83 	menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
84 	menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f), BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
85 
86 	menu->SetHighColor(oldColor);
87 }
88 
89 
90 //	#pragma mark - private
91 
92 
93 void BSeparatorItem::_ReservedSeparatorItem1() {}
94 void BSeparatorItem::_ReservedSeparatorItem2() {}
95 
96 
97 BSeparatorItem &
98 BSeparatorItem::operator=(const BSeparatorItem &)
99 {
100 	return *this;
101 }
102