ref: 02f4a0dcf492d3e86194ae39a59a286bfc2f3e32
parent: e9619f83e977041676e766920178db827ddddb3d
author: Simon Howard <[email protected]>
date: Fri Jun 2 15:45:41 EDT 2006
Add utility functions to create "Abort" and "Accept" window actions Subversion-branch: /trunk/chocolate-doom Subversion-revision: 551
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -37,13 +37,6 @@
window->actions[position] = action;
}
-static void DefaultCancelAction(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window))
-{
- TXT_CAST_ARG(txt_window_t, window);
-
- TXT_CloseWindow(window);
-}
-
txt_window_t *TXT_NewWindow(char *title)
{
int i;
@@ -79,11 +72,8 @@
// Default actions
- cancel_action = TXT_NewWindowAction(KEY_ESCAPE, "Abort");
- TXT_SetWindowAction(win, TXT_HORIZ_LEFT, cancel_action);
- TXT_SignalConnect(cancel_action, "pressed", DefaultCancelAction, win);
- accept_action = TXT_NewWindowAction(KEY_ENTER, "Accept");
- TXT_SetWindowAction(win, TXT_HORIZ_RIGHT, accept_action);
+ TXT_SetWindowAction(win, TXT_HORIZ_LEFT, TXT_NewWindowEscapeAction(win));
+ TXT_SetWindowAction(win, TXT_HORIZ_RIGHT, TXT_NewWindowAcceptAction());
return win;
}
--- a/textscreen/txt_window_action.c
+++ b/textscreen/txt_window_action.c
@@ -79,3 +79,25 @@
return action;
}
+static void WindowCloseCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window))
+{
+ TXT_CAST_ARG(txt_window_t, window);
+
+ TXT_CloseWindow(window);
+}
+
+txt_window_action_t *TXT_NewWindowEscapeAction(txt_window_t *window)
+{
+ txt_window_action_t *action;
+
+ action = TXT_NewWindowAction(KEY_ESCAPE, "Abort");
+ TXT_SignalConnect(action, "pressed", WindowCloseCallback, window);
+
+ return action;
+}
+
+txt_window_action_t *TXT_NewWindowAcceptAction(void)
+{
+ return TXT_NewWindowAction(KEY_ENTER, "Accept");
+}
+
--- a/textscreen/txt_window_action.h
+++ b/textscreen/txt_window_action.h
@@ -28,6 +28,7 @@
typedef struct txt_window_action_s txt_window_action_t;
#include "txt_widget.h"
+#include "txt_window.h"
struct txt_window_action_s
{
@@ -37,6 +38,14 @@
};
txt_window_action_t *TXT_NewWindowAction(int key, char *label);
+
+// Creates an "escape" button that closes the window
+
+txt_window_action_t *TXT_NewWindowEscapeAction(txt_window_t *window);
+
+// Accept button that does nothing
+
+txt_window_action_t *TXT_NewWindowAcceptAction(void);
#endif /* #ifndef TXT_WINDOW_ACTION_H */