Changeset 5078 in josm
- Timestamp:
- 2012-03-14T00:22:50+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java
r4982 r5078 17 17 18 18 import javax.swing.ButtonModel; 19 import javax.swing.JComponent; 20 import javax.swing.JFrame; 21 import javax.swing.KeyStroke; 19 22 20 23 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.tools.PlatformHookUnixoid;22 24 import org.openstreetmap.josm.tools.PlatformHookWindows; 23 25 import org.openstreetmap.josm.tools.Shortcut; … … 25 27 public class FullscreenToggleAction extends JosmAction { 26 28 private final List<ButtonModel> buttonModels = new ArrayList<ButtonModel>(); 27 //FIXME: replace with property Action.SELECTED_KEY when migrating to28 // Java 629 private boolean selected;30 29 private GraphicsDevice gd; 31 30 private Rectangle prevBounds; … … 43 42 Main.toolbar.register(this); 44 43 gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); 45 selected = Main.pref.getBoolean("draw.fullscreen", false);44 putValue(SELECTED_KEY, Main.pref.getBoolean("draw.fullscreen", false)); 46 45 notifySelectedState(); 47 46 } … … 61 60 protected void notifySelectedState() { 62 61 for (ButtonModel model: buttonModels) { 63 if (model.isSelected() != selected) {64 model.setSelected( selected);62 if (model.isSelected() != isSelected()) { 63 model.setSelected(isSelected()); 65 64 } 66 65 } … … 68 67 69 68 protected void toggleSelectedState() { 70 selected = !selected;71 Main.pref.put("draw.fullscreen", selected);69 putValue(SELECTED_KEY, !isSelected()); 70 Main.pref.put("draw.fullscreen", isSelected()); 72 71 notifySelectedState(); 73 72 setMode(); … … 75 74 76 75 public void initial() { 77 if (selected)76 if (isSelected()) { 78 77 setMode(); 78 } 79 79 } 80 80 81 81 protected void setMode() { 82 Frame frame = (Frame) Main.parent;82 JFrame frame = (JFrame) Main.parent; 83 83 84 84 List<Window> visibleWindows = new ArrayList<Window>(); … … 91 91 92 92 frame.dispose(); 93 frame.setUndecorated( selected);93 frame.setUndecorated(isSelected()); 94 94 95 if ( selected) {95 if (isSelected()) { 96 96 prevBounds = frame.getBounds(); 97 97 frame.setBounds(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); … … 100 100 // we cannot use hw-exclusive fullscreen mode in MS-Win, as long 101 101 // as josm throws out modal dialogs, see here: 102 // http://forums.sun.com/thread.jspa?threadID=5351882 102 // http://forums.sun.com/thread.jspa?threadID=5351882 FIXME this url does not work anymore 103 103 // 104 104 // the good thing is: fullscreen works without exclusive mode, … … 107 107 String exclusive = Main.pref.get("draw.fullscreen.exclusive-mode", "auto"); 108 108 if ("true".equals(exclusive) || ("auto".equals(exclusive) && !(Main.platform instanceof PlatformHookWindows))) { 109 gd.setFullScreenWindow( selected? frame : null);109 gd.setFullScreenWindow(isSelected() ? frame : null); 110 110 } 111 111 112 if (! selected&& prevBounds != null) {112 if (!isSelected() && prevBounds != null) { 113 113 frame.setBounds(prevBounds); 114 114 } … … 117 117 wind.setVisible(true); 118 118 } 119 120 // Free F10 key to allow it to be used by plugins, even after full screen (see #7502) 121 frame.getJMenuBar().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "none"); 119 122 } 120 123 … … 122 125 toggleSelectedState(); 123 126 } 127 128 public final boolean isSelected() { 129 return (Boolean)getValue(SELECTED_KEY); 130 } 124 131 }
Note:
See TracChangeset
for help on using the changeset viewer.