shithub: choc

Download patch

ref: 6b9f3748cf561254f085fa83ada80cb5ba9b3946
parent: 1d41349f0326187866c8212fed490f95b9692e47
author: Simon Howard <fraggle@gmail.com>
date: Thu Jun 29 14:07:32 EDT 2006

Add inverted checkboxes (tick in box when value is false)

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 565

--- a/textscreen/txt_checkbox.c
+++ b/textscreen/txt_checkbox.c
@@ -33,7 +33,7 @@
 
     TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
 
-    if (*checkbox->variable)
+    if ((*checkbox->variable != 0) ^ checkbox->inverted)
     {
         TXT_DrawString("\x07");
     }
@@ -112,7 +112,18 @@
     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;
 }
 
--- a/textscreen/txt_checkbox.h
+++ b/textscreen/txt_checkbox.h
@@ -34,9 +34,11 @@
     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 */