#34 call onResize() when window size is changed
[fanfix.git] / src / jexer / TApplication.java
index 9fa64d0703ae5d973453db0abb998661eb76fe20..96dad6cc0b0cece1541d43dccab333b813f233d0 100644 (file)
@@ -2063,6 +2063,9 @@ public class TApplication implements Runnable {
                 }
 
                 TWindow w = sorted.get(i);
+                int oldWidth = w.getWidth();
+                int oldHeight = w.getHeight();
+
                 w.setX(logicalX * newWidth);
                 w.setWidth(newWidth);
                 if (i >= ((a - 1) * b)) {
@@ -2072,6 +2075,12 @@ public class TApplication implements Runnable {
                     w.setY((logicalY * newHeight1) + 1);
                     w.setHeight(newHeight1);
                 }
+                if ((w.getWidth() != oldWidth)
+                    || (w.getHeight() != oldHeight)
+                ) {
+                    w.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+                            w.getWidth(), w.getHeight()));
+                }
             }
         }
     }
@@ -2861,6 +2870,22 @@ public class TApplication implements Runnable {
         return new TInputBox(this, 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 new TInputBox(this, title, caption, text, type);
+    }
+
     /**
      * Convenience function to open a terminal window.
      *