X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2Fwindows%2FTuiBasicWindow.java;fp=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2Fwindows%2FTuiBasicWindow.java;h=404d1460177eec84a0e74f896589d747e516c704;hp=a87df613c6d2e67cba8f5b3f0b6186a8e4df385e;hb=5c5abfd29edd67f4c16932dd8aaf16ac4ccec4f2;hpb=c8398c23a885b1b7b78fba35a423c7136fb975cf diff --git a/src/be/nikiroo/jvcard/tui/windows/TuiBasicWindow.java b/src/be/nikiroo/jvcard/tui/windows/TuiBasicWindow.java index a87df61..404d146 100644 --- a/src/be/nikiroo/jvcard/tui/windows/TuiBasicWindow.java +++ b/src/be/nikiroo/jvcard/tui/windows/TuiBasicWindow.java @@ -8,6 +8,7 @@ import java.util.Map; import jexer.TAction; import jexer.TApplication; import jexer.TKeypress; +import jexer.TStatusBar; import jexer.TWindow; import jexer.event.TKeypressEvent; import be.nikiroo.jvcard.tui.TuiLauncherJexer; @@ -22,6 +23,18 @@ public abstract class TuiBasicWindow extends TWindow { private Map keyBindings; private List closeListeners; + /** + * Create a new window with the given title. + * + * @param parent + * the parent {@link TuiBasicWindow} + * @param title + * the window title + */ + public TuiBasicWindow(TuiBasicWindow parent, String title) { + this(parent.app, title, parent.getWidth(), parent.getHeight()); + } + /** * Create a new window with the given title. * @@ -29,13 +42,13 @@ public abstract class TuiBasicWindow extends TWindow { * the application that will manage this window * @param title * the window title + * @param width + * the window width + * @param height + * the window height */ - public TuiBasicWindow(TApplication app, String title) { - // Note: will not support screen with less than 10x10 - super(app, title, // - Math.min(36, app.getScreen().getWidth() - 9), // - Math.min(16, app.getScreen().getHeight() - 9) // - ); + public TuiBasicWindow(TApplication app, String title, int width, int height) { + super(app, title, width, height); this.app = app; @@ -53,11 +66,20 @@ public abstract class TuiBasicWindow extends TWindow { * * @param key * the key to press + * @param text + * the text to display for this command * @param action * the action */ - public void addKeyBinding(TKeypress key, TAction action) { + public void addKeyBinding(TKeypress key, String text, TAction action) { keyBindings.put(key, action); + + TStatusBar statusbar = getStatusBar(); + if (statusbar == null) { + statusbar = newStatusBar(""); + } + + statusbar.addShortcutKeypress(key, null, text); } /** @@ -71,13 +93,6 @@ public abstract class TuiBasicWindow extends TWindow { closeListeners.add(listener); } - /** - * Close the window. - */ - public void close() { - app.closeWindow(this); - } - @Override public void onClose() { super.onClose();