summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-06-02 19:45:41 +0000
committerSimon Howard2006-06-02 19:45:41 +0000
commit02f4a0dcf492d3e86194ae39a59a286bfc2f3e32 (patch)
tree71c80be5f3ff2db5444e4150e927ef2f52090359
parente9619f83e977041676e766920178db827ddddb3d (diff)
downloadchocolate-doom-02f4a0dcf492d3e86194ae39a59a286bfc2f3e32.tar.gz
chocolate-doom-02f4a0dcf492d3e86194ae39a59a286bfc2f3e32.tar.bz2
chocolate-doom-02f4a0dcf492d3e86194ae39a59a286bfc2f3e32.zip
Add utility functions to create "Abort" and "Accept" window actions
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 551
-rw-r--r--textscreen/txt_window.c14
-rw-r--r--textscreen/txt_window_action.c22
-rw-r--r--textscreen/txt_window_action.h9
3 files changed, 33 insertions, 12 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c
index 53813a02..0cc46308 100644
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -37,13 +37,6 @@ void TXT_SetWindowAction(txt_window_t *window,
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 @@ txt_window_t *TXT_NewWindow(char *title)
// 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;
}
diff --git a/textscreen/txt_window_action.c b/textscreen/txt_window_action.c
index d7b82f68..727e9b56 100644
--- a/textscreen/txt_window_action.c
+++ b/textscreen/txt_window_action.c
@@ -79,3 +79,25 @@ txt_window_action_t *TXT_NewWindowAction(int key, char *label)
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");
+}
+
diff --git a/textscreen/txt_window_action.h b/textscreen/txt_window_action.h
index d4194ddd..2310547f 100644
--- 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
{
@@ -38,5 +39,13 @@ struct txt_window_action_s
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 */