resizing fixes
authorKevin Lamonte <kevin.lamonte@gmail.com>
Sat, 17 Aug 2019 15:28:00 +0000 (10:28 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Sat, 17 Aug 2019 15:28:00 +0000 (10:28 -0500)
src/jexer/TComboBox.java
src/jexer/TList.java
src/jexer/TText.java
src/jexer/ttree/TTreeViewWidget.java

index 4abdd6fbc7445b89378dffd3ec7e40923d88bec6..fe1366d3aad49693802efa0a3af0fee114abd3fc 100644 (file)
@@ -216,13 +216,15 @@ public class TComboBox extends TWidget {
     // ------------------------------------------------------------------------
 
     /**
-     * Override TWidget's width: we can only set width at construction time.
+     * Override TWidget's width: we need to set child widget widths.
      *
-     * @param width new widget width (ignored)
+     * @param width new widget width
      */
     @Override
     public void setWidth(final int width) {
-        // Do nothing
+        field.setWidth(width - 3);
+        list.setWidth(width);
+        super.setWidth(width);
     }
 
     /**
index a962f7cfe9eeee9b3ed579657964765add8bc772..253e40972a49ab133211bdff156708163b08eec8 100644 (file)
@@ -327,6 +327,31 @@ public class TList extends TScrollableWidget {
     // TScrollableWidget ------------------------------------------------------
     // ------------------------------------------------------------------------
 
+    /**
+     * Override TWidget's width: we need to set child widget widths.
+     *
+     * @param width new widget width
+     */
+    @Override
+    public void setWidth(final int width) {
+        super.setWidth(width);
+        hScroller.setWidth(getWidth() - 1);
+        vScroller.setX(getWidth() - 1);
+    }
+
+    /**
+     * Override TWidget's height: we need to set child widget heights.
+     * time.
+     *
+     * @param height new widget height
+     */
+    @Override
+    public void setHeight(final int height) {
+        super.setHeight(height);
+        hScroller.setY(getHeight() - 1);
+        vScroller.setHeight(getHeight() - 1);
+    }
+
     /**
      * Resize for a new width/height.
      */
index 4791fdc5e38e242e707a8ed97d64d618895463d1..e47a162c6f5fe7a38ca02381320d393bdace1a1e 100644 (file)
@@ -173,6 +173,31 @@ public class TText extends TScrollableWidget {
     // TScrollableWidget ------------------------------------------------------
     // ------------------------------------------------------------------------
 
+    /**
+     * Override TWidget's width: we need to set child widget widths.
+     *
+     * @param width new widget width
+     */
+    @Override
+    public void setWidth(final int width) {
+        super.setWidth(width);
+        hScroller.setWidth(getWidth() - 1);
+        vScroller.setX(getWidth() - 1);
+    }
+
+    /**
+     * Override TWidget's height: we need to set child widget heights.
+     * time.
+     *
+     * @param height new widget height
+     */
+    @Override
+    public void setHeight(final int height) {
+        super.setHeight(height);
+        hScroller.setY(getHeight() - 1);
+        vScroller.setHeight(getHeight() - 1);
+    }
+
     /**
      * Draw the text box.
      */
index 9ffb72461709645a428886f944a63a55213db006..080a200497dfbe5389a8f62f3593688eb325fb72 100644 (file)
@@ -37,6 +37,7 @@ import jexer.TWidget;
 import jexer.bits.StringUtils;
 import jexer.event.TKeypressEvent;
 import jexer.event.TMouseEvent;
+import jexer.event.TResizeEvent;
 import static jexer.TKeypress.*;
 
 /**
@@ -110,6 +111,24 @@ public class TTreeViewWidget extends TScrollableWidget {
     // Event handlers ---------------------------------------------------------
     // ------------------------------------------------------------------------
 
+    /**
+     * Handle window/screen resize events.
+     *
+     * @param event resize event
+     */
+    @Override
+    public void onResize(final TResizeEvent event) {
+        super.onResize(event);
+
+        if (event.getType() == TResizeEvent.Type.WIDGET) {
+            treeView.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+                    getWidth() - 1, getHeight() - 1));
+            return;
+        } else {
+            super.onResize(event);
+        }
+    }
+
     /**
      * Handle mouse press events.
      *