From 85b5a7487d5b44b94e6d2fc74c997ec69e352b1a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 3 Feb 2012 21:10:36 +0000 Subject: Upgrade the input box and label widgets to use UTF-8 strings. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2491 --- textscreen/txt_label.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'textscreen/txt_label.c') diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c index a2afc13b..c4238bf3 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)) @@ -68,7 +69,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 +83,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 +124,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 +145,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 +160,12 @@ void TXT_SetLabel(txt_label_t *label, char *value) for (y=0; yh; ++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; } } -- cgit v1.2.3 From 9ffd1cc4d4bbd2b2799cbd0bf927fc4f30aed63e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 1 Mar 2012 20:26:56 +0000 Subject: Rework the way that window background colors are set, and change the background color of inactive windows to black, to give better contrast when viewing many layered windows. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2507 --- textscreen/txt_label.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'textscreen/txt_label.c') diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c index c4238bf3..39ea0e16 100644 --- a/textscreen/txt_label.c +++ b/textscreen/txt_label.c @@ -47,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); @@ -181,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); -- cgit v1.2.3