draws CTL/ALT and SHFT bitmaps, not clean yet (green pixels)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16470 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f0bac93530
commit
5f71cfd4bc
@ -36,6 +36,61 @@
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
const unsigned char kCtrlBits [] = {
|
||||
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,
|
||||
0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,
|
||||
0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x04,0x1a,
|
||||
0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,
|
||||
0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,
|
||||
0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,
|
||||
0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x13,0x04,
|
||||
0x04,0x13,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,0x3f,0x3f,0x3f,
|
||||
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
|
||||
0x17,0x17,0x17,0x17,0x14,0x3f,0x3f,0x3f,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
|
||||
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x3f,0x3f,0x3f
|
||||
};
|
||||
|
||||
|
||||
const unsigned char kAltBits [] = {
|
||||
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,
|
||||
0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,
|
||||
0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x04,
|
||||
0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,0x3f,0x3f,0x3f,
|
||||
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,
|
||||
0x04,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,
|
||||
0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,0x1d,0x1a,0x1a,0x04,
|
||||
0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14,0x3f,0x3f,0x3f,
|
||||
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,
|
||||
0x14,0x3f,0x3f,0x3f,0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
|
||||
0x17,0x17,0x17,0x17,0x14,0x3f,0x3f,0x3f,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
|
||||
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x3f,0x3f,0x3f
|
||||
};
|
||||
|
||||
const unsigned char kShiftBits [] = {
|
||||
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,
|
||||
0x1d,0x1d,0x1d,0x1d,0x1d,0x17,0x3f,0x3f,0x1d,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
|
||||
0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x19,0x17,0x3f,0x3f,
|
||||
0x1d,0x1b,0x1b,0x17,0x0d,0x0d,0x17,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
|
||||
0x1b,0x1b,0x1b,0x1b,0x19,0x17,0x3f,0x3f,0x1d,0x1b,0x1b,0x0d,0x19,0x19,0x0d,0x1b,
|
||||
0x0d,0x1b,0x0d,0x1b,0x0d,0x0d,0x0d,0x1b,0x0d,0x0d,0x0d,0x1b,0x19,0x17,0x3f,0x3f,
|
||||
0x1d,0x1b,0x1b,0x17,0x0d,0x0d,0x19,0x1b,0x0d,0x1b,0x0d,0x1b,0x0d,0x1b,0x1b,0x1b,
|
||||
0x1b,0x0d,0x1b,0x1b,0x19,0x17,0x3f,0x3f,0x1d,0x1b,0x1b,0x1b,0x1b,0x1b,0x0d,0x1b,
|
||||
0x0d,0x0d,0x0d,0x1b,0x0d,0x0d,0x1b,0x1b,0x1b,0x0d,0x1b,0x1b,0x19,0x17,0x3f,0x3f,
|
||||
0x1d,0x1b,0x1b,0x0d,0x19,0x19,0x0d,0x1b,0x0d,0x1b,0x0d,0x1b,0x0d,0x1b,0x1b,0x1b,
|
||||
0x1b,0x0d,0x1b,0x1b,0x19,0x17,0x3f,0x3f,0x1d,0x1b,0x1b,0x17,0x0d,0x0d,0x17,0x1b,
|
||||
0x0d,0x1b,0x0d,0x1b,0x0d,0x1b,0x1b,0x1b,0x1b,0x0d,0x1b,0x1b,0x19,0x17,0x3f,0x3f,
|
||||
0x1d,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
|
||||
0x1b,0x1b,0x1b,0x1b,0x19,0x17,0x3f,0x3f,0x1d,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
|
||||
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x17,0x3f,0x3f,
|
||||
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
|
||||
0x17,0x17,0x17,0x17,0x17,0x17,0x3f,0x3f
|
||||
};
|
||||
|
||||
|
||||
BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut,
|
||||
uint32 modifiers)
|
||||
@ -646,17 +701,34 @@ BMenuItem::DrawMarkSymbol()
|
||||
void
|
||||
BMenuItem::DrawShortcutSymbol()
|
||||
{
|
||||
BString shortcut("");
|
||||
|
||||
if (fModifiers & B_CONTROL_KEY)
|
||||
shortcut += "ctl+";
|
||||
|
||||
shortcut += fShortcutChar;
|
||||
|
||||
if (fModifiers & B_COMMAND_KEY) {
|
||||
key_map *keys;
|
||||
char *chars;
|
||||
get_key_map(&keys, &chars);
|
||||
BRect rect(0,0,16,10);
|
||||
BBitmap control(rect, B_COLOR_8_BIT);
|
||||
if ((keys->left_command_key == 0x5d) && (keys->right_command_key == 0x5f))
|
||||
control.SetBits(kAltBits, (rect.Width() + 1) * (rect.Height() + 1), 0, B_COLOR_8_BIT);
|
||||
else
|
||||
control.SetBits(kCtrlBits, (rect.Width() + 1) * (rect.Height() + 1), 0, B_COLOR_8_BIT);
|
||||
fSuper->DrawBitmap(&control, ContentLocation() +
|
||||
BPoint(fBounds.Width() - 14.0f - 52.0f, fBounds.Height() - 4.0f - rect.Height()));
|
||||
|
||||
free(chars);
|
||||
free(keys);
|
||||
}
|
||||
if (fModifiers & B_SHIFT_KEY) {
|
||||
BRect rect(0,0,21,10);
|
||||
BBitmap shift(rect, B_COLOR_8_BIT);
|
||||
shift.SetBits(kShiftBits, (rect.Width() + 1) * (rect.Height() + 1), 0, B_COLOR_8_BIT);
|
||||
fSuper->DrawBitmap(&shift, ContentLocation() +
|
||||
BPoint(fBounds.Width() - 14.0f - 74.0f, fBounds.Height() - 4.0f - rect.Height()));
|
||||
}
|
||||
|
||||
// TODO: If the shortcut is one of B_DOWN_ARROW, B_UP_ARROW, B_ENTER, etc.
|
||||
// we can't just use DrawString(), as those aren't valid ascii/UTF8 charachters.
|
||||
// In that case we need to build a BBitmap for the given shortcut and draw it using DrawBitmap()
|
||||
fSuper->DrawString(shortcut.String(), ContentLocation() +
|
||||
fSuper->DrawChar(fShortcutChar, ContentLocation() +
|
||||
BPoint(fBounds.Width() - 14.0f - 32.0f, fBounds.Height() - 4.0f));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user