X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjexer%2FTWidget.java;h=08c0a45ca9c68c28c8345b14faa5f1344d852daf;hb=12b55d76e3473407bf37fca3667860240cb8f3be;hp=5be209e33b44ea79f4df2d85c49c454301e53bd0;hpb=0ee88b6d705993df0d9e32cdc08c619605c7d75c;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 5be209e..08c0a45 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.util.List; import java.util.ArrayList; +import jexer.backend.Screen; import jexer.bits.ColorTheme; import jexer.event.TCommandEvent; import jexer.event.TInputEvent; @@ -39,7 +40,6 @@ import jexer.event.TKeypressEvent; import jexer.event.TMenuEvent; import jexer.event.TMouseEvent; import jexer.event.TResizeEvent; -import jexer.io.Screen; import jexer.menu.TMenu; import static jexer.TKeypress.*; @@ -951,9 +951,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); + } } } @@ -1223,6 +1229,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. *