diff --git a/headers/os/interface/MenuItem.h b/headers/os/interface/MenuItem.h index 80c25f15a3..777ff3284c 100644 --- a/headers/os/interface/MenuItem.h +++ b/headers/os/interface/MenuItem.h @@ -93,9 +93,9 @@ private: void DrawMarkSymbol(rgb_color bgColor); void DrawShortcutSymbol(); void DrawSubmenuSymbol(rgb_color bgColor); - void DrawControlChar(const char *control); + void _DrawControlChar(char shortcut, BPoint where); void SetSysTrigger(char ch); - + char *fLabel; BMenu *fSubmenu; BWindow *fWindow; diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 38f3068a4e..07452322de 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -22,7 +22,7 @@ const uint32 kCtrlLength = 20*11; -const unsigned char kCtrlBits [] = { +const unsigned char kCtrlBits[] = { 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,0xff,0xff,0xff, 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0xff,0xff,0xff, 0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0xff,0xff,0xff, @@ -43,7 +43,7 @@ const unsigned char kCtrlBits [] = { const uint32 kAltLength = 20*11; -const unsigned char kAltBits [] = { +const unsigned char kAltBits[] = { 0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,0xff,0xff,0xff, 0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0xff,0xff,0xff, 0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,0xff,0xff,0xff, @@ -64,7 +64,7 @@ const unsigned char kAltBits [] = { const uint32 kShiftLength = 24*11; -const unsigned char kShiftBits [] = { +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,0xff,0xff, 0x1d,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x19,0x17,0xff,0xff, 0x1d,0x1b,0x1b,0x17,0x0d,0x0d,0x17,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x19,0x17,0xff,0xff, @@ -85,6 +85,7 @@ const unsigned char kShiftBits [] = { const float kLightBGTint = (B_LIGHTEN_1_TINT + B_LIGHTEN_1_TINT + B_NO_TINT) / 3.0; + BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut, uint32 modifiers) { @@ -707,11 +708,20 @@ BMenuItem::DrawShortcutSymbol() if (fSubmenu) where.x -= 12; - // 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->DrawChar(fShortcutChar, where + BPoint(0, fSuper->fAscent)); - + switch (fShortcutChar) { + case B_DOWN_ARROW: + case B_UP_ARROW: + case B_LEFT_ARROW: + case B_RIGHT_ARROW: + case B_ENTER: + _DrawControlChar(fShortcutChar, where + BPoint(0, fSuper->fAscent)); + break; + + default: + fSuper->DrawChar(fShortcutChar, where + BPoint(0, fSuper->fAscent)); + break; + } + where -= BPoint(20, -1); if (fModifiers & B_COMMAND_KEY) { @@ -782,9 +792,31 @@ BMenuItem::DrawSubmenuSymbol(rgb_color bgColor) void -BMenuItem::DrawControlChar(const char *control) +BMenuItem::_DrawControlChar(char shortcut, BPoint where) { - // TODO: Implement + const char* symbol = " "; + + switch (shortcut) { + case B_DOWN_ARROW: + symbol = "\xe2\x86\x93"; + break; + case B_UP_ARROW: + symbol = "\xe2\x86\x91"; + break; + case B_LEFT_ARROW: + symbol = "\xe2\x86\x90"; + break; + case B_RIGHT_ARROW: + symbol = "\xe2\x86\x92"; + break; + case B_ENTER: + // TODO: find a better one for this! + // If needed, take another font for the control characters + symbol = "\xe2\x86\x99"; + break; + } + + fSuper->DrawString(symbol, where); }