diff options
Diffstat (limited to 'textscreen')
-rw-r--r-- | textscreen/txt_button.c | 9 | ||||
-rw-r--r-- | textscreen/txt_gui.c | 63 | ||||
-rw-r--r-- | textscreen/txt_gui.h | 3 | ||||
-rw-r--r-- | textscreen/txt_separator.c | 11 |
4 files changed, 60 insertions, 26 deletions
diff --git a/textscreen/txt_button.c b/textscreen/txt_button.c index ba6f387a..4bf5b9c0 100644 --- a/textscreen/txt_button.c +++ b/textscreen/txt_button.c @@ -23,21 +23,18 @@ static void TXT_ButtonDrawer(txt_widget_t *widget, int w, int selected) TXT_BGColor(TXT_COLOR_BLUE, 0); TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); - TXT_PutChar(' '); + TXT_DrawString(" "); if (selected) { TXT_BGColor(TXT_COLOR_GREY, 0); } - for (i=0; i<strlen(button->label); ++i) - { - TXT_PutChar(button->label[i]); - } + TXT_DrawString(button->label); for (i=strlen(button->label); i < w-2; ++i) { - TXT_PutChar(' '); + TXT_DrawString(" "); } } diff --git a/textscreen/txt_gui.c b/textscreen/txt_gui.c index d4e9650c..2c58cb9f 100644 --- a/textscreen/txt_gui.c +++ b/textscreen/txt_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: txt_gui.c 486 2006-05-20 15:15:17Z fraggle $ +// $Id: txt_gui.c 487 2006-05-20 15:45:36Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -30,6 +30,7 @@ #include <string.h> +#include "txt_gui.h" #include "txt_io.h" #include "txt_main.h" @@ -48,6 +49,9 @@ static int borders[4][4] = {0xc0, 0xc4, 0xc1, 0xd9}, }; +#define VALID_X(y) ((y) >= 0 && (y) < TXT_SCREEN_W) +#define VALID_Y(y) ((y) >= 1 && (y) < TXT_SCREEN_H - 1) + void TXT_DrawDesktopBackground(char *title) { int i; @@ -90,8 +94,8 @@ void TXT_DrawDesktopBackground(char *title) TXT_FGColor(TXT_COLOR_BLACK); TXT_BGColor(TXT_COLOR_GREY, 0); - TXT_PutChar(' '); - TXT_Puts(title); + TXT_DrawString(" "); + TXT_DrawString(title); } void TXT_DrawShadow(int x, int y, int w, int h) @@ -108,8 +112,7 @@ void TXT_DrawShadow(int x, int y, int w, int h) for (x1=x; x1<x+w; ++x1) { - if (x1 >= 0 && x1 < TXT_SCREEN_W - && y1 >= 0 && y1 < TXT_SCREEN_H) + if (VALID_X(x1) && VALID_Y(y1)) { p[1] = TXT_COLOR_DARK_GREY; } @@ -129,8 +132,6 @@ void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h) for (y1=y; y1<y+h; ++y1) { - TXT_GotoXY(x, y1); - // Select the appropriate row and column in the borders // array to pick the appropriate character to draw at // this location. @@ -147,7 +148,11 @@ void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h) bx = x1 == x ? 0 : x1 == x + w - 1 ? 3 : 1; - TXT_PutChar(borders[by][bx]); + if (VALID_X(x1) && VALID_Y(y1)) + { + TXT_GotoXY(x1, y1); + TXT_PutChar(borders[by][bx]); + } } } @@ -159,11 +164,11 @@ void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h) for (x1=0; x1<w-2; ++x1) { - TXT_PutChar(' '); + TXT_DrawString(" "); } TXT_GotoXY(x + (w - strlen(title)) / 2, y + 1); - TXT_Puts(title); + TXT_DrawString(title); // Draw the window's shadow. @@ -179,6 +184,11 @@ void TXT_DrawSeparator(int x, int y, int w) TXT_FGColor(TXT_COLOR_BRIGHT_CYAN); TXT_BGColor(TXT_COLOR_BLUE, 0); + if (!VALID_Y(y)) + { + return; + } + for (x1=x; x1<x+w; ++x1) { TXT_GotoXY(x1, y); @@ -187,7 +197,38 @@ void TXT_DrawSeparator(int x, int y, int w) x1 == x + w - 1 ? borders[2][3] : borders[2][1]; - TXT_PutChar(c); + if (VALID_X(x1)) + { + TXT_PutChar(c); + } + } +} + +void TXT_DrawString(char *s) +{ + int x, y; + int x1; + char *p; + + TXT_GetXY(&x, &y); + + if (VALID_Y(y)) + { + p = s; + x1 = x; + + for (p = s; *p != '\0'; ++p) + { + if (VALID_X(x1)) + { + TXT_GotoXY(x1, y); + TXT_PutChar(*p); + } + + x1 += 1; + } } + + TXT_GotoXY(x + strlen(s), y); } diff --git a/textscreen/txt_gui.h b/textscreen/txt_gui.h index d9c3c8e6..03c1dc3d 100644 --- a/textscreen/txt_gui.h +++ b/textscreen/txt_gui.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: txt_gui.h 483 2006-05-19 19:57:59Z fraggle $ +// $Id: txt_gui.h 487 2006-05-20 15:45:36Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -45,6 +45,7 @@ void TXT_DrawDesktopBackground(char *title); void TXT_DrawWindowFrame(char *title, int x, int y, int w, int h); void TXT_DrawSeparator(int x, int y, int w); +void TXT_DrawString(char *s); #endif /* #ifndef TXT_GUI_H */ diff --git a/textscreen/txt_separator.c b/textscreen/txt_separator.c index f378a126..b430f831 100644 --- a/textscreen/txt_separator.c +++ b/textscreen/txt_separator.c @@ -42,14 +42,9 @@ static void TXT_SeparatorDrawer(txt_widget_t *widget, int w, int selected) TXT_BGColor(TXT_COLOR_BLUE, 0); TXT_FGColor(TXT_COLOR_BRIGHT_GREEN); - TXT_PutChar(' '); - - for (i=0; i<strlen(separator->label); ++i) - { - TXT_PutChar(separator->label[i]); - } - - TXT_PutChar(' '); + TXT_DrawString(" "); + TXT_DrawString(separator->label); + TXT_DrawString(" "); } } |