Sketch tabs at the top of the editor window.
| 41 | * Sketch tabs at the top of the editor window. |
| 42 | */ |
| 43 | @SuppressWarnings("serial") |
| 44 | public class EditorHeader extends JComponent { |
| 45 | static Color backgroundColor; |
| 46 | static Color textColor[] = new Color[2]; |
| 47 | |
| 48 | Editor editor; |
| 49 | |
| 50 | int tabLeft[]; |
| 51 | int tabRight[]; |
| 52 | |
| 53 | Font font; |
| 54 | FontMetrics metrics; |
| 55 | int fontAscent; |
| 56 | |
| 57 | JMenu menu; |
| 58 | JPopupMenu popup; |
| 59 | |
| 60 | int menuLeft; |
| 61 | int menuRight; |
| 62 | |
| 63 | // |
| 64 | |
| 65 | static final String STATUS[] = { "unsel", "sel" }; |
| 66 | static final int UNSELECTED = 0; |
| 67 | static final int SELECTED = 1; |
| 68 | |
| 69 | static final String WHERE[] = { "left", "mid", "right" }; |
| 70 | static final int LEFT = 0; |
| 71 | static final int MIDDLE = 1; |
| 72 | static final int RIGHT = 2; |
| 73 | |
| 74 | static final int PIECE_WIDTH = scale(4); |
| 75 | static final int PIECE_HEIGHT = scale(33); |
| 76 | static final int TAB_HEIGHT = scale(27); |
| 77 | |
| 78 | // value for the size bars, buttons, etc |
| 79 | // TODO: Should be a Theme value? |
| 80 | static final int GRID_SIZE = 33; |
| 81 | |
| 82 | static Image[][] pieces; |
| 83 | static Image menuButtons[]; |
| 84 | |
| 85 | Image offscreen; |
| 86 | int sizeW, sizeH; |
| 87 | int imageW, imageH; |
| 88 | |
| 89 | public class Actions { |
| 90 | public final Action newTab = new SimpleAction(tr("New Tab"), |
| 91 | Keys.ctrlShift(KeyEvent.VK_N), |
| 92 | () -> editor.getSketchController().handleNewCode()); |
| 93 | |
| 94 | public final Action renameTab = new SimpleAction(tr("Rename"), |
| 95 | () -> editor.getSketchController().handleRenameCode()); |
| 96 | |
| 97 | public final Action deleteTab = new SimpleAction(tr("Delete"), () -> { |
| 98 | try { |
| 99 | editor.getSketchController().handleDeleteCode(); |
| 100 | } catch (IOException e) { |