summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-05-18 18:55:24 +0000
committerSimon Howard2006-05-18 18:55:24 +0000
commitf6e8d4c46e9ffebe43a3ea84df3e544417266091 (patch)
treedc8a231a3ff7dc619e1b198dc66a2699d9d6a5b8
parent978ddf539803405ab8fed17e21014ee1ae69fac8 (diff)
downloadchocolate-doom-f6e8d4c46e9ffebe43a3ea84df3e544417266091.tar.gz
chocolate-doom-f6e8d4c46e9ffebe43a3ea84df3e544417266091.tar.bz2
chocolate-doom-f6e8d4c46e9ffebe43a3ea84df3e544417266091.zip
Make TXT_AddWidget take a NULL pointer so different widget types can
be passed to it. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 481
-rw-r--r--textscreen/guitest.c28
-rw-r--r--textscreen/txt_window.c6
-rw-r--r--textscreen/txt_window.h2
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 <stdlib.h>
-
+#include <string.h>
#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);