X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fmenu%2FTSubMenu.java;h=be281b52d97d58741072632e9009e5dc1c344904;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=488ccd48b5a96f32906d62668b3f953113d0f905;hpb=43ad7b6c509c45c8f261e77ea059c10fed8c9f1c;p=fanfix.git diff --git a/src/jexer/menu/TSubMenu.java b/src/jexer/menu/TSubMenu.java index 488ccd4..be281b5 100644 --- a/src/jexer/menu/TSubMenu.java +++ b/src/jexer/menu/TSubMenu.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -38,7 +38,7 @@ 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 -------------------------------------------------------------- @@ -163,8 +163,7 @@ public final class TSubMenu extends TMenuItem { } // Add the arrow - getScreen().putCharXY(getWidth() - 2, 0, GraphicsChars.CP437[0x10], - menuColor); + putCharXY(getWidth() - 2, 0, GraphicsChars.CP437[0x10], menuColor); } /** @@ -213,6 +212,21 @@ public final class TSubMenu extends TMenuItem { return menu.addItem(id, label, key); } + /** + * Convenience function to add a custom menu item. + * + * @param id menu item ID. Must be greater than 1024. + * @param label menu item label + * @param key global keyboard accelerator + * @param enabled default state for enabled + * @return the new menu item + */ + public TMenuItem addItem(final int id, final String label, + final TKeypress key, final boolean enabled) { + + return menu.addItem(id, label, key, enabled); + } + /** * Convenience function to add a menu item. * @@ -224,6 +238,20 @@ public final class TSubMenu extends TMenuItem { return menu.addItem(id, label); } + /** + * Convenience function to add a menu item. + * + * @param id menu item ID. Must be greater than 1024. + * @param label menu item label + * @param enabled default state for enabled + * @return the new menu item + */ + public TMenuItem addItem(final int id, final String label, + final boolean enabled) { + + return menu.addItem(id, label, enabled); + } + /** * Convenience function to add one of the default menu items. * @@ -235,6 +263,18 @@ public final class TSubMenu extends TMenuItem { return menu.addDefaultItem(id); } + /** + * Convenience function to add one of the default menu items. + * + * @param id menu item ID. Must be between 0 (inclusive) and 1023 + * (inclusive). + * @param enabled default state for enabled + * @return the new menu item + */ + public TMenuItem addDefaultItem(final int id, final boolean enabled) { + return menu.addDefaultItem(id, enabled); + } + /** * Convenience function to add a menu separator. */