summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--textscreen/txt_checkbox.c13
-rw-r--r--textscreen/txt_checkbox.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/textscreen/txt_checkbox.c b/textscreen/txt_checkbox.c
index cde095a8..56746f5f 100644
--- a/textscreen/txt_checkbox.c
+++ b/textscreen/txt_checkbox.c
@@ -33,7 +33,7 @@ static void TXT_CheckBoxDrawer(TXT_UNCAST_ARG(checkbox), int selected)
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
- if (*checkbox->variable)
+ if ((*checkbox->variable != 0) ^ checkbox->inverted)
{
TXT_DrawString("\x07");
}
@@ -112,7 +112,18 @@ txt_checkbox_t *TXT_NewCheckBox(char *label, int *variable)
TXT_InitWidget(checkbox, &txt_checkbox_class);
checkbox->label = strdup(label);
checkbox->variable = variable;
+ checkbox->inverted = 0;
return checkbox;
}
+txt_checkbox_t *TXT_NewInvertedCheckBox(char *label, int *variable)
+{
+ txt_checkbox_t *result;
+
+ result = TXT_NewCheckBox(label, variable);
+ result->inverted = 1;
+
+ return result;
+}
+
diff --git a/textscreen/txt_checkbox.h b/textscreen/txt_checkbox.h
index 3de21b30..44fb39c0 100644
--- a/textscreen/txt_checkbox.h
+++ b/textscreen/txt_checkbox.h
@@ -34,9 +34,11 @@ struct txt_checkbox_s
txt_widget_t widget;
char *label;
int *variable;
+ int inverted;
};
txt_checkbox_t *TXT_NewCheckBox(char *label, int *variable);
+txt_checkbox_t *TXT_NewInvertedCheckBox(char *label, int *variable);
#endif /* #ifndef TXT_CHECKBOX_H */