summaryrefslogtreecommitdiff
path: root/textscreen/txt_window.h
diff options
context:
space:
mode:
authorSimon Howard2006-08-31 18:11:26 +0000
committerSimon Howard2006-08-31 18:11:26 +0000
commit5e303c43dab6c433bc3b59dd34d4672317c5f4e1 (patch)
treef91ec9f4efeba2ed6cd4bb14503bf1f76340bbae /textscreen/txt_window.h
parentb20f94345cd4eb779acf08f3017d02d56aaad9a6 (diff)
downloadchocolate-doom-5e303c43dab6c433bc3b59dd34d4672317c5f4e1.tar.gz
chocolate-doom-5e303c43dab6c433bc3b59dd34d4672317c5f4e1.tar.bz2
chocolate-doom-5e303c43dab6c433bc3b59dd34d4672317c5f4e1.zip
Add window listener functions to allow spying on keys and mouse buttons
received by windows. Emit a 'closed' signal when a window is closed. Allow windows to have no action buttons. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 576
Diffstat (limited to 'textscreen/txt_window.h')
-rw-r--r--textscreen/txt_window.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h
index 5e01a16d..a71307ae 100644
--- a/textscreen/txt_window.h
+++ b/textscreen/txt_window.h
@@ -31,6 +31,13 @@ typedef struct txt_window_s txt_window_t;
#include "txt_table.h"
#include "txt_window_action.h"
+// Callback function for window key presses
+
+typedef int (*TxtWindowKeyPress)(txt_window_t *window, int key, void *user_data);
+typedef int (*TxtWindowMousePress)(txt_window_t *window,
+ int x, int y, int b,
+ void *user_data);
+
struct txt_window_s
{
// Base class: all windows are tables with one column.
@@ -51,6 +58,13 @@ struct txt_window_s
txt_window_action_t *actions[3];
+ // Callback functions to invoke when keys/mouse buttons are pressed
+
+ TxtWindowKeyPress key_listener;
+ void *key_listener_data;
+ TxtWindowMousePress mouse_listener;
+ void *mouse_listener_data;
+
// These are set automatically when the window is drawn
int window_x, window_y;
@@ -65,6 +79,12 @@ void TXT_SetWindowPosition(txt_window_t *window,
int x, int y);
void TXT_SetWindowAction(txt_window_t *window, txt_horiz_align_t position,
txt_window_action_t *action);
+void TXT_SetKeyListener(txt_window_t *window,
+ TxtWindowKeyPress key_listener,
+ void *user_data);
+void TXT_SetMouseListener(txt_window_t *window,
+ TxtWindowMousePress mouse_listener,
+ void *user_data);
#endif /* #ifndef TXT_WINDOW_T */