Make TXT_AddWidget take a NULL pointer so different widget types can
be passed to it. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 481
This commit is contained in:
parent
978ddf5398
commit
f6e8d4c46e
3 changed files with 12 additions and 24 deletions
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue