From 9379132a8234eeedf62d37ef57713e52c12db6ab Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:22 +0200 Subject: Imported Upstream version 0.7 --- CheckItem.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'CheckItem.c') diff --git a/CheckItem.c b/CheckItem.c index 8326123..45c0b22 100644 --- a/CheckItem.c +++ b/CheckItem.c @@ -16,7 +16,8 @@ in the source distribution for its full text. typedef struct CheckItem_ { Object super; char* text; - bool* value; + bool value; + bool* ref; } CheckItem; }*/ @@ -27,13 +28,14 @@ char* CHECKITEM_CLASS = "CheckItem"; #define CHECKITEM_CLASS NULL #endif -CheckItem* CheckItem_new(char* text, bool* value) { +CheckItem* CheckItem_new(char* text, bool* ref, bool value) { CheckItem* this = malloc(sizeof(CheckItem)); Object_setClass(this, CHECKITEM_CLASS); ((Object*)this)->display = CheckItem_display; ((Object*)this)->delete = CheckItem_delete; this->text = text; this->value = value; + this->ref = ref; return this; } @@ -45,11 +47,25 @@ void CheckItem_delete(Object* cast) { free(this); } +void CheckItem_set(CheckItem* this, bool value) { + if (this->ref) + *(this->ref) = value; + else + this->value = value; +} + +bool CheckItem_get(CheckItem* this) { + if (this->ref) + return *(this->ref); + else + return this->value; +} + void CheckItem_display(Object* cast, RichString* out) { CheckItem* this = (CheckItem*)cast; assert (this != NULL); RichString_write(out, CRT_colors[CHECK_BOX], "["); - if (*(this->value)) + if (CheckItem_get(this)) RichString_append(out, CRT_colors[CHECK_MARK], "x"); else RichString_append(out, CRT_colors[CHECK_MARK], " "); -- cgit v1.2.3