diff --git a/app/Base.java b/app/Base.java index 0e69e6b3a..fafad2572 100644 --- a/app/Base.java +++ b/app/Base.java @@ -499,6 +499,55 @@ public class Base { // ................................................................. + // someone needs to be slapped + //static KeyStroke closeWindowKeyStroke; + + /** + * Return true if the key event was a Ctrl-W or an ESC, + * both indicators to close the window. + * Use as part of a keyPressed() event handler for frames. + */ + /* + static public boolean isCloseWindowEvent(KeyEvent e) { + if (closeWindowKeyStroke == null) { + int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + closeWindowKeyStroke = KeyStroke.getKeyStroke('W', modifiers); + } + return ((e.getKeyCode() == KeyEvent.VK_ESCAPE) || + KeyStroke.getKeyStrokeForEvent(e).equals(closeWindowKeyStroke)); + } + */ + + + /** + * Registers key events for a Ctrl-W and ESC with an ActionListener + * that will take care of disposing the window. + */ + static public void registerWindowCloseKeys(JRootPane root, //Window window, + ActionListener disposer) { + /* + JRootPane root = null; + if (window instanceof JFrame) { + root = ((JFrame)window).getRootPane(); + } else if (window instanceof JDialog) { + root = ((JDialog)window).getRootPane(); + } + */ + + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + root.registerKeyboardAction(disposer, stroke, + JComponent.WHEN_IN_FOCUSED_WINDOW); + + int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + stroke = KeyStroke.getKeyStroke('W', modifiers); + root.registerKeyboardAction(disposer, stroke, + JComponent.WHEN_IN_FOCUSED_WINDOW); + } + + + // ................................................................. + + /** * Given the reference filename from the keywords list, * builds a URL and passes it to openURL. @@ -920,44 +969,4 @@ public class Base { } } } - - - /** - * Equivalent to the one in PApplet, but static (die() is removed) - */ - /* - static public String[] loadStrings(File file) { - try { - FileInputStream input = new FileInputStream(file); - BufferedReader reader = - new BufferedReader(new InputStreamReader(input)); - - String lines[] = new String[100]; - int lineCount = 0; - String line = null; - while ((line = reader.readLine()) != null) { - if (lineCount == lines.length) { - String temp[] = new String[lineCount << 1]; - System.arraycopy(lines, 0, temp, 0, lineCount); - lines = temp; - } - lines[lineCount++] = line; - } - reader.close(); - - if (lineCount == lines.length) { - return lines; - } - - // resize array to appropraite amount for these lines - String output[] = new String[lineCount]; - System.arraycopy(lines, 0, output, 0, lineCount); - return output; - - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - */ } diff --git a/app/Editor.java b/app/Editor.java index e5574a2a1..0b5b8975e 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -126,7 +126,7 @@ public class Editor extends JFrame //SketchHistory history; // TODO re-enable history Sketchbook sketchbook; //Preferences preferences; - FindReplace find; + //FindReplace find; //static Properties keywords; // keyword -> reference html lookup @@ -172,7 +172,7 @@ public class Editor extends JFrame setJMenuBar(menubar); // doesn't matter when this is created, just make it happen at some point - find = new FindReplace(Editor.this); + //find = new FindReplace(Editor.this); Container pain = getContentPane(); pain.setLayout(new BorderLayout()); @@ -803,7 +803,9 @@ public class Editor extends JFrame item = newJMenuItem("Find...", 'F'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - find.show(); + new FindReplace(Editor.this).show(); + //find.show(); + //find.setVisible(true); } }); menu.add(item); @@ -813,6 +815,8 @@ public class Editor extends JFrame public void actionPerformed(ActionEvent e) { // TODO find next should only be enabled after a // search has actually taken place + //find.find(true); + FindReplace find = new FindReplace(Editor.this); //.show(); find.find(true); } }); diff --git a/app/FindReplace.java b/app/FindReplace.java index 7006a5f45..791efc107 100644 --- a/app/FindReplace.java +++ b/app/FindReplace.java @@ -29,10 +29,21 @@ import javax.swing.*; /** - * Find & Replace window for the processing editor. + * Find & Replace window for the Processing editor. + *
+ * One major annoyance in this is that the window is re-created each time + * that "Find" is called. This is because Mac OS X has a strange focus + * issue with windows that are re-shown with setVisible() or show(). + * requestFocusInWindow() properly sets the focus to the find field, + * however, just a short moment later, the focus is set to null. Even + * trying to catch this scenario and request it again doesn't seem to work. + * Most likely this is some annoyance buried deep in one of Apple's docs, + * or in the doc for the focus stuff (I tend to think the former because + * Windows doesn't seem to be quite so beligerent). Filed as + * Bug 244 + * should anyone have clues about how to fix. */ -public class FindReplace extends JFrame - implements ActionListener, KeyListener { +public class FindReplace extends JFrame implements ActionListener { static final int BIG = 13; static final int SMALL = 6; @@ -41,16 +52,17 @@ public class FindReplace extends JFrame JTextField findField; JTextField replaceField; + static String findString; + static String replaceString; JButton replaceButton; JButton replaceAllButton; JButton findButton; JCheckBox ignoreCaseBox; - boolean ignoreCase; - - KeyStroke windowClose; + static boolean ignoreCase = true; + /// true when there's something selected in the editor boolean found; @@ -74,6 +86,27 @@ public class FindReplace extends JFrame pain.add(replaceField = new JTextField(20)); Dimension d2 = findField.getPreferredSize(); + if (findString != null) findField.setText(findString); + if (replaceString != null) replaceField.setText(replaceString); + //System.out.println("setting find str to " + findString); + //findField.requestFocusInWindow(); + + //pain.setDefault + /* + findField.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + System.out.println("Focus gained " + e.getOppositeComponent()); + } + + public void focusLost(FocusEvent e) { + System.out.println("Focus lost "); // + e.getOppositeComponent()); + if (e.getOppositeComponent() == null) { + requestFocusInWindow(); + } + } + }); + */ + // +1 since it's better to tend downwards int yoff = (1 + d2.height - d1.height) / 2; @@ -82,7 +115,7 @@ public class FindReplace extends JFrame replaceLabel.setBounds(BIG, BIG + d2.height + SMALL + yoff, d1.width, d1.height); - ignoreCase = true; + //ignoreCase = true; ignoreCaseBox = new JCheckBox("Ignore Case"); ignoreCaseBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -110,12 +143,8 @@ public class FindReplace extends JFrame } pain.add(buttons); - // 0069 TEMPORARILY DISABLED! - //replaceAllButton.setEnabled(false); - // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. - //if (Base.platform == Base.MACOSX) { if (Base.isMacOS()) { buttons.setBorder(null); } @@ -146,7 +175,7 @@ public class FindReplace extends JFrame replaceButton.setEnabled(false); // so that typing will go straight to this field - findField.requestFocus(); + //findField.requestFocus(); // make the find button the blinky default getRootPane().setDefaultButton(findButton); @@ -161,48 +190,62 @@ public class FindReplace extends JFrame (screen.height - high) / 2, wide, high); // add key listener to trap esc and ctrl/cmd-w - findField.addKeyListener(this); - replaceField.addKeyListener(this); - addKeyListener(this); + /* + KeyListener listener = new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (Base.isCloseWindowEvent(e)) hide(); + } + }; + findField.addKeyListener(listener); + replaceField.addKeyListener(listener); + addKeyListener(listener); + */ + ActionListener disposer = new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + //hide(); + handleClose(); + } + }; + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + handleClose(); + } + }); + Base.registerWindowCloseKeys(getRootPane(), disposer); + + /* // hack to to get first field to focus properly on osx // though this still doesn't seem to work addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { //System.out.println("activating"); - findField.requestFocus(); - findField.selectAll(); + //boolean ok = findField.requestFocusInWindow(); + //System.out.println("got " + ok); + //findField.selectAll(); } }); + */ } - /** - * Handle window closing commands for ctrl/cmd-W or hitting ESC. - */ - public void keyPressed(KeyEvent e) { - if (windowClose == null) { - int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - windowClose = KeyStroke.getKeyStroke('W', modifiers); - } - if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) || - (KeyStroke.getKeyStrokeForEvent(e).equals(windowClose))) { - hide(); - //} else { - //System.out.println("event " + e); - } + public void handleClose() { + //System.out.println("handling close now"); + findString = findField.getText(); + replaceString = replaceField.getText(); + + // this object should eventually become dereferenced + hide(); } - public void keyReleased(KeyEvent e) { } - - public void keyTyped(KeyEvent e) { } - /* public void show() { + findField.requestFocusInWindow(); super.show(); - findField.selectAll(); - findField.requestFocus(); + //findField.selectAll(); + //findField.requestFocus(); } */ @@ -233,6 +276,7 @@ public class FindReplace extends JFrame found = false; String search = findField.getText(); + //System.out.println("finding for " + search + " " + findString); // this will catch "find next" being called when no search yet if (search.length() == 0) return; @@ -266,9 +310,10 @@ public class FindReplace extends JFrame } - // replace the current selection with whatever's in the - // replacement text field - + /** + * Replace the current selection with whatever's in the + * replacement text field. + */ public void replace() { if (!found) return; // don't replace if nothing found @@ -291,8 +336,10 @@ public class FindReplace extends JFrame } - // keep doing find and replace alternately until nothing more found - + /** + * Replace everything that matches by doing find and replace + * alternately until nothing more found. + */ public void replaceAll() { // move to the beginning editor.textarea.select(0, 0); diff --git a/app/Preferences.java b/app/Preferences.java index a43464fd7..bd7197e24 100644 --- a/app/Preferences.java +++ b/app/Preferences.java @@ -49,7 +49,7 @@ import processing.core.PApplet; * properties files are iso8859-1, which is highly likely to * be a problem when trying to save sketch folders and locations. */ -public class Preferences extends JComponent { +public class Preferences { // what to call the feller @@ -75,7 +75,7 @@ public class Preferences extends JComponent { * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, * Windows XP needs 66, and Linux needs 76, so 76 seems proper. */ - static int BUTTON_WIDTH = 76; + static public int BUTTON_WIDTH = 76; /** * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, @@ -84,7 +84,7 @@ public class Preferences extends JComponent { * would be). Because of the disparity, on Mac OS X, it will be set * inside a static block. */ - static int BUTTON_HEIGHT = 24; + static public int BUTTON_HEIGHT = 24; static { if (Base.isMacOS()) BUTTON_HEIGHT = 29; } @@ -93,7 +93,10 @@ public class Preferences extends JComponent { static final int GRID_SIZE = 33; - // gui variables + + // indents and spacing standards. these probably need to be modified + // per platform as well, since macosx is so huge, windows is smaller, + // and linux is all over the map static final int GUI_BIG = 13; static final int GUI_BETWEEN = 10; @@ -101,14 +104,12 @@ public class Preferences extends JComponent { // gui elements - //JFrame frame; - JDialog frame; + JDialog dialog; int wide, high; JTextField sketchbookLocationField; JCheckBox sketchPromptBox; JCheckBox sketchCleanBox; - //JCheckBox exportLibraryBox; JCheckBox externalEditorBox; JCheckBox checkUpdatesBox; @@ -123,7 +124,6 @@ public class Preferences extends JComponent { static Hashtable table = new Hashtable();; static File preferencesFile; - //boolean firstTime; // first time this feller has been run static public void init() { @@ -164,9 +164,6 @@ public class Preferences extends JComponent { // next load user preferences file - //File home = new File(System.getProperty("user.home")); - //File processingHome = new File(home, "Processing"); - //preferencesFile = new File(home, PREFS_FILE); preferencesFile = Base.getSettingsFile(PREFS_FILE); if (!preferencesFile.exists()) { @@ -193,14 +190,12 @@ public class Preferences extends JComponent { public Preferences() { - // setup frame for the prefs + // setup dialog for the prefs - //frame = new JFrame("Preferences"); - frame = new JDialog(editor, "Preferences", true); - //frame.setResizable(false); + dialog = new JDialog(editor, "Preferences", true); + dialog.setResizable(false); - //Container pain = this; - Container pain = frame.getContentPane(); + Container pain = dialog.getContentPane(); pain.setLayout(null); int top = GUI_BIG; @@ -296,20 +291,6 @@ public class Preferences extends JComponent { top += d.height + GUI_BETWEEN; - // [ ] Enable export to "Library" - - /* - exportLibraryBox = new JCheckBox("Enable advanced \"Library\" features" + - " (requires restart)"); - exportLibraryBox.setEnabled(false); - pain.add(exportLibraryBox); - d = exportLibraryBox.getPreferredSize(); - exportLibraryBox.setBounds(left, top, d.width, d.height); - right = Math.max(right, left + d.width); - top += d.height + GUI_BETWEEN; - */ - - // [ ] Use external editor externalEditorBox = new JCheckBox("Use external editor"); @@ -332,21 +313,6 @@ public class Preferences extends JComponent { // More preferences are in the ... - /* - String blather = - "More preferences can be edited directly\n" + - "in the file " + preferencesFile.getAbsolutePath(); - //"More preferences are in the 'lib' folder inside text files\n" + - //"named preferences.txt and pde_" + - //Base.platforms[Base.platform] + ".properties"; - - JTextArea textarea = new JTextArea(blather); - textarea.setEditable(false); - textarea.setBorder(new EmptyBorder(0, 0, 0, 0)); - textarea.setBackground(null); - textarea.setFont(new Font("Dialog", Font.PLAIN, 12)); - pain.add(textarea); - */ label = new JLabel("More preferences can be edited directly in the file"); pain.add(label); @@ -374,9 +340,6 @@ public class Preferences extends JComponent { // [ OK ] [ Cancel ] maybe these should be next to the message? - //right = Math.max(right, left + d.width + GUI_BETWEEN + - // BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH); - button = new JButton(PROMPT_OK); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -387,10 +350,6 @@ public class Preferences extends JComponent { pain.add(button); d2 = button.getPreferredSize(); BUTTON_HEIGHT = d2.height; - //System.out.println("changing button height to " + BUTTON_HEIGHT); - - // smoosh up to the line before - //top -= BUTTON_HEIGHT; h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH); button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT); @@ -411,33 +370,40 @@ public class Preferences extends JComponent { // finish up wide = right + GUI_BIG; - high = top + GUI_SMALL; //GUI_BIG; - setSize(wide, high); + high = top + GUI_SMALL; + //setSize(wide, high); // closing the window is same as hitting cancel button - frame.addWindowListener(new WindowAdapter() { + dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { disposeFrame(); } }); - Container content = frame.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(this, BorderLayout.CENTER); - - frame.pack(); + ActionListener disposer = new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + disposeFrame(); + } + }; + Base.registerWindowCloseKeys(dialog.getRootPane(), disposer); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation((screen.width - wide) / 2, + dialog.setLocation((screen.width - wide) / 2, (screen.height - high) / 2); + dialog.pack(); // get insets + Insets insets = dialog.getInsets(); + dialog.setSize(wide + insets.left + insets.right, + high + insets.top + insets.bottom); + // handle window closing commands for ctrl/cmd-W or hitting ESC. - addKeyListener(new KeyAdapter() { + pain.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { + System.out.println(e); KeyStroke wc = Editor.WINDOW_CLOSE_KEYSTROKE; if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) { @@ -448,6 +414,26 @@ public class Preferences extends JComponent { } + /* + protected JRootPane createRootPane() { + System.out.println("creating root pane esc received"); + + ActionListener actionListener = new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + //setVisible(false); + System.out.println("esc received"); + } + }; + + JRootPane rootPane = new JRootPane(); + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + rootPane.registerKeyboardAction(actionListener, stroke, + JComponent.WHEN_IN_FOCUSED_WINDOW); + return rootPane; + } + */ + + public Dimension getPreferredSize() { return new Dimension(wide, high); } @@ -460,7 +446,7 @@ public class Preferences extends JComponent { * Close the window after an OK or Cancel. */ public void disposeFrame() { - frame.dispose(); + dialog.dispose(); } @@ -500,7 +486,7 @@ public class Preferences extends JComponent { externalEditorBox.setSelected(getBoolean("editor.external")); checkUpdatesBox.setSelected(getBoolean("update.check")); - frame.show(); + dialog.show(); } diff --git a/app/tools/CreateFont.java b/app/tools/CreateFont.java index 52a79c465..d36feb525 100644 --- a/app/tools/CreateFont.java +++ b/app/tools/CreateFont.java @@ -45,7 +45,7 @@ public class CreateFont extends JFrame { Dimension windowSize; JList fontSelector; - JComboBox styleSelector; + //JComboBox styleSelector; JTextField sizeSelector; JCheckBox allBox; JCheckBox smoothBox; @@ -62,9 +62,12 @@ public class CreateFont extends JFrame { String list[]; int selection = -1; - static final String styles[] = { - "Plain", "Bold", "Italic", "Bold Italic" - }; + static { + System.out.println("yep yep yep"); + } + //static final String styles[] = { + //"Plain", "Bold", "Italic", "Bold Italic" + //}; public CreateFont(Editor editor) { @@ -75,12 +78,7 @@ public class CreateFont extends JFrame { Container paine = getContentPane(); paine.setLayout(new BorderLayout()); //10, 10)); - //Dimension d = new Dimension(5, 5); - //paine.add(new Box.Filler(d, d, d), BorderLayout.WEST); - JPanel pain = new JPanel(); - //pain.setBorder(BorderFactory.createLineBorder(Color.black)); - //pain.setBorder(new EmptyBorder(10, 20, 20, 20)); pain.setBorder(new EmptyBorder(13, 13, 13, 13)); paine.add(pain, BorderLayout.CENTER); @@ -91,7 +89,6 @@ public class CreateFont extends JFrame { "Select a font and size, and click 'OK' to generate the font.\n" + "It will be added to the data folder of the current sketch."; - //JLabel label = new JLabel(labelText); JTextArea textarea = new JTextArea(labelText); textarea.setBorder(new EmptyBorder(10, 10, 20, 10)); textarea.setBackground(null); @@ -99,28 +96,6 @@ public class CreateFont extends JFrame { textarea.setHighlighter(null); textarea.setFont(new Font("Dialog", Font.PLAIN, 12)); pain.add(textarea); - //pain.add(label); - - //JPanel panel = new JPanel(); - //panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - - /* - // save this as an alternative implementation - GraphicsEnvironment ge = - GraphicsEnvironment.getLocalGraphicsEnvironment(); - - Font fonts[] = ge.getAllFonts(); - String families[] = ge.getAvailableFontFamilyNames(); - */ - - /* - for (int i = 0; i < fonts.length; i++) { - //System.out.println(fonts[i]); - if (fonts[i].getFontName().indexOf(fonts[i].getFamily()) != 0) { - System.out.println(fonts[i]); - } - } - */ // don't care about families starting with . or # // also ignore dialog, dialoginput, monospaced, serif, sansserif @@ -130,26 +105,9 @@ public class CreateFont extends JFrame { GraphicsEnvironment.getLocalGraphicsEnvironment(); Font fonts[] = ge.getAllFonts(); - //PApplet.printarr(fonts); String flist[] = new String[fonts.length]; table = new Hashtable(); - //String flist[] = ge.getAvailableFontFamilyNames(); - //fontSelector = new JComboBox(); - // old jdk11 version - //String flist[] = Toolkit.getDefaultToolkit().getFontList(); - - /* - for (int i = 0; i < flist.length; i++) { - if ((flist[i].indexOf('.') == 0) || (flist[i].indexOf('#') == 0) || - (flist[i].equals("Dialog")) || (flist[i].equals("DialogInput")) || - (flist[i].equals("Serif")) || (flist[i].equals("SansSerif")) || - (flist[i].equals("Monospaced"))) continue; - //flist[index++] = flist[i]; - Font f = new Font(flist[i], Font.PLAIN, 1); - flist[index++] = f.getPSName(); - } - */ int index = 0; for (int i = 0; i < fonts.length; i++) { String psname = fonts[i].getPSName(); @@ -162,36 +120,13 @@ public class CreateFont extends JFrame { list = new String[index]; System.arraycopy(flist, 0, list, 0, index); - fontSelector = new JList(list); //families); + fontSelector = new JList(list); fontSelector.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { - //System.out.println(e); - //System.out.println(e.getFirstIndex()); - //selection = e.getFirstIndex(); selection = fontSelector.getSelectedIndex(); okButton.setEnabled(true); update(); - - /* - int fontsize = 0; - try { - fontsize = Integer.parseInt(sizeSelector.getText().trim()); - //System.out.println("'" + sizeSelector.getText() + "'"); - } catch (NumberFormatException e2) { } - - // if a deselect occurred, selection will be -1 - if ((fontsize != 0) && (selection != -1)) { - font = new Font(list[selection], Font.PLAIN, fontsize); - //System.out.println("setting font to " + font); - sample.setFont(font); - - String filenameSuggestion = list[selection].replace(' ', '_'); - filenameField.setText(filenameSuggestion); - } - */ - //filenameField.paintComponent(filenameField.getGraphics()); - //getContentPane().repaint(); } } }); @@ -200,17 +135,8 @@ public class CreateFont extends JFrame { fontSelector.setVisibleRowCount(12); JScrollPane fontScroller = new JScrollPane(fontSelector); pain.add(fontScroller); - //fontSelector.setFont(new Font("SansSerif", Font.PLAIN, 10)); - /* - fontSelector.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fontName = e.getActionCommand(); - } - }); - */ Dimension d1 = new Dimension(13, 13); - //paine.add(new Box.Filler(d, d, d), BorderLayout.WEST); pain.add(new Box.Filler(d1, d1, d1)); // see http://rinkworks.com/words/pangrams.shtml @@ -229,35 +155,6 @@ public class CreateFont extends JFrame { pain.add(sample); - //for (int i = 0; i < list.length; i++) { - /* - for (int i = 0; i < families.length; i++) { - //fontSelector.addItem(list[i]); - fontSelector.addItem(families[i]); - } - panel.add(fontSelector); - */ - - /* - styleSelector = new JComboBox(); - for (int i = 0; i < styles.length; i++) { - styleSelector.addItem(styles[i]); - } - styleSelector.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String command = e.getActionCommand(); - int style = Font.PLAIN; - if (command.indexOf("Bold") != -1) { - style |= Font.BOLD; - } - if (command.indexOf("Italic") != -1) { - style |= Font.ITALIC; - } - } - }); - panel.add(styleSelector); - */ - Dimension d2 = new Dimension(6, 6); pain.add(new Box.Filler(d2, d2, d2)); @@ -271,14 +168,6 @@ public class CreateFont extends JFrame { }); panel.add(sizeSelector); - /* - JLabel rec = new JLabel("(Recommended size for 3D use is 48 points)"); - if (Base.platform == Base.MACOSX) { - rec.setFont(new Font("Dialog", Font.PLAIN, 10)); - } - panel.add(rec); - */ - smoothBox = new JCheckBox("Smooth"); smoothBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -325,17 +214,21 @@ public class CreateFont extends JFrame { buttons.add(okButton); pain.add(buttons); - getRootPane().setDefaultButton(okButton); + JRootPane root = getRootPane(); + root.setDefaultButton(okButton); + ActionListener disposer = new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + hide(); + } + }; + Base.registerWindowCloseKeys(root, disposer); - //setResizable(false); pack(); // do this after pack so it doesn't affect layout sample.setFont(new Font(list[0], Font.PLAIN, 48)); fontSelector.setSelectedIndex(0); - //selection = 0; - //update(); // ?? Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); windowSize = getSize(); diff --git a/todo.txt b/todo.txt index 81c776250..cc0d2f386 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,19 @@ 0099 pde X make buttons for editor status taller on macosx X also fix the editor text field placement a bit +X hack to fix find/replace issues on macosx +X http://dev.processing.org/bugs/show_bug.cgi?id=70 +X right now, typing works, but no caret, no blue highlight +X and on second find run, should instead select all the find string +X so that typing will replace it directly +X close/hide "Create Font" window on 'ESC' +X properly handle ENTER, Ctrl-W and ESC on all dialogs +X there must be a proper "swing" way of doing this that doesn't +X involve adding key listeners to every friggin component +X ESC should fake a cancel button press +X ENTER should do the default option +X (might be a matter of setting the default action for the window?) +X http://dev.processing.org/bugs/show_bug.cgi?id=34 _ deal with "could not delete stderr.txt" messages _ probably screwed up the temp folder stuff @@ -10,6 +23,10 @@ _ make editor save button highlight on ctrl-s _ same goes for the other editor buttons _ http://dev.processing.org/bugs/show_bug.cgi?id=242 +_ we're breaking some mac human interface guidelines +_ should be using a menu factory to create menus for all sub-windows +_ http://developer.apple.com/technotes/tn/tn2042.html + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -279,13 +296,6 @@ _ macosx handleQuit seems to force termination (at least on 1.3) _ http://dev.processing.org/bugs/show_bug.cgi?id=32 _ dim edit menus as appropriate during selection/no selection/etc _ http://dev.processing.org/bugs/show_bug.cgi?id=33 -_ properly handle ENTER, Ctrl-W and ESC on all dialogs -_ there must be a proper "swing" way of doing this that doesn't -_ involve adding key listeners to every friggin component -_ ESC should fake a cancel button press -_ ENTER should do the default option -_ (might be a matter of setting the default action for the window?) -_ http://dev.processing.org/bugs/show_bug.cgi?id=34 _ Ctrl-Z will undo, but not scroll to where the undo happens. _ so user thinks nothing is happening and overundo. _ http://dev.processing.org/bugs/show_bug.cgi?id=35 @@ -376,12 +386,9 @@ _ placing "replace" next to "find" ... (hitting "replace all" by accident) _ have a button "replace & find next" _ allowing to find & replace over multiple tabs _ http://dev.processing.org/bugs/show_bug.cgi?id=69 -_ fix find/replace focus issue on osx -_ http://dev.processing.org/bugs/show_bug.cgi?id=70 +_ better fix for find/replace focus issue on osx +_ http://dev.processing.org/bugs/show_bug.cgi?id=244 _ give that field focus explicitly, rather than just for typing -_ right now, typing works, but no caret, no blue highlight -_ and on second find run, should instead select all the find string -_ so that typing will replace it directly PDE / History @@ -531,13 +538,15 @@ _ related? an extra } brace deleting everything after it TOOLS / Create Font -_ create the tool object on startup, then use thread to getAllFonts() -_ close/hide window on 'ESC' _ loading is very slow on the first time (getting all font names) +_ create the tool object on startup, then use thread to getAllFonts() _ show a progress/status bar while it's happening? _ (would be useful to at least tell user that system not locked up) _ create font with user-specified charsets _ may help solve: http://dev.processing.org/bugs/show_bug.cgi?id=98 +_ when resizing window, only resize the text display area +_ just a matter of moving around the panels and BorderLayout +_ remember previous font selection when returning to the window