X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=d292ec1490c938f304e142a565551d8eb6060e74;hb=00fbfc382425d1f20a84cd8897919836cc6254ee;hp=726e13714ea4395af2c75fcf409ba685f24c4fbb;hpb=42873e30bf487bc0b695d60652dba44f82185dbb;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 726e137..d292ec1 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -550,6 +550,13 @@ public abstract class TWidget implements Comparable { } } + /** + * Repaint the screen on the next update. + */ + public void doRepaint() { + window.getApplication().doRepaint(); + } + // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ @@ -951,9 +958,15 @@ public abstract class TWidget implements Comparable { * @param resize resize event */ public void onResize(final TResizeEvent resize) { - // Default: do nothing, pass to children instead - for (TWidget widget: children) { - widget.onResize(resize); + // Default: change my width/height. + if (resize.getType() == TResizeEvent.Type.WIDGET) { + width = resize.getWidth(); + height = resize.getHeight(); + } else { + // Let children see the screen resize + for (TWidget widget: children) { + widget.onResize(resize); + } } } @@ -984,7 +997,8 @@ public abstract class TWidget implements Comparable { /** * Method that subclasses can override to do processing when the UI is - * idle. + * idle. Note that repainting is NOT assumed. To get a refresh after + * onIdle, call doRepaint(). */ public void onIdle() { // Default: do nothing, pass to children instead @@ -1223,6 +1237,23 @@ public abstract class TWidget implements Comparable { return new TText(this, text, x, y, width, height, "ttext"); } + /** + * Convenience function to add an editable text area box to this + * container/window. + * + * @param text text on the screen + * @param x column relative to parent + * @param y row relative to parent + * @param width width of text area + * @param height height of text area + * @return the new text box + */ + public final TEditorWidget addEditor(final String text, final int x, + final int y, final int width, final int height) { + + return new TEditorWidget(this, text, x, y, width, height); + } + /** * Convenience function to spawn a message box. *