X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=8a49c816ac1ceb8ab847cadeef41f25b3cc30d9f;hb=5d26b50423486b1e680e3adfc0054f6fd0bbcefe;hp=c89e70ec65de92a7240ec9c69e90bcbf7736da4a;hpb=382bc294dd88b71639fdd6c73216d2519635a080;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index c89e70e..8a49c81 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -204,6 +204,13 @@ public abstract class TWidget implements Comparable { protected TWidget(final TWidget parent, final boolean enabled, final int x, final int y, final int width, final int height) { + if (width < 0) { + throw new IllegalArgumentException("width cannot be negative"); + } + if (height < 0) { + throw new IllegalArgumentException("height cannot be negative"); + } + this.enabled = enabled; this.parent = parent; this.window = parent.window; @@ -234,6 +241,13 @@ public abstract class TWidget implements Comparable { protected final void setupForTWindow(final TWindow window, final int x, final int y, final int width, final int height) { + if (width < 0) { + throw new IllegalArgumentException("width cannot be negative"); + } + if (height < 0) { + throw new IllegalArgumentException("height cannot be negative"); + } + this.parent = window; this.window = window; this.x = x; @@ -1911,6 +1925,22 @@ public abstract class TWidget implements Comparable { return getApplication().inputBox(title, caption, text); } + /** + * Convenience function to spawn an input box. + * + * @param title window title, will be centered along the top border + * @param caption message to display. Use embedded newlines to get a + * multi-line box. + * @param text initial text to seed the field with + * @param type one of the Type constants. Default is Type.OK. + * @return the new input box + */ + public final TInputBox inputBox(final String title, final String caption, + final String text, final TInputBox.Type type) { + + return getApplication().inputBox(title, caption, text, type); + } + /** * Convenience function to add a password text field to this * container/window. @@ -2256,4 +2286,22 @@ public abstract class TWidget implements Comparable { return new TTableWidget(this, x, y, width, height); } + /** + * Convenience function to add an editable 2D data table to this + * container/window. + * + * @param x column relative to parent + * @param y row relative to parent + * @param width width of widget + * @param height height of widget + * @param gridColumns number of columns in grid + * @param gridRows number of rows in grid + */ + public TTableWidget addTable(final int x, final int y, final int width, + final int height, final int gridColumns, final int gridRows) { + + return new TTableWidget(this, x, y, width, height, gridColumns, + gridRows); + } + }