57 kShiftGlyph = 0x05,
58 kOptionGlyph = 0x07,
59 kControlGlyph = 0x06,
60 kPencilGlyph = 0x0F,
61 kCommandMark = 0x11;
62
63 // Unicode character codes
64 static final char
65 kUBlackDiamond = 0x25C6,
66 kUCheckMark = 0x2713,
67 kUControlGlyph = 0x2303,
68 kUOptionGlyph = 0x2325,
69 kUEnterGlyph = 0x2324,
70 kUCommandGlyph = 0x2318,
71 kULeftDeleteGlyph = 0x232B,
72 kURightDeleteGlyph = 0x2326,
73 kUShiftGlyph = 0x21E7,
74 kUCapsLockGlyph = 0x21EA;
75
76 static final int ALT_GRAPH_MASK = 1 << 5; // New to Java2
77 static final int sUnsupportedModifiersMask = ~(InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.SHIFT_MASK | InputEvent.META_MASK | ALT_GRAPH_MASK);
78
79 interface Client {
80 public void paintBackground(Graphics g, JComponent c, int menuWidth, int menuHeight);
81 }
82
83 // Return a string with the proper modifier glyphs
84 static String getKeyModifiersText(final int modifiers, final boolean isLeftToRight) {
85 return getKeyModifiersUnicode(modifiers, isLeftToRight);
86 }
87
88 // Return a string with the proper modifier glyphs
89 private static String getKeyModifiersUnicode(final int modifiers, final boolean isLeftToRight) {
90 final StringBuilder buf = new StringBuilder(2);
91 // Order (from StandardMenuDef.c): control, option(alt), shift, cmd
92 // reverse for right-to-left
93 //$ check for substitute key glyphs for localization
94 if (isLeftToRight) {
95 if ((modifiers & InputEvent.CTRL_MASK) != 0) {
96 buf.append(kUControlGlyph);
97 }
98 if ((modifiers & (InputEvent.ALT_MASK | ALT_GRAPH_MASK)) != 0) {
99 buf.append(kUOptionGlyph);
100 }
101 if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
102 buf.append(kUShiftGlyph);
103 }
104 if ((modifiers & InputEvent.META_MASK) != 0) {
105 buf.append(kUCommandGlyph);
106 }
107 } else {
108 if ((modifiers & InputEvent.META_MASK) != 0) {
|
57 kShiftGlyph = 0x05,
58 kOptionGlyph = 0x07,
59 kControlGlyph = 0x06,
60 kPencilGlyph = 0x0F,
61 kCommandMark = 0x11;
62
63 // Unicode character codes
64 static final char
65 kUBlackDiamond = 0x25C6,
66 kUCheckMark = 0x2713,
67 kUControlGlyph = 0x2303,
68 kUOptionGlyph = 0x2325,
69 kUEnterGlyph = 0x2324,
70 kUCommandGlyph = 0x2318,
71 kULeftDeleteGlyph = 0x232B,
72 kURightDeleteGlyph = 0x2326,
73 kUShiftGlyph = 0x21E7,
74 kUCapsLockGlyph = 0x21EA;
75
76 static final int ALT_GRAPH_MASK = 1 << 5; // New to Java2
77 @SuppressWarnings("deprecation")
78 static final int sUnsupportedModifiersMask =
79 ~(InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.SHIFT_MASK
80 | InputEvent.META_MASK | ALT_GRAPH_MASK);
81
82 interface Client {
83 public void paintBackground(Graphics g, JComponent c, int menuWidth, int menuHeight);
84 }
85
86 // Return a string with the proper modifier glyphs
87 static String getKeyModifiersText(final int modifiers, final boolean isLeftToRight) {
88 return getKeyModifiersUnicode(modifiers, isLeftToRight);
89 }
90
91 // Return a string with the proper modifier glyphs
92 @SuppressWarnings("deprecation")
93 private static String getKeyModifiersUnicode(final int modifiers, final boolean isLeftToRight) {
94 final StringBuilder buf = new StringBuilder(2);
95 // Order (from StandardMenuDef.c): control, option(alt), shift, cmd
96 // reverse for right-to-left
97 //$ check for substitute key glyphs for localization
98 if (isLeftToRight) {
99 if ((modifiers & InputEvent.CTRL_MASK) != 0) {
100 buf.append(kUControlGlyph);
101 }
102 if ((modifiers & (InputEvent.ALT_MASK | ALT_GRAPH_MASK)) != 0) {
103 buf.append(kUOptionGlyph);
104 }
105 if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
106 buf.append(kUShiftGlyph);
107 }
108 if ((modifiers & InputEvent.META_MASK) != 0) {
109 buf.append(kUCommandGlyph);
110 }
111 } else {
112 if ((modifiers & InputEvent.META_MASK) != 0) {
|