import java.util.Set;
import jexer.backend.Screen;
-import jexer.bits.Cell;
import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
+import jexer.bits.StringUtils;
import jexer.event.TCommandEvent;
import jexer.event.TKeypressEvent;
import jexer.event.TMenuEvent;
super.onMenu(menu);
}
+ /**
+ * Method that subclasses can override to handle window/screen resize
+ * events.
+ *
+ * @param resize resize event
+ */
+ @Override
+ public void onResize(final TResizeEvent resize) {
+ if (resize.getType() == TResizeEvent.Type.WIDGET) {
+ if (getChildren().size() == 1) {
+ TWidget child = getChildren().get(0);
+ if ((child instanceof TSplitPane)
+ || (child instanceof TPanel)
+ ) {
+ if (this instanceof TDesktop) {
+ child.onResize(new TResizeEvent(
+ TResizeEvent.Type.WIDGET,
+ resize.getWidth(), resize.getHeight()));
+ } else {
+ child.onResize(new TResizeEvent(
+ TResizeEvent.Type.WIDGET,
+ resize.getWidth() - 2, resize.getHeight() - 2));
+ }
+ }
+ return;
+ }
+ }
+
+ // Pass on to TWidget.
+ super.onResize(resize);
+ }
+
// ------------------------------------------------------------------------
// TWidget ----------------------------------------------------------------
// ------------------------------------------------------------------------
true);
// Draw the title
- int titleLeft = (getWidth() - title.length() - 2) / 2;
+ int titleLength = StringUtils.width(title);
+ int titleLeft = (getWidth() - titleLength - 2) / 2;
putCharXY(titleLeft, 0, ' ', border);
- putStringXY(titleLeft + 1, 0, title);
- putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
+ putStringXY(titleLeft + 1, 0, title, border);
+ putCharXY(titleLeft + titleLength + 1, 0, ' ', border);
if (isActive()) {
restoreWindowX = getX();
restoreWindowY = getY();
setWidth(getScreen().getWidth());
- setHeight(application.getDesktopBottom() - 1);
+ setHeight(application.getDesktopBottom() - application.getDesktopTop());
setX(0);
- setY(1);
+ setY(application.getDesktopTop());
maximized = true;
onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(),
/**
* Activate window (bring to top and receive events).
*/
+ @Override
public void activate() {
application.activateWindow(this);
}
* Close window. Note that windows without a close box can still be
* closed by calling the close() method.
*/
+ @Override
public void close() {
application.closeWindow(this);
}
* @return true if this window does not want the application-wide mouse
* cursor drawn over it
*/
- public final boolean hasHiddenMouse() {
+ public boolean hasHiddenMouse() {
return hideMouse;
}
this.hideMouse = hideMouse;
}
+ /**
+ * Generate a human-readable string for this window.
+ *
+ * @return a human-readable string
+ */
+ @Override
+ public String toString() {
+ return String.format("%s(%8x) \'%s\' position (%d, %d) geometry %dx%d" +
+ " hidden %s modal %s", getClass().getName(), hashCode(), title,
+ getX(), getY(), getWidth(), getHeight(), hidden, isModal());
+ }
+
}