summaryrefslogtreecommitdiff
path: root/textscreen/txt_label.c
diff options
context:
space:
mode:
authorSimon Howard2012-10-28 23:45:08 +0000
committerSimon Howard2012-10-28 23:45:08 +0000
commit993315afc4b1fddaf8952e7e55d1373b5052dd7c (patch)
tree94aa07d101ddced8404ceaa92ce051ed17fe2a88 /textscreen/txt_label.c
parenta1b2ce54d02823aa85c7df6aa016c567185451ae (diff)
parentad11652dcd8e0923432ad272e6535276c51d39eb (diff)
downloadchocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.gz
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.bz2
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.zip
Merge from trunk.
Subversion-branch: /branches/v2-branch Subversion-revision: 2537
Diffstat (limited to 'textscreen/txt_label.c')
-rw-r--r--textscreen/txt_label.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c
index a2afc13b..39ea0e16 100644
--- a/textscreen/txt_label.c
+++ b/textscreen/txt_label.c
@@ -26,6 +26,7 @@
#include "txt_gui.h"
#include "txt_io.h"
#include "txt_main.h"
+#include "txt_utf8.h"
#include "txt_window.h"
static void TXT_LabelSizeCalc(TXT_UNCAST_ARG(label))
@@ -46,8 +47,14 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
w = label->widget.w;
- TXT_BGColor(label->bgcolor, 0);
- TXT_FGColor(label->fgcolor);
+ if (label->bgcolor >= 0)
+ {
+ TXT_BGColor(label->bgcolor, 0);
+ }
+ if (label->fgcolor >= 0)
+ {
+ TXT_FGColor(label->fgcolor);
+ }
TXT_GetXY(&origin_x, &origin_y);
@@ -68,7 +75,7 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
align_indent = label->w - strlen(label->lines[y]);
break;
}
-
+
// Draw this line
TXT_GotoXY(origin_x, origin_y + y);
@@ -82,8 +89,8 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
// The string itself
- TXT_DrawString(label->lines[y]);
- x += strlen(label->lines[y]);
+ TXT_DrawUTF8String(label->lines[y]);
+ x += TXT_UTF8_Strlen(label->lines[y]);
// Gap at the end
@@ -123,7 +130,7 @@ void TXT_SetLabel(txt_label_t *label, char *value)
free(label->label);
free(label->lines);
- // Set the new value
+ // Set the new value
label->label = strdup(value);
@@ -144,7 +151,7 @@ void TXT_SetLabel(txt_label_t *label, char *value)
label->lines = malloc(sizeof(char *) * label->h);
label->lines[0] = label->label;
y = 1;
-
+
for (p = label->label; *p != '\0'; ++p)
{
if (*p == '\n')
@@ -159,8 +166,12 @@ void TXT_SetLabel(txt_label_t *label, char *value)
for (y=0; y<label->h; ++y)
{
- if (strlen(label->lines[y]) > label->w)
- label->w = strlen(label->lines[y]);
+ unsigned int line_len;
+
+ line_len = TXT_UTF8_Strlen(label->lines[y]);
+
+ if (line_len > label->w)
+ label->w = line_len;
}
}
@@ -176,8 +187,8 @@ txt_label_t *TXT_NewLabel(char *text)
// Default colors
- label->bgcolor = TXT_WINDOW_BACKGROUND;
- label->fgcolor = TXT_COLOR_BRIGHT_WHITE;
+ label->bgcolor = -1;
+ label->fgcolor = -1;
TXT_SetLabel(label, text);