window focus events and enable/disable menu items
[fanfix.git] / src / jexer / TWindow.java
index 0e94808fd05c1b0e3e9342402f642d9b2ed7f5c2..bfb09017f75fd615aa4422e2c56c0411bb7ee997 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Jexer - Java Text User Interface
  *
  * License: LGPLv3 or later
@@ -39,24 +39,26 @@ import jexer.event.TMenuEvent;
 import jexer.event.TMouseEvent;
 import jexer.event.TResizeEvent;
 import jexer.io.Screen;
+import jexer.menu.TMenu;
 import static jexer.TCommand.*;
 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.
      */
-    protected TApplication application;
+    private TApplication application;
 
     /**
      * Get this TWindow's parent TApplication.
      *
      * @return this TWindow's parent TApplication
      */
+    @Override
     public final TApplication getApplication() {
         return application;
     }
@@ -66,6 +68,7 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      *
      * @return the Screen
      */
+    @Override
     public final Screen getScreen() {
         return application.getScreen();
     }
@@ -73,7 +76,25 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     /**
      * Window title.
      */
-    protected String title = "";
+    private String title = "";
+
+    /**
+     * Get window title.
+     *
+     * @return window title
+     */
+    public final String getTitle() {
+        return title;
+    }
+
+    /**
+     * Set window title.
+     *
+     * @param title new window title
+     */
+    public final void setTitle(final String title) {
+        this.title = title;
+    }
 
     /**
      * Window is resizable (default yes).
@@ -122,13 +143,13 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      * 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
@@ -166,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).
      *
@@ -226,22 +256,20 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
         final int x, final int y, final int width, final int height,
         final int flags) {
 
+        super();
+
         // I am my own window and parent
-        this.parent = this;
-        this.window = this;
+        setupForTWindow(this, x, y + application.getDesktopTop(),
+            width, height);
 
         // Save fields
         this.title       = title;
         this.application = application;
-        this.x           = x;
-        this.y           = y + application.getDesktopTop();
-        this.width       = width;
-        this.height      = height;
         this.flags       = flags;
 
         // Minimum width/height are 10 and 2
         assert (width >= 10);
-        assert (height >= 2);
+        assert (getHeight() >= 2);
 
         // MODAL implies CENTERED
         if (isModal()) {
@@ -260,18 +288,17 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      */
     public final void center() {
         if ((flags & CENTERED) != 0) {
-            if (width < getScreen().getWidth()) {
-                x = (getScreen().getWidth() - width) / 2;
+            if (getWidth() < getScreen().getWidth()) {
+                setX((getScreen().getWidth() - getWidth()) / 2);
             } else {
-                x = 0;
+                setX(0);
             }
-            y = (application.getDesktopBottom() - application.getDesktopTop());
-            y -= height;
-            y /= 2;
-            if (y < 0) {
-                y = 0;
+            setY(((application.getDesktopBottom()
+                    - application.getDesktopTop()) - getHeight()) / 2);
+            if (getY() < 0) {
+                setY(0);
             }
-            y += application.getDesktopTop();
+            setY(getY() + application.getDesktopTop());
         }
     }
 
@@ -287,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.
      *
@@ -305,8 +321,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      */
     private boolean mouseOnClose() {
         if ((mouse != null)
-            && (mouse.getAbsoluteY() == y)
-            && (mouse.getAbsoluteX() == x + 3)
+            && (mouse.getAbsoluteY() == getY())
+            && (mouse.getAbsoluteX() == getX() + 3)
         ) {
             return true;
         }
@@ -321,8 +337,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     private boolean mouseOnMaximize() {
         if ((mouse != null)
             && !isModal()
-            && (mouse.getAbsoluteY() == y)
-            && (mouse.getAbsoluteX() == x + width - 4)
+            && (mouse.getAbsoluteY() == getY())
+            && (mouse.getAbsoluteX() == getX() + getWidth() - 4)
         ) {
             return true;
         }
@@ -340,9 +356,9 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
         if (((flags & RESIZABLE) != 0)
             && !isModal()
             && (mouse != null)
-            && (mouse.getAbsoluteY() == y + height - 1)
-            && ((mouse.getAbsoluteX() == x + width - 1)
-                || (mouse.getAbsoluteX() == x + width - 2))
+            && (mouse.getAbsoluteY() == getY() + getHeight() - 1)
+            && ((mouse.getAbsoluteX() == getX() + getWidth() - 1)
+                || (mouse.getAbsoluteX() == getX() + getWidth() - 2))
         ) {
             return true;
         }
@@ -354,26 +370,26 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      *
      * @return the background color
      */
-    protected final CellAttributes getBackground() {
+    public final CellAttributes getBackground() {
         if (!isModal()
             && (inWindowMove || inWindowResize || inKeyboardResize)
         ) {
-            assert (active);
-            return application.getTheme().getColor("twindow.background.windowmove");
+            assert (isActive());
+            return getTheme().getColor("twindow.background.windowmove");
         } else if (isModal() && inWindowMove) {
-            assert (active);
-            return application.getTheme().getColor("twindow.background.modal");
+            assert (isActive());
+            return getTheme().getColor("twindow.background.modal");
         } else if (isModal()) {
-            if (active) {
-                return application.getTheme().getColor("twindow.background.modal");
+            if (isActive()) {
+                return getTheme().getColor("twindow.background.modal");
             }
-            return application.getTheme().getColor("twindow.background.modal.inactive");
-        } else if (active) {
+            return getTheme().getColor("twindow.background.modal.inactive");
+        } else if (isActive()) {
             assert (!isModal());
-            return application.getTheme().getColor("twindow.background");
+            return getTheme().getColor("twindow.background");
         } else {
             assert (!isModal());
-            return application.getTheme().getColor("twindow.background.inactive");
+            return getTheme().getColor("twindow.background.inactive");
         }
     }
 
@@ -382,27 +398,27 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      *
      * @return the border color
      */
-    protected final CellAttributes getBorder() {
+    private CellAttributes getBorder() {
         if (!isModal()
             && (inWindowMove || inWindowResize || inKeyboardResize)
         ) {
-            assert (active);
-            return application.getTheme().getColor("twindow.border.windowmove");
+            assert (isActive());
+            return getTheme().getColor("twindow.border.windowmove");
         } else if (isModal() && inWindowMove) {
-            assert (active);
-            return application.getTheme().getColor("twindow.border.modal.windowmove");
+            assert (isActive());
+            return getTheme().getColor("twindow.border.modal.windowmove");
         } else if (isModal()) {
-            if (active) {
-                return application.getTheme().getColor("twindow.border.modal");
+            if (isActive()) {
+                return getTheme().getColor("twindow.border.modal");
             } else {
-                return application.getTheme().getColor("twindow.border.modal.inactive");
+                return getTheme().getColor("twindow.border.modal.inactive");
             }
-        } else if (active) {
+        } else if (isActive()) {
             assert (!isModal());
-            return application.getTheme().getColor("twindow.border");
+            return getTheme().getColor("twindow.border");
         } else {
             assert (!isModal());
-            return application.getTheme().getColor("twindow.border.inactive");
+            return getTheme().getColor("twindow.border.inactive");
         }
     }
 
@@ -411,22 +427,22 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      *
      * @return the border line type
      */
-    protected final int getBorderType() {
+    private int getBorderType() {
         if (!isModal()
             && (inWindowMove || inWindowResize || inKeyboardResize)
         ) {
-            assert (active);
+            assert (isActive());
             return 1;
         } else if (isModal() && inWindowMove) {
-            assert (active);
+            assert (isActive());
             return 1;
         } else if (isModal()) {
-            if (active) {
+            if (isActive()) {
                 return 2;
             } else {
                 return 1;
             }
-        } else if (active) {
+        } else if (isActive()) {
             return 2;
         } else {
             return 1;
@@ -441,6 +457,22 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
         // Default: do nothing
     }
 
+    /**
+     * Called by application.switchWindow() when this window gets the
+     * focus, and also by application.addWindow().
+     */
+    public void onFocus() {
+        // Default: do nothing
+    }
+
+    /**
+     * Called by application.switchWindow() when another window gets the
+     * focus.
+     */
+    public void onUnfocus() {
+        // Default: do nothing
+    }
+
     /**
      * Called by TApplication.drawChildren() to render on screen.
      */
@@ -451,56 +483,58 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
         CellAttributes background = getBackground();
         int borderType = getBorderType();
 
-        getScreen().drawBox(0, 0, width, height, border,
+        getScreen().drawBox(0, 0, getWidth(), getHeight(), border,
             background, borderType, true);
 
         // Draw the title
-        int titleLeft = (width - title.length() - 2) / 2;
+        int titleLeft = (getWidth() - title.length() - 2) / 2;
         putCharXY(titleLeft, 0, ' ', border);
-        putStrXY(titleLeft + 1, 0, title);
+        putStringXY(titleLeft + 1, 0, title);
         putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
 
-        if (active) {
+        if (isActive()) {
 
             // Draw the close button
             putCharXY(2, 0, '[', border);
             putCharXY(4, 0, ']', border);
-            if (mouseOnClose() && mouse.getMouse1()) {
+            if (mouseOnClose() && mouse.isMouse1()) {
                 putCharXY(3, 0, GraphicsChars.CP437[0x0F],
                     !isModal()
-                    ? application.getTheme().getColor("twindow.border.windowmove")
-                    : application.getTheme().getColor("twindow.border.modal.windowmove"));
+                    ? getTheme().getColor("twindow.border.windowmove")
+                    : getTheme().getColor("twindow.border.modal.windowmove"));
             } else {
                 putCharXY(3, 0, GraphicsChars.CP437[0xFE],
                     !isModal()
-                    ? application.getTheme().getColor("twindow.border.windowmove")
-                    : application.getTheme().getColor("twindow.border.modal.windowmove"));
+                    ? getTheme().getColor("twindow.border.windowmove")
+                    : getTheme().getColor("twindow.border.modal.windowmove"));
             }
 
             // Draw the maximize button
             if (!isModal()) {
 
-                putCharXY(width - 5, 0, '[', border);
-                putCharXY(width - 3, 0, ']', border);
-                if (mouseOnMaximize() && mouse.getMouse1()) {
-                    putCharXY(width - 4, 0, GraphicsChars.CP437[0x0F],
-                        application.getTheme().getColor("twindow.border.windowmove"));
+                putCharXY(getWidth() - 5, 0, '[', border);
+                putCharXY(getWidth() - 3, 0, ']', border);
+                if (mouseOnMaximize() && mouse.isMouse1()) {
+                    putCharXY(getWidth() - 4, 0, GraphicsChars.CP437[0x0F],
+                        getTheme().getColor("twindow.border.windowmove"));
                 } else {
                     if (maximized) {
-                        putCharXY(width - 4, 0, GraphicsChars.CP437[0x12],
-                            application.getTheme().getColor("twindow.border.windowmove"));
+                        putCharXY(getWidth() - 4, 0, GraphicsChars.CP437[0x12],
+                            getTheme().getColor("twindow.border.windowmove"));
                     } else {
-                        putCharXY(width - 4, 0, GraphicsChars.UPARROW,
-                            application.getTheme().getColor("twindow.border.windowmove"));
+                        putCharXY(getWidth() - 4, 0, GraphicsChars.UPARROW,
+                            getTheme().getColor("twindow.border.windowmove"));
                     }
                 }
 
                 // Draw the resize corner
                 if ((flags & RESIZABLE) != 0) {
-                    putCharXY(width - 2, height - 1, GraphicsChars.SINGLE_BAR,
-                        application.getTheme().getColor("twindow.border.windowmove"));
-                    putCharXY(width - 1, height - 1, GraphicsChars.LRCORNER,
-                        application.getTheme().getColor("twindow.border.windowmove"));
+                    putCharXY(getWidth() - 2, getHeight() - 1,
+                        GraphicsChars.SINGLE_BAR,
+                        getTheme().getColor("twindow.border.windowmove"));
+                    putCharXY(getWidth() - 1, getHeight() - 1,
+                        GraphicsChars.LRCORNER,
+                        getTheme().getColor("twindow.border.windowmove"));
                 }
             }
         }
@@ -514,14 +548,13 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     @Override
     public void onMouseDown(final TMouseEvent mouse) {
         this.mouse = mouse;
-        application.setRepaint();
 
         inKeyboardResize = false;
 
-        if ((mouse.getAbsoluteY() == y)
-            && mouse.getMouse1()
-            && (x <= mouse.getAbsoluteX())
-            && (mouse.getAbsoluteX() < x + width)
+        if ((mouse.getAbsoluteY() == getY())
+            && mouse.isMouse1()
+            && (getX() <= mouse.getAbsoluteX())
+            && (mouse.getAbsoluteX() < getX() + getWidth())
             && !mouseOnClose()
             && !mouseOnMaximize()
         ) {
@@ -529,8 +562,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
             inWindowMove = true;
             moveWindowMouseX = mouse.getAbsoluteX();
             moveWindowMouseY = mouse.getAbsoluteY();
-            oldWindowX = x;
-            oldWindowY = y;
+            oldWindowX = getX();
+            oldWindowY = getY();
             if (maximized) {
                 maximized = false;
             }
@@ -541,8 +574,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
             inWindowResize = true;
             moveWindowMouseX = mouse.getAbsoluteX();
             moveWindowMouseY = mouse.getAbsoluteY();
-            resizeWindowWidth = width;
-            resizeWindowHeight = height;
+            resizeWindowWidth = getWidth();
+            resizeWindowHeight = getHeight();
             if (maximized) {
                 maximized = false;
             }
@@ -557,14 +590,14 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      * Maximize window.
      */
     private void maximize() {
-        restoreWindowWidth = width;
-        restoreWindowHeight = height;
-        restoreWindowX = x;
-        restoreWindowY = y;
-        width = getScreen().getWidth();
-        height = application.getDesktopBottom() - 1;
-        x = 0;
-        y = 1;
+        restoreWindowWidth = getWidth();
+        restoreWindowHeight = getHeight();
+        restoreWindowX = getX();
+        restoreWindowY = getY();
+        setWidth(getScreen().getWidth());
+        setHeight(application.getDesktopBottom() - 1);
+        setX(0);
+        setY(1);
         maximized = true;
     }
 
@@ -572,10 +605,10 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      * Restote (unmaximize) window.
      */
     private void restore() {
-        width = restoreWindowWidth;
-        height = restoreWindowHeight;
-        x = restoreWindowX;
-        y = restoreWindowY;
+        setWidth(restoreWindowWidth);
+        setHeight(restoreWindowHeight);
+        setX(restoreWindowX);
+        setY(restoreWindowY);
         maximized = false;
     }
 
@@ -587,27 +620,27 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
     @Override
     public void onMouseUp(final TMouseEvent mouse) {
         this.mouse = mouse;
-        application.setRepaint();
 
-        if ((inWindowMove) && (mouse.getMouse1())) {
+        if ((inWindowMove) && (mouse.isMouse1())) {
             // Stop moving window
             inWindowMove = false;
             return;
         }
 
-        if ((inWindowResize) && (mouse.getMouse1())) {
+        if ((inWindowResize) && (mouse.isMouse1())) {
             // Stop resizing window
             inWindowResize = false;
             return;
         }
 
-        if (mouse.getMouse1() && mouseOnClose()) {
+        if (mouse.isMouse1() && mouseOnClose()) {
             // Close window
             application.closeWindow(this);
             return;
         }
 
-        if ((mouse.getAbsoluteY() == y) && mouse.getMouse1()
+        if ((mouse.getAbsoluteY() == getY())
+            && mouse.isMouse1()
             && mouseOnMaximize()) {
             if (maximized) {
                 // Restore
@@ -617,7 +650,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
                 maximize();
             }
             // Pass a resize event to my children
-            onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, width, height));
+            onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+                    getWidth(), getHeight()));
             return;
         }
 
@@ -633,54 +667,60 @@ 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
-            x = oldWindowX + (mouse.getAbsoluteX() - moveWindowMouseX);
-            y = oldWindowY + (mouse.getAbsoluteY() - moveWindowMouseY);
+            setX(oldWindowX + (mouse.getAbsoluteX() - moveWindowMouseX));
+            setY(oldWindowY + (mouse.getAbsoluteY() - moveWindowMouseY));
             // Don't cover up the menu bar
-            if (y < application.getDesktopTop()) {
-                y = application.getDesktopTop();
+            if (getY() < application.getDesktopTop()) {
+                setY(application.getDesktopTop());
             }
             return;
         }
 
         if (inWindowResize) {
             // Move window over
-            width = resizeWindowWidth + (mouse.getAbsoluteX() - moveWindowMouseX);
-            height = resizeWindowHeight + (mouse.getAbsoluteY() - moveWindowMouseY);
-            if (x + width > getScreen().getWidth()) {
-                width = getScreen().getWidth() - x;
+            setWidth(resizeWindowWidth + (mouse.getAbsoluteX()
+                    - moveWindowMouseX));
+            setHeight(resizeWindowHeight + (mouse.getAbsoluteY()
+                    - moveWindowMouseY));
+            if (getX() + getWidth() > getScreen().getWidth()) {
+                setWidth(getScreen().getWidth() - getX());
             }
-            if (y + height > application.getDesktopBottom()) {
-                y = application.getDesktopBottom() - height + 1;
+            if (getY() + getHeight() > application.getDesktopBottom()) {
+                setY(application.getDesktopBottom() - getHeight() + 1);
             }
             // Don't cover up the menu bar
-            if (y < application.getDesktopTop()) {
-                y = application.getDesktopTop();
+            if (getY() < application.getDesktopTop()) {
+                setY(application.getDesktopTop());
             }
 
             // Keep within min/max bounds
-            if (width < minimumWindowWidth) {
-                width = minimumWindowWidth;
+            if (getWidth() < minimumWindowWidth) {
+                setWidth(minimumWindowWidth);
                 inWindowResize = false;
             }
-            if (height < minimumWindowHeight) {
-                height = minimumWindowHeight;
+            if (getHeight() < minimumWindowHeight) {
+                setHeight(minimumWindowHeight);
                 inWindowResize = false;
             }
-            if ((maximumWindowWidth > 0) && (width > maximumWindowWidth)) {
-                width = maximumWindowWidth;
+            if ((maximumWindowWidth > 0)
+                && (getWidth() > maximumWindowWidth)
+            ) {
+                setWidth(maximumWindowWidth);
                 inWindowResize = false;
             }
-            if ((maximumWindowHeight > 0) && (height > maximumWindowHeight)) {
-                height = maximumWindowHeight;
+            if ((maximumWindowHeight > 0)
+                && (getHeight() > maximumWindowHeight)
+            ) {
+                setHeight(maximumWindowHeight);
                 inWindowResize = false;
             }
 
             // Pass a resize event to my children
-            onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, width, height));
+            onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+                    getWidth(), getHeight()));
             return;
         }
 
@@ -704,46 +744,58 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
             }
 
             if (keypress.equals(kbLeft)) {
-                if (x > 0) {
-                    x--;
+                if (getX() > 0) {
+                    setX(getX() - 1);
                 }
             }
             if (keypress.equals(kbRight)) {
-                if (x < getScreen().getWidth() - 1) {
-                    x++;
+                if (getX() < getScreen().getWidth() - 1) {
+                    setX(getX() + 1);
                 }
             }
             if (keypress.equals(kbDown)) {
-                if (y < application.getDesktopBottom() - 1) {
-                    y++;
+                if (getY() < application.getDesktopBottom() - 1) {
+                    setY(getY() + 1);
                 }
             }
             if (keypress.equals(kbUp)) {
-                if (y > 1) {
-                    y--;
+                if (getY() > 1) {
+                    setY(getY() - 1);
                 }
             }
             if (keypress.equals(kbShiftLeft)) {
-                if (width > minimumWindowWidth) {
-                    width--;
+                if ((getWidth() > minimumWindowWidth)
+                    || (minimumWindowWidth <= 0)
+                ) {
+                    setWidth(getWidth() - 1);
                 }
             }
             if (keypress.equals(kbShiftRight)) {
-                if (width < maximumWindowWidth) {
-                    width++;
+                if ((getWidth() < maximumWindowWidth)
+                    || (maximumWindowWidth <= 0)
+                ) {
+                    setWidth(getWidth() + 1);
                 }
             }
             if (keypress.equals(kbShiftUp)) {
-                if (height > minimumWindowHeight) {
-                    height--;
+                if ((getHeight() > minimumWindowHeight)
+                    || (minimumWindowHeight <= 0)
+                ) {
+                    setHeight(getHeight() - 1);
                 }
             }
             if (keypress.equals(kbShiftDown)) {
-                if (height < maximumWindowHeight) {
-                    height++;
+                if ((getHeight() < maximumWindowHeight)
+                    || (maximumWindowHeight <= 0)
+                ) {
+                    setHeight(getHeight() + 1);
                 }
             }
 
+            // Pass a resize event to my children
+            onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+                    getWidth(), getHeight()));
+
             return;
         }
 
@@ -967,10 +1019,10 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      * @param str string to draw
      * @param attr attributes to use (bold, foreColor, backColor)
      */
-    public final void putStrXY(final int x, final int y, final String str,
+    public final void putStringXY(final int x, final int y, final String str,
         final CellAttributes attr) {
 
-        getScreen().putStrXY(x, y, str, attr);
+        getScreen().putStringXY(x, y, str, attr);
     }
 
     /**
@@ -981,8 +1033,8 @@ public class TWindow extends TWidget implements Comparable<TWindow> {
      * @param y row coordinate.  0 is the top-most row.
      * @param str string to draw
      */
-    public final void putStrXY(final int x, final int y, final String str) {
-        getScreen().putStrXY(x, y, str);
+    public final void putStringXY(final int x, final int y, final String str) {
+        getScreen().putStringXY(x, y, str);
     }
 
     /**