summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-05-22 19:23:28 +0000
committerSimon Howard2006-05-22 19:23:28 +0000
commit2ad24f982e76e487e7c7f6543c2236723903a22d (patch)
tree9ecdaa43f057f78548b70a4c60f4da0f436a1d36
parenta94100706700ff6b29f6ff3d8a6be7daf46f4dfc (diff)
downloadchocolate-doom-2ad24f982e76e487e7c7f6543c2236723903a22d.tar.gz
chocolate-doom-2ad24f982e76e487e7c7f6543c2236723903a22d.tar.bz2
chocolate-doom-2ad24f982e76e487e7c7f6543c2236723903a22d.zip
Add TXT_SetLabel() function to set the label value.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 511
-rw-r--r--textscreen/txt_label.c18
-rw-r--r--textscreen/txt_label.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c
index 356623d9..32610f9e 100644
--- a/textscreen/txt_label.c
+++ b/textscreen/txt_label.c
@@ -48,16 +48,25 @@ txt_widget_class_t txt_label_class =
TXT_LabelDestructor,
};
-static void TXT_SplitLabel(txt_label_t *label)
+void TXT_SetLabel(txt_label_t *label, char *value)
{
char *p;
int y;
+ // Free back the old label
+
+ free(label->label);
+ free(label->lines);
+
+ // Set the new value
+
+ label->label = strdup(value);
+
// Work out how many lines in this label
label->h = 1;
- for (p = label->label; *p != '\0'; ++p)
+ for (p = value; *p != '\0'; ++p)
{
if (*p == '\n')
{
@@ -98,9 +107,10 @@ txt_label_t *TXT_NewLabel(char *text)
TXT_InitWidget(label, &txt_label_class);
label->widget.selectable = 0;
- label->label = strdup(text);
+ label->label = NULL;
+ label->lines = NULL;
- TXT_SplitLabel(label);
+ TXT_SetLabel(label, text);
return label;
}
diff --git a/textscreen/txt_label.h b/textscreen/txt_label.h
index 80be506a..26471634 100644
--- a/textscreen/txt_label.h
+++ b/textscreen/txt_label.h
@@ -38,6 +38,7 @@ struct txt_label_s
};
txt_label_t *TXT_NewLabel(char *label);
+void TXT_SetLabel(txt_label_t *label, char *value);
#endif /* #ifndef TXT_LABEL_H */