2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
10 * Copyright (C) 2015 Kevin Lamonte
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
33 import jexer
.bits
.MnemonicString
;
36 * TMenu is a top-level collection of TMenuItems.
38 public class TMenu
extends TWindow
{
41 * If true, this is a sub-menu.
43 private boolean isSubMenu
= false;
46 * The shortcut and title.
48 private MnemonicString mnemonic
;
50 // Reserved menu item IDs
51 public static final int MID_UNUSED
= -1;
54 public static final int MID_EXIT
= 1;
55 public static final int MID_QUIT
= MID_EXIT
;
56 public static final int MID_OPEN_FILE
= 2;
57 public static final int MID_SHELL
= 3;
60 public static final int MID_CUT
= 10;
61 public static final int MID_COPY
= 11;
62 public static final int MID_PASTE
= 12;
63 public static final int MID_CLEAR
= 13;
66 public static final int MID_TILE
= 20;
67 public static final int MID_CASCADE
= 21;
68 public static final int MID_CLOSE_ALL
= 22;
69 public static final int MID_WINDOW_MOVE
= 23;
70 public static final int MID_WINDOW_ZOOM
= 24;
71 public static final int MID_WINDOW_NEXT
= 25;
72 public static final int MID_WINDOW_PREVIOUS
= 26;
73 public static final int MID_WINDOW_CLOSE
= 27;
78 * @param parent parent application
79 * @param x column relative to parent
80 * @param y row relative to parent
81 * @param label mnemonic menu title. Label must contain a keyboard
82 * shortcut (mnemonic), denoted by prefixing a letter with "&",
85 public TMenu(final TApplication parent
, final int x
, final int y
,
88 super(parent
, label
, x
, y
, parent
.getScreen().getWidth(),
89 parent
.getScreen().getHeight());
91 // My parent constructor added me as a window, get rid of that
92 parent
.closeWindow(this);
94 // Setup the menu shortcut
95 mnemonic
= new MnemonicString(title
);
96 this.title
= mnemonic
.getRawLabel();
97 assert (mnemonic
.getShortcutIdx() >= 0);
99 // Recompute width and height to reflect an empty menu
100 width
= this.title
.length() + 4;