From 76e770217095fa7b42e62ddbd4e09e369d43bec1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 25 May 2006 21:26:13 +0000 Subject: Allow the fg/bg colors to be set on labels. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 529 --- textscreen/txt_label.c | 32 ++++++++++++++++++++++++++------ textscreen/txt_label.h | 5 +++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c index a6ac8293..7a8658f9 100644 --- a/textscreen/txt_label.c +++ b/textscreen/txt_label.c @@ -18,18 +18,23 @@ static void TXT_LabelSizeCalc(TXT_UNCAST_ARG(label), int *w, int *h) static void TXT_LabelDrawer(TXT_UNCAST_ARG(label), int w, int selected) { TXT_CAST_ARG(txt_label_t, label); - int i; + int x, y; int origin_x, origin_y; - TXT_BGColor(TXT_COLOR_BLUE, 0); - TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); + TXT_BGColor(label->bgcolor, 0); + TXT_FGColor(label->fgcolor); TXT_GetXY(&origin_x, &origin_y); - for (i=0; ih; ++i) + for (y=0; yh; ++y) { - TXT_GotoXY(origin_x, origin_y + i); - TXT_DrawString(label->lines[i]); + TXT_GotoXY(origin_x, origin_y + y); + TXT_DrawString(label->lines[y]); + + for (x=strlen(label->lines[y]); xlabel = NULL; label->lines = NULL; + // Default colors + + label->bgcolor = TXT_COLOR_BLUE; + label->fgcolor = TXT_COLOR_BRIGHT_WHITE; + TXT_SetLabel(label, text); return label; } +void TXT_SetFGColor(txt_label_t *label, txt_color_t color) +{ + label->fgcolor = color; +} + +void TXT_SetBGColor(txt_label_t *label, txt_color_t color) +{ + label->bgcolor = color; +} + diff --git a/textscreen/txt_label.h b/textscreen/txt_label.h index 26471634..5c421ffc 100644 --- a/textscreen/txt_label.h +++ b/textscreen/txt_label.h @@ -27,6 +27,7 @@ typedef struct txt_label_s txt_label_t; +#include "txt_main.h" #include "txt_widget.h" struct txt_label_s @@ -35,10 +36,14 @@ struct txt_label_s char *label; char **lines; int w, h; + txt_color_t fgcolor; + txt_color_t bgcolor; }; txt_label_t *TXT_NewLabel(char *label); void TXT_SetLabel(txt_label_t *label, char *value); +void TXT_SetBGColor(txt_label_t *label, txt_color_t color); +void TXT_SetFGColor(txt_label_t *label, txt_color_t color); #endif /* #ifndef TXT_LABEL_H */ -- cgit v1.2.3