ref: 76e770217095fa7b42e62ddbd4e09e369d43bec1
parent: 2808929cf61f5c2043e3c5cca356d7d26ceeeb28
author: Simon Howard <[email protected]>
date: Thu May 25 17:26:13 EDT 2006
Allow the fg/bg colors to be set on labels. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 529
--- a/textscreen/txt_label.c
+++ b/textscreen/txt_label.c
@@ -18,18 +18,23 @@
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; i<label->h; ++i)
+ for (y=0; y<label->h; ++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]); x<w; ++x)
+ {
+ TXT_DrawString(" ");
+ }
}
}
@@ -111,8 +116,23 @@
label->label = 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;
}
--- 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 @@
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 */