CAST -> TXT_CAST_ARG, UNCAST -> TXT_UNCAST_ARG.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 509
This commit is contained in:
Simon Howard 2006-05-22 11:59:11 +00:00
parent 11643c0887
commit 7c18ad6ccf
10 changed files with 77 additions and 77 deletions

View file

@ -23,7 +23,7 @@ int radiobutton_value;
txt_window_t *firstwin;
int checkbox_value;
void CloseWindow(UNCAST(button), void *user_data)
void CloseWindow(TXT_UNCAST_ARG(button), void *user_data)
{
TXT_CloseWindow(firstwin);
}

View file

@ -8,9 +8,9 @@
#include "txt_main.h"
#include "txt_window.h"
static void TXT_ButtonSizeCalc(UNCAST(button), int *w, int *h)
static void TXT_ButtonSizeCalc(TXT_UNCAST_ARG(button), int *w, int *h)
{
CAST(txt_button_t, button);
TXT_CAST_ARG(txt_button_t, button);
// Minimum width is the string length + two spaces for padding
@ -18,9 +18,9 @@ static void TXT_ButtonSizeCalc(UNCAST(button), int *w, int *h)
*h = 1;
}
static void TXT_ButtonDrawer(UNCAST(button), int w, int selected)
static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button), int w, int selected)
{
CAST(txt_button_t, button);
TXT_CAST_ARG(txt_button_t, button);
int i;
TXT_BGColor(TXT_COLOR_BLUE, 0);
@ -40,16 +40,16 @@ static void TXT_ButtonDrawer(UNCAST(button), int w, int selected)
}
}
static void TXT_ButtonDestructor(UNCAST(button))
static void TXT_ButtonDestructor(TXT_UNCAST_ARG(button))
{
CAST(txt_button_t, button);
TXT_CAST_ARG(txt_button_t, button);
free(button->label);
}
static int TXT_ButtonKeyPress(UNCAST(button), int key)
static int TXT_ButtonKeyPress(TXT_UNCAST_ARG(button), int key)
{
CAST(txt_button_t, button);
TXT_CAST_ARG(txt_button_t, button);
if (key == KEY_ENTER)
{

View file

@ -8,9 +8,9 @@
#include "txt_main.h"
#include "txt_window.h"
static void TXT_CheckBoxSizeCalc(UNCAST(checkbox), int *w, int *h)
static void TXT_CheckBoxSizeCalc(TXT_UNCAST_ARG(checkbox), int *w, int *h)
{
CAST(txt_checkbox_t, checkbox);
TXT_CAST_ARG(txt_checkbox_t, checkbox);
// Minimum width is the string length + two spaces for padding
@ -18,9 +18,9 @@ static void TXT_CheckBoxSizeCalc(UNCAST(checkbox), int *w, int *h)
*h = 1;
}
static void TXT_CheckBoxDrawer(UNCAST(checkbox), int w, int selected)
static void TXT_CheckBoxDrawer(TXT_UNCAST_ARG(checkbox), int w, int selected)
{
CAST(txt_checkbox_t, checkbox);
TXT_CAST_ARG(txt_checkbox_t, checkbox);
int i;
TXT_BGColor(TXT_COLOR_BLUE, 0);
@ -57,16 +57,16 @@ static void TXT_CheckBoxDrawer(UNCAST(checkbox), int w, int selected)
}
}
static void TXT_CheckBoxDestructor(UNCAST(checkbox))
static void TXT_CheckBoxDestructor(TXT_UNCAST_ARG(checkbox))
{
CAST(txt_checkbox_t, checkbox);
TXT_CAST_ARG(txt_checkbox_t, checkbox);
free(checkbox->label);
}
static int TXT_CheckBoxKeyPress(UNCAST(checkbox), int key)
static int TXT_CheckBoxKeyPress(TXT_UNCAST_ARG(checkbox), int key)
{
CAST(txt_checkbox_t, checkbox);
TXT_CAST_ARG(txt_checkbox_t, checkbox);
if (key == KEY_ENTER || key == ' ')
{

View file

@ -6,17 +6,17 @@
#include "txt_main.h"
#include "txt_window.h"
static void TXT_LabelSizeCalc(UNCAST(label), int *w, int *h)
static void TXT_LabelSizeCalc(TXT_UNCAST_ARG(label), int *w, int *h)
{
CAST(txt_label_t, label);
TXT_CAST_ARG(txt_label_t, label);
*w = label->w;
*h = label->h;
}
static void TXT_LabelDrawer(UNCAST(label), int w, int selected)
static void TXT_LabelDrawer(TXT_UNCAST_ARG(label), int w, int selected)
{
CAST(txt_label_t, label);
TXT_CAST_ARG(txt_label_t, label);
int i;
int origin_x, origin_y;
@ -32,9 +32,9 @@ static void TXT_LabelDrawer(UNCAST(label), int w, int selected)
}
}
static void TXT_LabelDestructor(UNCAST(label))
static void TXT_LabelDestructor(TXT_UNCAST_ARG(label))
{
CAST(txt_label_t, label);
TXT_CAST_ARG(txt_label_t, label);
free(label->label);
free(label->lines);

View file

@ -8,9 +8,9 @@
#include "txt_main.h"
#include "txt_window.h"
static void TXT_RadioButtonSizeCalc(UNCAST(radiobutton), int *w, int *h)
static void TXT_RadioButtonSizeCalc(TXT_UNCAST_ARG(radiobutton), int *w, int *h)
{
CAST(txt_radiobutton_t, radiobutton);
TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
// Minimum width is the string length + two spaces for padding
@ -18,9 +18,9 @@ static void TXT_RadioButtonSizeCalc(UNCAST(radiobutton), int *w, int *h)
*h = 1;
}
static void TXT_RadioButtonDrawer(UNCAST(radiobutton), int w, int selected)
static void TXT_RadioButtonDrawer(TXT_UNCAST_ARG(radiobutton), int w, int selected)
{
CAST(txt_radiobutton_t, radiobutton);
TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
int i;
TXT_BGColor(TXT_COLOR_BLUE, 0);
@ -57,16 +57,16 @@ static void TXT_RadioButtonDrawer(UNCAST(radiobutton), int w, int selected)
}
}
static void TXT_RadioButtonDestructor(UNCAST(radiobutton))
static void TXT_RadioButtonDestructor(TXT_UNCAST_ARG(radiobutton))
{
CAST(txt_radiobutton_t, radiobutton);
TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
free(radiobutton->label);
}
static int TXT_RadioButtonKeyPress(UNCAST(radiobutton), int key)
static int TXT_RadioButtonKeyPress(TXT_UNCAST_ARG(radiobutton), int key)
{
CAST(txt_radiobutton_t, radiobutton);
TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
if (key == KEY_ENTER || key == ' ')
{

View file

@ -6,9 +6,9 @@
#include "txt_main.h"
#include "txt_window.h"
static void TXT_SeparatorSizeCalc(UNCAST(separator), int *w, int *h)
static void TXT_SeparatorSizeCalc(TXT_UNCAST_ARG(separator), int *w, int *h)
{
CAST(txt_separator_t, separator);
TXT_CAST_ARG(txt_separator_t, separator);
if (separator->label != NULL)
{
@ -24,9 +24,9 @@ static void TXT_SeparatorSizeCalc(UNCAST(separator), int *w, int *h)
*h = 1;
}
static void TXT_SeparatorDrawer(UNCAST(separator), int w, int selected)
static void TXT_SeparatorDrawer(TXT_UNCAST_ARG(separator), int w, int selected)
{
CAST(txt_separator_t, separator);
TXT_CAST_ARG(txt_separator_t, separator);
int i;
int x, y;
@ -49,9 +49,9 @@ static void TXT_SeparatorDrawer(UNCAST(separator), int w, int selected)
}
}
static void TXT_SeparatorDestructor(UNCAST(separator))
static void TXT_SeparatorDestructor(TXT_UNCAST_ARG(separator))
{
CAST(txt_separator_t, separator);
TXT_CAST_ARG(txt_separator_t, separator);
free(separator->label);
}

View file

@ -33,9 +33,9 @@
#include "txt_separator.h"
#include "txt_table.h"
static void TXT_TableDestructor(UNCAST(table))
static void TXT_TableDestructor(TXT_UNCAST_ARG(table))
{
CAST(txt_table_t, table);
TXT_CAST_ARG(txt_table_t, table);
int i;
// Free all widgets
@ -90,9 +90,9 @@ static void CalcRowColSizes(txt_table_t *table,
}
}
static void TXT_CalcTableSize(UNCAST(table), int *w, int *h)
static void TXT_CalcTableSize(TXT_UNCAST_ARG(table), int *w, int *h)
{
CAST(txt_table_t, table);
TXT_CAST_ARG(txt_table_t, table);
int *column_widths;
int *row_heights;
int x, y;
@ -123,10 +123,10 @@ static void TXT_CalcTableSize(UNCAST(table), int *w, int *h)
free(column_widths);
}
void TXT_AddWidget(UNCAST(table), UNCAST(widget))
void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget))
{
CAST(txt_table_t, table);
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_table_t, table);
TXT_CAST_ARG(txt_widget_t, widget);
if (table->num_widgets > 0)
{
@ -207,9 +207,9 @@ static int FindSelectableColumn(txt_table_t *table, int row, int start_col)
return -1;
}
static int TXT_TableKeyPress(UNCAST(table), int key)
static int TXT_TableKeyPress(TXT_UNCAST_ARG(table), int key)
{
CAST(txt_table_t, table);
TXT_CAST_ARG(txt_table_t, table);
int selected;
int rows;
@ -339,9 +339,9 @@ static void CheckValidSelection(txt_table_t *table)
}
}
static void TXT_TableDrawer(UNCAST(table), int w, int selected)
static void TXT_TableDrawer(TXT_UNCAST_ARG(table), int w, int selected)
{
CAST(txt_table_t, table);
TXT_CAST_ARG(txt_table_t, table);
int *column_widths;
int *row_heights;
int origin_x, origin_y;

View file

@ -51,7 +51,7 @@ struct txt_table_s
txt_table_t *TXT_NewTable(int columns);
void TXT_InitTable(txt_table_t *table, int columns);
void TXT_AddWidget(UNCAST(table), UNCAST(widget));
void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget));
#endif /* #ifndef TXT_TABLE_T */

