2 * Copyright (c) 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
6 * Stefano Ceccherini, burton666@libero.it
7 * Marc Flerackers, mflerackers@androme.be
8 * Bill Hayden, haydentech@users.sourceforge.net
12 #include <SeparatorItem.h>
17 BSeparatorItem::BSeparatorItem()
21 BMenuItem::SetEnabled(false);
25 BSeparatorItem::BSeparatorItem(BMessage
* data
)
29 BMenuItem::SetEnabled(false);
33 BSeparatorItem::~BSeparatorItem()
39 BSeparatorItem::Archive(BMessage
* data
, bool deep
) const
41 return BMenuItem::Archive(data
, deep
);
46 BSeparatorItem::Instantiate(BMessage
* data
)
48 if (validate_instantiation(data
, "BSeparatorItem"))
49 return new BSeparatorItem(data
);
56 BSeparatorItem::SetEnabled(bool enable
)
58 // Don't do anything - we don't want to get enabled ever
63 BSeparatorItem::GetContentSize(float* _width
, float* _height
)
68 if (_height
!= NULL
) {
69 BFont
font(be_plain_font
);
71 Menu()->GetFont(&font
);
73 const float height
= floorf((font
.Size() * 0.8) / 2) * 2;
74 *_height
= max_c(4, height
);
80 BSeparatorItem::Draw()
86 BRect bounds
= Frame();
87 rgb_color oldColor
= menu
->HighColor();
88 rgb_color lowColor
= menu
->LowColor();
90 const float startTop
= bounds
.top
+ (floor(bounds
.Height())) / 2;
91 menu
->SetHighColor(tint_color(lowColor
, B_DARKEN_1_TINT
));
92 menu
->StrokeLine(BPoint(bounds
.left
+ 1.0f
, startTop
),
93 BPoint(bounds
.right
- 1.0f
, startTop
));
94 menu
->SetHighColor(tint_color(lowColor
, B_LIGHTEN_2_TINT
));
95 menu
->StrokeLine(BPoint(bounds
.left
+ 1.0f
, startTop
+ 1.0f
),
96 BPoint(bounds
.right
- 1.0f
, startTop
+ 1.0f
));
98 menu
->SetHighColor(oldColor
);
102 // #pragma mark - private
105 void BSeparatorItem::_ReservedSeparatorItem1() {}
106 void BSeparatorItem::_ReservedSeparatorItem2() {}
110 BSeparatorItem::operator=(const BSeparatorItem
&)