Merge branch 'subtree'
[fanfix.git] / src / jexer / TCalendar.java
index b5ecf4df4a3e4e381b7183a50ee0a444c03f6c99..c2005ccb60634279c8a3e5eb064cb59dc083ea04 100644 (file)
@@ -33,6 +33,7 @@ import java.util.GregorianCalendar;
 
 import jexer.bits.CellAttributes;
 import jexer.bits.GraphicsChars;
+import jexer.bits.StringUtils;
 import jexer.event.TKeypressEvent;
 import jexer.event.TMouseEvent;
 import static jexer.TKeypress.*;
@@ -160,7 +161,7 @@ public class TCalendar extends TWidget {
     @Override
     public void onMouseDoubleClick(final TMouseEvent mouse) {
         if (updateAction != null) {
-            updateAction.DO();
+            updateAction.DO(this);
         }
     }
 
@@ -183,7 +184,7 @@ public class TCalendar extends TWidget {
             increment = 1;
         } else if (keypress.equals(kbEnter)) {
             if (updateAction != null) {
-                updateAction.DO();
+                updateAction.DO(this);
             }
             return;
         } else {
@@ -238,10 +239,13 @@ public class TCalendar extends TWidget {
         // Draw the title
         String title = String.format("%tB %tY", displayCalendar,
             displayCalendar);
-        int titleLeft = (getWidth() - title.length() - 2) / 2;
+        // This particular title is always single-width (see format string
+        // above), but for completeness let's treat it the same as every
+        // other window title string.
+        int titleLeft = (getWidth() - StringUtils.width(title) - 2) / 2;
         putCharXY(titleLeft, 0, ' ', titleColor);
         putStringXY(titleLeft + 1, 0, title, titleColor);
-        putCharXY(titleLeft + title.length() + 1, 0, ' ',
+        putCharXY(titleLeft + StringUtils.width(title) + 1, 0, ' ',
             titleColor);
 
         // Arrows