View file

@ -40,9 +40,9 @@ void TXT_DestroyCallbackTable(txt_callback_table_t *table)
free(table);
}
void TXT_InitWidget(UNCAST(widget), txt_widget_class_t *widget_class)
void TXT_InitWidget(TXT_UNCAST_ARG(widget), txt_widget_class_t *widget_class)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
widget->widget_class = widget_class;
widget->callback_table = TXT_NewCallbackTable();
@ -53,12 +53,12 @@ void TXT_InitWidget(UNCAST(widget), txt_widget_class_t *widget_class)
widget->visible = 1;
}
void TXT_SignalConnect(UNCAST(widget),
void TXT_SignalConnect(TXT_UNCAST_ARG(widget),
char *signal_name,
TxtWidgetSignalFunc func,
void *user_data)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
txt_callback_table_t *table;
txt_callback_t *callback;
int i;
@ -90,9 +90,9 @@ void TXT_SignalConnect(UNCAST(widget),
callback->user_data = user_data;
}
void TXT_EmitSignal(UNCAST(widget), char *signal_name)
void TXT_EmitSignal(TXT_UNCAST_ARG(widget), char *signal_name)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
txt_callback_table_t *table;
int i;
@ -108,32 +108,32 @@ void TXT_EmitSignal(UNCAST(widget), char *signal_name)
}
}
void TXT_CalcWidgetSize(UNCAST(widget), int *w, int *h)
void TXT_CalcWidgetSize(TXT_UNCAST_ARG(widget), int *w, int *h)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
return widget->widget_class->size_calc(widget, w, h);
}
void TXT_DrawWidget(UNCAST(widget), int w, int selected)
void TXT_DrawWidget(TXT_UNCAST_ARG(widget), int w, int selected)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
widget->widget_class->drawer(widget, w, selected);
}
void TXT_DestroyWidget(UNCAST(widget))
void TXT_DestroyWidget(TXT_UNCAST_ARG(widget))
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
widget->widget_class->destructor(widget);
TXT_DestroyCallbackTable(widget->callback_table);
free(widget);
}
int TXT_WidgetKeyPress(UNCAST(widget), int key)
int TXT_WidgetKeyPress(TXT_UNCAST_ARG(widget), int key)
{
CAST(txt_widget_t, widget);
TXT_CAST_ARG(txt_widget_t, widget);
if (widget->widget_class->key_press != NULL)
{

View file

@ -27,18 +27,18 @@
#ifndef TXT_WIDGET_H
#define TXT_WIDGET_H
#define UNCAST(name) void *uncast_ ## name
#define CAST(type, name) type *name = (type *) uncast_ ## name
#define TXT_UNCAST_ARG(name) void *uncast_ ## name
#define TXT_CAST_ARG(type, name) type *name = (type *) uncast_ ## name
typedef struct txt_widget_class_s txt_widget_class_t;
typedef struct txt_widget_s txt_widget_t;
typedef struct txt_callback_table_s txt_callback_table_t;
typedef void (*TxtWidgetSizeCalc)(UNCAST(widget), int *w, int *h);
typedef void (*TxtWidgetDrawer)(UNCAST(widget), int w, int selected);
typedef void (*TxtWidgetDestroy)(UNCAST(widget));
typedef int (*TxtWidgetKeyPress)(UNCAST(widget), int key);
typedef void (*TxtWidgetSignalFunc)(UNCAST(widget), void *user_data);
typedef void (*TxtWidgetSizeCalc)(TXT_UNCAST_ARG(widget), int *w, int *h);
typedef void (*TxtWidgetDrawer)(TXT_UNCAST_ARG(widget), int w, int selected);
typedef void (*TxtWidgetDestroy)(TXT_UNCAST_ARG(widget));
typedef int (*TxtWidgetKeyPress)(TXT_UNCAST_ARG(widget), int key);
typedef void (*TxtWidgetSignalFunc)(TXT_UNCAST_ARG(widget), void *user_data);
struct txt_widget_class_s
{
@ -56,14 +56,14 @@ struct txt_widget_s
int visible;
};
void TXT_InitWidget(UNCAST(widget), txt_widget_class_t *widget_class);
void TXT_CalcWidgetSize(UNCAST(widget), int *w, int *h);
void TXT_DrawWidget(UNCAST(widget), int w, int selected);
void TXT_SignalConnect(UNCAST(widget), char *signal_name,
void TXT_InitWidget(TXT_UNCAST_ARG(widget), txt_widget_class_t *widget_class);
void TXT_CalcWidgetSize(TXT_UNCAST_ARG(widget), int *w, int *h);
void TXT_DrawWidget(TXT_UNCAST_ARG(widget), int w, int selected);
void TXT_SignalConnect(TXT_UNCAST_ARG(widget), char *signal_name,
TxtWidgetSignalFunc func, void *user_data);
void TXT_EmitSignal(UNCAST(widget), char *signal_name);
int TXT_WidgetKeyPress(UNCAST(widget), int key);
void TXT_DestroyWidget(UNCAST(widget));
void TXT_EmitSignal(TXT_UNCAST_ARG(widget), char *signal_name);
int TXT_WidgetKeyPress(TXT_UNCAST_ARG(widget), int key);
void TXT_DestroyWidget(TXT_UNCAST_ARG(widget));
#endif /* #ifndef TXT_WIDGET_H */