diff options
Diffstat (limited to 'textscreen')
-rw-r--r-- | textscreen/txt_label.c | 32 | ||||
-rw-r--r-- | 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; 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 */ |