/**
* TWindow is the top-level container and drawing surface for other widgets.
*/
-public class TWindow extends TWidget implements Comparable<TWindow> {
+public class TWindow extends TWidget {
/**
* Window's parent TApplication.
* If true, then the user clicked on the title bar and is moving the
* window.
*/
- private boolean inWindowMove = false;
+ protected boolean inWindowMove = false;
/**
* If true, then the user clicked on the bottom right corner and is
* resizing the window.
*/
- private boolean inWindowResize = false;
+ protected boolean inWindowResize = false;
/**
* If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is
private int restoreWindowX;
private int restoreWindowY;
+ /**
+ * Set the maximum width for this window.
+ *
+ * @param maximumWindowWidth new maximum width
+ */
+ public final void setMaximumWindowWidth(final int maximumWindowWidth) {
+ this.maximumWindowWidth = maximumWindowWidth;
+ }
+
/**
* Public constructor. Window will be located at (0, 0).
*
return true;
}
- /**
- * Comparison operator sorts on z.
- *
- * @param that another TWindow instance
- * @return difference between this.z and that.z
- */
- @Override
- public final int compareTo(final TWindow that) {
- return (this.z - that.z);
- }
-
/**
* Returns true if the mouse is currently on the close button.
*
@Override
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
inKeyboardResize = false;
@Override
public void onMouseUp(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
if ((inWindowMove) && (mouse.getMouse1())) {
// Stop moving window
@Override
public void onMouseMotion(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
if (inWindowMove) {
// Move window over
}
}
if (keypress.equals(kbShiftLeft)) {
- if (getWidth() > minimumWindowWidth) {
+ if ((getWidth() > minimumWindowWidth)
+ || (minimumWindowWidth <= 0)
+ ) {
setWidth(getWidth() - 1);
}
}
if (keypress.equals(kbShiftRight)) {
- if (getWidth() < maximumWindowWidth) {
+ if ((getWidth() < maximumWindowWidth)
+ || (maximumWindowWidth <= 0)
+ ) {
setWidth(getWidth() + 1);
}
}
if (keypress.equals(kbShiftUp)) {
- if (getHeight() > minimumWindowHeight) {
+ if ((getHeight() > minimumWindowHeight)
+ || (minimumWindowHeight <= 0)
+ ) {
setHeight(getHeight() - 1);
}
}
if (keypress.equals(kbShiftDown)) {
- if (getHeight() < maximumWindowHeight) {
+ if ((getHeight() < maximumWindowHeight)
+ || (maximumWindowHeight <= 0)
+ ) {
setHeight(getHeight() + 1);
}
}