1 | Dimension getPreferredSize()↵ | | 1 | Dimension getPreferredSize()↵
|
2 | {↵ | | 2 | {↵
|
3 | Dimension d = super.getPreferredSize();↵ | | 3 | Dimension d = super.getPreferredSize();↵
|
|
4 | if(shortcut != null)↵ | | 4 | if(shortcut != null)↵
|
5 | {↵ | | 5 | {↵
|
6 | d.width += (getFontMetrics(acceleratorFont)↵ | | 6 | d.width += (getFontMetrics(EnhancedMenuItem.acceleratorFont)↵
|
7 | .stringWidth(shortcut) + 15);↵ | | 7 | .stringWidth(shortcut) + 15);↵
|
8 | }↵ | | 8 | }↵
|
9 | return d;↵ | | 9 | return d;↵
|
10 | } //}}}↵ | | 10 | } //}}}↵
|
|
11 | //{{{ paint() method↵ | | 11 | //{{{ paint() method↵
|
12 | public void paint(Graphics g)↵ | | 12 | public void paint(Graphics g)↵
|
13 | {↵ | | 13 | {↵
|
14 | super.paint(g);↵ | | 14 | super.paint(g);↵
|
|
15 | if(shortcut != null)↵ | | 15 | if(shortcut != null)↵
|
16 | {↵ | | 16 | {↵
|
17 | g.setFont(acceleratorFont);↵ | | 17 | g.setFont(EnhancedMenuItem.acceleratorFont);↵
|
18 | g.setColor(getModel().isArmed() ?↵ | | 18 | g.setColor(getModel().isArmed() ?↵
|
19 | acceleratorSelectionForeground :↵ | | 19 | EnhancedMenuItem.acceleratorSelectionForeground :↵
|
20 | acceleratorForeground);↵ | | 20 | EnhancedMenuItem.acceleratorForeground);↵
|
21 | FontMetrics fm = g.getFontMetrics();↵ | | 21 | FontMetrics fm = g.getFontMetrics();↵
|
22 | Insets insets = getInsets();↵ | | 22 | Insets insets = getInsets();↵
|
23 | g.drawString(shortcut,getWidth() - (fm.stringWidth(↵ | | 23 | g.drawString(shortcut,getWidth() - (fm.stringWidth(↵
|
24 | shortcut) + insets.right + insets.left + 5),↵ | | 24 | shortcut) + insets.right + insets.left + 5),↵
|
25 | getFont().getSize() + (insets.top - ↵ | | 25 | getFont().getSize() + (insets.top - ↵
|
26 | (OperatingSystem.isMacOSLF() ? 0 : 1))↵ | | 26 | (OperatingSystem.isMacOSLF() ? 0 : 1))↵
|
27 | /* XXX magic number */);↵ | | 27 | /* XXX magic number */);↵
|
28 | }↵ | | 28 | }↵
|
29 | } //}}}↵ | | 29 | } //}}}↵
|
|
30 | //{{{ Package-private members↵ | | 30 | //{{{ Private members↵
|
31 | static Font acceleratorFont;↵ | | |
|
32 | static Color acceleratorForeground;↵ | | |
|
33 | static Color acceleratorSelectionForeground;↵ | | |
|
34 | //}}}↵ | | |
|
|
35 | //{{{ Private members↵ | | |
|
|
36 | //{{{ Instance variables↵ | | |
|
| | | 31 | //{{{ Instance variables↵
|
| | | 32 | private ActionContext context;↵
|
37 | private String shortcut;↵ | | 33 | private String shortcut;↵
|
38 | private String action;↵ | | 34 | private String action;↵
|
39 | //}}}↵ | | 35 | //}}}↵
|
|
40 | //{{{ getShortcut() method↵ | | 36 | //{{{ getShortcut() method↵
|
41 | private String getShortcut()↵ | | 37 | private String getShortcut()↵
|
42 | {↵ | | 38 | {↵
|
43 | if(action == null)↵ | | 39 | if(action == null)↵
|
44 | return null;↵ | | 40 | return null;↵
|
45 | else↵ | | 41 | else↵
|
46 | {↵ | | 42 | {↵
|
47 | String shortcut1 = jEdit.getProperty(action + ".shortcut");↵ | | 43 | String shortcut1 = jEdit.getProperty(action + ".shortcut");↵
|
48 | String shortcut2 = jEdit.getProperty(action + ".shortcut2");↵ | | 44 | String shortcut2 = jEdit.getProperty(action + ".shortcut2");↵
|
|
49 | if(shortcut1 == null || shortcut1.length() == 0)↵ | | 45 | if(shortcut1 == null || shortcut1.length() == 0)↵
|
50 | {↵ | | 46 | {↵
|
51 | if(shortcut2 == null || shortcut2.length() == 0)↵ | | 47 | if(shortcut2 == null || shortcut2.length() == 0)↵
|
52 | return null;↵ | | 48 | return null;↵
|
53 | else↵ | | 49 | else↵
|
54 | return shortcut2;↵ | | 50 | return shortcut2;↵
|
55 | }↵ | | 51 | }↵
|
56 | else↵ | | 52 | else↵
|
57 | {↵ | | 53 | {↵
|
58 | if(shortcut2 == null || shortcut2.length() == 0)↵ | | 54 | if(shortcut2 == null || shortcut2.length() == 0)↵
|
59 | return shortcut1;↵ | | 55 | return shortcut1;↵
|
60 | else↵ | | 56 | else↵
|
61 | return shortcut1 + " or " + shortcut2;↵ | | 57 | return shortcut1 + " or " + shortcut2;↵
|
62 | }↵ | | 58 | }↵
|
63 | }↵ | | 59 | }↵
|
64 | } | | 60 | }
|