tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / SeparatorItem.cpp
blobef4abf794c9a39d12fbfd3a1c56cf431ef8ef77e
1 /*
2 * Copyright (c) 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Stefano Ceccherini, burton666@libero.it
7 * Marc Flerackers, mflerackers@androme.be
8 * Bill Hayden, haydentech@users.sourceforge.net
9 */
12 #include <SeparatorItem.h>
14 #include <Font.h>
17 BSeparatorItem::BSeparatorItem()
19 BMenuItem("", NULL)
21 BMenuItem::SetEnabled(false);
25 BSeparatorItem::BSeparatorItem(BMessage* data)
27 BMenuItem(data)
29 BMenuItem::SetEnabled(false);
33 BSeparatorItem::~BSeparatorItem()
38 status_t
39 BSeparatorItem::Archive(BMessage* data, bool deep) const
41 return BMenuItem::Archive(data, deep);
45 BArchivable*
46 BSeparatorItem::Instantiate(BMessage* data)
48 if (validate_instantiation(data, "BSeparatorItem"))
49 return new BSeparatorItem(data);
51 return NULL;
55 void
56 BSeparatorItem::SetEnabled(bool enable)
58 // Don't do anything - we don't want to get enabled ever
62 void
63 BSeparatorItem::GetContentSize(float* _width, float* _height)
65 if (_width != NULL)
66 *_width = 2.0;
68 if (_height != NULL) {
69 BFont font(be_plain_font);
70 if (Menu() != NULL)
71 Menu()->GetFont(&font);
73 const float height = floorf((font.Size() * 0.8) / 2) * 2;
74 *_height = max_c(4, height);
79 void
80 BSeparatorItem::Draw()
82 BMenu *menu = Menu();
83 if (menu == NULL)
84 return;
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() {}
109 BSeparatorItem &
110 BSeparatorItem::operator=(const BSeparatorItem &)
112 return *this;