From f6e8d4c46e9ffebe43a3ea84df3e544417266091 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 18 May 2006 18:55:24 +0000 Subject: Make TXT_AddWidget take a NULL pointer so different widget types can be passed to it. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 481 --- textscreen/guitest.c | 28 ++++++---------------------- textscreen/txt_window.c | 6 +++++- textscreen/txt_window.h | 2 +- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/textscreen/guitest.c b/textscreen/guitest.c index afa0a45a..b4cd8df5 100644 --- a/textscreen/guitest.c +++ b/textscreen/guitest.c @@ -1,5 +1,5 @@ #include - +#include #include "txt_main.h" @@ -19,34 +19,21 @@ void SetupWindow(void) strcpy(buf, "This is a button label: "); - { - txt_separator_t *sep; - sep = TXT_NewSeparator("Main Section"); - TXT_AddWidget(window, &sep->widget); - } + TXT_AddWidget(window, TXT_NewSeparator("Main Section")); for (i=0; i<8; ++i) { - txt_button_t *button; - - button = TXT_NewButton(buf); strcat(buf, "a"); - TXT_AddWidget(window, &button->widget); + TXT_AddWidget(window, TXT_NewButton(buf)); if (i == 4) { - txt_separator_t *sep; - - sep = TXT_NewSeparator("Section"); - TXT_AddWidget(window, &sep->widget); + TXT_AddWidget(window, TXT_NewSeparator("Section")); } if (i == 6) { - txt_separator_t *sep; - - sep = TXT_NewSeparator(NULL); - TXT_AddWidget(window, &sep->widget); + TXT_AddWidget(window, TXT_NewSeparator(NULL)); } } @@ -62,10 +49,7 @@ void Window2(void) for (i=0; i<5; ++i) { - txt_button_t *button; - - button = TXT_NewButton("hello there blah blah blah blah"); - TXT_AddWidget(window, &button->widget); + TXT_AddWidget(window, TXT_NewButton("hello there blah blah blah blah")); } } diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index b50da9b4..ce58aaa3 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -166,8 +166,12 @@ void TXT_DrawAllWindows(void) TXT_UpdateScreen(); } -void TXT_AddWidget(txt_window_t *window, txt_widget_t *widget) +void TXT_AddWidget(txt_window_t *window, void *uncast_widget) { + txt_widget_t *widget; + + widget = (txt_widget_t *) uncast_widget; + if (window->num_widgets == 0) { // This is the first widget added. diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h index 51610f47..821ddca9 100644 --- a/textscreen/txt_window.h +++ b/textscreen/txt_window.h @@ -51,7 +51,7 @@ struct txt_window_s txt_window_t *TXT_NewWindow(char *title, int x, int y); void TXT_CloseWindow(txt_window_t *window); -void TXT_AddWidget(txt_window_t *window, txt_widget_t *widget); +void TXT_AddWidget(txt_window_t *window, void *widget); void TXT_DrawAllWindows(void); -- cgit v1.2.3