X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTDesktop.java;h=5aa52af74a981f97901c0e09c9d7af4062056fa3;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=07a29a3397b64847bb0a0d6fa8e439ac11bfa583;hpb=9245321388306b5b49d6385ce2f46ea6a82ab619;p=fanfix.git diff --git a/src/jexer/TDesktop.java b/src/jexer/TDesktop.java index 07a29a3..5aa52af 100644 --- a/src/jexer/TDesktop.java +++ b/src/jexer/TDesktop.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,86 +48,51 @@ import jexer.event.TResizeEvent; *
  • Keypress events are seen if no other windows are open.
  • *
  • Menu events are seen if no other windows are open.
  • *
  • Command events are seen if no other windows are open.
  • - * */ public class TDesktop extends TWindow { + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Public constructor. * * @param parent parent application */ public TDesktop(final TApplication parent) { - super(parent, "", 0, 0, parent.getScreen().getWidth(), - parent.getScreen().getHeight() - 1); + parent.getDesktopBottom() - parent.getDesktopTop()); setActive(false); } - /** - * The default TDesktop draws a hatch character across everything. - */ - @Override - public void draw() { - CellAttributes background = getTheme().getColor("tdesktop.background"); - putAll(GraphicsChars.HATCH, background); - } - - /** - * Hide window. This is a NOP for TDesktop. - */ - @Override - public final void hide() {} - - /** - * Show window. This is a NOP for TDesktop. - */ - @Override - public final void show() {} - - /** - * Called by hide(). This is a NOP for TDesktop. - */ - @Override - public final void onHide() {} - - /** - * Called by show(). This is a NOP for TDesktop. - */ - @Override - public final void onShow() {} - - /** - * Returns true if the mouse is currently on the close button. - * - * @return true if mouse is currently on the close button - */ - @Override - protected final boolean mouseOnClose() { - return false; - } - - /** - * Returns true if the mouse is currently on the maximize/restore button. - * - * @return true if the mouse is currently on the maximize/restore button - */ - @Override - protected final boolean mouseOnMaximize() { - return false; - } + // ------------------------------------------------------------------------ + // Event handlers --------------------------------------------------------- + // ------------------------------------------------------------------------ /** - * Returns true if the mouse is currently on the resizable lower right - * corner. + * Handle window/screen resize events. * - * @return true if the mouse is currently on the resizable lower right - * corner + * @param resize resize event */ @Override - protected final boolean mouseOnResize() { - return false; + public void onResize(final TResizeEvent resize) { + if (getChildren().size() == 1) { + TWidget child = getChildren().get(0); + if (!(child instanceof TWindow)) { + // Only one child, resize it to match my size. + child.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, + getWidth(), getHeight())); + } + } + if (resize.getType() == TResizeEvent.Type.SCREEN) { + // Let children see the screen resize + for (TWidget widget: getChildren()) { + widget.onResize(resize); + } + } } /** @@ -213,4 +178,81 @@ public class TDesktop extends TWindow { super.onMenu(menu); } + // ------------------------------------------------------------------------ + // TWindow ---------------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * The default TDesktop draws a hatch character across everything. + */ + @Override + public void draw() { + CellAttributes background = getTheme().getColor("tdesktop.background"); + putAll(GraphicsChars.HATCH, background); + + /* + // For debugging, let's see where the desktop bounds really are. + putCharXY(0, 0, '0', background); + putCharXY(getWidth() - 1, 0, '1', background); + putCharXY(0, getHeight() - 1, '2', background); + putCharXY(getWidth() - 1, getHeight() - 1, '3', background); + */ + } + + /** + * Hide window. This is a NOP for TDesktop. + */ + @Override + public final void hide() {} + + /** + * Show window. This is a NOP for TDesktop. + */ + @Override + public final void show() {} + + /** + * Called by hide(). This is a NOP for TDesktop. + */ + @Override + public final void onHide() {} + + /** + * Called by show(). This is a NOP for TDesktop. + */ + @Override + public final void onShow() {} + + /** + * Returns true if the mouse is currently on the close button. + * + * @return true if mouse is currently on the close button + */ + @Override + protected final boolean mouseOnClose() { + return false; + } + + /** + * Returns true if the mouse is currently on the maximize/restore button. + * + * @return true if the mouse is currently on the maximize/restore button + */ + @Override + protected final boolean mouseOnMaximize() { + return false; + } + + /** + * Returns true if the mouse is currently on the resizable lower right + * corner. + * + * @return true if the mouse is currently on the resizable lower right + * corner + */ + @Override + protected final boolean mouseOnResize() { + return false; + } + }