X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fmenu%2FTSubMenu.java;h=b61ca83cecbd0ff0af48b6d4cd05e60d4a3293f8;hb=051e29138b18fb4b731a72f8727475b10e4c74e4;hp=7b5f80c911e6e402dbf69dd9dc92c0e1a23b5b35;hpb=a2018e9964f6c58742cd1e6dd0a0c63e244a89d6;p=fanfix.git diff --git a/src/jexer/menu/TSubMenu.java b/src/jexer/menu/TSubMenu.java index 7b5f80c..b61ca83 100644 --- a/src/jexer/menu/TSubMenu.java +++ b/src/jexer/menu/TSubMenu.java @@ -38,19 +38,27 @@ import static jexer.TKeypress.*; /** * TSubMenu is a special case menu item that wraps another TMenu. */ -public final class TSubMenu extends TMenuItem { +public class TSubMenu extends TMenuItem { + + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ /** * The menu window. Note package private access. */ TMenu menu; + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Package private constructor. * * @param parent parent widget * @param title menu title. Title must contain a keyboard shortcut, - * denoted by prefixing a letter with "&", e.g. "&File" + * denoted by prefixing a letter with "&", e.g. "&File" * @param x column relative to parent * @param y row relative to parent */ @@ -67,28 +75,9 @@ public final class TSubMenu extends TMenuItem { this.menu.isSubMenu = true; } - /** - * Draw the menu title. - */ - @Override - public void draw() { - super.draw(); - - CellAttributes menuColor; - if (isAbsoluteActive()) { - menuColor = getTheme().getColor("tmenu.highlighted"); - } else { - if (isEnabled()) { - menuColor = getTheme().getColor("tmenu"); - } else { - menuColor = getTheme().getColor("tmenu.disabled"); - } - } - - // Add the arrow - getScreen().putCharXY(getWidth() - 2, 0, GraphicsChars.CP437[0x10], - menuColor); - } + // ------------------------------------------------------------------------ + // Event handlers --------------------------------------------------------- + // ------------------------------------------------------------------------ /** * Handle keystrokes. @@ -151,6 +140,33 @@ public final class TSubMenu extends TMenuItem { } } + // ------------------------------------------------------------------------ + // TMenuItem -------------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Draw the menu title. + */ + @Override + public void draw() { + super.draw(); + + CellAttributes menuColor; + if (isAbsoluteActive()) { + menuColor = getTheme().getColor("tmenu.highlighted"); + } else { + if (isEnabled()) { + menuColor = getTheme().getColor("tmenu"); + } else { + menuColor = getTheme().getColor("tmenu.disabled"); + } + } + + // Add the arrow + getScreen().putCharXY(getWidth() - 2, 0, GraphicsChars.CP437[0x10], + menuColor); + } + /** * Override dispatch() to do nothing. */ @@ -179,6 +195,10 @@ public final class TSubMenu extends TMenuItem { return this; } + // ------------------------------------------------------------------------ + // TSubMenu --------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Convenience function to add a custom menu item. * @@ -226,12 +246,11 @@ public final class TSubMenu extends TMenuItem { * Convenience function to add a sub-menu. * * @param title menu title. Title must contain a keyboard shortcut, - * denoted by prefixing a letter with "&", e.g. "&File" + * denoted by prefixing a letter with "&", e.g. "&File" * @return the new sub-menu */ public TSubMenu addSubMenu(final String title) { return menu.addSubMenu(title); } - }