// ------------------------------------------------------------------------
/**
- * 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);
}
/**
// 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.
*/
// 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.
*/
import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
+import jexer.event.TResizeEvent;
import static jexer.TKeypress.*;
/**
// 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.
*