}
if (inWindowResize) {
- // Do not permit resizing below the status line
- if (mouse.getAbsoluteY() == application.getDesktopBottom()) {
- inWindowResize = false;
- return;
- }
-
// Move window over
setWidth(resizeWindowWidth + (mouse.getAbsoluteX()
- moveWindowMouseX));
// Keep within min/max bounds
if (getWidth() < minimumWindowWidth) {
setWidth(minimumWindowWidth);
- inWindowResize = false;
}
if (getHeight() < minimumWindowHeight) {
setHeight(minimumWindowHeight);
- inWindowResize = false;
}
if ((maximumWindowWidth > 0)
&& (getWidth() > maximumWindowWidth)
) {
setWidth(maximumWindowWidth);
- inWindowResize = false;
}
if ((maximumWindowHeight > 0)
&& (getHeight() > maximumWindowHeight)
) {
setHeight(maximumWindowHeight);
- inWindowResize = false;
+ }
+ if (getHeight() + getY() >= getApplication().getDesktopBottom()) {
+ setHeight(getApplication().getDesktopBottom() - getY());
}
// Pass a resize event to my children
@Override
public void onKeypress(final TKeypressEvent keypress) {
+ if (inWindowMove || inWindowResize) {
+ // ESC or ENTER - Exit size/move
+ if (keypress.equals(kbEsc) || keypress.equals(kbEnter)) {
+ inWindowMove = false;
+ inWindowResize = false;
+ return;
+ }
+ }
+
if (inKeyboardResize) {
// ESC or ENTER - Exit size/move
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 ----------------------------------------------------------------
// ------------------------------------------------------------------------
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(),
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());
+ }
+
}