Ignore:
Timestamp:
2009-03-18T15:46:46+01:00 (15 years ago)
Author:
stoecker
Message:

fix translation issues for help, add fullscreen mode (patch by avar) - closes #1915, #2279, #2336 - breaks plugin interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r1434 r1498  
    33package org.openstreetmap.josm.gui;
    44
     5import static org.openstreetmap.josm.tools.I18n.marktr;
    56import static org.openstreetmap.josm.tools.I18n.tr;
    67
     
    1415import javax.swing.JMenuItem;
    1516import javax.swing.KeyStroke;
     17
     18/* For the fullscreen action */
     19import java.awt.Frame;
     20import java.awt.GraphicsEnvironment;
     21import java.awt.GraphicsDevice;
     22import org.openstreetmap.josm.tools.PlatformHookUnixoid;
    1623
    1724import org.openstreetmap.josm.Main;
     
    135142    public final JosmAction statusreport = new ShowStatusReportAction();
    136143
    137     public final JMenu fileMenu = new JMenu(tr("File"));
    138     public final JMenu editMenu = new JMenu(tr("Edit"));
    139     public final JMenu viewMenu = new JMenu(tr("View"));
    140     public final JMenu toolsMenu = new JMenu(tr("Tools"));
    141     public final JMenu audioMenu = new JMenu(tr("Audio"));
    142     public final JMenu presetsMenu = new JMenu(tr("Presets"));
    143     public final JMenu helpMenu = new JMenu(tr("Help"));
     144    public final JMenu fileMenu = addMenu(marktr("File"), KeyEvent.VK_F, 0);
     145    public final JMenu editMenu = addMenu(marktr("Edit"), KeyEvent.VK_E, 1);
     146    public final JMenu viewMenu = addMenu(marktr("View"), KeyEvent.VK_V, 2);
     147    public final JMenu toolsMenu = addMenu(marktr("Tools"), KeyEvent.VK_T, 3);
     148    public final JMenu presetsMenu = addMenu(marktr("Presets"), KeyEvent.VK_P, 4);
     149    public JMenu audioMenu = null;
     150    public final JMenu helpMenu = addMenu(marktr("Help"), KeyEvent.VK_H, 5);
     151    public final int defaultMenuPos = 5;
    144152
    145153    /**
     
    160168        return menuitem;
    161169    }
    162 
    163     /**
    164      * Add a menu to the main menu.
    165      *
    166      * This method handles all the shortcut handling.
    167      */
    168     public void add(JMenu menu, int mnemonicKey, String shortName) {
    169         Shortcut.registerShortcut("menu:" + shortName, tr("Menu: {0}", menu.getText()), mnemonicKey,
     170    public JMenu addMenu(String name, int mnemonicKey, int position)
     171    {
     172        JMenu menu = new JMenu(tr(name));
     173        Shortcut.registerShortcut("menu:" + name, tr("Menu: {0}", tr(name)), mnemonicKey,
    170174                Shortcut.GROUP_MNEMONIC).setMnemonic(menu);
    171         add(menu);
     175        add(menu, position);
     176        menu.putClientProperty("help", "Menu/"+name);
     177        return menu;
    172178    }
    173179
     
    188194        fileMenu.addSeparator();
    189195        add(fileMenu, exit);
    190         add(fileMenu, KeyEvent.VK_F, "file");
    191196
    192197        add(editMenu, undo);
     
    205210        editMenu.addSeparator();
    206211        add(editMenu, preferences);
    207         add(editMenu, KeyEvent.VK_E, "edit");
    208212
    209213        // TODO move code to an "action" like the others?
     
    229233            add(viewMenu, autoScaleAction);
    230234        }
    231         add(viewMenu, KeyEvent.VK_V, "view");
     235
     236        //
     237        // Full Screen action
     238        //
     239        final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     240
     241        if (Main.platform instanceof PlatformHookUnixoid && gd.isFullScreenSupported()) {
     242            final JCheckBoxMenuItem fullscreen = new JCheckBoxMenuItem(tr("Full Screen"));
     243            fullscreen.setSelected(Main.pref.getBoolean("draw.fullscreen", false));
     244            fullscreen.setAccelerator(Shortcut.registerShortcut("menu:view:fullscreen", tr("Toggle Full Screen view"),
     245                    KeyEvent.VK_F11, Shortcut.GROUP_DIRECT).getKeyStroke());
     246
     247            fullscreen.addActionListener(new ActionListener() {
     248                public void actionPerformed(ActionEvent ev) {
     249                    Main.pref.put("draw.fullscreen", fullscreen.isSelected());
     250
     251                    if (Main.pref.getBoolean("draw.fullscreen")) {
     252                        Frame frame = (Frame)Main.parent;
     253                        gd.setFullScreenWindow(frame);
     254                    } else {
     255                        gd.setFullScreenWindow(null);
     256                    }
     257                }
     258            });
     259            viewMenu.addSeparator();
     260            viewMenu.add(fullscreen);
     261        }
    232262
    233263        add(toolsMenu, splitWay);
     
    249279        toolsMenu.addSeparator();
    250280        add(toolsMenu, historyinfo);
    251         add(toolsMenu, KeyEvent.VK_T, "tools");
    252 
    253         add(presetsMenu, KeyEvent.VK_P, "presets");
    254281
    255282        if (!Main.pref.getBoolean("audio.menuinvisible", false)) {
     283            audioMenu = addMenu(marktr("Audio"), KeyEvent.VK_A, 5);
    256284            add(audioMenu, audioPlayPause);
    257285            add(audioMenu, audioNext);
     
    261289            add(audioMenu, audioSlower);
    262290            add(audioMenu, audioFaster);
    263             add(audioMenu, KeyEvent.VK_A, "audio");
    264291        }
    265292
    266                 /* TODO: Anyone really using this feature? */
    267         /*JMenuItem check = new JMenuItem("DEBUG: Check Dataset");
    268         check.addActionListener(new ActionListener() {
    269             public void actionPerformed(ActionEvent e) {
    270                 DataSetChecker.check();
    271             }
    272         });
    273         helpMenu.add(check);*/
    274        
    275293        helpMenu.add(statusreport);
    276        
     294
    277295        current = helpMenu.add(help); // FIXME why is help not a JosmAction?
    278296        current.setAccelerator(Shortcut.registerShortcut("system:help", tr("Help"), KeyEvent.VK_F1,
    279297                Shortcut.GROUP_DIRECT).getKeyStroke());
    280298        add(helpMenu, about);
    281         add(helpMenu, KeyEvent.VK_H, "help");
    282299    }
    283300}
Note: See TracChangeset for help on using the changeset viewer.