diff options
author | Simon Howard | 2006-05-22 00:56:12 +0000 |
---|---|---|
committer | Simon Howard | 2006-05-22 00:56:12 +0000 |
commit | 11643c088751a2d3797467463bce4476d3b03292 (patch) | |
tree | 3647ce861bdd91ce90a1fecf02c9d31d8540a9cc /textscreen/txt_button.c | |
parent | 8d188ff3d11c199621c56275d4fd6730d6f63c1b (diff) | |
download | chocolate-doom-11643c088751a2d3797467463bce4476d3b03292.tar.gz chocolate-doom-11643c088751a2d3797467463bce4476d3b03292.tar.bz2 chocolate-doom-11643c088751a2d3797467463bce4476d3b03292.zip |
Add casting macros to allow for easy casts between types.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 503
Diffstat (limited to 'textscreen/txt_button.c')
-rw-r--r-- | textscreen/txt_button.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/textscreen/txt_button.c b/textscreen/txt_button.c index e20f462d..d7dbe143 100644 --- a/textscreen/txt_button.c +++ b/textscreen/txt_button.c @@ -6,12 +6,11 @@ #include "txt_button.h" #include "txt_io.h" #include "txt_main.h" -#include "txt_widget.h" #include "txt_window.h" -static void TXT_ButtonSizeCalc(txt_widget_t *widget, int *w, int *h) +static void TXT_ButtonSizeCalc(UNCAST(button), int *w, int *h) { - txt_button_t *button = (txt_button_t *) widget; + CAST(txt_button_t, button); // Minimum width is the string length + two spaces for padding @@ -19,9 +18,9 @@ static void TXT_ButtonSizeCalc(txt_widget_t *widget, int *w, int *h) *h = 1; } -static void TXT_ButtonDrawer(txt_widget_t *widget, int w, int selected) +static void TXT_ButtonDrawer(UNCAST(button), int w, int selected) { - txt_button_t *button = (txt_button_t *) widget; + CAST(txt_button_t, button); int i; TXT_BGColor(TXT_COLOR_BLUE, 0); @@ -41,18 +40,20 @@ static void TXT_ButtonDrawer(txt_widget_t *widget, int w, int selected) } } -static void TXT_ButtonDestructor(txt_widget_t *widget) +static void TXT_ButtonDestructor(UNCAST(button)) { - txt_button_t *button = (txt_button_t *) widget; + CAST(txt_button_t, button); free(button->label); } -static int TXT_ButtonKeyPress(txt_widget_t *widget, int key) +static int TXT_ButtonKeyPress(UNCAST(button), int key) { + CAST(txt_button_t, button); + if (key == KEY_ENTER) { - TXT_EmitSignal(widget, "pressed"); + TXT_EmitSignal(button, "pressed"); } return 0; |