/jEdit/tags/jedit-4-3-pre5/bsh/commands/fontMenu.bsh
Unknown | 76 lines | 59 code | 17 blank | 0 comment | 0 complexity | 13ef52e74ffe751799c977167df3ddc5 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /**
- * Creates a font menu for use with the workspace and workspace editors
- *
- * @return a font menu
- *
- * @author Daniel Leuck
- */
- fontMenu(component) {
- if ( bsh.system.desktop == void ) {
- print("fontMenu() only works with the bsh desktop...");
- return;
- }
-
- JMenu fontMenu = new JMenu("Font");
-
- sizeListener() {
- actionPerformed(ae) {
- setFont(component, Integer.parseInt(ae.actionCommand));
- }
-
- return this;
- }
- this.sizeListener=sizeListener();
-
-
- this.boldMenuItem = new JCheckBoxMenuItem("Bold");
- this.italicMenuItem = new JCheckBoxMenuItem("Italic");
-
- styleListener() {
- actionPerformed(ae) {
- setFont(component, null, ((boldMenuItem.selected) ? Font.BOLD : 0) |
- ((italicMenuItem.selected) ? Font.ITALIC : 0), -1);
- }
-
- return this;
- }
- this.styleListener=styleListener();
-
- familyListener() {
- actionPerformed(ae) {
- setFont(component, ae.actionCommand, -1, -1);
- }
-
- return this;
- }
- this.familyListener=familyListener();
-
- JMenu sizeMenu = new JMenu("Size");
- for(int i:new int[] {9,10,12,14,16,20,24})
- sizeMenu.add(new JMenuItem(""+i)).addActionListener(sizeListener);
- fontMenu.add(sizeMenu);
-
- JMenu styleMenu = new JMenu("Style");
- //styleMenu.add(new JMenuItem("Plain")).addActionListener(this);
- styleMenu.add(boldMenuItem).addActionListener(styleListener);
- styleMenu.add(italicMenuItem).addActionListener(styleListener);
- fontMenu.add(styleMenu);
-
- fontMenu.addSeparator();
-
- for(var s:new String[] {"SansSerif","Monospaced","Serif","LucidaSans"})
- fontMenu.add(this.mi=new JMenuItem(s)).addActionListener(familyListener);
-
- fontMenu.addSeparator();
-
- actionPerformed(ae) {
- String family = (String)JOptionPane.showInputDialog(component,
- "Select a font", "Fonts", JOptionPane.QUESTION_MESSAGE,
- null, bsh.system.fonts, component.font.family);
- setFont(component, family, -1, -1);
- }
-
- fontMenu.add(new JMenuItem("More...")).addActionListener(this);
-
- return fontMenu;
- }