X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTField.java;h=e8fd3defc8baeb8229f99f831760f9866d618730;hb=1dac6b8d395e2bf3c1b58915f8f4f481d9e46793;hp=b4330b4cb3c809210c4abf07b6592b0ac69bbd20;hpb=2a92cf977ee2ae37d8302a294c6338fa51a5ca45;p=fanfix.git diff --git a/src/jexer/TField.java b/src/jexer/TField.java index b4330b4..e8fd3de 100644 --- a/src/jexer/TField.java +++ b/src/jexer/TField.java @@ -43,6 +43,11 @@ public class TField extends TWidget { // Variables -------------------------------------------------------------- // ------------------------------------------------------------------------ + /** + * Background character for unfilled-in text. + */ + protected char backgroundChar = GraphicsChars.HATCH; + /** * Field text. */ @@ -84,6 +89,16 @@ public class TField extends TWidget { */ protected TAction updateAction; + /** + * The color to use when this field is active. + */ + private String activeColorKey = "tfield.active"; + + /** + * The color to use when this field is not active. + */ + private String inactiveColorKey = "tfield.inactive"; + // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ @@ -349,16 +364,16 @@ public class TField extends TWidget { CellAttributes fieldColor; if (isAbsoluteActive()) { - fieldColor = getTheme().getColor("tfield.active"); + fieldColor = getTheme().getColor(activeColorKey); } else { - fieldColor = getTheme().getColor("tfield.inactive"); + fieldColor = getTheme().getColor(inactiveColorKey); } int end = windowStart + getWidth(); if (end > text.length()) { end = text.length(); } - hLineXY(0, 0, getWidth(), GraphicsChars.HATCH, fieldColor); + hLineXY(0, 0, getWidth(), backgroundChar, fieldColor); putStringXY(0, 0, text.substring(windowStart, end), fieldColor); // Fix the cursor, it will be rendered by TApplication.drawAll(). @@ -369,6 +384,24 @@ public class TField extends TWidget { // TField ----------------------------------------------------------------- // ------------------------------------------------------------------------ + /** + * Get field background character. + * + * @return background character + */ + public final char getBackgroundChar() { + return backgroundChar; + } + + /** + * Set field background character. + * + * @param backgroundChar the background character + */ + public void setBackgroundChar(final char backgroundChar) { + this.backgroundChar = backgroundChar; + } + /** * Get field text. * @@ -520,4 +553,25 @@ public class TField extends TWidget { normalizeWindowStart(); } + /** + * Set the active color key. + * + * @param activeColorKey ColorTheme key color to use when this field is + * active + */ + public void setActiveColorKey(final String activeColorKey) { + this.activeColorKey = activeColorKey; + } + + /** + * Set the inactive color key. + * + * @param inactiveColorKey ColorTheme key color to use when this field is + * inactive + */ + public void setInactiveColorKey(final String inactiveColorKey) { + this.inactiveColorKey = inactiveColorKey; + } + + }