clean up threads and timers
[nikiroo-utils.git] / src / jexer / TWindow.java
index 8634b2a9227c2e1bb17ab0ae01b08fcbd5268fff..0a74a40dcc830f8cf739c0ad0f56c9c7ea4f943a 100644 (file)
@@ -46,7 +46,7 @@ import static jexer.TKeypress.*;
 /**
  * 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.
@@ -187,6 +187,15 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     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).
      *
@@ -305,17 +314,6 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
         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.
      *
@@ -372,7 +370,7 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      *
      * @return the background color
      */
-    private CellAttributes getBackground() {
+    public final CellAttributes getBackground() {
         if (!isModal()
             && (inWindowMove || inWindowResize || inKeyboardResize)
         ) {
@@ -534,7 +532,6 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     @Override
     public void onMouseDown(final TMouseEvent mouse) {
         this.mouse = mouse;
-        application.setRepaint();
 
         inKeyboardResize = false;
 
@@ -607,7 +604,6 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     @Override
     public void onMouseUp(final TMouseEvent mouse) {
         this.mouse = mouse;
-        application.setRepaint();
 
         if ((inWindowMove) && (mouse.getMouse1())) {
             // Stop moving window
@@ -655,7 +651,6 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     @Override
     public void onMouseMotion(final TMouseEvent mouse) {
         this.mouse = mouse;
-        application.setRepaint();
 
         if (inWindowMove) {
             // Move window over
@@ -753,22 +748,30 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
                 }
             }
             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);
                 }
             }