import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
+import jexer.bits.StringUtils;
import jexer.event.TCommandEvent;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
* @return the number of columns this takes when drawn
*/
public int width() {
- return this.label.length() + this.key.toString().length() + 3;
+ return StringUtils.width(this.label) +
+ StringUtils.width(this.key.toString()) + 3;
}
/**
/**
* Public constructor.
*
- * @param parent parent widget
+ * @param window the window associated with this status bar
* @param text text for the bar on the bottom row
*/
- public TStatusBar(final TWidget parent, final String text) {
+ public TStatusBar(final TWindow window, final String text) {
- // Set parent and window
- super(parent, false, 0, 0, text.length(), 1);
+ // TStatusBar is a parentless widget, because TApplication handles
+ // its drawing and event routing directly.
+ super(null, false, 0, 0, StringUtils.width(text), 1);
this.text = text;
+ setWindow(window);
}
/**
* Public constructor.
*
- * @param parent parent widget
+ * @param window the window associated with this status bar
*/
- public TStatusBar(final TWidget parent) {
- this(parent, "");
+ public TStatusBar(final TWindow window) {
+ this(window, "");
}
// ------------------------------------------------------------------------
if (key.selected) {
putCharXY(col++, row, ' ', selectedColor);
putStringXY(col, row, keyStr, selectedColor);
- col += keyStr.length();
+ col += StringUtils.width(keyStr);
putCharXY(col++, row, ' ', selectedColor);
putStringXY(col, row, key.label, selectedColor);
- col += key.label.length();
+ col += StringUtils.width(key.label);
putCharXY(col++, row, ' ', selectedColor);
} else {
putCharXY(col++, row, ' ', barColor);
putStringXY(col, row, keyStr, keyColor);
- col += keyStr.length() + 1;
+ col += StringUtils.width(keyStr) + 1;
putStringXY(col, row, key.label, barColor);
- col += key.label.length();
+ col += StringUtils.width(key.label);
putCharXY(col++, row, ' ', barColor);
}
}