git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hidden mouse pointer support
[fanfix.git]
/
src
/
jexer
/
TCheckBox.java
diff --git
a/src/jexer/TCheckBox.java
b/src/jexer/TCheckBox.java
index 2b35843d92632d1c8ba3473ddcbbc31aa67ae3dc..84c2e41adf7a13d086e704b6490a13a0eccd5359 100644
(file)
--- a/
src/jexer/TCheckBox.java
+++ b/
src/jexer/TCheckBox.java
@@
-3,7
+3,7
@@
*
* The MIT License (MIT)
*
*
* The MIT License (MIT)
*
- * Copyright (C) 201
7
Kevin Lamonte
+ * Copyright (C) 201
9
Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@
-44,7
+44,7
@@
public class TCheckBox extends TWidget {
// ------------------------------------------------------------------------
/**
// ------------------------------------------------------------------------
/**
- * Check
b
ox state, true means checked.
+ * Check
B
ox state, true means checked.
*/
private boolean checked = false;
*/
private boolean checked = false;
@@
-53,6
+53,11
@@
public class TCheckBox extends TWidget {
*/
private String label;
*/
private String label;
+ /**
+ * If true, use the window's background color.
+ */
+ private boolean useWindowBackground = false;
+
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
@@
-89,7
+94,7
@@
public class TCheckBox extends TWidget {
* @param mouse mouse event
* @return true if the mouse is currently on the checkbox
*/
* @param mouse mouse event
* @return true if the mouse is currently on the checkbox
*/
- private boolean mouseOnCheck
b
ox(final TMouseEvent mouse) {
+ private boolean mouseOnCheck
B
ox(final TMouseEvent mouse) {
if ((mouse.getY() == 0)
&& (mouse.getX() >= 0)
&& (mouse.getX() <= 2)
if ((mouse.getY() == 0)
&& (mouse.getX() >= 0)
&& (mouse.getX() <= 2)
@@
-106,7
+111,7
@@
public class TCheckBox extends TWidget {
*/
@Override
public void onMouseDown(final TMouseEvent mouse) {
*/
@Override
public void onMouseDown(final TMouseEvent mouse) {
- if ((mouseOnCheck
b
ox(mouse)) && (mouse.isMouse1())) {
+ if ((mouseOnCheck
B
ox(mouse)) && (mouse.isMouse1())) {
// Switch state
checked = !checked;
}
// Switch state
checked = !checked;
}
@@
-144,15
+149,19
@@
public class TCheckBox extends TWidget {
} else {
checkboxColor = getTheme().getColor("tcheckbox.inactive");
}
} else {
checkboxColor = getTheme().getColor("tcheckbox.inactive");
}
+ if (useWindowBackground) {
+ CellAttributes background = getWindow().getBackground();
+ checkboxColor.setBackColor(background.getBackColor());
+ }
-
getScreen().
putCharXY(0, 0, '[', checkboxColor);
+ putCharXY(0, 0, '[', checkboxColor);
if (checked) {
if (checked) {
-
getScreen().
putCharXY(1, 0, GraphicsChars.CHECK, checkboxColor);
+ putCharXY(1, 0, GraphicsChars.CHECK, checkboxColor);
} else {
} else {
-
getScreen().
putCharXY(1, 0, ' ', checkboxColor);
+ putCharXY(1, 0, ' ', checkboxColor);
}
}
-
getScreen().
putCharXY(2, 0, ']', checkboxColor);
-
getScreen().
putStringXY(4, 0, label, checkboxColor);
+ putCharXY(2, 0, ']', checkboxColor);
+ putStringXY(4, 0, label, checkboxColor);
}
// ------------------------------------------------------------------------
}
// ------------------------------------------------------------------------