summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-05-25 21:26:13 +0000
committerSimon Howard2006-05-25 21:26:13 +0000
commit76e770217095fa7b42e62ddbd4e09e369d43bec1 (patch)
treef918638a2bd79fcd148f300fb6fee55632d1991b
parent2808929cf61f5c2043e3c5cca356d7d26ceeeb28 (diff)
downloadchocolate-doom-76e770217095fa7b42e62ddbd4e09e369d43bec1.tar.gz
chocolate-doom-76e770217095fa7b42e62ddbd4e09e369d43bec1.tar.bz2
chocolate-doom-76e770217095fa7b42e62ddbd4e09e369d43bec1.zip
Allow the fg/bg colors to be set on labels.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 529
-rw-r--r--textscreen/txt_label.c32
-rw-r--r--textscreen/txt_label.h5
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; 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 @@ txt_label_t *TXT_NewLabel(char *text)
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;
+}
+
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 */