tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / MenuPrivate.cpp
blobe824e27dc1d769cb813c3f0a96c96edfc9232b6e
1 /*
2 * Copyright 2001-2009, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stefano Ceccherini (stefano.ceccherini@gmail.com)
7 */
9 #include <MenuPrivate.h>
11 #include <Bitmap.h>
12 #include <Menu.h>
15 const unsigned char kShiftBits[] = {
16 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
17 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
18 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
19 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
20 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
21 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
22 0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
23 0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
24 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
25 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
26 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
30 const unsigned char kCtrlBits[] = {
31 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
32 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
33 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
34 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
35 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
36 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
37 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
38 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x13,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
39 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
40 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
41 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
45 const unsigned char kOptBits[] = {
46 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
47 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
48 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
49 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
50 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14,
51 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
52 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
53 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
54 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
55 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
56 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
60 const unsigned char kAltBits[] = {
61 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
62 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
63 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
64 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
65 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
66 0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
67 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
68 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14,
69 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
70 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
71 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
75 const unsigned char kMenuBits[] = {
76 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
77 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
78 0x1d,0x1a,0x1a,0x04,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
79 0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
80 0x1d,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
81 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
82 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
83 0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
84 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
85 0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
86 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
90 namespace BPrivate {
93 BBitmap* MenuPrivate::sMenuItemShift;
94 BBitmap* MenuPrivate::sMenuItemControl;
95 BBitmap* MenuPrivate::sMenuItemOption;
96 BBitmap* MenuPrivate::sMenuItemAlt;
97 BBitmap* MenuPrivate::sMenuItemMenu;
100 MenuPrivate::MenuPrivate(BMenu* menu)
102 fMenu(menu)
107 menu_layout
108 MenuPrivate::Layout() const
110 return fMenu->Layout();
114 void
115 MenuPrivate::SetLayout(menu_layout layout)
117 fMenu->fLayout = layout;
121 void
122 MenuPrivate::ItemMarked(BMenuItem *item)
124 fMenu->_ItemMarked(item);
128 void
129 MenuPrivate::CacheFontInfo()
131 fMenu->_CacheFontInfo();
135 float
136 MenuPrivate::FontHeight() const
138 return fMenu->fFontHeight;
142 float
143 MenuPrivate::Ascent() const
145 return fMenu->fAscent;
149 BRect
150 MenuPrivate::Padding() const
152 return fMenu->fPad;
156 void
157 MenuPrivate::GetItemMargins(float* left, float* top, float* right,
158 float* bottom) const
160 fMenu->GetItemMargins(left, top, right, bottom);
165 MenuPrivate::State(BMenuItem** item) const
167 return fMenu->_State(item);
171 void
172 MenuPrivate::Install(BWindow* window)
174 fMenu->_Install(window);
178 void
179 MenuPrivate::Uninstall()
181 fMenu->_Uninstall();
185 void
186 MenuPrivate::SetSuper(BMenu* menu)
188 fMenu->fSuper = menu;
192 void
193 MenuPrivate::SetSuperItem(BMenuItem* item)
195 fMenu->fSuperitem = item;
199 void
200 MenuPrivate::InvokeItem(BMenuItem* item, bool now)
202 fMenu->_InvokeItem(item, now);
206 void
207 MenuPrivate::QuitTracking(bool thisMenuOnly)
209 fMenu->_QuitTracking(thisMenuOnly);
213 /* static */
214 status_t
215 MenuPrivate::CreateBitmaps()
217 BRect smallRect(0, 0, 16, 10);
219 try {
220 sMenuItemShift = new BBitmap(BRect(0, 0, 23, 10), B_CMAP8);
221 sMenuItemControl = new BBitmap(BRect(0, 0, 21, 10), B_CMAP8);
222 sMenuItemOption = new BBitmap(smallRect, B_CMAP8);
223 sMenuItemAlt = new BBitmap(smallRect, B_CMAP8);
224 sMenuItemMenu = new BBitmap(BRect(0, 0, 22, 10), B_CMAP8);
225 } catch (...) {
226 return B_NO_MEMORY;
229 sMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits),
230 24, 0, B_CMAP8);
231 sMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits),
232 22, 0, B_CMAP8);
233 sMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits),
234 17, 0, B_CMAP8);
235 sMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits),
236 17, 0, B_CMAP8);
237 sMenuItemMenu->ImportBits(kMenuBits, sizeof(kMenuBits),
238 23, 0, B_CMAP8);
240 return B_OK;
244 /* static */
245 void
246 MenuPrivate::DeleteBitmaps()
248 delete sMenuItemShift;
249 delete sMenuItemControl;
250 delete sMenuItemOption;
251 delete sMenuItemAlt;
252 delete sMenuItemMenu;
256 /* static */
257 const BBitmap*
258 MenuPrivate::MenuItemShift()
260 return sMenuItemShift;
264 /* static */
265 const BBitmap*
266 MenuPrivate::MenuItemControl()
268 switch (BMenu::sControlKey) {
269 case 0x5d:
270 case 0x5f:
271 return sMenuItemAlt;
272 case 0x66:
273 case 0x67:
274 return sMenuItemOption;
277 return sMenuItemControl;
281 /* static */
282 const BBitmap*
283 MenuPrivate::MenuItemOption()
285 switch (BMenu::sOptionKey) {
286 case 0x5c:
287 case 0x60:
288 return sMenuItemControl;
289 case 0x66:
290 case 0x67:
291 return sMenuItemOption;
294 return sMenuItemAlt;
298 /* static */
299 const BBitmap*
300 MenuPrivate::MenuItemCommand()
302 switch (BMenu::sCommandKey) {
303 case 0x5c:
304 case 0x60:
305 return sMenuItemControl;
306 case 0x66:
307 case 0x67:
308 return sMenuItemOption;
311 return sMenuItemAlt;
315 /* static */
316 const BBitmap*
317 MenuPrivate::MenuItemMenu()
319 return sMenuItemMenu;
323 } // namespace BPrivate